From b16a30677f4e641329e768272cf9d3ecc2fa31c4 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 8 Aug 2018 14:28:26 +0200 Subject: Moved compile-fail tests to ui tests. --- src/test/compile-fail/.gitattributes | 1 - src/test/compile-fail/E0501.rs | 38 -- src/test/compile-fail/E0506.rs | 25 - src/test/compile-fail/E0508.rs | 20 - src/test/compile-fail/E0583.rs | 14 - src/test/compile-fail/E0594.rs | 19 - src/test/compile-fail/E0596.rs | 18 - .../absolute-paths-in-nested-use-groups.rs | 21 - src/test/compile-fail/access-mode-in-closures.rs | 21 - .../alloc-error-handler-bad-signature-1.rs | 28 - .../alloc-error-handler-bad-signature-2.rs | 27 - .../alloc-error-handler-bad-signature-3.rs | 25 - .../allocator/auxiliary/system-allocator.rs | 18 - .../allocator/auxiliary/system-allocator2.rs | 18 - .../compile-fail/allocator/function-allocator.rs | 15 - .../compile-fail/allocator/not-an-allocator.rs | 18 - src/test/compile-fail/allocator/two-allocators.rs | 20 - src/test/compile-fail/allocator/two-allocators2.rs | 23 - src/test/compile-fail/allocator/two-allocators3.rs | 20 - src/test/compile-fail/anon-params-deprecated.rs | 25 - src/test/compile-fail/arg-count-mismatch.rs | 15 - src/test/compile-fail/arg-type-mismatch.rs | 16 - src/test/compile-fail/array-not-vector.rs | 24 - src/test/compile-fail/array_const_index-0.rs | 18 - src/test/compile-fail/array_const_index-1.rs | 18 - src/test/compile-fail/asm-bad-clobber.rs | 35 - src/test/compile-fail/asm-in-bad-modifier.rs | 44 -- src/test/compile-fail/asm-misplaced-option.rs | 47 -- src/test/compile-fail/asm-out-no-modifier.rs | 41 -- src/test/compile-fail/asm-out-read-uninit.rs | 46 -- src/test/compile-fail/asm-src-loc-codegen-units.rs | 22 - src/test/compile-fail/asm-src-loc.rs | 19 - src/test/compile-fail/assign-imm-local-twice.rs | 28 - src/test/compile-fail/assign-to-method.rs | 31 - .../assignment-operator-unimplemented.rs | 17 - src/test/compile-fail/assoc-inherent.rs | 19 - .../associated-const-ambiguity-report.rs | 32 - .../compile-fail/associated-const-array-len.rs | 21 - .../compile-fail/associated-const-dead-code.rs | 22 - .../associated-const-generic-obligations.rs | 29 - src/test/compile-fail/associated-const-in-trait.rs | 24 - src/test/compile-fail/associated-const-no-item.rs | 21 - .../compile-fail/associated-const-private-impl.rs | 26 - .../associated-const-type-parameter-arms.rs | 40 -- .../associated-const-type-parameter-arrays-2.rs | 32 - .../associated-const-type-parameter-arrays.rs | 32 - .../associated-const-upper-case-lint.rs | 21 - .../associated-item-duplicate-names-2.rs | 19 - .../associated-item-duplicate-names-3.rs | 28 - .../associated-item-duplicate-names.rs | 29 - src/test/compile-fail/associated-path-shl.rs | 20 - ...jection-ambig-between-bound-and-where-clause.rs | 52 -- .../associated-type-projection-from-supertrait.rs | 54 -- ...-types-binding-to-type-defined-in-supertrait.rs | 51 -- .../compile-fail/associated-types-bound-failure.rs | 37 -- .../associated-types-coherence-failure.rs | 59 -- src/test/compile-fail/associated-types-eq-1.rs | 23 - src/test/compile-fail/associated-types-eq-2.rs | 29 - src/test/compile-fail/associated-types-eq-3.rs | 54 -- .../compile-fail/associated-types-eq-expr-path.rs | 26 - src/test/compile-fail/associated-types-eq-hr.rs | 109 --- .../associated-types-for-unimpl-trait.rs | 22 - .../associated-types-incomplete-object.rs | 42 -- ...sociated-types-invalid-trait-ref-issue-18865.rs | 24 - .../compile-fail/associated-types-issue-17359.rs | 20 - .../compile-fail/associated-types-issue-20346.rs | 45 -- .../associated-types-multiple-types-one-trait.rs | 56 -- .../associated-types-no-suitable-bound.rs | 26 - .../associated-types-no-suitable-supertrait-2.rs | 31 - .../associated-types-no-suitable-supertrait.rs | 36 - src/test/compile-fail/associated-types-outlives.rs | 38 -- .../associated-types-overridden-default.rs | 25 - src/test/compile-fail/associated-types-path-1.rs | 23 - src/test/compile-fail/associated-types-path-2.rs | 56 -- ...ssociated-types-project-from-hrtb-in-fn-body.rs | 36 - .../associated-types-project-from-hrtb-in-fn.rs | 45 -- ...associated-types-project-from-hrtb-in-struct.rs | 35 - ...ated-types-project-from-hrtb-in-trait-method.rs | 33 - ...to-unrelated-trait-in-method-without-default.rs | 39 -- .../compile-fail/associated-types-subtyping-1.rs | 55 -- .../compile-fail/associated-types-unconstrained.rs | 26 - src/test/compile-fail/associated-types-unsized.rs | 21 - .../associated-types/bound-lifetime-constrained.rs | 58 -- .../bound-lifetime-in-binding-only.rs | 81 --- .../bound-lifetime-in-return-only.rs | 59 -- .../associated-types/cache/chrono-scan.rs | 39 -- .../compile-fail/associated-types/cache/elision.rs | 34 - .../cache/project-fn-ret-contravariant.rs | 62 -- .../cache/project-fn-ret-invariant.rs | 70 -- .../associated-types/higher-ranked-projection.rs | 38 -- .../compile-fail/associated-types/issue-36499.rs | 15 - .../compile-fail/attempted-access-non-fatal.rs | 16 - src/test/compile-fail/attr-bad-crate-attr.rc | 14 - src/test/compile-fail/attr-usage-inline.rs | 19 - .../attrs-with-no-formal-in-generics-1.rs | 25 - .../attrs-with-no-formal-in-generics-2.rs | 22 - .../attrs-with-no-formal-in-generics-3.rs | 26 - src/test/compile-fail/auto-ref-slice-plus-ref.rs | 38 -- src/test/compile-fail/auto-trait-validation.rs | 19 - src/test/compile-fail/autoderef-full-lval.rs | 35 - .../compile-fail/auxiliary/ambig_impl_2_lib.rs | 14 - src/test/compile-fail/auxiliary/cci_class.rs | 24 - src/test/compile-fail/auxiliary/cci_class_5.rs | 27 - src/test/compile-fail/auxiliary/cdylib-dep.rs | 11 - .../auxiliary/coherence_copy_like_lib.rs | 20 - .../auxiliary/coherence_inherent_cc_lib.rs | 21 - src/test/compile-fail/auxiliary/coherence_lib.rs | 25 - .../compile-fail/auxiliary/coherence_orphan_lib.rs | 13 - src/test/compile-fail/auxiliary/const_fn_lib.rs | 16 - src/test/compile-fail/auxiliary/crate_a1.rs | 21 - src/test/compile-fail/auxiliary/crate_a2.rs | 17 - src/test/compile-fail/auxiliary/crateresolve1-1.rs | 15 - src/test/compile-fail/auxiliary/crateresolve1-2.rs | 15 - src/test/compile-fail/auxiliary/crateresolve1-3.rs | 15 - .../default_ty_param_cross_crate_crate.rs | 20 - src/test/compile-fail/auxiliary/define_macro.rs | 16 - .../compile-fail/auxiliary/deprecation-lint.rs | 108 --- .../auxiliary/edition-extern-crate-allowed.rs | 11 - src/test/compile-fail/auxiliary/empty-struct.rs | 19 - src/test/compile-fail/auxiliary/extern-statics.rs | 14 - src/test/compile-fail/auxiliary/go_trait.rs | 53 -- .../compile-fail/auxiliary/import_crate_var.rs | 17 - .../compile-fail/auxiliary/inherited_stability.rs | 56 -- .../compile-fail/auxiliary/internal_unstable.rs | 102 --- src/test/compile-fail/auxiliary/issue-19163.rs | 16 - src/test/compile-fail/auxiliary/issue-21146-inc.rs | 13 - src/test/compile-fail/auxiliary/issue-29181.rs | 15 - src/test/compile-fail/auxiliary/issue-30535.rs | 15 - src/test/compile-fail/auxiliary/issue-36881-aux.rs | 11 - src/test/compile-fail/auxiliary/issue-52489.rs | 13 - src/test/compile-fail/auxiliary/issue_11680.rs | 19 - src/test/compile-fail/auxiliary/issue_16725.rs | 13 - .../auxiliary/issue_17718_const_privacy.rs | 18 - src/test/compile-fail/auxiliary/issue_1920.rs | 14 - src/test/compile-fail/auxiliary/issue_21202.rs | 16 - src/test/compile-fail/auxiliary/issue_30123_aux.rs | 33 - src/test/compile-fail/auxiliary/issue_41549.rs | 14 - src/test/compile-fail/auxiliary/issue_5844_aux.rs | 13 - .../lifetime_bound_will_change_warning_lib.rs | 21 - .../compile-fail/auxiliary/lint_output_format.rs | 30 - src/test/compile-fail/auxiliary/lint_stability.rs | 198 ------ .../auxiliary/lint_stability_fields.rs | 61 -- .../auxiliary/lint_unused_extern_crate.rs | 11 - .../auxiliary/lint_unused_extern_crate2.rs | 11 - .../auxiliary/lint_unused_extern_crate3.rs | 11 - .../auxiliary/lint_unused_extern_crate4.rs | 9 - .../auxiliary/lint_unused_extern_crate5.rs | 9 - .../auxiliary/lto-duplicate-symbols1.rs | 16 - .../auxiliary/lto-duplicate-symbols2.rs | 16 - .../auxiliary/macro_crate_nonterminal.rs | 22 - src/test/compile-fail/auxiliary/namespace-mix.rs | 76 --- .../compile-fail/auxiliary/namespaced_enums.rs | 20 - src/test/compile-fail/auxiliary/noexporttypelib.rs | 12 - .../auxiliary/orphan_check_diagnostics.rs | 11 - .../compile-fail/auxiliary/privacy_tuple_struct.rs | 14 - .../auxiliary/private-inferred-type.rs | 46 -- .../compile-fail/auxiliary/private_trait_xc.rs | 11 - .../auxiliary/rbmtp_cross_crate_lib.rs | 42 -- .../compile-fail/auxiliary/recursive_reexports.rs | 13 - src/test/compile-fail/auxiliary/rmeta_meta.rs | 18 - src/test/compile-fail/auxiliary/rmeta_rlib.rs | 15 - src/test/compile-fail/auxiliary/some-panic-impl.rs | 22 - .../auxiliary/stability_attribute_issue.rs | 19 - src/test/compile-fail/auxiliary/stability_cfg1.rs | 13 - src/test/compile-fail/auxiliary/stability_cfg2.rs | 15 - .../auxiliary/static_priv_by_default.rs | 61 -- .../compile-fail/auxiliary/struct_field_privacy.rs | 19 - .../auxiliary/struct_variant_privacy.rs | 13 - .../compile-fail/auxiliary/tdticc_coherence_lib.rs | 16 - .../trait_bounds_on_structs_and_enums_xc.rs | 23 - .../compile-fail/auxiliary/trait_impl_conflict.rs | 16 - .../compile-fail/auxiliary/trait_safety_lib.rs | 19 - .../auxiliary/trait_superkinds_in_metadata.rs | 18 - src/test/compile-fail/auxiliary/two_macros.rs | 15 - .../compile-fail/auxiliary/unreachable_variant.rs | 15 - src/test/compile-fail/auxiliary/unstable-macros.rs | 16 - .../compile-fail/auxiliary/use_from_trait_xc.rs | 40 -- .../compile-fail/auxiliary/variant-namespacing.rs | 15 - src/test/compile-fail/auxiliary/weak-lang-items.rs | 32 - .../auxiliary/xc_private_method_lib.rs | 43 -- .../compile-fail/auxiliary/xcrate_unit_struct.rs | 38 -- src/test/compile-fail/bad-const-type.rs | 16 - src/test/compile-fail/bad-env-capture.rs | 16 - src/test/compile-fail/bad-env-capture2.rs | 15 - src/test/compile-fail/bad-env-capture3.rs | 18 - src/test/compile-fail/bad-expr-lhs.rs | 20 - src/test/compile-fail/bad-expr-path.rs | 18 - src/test/compile-fail/bad-expr-path2.rs | 20 - src/test/compile-fail/bad-extern-link-attrs.rs | 17 - .../compile-fail/bad-intrinsic-monomorphization.rs | 40 -- src/test/compile-fail/bad-lint-cap.rs | 14 - src/test/compile-fail/bad-lint-cap2.rs | 18 - src/test/compile-fail/bad-lint-cap3.rs | 21 - src/test/compile-fail/bad-main.rs | 11 - src/test/compile-fail/bad-method-typaram-kind.rs | 24 - src/test/compile-fail/bad-mid-path-type-params.rs | 53 -- src/test/compile-fail/bad-module.rs | 17 - src/test/compile-fail/bad-sized.rs | 18 - src/test/compile-fail/bad-type-env-capture.rs | 14 - ...-neither-can-live-while-the-other-survives-2.rs | 25 - ...-neither-can-live-while-the-other-survives-3.rs | 28 - ...-neither-can-live-while-the-other-survives-4.rs | 25 - src/test/compile-fail/bind-by-move-no-guards.rs | 23 - src/test/compile-fail/binop-bitxor-str.rs | 13 - src/test/compile-fail/binop-consume-args.rs | 75 --- src/test/compile-fail/binop-logic-float.rs | 14 - src/test/compile-fail/binop-logic-int.rs | 13 - src/test/compile-fail/binop-move-semantics.rs | 75 --- src/test/compile-fail/binop-mul-bool.rs | 13 - src/test/compile-fail/binop-typeck.rs | 18 - .../compile-fail/blind-item-block-item-shadow.rs | 19 - src/test/compile-fail/blind-item-block-middle.rs | 17 - .../borrow-immutable-upvar-mutation.rs | 45 -- src/test/compile-fail/borrow-tuple-fields.rs | 42 -- .../borrowck/borrowck-access-permissions.rs | 70 -- .../compile-fail/borrowck/borrowck-and-init.rs | 16 - .../borrowck/borrowck-anon-fields-struct.rs | 47 -- .../borrowck/borrowck-anon-fields-tuple.rs | 45 -- .../borrowck/borrowck-anon-fields-variant.rs | 53 -- .../compile-fail/borrowck/borrowck-argument.rs | 43 -- src/test/compile-fail/borrowck/borrowck-asm.rs | 102 --- .../borrowck/borrowck-assign-comp-idx.rs | 49 -- .../compile-fail/borrowck/borrowck-assign-comp.rs | 52 -- .../borrowck-assign-to-andmut-in-aliasable-loc.rs | 30 - .../borrowck-assign-to-andmut-in-borrowed-loc.rs | 31 - .../borrowck/borrowck-assign-to-constants.rs | 20 - .../borrowck/borrowck-auto-mut-ref-to-immut-var.rs | 26 - .../compile-fail/borrowck/borrowck-autoref-3261.rs | 34 - .../borrowck/borrowck-bad-nested-calls-free.rs | 45 -- .../borrowck/borrowck-bad-nested-calls-move.rs | 45 -- .../compile-fail/borrowck/borrowck-block-unint.rs | 17 - .../borrowck/borrowck-borrow-from-owned-ptr.rs | 144 ---- .../borrowck-borrow-from-stack-variable.rs | 141 ---- .../borrowck/borrowck-borrow-from-temporary.rs | 24 - .../borrowck-borrow-immut-deref-of-box-as-mut.rs | 24 - ...orrowck-borrow-mut-base-ptr-in-aliasable-loc.rs | 34 - .../borrowck/borrowck-borrow-mut-object-twice.rs | 24 - .../borrowck-borrow-overloaded-auto-deref.rs | 124 ---- .../borrowck/borrowck-borrow-overloaded-deref.rs | 64 -- .../borrowck/borrowck-borrowed-uniq-rvalue-2.rs | 34 - .../borrowck/borrowck-borrowed-uniq-rvalue.rs | 25 - .../borrowck/borrowck-break-uninit-2.rs | 24 - .../compile-fail/borrowck/borrowck-break-uninit.rs | 24 - .../borrowck/borrowck-closures-mut-and-imm.rs | 101 --- .../borrowck/borrowck-closures-mut-of-imm.rs | 31 - .../borrowck/borrowck-closures-two-mut.rs | 60 -- .../borrowck/borrowck-closures-unique-imm.rs | 24 - .../borrowck/borrowck-closures-unique.rs | 50 -- .../borrowck/borrowck-closures-use-after-free.rs | 33 - .../borrowck/borrowck-consume-unsize-vec.rs | 22 - .../borrowck/borrowck-consume-upcast-box.rs | 24 - .../borrowck/borrowck-describe-lvalue.rs | 324 --------- .../borrowck/borrowck-drop-from-guard.rs | 24 - .../borrowck/borrowck-field-sensitivity.rs | 126 ---- .../borrowck/borrowck-fn-in-const-a.rs | 26 - .../borrowck/borrowck-fn-in-const-c.rs | 33 - .../borrowck-for-loop-correct-cmt-for-pattern.rs | 34 - .../borrowck/borrowck-for-loop-head-linkage.rs | 20 - .../compile-fail/borrowck/borrowck-if-no-else.rs | 16 - .../compile-fail/borrowck/borrowck-if-with-else.rs | 21 - ...rrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs | 24 - .../borrowck/borrowck-init-in-called-fn-expr.rs | 17 - .../borrowck/borrowck-init-in-fn-expr.rs | 17 - .../compile-fail/borrowck/borrowck-init-in-fru.rs | 26 - .../borrowck/borrowck-init-op-equal.rs | 19 - .../borrowck/borrowck-init-plus-equal.rs | 18 - .../borrowck/borrowck-insert-during-each.rs | 35 - .../compile-fail/borrowck/borrowck-issue-14498.rs | 132 ---- .../compile-fail/borrowck/borrowck-issue-2657-1.rs | 21 - .../compile-fail/borrowck/borrowck-issue-2657-2.rs | 21 - .../compile-fail/borrowck/borrowck-issue-48962.rs | 38 -- .../compile-fail/borrowck/borrowck-lend-flow-if.rs | 54 -- .../borrowck/borrowck-lend-flow-loop.rs | 150 ----- .../borrowck/borrowck-lend-flow-match.rs | 36 - .../compile-fail/borrowck/borrowck-lend-flow.rs | 45 -- .../borrowck/borrowck-loan-blocks-move-cc.rs | 38 -- .../borrowck/borrowck-loan-blocks-move.rs | 23 - .../borrowck/borrowck-loan-blocks-mut-uniq.rs | 28 - .../borrowck/borrowck-loan-in-overloaded-op.rs | 33 - .../borrowck-loan-of-static-data-issue-27616.rs | 34 - .../borrowck/borrowck-loan-rcvr-overloaded-op.rs | 56 -- .../compile-fail/borrowck/borrowck-loan-rcvr.rs | 51 -- .../borrowck/borrowck-loan-vec-content.rs | 34 - .../borrowck/borrowck-local-borrow-outlives-fn.rs | 20 - ...borrowck-local-borrow-with-panic-outlives-fn.rs | 24 - .../borrowck/borrowck-match-already-borrowed.rs | 42 -- .../borrowck-match-binding-is-assignment.rs | 59 -- .../borrowck/borrowck-move-by-capture.rs | 21 - .../borrowck-move-from-subpath-of-borrowed-path.rs | 21 - .../borrowck/borrowck-move-from-unsafe-ptr.rs | 18 - .../borrowck/borrowck-move-in-irrefut-pat.rs | 32 - .../borrowck-move-moved-value-into-closure.rs | 26 - .../borrowck/borrowck-move-mut-base-ptr.rs | 23 - .../borrowck/borrowck-move-out-from-array.rs | 31 - .../borrowck-move-out-of-overloaded-auto-deref.rs | 20 - .../borrowck-move-out-of-overloaded-deref.rs | 16 - .../borrowck/borrowck-move-out-of-static-item.rs | 30 - .../borrowck-move-out-of-struct-with-dtor.rs | 38 -- .../borrowck-move-out-of-tuple-struct-with-dtor.rs | 32 - .../borrowck/borrowck-move-subcomponent.rs | 27 - .../borrowck/borrowck-multiple-captures.rs | 65 -- .../borrowck/borrowck-mut-addr-of-imm-var.rs | 16 - .../borrowck/borrowck-mut-borrow-linear-errors.rs | 31 - .../borrowck-mut-borrow-of-mut-base-ptr.rs | 31 - .../borrowck/borrowck-mut-slice-of-imm-vec.rs | 18 - .../borrowck/borrowck-mutate-in-guard.rs | 32 - .../borrowck/borrowck-no-cycle-in-exchange-heap.rs | 30 - .../borrowck/borrowck-object-lifetime.rs | 39 -- src/test/compile-fail/borrowck/borrowck-or-init.rs | 16 - .../borrowck/borrowck-overloaded-call.rs | 88 --- ...rrowck-overloaded-index-and-overloaded-deref.rs | 50 -- .../borrowck-overloaded-index-autoderef.rs | 93 --- .../borrowck-overloaded-index-move-from-vec.rs | 32 - .../borrowck-overloaded-index-move-index.rs | 74 --- .../borrowck-overloaded-index-ref-index.rs | 75 --- .../borrowck/borrowck-partial-reinit-1.rs | 49 -- .../borrowck/borrowck-partial-reinit-2.rs | 33 - .../borrowck/borrowck-partial-reinit-3.rs | 22 - .../borrowck/borrowck-partial-reinit-4.rs | 33 - .../borrowck/borrowck-pat-reassign-binding.rs | 29 - .../borrowck/borrowck-reborrow-from-mut.rs | 106 --- .../borrowck-reborrow-from-shorter-lived-andmut.rs | 32 - .../borrowck/borrowck-ref-mut-of-imm.rs | 20 - .../borrowck-return-variable-on-stack-via-clone.rs | 20 - src/test/compile-fail/borrowck/borrowck-return.rs | 16 - .../compile-fail/borrowck/borrowck-storage-dead.rs | 37 -- .../borrowck/borrowck-struct-update-with-dtor.rs | 36 - .../borrowck/borrowck-swap-mut-base-ptr.rs | 26 - ...rowck-thread-local-static-borrow-outlives-fn.rs | 23 - .../compile-fail/borrowck/borrowck-unary-move.rs | 26 - .../borrowck/borrowck-unboxed-closures.rs | 25 - .../borrowck/borrowck-uninit-after-item.rs | 15 - .../borrowck/borrowck-uninit-field-access.rs | 46 -- .../borrowck/borrowck-uninit-in-assignop.rs | 44 -- .../borrowck/borrowck-uninit-ref-chain.rs | 53 -- src/test/compile-fail/borrowck/borrowck-uninit.rs | 16 - .../borrowck/borrowck-union-borrow-nested.rs | 36 - .../compile-fail/borrowck/borrowck-union-borrow.rs | 122 ---- .../borrowck/borrowck-union-move-assign.rs | 42 -- .../compile-fail/borrowck/borrowck-union-move.rs | 96 --- .../borrowck/borrowck-union-uninitialized.rs | 28 - .../borrowck/borrowck-uniq-via-lend.rs | 62 -- .../borrowck/borrowck-use-in-index-lvalue.rs | 24 - .../borrowck/borrowck-use-mut-borrow.rs | 96 --- .../borrowck-use-uninitialized-in-cast-trait.rs | 24 - .../borrowck/borrowck-use-uninitialized-in-cast.rs | 22 - .../borrowck/borrowck-vec-pattern-element-loan.rs | 43 -- .../borrowck/borrowck-vec-pattern-loan-from-mut.rs | 24 - .../borrowck/borrowck-vec-pattern-move-tail.rs | 29 - .../borrowck-vec-pattern-tail-element-loan.rs | 26 - .../compile-fail/borrowck/borrowck-while-break.rs | 22 - .../compile-fail/borrowck/borrowck-while-cond.rs | 14 - src/test/compile-fail/borrowck/borrowck-while.rs | 17 - .../move-in-static-initializer-issue-38520.rs | 33 - .../compile-fail/borrowck/two-phase-across-loop.rs | 34 - .../two-phase-activation-sharing-interference.rs | 79 --- .../two-phase-allow-access-during-reservation.rs | 51 -- .../two-phase-cannot-nest-mut-self-calls.rs | 31 - .../borrowck/two-phase-nonrecv-autoref.rs | 204 ------ ...two-phase-reservation-sharing-interference-2.rs | 34 - .../two-phase-reservation-sharing-interference.rs | 60 -- src/test/compile-fail/borrowck/two-phase-sneaky.rs | 27 - src/test/compile-fail/bounds-lifetime.rs | 17 - src/test/compile-fail/break-outside-loop.rs | 35 - .../builtin-superkinds-double-superkind.rs | 24 - .../compile-fail/builtin-superkinds-in-metadata.rs | 27 - .../compile-fail/builtin-superkinds-self-type.rs | 27 - src/test/compile-fail/builtin-superkinds-simple.rs | 19 - .../builtin-superkinds-typaram-not-send.rs | 18 - src/test/compile-fail/by-move-pattern-binding.rs | 32 - .../compile-fail/call-fn-never-arg-wrong-type.rs | 22 - src/test/compile-fail/can-begin-expr-check.rs | 30 - .../cannot-mutate-captured-non-mut-var.rs | 31 - src/test/compile-fail/capture1.rs | 17 - src/test/compile-fail/cast-from-nil.rs | 12 - src/test/compile-fail/cast-ptr-to-int-const.rs | 17 - src/test/compile-fail/cast-to-bare-fn.rs | 20 - src/test/compile-fail/cast-to-nil.rs | 12 - src/test/compile-fail/catch-bad-lifetime.rs | 42 -- src/test/compile-fail/catch-bad-type.rs | 28 - src/test/compile-fail/catch-in-match.rs | 15 - src/test/compile-fail/catch-in-while.rs | 15 - src/test/compile-fail/catch-maybe-bad-lifetime.rs | 49 -- src/test/compile-fail/catch-opt-init.rs | 25 - .../compile-fail/cdylib-deps-must-be-static.rs | 19 - src/test/compile-fail/cfg-arg-invalid.rs | 13 - src/test/compile-fail/cfg-attr-cfg-2.rs | 18 - src/test/compile-fail/cfg-attr-crate-2.rs | 17 - .../compile-fail/cfg-attr-invalid-predicate.rs | 12 - .../cfg-attr-unknown-attribute-macro-expansion.rs | 20 - src/test/compile-fail/cfg-empty-codemap.rs | 18 - src/test/compile-fail/cfg-in-crate-1.rs | 13 - src/test/compile-fail/cfg-non-opt-expr.rs | 22 - src/test/compile-fail/cfg_attr_path.rs | 24 - .../check-static-immutable-mut-slices.rs | 16 - .../check-static-values-constraints.rs | 123 ---- src/test/compile-fail/class-cast-to-trait.rs | 64 -- src/test/compile-fail/class-method-missing.rs | 31 - src/test/compile-fail/class-missing-self.rs | 26 - src/test/compile-fail/cleanup-rvalue-scopes-cf.rs | 43 -- ...sure-bounds-cant-promote-superkind-in-struct.rs | 21 - .../closure-bounds-static-cant-capture-borrowed.rs | 22 - src/test/compile-fail/closure-bounds-subtype.rs | 27 - .../compile-fail/closure-expected-type/README.md | 1 - .../expect-fn-supply-fn-multiple.rs | 48 -- .../closure-expected-type/expect-fn-supply-fn.rs | 68 -- .../expect-infer-var-appearing-twice.rs | 35 - ...expect-infer-var-supply-ty-with-bound-region.rs | 29 - .../expect-infer-var-supply-ty-with-free-region.rs | 29 - ...t-two-infer-vars-supply-ty-with-bound-region.rs | 29 - src/test/compile-fail/closure-no-fn-1.rs | 18 - src/test/compile-fail/closure-no-fn-2.rs | 18 - src/test/compile-fail/closure-no-fn-3.rs | 18 - .../closure-referencing-itself-issue-25954.rs | 28 - src/test/compile-fail/closure-reform-bad.rs | 22 - src/test/compile-fail/closure-wrong-kind.rs | 22 - src/test/compile-fail/closure_promotion.rs | 17 - .../compile-fail/coerce-expect-unsized-ascribed.rs | 42 -- src/test/compile-fail/coerce-mut.rs | 20 - .../compile-fail/coerce-overloaded-autoderef.rs | 49 -- src/test/compile-fail/coerce-to-bang-cast.rs | 24 - src/test/compile-fail/coerce-to-bang.rs | 89 --- src/test/compile-fail/coerce-unsafe-to-closure.rs | 14 - src/test/compile-fail/coercion-slice.rs | 18 - src/test/compile-fail/coherence-all-remote.rs | 19 - src/test/compile-fail/coherence-bigint-param.rs | 21 - ...e-blanket-conflicts-with-blanket-implemented.rs | 38 -- ...blanket-conflicts-with-blanket-unimplemented.rs | 34 - ...-blanket-conflicts-with-specific-cross-crate.rs | 29 - ...lanket-conflicts-with-specific-multidispatch.rs | 36 - ...erence-blanket-conflicts-with-specific-trait.rs | 38 -- .../coherence-blanket-conflicts-with-specific.rs | 33 - .../coherence-conflicting-negative-trait-impl.rs | 28 - src/test/compile-fail/coherence-cow.rs | 35 - .../compile-fail/coherence-cross-crate-conflict.rs | 24 - .../compile-fail/coherence-default-trait-impl.rs | 25 - .../coherence-impl-trait-for-trait-object-safe.rs | 19 - .../compile-fail/coherence-impl-trait-for-trait.rs | 27 - src/test/compile-fail/coherence-impls-send.rs | 40 -- src/test/compile-fail/coherence-impls-sized.rs | 46 -- .../coherence-inherited-assoc-ty-cycle-err.rs | 34 - .../compile-fail/coherence-lone-type-parameter.rs | 19 - .../compile-fail/coherence-negative-impls-safe.rs | 20 - .../coherence-no-direct-lifetime-dispatch.rs | 18 - src/test/compile-fail/coherence-orphan.rs | 31 - .../coherence-overlap-all-t-and-tuple.rs | 29 - .../compile-fail/coherence-overlap-messages.rs | 32 - .../compile-fail/coherence-overlapping-pairs.rs | 21 - .../coherence-pair-covered-uncovered-1.rs | 24 - .../coherence-pair-covered-uncovered.rs | 21 - .../coherence-projection-conflict-orphan.rs | 28 - .../coherence-projection-conflict-ty-param.rs | 22 - .../compile-fail/coherence-projection-conflict.rs | 27 - .../compile-fail/coherence-projection-ok-orphan.rs | 29 - src/test/compile-fail/coherence-projection-ok.rs | 28 - src/test/compile-fail/coherence-tuple-conflict.rs | 29 - src/test/compile-fail/coherence-vec-local-2.rs | 23 - src/test/compile-fail/coherence-vec-local.rs | 23 - .../coherence_copy_like_err_fundamental_struct.rs | 34 - ...herence_copy_like_err_fundamental_struct_ref.rs | 34 - ...rence_copy_like_err_fundamental_struct_tuple.rs | 30 - .../compile-fail/coherence_copy_like_err_struct.rs | 31 - .../compile-fail/coherence_copy_like_err_tuple.rs | 30 - src/test/compile-fail/coherence_inherent.rs | 45 -- src/test/compile-fail/coherence_inherent_cc.rs | 37 -- src/test/compile-fail/coherence_local.rs | 33 - .../compile-fail/coherence_local_err_struct.rs | 29 - src/test/compile-fail/coherence_local_err_tuple.rs | 29 - src/test/compile-fail/coherence_local_ref.rs | 27 - src/test/compile-fail/compile_error_macro.rs | 13 - src/test/compile-fail/concat.rs | 16 - src/test/compile-fail/conflicting-repr-hints.rs | 67 -- src/test/compile-fail/conservative_impl_trait.rs | 17 - src/test/compile-fail/const-array-oob-arith.rs | 22 - src/test/compile-fail/const-array-oob.rs | 24 - .../const-block-non-item-statement-2.rs | 28 - .../const-block-non-item-statement-3.rs | 17 - .../compile-fail/const-block-non-item-statement.rs | 19 - src/test/compile-fail/const-call.rs | 19 - .../compile-fail/const-cast-different-types.rs | 16 - src/test/compile-fail/const-cast-wrong-type.rs | 15 - src/test/compile-fail/const-err-early.rs | 26 - src/test/compile-fail/const-err-multi.rs | 27 - src/test/compile-fail/const-err.rs | 32 - src/test/compile-fail/const-err2.rs | 39 -- src/test/compile-fail/const-err3.rs | 30 - src/test/compile-fail/const-err4.rs | 24 - src/test/compile-fail/const-eval-overflow-3.rs | 38 -- src/test/compile-fail/const-eval-overflow-3b.rs | 43 -- src/test/compile-fail/const-eval-overflow-4b.rs | 39 -- src/test/compile-fail/const-eval-overflow2.rs | 83 --- src/test/compile-fail/const-eval-overflow2b.rs | 83 --- src/test/compile-fail/const-eval-overflow2c.rs | 83 --- .../compile-fail/const-fn-destructuring-arg.rs | 27 - .../compile-fail/const-fn-not-safe-for-const.rs | 51 -- .../compile-fail/const-fn-stability-calls-3.rs | 25 - src/test/compile-fail/const-integer-bool-ops.rs | 85 --- .../compile-fail/const-len-underflow-subspans.rs | 21 - src/test/compile-fail/const-match-check.rs | 43 -- src/test/compile-fail/const-match-pattern-arm.rs | 27 - src/test/compile-fail/const-size_of-cycle.rs | 19 - src/test/compile-fail/const-slice-oob.rs | 20 - src/test/compile-fail/const-tup-index-span.rs | 19 - src/test/compile-fail/const-typeid-of.rs | 18 - src/test/compile-fail/constructor-lifetime-args.rs | 36 - src/test/compile-fail/copy-a-resource.rs | 31 - src/test/compile-fail/crate-name-mismatch.rs | 16 - src/test/compile-fail/crateresolve1.rs | 19 - src/test/compile-fail/cross-borrow-trait.rs | 23 - src/test/compile-fail/cross-fn-cache-hole.rs | 41 -- src/test/compile-fail/custom_attribute.rs | 19 - .../cycle-projection-based-on-where-clause.rs | 35 - .../compile-fail/cycle-trait-default-type-trait.rs | 18 - .../compile-fail/cycle-trait-supertrait-direct.rs | 17 - src/test/compile-fail/dead-code-closure-bang.rs | 19 - src/test/compile-fail/dead-code-ret.rs | 18 - src/test/compile-fail/defaulted-never-note.rs | 45 -- .../compile-fail/dep-graph-assoc-type-codegen.rs | 47 -- src/test/compile-fail/dep-graph-caller-callee.rs | 45 -- .../compile-fail/dep-graph-struct-signature.rs | 97 --- .../dep-graph-trait-impl-two-traits-same-method.rs | 55 -- .../dep-graph-trait-impl-two-traits.rs | 54 -- src/test/compile-fail/dep-graph-trait-impl.rs | 70 -- src/test/compile-fail/dep-graph-type-alias.rs | 66 -- src/test/compile-fail/dep-graph-variance-alias.rs | 32 - src/test/compile-fail/deprecated_no_stack_check.rs | 16 - src/test/compile-fail/deprecation-in-staged-api.rs | 18 - src/test/compile-fail/deprecation-lint-2.rs | 23 - src/test/compile-fail/deprecation-lint-3.rs | 24 - src/test/compile-fail/deprecation-lint-nested.rs | 81 --- src/test/compile-fail/deprecation-lint.rs | 445 ------------- src/test/compile-fail/deref-non-pointer.rs | 15 - .../compile-fail/derive-assoc-type-not-impl.rs | 29 - .../derive-on-trait-item-or-impl-item.rs | 23 - .../compile-fail/derived-errors/issue-30580.rs | 27 - .../compile-fail/derived-errors/issue-31997.rs | 27 - .../derives-span-Clone-enum-struct-variant.rs | 23 - src/test/compile-fail/derives-span-Clone-enum.rs | 23 - src/test/compile-fail/derives-span-Clone-struct.rs | 21 - .../derives-span-Clone-tuple-struct.rs | 21 - .../derives-span-Debug-enum-struct-variant.rs | 23 - src/test/compile-fail/derives-span-Debug-enum.rs | 23 - src/test/compile-fail/derives-span-Debug-struct.rs | 21 - .../derives-span-Debug-tuple-struct.rs | 21 - .../compile-fail/derives-span-Default-struct.rs | 21 - .../derives-span-Default-tuple-struct.rs | 21 - .../derives-span-Eq-enum-struct-variant.rs | 23 - src/test/compile-fail/derives-span-Eq-enum.rs | 23 - src/test/compile-fail/derives-span-Eq-struct.rs | 21 - .../compile-fail/derives-span-Eq-tuple-struct.rs | 21 - .../derives-span-Hash-enum-struct-variant.rs | 23 - src/test/compile-fail/derives-span-Hash-enum.rs | 23 - src/test/compile-fail/derives-span-Hash-struct.rs | 21 - .../compile-fail/derives-span-Hash-tuple-struct.rs | 21 - .../derives-span-Ord-enum-struct-variant.rs | 23 - src/test/compile-fail/derives-span-Ord-enum.rs | 23 - src/test/compile-fail/derives-span-Ord-struct.rs | 21 - .../compile-fail/derives-span-Ord-tuple-struct.rs | 21 - .../derives-span-PartialEq-enum-struct-variant.rs | 24 - .../compile-fail/derives-span-PartialEq-enum.rs | 24 - .../compile-fail/derives-span-PartialEq-struct.rs | 22 - .../derives-span-PartialEq-tuple-struct.rs | 22 - .../derives-span-PartialOrd-enum-struct-variant.rs | 23 - .../compile-fail/derives-span-PartialOrd-enum.rs | 23 - .../compile-fail/derives-span-PartialOrd-struct.rs | 21 - .../derives-span-PartialOrd-tuple-struct.rs | 21 - src/test/compile-fail/deriving-bounds.rs | 19 - src/test/compile-fail/deriving-copyclone.rs | 48 -- .../compile-fail/deriving-meta-unknown-trait.rs | 17 - .../deriving-no-inner-impl-error-message.rs | 25 - src/test/compile-fail/deriving-non-type.rs | 40 -- src/test/compile-fail/deriving-primitive.rs | 15 - src/test/compile-fail/destructure-trait-ref.rs | 55 -- .../directory_ownership/foo/compiletest-ignore-dir | 0 .../foo/mod_file_not_owning/aux2.rs | 9 - .../foo/mod_file_not_owning_aux2.rs | 9 - .../directory_ownership/macro-expanded-mod.rs | 23 - .../macro_expanded_mod_helper/foo/bar.rs | 11 - .../macro_expanded_mod_helper/foo/mod.rs | 13 - .../directory_ownership/mod_file_not_owning.rs | 15 - .../mod_file_not_owning_aux1.rs | 16 - .../compiletest-ignore-dir | 0 .../mod_file_not_owning_aux2.rs | 9 - .../mod_file_not_owning_aux2.rs | 11 - .../mod_file_not_owning_aux3.rs | 13 - .../non-inline-mod-restriction.rs | 15 - .../directory_ownership/unowned_mod_with_path.rs | 15 - ...llowed-deconstructing-destructing-struct-let.rs | 30 - ...owed-deconstructing-destructing-struct-match.rs | 28 - src/test/compile-fail/discrim-ill-typed.rs | 126 ---- src/test/compile-fail/diverging-fn-tail-35849.rs | 18 - .../compile-fail/diverging-tuple-parts-39485.rs | 25 - src/test/compile-fail/does-nothing.rs | 12 - src/test/compile-fail/dollar-crate-is-keyword-2.rs | 23 - src/test/compile-fail/dollar-crate-is-keyword.rs | 28 - src/test/compile-fail/double-type-import.rs | 23 - src/test/compile-fail/drop-on-non-struct.rs | 20 - .../compile-fail/drop-with-active-borrows-1.rs | 18 - .../compile-fail/drop-with-active-borrows-2.rs | 19 - .../dropck_no_diverge_on_nonregular_1.rs | 37 -- .../dropck_no_diverge_on_nonregular_2.rs | 36 - .../dropck_no_diverge_on_nonregular_3.rs | 46 -- .../compile-fail/dropck_trait_cycle_checked.rs | 131 ---- src/test/compile-fail/dst-bad-assign-2.rs | 48 -- src/test/compile-fail/dst-bad-assign-3.rs | 49 -- src/test/compile-fail/dst-bad-assign.rs | 51 -- src/test/compile-fail/dst-bad-coerce1.rs | 46 -- src/test/compile-fail/dst-bad-coerce2.rs | 41 -- src/test/compile-fail/dst-bad-coerce3.rs | 47 -- src/test/compile-fail/dst-bad-coerce4.rs | 35 - src/test/compile-fail/dst-bad-coercions.rs | 36 - src/test/compile-fail/dst-bad-deep-2.rs | 23 - src/test/compile-fail/dst-bad-deep.rs | 25 - src/test/compile-fail/dst-index.rs | 47 -- .../compile-fail/dst-object-from-unsized-type.rs | 37 -- src/test/compile-fail/dst-rvalue.rs | 24 - src/test/compile-fail/dst-sized-trait-param.rs | 23 - src/test/compile-fail/dupe-symbols-1.rs | 21 - src/test/compile-fail/dupe-symbols-2.rs | 25 - src/test/compile-fail/dupe-symbols-3.rs | 21 - src/test/compile-fail/dupe-symbols-4.rs | 31 - src/test/compile-fail/dupe-symbols-5.rs | 20 - src/test/compile-fail/dupe-symbols-6.rs | 18 - src/test/compile-fail/dupe-symbols-7.rs | 15 - src/test/compile-fail/duplicate-parameter.rs | 15 - src/test/compile-fail/duplicate-type-parameter.rs | 39 -- src/test/compile-fail/duplicate_entry_error.rs | 25 - src/test/compile-fail/dyn-trait-compatibility.rs | 24 - .../compile-fail/edition-extern-crate-allowed.rs | 20 - src/test/compile-fail/edition-feature-ok.rs | 16 - .../edition-raw-pointer-method-2015.rs | 23 - .../edition-raw-pointer-method-2018.rs | 22 - src/test/compile-fail/elided-test.rs | 17 - src/test/compile-fail/empty-comment.rs | 21 - src/test/compile-fail/empty-extern-arg.rs | 14 - src/test/compile-fail/empty-linkname.rs | 15 - src/test/compile-fail/empty-macro-use.rs | 19 - src/test/compile-fail/empty-never-array.rs | 27 - src/test/compile-fail/empty-struct-braces-expr.rs | 34 - src/test/compile-fail/empty-struct-braces-pat-1.rs | 44 -- src/test/compile-fail/empty-struct-braces-pat-2.rs | 36 - src/test/compile-fail/empty-struct-braces-pat-3.rs | 42 -- src/test/compile-fail/empty-struct-tuple-pat.rs | 47 -- src/test/compile-fail/empty-struct-unit-pat.rs | 59 -- .../compile-fail/enable-unstable-lib-feature.rs | 24 - src/test/compile-fail/enum-discrim-autosizing.rs | 20 - src/test/compile-fail/enum-discrim-too-small.rs | 49 -- src/test/compile-fail/enum-discrim-too-small2.rs | 47 -- src/test/compile-fail/enum-in-scope.rs | 15 - src/test/compile-fail/enum-to-float-cast-2.rs | 28 - src/test/compile-fail/enum-to-float-cast.rs | 31 - src/test/compile-fail/enum-variant-type-2.rs | 19 - src/test/compile-fail/enums-pats-not-idents.rs | 13 - .../compile-fail/error-should-say-copy-not-pod.rs | 17 - src/test/compile-fail/estr-subtyping.rs | 25 - src/test/compile-fail/eval-enum.rs | 22 - src/test/compile-fail/exclusive-drop-and-copy.rs | 27 - .../exclusive_range_pattern_syntax_collision.rs | 18 - .../exclusive_range_pattern_syntax_collision2.rs | 18 - .../exclusive_range_pattern_syntax_collision3.rs | 18 - src/test/compile-fail/expanded-cfg.rs | 32 - src/test/compile-fail/explicit-call-to-dtor.rs | 24 - .../explicit-call-to-supertrait-dtor.rs | 33 - .../explicit-self-lifetime-mismatch.rs | 30 - src/test/compile-fail/export-fully-qualified.rs | 21 - src/test/compile-fail/export-import.rs | 21 - src/test/compile-fail/export-tag-variant.rs | 17 - src/test/compile-fail/export.rs | 20 - src/test/compile-fail/export2.rs | 21 - src/test/compile-fail/expr_attr_paren_order.rs | 34 - src/test/compile-fail/ext-nonexistent.rs | 12 - .../extenv-arg-2-not-string-literal.rs | 11 - src/test/compile-fail/extenv-no-args.rs | 11 - src/test/compile-fail/extenv-not-defined-custom.rs | 11 - .../compile-fail/extenv-not-defined-default.rs | 14 - src/test/compile-fail/extenv-not-string-literal.rs | 11 - src/test/compile-fail/extenv-too-many-args.rs | 11 - src/test/compile-fail/extern-crate-visibility.rs | 34 - src/test/compile-fail/extern-macro.rs | 18 - src/test/compile-fail/extern-main-fn.rs | 11 - .../compile-fail/extern-types-distinct-types.rs | 22 - .../compile-fail/extern-types-not-sync-send.rs | 28 - src/test/compile-fail/extern-types-unsized.rs | 43 -- src/test/compile-fail/extern-with-type-bounds.rs | 30 - src/test/compile-fail/extern-wrong-value-type.rs | 21 - src/test/compile-fail/external-doc-error.rs | 16 - src/test/compile-fail/extoption_env-no-args.rs | 11 - .../extoption_env-not-string-literal.rs | 11 - .../compile-fail/extoption_env-too-many-args.rs | 11 - src/test/compile-fail/fail-no-dead-code-core.rs | 28 - src/test/compile-fail/fail-no-dead-code.rs | 25 - src/test/compile-fail/fail-simple.rs | 13 - .../feature-gate-alloc-error-handler.rs | 21 - .../feature-gate-panic-implementation.rs | 21 - src/test/compile-fail/feature-gate-tool_lints.rs | 12 - ...eature-gate-without_gate_irrefutable_pattern.rs | 17 - .../feature-gated-feature-in-macro-arg.rs | 24 - .../float-literal-inference-restrictions.rs | 14 - src/test/compile-fail/fn-bad-block-type.rs | 15 - src/test/compile-fail/fn-compare-mismatch.rs | 17 - src/test/compile-fail/fn-item-type.rs | 43 -- src/test/compile-fail/fn-trait-formatting.rs | 31 - src/test/compile-fail/for-expn.rs | 19 - src/test/compile-fail/for-loop-bogosity.rs | 30 - .../for-loop-refutable-pattern-error-message.rs | 13 - src/test/compile-fail/for-loop-type-error.rs | 16 - .../for-loop-unconstrained-element-type.rs | 19 - .../compile-fail/foreign-fn-return-lifetime.rs | 16 - src/test/compile-fail/foreign-unsafe-fn-called.rs | 21 - .../compile-fail/fully-qualified-type-name1.rs | 20 - .../compile-fail/fully-qualified-type-name2.rs | 30 - .../compile-fail/fully-qualified-type-name3.rs | 24 - .../compile-fail/fully-qualified-type-name4.rs | 24 - .../functional-struct-update-noncopyable.rs | 24 - .../functional-struct-update-respects-privacy.rs | 42 -- .../compile-fail/future-incompatible-lint-group.rs | 18 - src/test/compile-fail/gated-attr-literals.rs | 43 -- src/test/compile-fail/gated-bad-feature.rs | 22 - .../generator-yielding-or-returning-itself.rs | 45 -- src/test/compile-fail/generic-extern-lifetime.rs | 25 - src/test/compile-fail/generic-extern.rs | 17 - .../generic-impl-less-params-with-defaults.rs | 23 - .../generic-impl-more-params-with-defaults.rs | 25 - .../compile-fail/generic-lifetime-trait-impl.rs | 33 - src/test/compile-fail/generic-no-mangle.rs | 25 - .../compile-fail/generic-non-trailing-defaults.rs | 20 - .../generic-type-params-forward-mention.rs | 16 - .../compile-fail/generic-type-params-name-repr.rs | 61 -- src/test/compile-fail/glob-cycles.rs | 29 - src/test/compile-fail/glob-resolve1.rs | 41 -- .../compile-fail/hashmap-iter-value-lifetime.rs | 20 - src/test/compile-fail/hashmap-lifetimes.rs | 17 - src/test/compile-fail/hidden-rt-injection.rs | 18 - src/test/compile-fail/hidden-rt-injection2.rs | 18 - src/test/compile-fail/hr-subtype.rs | 116 ---- src/test/compile-fail/hrtb-conflate-regions.rs | 40 -- src/test/compile-fail/hrtb-debruijn-in-receiver.rs | 28 - .../hrtb-higher-ranker-supertraits-transitive.rs | 60 -- .../compile-fail/hrtb-higher-ranker-supertraits.rs | 58 -- src/test/compile-fail/hrtb-identity-fn-borrows.rs | 40 -- src/test/compile-fail/hrtb-just-for-static.rs | 37 -- src/test/compile-fail/hrtb-perfect-forwarding.rs | 66 -- src/test/compile-fail/huge-array-simple.rs | 21 - src/test/compile-fail/huge-array.rs | 20 - src/test/compile-fail/huge-enum.rs | 23 - src/test/compile-fail/huge-struct.rs | 54 -- src/test/compile-fail/hygienic-label-1.rs | 17 - src/test/compile-fail/hygienic-label-2.rs | 17 - src/test/compile-fail/hygienic-label-3.rs | 19 - src/test/compile-fail/hygienic-label-4.rs | 17 - src/test/compile-fail/if-branch-types.rs | 15 - src/test/compile-fail/if-let.rs | 55 -- src/test/compile-fail/if-loop.rs | 20 - src/test/compile-fail/if-typeck.rs | 20 - src/test/compile-fail/if-without-else-result.rs | 18 - src/test/compile-fail/ifmt-bad-format-args.rs | 14 - src/test/compile-fail/ifmt-unimpl.rs | 14 - src/test/compile-fail/ifmt-unknown-trait.rs | 14 - src/test/compile-fail/illegal-ufcs-drop.rs | 20 - src/test/compile-fail/immut-function-arguments.rs | 24 - src/test/compile-fail/impl-bounds-checking.rs | 24 - .../impl-trait/impl-generic-mismatch-ab.rs | 22 - .../impl-trait/infinite-impl-trait-issue-38064.rs | 37 -- .../must_outlive_least_region_or_bound.rs | 37 -- .../impl-trait/needs_least_region_or_bound.rs | 21 - src/test/compile-fail/impl-trait/no-trait.rs | 13 - .../impl-trait/type_parameters_captured.rs | 22 - src/test/compile-fail/impl-trait/where-allowed.rs | 235 ------- src/test/compile-fail/impl-unused-tps-inherent.rs | 35 - src/test/compile-fail/impl-unused-tps.rs | 72 -- src/test/compile-fail/implicit-method-bind.rs | 13 - src/test/compile-fail/import-crate-var.rs | 22 - src/test/compile-fail/import-from-missing.rs | 22 - src/test/compile-fail/import-glob-0.rs | 26 - src/test/compile-fail/import-glob-circular.rs | 27 - src/test/compile-fail/import-loop-2.rs | 21 - src/test/compile-fail/import-loop.rs | 19 - src/test/compile-fail/import-prefix-macro-1.rs | 26 - src/test/compile-fail/import-prefix-macro-2.rs | 26 - src/test/compile-fail/import-trait-method.rs | 17 - src/test/compile-fail/import.rs | 25 - src/test/compile-fail/import2.rs | 20 - src/test/compile-fail/import3.rs | 14 - src/test/compile-fail/import4.rs | 17 - src/test/compile-fail/imports/reexports.rs | 42 -- src/test/compile-fail/imports/unused-macro-use.rs | 21 - src/test/compile-fail/imports/unused.rs | 37 -- src/test/compile-fail/inaccessible-test-modules.rs | 19 - src/test/compile-fail/index-bot.rs | 13 - src/test/compile-fail/index_message.rs | 14 - src/test/compile-fail/indexing-requires-a-uint.rs | 24 - src/test/compile-fail/infinite-autoderef.rs | 37 -- src/test/compile-fail/infinite-instantiation.rs | 44 -- src/test/compile-fail/infinite-macro-expansion.rs | 17 - .../compile-fail/infinite-tag-type-recursion.rs | 14 - .../compile-fail/infinite-vec-type-recursion.rs | 14 - .../compile-fail/inhabitedness-infinite-loop.rs | 26 - src/test/compile-fail/init-unsafe.rs | 18 - .../compile-fail/inner-static-type-parameter.rs | 21 - .../integer-literal-suffix-inference.rs | 172 ----- src/test/compile-fail/integral-indexing.rs | 26 - .../integral-variable-unification-error.rs | 18 - src/test/compile-fail/internal-unstable-noallow.rs | 33 - .../compile-fail/internal-unstable-thread-local.rs | 21 - src/test/compile-fail/internal-unstable.rs | 52 -- .../intrinsic-invalid-number-of-arguments.rs | 24 - src/test/compile-fail/invalid-crate-type.rs | 16 - src/test/compile-fail/invalid-inline.rs | 28 - src/test/compile-fail/invalid-macro-matcher.rs | 18 - src/test/compile-fail/invalid-plugin-attr.rs | 17 - src/test/compile-fail/invalid_crate_type_syntax.rs | 14 - src/test/compile-fail/isssue-38821.rs | 43 -- src/test/compile-fail/issue-10755.rs | 15 - src/test/compile-fail/issue-11593.rs | 20 - src/test/compile-fail/issue-11680.rs | 21 - src/test/compile-fail/issue-15919.rs | 21 - src/test/compile-fail/issue-16725.rs | 18 - src/test/compile-fail/issue-17718-const-privacy.rs | 26 - src/test/compile-fail/issue-17913.rs | 28 - src/test/compile-fail/issue-19163.rs | 21 - src/test/compile-fail/issue-1920-1.rs | 24 - src/test/compile-fail/issue-1920-2.rs | 22 - src/test/compile-fail/issue-1920-3.rs | 26 - src/test/compile-fail/issue-21146.rs | 13 - src/test/compile-fail/issue-21202.rs | 25 - src/test/compile-fail/issue-22638.rs | 69 -- src/test/compile-fail/issue-23595-1.rs | 26 - src/test/compile-fail/issue-26548.rs | 21 - src/test/compile-fail/issue-28075.rs | 23 - src/test/compile-fail/issue-28388-1.rs | 15 - src/test/compile-fail/issue-28388-2.rs | 20 - src/test/compile-fail/issue-28388-3.rs | 21 - src/test/compile-fail/issue-28625.rs | 30 - src/test/compile-fail/issue-28848.rs | 23 - src/test/compile-fail/issue-29181.rs | 17 - src/test/compile-fail/issue-30123.rs | 19 - src/test/compile-fail/issue-30535.rs | 19 - src/test/compile-fail/issue-32377.rs | 27 - src/test/compile-fail/issue-36881.rs | 17 - src/test/compile-fail/issue-37131.rs | 18 - src/test/compile-fail/issue-41549.rs | 22 - src/test/compile-fail/issue-43733-2.rs | 39 -- .../issue-46209-private-enum-variant-reexport.rs | 51 -- .../issue-50264-inner-deref-trait/option_deref.rs | 16 - .../issue-50264-inner-deref-trait/result_deref.rs | 16 - .../result_deref_err.rs | 16 - .../result_deref_ok.rs | 16 - src/test/compile-fail/issue-52489.rs | 17 - src/test/compile-fail/issue-5500-1.rs | 26 - src/test/compile-fail/issue-5844.rs | 17 - src/test/compile-fail/issue32829.rs | 94 --- .../compile-fail/keyword-extern-as-identifier.rs | 15 - .../compile-fail/keyword-false-as-identifier.rs | 13 - .../compile-fail/keyword-self-as-identifier.rs | 13 - .../compile-fail/keyword-super-as-identifier.rs | 13 - src/test/compile-fail/keyword-super.rs | 13 - .../compile-fail/keyword-true-as-identifier.rs | 13 - src/test/compile-fail/kindck-copy.rs | 81 --- src/test/compile-fail/kindck-impl-type-params-2.rs | 25 - src/test/compile-fail/kindck-impl-type-params.rs | 60 -- .../compile-fail/kindck-inherited-copy-bound.rs | 39 -- src/test/compile-fail/kindck-nonsendable-1.rs | 22 - src/test/compile-fail/kindck-send-object.rs | 36 - src/test/compile-fail/kindck-send-object1.rs | 43 -- src/test/compile-fail/kindck-send-object2.rs | 34 - src/test/compile-fail/kindck-send-owned.rs | 26 - src/test/compile-fail/kindck-send-unsafe.rs | 21 - .../kindck-send-unsafe.rs~rust-lang_master | 22 - src/test/compile-fail/label-static.rs | 15 - src/test/compile-fail/label-underscore.rs | 15 - src/test/compile-fail/lang-item-missing.rs | 22 - src/test/compile-fail/lexical-scopes.rs | 23 - .../lifetime-bound-will-change-warning.rs | 64 -- src/test/compile-fail/lifetime-no-keyword.rs | 17 - src/test/compile-fail/linkage2.rs | 20 - src/test/compile-fail/linkage3.rs | 20 - src/test/compile-fail/linkage4.rs | 15 - src/test/compile-fail/lint-attr-non-item-node.rs | 19 - src/test/compile-fail/lint-change-warnings.rs | 31 - src/test/compile-fail/lint-ctypes-enum.rs | 38 -- src/test/compile-fail/lint-dead-code-1.rs | 116 ---- src/test/compile-fail/lint-dead-code-2.rs | 51 -- src/test/compile-fail/lint-dead-code-3.rs | 88 --- src/test/compile-fail/lint-dead-code-4.rs | 93 --- src/test/compile-fail/lint-dead-code-5.rs | 40 -- src/test/compile-fail/lint-dead-code-type-alias.rs | 20 - src/test/compile-fail/lint-dead-code-variant.rs | 22 - .../lint-directives-on-use-items-issue-10534.rs | 34 - src/test/compile-fail/lint-exceeding-bitshifts.rs | 57 -- src/test/compile-fail/lint-exceeding-bitshifts2.rs | 27 - src/test/compile-fail/lint-forbid-cmdline.rs | 15 - src/test/compile-fail/lint-impl-fn.rs | 43 -- src/test/compile-fail/lint-malformed.rs | 14 - src/test/compile-fail/lint-misplaced-attr.rs | 22 - .../lint-missing-copy-implementations.rs | 25 - src/test/compile-fail/lint-missing-doc.rs | 196 ------ src/test/compile-fail/lint-non-camel-case-types.rs | 56 -- .../compile-fail/lint-non-snake-case-crate-2.rs | 16 - src/test/compile-fail/lint-non-snake-case-crate.rs | 15 - .../compile-fail/lint-non-snake-case-functions.rs | 54 -- .../compile-fail/lint-non-snake-case-lifetimes.rs | 18 - .../compile-fail/lint-non-snake-case-modules.rs | 20 - .../compile-fail/lint-non-uppercase-statics.rs | 22 - src/test/compile-fail/lint-obsolete-attr.rs | 22 - src/test/compile-fail/lint-output-format.rs | 22 - src/test/compile-fail/lint-owned-heap-memory.rs | 22 - src/test/compile-fail/lint-qualification.rs | 29 - src/test/compile-fail/lint-removed-allow.rs | 18 - src/test/compile-fail/lint-removed-cmdline.rs | 22 - src/test/compile-fail/lint-removed.rs | 18 - src/test/compile-fail/lint-renamed-allow.rs | 18 - src/test/compile-fail/lint-renamed-cmdline.rs | 18 - src/test/compile-fail/lint-renamed.rs | 14 - src/test/compile-fail/lint-shorthand-field.rs | 64 -- src/test/compile-fail/lint-stability-2.rs | 423 ------------ src/test/compile-fail/lint-stability-deprecated.rs | 473 ------------- .../lint-stability-fields-deprecated.rs | 349 ---------- src/test/compile-fail/lint-stability-fields.rs | 293 --------- src/test/compile-fail/lint-stability.rs | 464 ------------- src/test/compile-fail/lint-stability2.rs | 23 - src/test/compile-fail/lint-stability3.rs | 24 - src/test/compile-fail/lint-type-limits.rs | 37 -- src/test/compile-fail/lint-type-limits2.rs | 24 - src/test/compile-fail/lint-type-limits3.rs | 22 - src/test/compile-fail/lint-type-overflow.rs | 56 -- src/test/compile-fail/lint-type-overflow2.rs | 25 - src/test/compile-fail/lint-unexported-no-mangle.rs | 39 -- src/test/compile-fail/lint-unknown-attr.rs | 21 - .../compile-fail/lint-unknown-feature-default.rs | 20 - src/test/compile-fail/lint-unknown-feature.rs | 20 - src/test/compile-fail/lint-unknown-lint-cmdline.rs | 16 - src/test/compile-fail/lint-unknown-lint.rs | 13 - .../compile-fail/lint-unnecessary-import-braces.rs | 21 - src/test/compile-fail/lint-unnecessary-parens.rs | 55 -- src/test/compile-fail/lint-unsafe-code.rs | 99 --- src/test/compile-fail/lint-unused-extern-crate.rs | 45 -- src/test/compile-fail/lint-unused-imports.rs | 98 --- src/test/compile-fail/lint-unused-mut-self.rs | 22 - src/test/compile-fail/lint-unused-mut-variables.rs | 145 ---- src/test/compile-fail/lint-uppercase-variables.rs | 41 -- .../liveness-assign-imm-local-in-loop.rs | 27 - .../liveness-assign-imm-local-in-op-eq.rs | 27 - .../liveness-assign-imm-local-with-drop.rs | 27 - .../liveness-assign-imm-local-with-init.rs | 27 - .../compile-fail/liveness-closure-require-ret.rs | 12 - src/test/compile-fail/liveness-dead.rs | 40 -- src/test/compile-fail/liveness-forgot-ret.rs | 16 - src/test/compile-fail/liveness-issue-2163.rs | 18 - src/test/compile-fail/liveness-missing-ret2.rs | 17 - src/test/compile-fail/liveness-move-call-arg.rs | 21 - src/test/compile-fail/liveness-move-in-loop.rs | 27 - src/test/compile-fail/liveness-move-in-while.rs | 21 - src/test/compile-fail/liveness-unused.rs | 151 ----- src/test/compile-fail/liveness-use-after-move.rs | 18 - src/test/compile-fail/liveness-use-after-send.rs | 29 - src/test/compile-fail/loop-break-value.rs | 103 --- src/test/compile-fail/loop-labeled-break-value.rs | 21 - src/test/compile-fail/loop-proper-liveness.rs | 42 -- src/test/compile-fail/loop-properly-diverging-2.rs | 16 - src/test/compile-fail/lto-duplicate-symbols.rs | 20 - src/test/compile-fail/lub-if.rs | 52 -- src/test/compile-fail/lub-match.rs | 55 -- src/test/compile-fail/macro-attribute.rs | 12 - src/test/compile-fail/macro-comma-behavior.rs | 101 --- src/test/compile-fail/macro-comma-support.rs | 20 - .../macro-crate-nonterminal-non-root.rs | 19 - src/test/compile-fail/macro-error.rs | 19 - .../compile-fail/macro-expanded-include/file.txt | 0 .../compile-fail/macro-expanded-include/foo/mod.rs | 19 - .../compile-fail/macro-expanded-include/test.rs | 23 - src/test/compile-fail/macro-expansion-tests.rs | 50 -- src/test/compile-fail/macro-follow.rs | 124 ---- src/test/compile-fail/macro-followed-by-seq-bad.rs | 21 - src/test/compile-fail/macro-inner-attributes.rs | 30 - .../compile-fail/macro-input-future-proofing.rs | 33 - src/test/compile-fail/macro-local-data-key-priv.rs | 20 - src/test/compile-fail/macro-match-nonterminal.rs | 15 - src/test/compile-fail/macro-missing-delimiters.rs | 17 - src/test/compile-fail/macro-missing-fragment.rs | 17 - src/test/compile-fail/macro-non-lifetime.rs | 20 - src/test/compile-fail/macro-outer-attributes.rs | 30 - src/test/compile-fail/macro-parameter-span.rs | 23 - src/test/compile-fail/macro-stability.rs | 22 - src/test/compile-fail/macro-stmt-matchers.rs | 17 - src/test/compile-fail/macro-tt-matchers.rs | 21 - src/test/compile-fail/macro-use-bad-args-1.rs | 15 - src/test/compile-fail/macro-use-bad-args-2.rs | 15 - src/test/compile-fail/macro-use-scope.rs | 32 - src/test/compile-fail/macro-use-undef.rs | 18 - src/test/compile-fail/macro-use-wrong-name.rs | 19 - src/test/compile-fail/macro-with-seps-err-msg.rs | 15 - src/test/compile-fail/macros-in-extern.rs | 42 -- src/test/compile-fail/macros-nonfatal-errors.rs | 42 -- src/test/compile-fail/main-wrong-type.rs | 18 - src/test/compile-fail/malformed-derive-entry.rs | 25 - src/test/compile-fail/malformed-plugin-1.rs | 14 - src/test/compile-fail/malformed-plugin-2.rs | 14 - src/test/compile-fail/malformed-plugin-3.rs | 14 - src/test/compile-fail/malformed_macro_lhs.rs | 17 - src/test/compile-fail/manual-link-bad-form.rs | 15 - src/test/compile-fail/manual-link-bad-kind.rs | 15 - .../compile-fail/manual-link-bad-search-path.rs | 15 - src/test/compile-fail/manual-link-framework.rs | 17 - src/test/compile-fail/map-types.rs | 29 - src/test/compile-fail/match-argm-statics-2.rs | 73 --- src/test/compile-fail/match-arm-statics.rs | 79 --- .../compile-fail/match-byte-array-patterns-2.rs | 24 - src/test/compile-fail/match-byte-array-patterns.rs | 66 -- src/test/compile-fail/match-ill-type2.rs | 17 - src/test/compile-fail/match-join.rs | 21 - .../match-no-arms-unreachable-after.rs | 22 - src/test/compile-fail/match-non-exhaustive.rs | 14 - .../compile-fail/match-pattern-field-mismatch-2.rs | 26 - .../compile-fail/match-pattern-field-mismatch.rs | 26 - src/test/compile-fail/match-privately-empty.rs | 31 - src/test/compile-fail/match-range-fail-2.rs | 31 - src/test/compile-fail/match-range-fail-dominate.rs | 49 -- src/test/compile-fail/match-range-fail.rs | 33 - src/test/compile-fail/match-ref-ice.rs | 26 - src/test/compile-fail/match-ref-mut-invariance.rs | 24 - .../compile-fail/match-ref-mut-let-invariance.rs | 25 - src/test/compile-fail/match-slice-patterns.rs | 24 - src/test/compile-fail/match-static-const-lc.rs | 61 -- src/test/compile-fail/match-struct.rs | 24 - src/test/compile-fail/match-tag-nullary.rs | 16 - src/test/compile-fail/match-tag-unary.rs | 16 - ...h-unreachable-warning-with-diverging-discrim.rs | 16 - src/test/compile-fail/match-unresolved-one-arm.rs | 17 - src/test/compile-fail/match-vec-fixed.rs | 28 - src/test/compile-fail/match-vec-mismatch-2.rs | 16 - src/test/compile-fail/match-vec-mismatch.rs | 48 -- src/test/compile-fail/match-vec-unreachable.rs | 40 -- src/test/compile-fail/maybe-bounds-where-cpass.rs | 19 - src/test/compile-fail/maybe-bounds-where.rs | 37 -- .../meta-expected-error-correct-rev.rs | 20 - .../compile-fail/meta-expected-error-wrong-rev.rs | 24 - .../method-ambig-one-trait-unknown-int-type.rs | 46 -- .../method-ambig-two-traits-cross-crate.rs | 21 - .../method-ambig-two-traits-from-bounds.rs | 18 - .../method-ambig-two-traits-with-default-method.rs | 23 - .../compile-fail/method-call-lifetime-args-lint.rs | 97 --- .../method-call-lifetime-args-subst-index.rs | 25 - .../method-call-lifetime-args-unresolved.rs | 13 - src/test/compile-fail/method-call-lifetime-args.rs | 82 --- src/test/compile-fail/method-call-type-binding.rs | 13 - src/test/compile-fail/method-macro-backtrace.rs | 35 - src/test/compile-fail/method-path-in-pattern.rs | 36 - .../method-resolvable-path-in-pattern.rs | 24 - src/test/compile-fail/method-self-arg-1.rs | 29 - src/test/compile-fail/method-self-arg-2.rs | 28 - src/test/compile-fail/minus-string.rs | 13 - src/test/compile-fail/mir-dataflow/README.md | 53 -- src/test/compile-fail/mir-dataflow/def-inits-1.rs | 62 -- src/test/compile-fail/mir-dataflow/inits-1.rs | 64 -- src/test/compile-fail/mir-dataflow/uninits-1.rs | 62 -- src/test/compile-fail/mir-dataflow/uninits-2.rs | 35 - src/test/compile-fail/mir-unpretty.rs | 15 - src/test/compile-fail/missing-derivable-attr.rs | 26 - src/test/compile-fail/missing-macro-use.rs | 18 - src/test/compile-fail/missing-main.rs | 12 - src/test/compile-fail/missing-return.rs | 15 - src/test/compile-fail/missing-semicolon-warning.rs | 22 - src/test/compile-fail/missing-stability.rs | 34 - src/test/compile-fail/missing_debug_impls.rs | 48 -- src/test/compile-fail/mod_file_aux.rs | 13 - src/test/compile-fail/mod_file_correct_spans.rs | 18 - src/test/compile-fail/mod_file_disambig.rs | 17 - src/test/compile-fail/mod_file_disambig_aux.rs | 11 - src/test/compile-fail/mod_file_disambig_aux/mod.rs | 11 - .../compile-fail/module-macro_use-arguments.rs | 16 - src/test/compile-fail/move-guard-same-consts.rs | 35 - src/test/compile-fail/move-in-guard-1.rs | 25 - src/test/compile-fail/move-in-guard-2.rs | 25 - src/test/compile-fail/move-into-dead-array-1.rs | 25 - src/test/compile-fail/move-into-dead-array-2.rs | 25 - src/test/compile-fail/move-out-of-array-1.rs | 28 - src/test/compile-fail/move-out-of-slice-1.rs | 21 - src/test/compile-fail/move-out-of-tuple-field.rs | 23 - .../moves-based-on-type-access-to-field.rs | 24 - .../moves-based-on-type-capture-clause-bad.rs | 19 - .../moves-based-on-type-cyclic-types-issue-4821.rs | 30 - ...ves-based-on-type-distribute-copy-over-paren.rs | 59 -- src/test/compile-fail/moves-based-on-type-exprs.rs | 103 --- ...d-on-type-move-out-of-closure-env-issue-1965.rs | 22 - ...ves-based-on-type-no-recursive-stack-closure.rs | 45 -- src/test/compile-fail/moves-sru-moved-field.rs | 33 - src/test/compile-fail/multiple-main-2.rs | 19 - src/test/compile-fail/multiple-main-3.rs | 21 - .../compile-fail/multiple-plugin-registrars.rs | 22 - src/test/compile-fail/mut-cant-alias.rs | 18 - src/test/compile-fail/mut-cross-borrowing.rs | 18 - .../mut-pattern-internal-mutability.rs | 30 - src/test/compile-fail/mut-pattern-mismatched.rs | 30 - src/test/compile-fail/mut-suggestion.rs | 32 - src/test/compile-fail/mutable-class-fields-2.rs | 34 - src/test/compile-fail/mutable-class-fields.rs | 30 - src/test/compile-fail/mutable-enum-indirect.rs | 29 - src/test/compile-fail/mutexguard-sync.rs | 23 - src/test/compile-fail/namespace-mix.rs | 165 ----- .../namespaced-enum-glob-import-no-impls-xcrate.rs | 25 - .../namespaced-enum-glob-import-no-impls.rs | 35 - src/test/compile-fail/nested-cfg-attrs.rs | 14 - src/test/compile-fail/nested-ty-params.rs | 16 - src/test/compile-fail/never-assign-dead-code.rs | 22 - src/test/compile-fail/never-assign-wrong-type.rs | 18 - src/test/compile-fail/never_transmute_never.rs | 33 - .../nll/constant-thread-locals-issue-47053.rs | 21 - .../nll/do-not-ignore-lifetime-bounds-in-copy.rs | 23 - .../compile-fail/nll/loan_ends_mid_block_pair.rs | 50 -- .../compile-fail/nll/loan_ends_mid_block_vec.rs | 49 -- .../compile-fail/nll/match-guards-always-borrow.rs | 61 -- .../nll/reference-carried-through-struct-field.rs | 26 - .../nll/region-ends-after-if-condition.rs | 46 -- src/test/compile-fail/nll/return_from_loop.rs | 49 -- .../compile-fail/nll/unused-mut-issue-50343.rs | 17 - .../compile-fail/nll/where_clauses_in_functions.rs | 28 - .../compile-fail/nll/where_clauses_in_structs.rs | 28 - src/test/compile-fail/no-capture-arc.rs | 27 - .../compile-fail/no-implicit-prelude-nested.rs | 64 -- src/test/compile-fail/no-implicit-prelude.rs | 28 - src/test/compile-fail/no-link.rs | 19 - src/test/compile-fail/no-patterns-in-args-2.rs | 23 - src/test/compile-fail/no-patterns-in-args-macro.rs | 36 - src/test/compile-fail/no-reuse-move-arc.rs | 25 - src/test/compile-fail/no-send-res-ports.rs | 40 -- src/test/compile-fail/no-std-inject.rs | 17 - src/test/compile-fail/no-type-for-node-ice.rs | 15 - .../no-warn-on-field-replace-issue-34101.rs | 56 -- src/test/compile-fail/no_crate_type.rs | 16 - src/test/compile-fail/no_owned_box_lang_item.rs | 24 - src/test/compile-fail/no_send-enum.rs | 28 - src/test/compile-fail/no_send-rc.rs | 19 - src/test/compile-fail/no_send-struct.rs | 27 - src/test/compile-fail/no_share-enum.rs | 26 - src/test/compile-fail/no_share-struct.rs | 24 - src/test/compile-fail/noexporttypeexe.rs | 25 - src/test/compile-fail/nolink-with-link-args.rs | 23 - .../compile-fail/non-constant-in-const-path.rs | 17 - src/test/compile-fail/non-copyable-void.rs | 24 - .../compile-fail/non-exhaustive-match-nested.rs | 31 - src/test/compile-fail/non-exhaustive-match.rs | 73 --- src/test/compile-fail/non-interger-atomic.rs | 100 --- src/test/compile-fail/noncopyable-class.rs | 46 -- src/test/compile-fail/nonscalar-cast.rs | 18 - src/test/compile-fail/not-clone-closure.rs | 22 - src/test/compile-fail/not-copy-closure.rs | 21 - src/test/compile-fail/not-panic-safe-2.rs | 23 - src/test/compile-fail/not-panic-safe-3.rs | 23 - src/test/compile-fail/not-panic-safe-4.rs | 22 - src/test/compile-fail/not-panic-safe-5.rs | 20 - src/test/compile-fail/not-panic-safe-6.rs | 22 - src/test/compile-fail/not-panic-safe.rs | 21 - src/test/compile-fail/not-sync.rs | 32 - src/test/compile-fail/not-utf8.bin | Bin 3036 -> 0 bytes src/test/compile-fail/not-utf8.rs | 15 - .../compile-fail/object-does-not-impl-trait.rs | 18 - .../object-lifetime-default-ambiguous.rs | 58 -- .../object-lifetime-default-elision.rs | 87 --- .../object-lifetime-default-from-box-error.rs | 45 -- .../object-lifetime-default-from-rptr-box-error.rs | 29 - ...ject-lifetime-default-from-rptr-struct-error.rs | 35 - .../compile-fail/object-lifetime-default-mybox.rs | 45 -- src/test/compile-fail/object-lifetime-default.rs | 34 - src/test/compile-fail/object-pointer-types.rs | 41 -- .../object-safety-by-value-self-use.rs | 28 - .../compile-fail/object-safety-by-value-self.rs | 56 -- src/test/compile-fail/object-safety-issue-22040.rs | 52 -- src/test/compile-fail/object-safety-no-static.rs | 24 - src/test/compile-fail/object-safety-phantom-fn.rs | 32 - src/test/compile-fail/object-safety-sized-2.rs | 26 - src/test/compile-fail/occurs-check-2.rs | 20 - src/test/compile-fail/occurs-check-3.rs | 14 - src/test/compile-fail/occurs-check.rs | 18 - .../old-suffixes-are-really-forbidden.rs | 14 - .../compile-fail/once-cant-call-twice-on-heap.rs | 28 - src/test/compile-fail/opt-in-copy.rs | 32 - src/test/compile-fail/or-patter-mismatch.rs | 15 - src/test/compile-fail/orphan-check-diagnostics.rs | 23 - src/test/compile-fail/osx-frameworks.rs | 18 - src/test/compile-fail/out-of-order-shadowing.rs | 21 - src/test/compile-fail/output-type-mismatch.rs | 15 - src/test/compile-fail/overlap-marker-trait.rs | 41 -- src/test/compile-fail/overloaded-calls-nontuple.rs | 37 -- .../packed-struct-generic-transmute.rs | 37 -- src/test/compile-fail/packed-struct-transmute.rs | 38 -- .../panic-implementation-bad-signature-1.rs | 24 - .../panic-implementation-bad-signature-2.rs | 25 - .../panic-implementation-bad-signature-3.rs | 22 - .../panic-implementation-bad-signature-4.rs | 23 - .../compile-fail/panic-implementation-duplicate.rs | 28 - .../compile-fail/panic-implementation-missing.rs | 18 - .../panic-implementation-requires-panic-info.rs | 26 - src/test/compile-fail/panic-implementation-std.rs | 22 - .../compile-fail/panic-implementation-twice.rs | 29 - .../panic-runtime/abort-link-to-unwind-dylib.rs | 26 - .../panic-runtime/auxiliary/depends.rs | 18 - .../panic-runtime/auxiliary/needs-panic-runtime.rs | 16 - .../panic-runtime/auxiliary/panic-runtime-abort.rs | 27 - .../auxiliary/panic-runtime-lang-items.rs | 25 - .../auxiliary/panic-runtime-unwind.rs | 27 - .../auxiliary/panic-runtime-unwind2.rs | 27 - .../auxiliary/wants-panic-runtime-abort.rs | 17 - .../auxiliary/wants-panic-runtime-unwind.rs | 16 - .../compile-fail/panic-runtime/bad-panic-flag1.rs | 14 - .../compile-fail/panic-runtime/bad-panic-flag2.rs | 14 - .../compile-fail/panic-runtime/libtest-unwinds.rs | 21 - src/test/compile-fail/panic-runtime/needs-gate.rs | 17 - .../runtime-depend-on-needs-runtime.rs | 15 - .../panic-runtime/transitive-link-a-bunch.rs | 25 - .../panic-runtime/two-panic-runtimes.rs | 23 - .../panic-runtime/want-abort-got-unwind.rs | 17 - .../panic-runtime/want-abort-got-unwind2.rs | 18 - .../panic-runtime/want-unwind-got-abort.rs | 21 - .../panic-runtime/want-unwind-got-abort2.rs | 22 - .../compile-fail/panic_implementation-closures.rs | 21 - src/test/compile-fail/paren-span.rs | 31 - src/test/compile-fail/parse-error-correct.rs | 22 - src/test/compile-fail/parser-recovery-1.rs | 24 - src/test/compile-fail/parser-recovery-2.rs | 24 - .../compile-fail/pat-shadow-in-nested-binding.rs | 15 - src/test/compile-fail/pat-tuple-bad-type.rs | 25 - src/test/compile-fail/pat-tuple-overfield.rs | 26 - src/test/compile-fail/patkind-litrange-no-expr.rs | 34 - .../compile-fail/pattern-binding-disambiguation.rs | 67 -- src/test/compile-fail/pattern-bindings-after-at.rs | 25 - src/test/compile-fail/pattern-error-continue.rs | 47 -- .../compile-fail/pattern-ident-path-generics.rs | 16 - src/test/compile-fail/pattern-tyvar-2.rs | 17 - src/test/compile-fail/pattern-tyvar.rs | 24 - src/test/compile-fail/phantom-oibit.rs | 40 -- src/test/compile-fail/platform-intrinsic-params.rs | 16 - src/test/compile-fail/pptypedef.rs | 21 - src/test/compile-fail/prim-with-args.rs | 37 -- src/test/compile-fail/priv-in-bad-locations.rs | 27 - src/test/compile-fail/privacy-in-paths.rs | 40 -- src/test/compile-fail/privacy-ns1.rs | 65 -- src/test/compile-fail/privacy-ns2.rs | 88 --- src/test/compile-fail/privacy-sanity.rs | 92 --- src/test/compile-fail/privacy-ufcs.rs | 23 - .../privacy/associated-item-privacy-inherent.rs | 122 ---- .../privacy/associated-item-privacy-trait.rs | 151 ----- .../associated-item-privacy-type-binding.rs | 74 --- .../compile-fail/privacy/legacy-ctor-visibility.rs | 30 - .../privacy/restricted/auxiliary/pub_restricted.rs | 26 - .../privacy/restricted/lookup-ignores-private.rs | 44 -- .../privacy/restricted/private-in-public.rs | 23 - .../privacy/restricted/struct-literal-field.rs | 29 - src/test/compile-fail/privacy/restricted/test.rs | 62 -- .../compile-fail/privacy/union-field-privacy-1.rs | 27 - .../compile-fail/privacy/union-field-privacy-2.rs | 25 - src/test/compile-fail/privacy1.rs | 172 ----- src/test/compile-fail/privacy2.rs | 37 -- src/test/compile-fail/privacy3.rs | 37 -- src/test/compile-fail/privacy4.rs | 35 - src/test/compile-fail/privacy5.rs | 138 ---- src/test/compile-fail/private-impl-method.rs | 31 - .../compile-fail/private-in-public-assoc-ty.rs | 43 -- .../compile-fail/private-in-public-ill-formed.rs | 45 -- src/test/compile-fail/private-in-public-lint.rs | 29 - src/test/compile-fail/private-in-public-warn.rs | 282 -------- src/test/compile-fail/private-in-public.rs | 158 ----- src/test/compile-fail/private-inferred-type-1.rs | 28 - src/test/compile-fail/private-inferred-type-2.rs | 29 - src/test/compile-fail/private-inferred-type-3.rs | 27 - src/test/compile-fail/private-inferred-type.rs | 143 ---- src/test/compile-fail/private-item-simple.rs | 17 - .../compile-fail/private-method-cross-crate.rs | 18 - src/test/compile-fail/private-method-inherited.rs | 24 - src/test/compile-fail/private-method.rs | 35 - .../private-struct-field-cross-crate.rs | 19 - src/test/compile-fail/private-struct-field-ctor.rs | 19 - .../compile-fail/private-struct-field-pattern.rs | 27 - src/test/compile-fail/private-struct-field.rs | 24 - src/test/compile-fail/private-type-in-interface.rs | 42 -- src/test/compile-fail/private-variant-reexport.rs | 29 - src/test/compile-fail/ptr-coercion.rs | 33 - .../compile-fail/pub-reexport-priv-extern-crate.rs | 34 - src/test/compile-fail/qualified-path-params.rs | 34 - src/test/compile-fail/question-mark-type-infer.rs | 27 - src/test/compile-fail/quote-with-interpolated.rs | 19 - src/test/compile-fail/range-1.rs | 26 - src/test/compile-fail/range_traits-1.rs | 35 - src/test/compile-fail/range_traits-2.rs | 17 - src/test/compile-fail/range_traits-3.rs | 17 - src/test/compile-fail/range_traits-4.rs | 20 - src/test/compile-fail/range_traits-5.rs | 20 - src/test/compile-fail/range_traits-6.rs | 17 - src/test/compile-fail/range_traits-7.rs | 20 - src/test/compile-fail/recursion.rs | 32 - src/test/compile-fail/recursive-enum.rs | 14 - src/test/compile-fail/recursive-reexports.rs | 17 - .../compile-fail/recursive-static-definition.rs | 14 - .../recursive-types-are-not-uninhabited.rs | 24 - src/test/compile-fail/ref-suggestion.rs | 27 - src/test/compile-fail/refutable-pattern-errors.rs | 18 - .../compile-fail/refutable-pattern-in-fn-arg.rs | 15 - .../region-borrow-params-issue-29793-big.rs | 90 --- .../region-bound-extra-bound-in-inherent-impl.rs | 26 - .../region-bound-on-closure-outlives-call.rs | 15 - .../region-bound-same-bounds-in-trait-and-impl.rs | 27 - ...region-bounds-on-objects-and-type-parameters.rs | 46 -- .../region-invariant-static-error-reporting.rs | 32 - .../region-lifetime-bounds-on-fns-where-clause.rs | 39 -- ...multiple-lifetime-bounds-on-fns-where-clause.rs | 41 -- src/test/compile-fail/region-object-lifetime-1.rs | 28 - src/test/compile-fail/region-object-lifetime-2.rs | 23 - src/test/compile-fail/region-object-lifetime-3.rs | 28 - src/test/compile-fail/region-object-lifetime-4.rs | 25 - src/test/compile-fail/region-object-lifetime-5.rs | 24 - .../region-object-lifetime-in-coercion.rs | 44 -- src/test/compile-fail/regions-addr-of-arg.rs | 27 - src/test/compile-fail/regions-addr-of-self.rs | 37 -- .../compile-fail/regions-addr-of-upvar-self.rs | 27 - .../compile-fail/regions-adjusted-lvalue-op.rs | 26 - ...-assoc-type-in-supertrait-outlives-container.rs | 54 -- ...ons-assoc-type-region-bound-in-trait-not-met.rs | 34 - ...ons-assoc-type-static-bound-in-trait-not-met.rs | 29 - .../regions-bounded-by-trait-requiring-static.rs | 73 --- ...s-bounded-method-type-parameters-cross-crate.rs | 33 - ...s-bounded-method-type-parameters-trait-bound.rs | 38 -- .../regions-bounded-method-type-parameters.rs | 26 - src/test/compile-fail/regions-bounds.rs | 26 - .../regions-close-associated-type-into-object.rs | 81 --- .../regions-close-object-into-object-1.rs | 25 - .../regions-close-object-into-object-2.rs | 23 - .../regions-close-object-into-object-3.rs | 24 - .../regions-close-object-into-object-4.rs | 23 - .../regions-close-object-into-object-5.rs | 36 - .../regions-close-over-type-parameter-1.rs | 35 - .../regions-close-over-type-parameter-multiple.rs | 34 - .../regions-close-param-into-object.rs | 37 -- src/test/compile-fail/regions-creating-enums.rs | 43 -- src/test/compile-fail/regions-creating-enums3.rs | 21 - src/test/compile-fail/regions-creating-enums4.rs | 21 - .../regions-early-bound-error-method.rs | 36 - src/test/compile-fail/regions-early-bound-error.rs | 34 - src/test/compile-fail/regions-enum-not-wf.rs | 38 -- src/test/compile-fail/regions-escape-method.rs | 26 - .../regions-escape-via-trait-or-not.rs | 32 - .../regions-fn-subtyping-return-static.rs | 67 -- .../regions-free-region-ordering-callee-4.rs | 21 - .../regions-free-region-ordering-callee.rs | 39 -- .../regions-free-region-ordering-caller.rs | 30 - .../regions-free-region-ordering-caller1.rs | 24 - .../regions-free-region-ordering-incorrect.rs | 32 - src/test/compile-fail/regions-glb-free-free.rs | 39 -- .../regions-implied-bounds-projection-gap-1.rs | 40 -- .../regions-implied-bounds-projection-gap-2.rs | 33 - .../regions-implied-bounds-projection-gap-3.rs | 33 - .../regions-implied-bounds-projection-gap-4.rs | 33 - .../regions-implied-bounds-projection-gap-hr-1.rs | 36 - src/test/compile-fail/regions-in-enums-anon.rs | 17 - src/test/compile-fail/regions-in-enums.rs | 30 - src/test/compile-fail/regions-in-structs-anon.rs | 17 - src/test/compile-fail/regions-in-structs.rs | 25 - .../compile-fail/regions-infer-at-fn-not-param.rs | 29 - .../regions-infer-borrow-scope-too-big.rs | 27 - .../regions-infer-bound-from-trait-self.rs | 61 -- .../compile-fail/regions-infer-bound-from-trait.rs | 50 -- src/test/compile-fail/regions-infer-call-3.rs | 24 - .../regions-infer-contravariance-due-to-decl.rs | 38 -- .../regions-infer-covariance-due-to-decl.rs | 35 - .../regions-infer-invariance-due-to-decl.rs | 26 - ...regions-infer-invariance-due-to-mutability-3.rs | 25 - ...regions-infer-invariance-due-to-mutability-4.rs | 25 - src/test/compile-fail/regions-infer-not-param.rs | 36 - .../compile-fail/regions-infer-paramd-indirect.rs | 41 -- .../regions-infer-proc-static-upvar.rs | 34 - .../compile-fail/regions-lifetime-bounds-on-fns.rs | 39 -- .../regions-lifetime-of-struct-or-enum-variant.rs | 36 - src/test/compile-fail/regions-name-duplicated.rs | 15 - src/test/compile-fail/regions-name-static.rs | 15 - src/test/compile-fail/regions-name-undeclared.rs | 60 -- src/test/compile-fail/regions-nested-fns.rs | 30 - .../regions-normalize-in-where-clause-list.rs | 37 -- ...egions-outlives-nominal-type-enum-region-rev.rs | 29 - .../regions-outlives-nominal-type-enum-region.rs | 29 - .../regions-outlives-nominal-type-enum-type-rev.rs | 29 - .../regions-outlives-nominal-type-enum-type.rs | 29 - ...ions-outlives-nominal-type-struct-region-rev.rs | 29 - .../regions-outlives-nominal-type-struct-region.rs | 29 - ...egions-outlives-nominal-type-struct-type-rev.rs | 29 - .../regions-outlives-nominal-type-struct-type.rs | 29 - .../regions-outlives-projection-container-hrtb.rs | 69 -- .../regions-outlives-projection-container-wc.rs | 49 -- .../regions-outlives-projection-container.rs | 86 --- .../regions-outlives-projection-hrtype.rs | 36 - .../regions-outlives-projection-trait-def.rs | 31 - src/test/compile-fail/regions-outlives-scalar.rs | 23 - .../regions-pattern-typing-issue-19552.rs | 18 - .../regions-pattern-typing-issue-19997.rs | 25 - .../compile-fail/regions-proc-bound-capture.rs | 22 - ...egions-reborrow-from-shorter-mut-ref-mut-ref.rs | 18 - .../regions-reborrow-from-shorter-mut-ref.rs | 25 - src/test/compile-fail/regions-ref-in-fn-arg.rs | 24 - src/test/compile-fail/regions-ret-borrowed-1.rs | 27 - src/test/compile-fail/regions-ret-borrowed.rs | 30 - src/test/compile-fail/regions-ret.rs | 18 - .../regions-return-ref-to-upvar-issue-17403.rs | 21 - .../regions-return-stack-allocated-vec.rs | 20 - src/test/compile-fail/regions-static-bound.rs | 33 - src/test/compile-fail/regions-steal-closure.rs | 27 - src/test/compile-fail/regions-struct-not-wf.rs | 40 -- src/test/compile-fail/regions-trait-1.rs | 40 -- .../compile-fail/regions-trait-object-subtyping.rs | 35 - src/test/compile-fail/regions-trait-variance.rs | 54 -- src/test/compile-fail/regions-undeclared.rs | 23 - .../compile-fail/regions-var-type-out-of-scope.rs | 24 - ...ntravariant-use-covariant-in-second-position.rs | 38 -- ...regions-variance-contravariant-use-covariant.rs | 36 - ...regions-variance-covariant-use-contravariant.rs | 36 - ...regions-variance-invariant-use-contravariant.rs | 33 - .../regions-variance-invariant-use-covariant.rs | 30 - src/test/compile-fail/regions-wf-trait-object.rs | 20 - .../compile-fail/reject-specialized-drops-8142.rs | 67 -- src/test/compile-fail/repeat-to-run-dtor-twice.rs | 29 - src/test/compile-fail/repeat_count.rs | 49 -- src/test/compile-fail/repr-align.rs | 24 - .../compile-fail/repr-packed-contains-align.rs | 59 -- .../compile-fail/repr-transparent-other-items.rs | 38 -- .../compile-fail/repr-transparent-other-reprs.rs | 28 - src/test/compile-fail/repr-transparent.rs | 50 -- src/test/compile-fail/required-lang-item.rs | 19 - src/test/compile-fail/reserved-attr-on-macro.rs | 18 - src/test/compile-fail/reserved-become.rs | 14 - src/test/compile-fail/resolve-bad-import-prefix.rs | 24 - src/test/compile-fail/resolve-bad-visibility.rs | 25 - ...esolve-conflict-extern-crate-vs-extern-crate.rs | 15 - .../resolve-conflict-import-vs-extern-crate.rs | 14 - .../resolve-conflict-import-vs-import.rs | 16 - .../resolve-conflict-item-vs-extern-crate.rs | 15 - .../resolve-conflict-type-vs-import.rs | 17 - .../resolve-inconsistent-binding-mode.rs | 50 -- src/test/compile-fail/resolve-label.rs | 23 - .../compile-fail/resolve-primitive-fallback.rs | 20 - src/test/compile-fail/resolve-self-in-impl-2.rs | 17 - src/test/compile-fail/resolve-self-in-impl.rs | 30 - .../resolve-type-param-in-item-in-trait.rs | 45 -- src/test/compile-fail/resolve-unknown-trait.rs | 19 - .../compile-fail/resolve-variant-assoc-item.rs | 17 - src/test/compile-fail/resolve_self_super_hint.rs | 34 - src/test/compile-fail/ret-non-nil.rs | 17 - src/test/compile-fail/retslot-cast.rs | 33 - src/test/compile-fail/return-from-diverging.rs | 19 - .../compile-fail/return-unit-from-diverging.rs | 20 - .../termination-trait-main-i32.rs | 16 - .../termination-trait-not-satisfied.rs | 15 - .../rfc-2008-non-exhaustive/auxiliary/enums.rs | 19 - .../rfc-2008-non-exhaustive/auxiliary/structs.rs | 37 -- .../rfc-2008-non-exhaustive/auxiliary/variants.rs | 18 - .../compile-fail/rfc-2008-non-exhaustive/enum.rs | 25 - .../rfc-2008-non-exhaustive/invalid-attribute.rs | 28 - .../rfc-2008-non-exhaustive/structs.rs | 47 -- .../rfc-2008-non-exhaustive/variants.rs | 36 - .../rfc-2008-non-exhaustive/variants_create.rs | 27 - .../crate-path-non-absolute.rs | 22 - .../keyword-crate-as-identifier.rs | 15 - .../auxiliary/xcrate.rs | 15 - .../non-existent-1.rs | 15 - .../non-existent-2.rs | 15 - .../non-existent-3.rs | 15 - .../single-segment.rs | 20 - .../rfc-2126-extern-in-paths/auxiliary/xcrate.rs | 15 - .../rfc-2126-extern-in-paths/non-existent-1.rs | 15 - .../rfc-2126-extern-in-paths/non-existent-2.rs | 15 - .../rfc-2126-extern-in-paths/non-existent-3.rs | 15 - .../rfc-2126-extern-in-paths/single-segment.rs | 22 - src/test/compile-fail/rfc1445/feature-gate.rs | 37 -- .../rfc1445/match-forbidden-without-eq.rs | 35 - .../match-requires-both-partialeq-and-eq.rs | 31 - src/test/compile-fail/rfc1623.rs | 102 --- src/test/compile-fail/rfc1717/missing-link-attr.rs | 14 - src/test/compile-fail/rfc1717/multiple-renames.rs | 17 - src/test/compile-fail/rfc1717/rename-to-empty.rs | 17 - src/test/compile-fail/rmeta-lib-pass.rs | 24 - src/test/compile-fail/rmeta-pass.rs | 25 - src/test/compile-fail/rmeta-priv-warn.rs | 21 - src/test/compile-fail/rmeta.rs | 18 - src/test/compile-fail/rmeta_lib.rs | 23 - src/test/compile-fail/rmeta_meta_main.rs | 24 - .../compile-fail/rust-unstable-column-gated.rs | 14 - src/test/compile-fail/rustc-args-required-const.rs | 36 - .../compile-fail/rustc-args-required-const2.rs | 20 - src/test/compile-fail/rustc-error.rs | 16 - src/test/compile-fail/safe-extern-statics-mut.rs | 25 - src/test/compile-fail/safe-extern-statics.rs | 31 - src/test/compile-fail/self-infer.rs | 18 - src/test/compile-fail/self-vs-path-ambiguity.rs | 22 - src/test/compile-fail/self_type_keyword-2.rs | 23 - src/test/compile-fail/self_type_keyword.rs | 51 -- src/test/compile-fail/seq-args.rs | 21 - src/test/compile-fail/shadowed-trait-methods.rs | 24 - src/test/compile-fail/shadowed-use-visibility.rs | 26 - .../compile-fail/shadowing-in-the-same-pattern.rs | 17 - src/test/compile-fail/shift-various-bad-types.rs | 41 -- ...ould-fail-no_gate_irrefutable_if_let_pattern.rs | 15 - ...ould-fail-with_gate_irrefutable_pattern_deny.rs | 17 - .../simd-intrinsic-declaration-type.rs | 68 -- .../simd-intrinsic-generic-arithmetic.rs | 103 --- .../compile-fail/simd-intrinsic-generic-cast.rs | 51 -- .../simd-intrinsic-generic-comparison.rs | 75 --- .../simd-intrinsic-generic-elements.rs | 97 --- .../simd-intrinsic-generic-reduction.rs | 81 --- .../compile-fail/simd-intrinsic-generic-select.rs | 56 -- .../simd-intrinsic-single-nominal-type.rs | 33 - .../simd-type-generic-monomorphisation.rs | 21 - src/test/compile-fail/simd-type.rs | 22 - .../compile-fail/single-primitive-inherent-impl.rs | 23 - src/test/compile-fail/sized-cycle-note.rs | 26 - src/test/compile-fail/slice-2.rs | 21 - src/test/compile-fail/slice-mut-2.rs | 18 - src/test/compile-fail/slice-mut.rs | 22 - .../slightly-nice-generic-literal-messages.rs | 24 - src/test/compile-fail/specialization/README.md | 21 - .../specialization-feature-gate-default.rs | 21 - .../defaultimpl/specialization-no-default.rs | 95 --- .../specialization-trait-item-not-implemented.rs | 33 - .../specialization-trait-not-implemented.rs | 34 - .../defaultimpl/specialization-wfcheck.rs | 20 - .../specialization/defaultimpl/validation.rs | 23 - .../compile-fail/specialization/issue-52050.rs | 42 -- .../specialization-default-projection.rs | 46 -- .../specialization/specialization-default-types.rs | 45 -- .../specialization/specialization-no-default.rs | 95 --- .../specialization-overlap-negative.rs | 21 - .../specialization/specialization-overlap.rs | 29 - .../specialization/specialization-polarity.rs | 26 - .../stability-attribute-issue-43027.rs | 20 - src/test/compile-fail/stability-attribute-issue.rs | 24 - ...tability-attribute-non-staged-force-unstable.rs | 16 - .../compile-fail/stability-attribute-non-staged.rs | 14 - .../compile-fail/stability-attribute-sanity-2.rs | 26 - .../compile-fail/stability-attribute-sanity-3.rs | 22 - .../compile-fail/stability-attribute-sanity.rs | 101 --- src/test/compile-fail/stable-features.rs | 24 - src/test/compile-fail/static-closures.rs | 14 - src/test/compile-fail/static-drop-scope.rs | 41 -- src/test/compile-fail/static-items-cant-move.rs | 29 - src/test/compile-fail/static-lifetime-bound.rs | 16 - src/test/compile-fail/static-method-privacy.rs | 20 - src/test/compile-fail/static-mut-bad-types.rs | 17 - .../static-mut-foreign-requires-unsafe.rs | 19 - src/test/compile-fail/static-mut-not-constant.rs | 16 - src/test/compile-fail/static-mut-not-pat.rs | 53 -- .../compile-fail/static-mut-requires-unsafe.rs | 17 - src/test/compile-fail/static-priv-by-default.rs | 37 -- src/test/compile-fail/static-priv-by-default2.rs | 40 -- src/test/compile-fail/static-reference-to-fn-1.rs | 34 - src/test/compile-fail/static-reference-to-fn-2.rs | 64 -- src/test/compile-fail/static-region-bound.rs | 22 - .../compile-fail/static-vec-repeat-not-constant.rs | 16 - src/test/compile-fail/staticness-mismatch.rs | 21 - src/test/compile-fail/std-uncopyable-atomics.rs | 26 - .../compile-fail/stmt_expr_attrs_no_feature.rs | 150 ----- src/test/compile-fail/str-idx.rs | 14 - src/test/compile-fail/str-mut-idx.rs | 21 - src/test/compile-fail/struct-base-wrong-type-2.rs | 29 - src/test/compile-fail/struct-base-wrong-type.rs | 37 -- src/test/compile-fail/struct-field-cfg.rs | 28 - src/test/compile-fail/struct-field-privacy.rs | 48 -- src/test/compile-fail/struct-fields-dupe.rs | 20 - src/test/compile-fail/struct-fields-missing.rs | 21 - .../struct-fields-shorthand-unresolved.rs | 22 - src/test/compile-fail/struct-fields-shorthand.rs | 22 - src/test/compile-fail/struct-fields-typo.rs | 24 - .../compile-fail/struct-like-enum-nonexhaustive.rs | 22 - src/test/compile-fail/struct-pat-derived-error.rs | 24 - src/test/compile-fail/struct-path-alias-bounds.rs | 21 - .../compile-fail/struct-path-associated-type.rs | 48 -- src/test/compile-fail/struct-path-self.rs | 47 -- .../compile-fail/struct-pattern-match-useless.rs | 25 - src/test/compile-fail/struct-variant-privacy-xc.rs | 20 - src/test/compile-fail/struct-variant-privacy.rs | 22 - .../structure-constructor-type-mismatch.rs | 83 --- src/test/compile-fail/substs-ppaux.rs | 61 -- src/test/compile-fail/suffixed-literal-meta.rs | 25 - src/test/compile-fail/super-at-top-level.rs | 14 - src/test/compile-fail/suppressed-error.rs | 18 - src/test/compile-fail/symbol-names/basic.rs | 16 - src/test/compile-fail/symbol-names/impl1.rs | 35 - src/test/compile-fail/syntax-extension-minor.rs | 24 - .../syntax-trait-polarity-feature-gate.rs | 20 - src/test/compile-fail/syntax-trait-polarity.rs | 37 -- src/test/compile-fail/synthetic-param.rs | 38 -- .../tag-that-dare-not-speak-its-name.rs | 27 - src/test/compile-fail/tag-type-args.rs | 17 - .../compile-fail/tag-variant-cast-non-nullary.rs | 19 - src/test/compile-fail/tag-variant-disr-dup.rs | 23 - src/test/compile-fail/tail-typeck.rs | 17 - src/test/compile-fail/terr-in-field.rs | 29 - src/test/compile-fail/terr-sorts.rs | 26 - src/test/compile-fail/test-cfg.rs | 18 - src/test/compile-fail/test-warns-dead-code.rs | 17 - src/test/compile-fail/thread-local-in-ctfe.rs | 33 - src/test/compile-fail/tool_lints.rs | 18 - src/test/compile-fail/trace_macros-format.rs | 28 - src/test/compile-fail/trace_macros-gate.rs | 30 - src/test/compile-fail/trait-alias.rs | 27 - .../compile-fail/trait-as-struct-constructor.rs | 16 - .../compile-fail/trait-bounds-not-on-bare-trait.rs | 21 - .../compile-fail/trait-bounds-not-on-struct.rs | 19 - .../trait-bounds-on-structs-and-enums-in-fns.rs | 30 - .../trait-bounds-on-structs-and-enums-in-impls.rs | 35 - .../trait-bounds-on-structs-and-enums-locals.rs | 27 - .../trait-bounds-on-structs-and-enums-static.rs | 25 - .../trait-bounds-on-structs-and-enums-xc.rs | 24 - .../trait-bounds-on-structs-and-enums-xc1.rs | 25 - .../trait-bounds-on-structs-and-enums.rs | 53 -- src/test/compile-fail/trait-bounds-sugar.rs | 29 - .../compile-fail/trait-coercion-generic-bad.rs | 29 - .../compile-fail/trait-coercion-generic-regions.rs | 29 - src/test/compile-fail/trait-impl-1.rs | 26 - .../trait-impl-can-not-have-untraitful-items.rs | 20 - .../trait-impl-different-num-params.rs | 22 - src/test/compile-fail/trait-impl-for-module.rs | 21 - .../compile-fail/trait-impl-method-mismatch.rs | 24 - ...-of-supertrait-has-wrong-lifetime-parameters.rs | 41 -- src/test/compile-fail/trait-item-privacy.rs | 146 ----- src/test/compile-fail/trait-matching-lifetimes.rs | 30 - .../compile-fail/trait-object-macro-matcher.rs | 21 - src/test/compile-fail/trait-object-safety.rs | 27 - .../compile-fail/trait-object-vs-lifetime-2.rs | 23 - src/test/compile-fail/trait-object-vs-lifetime.rs | 29 - src/test/compile-fail/trait-or-new-type-instead.rs | 16 - src/test/compile-fail/trait-privacy.rs | 35 - .../trait-resolution-in-overloaded-op.rs | 21 - .../compile-fail/trait-safety-inherent-impl.rs | 19 - .../compile-fail/trait-safety-trait-impl-cc.rs | 25 - src/test/compile-fail/trait-safety-trait-impl.rs | 28 - .../trait-static-method-generic-inference.rs | 38 -- src/test/compile-fail/trait-test-2.rs | 24 - src/test/compile-fail/trait-test.rs | 15 - .../traits-assoc-type-in-supertrait-bad.rs | 26 - .../traits-inductive-overflow-simultaneous.rs | 30 - .../traits-inductive-overflow-supertrait-oibit.rs | 27 - .../traits-inductive-overflow-supertrait.rs | 25 - .../traits-inductive-overflow-two-traits.rs | 31 - .../compile-fail/traits-issue-23003-overflow.rs | 39 -- src/test/compile-fail/traits-multidispatch-bad.rs | 32 - src/test/compile-fail/traits-negative-impls.rs | 78 --- .../traits-repeated-supertrait-ambig.rs | 53 -- src/test/compile-fail/transmute-different-sizes.rs | 39 -- src/test/compile-fail/transmute-fat-pointers.rs | 41 -- src/test/compile-fail/transmute-impl.rs | 33 - src/test/compile-fail/transmute-imut-to-mut.rs | 19 - src/test/compile-fail/trivial_casts.rs | 95 --- src/test/compile-fail/tuple-arity-mismatch.rs | 27 - src/test/compile-fail/tuple-index-not-tuple.rs | 20 - src/test/compile-fail/tuple-index-out-of-bounds.rs | 24 - .../compile-fail/tuple-struct-nonexhaustive.rs | 19 - .../compile-fail/tutorial-suffix-inference-test.rs | 34 - src/test/compile-fail/type-arg-out-of-scope.rs | 15 - .../compile-fail/type-ascription-precedence.rs | 64 -- src/test/compile-fail/type-ascription-soundness.rs | 23 - src/test/compile-fail/type-mismatch-multiple.rs | 20 - .../compile-fail/type-mismatch-same-crate-name.rs | 39 -- ...pe-parameter-defaults-referencing-Self-ppaux.rs | 27 - .../type-parameter-defaults-referencing-Self.rs | 23 - src/test/compile-fail/type-parameter-names.rs | 22 - .../type-params-in-different-spaces-1.rs | 28 - .../type-params-in-different-spaces-2.rs | 31 - .../type-params-in-different-spaces-3.rs | 17 - src/test/compile-fail/type-path-err-node-types.rs | 36 - src/test/compile-fail/type-shadow.rs | 18 - src/test/compile-fail/type_length_limit.rs | 35 - .../typeck-auto-trait-no-supertraits-2.rs | 24 - .../typeck-auto-trait-no-supertraits.rs | 48 -- .../compile-fail/typeck-cast-pointer-to-float.rs | 15 - .../typeck-default-trait-impl-assoc-type.rs | 25 - ...ypeck-default-trait-impl-constituent-types-2.rs | 28 - .../typeck-default-trait-impl-constituent-types.rs | 32 - ...eck-default-trait-impl-cross-crate-coherence.rs | 34 - .../typeck-default-trait-impl-negation-send.rs | 31 - .../typeck-default-trait-impl-negation-sync.rs | 53 -- .../typeck-default-trait-impl-negation.rs | 38 -- .../typeck-default-trait-impl-precedence.rs | 30 - .../typeck-default-trait-impl-send-param.rs | 21 - .../compile-fail/typeck-negative-impls-builtin.rs | 22 - .../compile-fail/typeck-unsafe-always-share.rs | 42 -- .../typeck_type_placeholder_mismatch.rs | 37 -- src/test/compile-fail/ufcs-explicit-self-bad.rs | 69 -- src/test/compile-fail/ufcs-partially-resolved.rs | 66 -- src/test/compile-fail/ufcs-qpath-missing-params.rs | 26 - src/test/compile-fail/ufcs-qpath-self-mismatch.rs | 20 - .../compile-fail/unboxed-closure-feature-gate.rs | 30 - .../compile-fail/unboxed-closure-illegal-move.rs | 48 -- .../unboxed-closure-immutable-capture.rs | 29 - src/test/compile-fail/unboxed-closure-region.rs | 18 - .../compile-fail/unboxed-closure-sugar-default.rs | 38 -- .../compile-fail/unboxed-closure-sugar-equiv.rs | 58 -- .../unboxed-closure-sugar-lifetime-elision.rs | 37 -- .../unboxed-closure-sugar-not-used-on-fn.rs | 22 - .../compile-fail/unboxed-closure-sugar-region.rs | 46 -- .../unboxed-closure-sugar-used-on-struct-1.rs | 23 - .../unboxed-closure-sugar-used-on-struct-3.rs | 28 - .../unboxed-closure-sugar-used-on-struct.rs | 22 - ...-sugar-wrong-number-number-type-parameters-1.rs | 18 - ...-sugar-wrong-number-number-type-parameters-3.rs | 20 - ...re-sugar-wrong-number-number-type-parameters.rs | 20 - .../unboxed-closures-borrow-conflict.rs | 18 - .../unboxed-closures-failed-recursive-fn-1.rs | 45 -- .../unboxed-closures-failed-recursive-fn-2.rs | 39 -- .../compile-fail/unboxed-closures-fnmut-as-fn.rs | 40 -- ...res-infer-argument-types-two-region-pointers.rs | 29 - ...ed-closures-infer-fnmut-calling-fnmut-no-mut.rs | 31 - .../unboxed-closures-infer-fnmut-missing-mut.rs | 18 - ...nboxed-closures-infer-fnmut-move-missing-mut.rs | 18 - .../unboxed-closures-infer-fnonce-call-twice.rs | 21 - ...nboxed-closures-infer-fnonce-move-call-twice.rs | 21 - .../compile-fail/unboxed-closures-mutate-upvar.rs | 67 -- ...boxed-closures-mutated-upvar-from-fn-closure.rs | 28 - .../unboxed-closures-recursive-fn-using-fn-mut.rs | 53 -- .../unboxed-closures-static-call-wrong-trait.rs | 18 - .../compile-fail/unboxed-closures-type-mismatch.rs | 17 - .../unboxed-closures-unsafe-extern-fn.rs | 36 - .../compile-fail/unboxed-closures-wrong-abi.rs | 36 - .../unboxed-closures-wrong-arg-type-extern-fn.rs | 37 -- .../compile-fail/underscore-lifetime-binders.rs | 36 - .../underscore-lifetime-elison-mismatch.rs | 13 - src/test/compile-fail/uninhabited-enum-cast.rs | 17 - src/test/compile-fail/uninhabited-irrefutable.rs | 39 -- .../uninhabited-matches-feature-gated.rs | 44 -- src/test/compile-fail/uninhabited-patterns.rs | 58 -- src/test/compile-fail/union-ub-fat-ptr.rs | 89 --- .../union/union-borrow-move-parent-sibling.rs | 57 -- src/test/compile-fail/union/union-const-pat.rs | 23 - src/test/compile-fail/union/union-copy.rs | 26 - src/test/compile-fail/union/union-derive-clone.rs | 41 -- src/test/compile-fail/union/union-derive.rs | 26 - src/test/compile-fail/union/union-empty.rs | 13 - src/test/compile-fail/union/union-generic.rs | 22 - .../compile-fail/union/union-lint-dead-code.rs | 25 - .../compile-fail/union/union-nonrepresentable.rs | 18 - src/test/compile-fail/union/union-repr-c.rs | 28 - src/test/compile-fail/union/union-unsafe.rs | 55 -- src/test/compile-fail/union/union-unsized.rs | 26 - .../union/union-with-drop-fields-lint.rs | 40 -- src/test/compile-fail/unique-object-noncopyable.rs | 35 - src/test/compile-fail/unique-pinned-nocopy.rs | 24 - src/test/compile-fail/unknown-lint-tool-name.rs | 16 - src/test/compile-fail/unknown-tool-name.rs | 14 - src/test/compile-fail/unop-move-semantics.rs | 39 -- src/test/compile-fail/unop-neg-bool.rs | 13 - src/test/compile-fail/unreachable-arm.rs | 25 - src/test/compile-fail/unreachable-code.rs | 18 - src/test/compile-fail/unreachable-in-call.rs | 32 - src/test/compile-fail/unreachable-loop-patterns.rs | 21 - src/test/compile-fail/unreachable-try-pattern.rs | 52 -- src/test/compile-fail/unreachable-variant.rs | 17 - .../unresolved-extern-mod-suggestion.rs | 15 - .../compile-fail/unresolved-import-recovery.rs | 27 - src/test/compile-fail/unresolved-import.rs | 57 -- .../unsafe-around-compiler-generated-unsafe.rs | 17 - .../compile-fail/unsafe-fn-assign-deref-ptr.rs | 19 - src/test/compile-fail/unsafe-fn-autoderef.rs | 33 - .../compile-fail/unsafe-fn-called-from-safe.rs | 16 - src/test/compile-fail/unsafe-fn-deref-ptr.rs | 17 - src/test/compile-fail/unsafe-fn-used-as-value.rs | 17 - src/test/compile-fail/unsafe-move-val-init.rs | 20 - src/test/compile-fail/unsafe-subtyping.rs | 21 - src/test/compile-fail/unsafe-trait-impl.rs | 24 - src/test/compile-fail/unsized-bare-typaram.rs | 14 - src/test/compile-fail/unsized-enum.rs | 22 - .../unsized-inherent-impl-self-type.rs | 21 - src/test/compile-fail/unsized-struct.rs | 29 - .../compile-fail/unsized-trait-impl-self-type.rs | 24 - .../compile-fail/unsized-trait-impl-trait-arg.rs | 22 - src/test/compile-fail/unsized3.rs | 61 -- src/test/compile-fail/unsized5.rs | 44 -- src/test/compile-fail/unsized6.rs | 54 -- src/test/compile-fail/unsized7.rs | 26 - .../compile-fail/unspecified-self-in-trait-ref.rs | 30 - src/test/compile-fail/unsupported-cast.rs | 17 - src/test/compile-fail/unused-attr.rs | 60 -- src/test/compile-fail/unused-macro-rules.rs | 39 -- .../unused-macro-with-bad-frag-spec.rs | 19 - .../unused-macro-with-follow-violation.rs | 17 - src/test/compile-fail/unused-macro.rs | 36 - .../unused-mut-warning-captured-var.rs | 17 - src/test/compile-fail/unused-result.rs | 52 -- .../compile-fail/use-after-move-based-on-type.rs | 15 - .../use-after-move-implicity-coerced-object.rs | 40 -- .../use-after-move-self-based-on-type.rs | 31 - src/test/compile-fail/use-after-move-self.rs | 29 - src/test/compile-fail/use-from-trait-xc.rs | 36 - src/test/compile-fail/use-from-trait.rs | 40 -- src/test/compile-fail/use-keyword.rs | 27 - src/test/compile-fail/use-meta-mismatch.rs | 15 - src/test/compile-fail/use-mod-2.rs | 21 - src/test/compile-fail/use-mod-3.rs | 22 - src/test/compile-fail/use-mod-4.rs | 17 - src/test/compile-fail/use-paths-as-items.rs | 19 - src/test/compile-fail/use-self-type.rs | 21 - src/test/compile-fail/use-super-global-path.rs | 25 - src/test/compile-fail/used.rs | 28 - src/test/compile-fail/useless-pub.rs | 26 - src/test/compile-fail/useless_comment.rs | 30 - src/test/compile-fail/user-defined-macro-rules.rs | 13 - src/test/compile-fail/utf8_idents.rs | 23 - src/test/compile-fail/variadic-ffi-2.rs | 18 - src/test/compile-fail/variadic-ffi.rs | 41 -- src/test/compile-fail/variance-associated-types.rs | 32 - .../compile-fail/variance-btree-invariant-types.rs | 63 -- .../compile-fail/variance-cell-is-invariant.rs | 28 - .../variance-contravariant-arg-object.rs | 35 - .../variance-contravariant-arg-trait-match.rs | 36 - .../variance-contravariant-self-trait-match.rs | 37 -- .../compile-fail/variance-covariant-arg-object.rs | 35 - .../variance-covariant-arg-trait-match.rs | 35 - .../variance-covariant-self-trait-match.rs | 35 - .../compile-fail/variance-invariant-arg-object.rs | 31 - .../variance-invariant-arg-trait-match.rs | 31 - .../variance-invariant-self-trait-match.rs | 31 - src/test/compile-fail/variance-issue-20533.rs | 53 -- src/test/compile-fail/variance-object-types.rs | 26 - src/test/compile-fail/variance-regions-direct.rs | 75 --- src/test/compile-fail/variance-regions-indirect.rs | 44 -- .../compile-fail/variance-regions-unused-direct.rs | 25 - .../variance-regions-unused-indirect.rs | 21 - src/test/compile-fail/variance-trait-bounds.rs | 45 -- src/test/compile-fail/variance-trait-matching.rs | 48 -- .../compile-fail/variance-trait-object-bound.rs | 28 - src/test/compile-fail/variance-types-bounds.rs | 53 -- src/test/compile-fail/variance-types.rs | 51 -- .../compile-fail/variance-unused-region-param.rs | 17 - .../variance-use-contravariant-struct-1.rs | 26 - .../variance-use-contravariant-struct-2.rs | 27 - .../variance-use-covariant-struct-1.rs | 23 - .../variance-use-covariant-struct-2.rs | 26 - .../variance-use-invariant-struct-1.rs | 33 - src/test/compile-fail/variant-namespacing.rs | 43 -- src/test/compile-fail/variant-size-differences.rs | 18 - src/test/compile-fail/variant-used-as-type.rs | 30 - src/test/compile-fail/vec-macro-with-comma-only.rs | 13 - src/test/compile-fail/vec-mut-iter-borrow.rs | 17 - src/test/compile-fail/vec-res-add.rs | 29 - src/test/compile-fail/vector-cast-weirdness.rs | 34 - src/test/compile-fail/vtable-res-trait-param.rs | 33 - src/test/compile-fail/walk-struct-literal-with.rs | 27 - src/test/compile-fail/warn-path-statement.rs | 16 - src/test/compile-fail/weak-lang-item.rs | 21 - src/test/compile-fail/wf-array-elem-sized.rs | 21 - src/test/compile-fail/wf-const-type.rs | 24 - src/test/compile-fail/wf-enum-bound.rs | 26 - .../compile-fail/wf-enum-fields-struct-variant.rs | 28 - src/test/compile-fail/wf-enum-fields.rs | 26 - src/test/compile-fail/wf-fn-where-clause.rs | 24 - .../compile-fail/wf-impl-associated-type-region.rs | 24 - .../compile-fail/wf-impl-associated-type-trait.rs | 32 - src/test/compile-fail/wf-in-fn-arg.rs | 24 - src/test/compile-fail/wf-in-fn-ret.rs | 24 - src/test/compile-fail/wf-in-fn-type-arg.rs | 22 - src/test/compile-fail/wf-in-fn-type-ret.rs | 22 - src/test/compile-fail/wf-in-fn-type-static.rs | 32 - src/test/compile-fail/wf-in-fn-where-clause.rs | 25 - src/test/compile-fail/wf-in-obj-type-static.rs | 28 - src/test/compile-fail/wf-in-obj-type-trait.rs | 24 - .../wf-inherent-impl-method-where-clause.rs | 27 - .../compile-fail/wf-inherent-impl-where-clause.rs | 26 - .../compile-fail/wf-misc-methods-issue-28609.rs | 84 --- src/test/compile-fail/wf-object-safe.rs | 20 - .../compile-fail/wf-outlives-ty-in-fn-or-trait.rs | 32 - src/test/compile-fail/wf-static-method.rs | 64 -- src/test/compile-fail/wf-static-type.rs | 24 - src/test/compile-fail/wf-struct-bound.rs | 26 - src/test/compile-fail/wf-struct-field.rs | 26 - .../compile-fail/wf-trait-associated-type-bound.rs | 24 - .../wf-trait-associated-type-region.rs | 24 - .../compile-fail/wf-trait-associated-type-trait.rs | 26 - src/test/compile-fail/wf-trait-bound.rs | 25 - src/test/compile-fail/wf-trait-default-fn-arg.rs | 29 - src/test/compile-fail/wf-trait-default-fn-ret.rs | 29 - .../wf-trait-default-fn-where-clause.rs | 29 - src/test/compile-fail/wf-trait-fn-arg.rs | 26 - src/test/compile-fail/wf-trait-fn-ret.rs | 26 - src/test/compile-fail/wf-trait-fn-where-clause.rs | 27 - src/test/compile-fail/wf-trait-superbound.rs | 22 - ...ause-constraints-are-local-for-inherent-impl.rs | 28 - ...-clause-constraints-are-local-for-trait-impl.rs | 33 - .../where-clause-method-substituion.rs | 32 - .../where-clauses-method-unsatisfied.rs | 30 - src/test/compile-fail/where-clauses-unsatisfied.rs | 18 - .../compile-fail/where-equality-constraints.rs | 16 - src/test/compile-fail/where-for-self-2.rs | 33 - src/test/compile-fail/where-for-self.rs | 29 - src/test/compile-fail/where-lifetime-resolution.rs | 23 - src/test/compile-fail/while-let.rs | 35 - src/test/compile-fail/while-type-error.rs | 13 - src/test/compile-fail/windows-subsystem-invalid.rs | 15 - .../compile-fail/write-to-static-mut-in-static.rs | 22 - src/test/compile-fail/writing-to-immutable-vec.rs | 15 - .../compile-fail/wrong-mul-method-signature.rs | 79 --- src/test/compile-fail/wrong-ret-type.rs | 13 - src/test/compile-fail/xc-private-method.rs | 21 - src/test/compile-fail/xc-private-method2.rs | 21 - src/test/compile-fail/xcrate-private-by-default.rs | 55 -- src/test/compile-fail/xcrate-unit-struct.rs | 22 - src/test/ui/compile-fail-migration/.gitattributes | 1 + .../ui/compile-fail-migration/E0501.ast.nll.stderr | 31 + .../ui/compile-fail-migration/E0501.ast.stderr | 31 + .../ui/compile-fail-migration/E0501.mir.stderr | 31 + src/test/ui/compile-fail-migration/E0501.rs | 38 ++ .../ui/compile-fail-migration/E0506.ast.nll.stderr | 14 + .../ui/compile-fail-migration/E0506.ast.stderr | 11 + .../ui/compile-fail-migration/E0506.mir.stderr | 14 + src/test/ui/compile-fail-migration/E0506.rs | 25 + .../ui/compile-fail-migration/E0508.ast.stderr | 12 + .../ui/compile-fail-migration/E0508.mir.stderr | 12 + src/test/ui/compile-fail-migration/E0508.rs | 20 + src/test/ui/compile-fail-migration/E0583.rs | 14 + src/test/ui/compile-fail-migration/E0583.stderr | 11 + .../ui/compile-fail-migration/E0594.ast.nll.stderr | 9 + .../ui/compile-fail-migration/E0594.ast.stderr | 9 + .../ui/compile-fail-migration/E0594.mir.stderr | 9 + src/test/ui/compile-fail-migration/E0594.rs | 19 + .../ui/compile-fail-migration/E0596.ast.nll.stderr | 11 + .../ui/compile-fail-migration/E0596.ast.stderr | 11 + .../ui/compile-fail-migration/E0596.mir.stderr | 11 + src/test/ui/compile-fail-migration/E0596.rs | 18 + .../absolute-paths-in-nested-use-groups.rs | 21 + .../absolute-paths-in-nested-use-groups.stderr | 21 + .../access-mode-in-closures.nll.stderr | 12 + .../access-mode-in-closures.rs | 21 + .../access-mode-in-closures.stderr | 11 + .../alloc-error-handler-bad-signature-1.rs | 28 + .../alloc-error-handler-bad-signature-1.stderr | 14 + .../alloc-error-handler-bad-signature-2.rs | 27 + .../alloc-error-handler-bad-signature-2.stderr | 14 + .../alloc-error-handler-bad-signature-3.rs | 25 + .../alloc-error-handler-bad-signature-3.stderr | 10 + .../allocator/auxiliary/system-allocator.rs | 18 + .../allocator/auxiliary/system-allocator2.rs | 18 + .../allocator/function-allocator.rs | 15 + .../allocator/function-allocator.stderr | 8 + .../allocator/not-an-allocator.rs | 18 + .../allocator/not-an-allocator.stderr | 35 + .../allocator/two-allocators.rs | 20 + .../allocator/two-allocators.stderr | 8 + .../allocator/two-allocators2.rs | 23 + .../allocator/two-allocators2.stderr | 4 + .../allocator/two-allocators3.rs | 20 + .../allocator/two-allocators3.stderr | 4 + .../anon-params-deprecated.rs | 25 + .../anon-params-deprecated.stderr | 34 + .../compile-fail-migration/arg-count-mismatch.rs | 15 + .../arg-count-mismatch.stderr | 12 + .../ui/compile-fail-migration/arg-type-mismatch.rs | 16 + .../arg-type-mismatch.stderr | 12 + .../ui/compile-fail-migration/array-not-vector.rs | 24 + .../compile-fail-migration/array-not-vector.stderr | 21 + .../compile-fail-migration/array_const_index-0.rs | 18 + .../array_const_index-0.stderr | 12 + .../compile-fail-migration/array_const_index-1.rs | 18 + .../array_const_index-1.stderr | 12 + .../ui/compile-fail-migration/asm-bad-clobber.rs | 35 + .../compile-fail-migration/asm-bad-clobber.stderr | 9 + .../compile-fail-migration/asm-in-bad-modifier.rs | 44 ++ .../asm-in-bad-modifier.stderr | 16 + .../compile-fail-migration/asm-misplaced-option.rs | 47 ++ .../asm-misplaced-option.stderr | 26 + .../compile-fail-migration/asm-out-no-modifier.rs | 41 ++ .../asm-out-no-modifier.stderr | 9 + .../asm-out-read-uninit.ast.stderr | 9 + .../asm-out-read-uninit.mir.stderr | 9 + .../compile-fail-migration/asm-out-read-uninit.rs | 46 ++ .../asm-src-loc-codegen-units.rs | 22 + .../asm-src-loc-codegen-units.stderr | 11 + src/test/ui/compile-fail-migration/asm-src-loc.rs | 19 + .../ui/compile-fail-migration/asm-src-loc.stderr | 11 + .../assign-imm-local-twice.ast.nll.stderr | 15 + .../assign-imm-local-twice.ast.stderr | 12 + .../assign-imm-local-twice.mir.stderr | 15 + .../assign-imm-local-twice.rs | 28 + .../ui/compile-fail-migration/assign-to-method.rs | 31 + .../compile-fail-migration/assign-to-method.stderr | 11 + .../assignment-operator-unimplemented.rs | 17 + .../assignment-operator-unimplemented.stderr | 13 + .../ui/compile-fail-migration/assoc-inherent.rs | 19 + .../compile-fail-migration/assoc-inherent.stderr | 9 + .../associated-const-ambiguity-report.rs | 32 + .../associated-const-ambiguity-report.stderr | 20 + .../associated-const-array-len.rs | 21 + .../associated-const-array-len.stderr | 15 + .../associated-const-dead-code.rs | 22 + .../associated-const-dead-code.stderr | 14 + .../associated-const-generic-obligations.rs | 29 + .../associated-const-generic-obligations.stderr | 11 + .../associated-const-in-trait.rs | 24 + .../associated-const-in-trait.stderr | 11 + .../associated-const-no-item.rs | 21 + .../associated-const-no-item.stderr | 13 + .../associated-const-private-impl.rs | 26 + .../associated-const-private-impl.stderr | 9 + .../associated-const-type-parameter-arms.rs | 40 ++ .../associated-const-type-parameter-arms.stderr | 15 + .../associated-const-type-parameter-arrays-2.rs | 32 + ...associated-const-type-parameter-arrays-2.stderr | 16 + .../associated-const-type-parameter-arrays.rs | 32 + .../associated-const-type-parameter-arrays.stderr | 16 + .../associated-const-upper-case-lint.rs | 21 + .../associated-const-upper-case-lint.stderr | 14 + .../associated-item-duplicate-names-2.rs | 19 + .../associated-item-duplicate-names-2.stderr | 11 + .../associated-item-duplicate-names-3.rs | 28 + .../associated-item-duplicate-names-3.stderr | 11 + .../associated-item-duplicate-names.rs | 29 + .../associated-item-duplicate-names.stderr | 19 + .../compile-fail-migration/associated-path-shl.rs | 20 + .../associated-path-shl.stderr | 43 ++ ...jection-ambig-between-bound-and-where-clause.rs | 52 ++ ...ion-ambig-between-bound-and-where-clause.stderr | 75 +++ .../associated-type-projection-from-supertrait.rs | 54 ++ ...sociated-type-projection-from-supertrait.stderr | 39 ++ ...-types-binding-to-type-defined-in-supertrait.rs | 51 ++ ...es-binding-to-type-defined-in-supertrait.stderr | 31 + .../associated-types-bound-failure.rs | 37 ++ .../associated-types-bound-failure.stderr | 16 + .../associated-types-coherence-failure.rs | 59 ++ .../associated-types-coherence-failure.stderr | 21 + .../associated-types-eq-1.rs | 23 + .../associated-types-eq-1.stderr | 9 + .../associated-types-eq-2.rs | 29 + .../associated-types-eq-2.stderr | 9 + .../associated-types-eq-3.rs | 54 ++ .../associated-types-eq-3.stderr | 37 ++ .../associated-types-eq-expr-path.rs | 26 + .../associated-types-eq-expr-path.stderr | 9 + .../associated-types-eq-hr.rs | 109 +++ .../associated-types-eq-hr.stderr | 126 ++++ .../associated-types-for-unimpl-trait.rs | 22 + .../associated-types-for-unimpl-trait.stderr | 11 + .../associated-types-incomplete-object.rs | 42 ++ .../associated-types-incomplete-object.stderr | 27 + ...sociated-types-invalid-trait-ref-issue-18865.rs | 24 + ...ated-types-invalid-trait-ref-issue-18865.stderr | 11 + .../associated-types-issue-17359.rs | 20 + .../associated-types-issue-17359.stderr | 12 + .../associated-types-issue-20346.rs | 45 ++ .../associated-types-issue-20346.stderr | 17 + .../associated-types-multiple-types-one-trait.rs | 56 ++ ...ssociated-types-multiple-types-one-trait.stderr | 31 + .../associated-types-no-suitable-bound.rs | 26 + .../associated-types-no-suitable-bound.stderr | 11 + .../associated-types-no-suitable-supertrait-2.rs | 31 + ...ssociated-types-no-suitable-supertrait-2.stderr | 11 + .../associated-types-no-suitable-supertrait.rs | 36 + .../associated-types-no-suitable-supertrait.stderr | 17 + .../associated-types-outlives.nll.stderr | 13 + .../associated-types-outlives.rs | 38 ++ .../associated-types-outlives.stderr | 11 + .../associated-types-overridden-default.rs | 25 + .../associated-types-overridden-default.stderr | 9 + .../associated-types-path-1.rs | 23 + .../associated-types-path-1.stderr | 22 + .../associated-types-path-2.rs | 56 ++ .../associated-types-path-2.stderr | 52 ++ ...d-types-project-from-hrtb-in-fn-body.nll.stderr | 30 + ...ssociated-types-project-from-hrtb-in-fn-body.rs | 36 + ...iated-types-project-from-hrtb-in-fn-body.stderr | 14 + .../associated-types-project-from-hrtb-in-fn.rs | 45 ++ ...associated-types-project-from-hrtb-in-fn.stderr | 9 + ...associated-types-project-from-hrtb-in-struct.rs | 35 + ...ciated-types-project-from-hrtb-in-struct.stderr | 9 + ...ated-types-project-from-hrtb-in-trait-method.rs | 33 + ...-types-project-from-hrtb-in-trait-method.stderr | 9 + ...to-unrelated-trait-in-method-without-default.rs | 39 ++ ...nrelated-trait-in-method-without-default.stderr | 11 + .../associated-types-subtyping-1.rs | 55 ++ .../associated-types-subtyping-1.stderr | 21 + .../associated-types-unconstrained.rs | 26 + .../associated-types-unconstrained.stderr | 9 + .../associated-types-unsized.rs | 21 + .../associated-types-unsized.stderr | 14 + .../bound-lifetime-constrained.clause.stderr | 15 + .../bound-lifetime-constrained.func.stderr | 15 + .../bound-lifetime-constrained.object.stderr | 15 + .../associated-types/bound-lifetime-constrained.rs | 58 ++ .../bound-lifetime-in-binding-only.angle.stderr | 27 + .../bound-lifetime-in-binding-only.elision.stderr | 12 + .../bound-lifetime-in-binding-only.ok.stderr | 8 + .../bound-lifetime-in-binding-only.paren.stderr | 27 + .../bound-lifetime-in-binding-only.rs | 81 +++ .../bound-lifetime-in-return-only.elision.stderr | 12 + .../bound-lifetime-in-return-only.local.stderr | 9 + .../bound-lifetime-in-return-only.ok.stderr | 8 + .../bound-lifetime-in-return-only.rs | 59 ++ .../bound-lifetime-in-return-only.sig.stderr | 15 + .../bound-lifetime-in-return-only.structure.stderr | 9 + .../associated-types/cache/chrono-scan.rs | 39 ++ .../associated-types/cache/chrono-scan.stderr | 8 + .../associated-types/cache/elision.rs | 34 + .../associated-types/cache/elision.stderr | 8 + ...ject-fn-ret-contravariant.krisskross.nll.stderr | 35 + .../project-fn-ret-contravariant.krisskross.stderr | 25 + .../cache/project-fn-ret-contravariant.ok.stderr | 8 + .../project-fn-ret-contravariant.oneuse.stderr | 8 + .../cache/project-fn-ret-contravariant.rs | 62 ++ ...oject-fn-ret-contravariant.transmute.nll.stderr | 16 + .../project-fn-ret-contravariant.transmute.stderr | 26 + .../project-fn-ret-invariant.krisskross.nll.stderr | 35 + .../project-fn-ret-invariant.krisskross.stderr | 24 + .../cache/project-fn-ret-invariant.ok.stderr | 8 + .../project-fn-ret-invariant.oneuse.nll.stderr | 30 + .../cache/project-fn-ret-invariant.oneuse.stderr | 14 + .../cache/project-fn-ret-invariant.rs | 70 ++ .../project-fn-ret-invariant.transmute.nll.stderr | 17 + .../project-fn-ret-invariant.transmute.stderr | 22 + .../higher-ranked-projection.bad.stderr | 17 + .../higher-ranked-projection.good.stderr | 12 + .../associated-types/higher-ranked-projection.rs | 38 ++ .../associated-types/issue-36499.rs | 15 + .../associated-types/issue-36499.stderr | 8 + .../attempted-access-non-fatal.rs | 16 + .../attempted-access-non-fatal.stderr | 15 + .../compile-fail-migration/attr-bad-crate-attr.rc | 14 + .../ui/compile-fail-migration/attr-usage-inline.rs | 19 + .../attr-usage-inline.stderr | 11 + .../attrs-with-no-formal-in-generics-1.rs | 25 + .../attrs-with-no-formal-in-generics-1.stderr | 8 + .../attrs-with-no-formal-in-generics-2.rs | 22 + .../attrs-with-no-formal-in-generics-2.stderr | 8 + .../attrs-with-no-formal-in-generics-3.rs | 26 + .../attrs-with-no-formal-in-generics-3.stderr | 8 + .../auto-ref-slice-plus-ref.rs | 38 ++ .../auto-ref-slice-plus-ref.stderr | 44 ++ .../auto-trait-validation.rs | 19 + .../auto-trait-validation.stderr | 22 + .../compile-fail-migration/autoderef-full-lval.rs | 35 + .../autoderef-full-lval.stderr | 19 + .../auxiliary/ambig_impl_2_lib.rs | 14 + .../compile-fail-migration/auxiliary/cci_class.rs | 24 + .../auxiliary/cci_class_5.rs | 27 + .../compile-fail-migration/auxiliary/cdylib-dep.rs | 11 + .../auxiliary/coherence_copy_like_lib.rs | 20 + .../auxiliary/coherence_inherent_cc_lib.rs | 21 + .../auxiliary/coherence_lib.rs | 25 + .../auxiliary/coherence_orphan_lib.rs | 13 + .../auxiliary/const_fn_lib.rs | 16 + .../compile-fail-migration/auxiliary/crate_a1.rs | 21 + .../compile-fail-migration/auxiliary/crate_a2.rs | 17 + .../auxiliary/crateresolve1-1.rs | 15 + .../auxiliary/crateresolve1-2.rs | 15 + .../auxiliary/crateresolve1-3.rs | 15 + .../default_ty_param_cross_crate_crate.rs | 20 + .../auxiliary/define_macro.rs | 16 + .../auxiliary/deprecation-lint.rs | 108 +++ .../auxiliary/edition-extern-crate-allowed.rs | 11 + .../auxiliary/empty-struct.rs | 19 + .../auxiliary/extern-statics.rs | 14 + .../compile-fail-migration/auxiliary/go_trait.rs | 53 ++ .../auxiliary/import_crate_var.rs | 17 + .../auxiliary/inherited_stability.rs | 56 ++ .../auxiliary/internal_unstable.rs | 102 +++ .../auxiliary/issue-19163.rs | 16 + .../auxiliary/issue-21146-inc.rs | 13 + .../auxiliary/issue-29181.rs | 15 + .../auxiliary/issue-30535.rs | 15 + .../auxiliary/issue-36881-aux.rs | 11 + .../auxiliary/issue-52489.rs | 13 + .../auxiliary/issue_11680.rs | 19 + .../auxiliary/issue_16725.rs | 13 + .../auxiliary/issue_17718_const_privacy.rs | 18 + .../compile-fail-migration/auxiliary/issue_1920.rs | 14 + .../auxiliary/issue_21202.rs | 16 + .../auxiliary/issue_30123_aux.rs | 33 + .../auxiliary/issue_41549.rs | 14 + .../auxiliary/issue_5844_aux.rs | 13 + .../lifetime_bound_will_change_warning_lib.rs | 21 + .../auxiliary/lint_output_format.rs | 30 + .../auxiliary/lint_stability.rs | 198 ++++++ .../auxiliary/lint_stability_fields.rs | 61 ++ .../auxiliary/lint_unused_extern_crate.rs | 11 + .../auxiliary/lint_unused_extern_crate2.rs | 11 + .../auxiliary/lint_unused_extern_crate3.rs | 11 + .../auxiliary/lint_unused_extern_crate4.rs | 9 + .../auxiliary/lint_unused_extern_crate5.rs | 9 + .../auxiliary/lto-duplicate-symbols1.rs | 16 + .../auxiliary/lto-duplicate-symbols2.rs | 16 + .../auxiliary/macro_crate_nonterminal.rs | 22 + .../auxiliary/namespace-mix.rs | 76 +++ .../auxiliary/namespaced_enums.rs | 20 + .../auxiliary/noexporttypelib.rs | 12 + .../auxiliary/orphan_check_diagnostics.rs | 11 + .../auxiliary/privacy_tuple_struct.rs | 14 + .../auxiliary/private-inferred-type.rs | 46 ++ .../auxiliary/private_trait_xc.rs | 11 + .../auxiliary/rbmtp_cross_crate_lib.rs | 42 ++ .../auxiliary/recursive_reexports.rs | 13 + .../compile-fail-migration/auxiliary/rmeta_meta.rs | 18 + .../compile-fail-migration/auxiliary/rmeta_rlib.rs | 15 + .../auxiliary/some-panic-impl.rs | 22 + .../auxiliary/stability_attribute_issue.rs | 19 + .../auxiliary/stability_cfg1.rs | 13 + .../auxiliary/stability_cfg2.rs | 15 + .../auxiliary/static_priv_by_default.rs | 61 ++ .../auxiliary/struct_field_privacy.rs | 19 + .../auxiliary/struct_variant_privacy.rs | 13 + .../auxiliary/tdticc_coherence_lib.rs | 16 + .../trait_bounds_on_structs_and_enums_xc.rs | 23 + .../auxiliary/trait_impl_conflict.rs | 16 + .../auxiliary/trait_safety_lib.rs | 19 + .../auxiliary/trait_superkinds_in_metadata.rs | 18 + .../compile-fail-migration/auxiliary/two_macros.rs | 15 + .../auxiliary/unreachable_variant.rs | 15 + .../auxiliary/unstable-macros.rs | 16 + .../auxiliary/use_from_trait_xc.rs | 40 ++ .../auxiliary/variant-namespacing.rs | 15 + .../auxiliary/weak-lang-items.rs | 32 + .../auxiliary/xc_private_method_lib.rs | 43 ++ .../auxiliary/xcrate_unit_struct.rs | 38 ++ .../ui/compile-fail-migration/bad-const-type.rs | 16 + .../compile-fail-migration/bad-const-type.stderr | 15 + .../ui/compile-fail-migration/bad-env-capture.rs | 16 + .../compile-fail-migration/bad-env-capture.stderr | 24 + .../ui/compile-fail-migration/bad-env-capture2.rs | 15 + .../compile-fail-migration/bad-env-capture2.stderr | 24 + .../ui/compile-fail-migration/bad-env-capture3.rs | 18 + .../compile-fail-migration/bad-env-capture3.stderr | 24 + src/test/ui/compile-fail-migration/bad-expr-lhs.rs | 20 + .../ui/compile-fail-migration/bad-expr-lhs.stderr | 34 + .../ui/compile-fail-migration/bad-expr-path.rs | 18 + .../ui/compile-fail-migration/bad-expr-path.stderr | 31 + .../ui/compile-fail-migration/bad-expr-path2.rs | 20 + .../compile-fail-migration/bad-expr-path2.stderr | 31 + .../bad-extern-link-attrs.rs | 17 + .../bad-extern-link-attrs.stderr | 24 + .../bad-intrinsic-monomorphization.rs | 40 ++ .../bad-intrinsic-monomorphization.stderr | 21 + src/test/ui/compile-fail-migration/bad-lint-cap.rs | 14 + .../ui/compile-fail-migration/bad-lint-cap.stderr | 2 + .../ui/compile-fail-migration/bad-lint-cap2.rs | 18 + .../ui/compile-fail-migration/bad-lint-cap2.stderr | 15 + .../ui/compile-fail-migration/bad-lint-cap3.rs | 21 + .../ui/compile-fail-migration/bad-lint-cap3.stderr | 21 + src/test/ui/compile-fail-migration/bad-main.rs | 11 + src/test/ui/compile-fail-migration/bad-main.stderr | 12 + .../bad-method-typaram-kind.rs | 24 + .../bad-method-typaram-kind.stderr | 12 + .../bad-mid-path-type-params.rs | 53 ++ .../bad-mid-path-type-params.stderr | 28 + src/test/ui/compile-fail-migration/bad-module.rs | 17 + .../ui/compile-fail-migration/bad-module.stderr | 15 + src/test/ui/compile-fail-migration/bad-sized.rs | 18 + .../ui/compile-fail-migration/bad-sized.stderr | 30 + .../compile-fail-migration/bad-type-env-capture.rs | 14 + .../bad-type-env-capture.stderr | 13 + ...-neither-can-live-while-the-other-survives-2.rs | 25 + ...ther-can-live-while-the-other-survives-2.stderr | 11 + ...-neither-can-live-while-the-other-survives-3.rs | 28 + ...ther-can-live-while-the-other-survives-3.stderr | 11 + ...-neither-can-live-while-the-other-survives-4.rs | 25 + ...ther-can-live-while-the-other-survives-4.stderr | 11 + .../bind-by-move-no-guards.rs | 23 + .../bind-by-move-no-guards.stderr | 9 + .../ui/compile-fail-migration/binop-bitxor-str.rs | 13 + .../compile-fail-migration/binop-bitxor-str.stderr | 11 + .../compile-fail-migration/binop-consume-args.rs | 75 +++ .../binop-consume-args.stderr | 213 ++++++ .../ui/compile-fail-migration/binop-logic-float.rs | 14 + .../binop-logic-float.stderr | 15 + .../ui/compile-fail-migration/binop-logic-int.rs | 13 + .../compile-fail-migration/binop-logic-int.stderr | 21 + .../binop-move-semantics.nll.stderr | 68 ++ .../compile-fail-migration/binop-move-semantics.rs | 75 +++ .../binop-move-semantics.stderr | 80 +++ .../ui/compile-fail-migration/binop-mul-bool.rs | 13 + .../compile-fail-migration/binop-mul-bool.stderr | 11 + src/test/ui/compile-fail-migration/binop-typeck.rs | 18 + .../ui/compile-fail-migration/binop-typeck.stderr | 11 + .../blind-item-block-item-shadow.rs | 19 + .../blind-item-block-item-shadow.stderr | 17 + .../blind-item-block-middle.rs | 17 + .../blind-item-block-middle.stderr | 12 + .../borrow-immutable-upvar-mutation.nll.stderr | 76 +++ .../borrow-immutable-upvar-mutation.rs | 45 ++ .../borrow-immutable-upvar-mutation.stderr | 78 +++ .../compile-fail-migration/borrow-tuple-fields.rs | 42 ++ .../borrow-tuple-fields.stderr | 63 ++ .../borrowck-access-permissions.ast.nll.stderr | 53 ++ .../borrowck-access-permissions.ast.stderr | 46 ++ .../borrowck-access-permissions.mir.stderr | 53 ++ .../borrowck/borrowck-access-permissions.rs | 70 ++ .../borrowck/borrowck-and-init.nll.stderr | 9 + .../borrowck/borrowck-and-init.rs | 16 + .../borrowck/borrowck-and-init.stderr | 9 + .../borrowck-anon-fields-struct.nll.stderr | 40 ++ .../borrowck/borrowck-anon-fields-struct.rs | 47 ++ .../borrowck/borrowck-anon-fields-struct.stderr | 15 + .../borrowck/borrowck-anon-fields-tuple.nll.stderr | 40 ++ .../borrowck/borrowck-anon-fields-tuple.rs | 45 ++ .../borrowck/borrowck-anon-fields-tuple.stderr | 15 + .../borrowck-anon-fields-variant.nll.stderr | 40 ++ .../borrowck/borrowck-anon-fields-variant.rs | 53 ++ .../borrowck/borrowck-anon-fields-variant.stderr | 15 + .../borrowck/borrowck-argument.nll.stderr | 35 + .../borrowck/borrowck-argument.rs | 43 ++ .../borrowck/borrowck-argument.stderr | 35 + .../borrowck/borrowck-asm.ast.nll.stderr | 79 +++ .../borrowck/borrowck-asm.ast.stderr | 76 +++ .../borrowck/borrowck-asm.mir.stderr | 79 +++ .../borrowck/borrowck-asm.rs | 102 +++ .../borrowck/borrowck-assign-comp-idx.nll.stderr | 27 + .../borrowck/borrowck-assign-comp-idx.rs | 49 ++ .../borrowck/borrowck-assign-comp-idx.stderr | 26 + .../borrowck/borrowck-assign-comp.ast.nll.stderr | 37 ++ .../borrowck/borrowck-assign-comp.ast.stderr | 28 + .../borrowck/borrowck-assign-comp.mir.stderr | 37 ++ .../borrowck/borrowck-assign-comp.rs | 52 ++ ...ck-assign-to-andmut-in-aliasable-loc.nll.stderr | 19 + .../borrowck-assign-to-andmut-in-aliasable-loc.rs | 30 + ...rrowck-assign-to-andmut-in-aliasable-loc.stderr | 19 + ...wck-assign-to-andmut-in-borrowed-loc.nll.stderr | 24 + .../borrowck-assign-to-andmut-in-borrowed-loc.rs | 31 + ...orrowck-assign-to-andmut-in-borrowed-loc.stderr | 11 + .../borrowck-assign-to-constants.ast.nll.stderr | 9 + .../borrowck-assign-to-constants.ast.stderr | 9 + .../borrowck-assign-to-constants.mir.stderr | 9 + .../borrowck/borrowck-assign-to-constants.rs | 20 + .../borrowck-auto-mut-ref-to-immut-var.nll.stderr | 11 + .../borrowck/borrowck-auto-mut-ref-to-immut-var.rs | 26 + .../borrowck-auto-mut-ref-to-immut-var.stderr | 11 + .../borrowck/borrowck-autoref-3261.nll.stderr | 22 + .../borrowck/borrowck-autoref-3261.rs | 34 + .../borrowck/borrowck-autoref-3261.stderr | 17 + .../borrowck-bad-nested-calls-free.nll.stderr | 25 + .../borrowck/borrowck-bad-nested-calls-free.rs | 45 ++ .../borrowck/borrowck-bad-nested-calls-free.stderr | 23 + .../borrowck-bad-nested-calls-move.nll.stderr | 25 + .../borrowck/borrowck-bad-nested-calls-move.rs | 45 ++ .../borrowck/borrowck-bad-nested-calls-move.stderr | 19 + .../borrowck/borrowck-block-unint.nll.stderr | 11 + .../borrowck/borrowck-block-unint.rs | 17 + .../borrowck/borrowck-block-unint.stderr | 9 + .../borrowck-borrow-from-owned-ptr.nll.stderr | 127 ++++ .../borrowck/borrowck-borrow-from-owned-ptr.rs | 144 ++++ .../borrowck/borrowck-borrow-from-owned-ptr.stderr | 168 +++++ .../borrowck-borrow-from-stack-variable.nll.stderr | 127 ++++ .../borrowck-borrow-from-stack-variable.rs | 141 ++++ .../borrowck-borrow-from-stack-variable.stderr | 124 ++++ .../borrowck/borrowck-borrow-from-temporary.rs | 24 + .../borrowck/borrowck-borrow-from-temporary.stderr | 18 + ...wck-borrow-immut-deref-of-box-as-mut.nll.stderr | 11 + .../borrowck-borrow-immut-deref-of-box-as-mut.rs | 24 + ...orrowck-borrow-immut-deref-of-box-as-mut.stderr | 11 + ...borrow-mut-base-ptr-in-aliasable-loc.nll.stderr | 31 + ...orrowck-borrow-mut-base-ptr-in-aliasable-loc.rs | 34 + ...wck-borrow-mut-base-ptr-in-aliasable-loc.stderr | 29 + .../borrowck/borrowck-borrow-mut-object-twice.rs | 24 + .../borrowck-borrow-mut-object-twice.stderr | 13 + ...orrowck-borrow-overloaded-auto-deref.nll.stderr | 88 +++ .../borrowck-borrow-overloaded-auto-deref.rs | 124 ++++ .../borrowck-borrow-overloaded-auto-deref.stderr | 88 +++ .../borrowck-borrow-overloaded-deref.nll.stderr | 46 ++ .../borrowck/borrowck-borrow-overloaded-deref.rs | 64 ++ .../borrowck-borrow-overloaded-deref.stderr | 46 ++ .../borrowck-borrowed-uniq-rvalue-2.nll.stderr | 15 + .../borrowck/borrowck-borrowed-uniq-rvalue-2.rs | 34 + .../borrowck-borrowed-uniq-rvalue-2.stderr | 17 + .../borrowck-borrowed-uniq-rvalue.nll.stderr | 14 + .../borrowck/borrowck-borrowed-uniq-rvalue.rs | 25 + .../borrowck/borrowck-borrowed-uniq-rvalue.stderr | 16 + .../borrowck/borrowck-break-uninit-2.nll.stderr | 9 + .../borrowck/borrowck-break-uninit-2.rs | 24 + .../borrowck/borrowck-break-uninit-2.stderr | 9 + .../borrowck/borrowck-break-uninit.nll.stderr | 9 + .../borrowck/borrowck-break-uninit.rs | 24 + .../borrowck/borrowck-break-uninit.stderr | 9 + .../borrowck-closures-mut-and-imm.ast.nll.stderr | 116 ++++ .../borrowck-closures-mut-and-imm.ast.stderr | 96 +++ .../borrowck-closures-mut-and-imm.mir.stderr | 116 ++++ .../borrowck/borrowck-closures-mut-and-imm.rs | 101 +++ .../borrowck-closures-mut-of-imm.nll.stderr | 15 + .../borrowck/borrowck-closures-mut-of-imm.rs | 31 + .../borrowck/borrowck-closures-mut-of-imm.stderr | 32 + .../borrowck/borrowck-closures-two-mut.rs | 60 ++ .../borrowck/borrowck-closures-two-mut.stderr | 75 +++ .../borrowck/borrowck-closures-unique-imm.rs | 24 + .../borrowck/borrowck-closures-unique-imm.stderr | 13 + .../borrowck/borrowck-closures-unique.rs | 50 ++ .../borrowck/borrowck-closures-unique.stderr | 56 ++ .../borrowck-closures-use-after-free.nll.stderr | 17 + .../borrowck/borrowck-closures-use-after-free.rs | 33 + .../borrowck-closures-use-after-free.stderr | 16 + .../borrowck/borrowck-consume-unsize-vec.rs | 22 + .../borrowck/borrowck-consume-unsize-vec.stderr | 13 + .../borrowck-consume-upcast-box.nll.stderr | 13 + .../borrowck/borrowck-consume-upcast-box.rs | 24 + .../borrowck/borrowck-consume-upcast-box.stderr | 13 + .../borrowck-describe-lvalue.ast.nll.stderr | 543 +++++++++++++++ .../borrowck/borrowck-describe-lvalue.ast.stderr | 246 +++++++ .../borrowck/borrowck-describe-lvalue.mir.stderr | 543 +++++++++++++++ .../borrowck/borrowck-describe-lvalue.rs | 324 +++++++++ .../borrowck/borrowck-drop-from-guard.rs | 24 + .../borrowck/borrowck-drop-from-guard.stderr | 14 + .../borrowck/borrowck-field-sensitivity.nll.stderr | 110 ++++ .../borrowck/borrowck-field-sensitivity.rs | 126 ++++ .../borrowck/borrowck-field-sensitivity.stderr | 129 ++++ .../borrowck/borrowck-fn-in-const-a.ast.stderr | 9 + .../borrowck/borrowck-fn-in-const-a.mir.stderr | 9 + .../borrowck/borrowck-fn-in-const-a.rs | 26 + .../borrowck/borrowck-fn-in-const-c.nll.stderr | 13 + .../borrowck/borrowck-fn-in-const-c.rs | 33 + .../borrowck/borrowck-fn-in-const-c.stderr | 13 + ...wck-for-loop-correct-cmt-for-pattern.nll.stderr | 30 + .../borrowck-for-loop-correct-cmt-for-pattern.rs | 34 + ...orrowck-for-loop-correct-cmt-for-pattern.stderr | 30 + .../borrowck-for-loop-head-linkage.nll.stderr | 27 + .../borrowck/borrowck-for-loop-head-linkage.rs | 20 + .../borrowck/borrowck-for-loop-head-linkage.stderr | 27 + .../borrowck/borrowck-if-no-else.rs | 16 + .../borrowck/borrowck-if-no-else.stderr | 9 + .../borrowck/borrowck-if-with-else.rs | 21 + .../borrowck/borrowck-if-with-else.stderr | 9 + ...ef-to-mut-rec-field-issue-3162-c.ast.nll.stderr | 15 + ...mm-ref-to-mut-rec-field-issue-3162-c.ast.stderr | 12 + ...mm-ref-to-mut-rec-field-issue-3162-c.mir.stderr | 15 + ...rrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs | 24 + .../borrowck/borrowck-init-in-called-fn-expr.rs | 17 + .../borrowck-init-in-called-fn-expr.stderr | 9 + .../borrowck/borrowck-init-in-fn-expr.rs | 17 + .../borrowck/borrowck-init-in-fn-expr.stderr | 9 + .../borrowck/borrowck-init-in-fru.ast.nll.stderr | 9 + .../borrowck/borrowck-init-in-fru.ast.stderr | 9 + .../borrowck/borrowck-init-in-fru.mir.stderr | 9 + .../borrowck/borrowck-init-in-fru.rs | 26 + .../borrowck/borrowck-init-op-equal.rs | 19 + .../borrowck/borrowck-init-op-equal.stderr | 9 + .../borrowck/borrowck-init-plus-equal.rs | 18 + .../borrowck/borrowck-init-plus-equal.stderr | 9 + .../borrowck-insert-during-each.nll.stderr | 36 + .../borrowck/borrowck-insert-during-each.rs | 35 + .../borrowck/borrowck-insert-during-each.stderr | 15 + .../borrowck/borrowck-issue-14498.ast.nll.stderr | 108 +++ .../borrowck/borrowck-issue-14498.ast.stderr | 82 +++ .../borrowck/borrowck-issue-14498.mir.stderr | 108 +++ .../borrowck/borrowck-issue-14498.rs | 132 ++++ .../borrowck/borrowck-issue-2657-1.rs | 21 + .../borrowck/borrowck-issue-2657-1.stderr | 11 + .../borrowck/borrowck-issue-2657-2.nll.stderr | 12 + .../borrowck/borrowck-issue-2657-2.rs | 21 + .../borrowck/borrowck-issue-2657-2.stderr | 12 + .../borrowck/borrowck-issue-48962.rs | 38 ++ .../borrowck/borrowck-issue-48962.stderr | 23 + .../borrowck/borrowck-lend-flow-if.rs | 54 ++ .../borrowck/borrowck-lend-flow-if.stderr | 14 + .../borrowck/borrowck-lend-flow-loop.nll.stderr | 26 + .../borrowck/borrowck-lend-flow-loop.rs | 150 +++++ .../borrowck/borrowck-lend-flow-loop.stderr | 93 +++ .../borrowck-lend-flow-match.ast.nll.stderr | 14 + .../borrowck/borrowck-lend-flow-match.ast.stderr | 11 + .../borrowck/borrowck-lend-flow-match.mir.stderr | 14 + .../borrowck/borrowck-lend-flow-match.rs | 36 + .../borrowck/borrowck-lend-flow.rs | 45 ++ .../borrowck/borrowck-lend-flow.stderr | 13 + .../borrowck/borrowck-loan-blocks-move-cc.rs | 38 ++ .../borrowck/borrowck-loan-blocks-move-cc.stderr | 21 + .../borrowck/borrowck-loan-blocks-move.rs | 23 + .../borrowck/borrowck-loan-blocks-move.stderr | 11 + .../borrowck-loan-blocks-mut-uniq.nll.stderr | 19 + .../borrowck/borrowck-loan-blocks-mut-uniq.rs | 28 + .../borrowck/borrowck-loan-blocks-mut-uniq.stderr | 16 + .../borrowck-loan-in-overloaded-op.nll.stderr | 13 + .../borrowck/borrowck-loan-in-overloaded-op.rs | 33 + .../borrowck/borrowck-loan-in-overloaded-op.stderr | 13 + ...owck-loan-of-static-data-issue-27616.nll.stderr | 14 + .../borrowck-loan-of-static-data-issue-27616.rs | 34 + ...borrowck-loan-of-static-data-issue-27616.stderr | 12 + .../borrowck-loan-rcvr-overloaded-op.nll.stderr | 28 + .../borrowck/borrowck-loan-rcvr-overloaded-op.rs | 56 ++ .../borrowck-loan-rcvr-overloaded-op.stderr | 25 + .../borrowck/borrowck-loan-rcvr.nll.stderr | 27 + .../borrowck/borrowck-loan-rcvr.rs | 51 ++ .../borrowck/borrowck-loan-rcvr.stderr | 26 + .../borrowck/borrowck-loan-vec-content.nll.stderr | 16 + .../borrowck/borrowck-loan-vec-content.rs | 34 + .../borrowck/borrowck-loan-vec-content.stderr | 15 + ...orrowck-local-borrow-outlives-fn.ast.nll.stderr | 14 + .../borrowck-local-borrow-outlives-fn.ast.stderr | 14 + .../borrowck-local-borrow-outlives-fn.mir.stderr | 14 + .../borrowck/borrowck-local-borrow-outlives-fn.rs | 20 + ...al-borrow-with-panic-outlives-fn.ast.nll.stderr | 14 + ...-local-borrow-with-panic-outlives-fn.ast.stderr | 14 + ...-local-borrow-with-panic-outlives-fn.mir.stderr | 14 + ...borrowck-local-borrow-with-panic-outlives-fn.rs | 24 + .../borrowck-match-already-borrowed.ast.nll.stderr | 73 +++ .../borrowck-match-already-borrowed.ast.stderr | 30 + .../borrowck-match-already-borrowed.mir.stderr | 73 +++ .../borrowck/borrowck-match-already-borrowed.rs | 42 ++ ...owck-match-binding-is-assignment.ast.nll.stderr | 58 ++ ...borrowck-match-binding-is-assignment.ast.stderr | 43 ++ ...borrowck-match-binding-is-assignment.mir.stderr | 58 ++ .../borrowck-match-binding-is-assignment.rs | 59 ++ .../borrowck/borrowck-move-by-capture.nll.stderr | 9 + .../borrowck/borrowck-move-by-capture.rs | 21 + .../borrowck/borrowck-move-by-capture.stderr | 12 + .../borrowck-move-from-subpath-of-borrowed-path.rs | 21 + ...rowck-move-from-subpath-of-borrowed-path.stderr | 12 + .../borrowck-move-from-unsafe-ptr.nll.stderr | 12 + .../borrowck/borrowck-move-from-unsafe-ptr.rs | 18 + .../borrowck/borrowck-move-from-unsafe-ptr.stderr | 12 + .../borrowck-move-in-irrefut-pat.ast.nll.stderr | 32 + .../borrowck-move-in-irrefut-pat.ast.stderr | 30 + .../borrowck-move-in-irrefut-pat.mir.stderr | 32 + .../borrowck/borrowck-move-in-irrefut-pat.rs | 32 + ...ck-move-moved-value-into-closure.ast.nll.stderr | 17 + ...rrowck-move-moved-value-into-closure.ast.stderr | 13 + ...rrowck-move-moved-value-into-closure.mir.stderr | 17 + .../borrowck-move-moved-value-into-closure.rs | 26 + .../borrowck/borrowck-move-mut-base-ptr.rs | 23 + .../borrowck/borrowck-move-mut-base-ptr.stderr | 11 + .../borrowck-move-out-from-array.ast.nll.stderr | 19 + .../borrowck-move-out-from-array.ast.stderr | 23 + .../borrowck-move-out-from-array.mir.stderr | 19 + .../borrowck/borrowck-move-out-from-array.rs | 31 + ...ck-move-out-of-overloaded-auto-deref.ast.stderr | 9 + ...ck-move-out-of-overloaded-auto-deref.mir.stderr | 9 + .../borrowck-move-out-of-overloaded-auto-deref.rs | 20 + .../borrowck-move-out-of-overloaded-deref.rs | 16 + .../borrowck-move-out-of-overloaded-deref.stderr | 12 + .../borrowck-move-out-of-static-item.ast.stderr | 9 + .../borrowck-move-out-of-static-item.mir.stderr | 9 + .../borrowck/borrowck-move-out-of-static-item.rs | 30 + ...wck-move-out-of-struct-with-dtor.ast.nll.stderr | 34 + ...orrowck-move-out-of-struct-with-dtor.ast.stderr | 30 + ...orrowck-move-out-of-struct-with-dtor.mir.stderr | 34 + .../borrowck-move-out-of-struct-with-dtor.rs | 38 ++ ...k-move-out-of-tuple-struct-with-dtor.nll.stderr | 33 + .../borrowck-move-out-of-tuple-struct-with-dtor.rs | 32 + ...rowck-move-out-of-tuple-struct-with-dtor.stderr | 30 + .../borrowck/borrowck-move-subcomponent.nll.stderr | 13 + .../borrowck/borrowck-move-subcomponent.rs | 27 + .../borrowck/borrowck-move-subcomponent.stderr | 11 + .../borrowck/borrowck-multiple-captures.nll.stderr | 103 +++ .../borrowck/borrowck-multiple-captures.rs | 65 ++ .../borrowck/borrowck-multiple-captures.stderr | 84 +++ .../borrowck-mut-addr-of-imm-var.nll.stderr | 11 + .../borrowck/borrowck-mut-addr-of-imm-var.rs | 16 + .../borrowck/borrowck-mut-addr-of-imm-var.stderr | 11 + ...orrowck-mut-borrow-linear-errors.ast.nll.stderr | 32 + .../borrowck-mut-borrow-linear-errors.ast.stderr | 36 + .../borrowck-mut-borrow-linear-errors.mir.stderr | 32 + .../borrowck/borrowck-mut-borrow-linear-errors.rs | 31 + .../borrowck-mut-borrow-of-mut-base-ptr.rs | 31 + .../borrowck-mut-borrow-of-mut-base-ptr.stderr | 26 + .../borrowck-mut-slice-of-imm-vec.nll.stderr | 11 + .../borrowck/borrowck-mut-slice-of-imm-vec.rs | 18 + .../borrowck/borrowck-mut-slice-of-imm-vec.stderr | 11 + .../borrowck/borrowck-mutate-in-guard.rs | 32 + .../borrowck/borrowck-mutate-in-guard.stderr | 22 + .../borrowck-no-cycle-in-exchange-heap.nll.stderr | 13 + .../borrowck/borrowck-no-cycle-in-exchange-heap.rs | 30 + .../borrowck-no-cycle-in-exchange-heap.stderr | 11 + .../borrowck/borrowck-object-lifetime.rs | 39 ++ .../borrowck/borrowck-object-lifetime.stderr | 23 + .../borrowck/borrowck-or-init.nll.stderr | 9 + .../borrowck/borrowck-or-init.rs | 16 + .../borrowck/borrowck-or-init.stderr | 9 + .../borrowck/borrowck-overloaded-call.nll.stderr | 23 + .../borrowck/borrowck-overloaded-call.rs | 88 +++ .../borrowck/borrowck-overloaded-call.stderr | 33 + ...oaded-index-and-overloaded-deref.ast.nll.stderr | 14 + ...verloaded-index-and-overloaded-deref.ast.stderr | 11 + ...verloaded-index-and-overloaded-deref.mir.stderr | 14 + ...rrowck-overloaded-index-and-overloaded-deref.rs | 50 ++ .../borrowck-overloaded-index-autoderef.rs | 93 +++ .../borrowck-overloaded-index-autoderef.stderr | 76 +++ ...rowck-overloaded-index-move-from-vec.nll.stderr | 12 + .../borrowck-overloaded-index-move-from-vec.rs | 32 + .../borrowck-overloaded-index-move-from-vec.stderr | 12 + ...borrowck-overloaded-index-move-index.nll.stderr | 14 + .../borrowck-overloaded-index-move-index.rs | 74 +++ .../borrowck-overloaded-index-move-index.stderr | 33 + ...rowck-overloaded-index-ref-index.ast.nll.stderr | 33 + .../borrowck-overloaded-index-ref-index.ast.stderr | 33 + .../borrowck-overloaded-index-ref-index.mir.stderr | 33 + .../borrowck-overloaded-index-ref-index.rs | 75 +++ .../borrowck/borrowck-partial-reinit-1.nll.stderr | 23 + .../borrowck/borrowck-partial-reinit-1.rs | 49 ++ .../borrowck/borrowck-partial-reinit-1.stderr | 15 + .../borrowck/borrowck-partial-reinit-2.nll.stderr | 13 + .../borrowck/borrowck-partial-reinit-2.rs | 33 + .../borrowck/borrowck-partial-reinit-2.stderr | 9 + .../borrowck/borrowck-partial-reinit-3.nll.stderr | 13 + .../borrowck/borrowck-partial-reinit-3.rs | 22 + .../borrowck/borrowck-partial-reinit-3.stderr | 9 + .../borrowck/borrowck-partial-reinit-4.nll.stderr | 9 + .../borrowck/borrowck-partial-reinit-4.rs | 33 + .../borrowck/borrowck-partial-reinit-4.stderr | 9 + .../borrowck-pat-reassign-binding.ast.nll.stderr | 15 + .../borrowck-pat-reassign-binding.ast.stderr | 12 + .../borrowck-pat-reassign-binding.mir.stderr | 15 + .../borrowck/borrowck-pat-reassign-binding.rs | 29 + .../borrowck/borrowck-reborrow-from-mut.nll.stderr | 11 + .../borrowck/borrowck-reborrow-from-mut.rs | 106 +++ .../borrowck/borrowck-reborrow-from-mut.stderr | 116 ++++ ...k-reborrow-from-shorter-lived-andmut.nll.stderr | 18 + .../borrowck-reborrow-from-shorter-lived-andmut.rs | 32 + ...rowck-reborrow-from-shorter-lived-andmut.stderr | 13 + .../borrowck/borrowck-ref-mut-of-imm.nll.stderr | 12 + .../borrowck/borrowck-ref-mut-of-imm.rs | 20 + .../borrowck/borrowck-ref-mut-of-imm.stderr | 12 + ...k-return-variable-on-stack-via-clone.nll.stderr | 17 + .../borrowck-return-variable-on-stack-via-clone.rs | 20 + ...rowck-return-variable-on-stack-via-clone.stderr | 17 + .../borrowck/borrowck-return.rs | 16 + .../borrowck/borrowck-return.stderr | 9 + .../borrowck/borrowck-storage-dead.rs | 37 ++ .../borrowck/borrowck-storage-dead.stderr | 15 + ...borrowck-struct-update-with-dtor.ast.nll.stderr | 15 + .../borrowck-struct-update-with-dtor.ast.stderr | 15 + .../borrowck-struct-update-with-dtor.mir.stderr | 15 + .../borrowck/borrowck-struct-update-with-dtor.rs | 36 + .../borrowck/borrowck-swap-mut-base-ptr.rs | 26 + .../borrowck/borrowck-swap-mut-base-ptr.stderr | 14 + ...-local-static-borrow-outlives-fn.ast.nll.stderr | 14 + ...read-local-static-borrow-outlives-fn.ast.stderr | 13 + ...read-local-static-borrow-outlives-fn.mir.stderr | 14 + ...rowck-thread-local-static-borrow-outlives-fn.rs | 23 + .../borrowck/borrowck-unary-move.ast.nll.stderr | 14 + .../borrowck/borrowck-unary-move.ast.stderr | 11 + .../borrowck/borrowck-unary-move.mir.stderr | 14 + .../borrowck/borrowck-unary-move.rs | 26 + .../borrowck/borrowck-unboxed-closures.nll.stderr | 22 + .../borrowck/borrowck-unboxed-closures.rs | 25 + .../borrowck/borrowck-unboxed-closures.stderr | 32 + .../borrowck/borrowck-uninit-after-item.rs | 15 + .../borrowck/borrowck-uninit-after-item.stderr | 9 + .../borrowck-uninit-field-access.ast.nll.stderr | 30 + .../borrowck-uninit-field-access.ast.stderr | 30 + .../borrowck-uninit-field-access.mir.stderr | 30 + .../borrowck/borrowck-uninit-field-access.rs | 46 ++ .../borrowck/borrowck-uninit-in-assignop.rs | 44 ++ .../borrowck/borrowck-uninit-in-assignop.stderr | 63 ++ .../borrowck-uninit-ref-chain.ast.nll.stderr | 33 + .../borrowck/borrowck-uninit-ref-chain.ast.stderr | 45 ++ .../borrowck/borrowck-uninit-ref-chain.mir.stderr | 33 + .../borrowck/borrowck-uninit-ref-chain.rs | 53 ++ .../borrowck/borrowck-uninit.rs | 16 + .../borrowck/borrowck-uninit.stderr | 9 + .../borrowck/borrowck-union-borrow-nested.rs | 36 + .../borrowck/borrowck-union-borrow-nested.stderr | 11 + .../borrowck/borrowck-union-borrow.ast.nll.stderr | 136 ++++ .../borrowck/borrowck-union-borrow.ast.stderr | 118 ++++ .../borrowck/borrowck-union-borrow.mir.stderr | 136 ++++ .../borrowck/borrowck-union-borrow.rs | 122 ++++ .../borrowck/borrowck-union-move-assign.nll.stderr | 35 + .../borrowck/borrowck-union-move-assign.rs | 42 ++ .../borrowck/borrowck-union-move-assign.stderr | 13 + .../borrowck/borrowck-union-move.nll.stderr | 63 ++ .../borrowck/borrowck-union-move.rs | 96 +++ .../borrowck/borrowck-union-move.stderr | 63 ++ .../borrowck-union-uninitialized.nll.stderr | 9 + .../borrowck/borrowck-union-uninitialized.rs | 28 + .../borrowck/borrowck-union-uninitialized.stderr | 15 + .../borrowck/borrowck-uniq-via-lend.rs | 62 ++ .../borrowck/borrowck-uniq-via-lend.stderr | 23 + .../borrowck-use-in-index-lvalue.ast.nll.stderr | 15 + .../borrowck-use-in-index-lvalue.ast.stderr | 15 + .../borrowck-use-in-index-lvalue.mir.stderr | 15 + .../borrowck/borrowck-use-in-index-lvalue.rs | 24 + .../borrowck/borrowck-use-mut-borrow.nll.stderr | 95 +++ .../borrowck/borrowck-use-mut-borrow.rs | 96 +++ .../borrowck/borrowck-use-mut-borrow.stderr | 75 +++ ...-use-uninitialized-in-cast-trait.ast.nll.stderr | 9 + ...owck-use-uninitialized-in-cast-trait.ast.stderr | 9 + ...owck-use-uninitialized-in-cast-trait.mir.stderr | 9 + .../borrowck-use-uninitialized-in-cast-trait.rs | 24 + ...rrowck-use-uninitialized-in-cast.ast.nll.stderr | 9 + .../borrowck-use-uninitialized-in-cast.ast.stderr | 9 + .../borrowck-use-uninitialized-in-cast.mir.stderr | 9 + .../borrowck/borrowck-use-uninitialized-in-cast.rs | 22 + .../borrowck-vec-pattern-element-loan.nll.stderr | 48 ++ .../borrowck/borrowck-vec-pattern-element-loan.rs | 43 ++ .../borrowck-vec-pattern-element-loan.stderr | 48 ++ .../borrowck-vec-pattern-loan-from-mut.nll.stderr | 14 + .../borrowck/borrowck-vec-pattern-loan-from-mut.rs | 24 + .../borrowck-vec-pattern-loan-from-mut.stderr | 15 + .../borrowck-vec-pattern-move-tail.ast.nll.stderr | 15 + .../borrowck-vec-pattern-move-tail.ast.stderr | 12 + .../borrowck-vec-pattern-move-tail.cmp.stderr | 24 + .../borrowck/borrowck-vec-pattern-move-tail.rs | 29 + ...rrowck-vec-pattern-tail-element-loan.nll.stderr | 18 + .../borrowck-vec-pattern-tail-element-loan.rs | 26 + .../borrowck-vec-pattern-tail-element-loan.stderr | 18 + .../borrowck/borrowck-while-break.nll.stderr | 9 + .../borrowck/borrowck-while-break.rs | 22 + .../borrowck/borrowck-while-break.stderr | 9 + .../borrowck/borrowck-while-cond.rs | 14 + .../borrowck/borrowck-while-cond.stderr | 9 + .../borrowck/borrowck-while.rs | 17 + .../borrowck/borrowck-while.stderr | 9 + ...ve-in-static-initializer-issue-38520.ast.stderr | 15 + ...ve-in-static-initializer-issue-38520.mir.stderr | 15 + .../move-in-static-initializer-issue-38520.rs | 33 + .../borrowck/two-phase-across-loop.rs | 34 + .../borrowck/two-phase-across-loop.stderr | 9 + ...tivation-sharing-interference.nll_target.stderr | 47 ++ .../two-phase-activation-sharing-interference.rs | 79 +++ ...low-access-during-reservation.nll_target.stderr | 27 + .../two-phase-allow-access-during-reservation.rs | 51 ++ .../two-phase-cannot-nest-mut-self-calls.rs | 31 + .../two-phase-cannot-nest-mut-self-calls.stderr | 20 + .../two-phase-nonrecv-autoref.ast.nll.stderr | 82 +++ .../borrowck/two-phase-nonrecv-autoref.ast.stderr | 113 ++++ .../borrowck/two-phase-nonrecv-autoref.nll.stderr | 82 +++ .../borrowck/two-phase-nonrecv-autoref.rs | 204 ++++++ ...two-phase-reservation-sharing-interference-2.rs | 34 + ...phase-reservation-sharing-interference-2.stderr | 14 + ...ervation-sharing-interference.nll_target.stderr | 15 + .../two-phase-reservation-sharing-interference.rs | 60 ++ .../borrowck/two-phase-sneaky.nll.stderr | 20 + .../borrowck/two-phase-sneaky.rs | 27 + .../borrowck/two-phase-sneaky.stderr | 15 + .../ui/compile-fail-migration/bounds-lifetime.rs | 17 + .../compile-fail-migration/bounds-lifetime.stderr | 32 + .../compile-fail-migration/break-outside-loop.rs | 35 + .../break-outside-loop.stderr | 34 + .../builtin-superkinds-double-superkind.rs | 24 + .../builtin-superkinds-double-superkind.stderr | 23 + .../builtin-superkinds-in-metadata.rs | 27 + .../builtin-superkinds-in-metadata.stderr | 13 + .../builtin-superkinds-self-type.rs | 27 + .../builtin-superkinds-self-type.stderr | 17 + .../builtin-superkinds-simple.rs | 19 + .../builtin-superkinds-simple.stderr | 11 + .../builtin-superkinds-typaram-not-send.rs | 18 + .../builtin-superkinds-typaram-not-send.stderr | 12 + .../by-move-pattern-binding.nll.stderr | 15 + .../by-move-pattern-binding.rs | 32 + .../by-move-pattern-binding.stderr | 12 + .../call-fn-never-arg-wrong-type.rs | 22 + .../call-fn-never-arg-wrong-type.stderr | 12 + .../compile-fail-migration/can-begin-expr-check.rs | 30 + .../can-begin-expr-check.stderr | 8 + ...nnot-mutate-captured-non-mut-var.ast.nll.stderr | 20 + .../cannot-mutate-captured-non-mut-var.ast.stderr | 16 + .../cannot-mutate-captured-non-mut-var.mir.stderr | 20 + .../cannot-mutate-captured-non-mut-var.rs | 31 + src/test/ui/compile-fail-migration/capture1.rs | 17 + src/test/ui/compile-fail-migration/capture1.stderr | 11 + .../ui/compile-fail-migration/cast-from-nil.rs | 12 + .../ui/compile-fail-migration/cast-from-nil.stderr | 11 + .../cast-ptr-to-int-const.rs | 17 + .../cast-ptr-to-int-const.stderr | 19 + .../ui/compile-fail-migration/cast-to-bare-fn.rs | 20 + .../compile-fail-migration/cast-to-bare-fn.stderr | 19 + src/test/ui/compile-fail-migration/cast-to-nil.rs | 12 + .../ui/compile-fail-migration/cast-to-nil.stderr | 11 + .../catch-bad-lifetime.nll.stderr | 39 ++ .../compile-fail-migration/catch-bad-lifetime.rs | 42 ++ .../catch-bad-lifetime.stderr | 44 ++ .../ui/compile-fail-migration/catch-bad-type.rs | 28 + .../compile-fail-migration/catch-bad-type.stderr | 52 ++ .../ui/compile-fail-migration/catch-in-match.rs | 15 + .../compile-fail-migration/catch-in-match.stderr | 8 + .../ui/compile-fail-migration/catch-in-while.rs | 15 + .../compile-fail-migration/catch-in-while.stderr | 8 + .../catch-maybe-bad-lifetime.nll.stderr | 14 + .../catch-maybe-bad-lifetime.rs | 49 ++ .../catch-maybe-bad-lifetime.stderr | 33 + .../catch-opt-init.nll.stderr | 11 + .../ui/compile-fail-migration/catch-opt-init.rs | 25 + .../compile-fail-migration/catch-opt-init.stderr | 9 + .../cdylib-deps-must-be-static.rs | 19 + .../cdylib-deps-must-be-static.stderr | 4 + .../ui/compile-fail-migration/cfg-arg-invalid.rs | 13 + .../ui/compile-fail-migration/cfg-attr-cfg-2.rs | 18 + .../compile-fail-migration/cfg-attr-cfg-2.stderr | 7 + .../ui/compile-fail-migration/cfg-attr-crate-2.rs | 17 + .../compile-fail-migration/cfg-attr-crate-2.stderr | 11 + .../cfg-attr-invalid-predicate.rs | 12 + .../cfg-attr-invalid-predicate.stderr | 9 + .../cfg-attr-unknown-attribute-macro-expansion.rs | 20 + ...g-attr-unknown-attribute-macro-expansion.stderr | 14 + .../ui/compile-fail-migration/cfg-empty-codemap.rs | 18 + .../ui/compile-fail-migration/cfg-in-crate-1.rs | 13 + .../compile-fail-migration/cfg-in-crate-1.stderr | 7 + .../ui/compile-fail-migration/cfg-non-opt-expr.rs | 22 + .../compile-fail-migration/cfg-non-opt-expr.stderr | 26 + .../ui/compile-fail-migration/cfg_attr_path.rs | 24 + .../ui/compile-fail-migration/cfg_attr_path.stderr | 11 + .../check-static-immutable-mut-slices.rs | 16 + .../check-static-immutable-mut-slices.stderr | 9 + .../check-static-values-constraints.nll.stderr | 70 ++ .../check-static-values-constraints.rs | 123 ++++ .../check-static-values-constraints.stderr | 67 ++ .../compile-fail-migration/class-cast-to-trait.rs | 64 ++ .../class-cast-to-trait.stderr | 9 + .../compile-fail-migration/class-method-missing.rs | 31 + .../class-method-missing.stderr | 12 + .../compile-fail-migration/class-missing-self.rs | 26 + .../class-missing-self.stderr | 19 + .../cleanup-rvalue-scopes-cf.rs | 43 ++ .../cleanup-rvalue-scopes-cf.stderr | 93 +++ ...sure-bounds-cant-promote-superkind-in-struct.rs | 21 + ...-bounds-cant-promote-superkind-in-struct.stderr | 20 + ...-bounds-static-cant-capture-borrowed.nll.stderr | 39 ++ .../closure-bounds-static-cant-capture-borrowed.rs | 22 + ...sure-bounds-static-cant-capture-borrowed.stderr | 11 + .../closure-bounds-subtype.rs | 27 + .../closure-bounds-subtype.stderr | 17 + .../closure-expected-type/README.md | 1 + .../expect-fn-supply-fn-multiple.rs | 48 ++ .../expect-fn-supply-fn.nll.stderr | 60 ++ .../closure-expected-type/expect-fn-supply-fn.rs | 68 ++ .../expect-fn-supply-fn.stderr | 93 +++ .../expect-infer-var-appearing-twice.rs | 35 + .../expect-infer-var-appearing-twice.stderr | 20 + ...expect-infer-var-supply-ty-with-bound-region.rs | 29 + .../expect-infer-var-supply-ty-with-free-region.rs | 29 + ...t-two-infer-vars-supply-ty-with-bound-region.rs | 29 + ...o-infer-vars-supply-ty-with-bound-region.stderr | 9 + .../ui/compile-fail-migration/closure-no-fn-1.rs | 18 + .../compile-fail-migration/closure-no-fn-1.stderr | 12 + .../ui/compile-fail-migration/closure-no-fn-2.rs | 18 + .../compile-fail-migration/closure-no-fn-2.stderr | 12 + .../ui/compile-fail-migration/closure-no-fn-3.rs | 18 + .../compile-fail-migration/closure-no-fn-3.stderr | 11 + .../closure-referencing-itself-issue-25954.rs | 28 + .../closure-referencing-itself-issue-25954.stderr | 9 + .../compile-fail-migration/closure-reform-bad.rs | 22 + .../closure-reform-bad.stderr | 12 + .../compile-fail-migration/closure-wrong-kind.rs | 22 + .../closure-wrong-kind.stderr | 14 + .../ui/compile-fail-migration/closure_promotion.rs | 17 + .../closure_promotion.stderr | 13 + .../coerce-expect-unsized-ascribed.rs | 42 ++ .../coerce-expect-unsized-ascribed.stderr | 129 ++++ src/test/ui/compile-fail-migration/coerce-mut.rs | 20 + .../ui/compile-fail-migration/coerce-mut.stderr | 12 + .../coerce-overloaded-autoderef.ast.nll.stderr | 47 ++ .../coerce-overloaded-autoderef.ast.stderr | 42 ++ .../coerce-overloaded-autoderef.mir.nll.stderr | 47 ++ .../coerce-overloaded-autoderef.mir.stderr | 47 ++ .../coerce-overloaded-autoderef.rs | 49 ++ .../compile-fail-migration/coerce-to-bang-cast.rs | 24 + .../coerce-to-bang-cast.stderr | 19 + .../ui/compile-fail-migration/coerce-to-bang.rs | 89 +++ .../compile-fail-migration/coerce-to-bang.stderr | 93 +++ .../coerce-unsafe-to-closure.rs | 14 + .../coerce-unsafe-to-closure.stderr | 9 + .../ui/compile-fail-migration/coercion-slice.rs | 18 + .../compile-fail-migration/coercion-slice.stderr | 15 + .../compile-fail-migration/coherence-all-remote.rs | 19 + .../coherence-all-remote.stderr | 11 + .../coherence-bigint-param.rs | 21 + .../coherence-bigint-param.stderr | 11 + ...e-blanket-conflicts-with-blanket-implemented.rs | 38 ++ ...anket-conflicts-with-blanket-implemented.stderr | 12 + ...blanket-conflicts-with-blanket-unimplemented.rs | 34 + ...ket-conflicts-with-blanket-unimplemented.stderr | 12 + ...-blanket-conflicts-with-specific-cross-crate.rs | 29 + ...nket-conflicts-with-specific-cross-crate.stderr | 13 + ...lanket-conflicts-with-specific-multidispatch.rs | 36 + ...et-conflicts-with-specific-multidispatch.stderr | 12 + ...erence-blanket-conflicts-with-specific-trait.rs | 38 ++ ...ce-blanket-conflicts-with-specific-trait.stderr | 12 + .../coherence-blanket-conflicts-with-specific.rs | 33 + ...oherence-blanket-conflicts-with-specific.stderr | 12 + .../coherence-conflicting-negative-trait-impl.rs | 28 + ...oherence-conflicting-negative-trait-impl.stderr | 21 + .../compile-fail-migration/coherence-cow.a.stderr | 11 + .../compile-fail-migration/coherence-cow.b.stderr | 11 + .../compile-fail-migration/coherence-cow.c.stderr | 11 + .../ui/compile-fail-migration/coherence-cow.rs | 35 + .../coherence-cross-crate-conflict.rs | 24 + .../coherence-cross-crate-conflict.stderr | 21 + .../coherence-default-trait-impl.rs | 25 + .../coherence-default-trait-impl.stderr | 16 + .../coherence-impl-trait-for-trait-object-safe.rs | 19 + ...herence-impl-trait-for-trait-object-safe.stderr | 11 + .../coherence-impl-trait-for-trait.rs | 27 + .../coherence-impl-trait-for-trait.stderr | 21 + .../compile-fail-migration/coherence-impls-send.rs | 40 ++ .../coherence-impls-send.stderr | 37 ++ .../coherence-impls-sized.rs | 46 ++ .../coherence-impls-sized.stderr | 67 ++ .../coherence-inherited-assoc-ty-cycle-err.rs | 34 + .../coherence-inherited-assoc-ty-cycle-err.stderr | 16 + .../coherence-lone-type-parameter.rs | 19 + .../coherence-lone-type-parameter.stderr | 11 + .../coherence-negative-impls-safe.rs | 20 + .../coherence-negative-impls-safe.stderr | 9 + .../coherence-no-direct-lifetime-dispatch.rs | 18 + .../coherence-no-direct-lifetime-dispatch.stderr | 11 + .../ui/compile-fail-migration/coherence-orphan.rs | 31 + .../compile-fail-migration/coherence-orphan.stderr | 21 + .../coherence-overlap-all-t-and-tuple.rs | 29 + .../coherence-overlap-all-t-and-tuple.stderr | 12 + .../coherence-overlap-messages.rs | 32 + .../coherence-overlap-messages.stderr | 44 ++ .../coherence-overlapping-pairs.rs | 21 + .../coherence-overlapping-pairs.stderr | 11 + .../coherence-pair-covered-uncovered-1.rs | 24 + .../coherence-pair-covered-uncovered-1.stderr | 11 + .../coherence-pair-covered-uncovered.rs | 21 + .../coherence-pair-covered-uncovered.stderr | 11 + .../coherence-projection-conflict-orphan.rs | 28 + .../coherence-projection-conflict-orphan.stderr | 14 + .../coherence-projection-conflict-ty-param.rs | 22 + .../coherence-projection-conflict-ty-param.stderr | 12 + .../coherence-projection-conflict.rs | 27 + .../coherence-projection-conflict.stderr | 12 + .../coherence-projection-ok-orphan.rs | 29 + .../coherence-projection-ok-orphan.stderr | 8 + .../coherence-projection-ok.rs | 28 + .../coherence-projection-ok.stderr | 8 + .../coherence-tuple-conflict.rs | 29 + .../coherence-tuple-conflict.stderr | 12 + .../coherence-vec-local-2.rs | 23 + .../coherence-vec-local-2.stderr | 11 + .../compile-fail-migration/coherence-vec-local.rs | 23 + .../coherence-vec-local.stderr | 12 + .../coherence_copy_like_err_fundamental_struct.rs | 34 + ...herence_copy_like_err_fundamental_struct.stderr | 8 + ...herence_copy_like_err_fundamental_struct_ref.rs | 34 + ...nce_copy_like_err_fundamental_struct_ref.stderr | 8 + ...rence_copy_like_err_fundamental_struct_tuple.rs | 30 + ...e_copy_like_err_fundamental_struct_tuple.stderr | 14 + .../coherence_copy_like_err_struct.rs | 31 + .../coherence_copy_like_err_struct.stderr | 14 + .../coherence_copy_like_err_tuple.rs | 30 + .../coherence_copy_like_err_tuple.stderr | 14 + .../compile-fail-migration/coherence_inherent.rs | 45 ++ .../coherence_inherent.stderr | 13 + .../coherence_inherent_cc.rs | 37 ++ .../coherence_inherent_cc.stderr | 13 + .../ui/compile-fail-migration/coherence_local.rs | 33 + .../compile-fail-migration/coherence_local.stderr | 8 + .../coherence_local_err_struct.rs | 29 + .../coherence_local_err_struct.stderr | 12 + .../coherence_local_err_tuple.rs | 29 + .../coherence_local_err_tuple.stderr | 12 + .../compile-fail-migration/coherence_local_ref.rs | 27 + .../coherence_local_ref.stderr | 8 + .../compile-fail-migration/compile_error_macro.rs | 13 + .../compile_error_macro.stderr | 8 + src/test/ui/compile-fail-migration/concat.rs | 16 + src/test/ui/compile-fail-migration/concat.stderr | 30 + .../conflicting-repr-hints.rs | 67 ++ .../conflicting-repr-hints.stderr | 70 ++ .../conservative_impl_trait.rs | 17 + .../conservative_impl_trait.stderr | 12 + .../const-array-oob-arith.rs | 22 + .../const-array-oob-arith.stderr | 21 + .../ui/compile-fail-migration/const-array-oob.rs | 24 + .../compile-fail-migration/const-array-oob.stderr | 19 + .../const-block-non-item-statement-2.rs | 28 + .../const-block-non-item-statement-2.stderr | 62 ++ .../const-block-non-item-statement-3.rs | 17 + .../const-block-non-item-statement-3.stderr | 35 + .../const-block-non-item-statement.rs | 19 + .../const-block-non-item-statement.stderr | 35 + src/test/ui/compile-fail-migration/const-call.rs | 19 + .../ui/compile-fail-migration/const-call.stderr | 16 + .../const-cast-different-types.rs | 16 + .../const-cast-different-types.stderr | 15 + .../const-cast-wrong-type.rs | 15 + .../const-cast-wrong-type.stderr | 9 + .../ui/compile-fail-migration/const-err-early.rs | 26 + .../compile-fail-migration/const-err-early.stderr | 48 ++ .../ui/compile-fail-migration/const-err-multi.rs | 27 + .../compile-fail-migration/const-err-multi.stderr | 67 ++ src/test/ui/compile-fail-migration/const-err.rs | 32 + .../ui/compile-fail-migration/const-err.stderr | 26 + src/test/ui/compile-fail-migration/const-err2.rs | 39 ++ .../ui/compile-fail-migration/const-err2.stderr | 38 ++ src/test/ui/compile-fail-migration/const-err3.rs | 30 + .../ui/compile-fail-migration/const-err3.stderr | 32 + src/test/ui/compile-fail-migration/const-err4.rs | 24 + .../ui/compile-fail-migration/const-err4.stderr | 9 + .../const-eval-overflow-3.rs | 38 ++ .../const-eval-overflow-3.stderr | 19 + .../const-eval-overflow-3b.rs | 43 ++ .../const-eval-overflow-3b.stderr | 18 + .../const-eval-overflow-4b.rs | 39 ++ .../const-eval-overflow-4b.stderr | 24 + .../compile-fail-migration/const-eval-overflow2.rs | 83 +++ .../const-eval-overflow2.stderr | 94 +++ .../const-eval-overflow2b.rs | 83 +++ .../const-eval-overflow2b.stderr | 94 +++ .../const-eval-overflow2c.rs | 83 +++ .../const-eval-overflow2c.stderr | 94 +++ .../const-fn-destructuring-arg.rs | 27 + .../const-fn-destructuring-arg.stderr | 35 + .../const-fn-not-safe-for-const.rs | 51 ++ .../const-fn-not-safe-for-const.stderr | 76 +++ .../const-fn-stability-calls-3.rs | 25 + .../const-fn-stability-calls-3.stderr | 10 + .../const-integer-bool-ops.rs | 85 +++ .../const-integer-bool-ops.stderr | 135 ++++ .../const-len-underflow-subspans.rs | 21 + .../const-len-underflow-subspans.stderr | 19 + .../const-match-check.eval1.stderr | 9 + .../const-match-check.eval2.stderr | 9 + .../const-match-check.matchck.stderr | 27 + .../ui/compile-fail-migration/const-match-check.rs | 43 ++ .../const-match-pattern-arm.rs | 27 + .../const-match-pattern-arm.stderr | 15 + .../compile-fail-migration/const-size_of-cycle.rs | 19 + .../const-size_of-cycle.stderr | 18 + .../ui/compile-fail-migration/const-slice-oob.rs | 20 + .../compile-fail-migration/const-slice-oob.stderr | 12 + .../compile-fail-migration/const-tup-index-span.rs | 19 + .../const-tup-index-span.stderr | 12 + .../ui/compile-fail-migration/const-typeid-of.rs | 18 + .../compile-fail-migration/const-typeid-of.stderr | 10 + .../constructor-lifetime-args.rs | 36 + .../constructor-lifetime-args.stderr | 28 + .../ui/compile-fail-migration/copy-a-resource.rs | 31 + .../compile-fail-migration/copy-a-resource.stderr | 16 + .../compile-fail-migration/crate-name-mismatch.rs | 16 + .../crate-name-mismatch.stderr | 8 + .../crateresolve1.nll.stderr | 21 + .../ui/compile-fail-migration/crateresolve1.rs | 19 + .../ui/compile-fail-migration/crateresolve1.stderr | 21 + .../compile-fail-migration/cross-borrow-trait.rs | 23 + .../cross-borrow-trait.stderr | 15 + .../compile-fail-migration/cross-fn-cache-hole.rs | 41 ++ .../cross-fn-cache-hole.stderr | 18 + .../ui/compile-fail-migration/custom_attribute.rs | 19 + .../compile-fail-migration/custom_attribute.stderr | 27 + .../cycle-projection-based-on-where-clause.rs | 35 + .../cycle-projection-based-on-where-clause.stderr | 23 + .../cycle-trait-default-type-trait.rs | 18 + .../cycle-trait-default-type-trait.stderr | 11 + .../cycle-trait-supertrait-direct.rs | 17 + .../cycle-trait-supertrait-direct.stderr | 11 + .../dead-code-closure-bang.rs | 19 + .../ui/compile-fail-migration/dead-code-ret.rs | 18 + .../ui/compile-fail-migration/dead-code-ret.stderr | 15 + .../compile-fail-migration/defaulted-never-note.rs | 45 ++ .../defaulted-never-note.stderr | 16 + .../dep-graph-assoc-type-codegen.rs | 47 ++ .../dep-graph-assoc-type-codegen.stderr | 8 + .../dep-graph-caller-callee.rs | 45 ++ .../dep-graph-caller-callee.stderr | 14 + .../dep-graph-struct-signature.rs | 97 +++ .../dep-graph-struct-signature.stderr | 140 ++++ .../dep-graph-trait-impl-two-traits-same-method.rs | 55 ++ ...-graph-trait-impl-two-traits-same-method.stderr | 14 + .../dep-graph-trait-impl-two-traits.rs | 54 ++ .../dep-graph-trait-impl-two-traits.stderr | 14 + .../compile-fail-migration/dep-graph-trait-impl.rs | 70 ++ .../dep-graph-trait-impl.stderr | 32 + .../compile-fail-migration/dep-graph-type-alias.rs | 66 ++ .../dep-graph-type-alias.stderr | 74 +++ .../dep-graph-variance-alias.rs | 32 + .../dep-graph-variance-alias.stderr | 8 + .../deprecated_no_stack_check.rs | 16 + .../deprecated_no_stack_check.stderr | 9 + .../deprecation-in-staged-api.rs | 18 + .../deprecation-in-staged-api.stderr | 8 + .../compile-fail-migration/deprecation-lint-2.rs | 23 + .../deprecation-lint-2.stderr | 15 + .../compile-fail-migration/deprecation-lint-3.rs | 24 + .../deprecation-lint-3.stderr | 15 + .../deprecation-lint-nested.rs | 81 +++ .../deprecation-lint-nested.stderr | 44 ++ .../ui/compile-fail-migration/deprecation-lint.rs | 445 +++++++++++++ .../compile-fail-migration/deprecation-lint.stderr | 728 +++++++++++++++++++++ .../ui/compile-fail-migration/deref-non-pointer.rs | 15 + .../deref-non-pointer.stderr | 9 + .../derive-assoc-type-not-impl.rs | 29 + .../derive-assoc-type-not-impl.stderr | 18 + .../derive-on-trait-item-or-impl-item.rs | 23 + .../derive-on-trait-item-or-impl-item.stderr | 14 + .../derived-errors/issue-30580.rs | 27 + .../derived-errors/issue-30580.stderr | 9 + .../derived-errors/issue-31997.rs | 27 + .../derived-errors/issue-31997.stderr | 9 + .../derives-span-Clone-enum-struct-variant.rs | 23 + .../derives-span-Clone-enum-struct-variant.stderr | 11 + .../derives-span-Clone-enum.rs | 23 + .../derives-span-Clone-enum.stderr | 11 + .../derives-span-Clone-struct.rs | 21 + .../derives-span-Clone-struct.stderr | 11 + .../derives-span-Clone-tuple-struct.rs | 21 + .../derives-span-Clone-tuple-struct.stderr | 11 + .../derives-span-Debug-enum-struct-variant.rs | 23 + .../derives-span-Debug-enum-struct-variant.stderr | 14 + .../derives-span-Debug-enum.rs | 23 + .../derives-span-Debug-enum.stderr | 14 + .../derives-span-Debug-struct.rs | 21 + .../derives-span-Debug-struct.stderr | 14 + .../derives-span-Debug-tuple-struct.rs | 21 + .../derives-span-Debug-tuple-struct.stderr | 14 + .../derives-span-Default-struct.rs | 21 + .../derives-span-Default-struct.stderr | 11 + .../derives-span-Default-tuple-struct.rs | 21 + .../derives-span-Default-tuple-struct.stderr | 11 + .../derives-span-Eq-enum-struct-variant.rs | 23 + .../derives-span-Eq-enum-struct-variant.stderr | 11 + .../compile-fail-migration/derives-span-Eq-enum.rs | 23 + .../derives-span-Eq-enum.stderr | 11 + .../derives-span-Eq-struct.rs | 21 + .../derives-span-Eq-struct.stderr | 11 + .../derives-span-Eq-tuple-struct.rs | 21 + .../derives-span-Eq-tuple-struct.stderr | 11 + .../derives-span-Hash-enum-struct-variant.rs | 23 + .../derives-span-Hash-enum-struct-variant.stderr | 11 + .../derives-span-Hash-enum.rs | 23 + .../derives-span-Hash-enum.stderr | 11 + .../derives-span-Hash-struct.rs | 21 + .../derives-span-Hash-struct.stderr | 11 + .../derives-span-Hash-tuple-struct.rs | 21 + .../derives-span-Hash-tuple-struct.stderr | 11 + .../derives-span-Ord-enum-struct-variant.rs | 23 + .../derives-span-Ord-enum-struct-variant.stderr | 11 + .../derives-span-Ord-enum.rs | 23 + .../derives-span-Ord-enum.stderr | 11 + .../derives-span-Ord-struct.rs | 21 + .../derives-span-Ord-struct.stderr | 11 + .../derives-span-Ord-tuple-struct.rs | 21 + .../derives-span-Ord-tuple-struct.stderr | 11 + .../derives-span-PartialEq-enum-struct-variant.rs | 24 + ...rives-span-PartialEq-enum-struct-variant.stderr | 19 + .../derives-span-PartialEq-enum.rs | 24 + .../derives-span-PartialEq-enum.stderr | 19 + .../derives-span-PartialEq-struct.rs | 22 + .../derives-span-PartialEq-struct.stderr | 19 + .../derives-span-PartialEq-tuple-struct.rs | 22 + .../derives-span-PartialEq-tuple-struct.stderr | 19 + .../derives-span-PartialOrd-enum-struct-variant.rs | 23 + ...ives-span-PartialOrd-enum-struct-variant.stderr | 12 + .../derives-span-PartialOrd-enum.rs | 23 + .../derives-span-PartialOrd-enum.stderr | 12 + .../derives-span-PartialOrd-struct.rs | 21 + .../derives-span-PartialOrd-struct.stderr | 12 + .../derives-span-PartialOrd-tuple-struct.rs | 21 + .../derives-span-PartialOrd-tuple-struct.stderr | 12 + .../ui/compile-fail-migration/deriving-bounds.rs | 19 + .../compile-fail-migration/deriving-bounds.stderr | 14 + .../compile-fail-migration/deriving-copyclone.rs | 48 ++ .../deriving-copyclone.stderr | 42 ++ .../deriving-meta-unknown-trait.rs | 17 + .../deriving-meta-unknown-trait.stderr | 8 + .../deriving-no-inner-impl-error-message.rs | 25 + .../deriving-no-inner-impl-error-message.stderr | 28 + .../ui/compile-fail-migration/deriving-non-type.rs | 40 ++ .../deriving-non-type.stderr | 56 ++ .../compile-fail-migration/deriving-primitive.rs | 15 + .../deriving-primitive.stderr | 8 + .../destructure-trait-ref.rs | 55 ++ .../destructure-trait-ref.stderr | 51 ++ .../directory_ownership/foo/compiletest-ignore-dir | 0 .../foo/mod_file_not_owning/aux2.rs | 9 + .../foo/mod_file_not_owning_aux2.rs | 9 + .../directory_ownership/macro-expanded-mod.rs | 23 + .../directory_ownership/macro-expanded-mod.stderr | 8 + .../macro_expanded_mod_helper/foo/bar.rs | 11 + .../macro_expanded_mod_helper/foo/mod.rs | 13 + .../directory_ownership/mod_file_not_owning.rs | 15 + .../directory_ownership/mod_file_not_owning.stderr | 15 + .../mod_file_not_owning_aux1.rs | 16 + .../compiletest-ignore-dir | 0 .../mod_file_not_owning_aux2.rs | 9 + .../mod_file_not_owning_aux2.rs | 11 + .../mod_file_not_owning_aux3.rs | 13 + .../non-inline-mod-restriction.rs | 15 + .../non-inline-mod-restriction.stderr | 8 + .../directory_ownership/unowned_mod_with_path.rs | 15 + .../unowned_mod_with_path.stderr | 15 + ...econstructing-destructing-struct-let.nll.stderr | 12 + ...llowed-deconstructing-destructing-struct-let.rs | 30 + ...ed-deconstructing-destructing-struct-let.stderr | 12 + ...onstructing-destructing-struct-match.nll.stderr | 14 + ...owed-deconstructing-destructing-struct-match.rs | 28 + ...-deconstructing-destructing-struct-match.stderr | 12 + .../ui/compile-fail-migration/discrim-ill-typed.rs | 126 ++++ .../discrim-ill-typed.stderr | 51 ++ .../diverging-fn-tail-35849.rs | 18 + .../diverging-fn-tail-35849.stderr | 15 + .../diverging-tuple-parts-39485.rs | 25 + .../diverging-tuple-parts-39485.stderr | 25 + src/test/ui/compile-fail-migration/does-nothing.rs | 12 + .../ui/compile-fail-migration/does-nothing.stderr | 9 + .../dollar-crate-is-keyword-2.rs | 23 + .../dollar-crate-is-keyword-2.stderr | 31 + .../dollar-crate-is-keyword.rs | 28 + .../dollar-crate-is-keyword.stderr | 42 ++ .../compile-fail-migration/double-type-import.rs | 23 + .../double-type-import.stderr | 17 + .../compile-fail-migration/drop-on-non-struct.rs | 20 + .../drop-on-non-struct.stderr | 19 + .../drop-with-active-borrows-1.nll.stderr | 13 + .../drop-with-active-borrows-1.rs | 18 + .../drop-with-active-borrows-1.stderr | 11 + .../drop-with-active-borrows-2.nll.stderr | 18 + .../drop-with-active-borrows-2.rs | 19 + .../drop-with-active-borrows-2.stderr | 18 + .../dropck_no_diverge_on_nonregular_1.rs | 37 ++ .../dropck_no_diverge_on_nonregular_1.stderr | 19 + .../dropck_no_diverge_on_nonregular_2.rs | 36 + .../dropck_no_diverge_on_nonregular_2.stderr | 19 + .../dropck_no_diverge_on_nonregular_3.rs | 46 ++ .../dropck_no_diverge_on_nonregular_3.stderr | 27 + .../dropck_trait_cycle_checked.nll.stderr | 71 ++ .../dropck_trait_cycle_checked.rs | 131 ++++ .../dropck_trait_cycle_checked.stderr | 68 ++ .../ui/compile-fail-migration/dst-bad-assign-2.rs | 48 ++ .../compile-fail-migration/dst-bad-assign-2.stderr | 13 + .../ui/compile-fail-migration/dst-bad-assign-3.rs | 49 ++ .../compile-fail-migration/dst-bad-assign-3.stderr | 23 + .../ui/compile-fail-migration/dst-bad-assign.rs | 51 ++ .../compile-fail-migration/dst-bad-assign.stderr | 23 + .../ui/compile-fail-migration/dst-bad-coerce1.rs | 46 ++ .../compile-fail-migration/dst-bad-coerce1.stderr | 38 ++ .../ui/compile-fail-migration/dst-bad-coerce2.rs | 41 ++ .../compile-fail-migration/dst-bad-coerce2.stderr | 39 ++ .../dst-bad-coerce3.nll.stderr | 63 ++ .../ui/compile-fail-migration/dst-bad-coerce3.rs | 47 ++ .../compile-fail-migration/dst-bad-coerce3.stderr | 63 ++ .../ui/compile-fail-migration/dst-bad-coerce4.rs | 35 + .../compile-fail-migration/dst-bad-coerce4.stderr | 21 + .../ui/compile-fail-migration/dst-bad-coercions.rs | 36 + .../dst-bad-coercions.stderr | 72 ++ .../ui/compile-fail-migration/dst-bad-deep-2.rs | 23 + .../compile-fail-migration/dst-bad-deep-2.stderr | 15 + src/test/ui/compile-fail-migration/dst-bad-deep.rs | 25 + .../ui/compile-fail-migration/dst-bad-deep.stderr | 15 + .../ui/compile-fail-migration/dst-index.nll.stderr | 28 + src/test/ui/compile-fail-migration/dst-index.rs | 47 ++ .../ui/compile-fail-migration/dst-index.stderr | 28 + .../dst-object-from-unsized-type.rs | 37 ++ .../dst-object-from-unsized-type.stderr | 45 ++ .../compile-fail-migration/dst-rvalue.nll.stderr | 28 + src/test/ui/compile-fail-migration/dst-rvalue.rs | 24 + .../ui/compile-fail-migration/dst-rvalue.stderr | 28 + .../dst-sized-trait-param.rs | 23 + .../dst-sized-trait-param.stderr | 21 + .../ui/compile-fail-migration/dupe-symbols-1.rs | 21 + .../compile-fail-migration/dupe-symbols-1.stderr | 10 + .../ui/compile-fail-migration/dupe-symbols-2.rs | 25 + .../compile-fail-migration/dupe-symbols-2.stderr | 10 + .../ui/compile-fail-migration/dupe-symbols-3.rs | 21 + .../compile-fail-migration/dupe-symbols-3.stderr | 10 + .../ui/compile-fail-migration/dupe-symbols-4.rs | 31 + .../compile-fail-migration/dupe-symbols-4.stderr | 8 + .../ui/compile-fail-migration/dupe-symbols-5.rs | 20 + .../compile-fail-migration/dupe-symbols-5.stderr | 10 + .../ui/compile-fail-migration/dupe-symbols-6.rs | 18 + .../compile-fail-migration/dupe-symbols-6.stderr | 8 + .../ui/compile-fail-migration/dupe-symbols-7.rs | 15 + .../compile-fail-migration/dupe-symbols-7.stderr | 10 + .../compile-fail-migration/duplicate-parameter.rs | 15 + .../duplicate-parameter.stderr | 9 + .../duplicate-type-parameter.rs | 39 ++ .../duplicate-type-parameter.stderr | 66 ++ .../duplicate_entry_error.rs | 25 + .../duplicate_entry_error.stderr | 14 + .../dyn-trait-compatibility.rs | 24 + .../dyn-trait-compatibility.stderr | 52 ++ .../edition-extern-crate-allowed.rs | 20 + .../edition-extern-crate-allowed.stderr | 13 + .../compile-fail-migration/edition-feature-ok.rs | 16 + .../edition-raw-pointer-method-2015.rs | 23 + .../edition-raw-pointer-method-2015.stderr | 17 + .../edition-raw-pointer-method-2018.rs | 22 + .../edition-raw-pointer-method-2018.stderr | 9 + src/test/ui/compile-fail-migration/elided-test.rs | 17 + .../ui/compile-fail-migration/elided-test.stderr | 7 + .../ui/compile-fail-migration/empty-comment.rs | 21 + .../ui/compile-fail-migration/empty-comment.stderr | 8 + .../ui/compile-fail-migration/empty-extern-arg.rs | 14 + .../compile-fail-migration/empty-extern-arg.stderr | 7 + .../ui/compile-fail-migration/empty-linkname.rs | 15 + .../compile-fail-migration/empty-linkname.stderr | 9 + .../ui/compile-fail-migration/empty-macro-use.rs | 19 + .../compile-fail-migration/empty-macro-use.stderr | 8 + .../ui/compile-fail-migration/empty-never-array.rs | 27 + .../empty-never-array.stderr | 9 + .../empty-struct-braces-expr.rs | 34 + .../empty-struct-braces-expr.stderr | 68 ++ .../empty-struct-braces-pat-1.rs | 44 ++ .../empty-struct-braces-pat-1.stderr | 18 + .../empty-struct-braces-pat-2.rs | 36 + .../empty-struct-braces-pat-2.stderr | 39 ++ .../empty-struct-braces-pat-3.rs | 42 ++ .../empty-struct-braces-pat-3.stderr | 33 + .../empty-struct-tuple-pat.rs | 47 ++ .../empty-struct-tuple-pat.stderr | 36 + .../empty-struct-unit-pat.rs | 59 ++ .../empty-struct-unit-pat.stderr | 55 ++ .../enable-unstable-lib-feature.rs | 24 + .../enable-unstable-lib-feature.stderr | 14 + .../enum-discrim-autosizing.rs | 20 + .../enum-discrim-autosizing.stderr | 16 + .../enum-discrim-too-small.rs | 49 ++ .../enum-discrim-too-small.stderr | 35 + .../enum-discrim-too-small2.rs | 47 ++ .../enum-discrim-too-small2.stderr | 32 + .../ui/compile-fail-migration/enum-in-scope.rs | 15 + .../ui/compile-fail-migration/enum-in-scope.stderr | 12 + .../compile-fail-migration/enum-to-float-cast-2.rs | 28 + .../enum-to-float-cast-2.stderr | 19 + .../compile-fail-migration/enum-to-float-cast.rs | 31 + .../enum-to-float-cast.stderr | 19 + .../compile-fail-migration/enum-variant-type-2.rs | 19 + .../enum-variant-type-2.stderr | 12 + .../enums-pats-not-idents.rs | 13 + .../enums-pats-not-idents.stderr | 9 + .../error-should-say-copy-not-pod.rs | 17 + .../error-should-say-copy-not-pod.stderr | 15 + .../ui/compile-fail-migration/estr-subtyping.rs | 25 + .../compile-fail-migration/estr-subtyping.stderr | 15 + src/test/ui/compile-fail-migration/eval-enum.rs | 22 + .../ui/compile-fail-migration/eval-enum.stderr | 41 ++ .../exclusive-drop-and-copy.rs | 27 + .../exclusive-drop-and-copy.stderr | 15 + .../exclusive_range_pattern_syntax_collision.rs | 18 + ...exclusive_range_pattern_syntax_collision.stderr | 8 + .../exclusive_range_pattern_syntax_collision2.rs | 18 + ...xclusive_range_pattern_syntax_collision2.stderr | 8 + .../exclusive_range_pattern_syntax_collision3.rs | 18 + ...xclusive_range_pattern_syntax_collision3.stderr | 8 + src/test/ui/compile-fail-migration/expanded-cfg.rs | 32 + .../ui/compile-fail-migration/expanded-cfg.stderr | 8 + .../explicit-call-to-dtor.rs | 24 + .../explicit-call-to-dtor.stderr | 9 + .../explicit-call-to-supertrait-dtor.rs | 33 + .../explicit-call-to-supertrait-dtor.stderr | 9 + .../explicit-self-lifetime-mismatch.rs | 30 + .../explicit-self-lifetime-mismatch.stderr | 41 ++ .../export-fully-qualified.rs | 21 + .../export-fully-qualified.stderr | 9 + .../ui/compile-fail-migration/export-import.rs | 21 + .../ui/compile-fail-migration/export-import.stderr | 9 + .../compile-fail-migration/export-tag-variant.rs | 17 + .../export-tag-variant.stderr | 9 + src/test/ui/compile-fail-migration/export.rs | 20 + src/test/ui/compile-fail-migration/export.stderr | 34 + src/test/ui/compile-fail-migration/export2.rs | 21 + src/test/ui/compile-fail-migration/export2.stderr | 9 + .../expr_attr_paren_order.rs | 34 + .../expr_attr_paren_order.stderr | 14 + .../ui/compile-fail-migration/ext-nonexistent.rs | 12 + .../compile-fail-migration/ext-nonexistent.stderr | 8 + .../extenv-arg-2-not-string-literal.rs | 11 + .../extenv-arg-2-not-string-literal.stderr | 8 + .../ui/compile-fail-migration/extenv-no-args.rs | 11 + .../compile-fail-migration/extenv-no-args.stderr | 8 + .../extenv-not-defined-custom.rs | 11 + .../extenv-not-defined-custom.stderr | 8 + .../extenv-not-defined-default.rs | 14 + .../extenv-not-defined-default.stderr | 8 + .../extenv-not-string-literal.rs | 11 + .../extenv-not-string-literal.stderr | 8 + .../compile-fail-migration/extenv-too-many-args.rs | 11 + .../extenv-too-many-args.stderr | 8 + .../extern-crate-visibility.rs | 34 + .../extern-crate-visibility.stderr | 15 + src/test/ui/compile-fail-migration/extern-macro.rs | 18 + .../ui/compile-fail-migration/extern-macro.stderr | 8 + .../ui/compile-fail-migration/extern-main-fn.rs | 11 + .../compile-fail-migration/extern-main-fn.stderr | 12 + .../extern-types-distinct-types.rs | 22 + .../extern-types-distinct-types.stderr | 12 + .../extern-types-not-sync-send.rs | 28 + .../extern-types-not-sync-send.stderr | 29 + .../compile-fail-migration/extern-types-unsized.rs | 43 ++ .../extern-types-unsized.stderr | 63 ++ .../extern-with-type-bounds.rs | 30 + .../extern-with-type-bounds.stderr | 9 + .../extern-wrong-value-type.rs | 21 + .../extern-wrong-value-type.stderr | 15 + .../compile-fail-migration/external-doc-error.rs | 16 + .../external-doc-error.stderr | 8 + .../extoption_env-no-args.rs | 11 + .../extoption_env-no-args.stderr | 8 + .../extoption_env-not-string-literal.rs | 11 + .../extoption_env-not-string-literal.stderr | 8 + .../extoption_env-too-many-args.rs | 11 + .../extoption_env-too-many-args.stderr | 8 + .../fail-no-dead-code-core.rs | 28 + .../fail-no-dead-code-core.stderr | 14 + .../ui/compile-fail-migration/fail-no-dead-code.rs | 25 + .../fail-no-dead-code.stderr | 14 + src/test/ui/compile-fail-migration/fail-simple.rs | 13 + .../ui/compile-fail-migration/fail-simple.stderr | 8 + .../feature-gate-alloc-error-handler.rs | 21 + .../feature-gate-alloc-error-handler.stderr | 11 + .../feature-gate-panic-implementation.rs | 21 + .../feature-gate-panic-implementation.stderr | 11 + .../feature-gate-tool_lints.rs | 12 + .../feature-gate-tool_lints.stderr | 11 + ...eature-gate-without_gate_irrefutable_pattern.rs | 17 + ...re-gate-without_gate_irrefutable_pattern.stderr | 9 + .../feature-gated-feature-in-macro-arg.rs | 24 + .../feature-gated-feature-in-macro-arg.stderr | 13 + .../float-literal-inference-restrictions.rs | 14 + .../float-literal-inference-restrictions.stderr | 18 + .../ui/compile-fail-migration/fn-bad-block-type.rs | 15 + .../fn-bad-block-type.stderr | 11 + .../compile-fail-migration/fn-compare-mismatch.rs | 17 + .../fn-compare-mismatch.stderr | 21 + src/test/ui/compile-fail-migration/fn-item-type.rs | 43 ++ .../ui/compile-fail-migration/fn-item-type.stderr | 39 ++ .../compile-fail-migration/fn-trait-formatting.rs | 31 + .../fn-trait-formatting.stderr | 46 ++ src/test/ui/compile-fail-migration/for-expn.rs | 19 + src/test/ui/compile-fail-migration/for-expn.stderr | 9 + .../ui/compile-fail-migration/for-loop-bogosity.rs | 30 + .../for-loop-bogosity.stderr | 12 + .../for-loop-refutable-pattern-error-message.rs | 13 + ...for-loop-refutable-pattern-error-message.stderr | 9 + .../compile-fail-migration/for-loop-type-error.rs | 16 + .../for-loop-type-error.stderr | 11 + .../for-loop-unconstrained-element-type.rs | 19 + .../for-loop-unconstrained-element-type.stderr | 12 + .../foreign-fn-return-lifetime.rs | 16 + .../foreign-fn-return-lifetime.stderr | 12 + .../foreign-unsafe-fn-called.rs | 21 + .../foreign-unsafe-fn-called.stderr | 11 + .../fully-qualified-type-name1.rs | 20 + .../fully-qualified-type-name1.stderr | 15 + .../fully-qualified-type-name2.rs | 30 + .../fully-qualified-type-name2.stderr | 12 + .../fully-qualified-type-name3.rs | 24 + .../fully-qualified-type-name4.rs | 24 + .../fully-qualified-type-name4.stderr | 12 + ...functional-struct-update-noncopyable.nll.stderr | 9 + .../functional-struct-update-noncopyable.rs | 24 + .../functional-struct-update-noncopyable.stderr | 9 + .../functional-struct-update-respects-privacy.rs | 42 ++ ...unctional-struct-update-respects-privacy.stderr | 9 + .../future-incompatible-lint-group.rs | 18 + .../future-incompatible-lint-group.stderr | 17 + .../compile-fail-migration/gated-attr-literals.rs | 43 ++ .../gated-attr-literals.stderr | 195 ++++++ .../ui/compile-fail-migration/gated-bad-feature.rs | 22 + .../gated-bad-feature.stderr | 38 ++ .../generator-yielding-or-returning-itself.rs | 45 ++ .../generator-yielding-or-returning-itself.stderr | 39 ++ .../generic-extern-lifetime.rs | 25 + .../generic-extern-lifetime.stderr | 21 + .../ui/compile-fail-migration/generic-extern.rs | 17 + .../compile-fail-migration/generic-extern.stderr | 11 + .../generic-impl-less-params-with-defaults.rs | 23 + .../generic-impl-less-params-with-defaults.stderr | 9 + .../generic-impl-more-params-with-defaults.rs | 25 + .../generic-impl-more-params-with-defaults.stderr | 9 + .../generic-lifetime-trait-impl.rs | 33 + .../generic-lifetime-trait-impl.stderr | 12 + .../ui/compile-fail-migration/generic-no-mangle.rs | 25 + .../generic-no-mangle.stderr | 24 + .../generic-non-trailing-defaults.rs | 20 + .../generic-non-trailing-defaults.stderr | 21 + .../generic-type-params-forward-mention.rs | 16 + .../generic-type-params-forward-mention.stderr | 9 + .../generic-type-params-name-repr.rs | 61 ++ .../generic-type-params-name-repr.stderr | 57 ++ src/test/ui/compile-fail-migration/glob-cycles.rs | 29 + .../ui/compile-fail-migration/glob-cycles.stderr | 8 + .../ui/compile-fail-migration/glob-resolve1.rs | 41 ++ .../ui/compile-fail-migration/glob-resolve1.stderr | 79 +++ .../hashmap-iter-value-lifetime.nll.stderr | 15 + .../hashmap-iter-value-lifetime.rs | 20 + .../hashmap-iter-value-lifetime.stderr | 15 + .../ui/compile-fail-migration/hashmap-lifetimes.rs | 17 + .../hashmap-lifetimes.stderr | 13 + .../compile-fail-migration/hidden-rt-injection.rs | 18 + .../hidden-rt-injection.stderr | 9 + .../compile-fail-migration/hidden-rt-injection2.rs | 18 + .../hidden-rt-injection2.stderr | 9 + ...subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr | 16 + .../hr-subtype.bound_a_b_vs_bound_a.stderr | 16 + .../hr-subtype.bound_a_vs_bound_a.stderr | 14 + .../hr-subtype.bound_a_vs_bound_b.stderr | 14 + .../hr-subtype.bound_a_vs_free_x.stderr | 16 + .../hr-subtype.bound_co_a_b_vs_bound_co_a.stderr | 16 + .../hr-subtype.bound_co_a_co_b_ret_contra_a.stderr | 16 + .../hr-subtype.bound_co_a_vs_bound_co_b.stderr | 14 + ...subtype.bound_contra_a_contra_b_ret_co_a.stderr | 16 + .../hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr | 16 + .../hr-subtype.bound_inv_a_vs_bound_inv_b.stderr | 14 + .../hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr | 34 + .../hr-subtype.free_inv_x_vs_free_inv_y.stderr | 65 ++ .../hr-subtype.free_x_vs_free_x.stderr | 14 + .../hr-subtype.free_x_vs_free_y.nll.stderr | 24 + .../hr-subtype.free_x_vs_free_y.stderr | 34 + src/test/ui/compile-fail-migration/hr-subtype.rs | 116 ++++ .../hrtb-conflate-regions.rs | 40 ++ .../hrtb-conflate-regions.stderr | 20 + .../hrtb-debruijn-in-receiver.nll.stderr | 14 + .../hrtb-debruijn-in-receiver.rs | 28 + .../hrtb-debruijn-in-receiver.stderr | 13 + .../hrtb-higher-ranker-supertraits-transitive.rs | 60 ++ ...rtb-higher-ranker-supertraits-transitive.stderr | 19 + .../hrtb-higher-ranker-supertraits.rs | 58 ++ .../hrtb-higher-ranker-supertraits.stderr | 40 ++ .../hrtb-identity-fn-borrows.ast.nll.stderr | 14 + .../hrtb-identity-fn-borrows.ast.stderr | 11 + .../hrtb-identity-fn-borrows.mir.stderr | 14 + .../hrtb-identity-fn-borrows.rs | 40 ++ .../compile-fail-migration/hrtb-just-for-static.rs | 37 ++ .../hrtb-just-for-static.stderr | 20 + .../hrtb-perfect-forwarding.rs | 66 ++ .../hrtb-perfect-forwarding.stderr | 23 + .../ui/compile-fail-migration/huge-array-simple.rs | 21 + src/test/ui/compile-fail-migration/huge-array.rs | 20 + .../ui/compile-fail-migration/huge-array.stderr | 4 + src/test/ui/compile-fail-migration/huge-enum.rs | 23 + .../ui/compile-fail-migration/huge-enum.stderr | 4 + src/test/ui/compile-fail-migration/huge-struct.rs | 54 ++ .../ui/compile-fail-migration/huge-struct.stderr | 4 + .../ui/compile-fail-migration/hygienic-label-1.rs | 17 + .../compile-fail-migration/hygienic-label-1.stderr | 12 + .../ui/compile-fail-migration/hygienic-label-2.rs | 17 + .../compile-fail-migration/hygienic-label-2.stderr | 9 + .../ui/compile-fail-migration/hygienic-label-3.rs | 19 + .../compile-fail-migration/hygienic-label-3.stderr | 12 + .../ui/compile-fail-migration/hygienic-label-4.rs | 17 + .../compile-fail-migration/hygienic-label-4.stderr | 9 + .../ui/compile-fail-migration/if-branch-types.rs | 15 + .../compile-fail-migration/if-branch-types.stderr | 12 + src/test/ui/compile-fail-migration/if-let.rs | 55 ++ src/test/ui/compile-fail-migration/if-let.stderr | 39 ++ src/test/ui/compile-fail-migration/if-loop.rs | 20 + src/test/ui/compile-fail-migration/if-loop.stderr | 8 + src/test/ui/compile-fail-migration/if-typeck.rs | 20 + .../ui/compile-fail-migration/if-typeck.stderr | 12 + .../if-without-else-result.rs | 18 + .../if-without-else-result.stderr | 12 + .../compile-fail-migration/ifmt-bad-format-args.rs | 14 + .../ifmt-bad-format-args.stderr | 18 + src/test/ui/compile-fail-migration/ifmt-unimpl.rs | 14 + .../ui/compile-fail-migration/ifmt-unimpl.stderr | 12 + .../compile-fail-migration/ifmt-unknown-trait.rs | 14 + .../ifmt-unknown-trait.stderr | 8 + .../ui/compile-fail-migration/illegal-ufcs-drop.rs | 20 + .../illegal-ufcs-drop.stderr | 9 + .../immut-function-arguments.ast.nll.stderr | 19 + .../immut-function-arguments.ast.stderr | 19 + .../immut-function-arguments.mir.stderr | 19 + .../immut-function-arguments.rs | 24 + .../compile-fail-migration/impl-bounds-checking.rs | 24 + .../impl-bounds-checking.stderr | 9 + .../impl-trait/impl-generic-mismatch-ab.rs | 22 + .../impl-trait/impl-generic-mismatch-ab.stderr | 15 + .../impl-trait/infinite-impl-trait-issue-38064.rs | 37 ++ .../infinite-impl-trait-issue-38064.stderr | 7 + .../must_outlive_least_region_or_bound.nll.stderr | 73 +++ .../must_outlive_least_region_or_bound.rs | 37 ++ .../must_outlive_least_region_or_bound.stderr | 71 ++ .../impl-trait/needs_least_region_or_bound.rs | 21 + .../impl-trait/needs_least_region_or_bound.stderr | 8 + .../compile-fail-migration/impl-trait/no-trait.rs | 13 + .../impl-trait/no-trait.stderr | 8 + .../impl-trait/type_parameters_captured.nll.stderr | 17 + .../impl-trait/type_parameters_captured.rs | 22 + .../impl-trait/type_parameters_captured.stderr | 17 + .../impl-trait/where-allowed.rs | 235 +++++++ .../impl-trait/where-allowed.stderr | 244 +++++++ .../impl-unused-tps-inherent.rs | 35 + .../impl-unused-tps-inherent.stderr | 15 + .../ui/compile-fail-migration/impl-unused-tps.rs | 72 ++ .../compile-fail-migration/impl-unused-tps.stderr | 33 + .../compile-fail-migration/implicit-method-bind.rs | 13 + .../implicit-method-bind.stderr | 11 + .../ui/compile-fail-migration/import-crate-var.rs | 22 + .../compile-fail-migration/import-crate-var.stderr | 19 + .../compile-fail-migration/import-from-missing.rs | 22 + .../import-from-missing.stderr | 9 + .../ui/compile-fail-migration/import-glob-0.rs | 26 + .../ui/compile-fail-migration/import-glob-0.stderr | 9 + .../compile-fail-migration/import-glob-circular.rs | 27 + .../import-glob-circular.stderr | 14 + .../ui/compile-fail-migration/import-loop-2.rs | 21 + .../ui/compile-fail-migration/import-loop-2.stderr | 19 + src/test/ui/compile-fail-migration/import-loop.rs | 19 + .../ui/compile-fail-migration/import-loop.stderr | 9 + .../import-prefix-macro-1.rs | 26 + .../import-prefix-macro-1.stderr | 11 + .../import-prefix-macro-2.rs | 26 + .../import-prefix-macro-2.stderr | 11 + .../compile-fail-migration/import-trait-method.rs | 17 + .../import-trait-method.stderr | 9 + src/test/ui/compile-fail-migration/import.rs | 25 + src/test/ui/compile-fail-migration/import.stderr | 22 + src/test/ui/compile-fail-migration/import2.rs | 20 + src/test/ui/compile-fail-migration/import2.stderr | 9 + src/test/ui/compile-fail-migration/import3.rs | 14 + src/test/ui/compile-fail-migration/import3.stderr | 9 + src/test/ui/compile-fail-migration/import4.rs | 17 + src/test/ui/compile-fail-migration/import4.stderr | 9 + .../ui/compile-fail-migration/imports/reexports.rs | 42 ++ .../imports/reexports.stderr | 34 + .../imports/unused-macro-use.rs | 21 + .../imports/unused-macro-use.stderr | 21 + .../ui/compile-fail-migration/imports/unused.rs | 37 ++ .../compile-fail-migration/imports/unused.stderr | 15 + .../inaccessible-test-modules.rs | 19 + .../inaccessible-test-modules.stderr | 15 + src/test/ui/compile-fail-migration/index-bot.rs | 13 + .../ui/compile-fail-migration/index-bot.stderr | 9 + .../ui/compile-fail-migration/index_message.rs | 14 + .../ui/compile-fail-migration/index_message.stderr | 9 + .../indexing-requires-a-uint.rs | 24 + .../indexing-requires-a-uint.stderr | 19 + .../compile-fail-migration/infinite-autoderef.rs | 37 ++ .../infinite-autoderef.stderr | 52 ++ .../infinite-instantiation.rs | 44 ++ .../infinite-instantiation.stderr | 14 + .../infinite-macro-expansion.rs | 17 + .../infinite-macro-expansion.stderr | 13 + .../infinite-tag-type-recursion.rs | 14 + .../infinite-tag-type-recursion.stderr | 13 + .../infinite-vec-type-recursion.rs | 14 + .../infinite-vec-type-recursion.stderr | 11 + .../inhabitedness-infinite-loop.rs | 26 + .../inhabitedness-infinite-loop.stderr | 4 + src/test/ui/compile-fail-migration/init-unsafe.rs | 18 + .../ui/compile-fail-migration/init-unsafe.stderr | 11 + .../inner-static-type-parameter.rs | 21 + .../inner-static-type-parameter.stderr | 22 + .../integer-literal-suffix-inference.rs | 172 +++++ .../integer-literal-suffix-inference.stderr | 291 ++++++++ .../ui/compile-fail-migration/integral-indexing.rs | 26 + .../integral-indexing.stderr | 75 +++ .../integral-variable-unification-error.rs | 18 + .../integral-variable-unification-error.stderr | 12 + .../internal-unstable-noallow.rs | 33 + .../internal-unstable-noallow.stderr | 39 ++ .../internal-unstable-thread-local.rs | 21 + .../internal-unstable-thread-local.stderr | 11 + .../ui/compile-fail-migration/internal-unstable.rs | 52 ++ .../internal-unstable.stderr | 46 ++ .../intrinsic-invalid-number-of-arguments.rs | 24 + .../intrinsic-invalid-number-of-arguments.stderr | 9 + .../compile-fail-migration/invalid-crate-type.rs | 16 + .../invalid-crate-type.stderr | 10 + .../ui/compile-fail-migration/invalid-inline.rs | 28 + .../compile-fail-migration/invalid-inline.stderr | 22 + .../invalid-macro-matcher.rs | 18 + .../invalid-macro-matcher.stderr | 8 + .../compile-fail-migration/invalid-plugin-attr.rs | 17 + .../invalid-plugin-attr.stderr | 20 + .../invalid_crate_type_syntax.rs | 14 + .../invalid_crate_type_syntax.stderr | 15 + src/test/ui/compile-fail-migration/isssue-38821.rs | 43 ++ .../ui/compile-fail-migration/isssue-38821.stderr | 12 + src/test/ui/compile-fail-migration/issue-10755.rs | 15 + .../ui/compile-fail-migration/issue-10755.stderr | 6 + src/test/ui/compile-fail-migration/issue-11593.rs | 20 + .../ui/compile-fail-migration/issue-11593.stderr | 9 + src/test/ui/compile-fail-migration/issue-11680.rs | 21 + .../ui/compile-fail-migration/issue-11680.stderr | 15 + src/test/ui/compile-fail-migration/issue-15919.rs | 21 + .../ui/compile-fail-migration/issue-15919.stderr | 4 + src/test/ui/compile-fail-migration/issue-16725.rs | 18 + .../ui/compile-fail-migration/issue-16725.stderr | 9 + .../issue-17718-const-privacy.rs | 26 + .../issue-17718-const-privacy.stderr | 15 + src/test/ui/compile-fail-migration/issue-17913.rs | 28 + .../ui/compile-fail-migration/issue-17913.stderr | 4 + .../compile-fail-migration/issue-19163.nll.stderr | 9 + src/test/ui/compile-fail-migration/issue-19163.rs | 21 + .../ui/compile-fail-migration/issue-19163.stderr | 9 + src/test/ui/compile-fail-migration/issue-1920-1.rs | 24 + .../ui/compile-fail-migration/issue-1920-1.stderr | 15 + src/test/ui/compile-fail-migration/issue-1920-2.rs | 22 + .../ui/compile-fail-migration/issue-1920-2.stderr | 15 + src/test/ui/compile-fail-migration/issue-1920-3.rs | 26 + .../ui/compile-fail-migration/issue-1920-3.stderr | 15 + src/test/ui/compile-fail-migration/issue-21146.rs | 13 + .../ui/compile-fail-migration/issue-21146.stderr | 8 + src/test/ui/compile-fail-migration/issue-21202.rs | 25 + .../ui/compile-fail-migration/issue-21202.stderr | 9 + src/test/ui/compile-fail-migration/issue-22638.rs | 69 ++ .../ui/compile-fail-migration/issue-22638.stderr | 14 + .../ui/compile-fail-migration/issue-23595-1.rs | 26 + .../ui/compile-fail-migration/issue-23595-1.stderr | 21 + src/test/ui/compile-fail-migration/issue-26548.rs | 21 + .../ui/compile-fail-migration/issue-26548.stderr | 13 + src/test/ui/compile-fail-migration/issue-28075.rs | 23 + .../ui/compile-fail-migration/issue-28075.stderr | 11 + .../ui/compile-fail-migration/issue-28388-1.rs | 15 + .../ui/compile-fail-migration/issue-28388-1.stderr | 9 + .../ui/compile-fail-migration/issue-28388-2.rs | 20 + .../ui/compile-fail-migration/issue-28388-2.stderr | 9 + .../ui/compile-fail-migration/issue-28388-3.rs | 21 + .../ui/compile-fail-migration/issue-28388-3.stderr | 11 + src/test/ui/compile-fail-migration/issue-28625.rs | 30 + .../ui/compile-fail-migration/issue-28625.stderr | 12 + src/test/ui/compile-fail-migration/issue-28848.rs | 23 + .../ui/compile-fail-migration/issue-28848.stderr | 20 + src/test/ui/compile-fail-migration/issue-29181.rs | 17 + .../ui/compile-fail-migration/issue-29181.stderr | 9 + src/test/ui/compile-fail-migration/issue-30123.rs | 19 + .../ui/compile-fail-migration/issue-30123.stderr | 9 + src/test/ui/compile-fail-migration/issue-30535.rs | 19 + .../ui/compile-fail-migration/issue-30535.stderr | 11 + src/test/ui/compile-fail-migration/issue-32377.rs | 27 + .../ui/compile-fail-migration/issue-32377.stderr | 12 + src/test/ui/compile-fail-migration/issue-36881.rs | 17 + .../ui/compile-fail-migration/issue-36881.stderr | 9 + src/test/ui/compile-fail-migration/issue-37131.rs | 18 + .../ui/compile-fail-migration/issue-37131.stderr | 7 + src/test/ui/compile-fail-migration/issue-41549.rs | 22 + .../ui/compile-fail-migration/issue-41549.stderr | 12 + .../ui/compile-fail-migration/issue-43733-2.rs | 39 ++ .../ui/compile-fail-migration/issue-43733-2.stderr | 23 + .../issue-46209-private-enum-variant-reexport.rs | 51 ++ ...ssue-46209-private-enum-variant-reexport.stderr | 44 ++ .../issue-50264-inner-deref-trait/option_deref.rs | 16 + .../option_deref.stderr | 12 + .../issue-50264-inner-deref-trait/result_deref.rs | 16 + .../result_deref.stderr | 12 + .../result_deref_err.rs | 16 + .../result_deref_err.stderr | 13 + .../result_deref_ok.rs | 16 + .../result_deref_ok.stderr | 12 + src/test/ui/compile-fail-migration/issue-52489.rs | 17 + .../ui/compile-fail-migration/issue-52489.stderr | 11 + .../compile-fail-migration/issue-5500-1.ast.stderr | 15 + .../compile-fail-migration/issue-5500-1.mir.stderr | 15 + src/test/ui/compile-fail-migration/issue-5500-1.rs | 27 + src/test/ui/compile-fail-migration/issue-5844.rs | 17 + .../ui/compile-fail-migration/issue-5844.stderr | 11 + src/test/ui/compile-fail-migration/issue32829.rs | 94 +++ .../ui/compile-fail-migration/issue32829.stderr | 94 +++ .../keyword-extern-as-identifier.rs | 15 + .../keyword-extern-as-identifier.stderr | 9 + .../keyword-false-as-identifier.rs | 13 + .../keyword-false-as-identifier.stderr | 12 + .../keyword-self-as-identifier.rs | 13 + .../keyword-self-as-identifier.stderr | 9 + .../keyword-super-as-identifier.rs | 13 + .../keyword-super-as-identifier.stderr | 9 + .../ui/compile-fail-migration/keyword-super.rs | 13 + .../ui/compile-fail-migration/keyword-super.stderr | 9 + .../keyword-true-as-identifier.rs | 13 + .../keyword-true-as-identifier.stderr | 12 + src/test/ui/compile-fail-migration/kindck-copy.rs | 81 +++ .../ui/compile-fail-migration/kindck-copy.stderr | 139 ++++ .../kindck-impl-type-params-2.rs | 25 + .../kindck-impl-type-params-2.stderr | 16 + .../kindck-impl-type-params.nll.stderr | 69 ++ .../kindck-impl-type-params.rs | 60 ++ .../kindck-impl-type-params.stderr | 72 ++ .../kindck-inherited-copy-bound.rs | 39 ++ .../kindck-inherited-copy-bound.stderr | 34 + .../compile-fail-migration/kindck-nonsendable-1.rs | 22 + .../kindck-nonsendable-1.stderr | 17 + .../compile-fail-migration/kindck-send-object.rs | 36 + .../kindck-send-object.stderr | 32 + .../kindck-send-object1.nll.stderr | 38 ++ .../compile-fail-migration/kindck-send-object1.rs | 43 ++ .../kindck-send-object1.stderr | 41 ++ .../compile-fail-migration/kindck-send-object2.rs | 34 + .../kindck-send-object2.stderr | 32 + .../ui/compile-fail-migration/kindck-send-owned.rs | 26 + .../kindck-send-owned.stderr | 18 + .../compile-fail-migration/kindck-send-unsafe.rs | 21 + .../kindck-send-unsafe.rs~rust-lang_master | 22 + .../kindck-send-unsafe.stderr | 16 + src/test/ui/compile-fail-migration/label-static.rs | 15 + .../ui/compile-fail-migration/label-static.stderr | 14 + .../ui/compile-fail-migration/label-underscore.rs | 15 + .../compile-fail-migration/label-underscore.stderr | 14 + .../ui/compile-fail-migration/lang-item-missing.rs | 22 + .../lang-item-missing.stderr | 4 + .../ui/compile-fail-migration/lexical-scopes.rs | 23 + .../compile-fail-migration/lexical-scopes.stderr | 20 + .../lifetime-bound-will-change-warning.nll.stderr | 32 + .../lifetime-bound-will-change-warning.rs | 64 ++ .../lifetime-bound-will-change-warning.stderr | 33 + .../compile-fail-migration/lifetime-no-keyword.rs | 17 + .../lifetime-no-keyword.stderr | 26 + src/test/ui/compile-fail-migration/linkage2.rs | 20 + src/test/ui/compile-fail-migration/linkage2.stderr | 8 + src/test/ui/compile-fail-migration/linkage3.rs | 20 + src/test/ui/compile-fail-migration/linkage3.stderr | 8 + src/test/ui/compile-fail-migration/linkage4.rs | 15 + src/test/ui/compile-fail-migration/linkage4.stderr | 11 + .../lint-attr-non-item-node.rs | 19 + .../lint-attr-non-item-node.stderr | 14 + .../compile-fail-migration/lint-change-warnings.rs | 31 + .../lint-change-warnings.stderr | 36 + .../ui/compile-fail-migration/lint-ctypes-enum.rs | 38 ++ .../compile-fail-migration/lint-ctypes-enum.stderr | 46 ++ .../ui/compile-fail-migration/lint-dead-code-1.rs | 116 ++++ .../compile-fail-migration/lint-dead-code-1.stderr | 62 ++ .../ui/compile-fail-migration/lint-dead-code-2.rs | 51 ++ .../compile-fail-migration/lint-dead-code-2.stderr | 26 + .../ui/compile-fail-migration/lint-dead-code-3.rs | 88 +++ .../compile-fail-migration/lint-dead-code-3.stderr | 38 ++ .../ui/compile-fail-migration/lint-dead-code-4.rs | 93 +++ .../compile-fail-migration/lint-dead-code-4.stderr | 72 ++ .../ui/compile-fail-migration/lint-dead-code-5.rs | 40 ++ .../compile-fail-migration/lint-dead-code-5.stderr | 32 + .../lint-dead-code-type-alias.rs | 20 + .../lint-dead-code-type-alias.stderr | 14 + .../lint-dead-code-variant.rs | 22 + .../lint-dead-code-variant.stderr | 14 + .../lint-directives-on-use-items-issue-10534.rs | 34 + ...lint-directives-on-use-items-issue-10534.stderr | 26 + .../lint-exceeding-bitshifts.rs | 57 ++ .../lint-exceeding-bitshifts.stderr | 116 ++++ .../lint-exceeding-bitshifts2.rs | 27 + .../lint-exceeding-bitshifts2.stderr | 26 + .../compile-fail-migration/lint-forbid-cmdline.rs | 15 + .../lint-forbid-cmdline.stderr | 11 + src/test/ui/compile-fail-migration/lint-impl-fn.rs | 43 ++ .../ui/compile-fail-migration/lint-impl-fn.stderr | 38 ++ .../ui/compile-fail-migration/lint-malformed.rs | 14 + .../compile-fail-migration/lint-malformed.stderr | 15 + .../compile-fail-migration/lint-misplaced-attr.rs | 22 + .../lint-misplaced-attr.stderr | 32 + .../lint-missing-copy-implementations.rs | 25 + .../lint-missing-copy-implementations.stderr | 16 + .../ui/compile-fail-migration/lint-missing-doc.rs | 196 ++++++ .../compile-fail-migration/lint-missing-doc.stderr | 122 ++++ .../lint-non-camel-case-types.rs | 56 ++ .../lint-non-camel-case-types.stderr | 88 +++ .../lint-non-snake-case-crate-2.rs | 16 + .../lint-non-snake-case-crate-2.stderr | 10 + .../lint-non-snake-case-crate.rs | 15 + .../lint-non-snake-case-crate.stderr | 14 + .../lint-non-snake-case-functions.rs | 54 ++ .../lint-non-snake-case-functions.stderr | 62 ++ .../lint-non-snake-case-lifetimes.rs | 18 + .../lint-non-snake-case-lifetimes.stderr | 14 + .../lint-non-snake-case-modules.rs | 20 + .../lint-non-snake-case-modules.stderr | 16 + .../lint-non-uppercase-statics.rs | 22 + .../lint-non-uppercase-statics.stderr | 20 + .../compile-fail-migration/lint-obsolete-attr.rs | 22 + .../lint-obsolete-attr.stderr | 20 + .../compile-fail-migration/lint-output-format.rs | 22 + .../lint-output-format.stderr | 27 + .../lint-owned-heap-memory.rs | 22 + .../lint-owned-heap-memory.stderr | 20 + .../compile-fail-migration/lint-qualification.rs | 29 + .../lint-qualification.stderr | 14 + .../compile-fail-migration/lint-removed-allow.rs | 18 + .../lint-removed-allow.stderr | 14 + .../compile-fail-migration/lint-removed-cmdline.rs | 22 + .../lint-removed-cmdline.stderr | 19 + src/test/ui/compile-fail-migration/lint-removed.rs | 18 + .../ui/compile-fail-migration/lint-removed.stderr | 22 + .../compile-fail-migration/lint-renamed-allow.rs | 18 + .../lint-renamed-allow.stderr | 15 + .../compile-fail-migration/lint-renamed-cmdline.rs | 18 + .../lint-renamed-cmdline.stderr | 19 + src/test/ui/compile-fail-migration/lint-renamed.rs | 14 + .../ui/compile-fail-migration/lint-renamed.stderr | 23 + .../compile-fail-migration/lint-shorthand-field.rs | 64 ++ .../lint-shorthand-field.stderr | 24 + .../ui/compile-fail-migration/lint-stability-2.rs | 423 ++++++++++++ .../compile-fail-migration/lint-stability-2.stderr | 259 ++++++++ .../lint-stability-deprecated.rs | 473 +++++++++++++ .../lint-stability-deprecated.stderr | 644 ++++++++++++++++++ .../lint-stability-fields-deprecated.rs | 349 ++++++++++ .../lint-stability-fields-deprecated.stderr | 380 +++++++++++ .../lint-stability-fields.rs | 293 +++++++++ .../lint-stability-fields.stderr | 347 ++++++++++ .../ui/compile-fail-migration/lint-stability.rs | 464 +++++++++++++ .../compile-fail-migration/lint-stability.stderr | 331 ++++++++++ .../ui/compile-fail-migration/lint-stability2.rs | 23 + .../compile-fail-migration/lint-stability2.stderr | 15 + .../ui/compile-fail-migration/lint-stability3.rs | 24 + .../compile-fail-migration/lint-stability3.stderr | 15 + .../ui/compile-fail-migration/lint-type-limits.rs | 37 ++ .../compile-fail-migration/lint-type-limits.stderr | 58 ++ .../ui/compile-fail-migration/lint-type-limits2.rs | 24 + .../lint-type-limits2.stderr | 18 + .../ui/compile-fail-migration/lint-type-limits3.rs | 22 + .../lint-type-limits3.stderr | 18 + .../compile-fail-migration/lint-type-overflow.rs | 56 ++ .../lint-type-overflow.stderr | 116 ++++ .../compile-fail-migration/lint-type-overflow2.rs | 25 + .../lint-type-overflow2.stderr | 50 ++ .../lint-unexported-no-mangle.rs | 39 ++ .../lint-unexported-no-mangle.stderr | 43 ++ .../ui/compile-fail-migration/lint-unknown-attr.rs | 21 + .../lint-unknown-attr.stderr | 26 + .../lint-unknown-feature-default.rs | 20 + .../lint-unknown-feature-default.stderr | 8 + .../compile-fail-migration/lint-unknown-feature.rs | 20 + .../lint-unknown-feature.stderr | 8 + .../lint-unknown-lint-cmdline.rs | 16 + .../lint-unknown-lint-cmdline.stderr | 7 + .../ui/compile-fail-migration/lint-unknown-lint.rs | 13 + .../lint-unknown-lint.stderr | 23 + .../lint-unnecessary-import-braces.rs | 21 + .../lint-unnecessary-import-braces.stderr | 14 + .../lint-unnecessary-parens.rs | 55 ++ .../lint-unnecessary-parens.stderr | 80 +++ .../ui/compile-fail-migration/lint-unsafe-code.rs | 99 +++ .../compile-fail-migration/lint-unsafe-code.stderr | 95 +++ .../lint-unused-extern-crate.rs | 45 ++ .../lint-unused-extern-crate.stderr | 20 + .../compile-fail-migration/lint-unused-imports.rs | 98 +++ .../lint-unused-imports.stderr | 56 ++ .../compile-fail-migration/lint-unused-mut-self.rs | 22 + .../lint-unused-mut-self.stderr | 24 + .../lint-unused-mut-variables.lexical.stderr | 150 +++++ .../lint-unused-mut-variables.nll.stderr | 150 +++++ .../lint-unused-mut-variables.rs | 145 ++++ .../lint-uppercase-variables.rs | 41 ++ .../lint-uppercase-variables.stderr | 52 ++ ...iveness-assign-imm-local-in-loop.ast.nll.stderr | 12 + .../liveness-assign-imm-local-in-loop.ast.stderr | 9 + .../liveness-assign-imm-local-in-loop.mir.stderr | 12 + .../liveness-assign-imm-local-in-loop.rs | 27 + ...veness-assign-imm-local-in-op-eq.ast.nll.stderr | 15 + .../liveness-assign-imm-local-in-op-eq.ast.stderr | 12 + .../liveness-assign-imm-local-in-op-eq.mir.stderr | 15 + .../liveness-assign-imm-local-in-op-eq.rs | 27 + ...eness-assign-imm-local-with-drop.ast.nll.stderr | 15 + .../liveness-assign-imm-local-with-drop.ast.stderr | 12 + .../liveness-assign-imm-local-with-drop.mir.stderr | 15 + .../liveness-assign-imm-local-with-drop.rs | 27 + ...eness-assign-imm-local-with-init.ast.nll.stderr | 15 + .../liveness-assign-imm-local-with-init.ast.stderr | 12 + .../liveness-assign-imm-local-with-init.mir.stderr | 15 + .../liveness-assign-imm-local-with-init.rs | 27 + .../liveness-closure-require-ret.rs | 12 + .../liveness-closure-require-ret.stderr | 12 + .../ui/compile-fail-migration/liveness-dead.rs | 40 ++ .../ui/compile-fail-migration/liveness-dead.stderr | 32 + .../compile-fail-migration/liveness-forgot-ret.rs | 16 + .../liveness-forgot-ret.stderr | 12 + .../compile-fail-migration/liveness-issue-2163.rs | 18 + .../liveness-issue-2163.stderr | 15 + .../liveness-missing-ret2.rs | 17 + .../liveness-missing-ret2.stderr | 17 + .../liveness-move-call-arg.rs | 21 + .../liveness-move-call-arg.stderr | 11 + .../liveness-move-in-loop.rs | 27 + .../liveness-move-in-loop.stderr | 11 + .../liveness-move-in-while.nll.stderr | 21 + .../liveness-move-in-while.rs | 21 + .../liveness-move-in-while.stderr | 21 + .../ui/compile-fail-migration/liveness-unused.rs | 151 +++++ .../compile-fail-migration/liveness-unused.stderr | 111 ++++ .../liveness-use-after-move.nll.stderr | 11 + .../liveness-use-after-move.rs | 18 + .../liveness-use-after-move.stderr | 13 + .../liveness-use-after-send.nll.stderr | 13 + .../liveness-use-after-send.rs | 29 + .../liveness-use-after-send.stderr | 13 + .../ui/compile-fail-migration/loop-break-value.rs | 103 +++ .../compile-fail-migration/loop-break-value.stderr | 156 +++++ .../loop-labeled-break-value.rs | 21 + .../loop-labeled-break-value.stderr | 30 + .../loop-proper-liveness.nll.stderr | 9 + .../compile-fail-migration/loop-proper-liveness.rs | 42 ++ .../loop-proper-liveness.stderr | 9 + .../loop-properly-diverging-2.rs | 16 + .../loop-properly-diverging-2.stderr | 12 + .../lto-duplicate-symbols.rs | 20 + .../lto-duplicate-symbols.stderr | 6 + .../ui/compile-fail-migration/lub-if.nll.stderr | 30 + src/test/ui/compile-fail-migration/lub-if.rs | 52 ++ src/test/ui/compile-fail-migration/lub-if.stderr | 29 + .../ui/compile-fail-migration/lub-match.nll.stderr | 30 + src/test/ui/compile-fail-migration/lub-match.rs | 55 ++ .../ui/compile-fail-migration/lub-match.stderr | 29 + .../ui/compile-fail-migration/macro-attribute.rs | 12 + .../compile-fail-migration/macro-attribute.stderr | 8 + .../macro-comma-behavior.core.stderr | 44 ++ .../compile-fail-migration/macro-comma-behavior.rs | 101 +++ .../macro-comma-behavior.std.stderr | 62 ++ .../compile-fail-migration/macro-comma-support.rs | 20 + .../macro-comma-support.stderr | 14 + .../macro-crate-nonterminal-non-root.rs | 19 + .../macro-crate-nonterminal-non-root.stderr | 9 + src/test/ui/compile-fail-migration/macro-error.rs | 19 + .../ui/compile-fail-migration/macro-error.stderr | 14 + .../macro-expanded-include/file.txt | 0 .../macro-expanded-include/foo/mod.rs | 19 + .../macro-expanded-include/test.rs | 23 + .../macro-expanded-include/test.stderr | 8 + .../macro-expansion-tests.rs | 50 ++ .../macro-expansion-tests.stderr | 18 + src/test/ui/compile-fail-migration/macro-follow.rs | 124 ++++ .../ui/compile-fail-migration/macro-follow.stderr | 512 +++++++++++++++ .../macro-followed-by-seq-bad.rs | 21 + .../macro-followed-by-seq-bad.stderr | 14 + .../macro-inner-attributes.rs | 30 + .../macro-inner-attributes.stderr | 9 + .../macro-input-future-proofing.rs | 33 + .../macro-input-future-proofing.stderr | 56 ++ .../macro-local-data-key-priv.rs | 20 + .../macro-local-data-key-priv.stderr | 9 + .../macro-match-nonterminal.rs | 15 + .../macro-match-nonterminal.stderr | 8 + .../macro-missing-delimiters.rs | 17 + .../macro-missing-delimiters.stderr | 8 + .../macro-missing-fragment.rs | 17 + .../macro-missing-fragment.stderr | 8 + .../compile-fail-migration/macro-non-lifetime.rs | 20 + .../macro-non-lifetime.stderr | 8 + .../macro-outer-attributes.rs | 30 + .../macro-outer-attributes.stderr | 13 + .../compile-fail-migration/macro-parameter-span.rs | 23 + .../macro-parameter-span.stderr | 9 + .../ui/compile-fail-migration/macro-stability.rs | 22 + .../compile-fail-migration/macro-stability.stderr | 11 + .../compile-fail-migration/macro-stmt-matchers.rs | 17 + .../macro-stmt-matchers.stderr | 11 + .../ui/compile-fail-migration/macro-tt-matchers.rs | 21 + .../macro-tt-matchers.stderr | 8 + .../compile-fail-migration/macro-use-bad-args-1.rs | 15 + .../macro-use-bad-args-1.stderr | 14 + .../compile-fail-migration/macro-use-bad-args-2.rs | 15 + .../macro-use-bad-args-2.stderr | 14 + .../ui/compile-fail-migration/macro-use-scope.rs | 32 + .../compile-fail-migration/macro-use-scope.stderr | 8 + .../ui/compile-fail-migration/macro-use-undef.rs | 18 + .../compile-fail-migration/macro-use-undef.stderr | 9 + .../compile-fail-migration/macro-use-wrong-name.rs | 19 + .../macro-use-wrong-name.stderr | 8 + .../macro-with-seps-err-msg.rs | 15 + .../macro-with-seps-err-msg.stderr | 27 + .../ui/compile-fail-migration/macros-in-extern.rs | 42 ++ .../compile-fail-migration/macros-in-extern.stderr | 27 + .../macros-nonfatal-errors.rs | 42 ++ .../macros-nonfatal-errors.stderr | 100 +++ .../ui/compile-fail-migration/main-wrong-type.rs | 18 + .../compile-fail-migration/main-wrong-type.stderr | 12 + .../malformed-derive-entry.rs | 25 + .../malformed-derive-entry.stderr | 26 + .../compile-fail-migration/malformed-plugin-1.rs | 14 + .../malformed-plugin-1.stderr | 9 + .../compile-fail-migration/malformed-plugin-2.rs | 14 + .../malformed-plugin-2.stderr | 9 + .../compile-fail-migration/malformed-plugin-3.rs | 14 + .../malformed-plugin-3.stderr | 9 + .../compile-fail-migration/malformed_macro_lhs.rs | 17 + .../malformed_macro_lhs.stderr | 8 + .../compile-fail-migration/manual-link-bad-form.rs | 15 + .../manual-link-bad-form.stderr | 4 + .../compile-fail-migration/manual-link-bad-kind.rs | 15 + .../manual-link-bad-kind.stderr | 2 + .../manual-link-bad-search-path.rs | 15 + .../manual-link-bad-search-path.stderr | 2 + .../manual-link-framework.rs | 17 + .../manual-link-framework.stderr | 4 + src/test/ui/compile-fail-migration/map-types.rs | 29 + .../ui/compile-fail-migration/map-types.stderr | 11 + .../compile-fail-migration/match-argm-statics-2.rs | 73 +++ .../match-argm-statics-2.stderr | 21 + .../ui/compile-fail-migration/match-arm-statics.rs | 79 +++ .../match-arm-statics.stderr | 26 + .../match-byte-array-patterns-2.rs | 24 + .../match-byte-array-patterns-2.stderr | 15 + .../match-byte-array-patterns.rs | 66 ++ .../match-byte-array-patterns.stderr | 56 ++ .../ui/compile-fail-migration/match-ill-type2.rs | 17 + .../compile-fail-migration/match-ill-type2.stderr | 9 + src/test/ui/compile-fail-migration/match-join.rs | 21 + .../ui/compile-fail-migration/match-join.stderr | 9 + .../match-no-arms-unreachable-after.rs | 22 + .../match-no-arms-unreachable-after.stderr | 14 + .../compile-fail-migration/match-non-exhaustive.rs | 14 + .../match-non-exhaustive.stderr | 15 + .../match-pattern-field-mismatch-2.rs | 26 + .../match-pattern-field-mismatch-2.stderr | 9 + .../match-pattern-field-mismatch.rs | 26 + .../match-pattern-field-mismatch.stderr | 9 + .../match-privately-empty.rs | 31 + .../match-privately-empty.stderr | 9 + .../compile-fail-migration/match-range-fail-2.rs | 31 + .../match-range-fail-2.stderr | 22 + .../match-range-fail-dominate.rs | 49 ++ .../match-range-fail-dominate.stderr | 66 ++ .../ui/compile-fail-migration/match-range-fail.rs | 33 + .../compile-fail-migration/match-range-fail.stderr | 31 + .../ui/compile-fail-migration/match-ref-ice.rs | 26 + .../ui/compile-fail-migration/match-ref-ice.stderr | 14 + .../match-ref-mut-invariance.nll.stderr | 21 + .../match-ref-mut-invariance.rs | 24 + .../match-ref-mut-invariance.stderr | 22 + .../match-ref-mut-let-invariance.nll.stderr | 22 + .../match-ref-mut-let-invariance.rs | 25 + .../match-ref-mut-let-invariance.stderr | 22 + .../compile-fail-migration/match-slice-patterns.rs | 24 + .../match-slice-patterns.stderr | 9 + .../match-static-const-lc.rs | 61 ++ .../match-static-const-lc.stderr | 26 + src/test/ui/compile-fail-migration/match-struct.rs | 24 + .../ui/compile-fail-migration/match-struct.stderr | 12 + .../ui/compile-fail-migration/match-tag-nullary.rs | 16 + .../match-tag-nullary.stderr | 12 + .../ui/compile-fail-migration/match-tag-unary.rs | 16 + .../compile-fail-migration/match-tag-unary.stderr | 12 + ...h-unreachable-warning-with-diverging-discrim.rs | 16 + ...reachable-warning-with-diverging-discrim.stderr | 14 + .../match-unresolved-one-arm.rs | 17 + .../match-unresolved-one-arm.stderr | 12 + .../ui/compile-fail-migration/match-vec-fixed.rs | 28 + .../compile-fail-migration/match-vec-fixed.stderr | 20 + .../compile-fail-migration/match-vec-mismatch-2.rs | 16 + .../match-vec-mismatch-2.stderr | 9 + .../compile-fail-migration/match-vec-mismatch.rs | 48 ++ .../match-vec-mismatch.stderr | 36 + .../match-vec-unreachable.rs | 40 ++ .../match-vec-unreachable.stderr | 26 + .../maybe-bounds-where-cpass.rs | 19 + .../maybe-bounds-where-cpass.stderr | 11 + .../compile-fail-migration/maybe-bounds-where.rs | 37 ++ .../maybe-bounds-where.stderr | 45 ++ .../meta-expected-error-correct-rev.a.stderr | 9 + .../meta-expected-error-correct-rev.rs | 20 + .../meta-expected-error-wrong-rev.a.stderr | 9 + .../meta-expected-error-wrong-rev.rs | 24 + .../method-ambig-one-trait-unknown-int-type.rs | 46 ++ .../method-ambig-one-trait-unknown-int-type.stderr | 18 + .../method-ambig-two-traits-cross-crate.rs | 21 + .../method-ambig-two-traits-cross-crate.stderr | 16 + .../method-ambig-two-traits-from-bounds.rs | 18 + .../method-ambig-two-traits-from-bounds.stderr | 22 + .../method-ambig-two-traits-with-default-method.rs | 23 + ...hod-ambig-two-traits-with-default-method.stderr | 20 + .../method-call-lifetime-args-lint.rs | 97 +++ .../method-call-lifetime-args-lint.stderr | 187 ++++++ .../method-call-lifetime-args-subst-index.rs | 25 + .../method-call-lifetime-args-subst-index.stderr | 8 + .../method-call-lifetime-args-unresolved.rs | 13 + .../method-call-lifetime-args-unresolved.stderr | 9 + .../method-call-lifetime-args.rs | 82 +++ .../method-call-lifetime-args.stderr | 196 ++++++ .../method-call-type-binding.rs | 13 + .../method-call-type-binding.stderr | 9 + .../method-macro-backtrace.rs | 35 + .../method-macro-backtrace.stderr | 11 + .../method-path-in-pattern.rs | 36 + .../method-path-in-pattern.stderr | 21 + .../method-resolvable-path-in-pattern.rs | 24 + .../method-resolvable-path-in-pattern.stderr | 9 + .../ui/compile-fail-migration/method-self-arg-1.rs | 29 + .../method-self-arg-1.stderr | 24 + .../ui/compile-fail-migration/method-self-arg-2.rs | 28 + .../method-self-arg-2.stderr | 25 + src/test/ui/compile-fail-migration/minus-string.rs | 13 + .../ui/compile-fail-migration/minus-string.stderr | 11 + .../compile-fail-migration/mir-dataflow/README.md | 53 ++ .../mir-dataflow/def-inits-1.rs | 62 ++ .../mir-dataflow/def-inits-1.stderr | 28 + .../compile-fail-migration/mir-dataflow/inits-1.rs | 64 ++ .../mir-dataflow/inits-1.stderr | 22 + .../mir-dataflow/uninits-1.rs | 62 ++ .../mir-dataflow/uninits-1.stderr | 34 + .../mir-dataflow/uninits-2.rs | 35 + .../mir-dataflow/uninits-2.stderr | 10 + src/test/ui/compile-fail-migration/mir-unpretty.rs | 15 + .../ui/compile-fail-migration/mir-unpretty.stderr | 12 + .../missing-derivable-attr.rs | 26 + .../missing-derivable-attr.stderr | 12 + .../ui/compile-fail-migration/missing-macro-use.rs | 18 + .../missing-macro-use.stderr | 8 + src/test/ui/compile-fail-migration/missing-main.rs | 12 + .../ui/compile-fail-migration/missing-main.stderr | 7 + .../ui/compile-fail-migration/missing-return.rs | 15 + .../compile-fail-migration/missing-return.stderr | 12 + .../missing-semicolon-warning.rs | 22 + .../missing-semicolon-warning.stderr | 30 + .../ui/compile-fail-migration/missing-stability.rs | 34 + .../missing-stability.stderr | 17 + .../compile-fail-migration/missing_debug_impls.rs | 48 ++ .../missing_debug_impls.stderr | 20 + src/test/ui/compile-fail-migration/mod_file_aux.rs | 13 + .../mod_file_correct_spans.rs | 18 + .../mod_file_correct_spans.stderr | 9 + .../ui/compile-fail-migration/mod_file_disambig.rs | 17 + .../mod_file_disambig.stderr | 11 + .../mod_file_disambig_aux.rs | 11 + .../mod_file_disambig_aux/mod.rs | 11 + .../module-macro_use-arguments.rs | 16 + .../module-macro_use-arguments.stderr | 8 + .../move-guard-same-consts.rs | 35 + .../move-guard-same-consts.stderr | 13 + .../ui/compile-fail-migration/move-in-guard-1.rs | 25 + .../compile-fail-migration/move-in-guard-1.stderr | 13 + .../ui/compile-fail-migration/move-in-guard-2.rs | 25 + .../compile-fail-migration/move-in-guard-2.stderr | 11 + .../move-into-dead-array-1.nll.stderr | 9 + .../move-into-dead-array-1.rs | 25 + .../move-into-dead-array-1.stderr | 9 + .../move-into-dead-array-2.nll.stderr | 13 + .../move-into-dead-array-2.rs | 25 + .../move-into-dead-array-2.stderr | 13 + .../compile-fail-migration/move-out-of-array-1.rs | 28 + .../move-out-of-array-1.stderr | 9 + .../move-out-of-slice-1.nll.stderr | 14 + .../compile-fail-migration/move-out-of-slice-1.rs | 21 + .../move-out-of-slice-1.stderr | 12 + .../move-out-of-tuple-field.nll.stderr | 23 + .../move-out-of-tuple-field.rs | 23 + .../move-out-of-tuple-field.stderr | 23 + .../moves-based-on-type-access-to-field.nll.stderr | 13 + .../moves-based-on-type-access-to-field.rs | 24 + .../moves-based-on-type-access-to-field.stderr | 13 + ...ves-based-on-type-capture-clause-bad.nll.stderr | 16 + .../moves-based-on-type-capture-clause-bad.rs | 19 + .../moves-based-on-type-capture-clause-bad.stderr | 14 + ...ased-on-type-cyclic-types-issue-4821.nll.stderr | 14 + .../moves-based-on-type-cyclic-types-issue-4821.rs | 30 + ...es-based-on-type-cyclic-types-issue-4821.stderr | 14 + ...d-on-type-distribute-copy-over-paren.nll.stderr | 25 + ...ves-based-on-type-distribute-copy-over-paren.rs | 59 ++ ...based-on-type-distribute-copy-over-paren.stderr | 25 + .../moves-based-on-type-exprs.nll.stderr | 118 ++++ .../moves-based-on-type-exprs.rs | 103 +++ .../moves-based-on-type-exprs.stderr | 118 ++++ ...e-move-out-of-closure-env-issue-1965.nll.stderr | 9 + ...d-on-type-move-out-of-closure-env-issue-1965.rs | 22 + ...-type-move-out-of-closure-env-issue-1965.stderr | 11 + ...d-on-type-no-recursive-stack-closure.nll.stderr | 24 + ...ves-based-on-type-no-recursive-stack-closure.rs | 45 ++ ...based-on-type-no-recursive-stack-closure.stderr | 23 + .../moves-sru-moved-field.nll.stderr | 13 + .../moves-sru-moved-field.rs | 33 + .../moves-sru-moved-field.stderr | 13 + .../ui/compile-fail-migration/multiple-main-2.rs | 19 + .../compile-fail-migration/multiple-main-2.stderr | 14 + .../ui/compile-fail-migration/multiple-main-3.rs | 21 + .../compile-fail-migration/multiple-main-3.stderr | 14 + .../multiple-plugin-registrars.rs | 22 + .../multiple-plugin-registrars.stderr | 15 + .../ui/compile-fail-migration/mut-cant-alias.rs | 18 + .../compile-fail-migration/mut-cant-alias.stderr | 13 + .../compile-fail-migration/mut-cross-borrowing.rs | 18 + .../mut-cross-borrowing.stderr | 15 + .../mut-pattern-internal-mutability.ast.nll.stderr | 26 + .../mut-pattern-internal-mutability.ast.stderr | 20 + .../mut-pattern-internal-mutability.mir.stderr | 26 + .../mut-pattern-internal-mutability.rs | 30 + .../mut-pattern-mismatched.rs | 30 + .../mut-pattern-mismatched.stderr | 21 + .../mut-suggestion.nll.stderr | 21 + .../ui/compile-fail-migration/mut-suggestion.rs | 32 + .../compile-fail-migration/mut-suggestion.stderr | 21 + .../mutable-class-fields-2.nll.stderr | 11 + .../mutable-class-fields-2.rs | 34 + .../mutable-class-fields-2.stderr | 11 + .../mutable-class-fields.ast.nll.stderr | 14 + .../mutable-class-fields.ast.stderr | 11 + .../mutable-class-fields.mir.stderr | 14 + .../compile-fail-migration/mutable-class-fields.rs | 30 + .../mutable-enum-indirect.rs | 29 + .../mutable-enum-indirect.stderr | 18 + .../ui/compile-fail-migration/mutexguard-sync.rs | 23 + .../compile-fail-migration/mutexguard-sync.stderr | 17 + .../ui/compile-fail-migration/namespace-mix.rs | 165 +++++ .../ui/compile-fail-migration/namespace-mix.stderr | 594 +++++++++++++++++ .../namespaced-enum-glob-import-no-impls-xcrate.rs | 25 + ...espaced-enum-glob-import-no-impls-xcrate.stderr | 27 + .../namespaced-enum-glob-import-no-impls.rs | 35 + .../namespaced-enum-glob-import-no-impls.stderr | 27 + .../ui/compile-fail-migration/nested-cfg-attrs.rs | 14 + .../compile-fail-migration/nested-cfg-attrs.stderr | 9 + .../ui/compile-fail-migration/nested-ty-params.rs | 16 + .../compile-fail-migration/nested-ty-params.stderr | 28 + .../never-assign-dead-code.rs | 22 + .../never-assign-dead-code.stderr | 44 ++ .../never-assign-wrong-type.rs | 18 + .../never-assign-wrong-type.stderr | 12 + .../never_transmute_never.rs | 33 + .../nll/constant-thread-locals-issue-47053.rs | 21 + .../nll/constant-thread-locals-issue-47053.stderr | 9 + .../nll/do-not-ignore-lifetime-bounds-in-copy.rs | 23 + .../do-not-ignore-lifetime-bounds-in-copy.stderr | 14 + .../nll/loan_ends_mid_block_pair.rs | 50 ++ .../nll/loan_ends_mid_block_pair.stderr | 93 +++ .../nll/loan_ends_mid_block_vec.rs | 49 ++ .../nll/loan_ends_mid_block_vec.stderr | 111 ++++ .../nll/match-guards-always-borrow.ast.nll.stderr | 9 + .../nll/match-guards-always-borrow.ast.stderr | 12 + .../nll/match-guards-always-borrow.mir.stderr | 9 + .../nll/match-guards-always-borrow.rs | 61 ++ ...nce-carried-through-struct-field.ast.nll.stderr | 14 + ...ference-carried-through-struct-field.ast.stderr | 11 + ...ference-carried-through-struct-field.mir.stderr | 14 + .../nll/reference-carried-through-struct-field.rs | 26 + .../nll/region-ends-after-if-condition.nll.stderr | 39 ++ .../nll/region-ends-after-if-condition.rs | 46 ++ .../nll/region-ends-after-if-condition.stderr | 39 ++ .../compile-fail-migration/nll/return_from_loop.rs | 49 ++ .../nll/return_from_loop.stderr | 39 ++ .../nll/unused-mut-issue-50343.rs | 17 + .../nll/unused-mut-issue-50343.stderr | 16 + .../nll/where_clauses_in_functions.rs | 28 + .../nll/where_clauses_in_functions.stderr | 18 + .../nll/where_clauses_in_structs.rs | 28 + .../nll/where_clauses_in_structs.stderr | 18 + .../no-capture-arc.nll.stderr | 29 + .../ui/compile-fail-migration/no-capture-arc.rs | 27 + .../compile-fail-migration/no-capture-arc.stderr | 25 + .../no-implicit-prelude-nested.rs | 64 ++ .../no-implicit-prelude-nested.stderr | 196 ++++++ .../compile-fail-migration/no-implicit-prelude.rs | 28 + .../no-implicit-prelude.stderr | 68 ++ src/test/ui/compile-fail-migration/no-link.rs | 19 + src/test/ui/compile-fail-migration/no-link.stderr | 15 + .../no-patterns-in-args-2.rs | 23 + .../no-patterns-in-args-2.stderr | 23 + .../no-patterns-in-args-macro.rs | 36 + .../no-patterns-in-args-macro.stderr | 22 + .../no-reuse-move-arc.nll.stderr | 29 + .../ui/compile-fail-migration/no-reuse-move-arc.rs | 25 + .../no-reuse-move-arc.stderr | 25 + .../ui/compile-fail-migration/no-send-res-ports.rs | 40 ++ .../no-send-res-ports.stderr | 15 + .../ui/compile-fail-migration/no-std-inject.rs | 17 + .../ui/compile-fail-migration/no-std-inject.stderr | 15 + .../compile-fail-migration/no-type-for-node-ice.rs | 15 + .../no-type-for-node-ice.stderr | 9 + .../no-warn-on-field-replace-issue-34101.rs | 56 ++ .../no-warn-on-field-replace-issue-34101.stderr | 11 + .../ui/compile-fail-migration/no_crate_type.rs | 16 + .../ui/compile-fail-migration/no_crate_type.stderr | 10 + .../no_owned_box_lang_item.rs | 24 + .../no_owned_box_lang_item.stderr | 4 + src/test/ui/compile-fail-migration/no_send-enum.rs | 28 + .../ui/compile-fail-migration/no_send-enum.stderr | 17 + src/test/ui/compile-fail-migration/no_send-rc.rs | 19 + .../ui/compile-fail-migration/no_send-rc.stderr | 16 + .../ui/compile-fail-migration/no_send-struct.rs | 27 + .../compile-fail-migration/no_send-struct.stderr | 16 + .../ui/compile-fail-migration/no_share-enum.rs | 26 + .../ui/compile-fail-migration/no_share-enum.stderr | 17 + .../ui/compile-fail-migration/no_share-struct.rs | 24 + .../compile-fail-migration/no_share-struct.stderr | 16 + .../ui/compile-fail-migration/noexporttypeexe.rs | 25 + .../compile-fail-migration/noexporttypeexe.stderr | 12 + .../nolink-with-link-args.nll.stderr | 9 + .../nolink-with-link-args.rs | 23 + .../nolink-with-link-args.stderr | 9 + .../non-constant-in-const-path.rs | 17 + .../non-constant-in-const-path.stderr | 9 + .../ui/compile-fail-migration/non-copyable-void.rs | 24 + .../non-copyable-void.stderr | 9 + .../non-exhaustive-match-nested.rs | 31 + .../non-exhaustive-match-nested.stderr | 15 + .../compile-fail-migration/non-exhaustive-match.rs | 73 +++ .../non-exhaustive-match.stderr | 51 ++ .../compile-fail-migration/non-interger-atomic.rs | 100 +++ .../non-interger-atomic.stderr | 99 +++ .../ui/compile-fail-migration/noncopyable-class.rs | 46 ++ .../noncopyable-class.stderr | 16 + .../ui/compile-fail-migration/nonscalar-cast.rs | 18 + .../compile-fail-migration/nonscalar-cast.stderr | 11 + .../ui/compile-fail-migration/not-clone-closure.rs | 22 + .../not-clone-closure.stderr | 11 + .../not-copy-closure.nll.stderr | 11 + .../ui/compile-fail-migration/not-copy-closure.rs | 21 + .../compile-fail-migration/not-copy-closure.stderr | 17 + .../ui/compile-fail-migration/not-panic-safe-2.rs | 23 + .../compile-fail-migration/not-panic-safe-2.stderr | 34 + .../ui/compile-fail-migration/not-panic-safe-3.rs | 23 + .../compile-fail-migration/not-panic-safe-3.stderr | 34 + .../ui/compile-fail-migration/not-panic-safe-4.rs | 22 + .../compile-fail-migration/not-panic-safe-4.stderr | 34 + .../ui/compile-fail-migration/not-panic-safe-5.rs | 20 + .../compile-fail-migration/not-panic-safe-5.stderr | 17 + .../ui/compile-fail-migration/not-panic-safe-6.rs | 22 + .../compile-fail-migration/not-panic-safe-6.stderr | 34 + .../ui/compile-fail-migration/not-panic-safe.rs | 21 + .../compile-fail-migration/not-panic-safe.stderr | 16 + src/test/ui/compile-fail-migration/not-sync.rs | 32 + src/test/ui/compile-fail-migration/not-sync.stderr | 81 +++ src/test/ui/compile-fail-migration/not-utf8.bin | Bin 0 -> 3036 bytes src/test/ui/compile-fail-migration/not-utf8.rs | 15 + src/test/ui/compile-fail-migration/not-utf8.stderr | 8 + .../object-does-not-impl-trait.rs | 18 + .../object-does-not-impl-trait.stderr | 15 + .../object-lifetime-default-ambiguous.rs | 58 ++ .../object-lifetime-default-ambiguous.stderr | 21 + .../object-lifetime-default-elision.nll.stderr | 24 + .../object-lifetime-default-elision.rs | 87 +++ .../object-lifetime-default-elision.stderr | 53 ++ ...ject-lifetime-default-from-box-error.nll.stderr | 45 ++ .../object-lifetime-default-from-box-error.rs | 45 ++ .../object-lifetime-default-from-box-error.stderr | 21 + ...lifetime-default-from-rptr-box-error.nll.stderr | 16 + .../object-lifetime-default-from-rptr-box-error.rs | 29 + ...ect-lifetime-default-from-rptr-box-error.stderr | 18 + ...etime-default-from-rptr-struct-error.nll.stderr | 16 + ...ject-lifetime-default-from-rptr-struct-error.rs | 35 + ...-lifetime-default-from-rptr-struct-error.stderr | 18 + .../object-lifetime-default-mybox.nll.stderr | 33 + .../object-lifetime-default-mybox.rs | 45 ++ .../object-lifetime-default-mybox.stderr | 31 + .../object-lifetime-default.rs | 34 + .../object-lifetime-default.stderr | 44 ++ .../compile-fail-migration/object-pointer-types.rs | 41 ++ .../object-pointer-types.stderr | 29 + .../object-safety-by-value-self-use.nll.stderr | 9 + .../object-safety-by-value-self-use.rs | 28 + .../object-safety-by-value-self-use.stderr | 9 + .../object-safety-by-value-self.rs | 56 ++ .../object-safety-by-value-self.stderr | 9 + .../object-safety-issue-22040.rs | 52 ++ .../object-safety-issue-22040.stderr | 11 + .../object-safety-no-static.rs | 24 + .../object-safety-no-static.stderr | 11 + .../object-safety-phantom-fn.rs | 32 + .../object-safety-phantom-fn.stderr | 9 + .../object-safety-sized-2.rs | 26 + .../object-safety-sized-2.stderr | 11 + .../ui/compile-fail-migration/occurs-check-2.rs | 20 + .../compile-fail-migration/occurs-check-2.stderr | 12 + .../ui/compile-fail-migration/occurs-check-3.rs | 14 + .../compile-fail-migration/occurs-check-3.stderr | 9 + src/test/ui/compile-fail-migration/occurs-check.rs | 18 + .../ui/compile-fail-migration/occurs-check.stderr | 12 + .../old-suffixes-are-really-forbidden.rs | 14 + .../old-suffixes-are-really-forbidden.stderr | 18 + .../once-cant-call-twice-on-heap.rs | 28 + .../once-cant-call-twice-on-heap.stderr | 13 + src/test/ui/compile-fail-migration/opt-in-copy.rs | 32 + .../ui/compile-fail-migration/opt-in-copy.stderr | 21 + .../compile-fail-migration/or-patter-mismatch.rs | 15 + .../or-patter-mismatch.stderr | 12 + .../orphan-check-diagnostics.rs | 23 + .../orphan-check-diagnostics.stderr | 11 + .../ui/compile-fail-migration/osx-frameworks.rs | 18 + .../compile-fail-migration/osx-frameworks.stderr | 9 + .../out-of-order-shadowing.rs | 21 + .../out-of-order-shadowing.stderr | 11 + .../compile-fail-migration/output-type-mismatch.rs | 15 + .../output-type-mismatch.stderr | 12 + .../compile-fail-migration/overlap-marker-trait.rs | 41 ++ .../overlap-marker-trait.stderr | 15 + .../overloaded-calls-nontuple.rs | 37 ++ .../overloaded-calls-nontuple.stderr | 9 + .../packed-struct-generic-transmute.rs | 37 ++ .../packed-struct-generic-transmute.stderr | 12 + .../packed-struct-transmute.rs | 38 ++ .../packed-struct-transmute.stderr | 12 + .../panic-implementation-bad-signature-1.rs | 24 + .../panic-implementation-bad-signature-1.stderr | 14 + .../panic-implementation-bad-signature-2.rs | 25 + .../panic-implementation-bad-signature-2.stderr | 8 + .../panic-implementation-bad-signature-3.rs | 22 + .../panic-implementation-bad-signature-3.stderr | 10 + .../panic-implementation-bad-signature-4.rs | 23 + .../panic-implementation-bad-signature-4.stderr | 11 + .../panic-implementation-duplicate.rs | 28 + .../panic-implementation-duplicate.stderr | 19 + .../panic-implementation-missing.rs | 18 + .../panic-implementation-missing.stderr | 4 + .../panic-implementation-requires-panic-info.rs | 26 + ...panic-implementation-requires-panic-info.stderr | 4 + .../panic-implementation-std.rs | 22 + .../panic-implementation-std.stderr | 13 + .../panic-implementation-twice.rs | 29 + .../panic-implementation-twice.stderr | 14 + .../panic-runtime/abort-link-to-unwind-dylib.rs | 26 + .../abort-link-to-unwind-dylib.stderr | 4 + .../panic-runtime/auxiliary/depends.rs | 18 + .../panic-runtime/auxiliary/needs-panic-runtime.rs | 16 + .../panic-runtime/auxiliary/panic-runtime-abort.rs | 27 + .../auxiliary/panic-runtime-lang-items.rs | 25 + .../auxiliary/panic-runtime-unwind.rs | 27 + .../auxiliary/panic-runtime-unwind2.rs | 27 + .../auxiliary/wants-panic-runtime-abort.rs | 17 + .../auxiliary/wants-panic-runtime-unwind.rs | 16 + .../panic-runtime/bad-panic-flag1.rs | 14 + .../panic-runtime/bad-panic-flag1.stderr | 2 + .../panic-runtime/bad-panic-flag2.rs | 14 + .../panic-runtime/bad-panic-flag2.stderr | 2 + .../panic-runtime/libtest-unwinds.rs | 21 + .../panic-runtime/libtest-unwinds.stderr | 4 + .../panic-runtime/needs-gate.rs | 17 + .../panic-runtime/needs-gate.stderr | 19 + .../runtime-depend-on-needs-runtime.rs | 15 + .../runtime-depend-on-needs-runtime.stderr | 9 + .../panic-runtime/transitive-link-a-bunch.rs | 25 + .../panic-runtime/transitive-link-a-bunch.stderr | 10 + .../panic-runtime/two-panic-runtimes.rs | 23 + .../panic-runtime/two-panic-runtimes.stderr | 4 + .../panic-runtime/want-abort-got-unwind.rs | 17 + .../panic-runtime/want-abort-got-unwind.stderr | 6 + .../panic-runtime/want-abort-got-unwind2.rs | 18 + .../panic-runtime/want-abort-got-unwind2.stderr | 6 + .../panic-runtime/want-unwind-got-abort.rs | 21 + .../panic-runtime/want-unwind-got-abort.stderr | 6 + .../panic-runtime/want-unwind-got-abort2.rs | 22 + .../panic-runtime/want-unwind-got-abort2.stderr | 8 + .../panic_implementation-closures.rs | 21 + src/test/ui/compile-fail-migration/paren-span.rs | 31 + .../ui/compile-fail-migration/paren-span.stderr | 9 + .../compile-fail-migration/parse-error-correct.rs | 22 + .../parse-error-correct.stderr | 31 + .../ui/compile-fail-migration/parser-recovery-1.rs | 24 + .../parser-recovery-1.stderr | 38 ++ .../ui/compile-fail-migration/parser-recovery-2.rs | 24 + .../parser-recovery-2.stderr | 33 + .../pat-shadow-in-nested-binding.rs | 15 + .../pat-shadow-in-nested-binding.stderr | 12 + .../compile-fail-migration/pat-tuple-bad-type.rs | 25 + .../pat-tuple-bad-type.stderr | 24 + .../compile-fail-migration/pat-tuple-overfield.rs | 26 + .../pat-tuple-overfield.stderr | 34 + .../patkind-litrange-no-expr.rs | 34 + .../patkind-litrange-no-expr.stderr | 18 + .../pattern-binding-disambiguation.rs | 67 ++ .../pattern-binding-disambiguation.stderr | 75 +++ .../pattern-bindings-after-at.rs | 25 + .../pattern-bindings-after-at.stderr | 9 + .../pattern-error-continue.rs | 47 ++ .../pattern-error-continue.stderr | 39 ++ .../pattern-ident-path-generics.rs | 16 + .../pattern-ident-path-generics.stderr | 12 + .../ui/compile-fail-migration/pattern-tyvar-2.rs | 17 + .../compile-fail-migration/pattern-tyvar-2.stderr | 11 + .../ui/compile-fail-migration/pattern-tyvar.rs | 24 + .../ui/compile-fail-migration/pattern-tyvar.stderr | 12 + .../ui/compile-fail-migration/phantom-oibit.rs | 40 ++ .../ui/compile-fail-migration/phantom-oibit.stderr | 38 ++ .../platform-intrinsic-params.rs | 16 + .../platform-intrinsic-params.stderr | 9 + src/test/ui/compile-fail-migration/pptypedef.rs | 21 + .../ui/compile-fail-migration/pptypedef.stderr | 15 + .../ui/compile-fail-migration/prim-with-args.rs | 37 ++ .../compile-fail-migration/prim-with-args.stderr | 136 ++++ .../priv-in-bad-locations.rs | 27 + .../priv-in-bad-locations.stderr | 31 + .../ui/compile-fail-migration/privacy-in-paths.rs | 40 ++ .../compile-fail-migration/privacy-in-paths.stderr | 21 + src/test/ui/compile-fail-migration/privacy-ns1.rs | 65 ++ .../ui/compile-fail-migration/privacy-ns1.stderr | 60 ++ src/test/ui/compile-fail-migration/privacy-ns2.rs | 88 +++ .../ui/compile-fail-migration/privacy-ns2.stderr | 78 +++ .../ui/compile-fail-migration/privacy-sanity.rs | 92 +++ .../compile-fail-migration/privacy-sanity.stderr | 123 ++++ src/test/ui/compile-fail-migration/privacy-ufcs.rs | 23 + .../ui/compile-fail-migration/privacy-ufcs.stderr | 9 + .../privacy/associated-item-privacy-inherent.rs | 122 ++++ .../associated-item-privacy-inherent.stderr | 191 ++++++ .../privacy/associated-item-privacy-trait.rs | 151 +++++ .../privacy/associated-item-privacy-trait.stderr | 317 +++++++++ .../associated-item-privacy-type-binding.rs | 74 +++ .../associated-item-privacy-type-binding.stderr | 146 +++++ .../privacy/legacy-ctor-visibility.rs | 30 + .../privacy/legacy-ctor-visibility.stderr | 12 + .../privacy/restricted/auxiliary/pub_restricted.rs | 26 + .../privacy/restricted/lookup-ignores-private.rs | 44 ++ .../restricted/lookup-ignores-private.stderr | 12 + .../privacy/restricted/private-in-public.rs | 23 + .../privacy/restricted/private-in-public.stderr | 21 + .../privacy/restricted/struct-literal-field.rs | 29 + .../privacy/restricted/struct-literal-field.stderr | 9 + .../privacy/restricted/test.rs | 62 ++ .../privacy/restricted/test.stderr | 82 +++ .../privacy/union-field-privacy-1.rs | 27 + .../privacy/union-field-privacy-1.stderr | 15 + .../privacy/union-field-privacy-2.rs | 25 + .../privacy/union-field-privacy-2.stderr | 9 + src/test/ui/compile-fail-migration/privacy1.rs | 172 +++++ src/test/ui/compile-fail-migration/privacy1.stderr | 112 ++++ src/test/ui/compile-fail-migration/privacy2.rs | 37 ++ src/test/ui/compile-fail-migration/privacy2.stderr | 18 + src/test/ui/compile-fail-migration/privacy3.rs | 37 ++ src/test/ui/compile-fail-migration/privacy3.stderr | 11 + src/test/ui/compile-fail-migration/privacy4.rs | 35 + src/test/ui/compile-fail-migration/privacy4.stderr | 9 + src/test/ui/compile-fail-migration/privacy5.rs | 138 ++++ src/test/ui/compile-fail-migration/privacy5.stderr | 291 ++++++++ .../compile-fail-migration/private-impl-method.rs | 31 + .../private-impl-method.stderr | 9 + .../private-in-public-assoc-ty.rs | 43 ++ .../private-in-public-assoc-ty.stderr | 52 ++ .../private-in-public-ill-formed.rs | 45 ++ .../private-in-public-ill-formed.stderr | 19 + .../private-in-public-lint.rs | 29 + .../private-in-public-lint.stderr | 21 + .../private-in-public-warn.rs | 282 ++++++++ .../private-in-public-warn.stderr | 329 ++++++++++ .../ui/compile-fail-migration/private-in-public.rs | 158 +++++ .../private-in-public.stderr | 268 ++++++++ .../private-inferred-type-1.rs | 28 + .../private-inferred-type-1.stderr | 14 + .../private-inferred-type-2.rs | 29 + .../private-inferred-type-2.stderr | 20 + .../private-inferred-type-3.rs | 27 + .../private-inferred-type-3.stderr | 58 ++ .../private-inferred-type.rs | 143 ++++ .../private-inferred-type.stderr | 225 +++++++ .../compile-fail-migration/private-item-simple.rs | 17 + .../private-item-simple.stderr | 9 + .../private-method-cross-crate.rs | 18 + .../private-method-cross-crate.stderr | 9 + .../private-method-inherited.rs | 24 + .../private-method-inherited.stderr | 9 + .../ui/compile-fail-migration/private-method.rs | 35 + .../compile-fail-migration/private-method.stderr | 9 + .../private-struct-field-cross-crate.rs | 19 + .../private-struct-field-cross-crate.stderr | 9 + .../private-struct-field-ctor.rs | 19 + .../private-struct-field-ctor.stderr | 9 + .../private-struct-field-pattern.rs | 27 + .../private-struct-field-pattern.stderr | 9 + .../compile-fail-migration/private-struct-field.rs | 24 + .../private-struct-field.stderr | 9 + .../private-type-in-interface.rs | 42 ++ .../private-type-in-interface.stderr | 68 ++ .../private-variant-reexport.rs | 29 + .../private-variant-reexport.stderr | 29 + src/test/ui/compile-fail-migration/ptr-coercion.rs | 33 + .../ui/compile-fail-migration/ptr-coercion.stderr | 30 + .../pub-reexport-priv-extern-crate.rs | 34 + .../pub-reexport-priv-extern-crate.stderr | 30 + .../qualified-path-params.rs | 34 + .../qualified-path-params.stderr | 19 + .../question-mark-type-infer.rs | 27 + .../question-mark-type-infer.stderr | 9 + .../quote-with-interpolated.rs | 19 + .../quote-with-interpolated.stderr | 11 + src/test/ui/compile-fail-migration/range-1.rs | 26 + src/test/ui/compile-fail-migration/range-1.stderr | 28 + .../ui/compile-fail-migration/range_traits-1.rs | 35 + .../compile-fail-migration/range_traits-1.stderr | 105 +++ .../ui/compile-fail-migration/range_traits-2.rs | 17 + .../compile-fail-migration/range_traits-2.stderr | 11 + .../ui/compile-fail-migration/range_traits-3.rs | 17 + .../compile-fail-migration/range_traits-3.stderr | 11 + .../ui/compile-fail-migration/range_traits-4.rs | 20 + .../compile-fail-migration/range_traits-4.stderr | 8 + .../ui/compile-fail-migration/range_traits-5.rs | 20 + .../compile-fail-migration/range_traits-5.stderr | 8 + .../ui/compile-fail-migration/range_traits-6.rs | 17 + .../compile-fail-migration/range_traits-6.stderr | 11 + .../ui/compile-fail-migration/range_traits-7.rs | 20 + .../compile-fail-migration/range_traits-7.stderr | 8 + src/test/ui/compile-fail-migration/recursion.rs | 32 + .../ui/compile-fail-migration/recursion.stderr | 14 + .../ui/compile-fail-migration/recursive-enum.rs | 14 + .../compile-fail-migration/recursive-enum.stderr | 13 + .../compile-fail-migration/recursive-reexports.rs | 17 + .../recursive-reexports.stderr | 9 + .../recursive-static-definition.rs | 14 + .../recursive-static-definition.stderr | 11 + .../recursive-types-are-not-uninhabited.rs | 24 + .../recursive-types-are-not-uninhabited.stderr | 9 + .../ref-suggestion.nll.stderr | 34 + .../ui/compile-fail-migration/ref-suggestion.rs | 27 + .../compile-fail-migration/ref-suggestion.stderr | 34 + .../refutable-pattern-errors.rs | 18 + .../refutable-pattern-errors.stderr | 15 + .../refutable-pattern-in-fn-arg.rs | 15 + .../refutable-pattern-in-fn-arg.stderr | 9 + ...on-borrow-params-issue-29793-big.ast.nll.stderr | 25 + ...region-borrow-params-issue-29793-big.ast.stderr | 29 + ...region-borrow-params-issue-29793-big.mir.stderr | 25 + .../region-borrow-params-issue-29793-big.rs | 90 +++ .../region-bound-extra-bound-in-inherent-impl.rs | 26 + ...egion-bound-extra-bound-in-inherent-impl.stderr | 8 + ...egion-bound-on-closure-outlives-call.nll.stderr | 14 + .../region-bound-on-closure-outlives-call.rs | 15 + .../region-bound-on-closure-outlives-call.stderr | 11 + .../region-bound-same-bounds-in-trait-and-impl.rs | 27 + ...gion-bound-same-bounds-in-trait-and-impl.stderr | 8 + ...region-bounds-on-objects-and-type-parameters.rs | 46 ++ ...on-bounds-on-objects-and-type-parameters.stderr | 35 + ...ion-invariant-static-error-reporting.nll.stderr | 22 + .../region-invariant-static-error-reporting.rs | 32 + .../region-invariant-static-error-reporting.stderr | 23 + ...-lifetime-bounds-on-fns-where-clause.nll.stderr | 24 + .../region-lifetime-bounds-on-fns-where-clause.rs | 39 ++ ...gion-lifetime-bounds-on-fns-where-clause.stderr | 31 + ...-lifetime-bounds-on-fns-where-clause.nll.stderr | 30 + ...multiple-lifetime-bounds-on-fns-where-clause.rs | 41 ++ ...iple-lifetime-bounds-on-fns-where-clause.stderr | 42 ++ .../region-object-lifetime-1.rs | 28 + .../region-object-lifetime-1.stderr | 8 + .../region-object-lifetime-2.nll.stderr | 16 + .../region-object-lifetime-2.rs | 23 + .../region-object-lifetime-2.stderr | 30 + .../region-object-lifetime-3.rs | 28 + .../region-object-lifetime-3.stderr | 8 + .../region-object-lifetime-4.nll.stderr | 18 + .../region-object-lifetime-4.rs | 25 + .../region-object-lifetime-4.stderr | 30 + .../region-object-lifetime-5.nll.stderr | 13 + .../region-object-lifetime-5.rs | 24 + .../region-object-lifetime-5.stderr | 13 + .../region-object-lifetime-in-coercion.nll.stderr | 74 +++ .../region-object-lifetime-in-coercion.rs | 44 ++ .../region-object-lifetime-in-coercion.stderr | 52 ++ .../regions-addr-of-arg.nll.stderr | 27 + .../compile-fail-migration/regions-addr-of-arg.rs | 27 + .../regions-addr-of-arg.stderr | 27 + .../regions-addr-of-self.nll.stderr | 16 + .../compile-fail-migration/regions-addr-of-self.rs | 37 ++ .../regions-addr-of-self.stderr | 29 + .../regions-addr-of-upvar-self.nll.stderr | 41 ++ .../regions-addr-of-upvar-self.rs | 27 + .../regions-addr-of-upvar-self.stderr | 26 + .../regions-adjusted-lvalue-op.nll.stderr | 23 + .../regions-adjusted-lvalue-op.rs | 26 + .../regions-adjusted-lvalue-op.stderr | 21 + ...-assoc-type-in-supertrait-outlives-container.rs | 54 ++ ...oc-type-in-supertrait-outlives-container.stderr | 20 + ...ons-assoc-type-region-bound-in-trait-not-met.rs | 34 + ...assoc-type-region-bound-in-trait-not-met.stderr | 49 ++ ...ons-assoc-type-static-bound-in-trait-not-met.rs | 29 + ...assoc-type-static-bound-in-trait-not-met.stderr | 24 + .../regions-bounded-by-trait-requiring-static.rs | 73 +++ ...egions-bounded-by-trait-requiring-static.stderr | 51 ++ ...d-method-type-parameters-cross-crate.nll.stderr | 19 + ...s-bounded-method-type-parameters-cross-crate.rs | 33 + ...unded-method-type-parameters-cross-crate.stderr | 12 + ...d-method-type-parameters-trait-bound.nll.stderr | 19 + ...s-bounded-method-type-parameters-trait-bound.rs | 38 ++ ...unded-method-type-parameters-trait-bound.stderr | 12 + .../regions-bounded-method-type-parameters.rs | 26 + .../regions-bounded-method-type-parameters.stderr | 11 + .../regions-bounds.nll.stderr | 34 + .../ui/compile-fail-migration/regions-bounds.rs | 26 + .../compile-fail-migration/regions-bounds.stderr | 41 ++ ...ns-close-associated-type-into-object.nll.stderr | 60 ++ .../regions-close-associated-type-into-object.rs | 81 +++ ...egions-close-associated-type-into-object.stderr | 56 ++ .../regions-close-object-into-object-1.nll.stderr | 13 + .../regions-close-object-into-object-1.rs | 25 + .../regions-close-object-into-object-1.stderr | 13 + .../regions-close-object-into-object-2.nll.stderr | 30 + .../regions-close-object-into-object-2.rs | 23 + .../regions-close-object-into-object-2.stderr | 24 + .../regions-close-object-into-object-3.nll.stderr | 13 + .../regions-close-object-into-object-3.rs | 24 + .../regions-close-object-into-object-3.stderr | 13 + .../regions-close-object-into-object-4.nll.stderr | 71 ++ .../regions-close-object-into-object-4.rs | 23 + .../regions-close-object-into-object-4.stderr | 24 + .../regions-close-object-into-object-5.nll.stderr | 61 ++ .../regions-close-object-into-object-5.rs | 36 + .../regions-close-object-into-object-5.stderr | 93 +++ .../regions-close-over-type-parameter-1.nll.stderr | 44 ++ .../regions-close-over-type-parameter-1.rs | 35 + .../regions-close-over-type-parameter-1.stderr | 60 ++ ...s-close-over-type-parameter-multiple.nll.stderr | 17 + .../regions-close-over-type-parameter-multiple.rs | 34 + ...gions-close-over-type-parameter-multiple.stderr | 28 + .../regions-close-param-into-object.nll.stderr | 60 ++ .../regions-close-param-into-object.rs | 37 ++ .../regions-close-param-into-object.stderr | 64 ++ .../regions-creating-enums.nll.stderr | 31 + .../regions-creating-enums.rs | 43 ++ .../regions-creating-enums.stderr | 33 + .../regions-creating-enums3.nll.stderr | 18 + .../regions-creating-enums3.rs | 21 + .../regions-creating-enums3.stderr | 13 + .../regions-creating-enums4.nll.stderr | 18 + .../regions-creating-enums4.rs | 21 + .../regions-creating-enums4.stderr | 26 + .../regions-early-bound-error-method.nll.stderr | 18 + .../regions-early-bound-error-method.rs | 36 + .../regions-early-bound-error-method.stderr | 20 + .../regions-early-bound-error.nll.stderr | 18 + .../regions-early-bound-error.rs | 34 + .../regions-early-bound-error.stderr | 20 + .../compile-fail-migration/regions-enum-not-wf.rs | 38 ++ .../regions-enum-not-wf.stderr | 64 ++ .../regions-escape-method.nll.stderr | 18 + .../regions-escape-method.rs | 26 + .../regions-escape-method.stderr | 28 + .../regions-escape-via-trait-or-not.nll.stderr | 18 + .../regions-escape-via-trait-or-not.rs | 32 + .../regions-escape-via-trait-or-not.stderr | 28 + .../regions-fn-subtyping-return-static.rs | 67 ++ .../regions-fn-subtyping-return-static.stderr | 21 + .../regions-free-region-ordering-callee-4.rs | 21 + .../regions-free-region-ordering-callee-4.stderr | 24 + .../regions-free-region-ordering-callee.nll.stderr | 36 + .../regions-free-region-ordering-callee.rs | 39 ++ .../regions-free-region-ordering-callee.stderr | 25 + .../regions-free-region-ordering-caller.rs | 30 + .../regions-free-region-ordering-caller.stderr | 32 + ...regions-free-region-ordering-caller1.nll.stderr | 18 + .../regions-free-region-ordering-caller1.rs | 24 + .../regions-free-region-ordering-caller1.stderr | 33 + ...gions-free-region-ordering-incorrect.nll.stderr | 21 + .../regions-free-region-ordering-incorrect.rs | 32 + .../regions-free-region-ordering-incorrect.stderr | 33 + .../regions-glb-free-free.nll.stderr | 18 + .../regions-glb-free-free.rs | 39 ++ .../regions-glb-free-free.stderr | 16 + .../regions-implied-bounds-projection-gap-1.rs | 40 ++ .../regions-implied-bounds-projection-gap-1.stderr | 18 + .../regions-implied-bounds-projection-gap-2.rs | 33 + .../regions-implied-bounds-projection-gap-2.stderr | 8 + .../regions-implied-bounds-projection-gap-3.rs | 33 + .../regions-implied-bounds-projection-gap-3.stderr | 8 + .../regions-implied-bounds-projection-gap-4.rs | 33 + .../regions-implied-bounds-projection-gap-4.stderr | 8 + .../regions-implied-bounds-projection-gap-hr-1.rs | 36 + ...gions-implied-bounds-projection-gap-hr-1.stderr | 23 + .../regions-in-enums-anon.rs | 17 + .../regions-in-enums-anon.stderr | 9 + .../ui/compile-fail-migration/regions-in-enums.rs | 30 + .../compile-fail-migration/regions-in-enums.stderr | 15 + .../regions-in-structs-anon.rs | 17 + .../regions-in-structs-anon.stderr | 9 + .../compile-fail-migration/regions-in-structs.rs | 25 + .../regions-in-structs.stderr | 15 + .../regions-infer-at-fn-not-param.nll.stderr | 17 + .../regions-infer-at-fn-not-param.rs | 29 + .../regions-infer-at-fn-not-param.stderr | 11 + .../regions-infer-borrow-scope-too-big.nll.stderr | 18 + .../regions-infer-borrow-scope-too-big.rs | 27 + .../regions-infer-borrow-scope-too-big.stderr | 18 + .../regions-infer-bound-from-trait-self.nll.stderr | 17 + .../regions-infer-bound-from-trait-self.rs | 61 ++ .../regions-infer-bound-from-trait-self.stderr | 16 + .../regions-infer-bound-from-trait.nll.stderr | 31 + .../regions-infer-bound-from-trait.rs | 50 ++ .../regions-infer-bound-from-trait.stderr | 31 + .../regions-infer-call-3.nll.stderr | 16 + .../compile-fail-migration/regions-infer-call-3.rs | 24 + .../regions-infer-call-3.stderr | 30 + .../regions-infer-contravariance-due-to-decl.rs | 38 ++ ...regions-infer-contravariance-due-to-decl.stderr | 15 + .../regions-infer-covariance-due-to-decl.rs | 35 + .../regions-infer-covariance-due-to-decl.stderr | 14 + ...regions-infer-invariance-due-to-decl.nll.stderr | 16 + .../regions-infer-invariance-due-to-decl.rs | 26 + .../regions-infer-invariance-due-to-decl.stderr | 18 + ...infer-invariance-due-to-mutability-3.nll.stderr | 16 + ...regions-infer-invariance-due-to-mutability-3.rs | 25 + ...ons-infer-invariance-due-to-mutability-3.stderr | 18 + ...infer-invariance-due-to-mutability-4.nll.stderr | 16 + ...regions-infer-invariance-due-to-mutability-4.rs | 25 + ...ons-infer-invariance-due-to-mutability-4.stderr | 18 + .../regions-infer-not-param.nll.stderr | 38 ++ .../regions-infer-not-param.rs | 36 + .../regions-infer-not-param.stderr | 60 ++ .../regions-infer-paramd-indirect.nll.stderr | 18 + .../regions-infer-paramd-indirect.rs | 41 ++ .../regions-infer-paramd-indirect.stderr | 28 + .../regions-infer-proc-static-upvar.nll.stderr | 14 + .../regions-infer-proc-static-upvar.rs | 34 + .../regions-infer-proc-static-upvar.stderr | 14 + .../regions-lifetime-bounds-on-fns.nll.stderr | 24 + .../regions-lifetime-bounds-on-fns.rs | 39 ++ .../regions-lifetime-bounds-on-fns.stderr | 31 + .../regions-lifetime-of-struct-or-enum-variant.rs | 36 + ...gions-lifetime-of-struct-or-enum-variant.stderr | 33 + .../regions-name-duplicated.rs | 15 + .../regions-name-duplicated.stderr | 11 + .../compile-fail-migration/regions-name-static.rs | 15 + .../regions-name-static.stderr | 9 + .../regions-name-undeclared.rs | 60 ++ .../regions-name-undeclared.stderr | 69 ++ .../regions-nested-fns.nll.stderr | 60 ++ .../compile-fail-migration/regions-nested-fns.rs | 30 + .../regions-nested-fns.stderr | 61 ++ .../regions-normalize-in-where-clause-list.rs | 37 ++ .../regions-normalize-in-where-clause-list.stderr | 26 + ...egions-outlives-nominal-type-enum-region-rev.rs | 29 + ...ns-outlives-nominal-type-enum-region-rev.stderr | 20 + .../regions-outlives-nominal-type-enum-region.rs | 29 + ...egions-outlives-nominal-type-enum-region.stderr | 20 + .../regions-outlives-nominal-type-enum-type-rev.rs | 29 + ...ions-outlives-nominal-type-enum-type-rev.stderr | 20 + .../regions-outlives-nominal-type-enum-type.rs | 29 + .../regions-outlives-nominal-type-enum-type.stderr | 20 + ...ions-outlives-nominal-type-struct-region-rev.rs | 29 + ...-outlives-nominal-type-struct-region-rev.stderr | 20 + .../regions-outlives-nominal-type-struct-region.rs | 29 + ...ions-outlives-nominal-type-struct-region.stderr | 20 + ...egions-outlives-nominal-type-struct-type-rev.rs | 29 + ...ns-outlives-nominal-type-struct-type-rev.stderr | 20 + .../regions-outlives-nominal-type-struct-type.rs | 29 + ...egions-outlives-nominal-type-struct-type.stderr | 20 + ...s-outlives-projection-container-hrtb.nll.stderr | 21 + .../regions-outlives-projection-container-hrtb.rs | 69 ++ ...gions-outlives-projection-container-hrtb.stderr | 37 ++ .../regions-outlives-projection-container-wc.rs | 49 ++ ...regions-outlives-projection-container-wc.stderr | 20 + .../regions-outlives-projection-container.rs | 86 +++ .../regions-outlives-projection-container.stderr | 71 ++ .../regions-outlives-projection-hrtype.rs | 36 + .../regions-outlives-projection-hrtype.stderr | 8 + .../regions-outlives-projection-trait-def.rs | 31 + .../regions-outlives-projection-trait-def.stderr | 8 + .../regions-outlives-scalar.rs | 23 + .../regions-outlives-scalar.stderr | 8 + .../regions-pattern-typing-issue-19552.nll.stderr | 14 + .../regions-pattern-typing-issue-19552.rs | 18 + .../regions-pattern-typing-issue-19552.stderr | 14 + ...gions-pattern-typing-issue-19997.ast.nll.stderr | 15 + .../regions-pattern-typing-issue-19997.ast.stderr | 12 + .../regions-pattern-typing-issue-19997.mir.stderr | 15 + .../regions-pattern-typing-issue-19997.rs | 25 + .../regions-proc-bound-capture.nll.stderr | 21 + .../regions-proc-bound-capture.rs | 22 + .../regions-proc-bound-capture.stderr | 12 + ...eborrow-from-shorter-mut-ref-mut-ref.nll.stderr | 20 + ...egions-reborrow-from-shorter-mut-ref-mut-ref.rs | 18 + ...ns-reborrow-from-shorter-mut-ref-mut-ref.stderr | 13 + ...egions-reborrow-from-shorter-mut-ref.nll.stderr | 20 + .../regions-reborrow-from-shorter-mut-ref.rs | 25 + .../regions-reborrow-from-shorter-mut-ref.stderr | 13 + .../regions-ref-in-fn-arg.nll.stderr | 22 + .../regions-ref-in-fn-arg.rs | 24 + .../regions-ref-in-fn-arg.stderr | 24 + .../regions-ret-borrowed-1.nll.stderr | 18 + .../regions-ret-borrowed-1.rs | 27 + .../regions-ret-borrowed-1.stderr | 28 + .../regions-ret-borrowed.nll.stderr | 18 + .../compile-fail-migration/regions-ret-borrowed.rs | 30 + .../regions-ret-borrowed.stderr | 28 + .../compile-fail-migration/regions-ret.nll.stderr | 19 + src/test/ui/compile-fail-migration/regions-ret.rs | 18 + .../ui/compile-fail-migration/regions-ret.stderr | 20 + ...ions-return-ref-to-upvar-issue-17403.nll.stderr | 18 + .../regions-return-ref-to-upvar-issue-17403.rs | 21 + .../regions-return-ref-to-upvar-issue-17403.stderr | 30 + .../regions-return-stack-allocated-vec.rs | 20 + .../regions-return-stack-allocated-vec.stderr | 13 + .../regions-static-bound.ll.nll.stderr | 46 ++ .../regions-static-bound.ll.stderr | 34 + .../regions-static-bound.nll.stderr | 46 ++ .../compile-fail-migration/regions-static-bound.rs | 33 + .../regions-steal-closure.nll.stderr | 15 + .../regions-steal-closure.rs | 27 + .../regions-steal-closure.stderr | 16 + .../regions-struct-not-wf.lexical.stderr | 49 ++ .../regions-struct-not-wf.nll.stderr | 49 ++ .../regions-struct-not-wf.rs | 40 ++ .../ui/compile-fail-migration/regions-trait-1.rs | 40 ++ .../compile-fail-migration/regions-trait-1.stderr | 24 + .../regions-trait-object-subtyping.nll.stderr | 39 ++ .../regions-trait-object-subtyping.rs | 35 + .../regions-trait-object-subtyping.stderr | 65 ++ .../regions-trait-variance.nll.stderr | 18 + .../regions-trait-variance.rs | 54 ++ .../regions-trait-variance.stderr | 18 + .../compile-fail-migration/regions-undeclared.rs | 23 + .../regions-undeclared.stderr | 33 + .../regions-var-type-out-of-scope.nll.stderr | 15 + .../regions-var-type-out-of-scope.rs | 24 + .../regions-var-type-out-of-scope.stderr | 16 + ...ntravariant-use-covariant-in-second-position.rs | 38 ++ ...variant-use-covariant-in-second-position.stderr | 14 + ...regions-variance-contravariant-use-covariant.rs | 36 + ...ons-variance-contravariant-use-covariant.stderr | 15 + ...regions-variance-covariant-use-contravariant.rs | 36 + ...ons-variance-covariant-use-contravariant.stderr | 14 + ...regions-variance-invariant-use-contravariant.rs | 33 + ...ons-variance-invariant-use-contravariant.stderr | 14 + .../regions-variance-invariant-use-covariant.rs | 30 + ...regions-variance-invariant-use-covariant.stderr | 18 + .../regions-wf-trait-object.rs | 20 + .../regions-wf-trait-object.stderr | 20 + .../reject-specialized-drops-8142.rs | 67 ++ .../reject-specialized-drops-8142.stderr | 115 ++++ .../repeat-to-run-dtor-twice.rs | 29 + .../repeat-to-run-dtor-twice.stderr | 11 + src/test/ui/compile-fail-migration/repeat_count.rs | 49 ++ .../ui/compile-fail-migration/repeat_count.stderr | 64 ++ src/test/ui/compile-fail-migration/repr-align.rs | 24 + .../ui/compile-fail-migration/repr-align.stderr | 21 + .../repr-packed-contains-align.rs | 59 ++ .../repr-packed-contains-align.stderr | 59 ++ .../repr-transparent-other-items.rs | 38 ++ .../repr-transparent-other-items.stderr | 73 +++ .../repr-transparent-other-reprs.rs | 28 + .../repr-transparent-other-reprs.stderr | 34 + .../ui/compile-fail-migration/repr-transparent.rs | 50 ++ .../compile-fail-migration/repr-transparent.stderr | 76 +++ .../compile-fail-migration/required-lang-item.rs | 19 + .../required-lang-item.stderr | 4 + .../reserved-attr-on-macro.rs | 18 + .../reserved-attr-on-macro.stderr | 11 + .../ui/compile-fail-migration/reserved-become.rs | 14 + .../compile-fail-migration/reserved-become.stderr | 8 + .../resolve-bad-import-prefix.rs | 24 + .../resolve-bad-import-prefix.stderr | 24 + .../resolve-bad-visibility.rs | 25 + .../resolve-bad-visibility.stderr | 34 + ...esolve-conflict-extern-crate-vs-extern-crate.rs | 15 + ...ve-conflict-extern-crate-vs-extern-crate.stderr | 15 + .../resolve-conflict-import-vs-extern-crate.rs | 14 + .../resolve-conflict-import-vs-extern-crate.stderr | 15 + .../resolve-conflict-import-vs-import.rs | 16 + .../resolve-conflict-import-vs-import.stderr | 17 + .../resolve-conflict-item-vs-extern-crate.rs | 15 + .../resolve-conflict-item-vs-extern-crate.stderr | 15 + .../resolve-conflict-type-vs-import.rs | 17 + .../resolve-conflict-type-vs-import.stderr | 18 + .../resolve-inconsistent-binding-mode.rs | 50 ++ .../resolve-inconsistent-binding-mode.stderr | 53 ++ .../ui/compile-fail-migration/resolve-label.rs | 23 + .../ui/compile-fail-migration/resolve-label.stderr | 9 + .../resolve-primitive-fallback.rs | 20 + .../resolve-primitive-fallback.stderr | 22 + .../resolve-self-in-impl-2.rs | 17 + .../resolve-self-in-impl-2.stderr | 16 + .../compile-fail-migration/resolve-self-in-impl.rs | 30 + .../resolve-self-in-impl.stderr | 43 ++ .../resolve-type-param-in-item-in-trait.rs | 45 ++ .../resolve-type-param-in-item-in-trait.stderr | 45 ++ .../resolve-unknown-trait.rs | 19 + .../resolve-unknown-trait.stderr | 26 + .../resolve-variant-assoc-item.rs | 17 + .../resolve-variant-assoc-item.stderr | 15 + .../resolve_self_super_hint.rs | 34 + .../resolve_self_super_hint.stderr | 32 + src/test/ui/compile-fail-migration/ret-non-nil.rs | 17 + .../ui/compile-fail-migration/ret-non-nil.stderr | 9 + src/test/ui/compile-fail-migration/retslot-cast.rs | 33 + .../ui/compile-fail-migration/retslot-cast.stderr | 12 + .../return-from-diverging.rs | 19 + .../return-from-diverging.stderr | 12 + .../return-unit-from-diverging.rs | 20 + .../return-unit-from-diverging.stderr | 9 + .../termination-trait-main-i32.rs | 16 + .../termination-trait-main-i32.stderr | 11 + .../termination-trait-not-satisfied.rs | 15 + .../termination-trait-not-satisfied.stderr | 11 + .../rfc-2008-non-exhaustive/auxiliary/enums.rs | 19 + .../rfc-2008-non-exhaustive/auxiliary/structs.rs | 37 ++ .../rfc-2008-non-exhaustive/auxiliary/variants.rs | 18 + .../rfc-2008-non-exhaustive/enum.rs | 25 + .../rfc-2008-non-exhaustive/enum.stderr | 9 + .../rfc-2008-non-exhaustive/invalid-attribute.rs | 28 + .../invalid-attribute.stderr | 34 + .../rfc-2008-non-exhaustive/structs.rs | 47 ++ .../rfc-2008-non-exhaustive/structs.stderr | 64 ++ .../rfc-2008-non-exhaustive/variants.rs | 36 + .../rfc-2008-non-exhaustive/variants_create.rs | 27 + .../rfc-2008-non-exhaustive/variants_create.stderr | 20 + .../crate-path-non-absolute.rs | 22 + .../crate-path-non-absolute.stderr | 9 + .../keyword-crate-as-identifier.rs | 15 + .../keyword-crate-as-identifier.stderr | 9 + .../auxiliary/xcrate.rs | 15 + .../non-existent-1.rs | 15 + .../non-existent-1.stderr | 9 + .../non-existent-2.rs | 15 + .../non-existent-2.stderr | 9 + .../non-existent-3.rs | 15 + .../non-existent-3.stderr | 9 + .../single-segment.rs | 20 + .../single-segment.stderr | 22 + .../rfc-2126-extern-in-paths/auxiliary/xcrate.rs | 15 + .../rfc-2126-extern-in-paths/non-existent-1.rs | 15 + .../rfc-2126-extern-in-paths/non-existent-1.stderr | 9 + .../rfc-2126-extern-in-paths/non-existent-2.rs | 15 + .../rfc-2126-extern-in-paths/non-existent-2.stderr | 9 + .../rfc-2126-extern-in-paths/non-existent-3.rs | 15 + .../rfc-2126-extern-in-paths/non-existent-3.stderr | 9 + .../rfc-2126-extern-in-paths/single-segment.rs | 22 + .../rfc-2126-extern-in-paths/single-segment.stderr | 22 + .../rfc1445/feature-gate.no_gate.stderr | 11 + .../compile-fail-migration/rfc1445/feature-gate.rs | 37 ++ .../rfc1445/feature-gate.with_gate.stderr | 14 + .../rfc1445/match-forbidden-without-eq.rs | 35 + .../rfc1445/match-forbidden-without-eq.stderr | 18 + .../match-requires-both-partialeq-and-eq.rs | 31 + .../match-requires-both-partialeq-and-eq.stderr | 8 + src/test/ui/compile-fail-migration/rfc1623.rs | 102 +++ src/test/ui/compile-fail-migration/rfc1623.stderr | 19 + .../rfc1717/missing-link-attr.rs | 14 + .../rfc1717/missing-link-attr.stderr | 4 + .../rfc1717/multiple-renames.rs | 17 + .../rfc1717/multiple-renames.stderr | 4 + .../rfc1717/rename-to-empty.rs | 17 + .../rfc1717/rename-to-empty.stderr | 4 + .../ui/compile-fail-migration/rmeta-lib-pass.rs | 24 + src/test/ui/compile-fail-migration/rmeta-pass.rs | 25 + .../ui/compile-fail-migration/rmeta-priv-warn.rs | 21 + src/test/ui/compile-fail-migration/rmeta.rs | 18 + src/test/ui/compile-fail-migration/rmeta.stderr | 9 + src/test/ui/compile-fail-migration/rmeta_lib.rs | 23 + .../ui/compile-fail-migration/rmeta_lib.stderr | 4 + .../ui/compile-fail-migration/rmeta_meta_main.rs | 24 + .../compile-fail-migration/rmeta_meta_main.stderr | 9 + .../rust-unstable-column-gated.rs | 14 + .../rust-unstable-column-gated.stderr | 8 + .../rustc-args-required-const.rs | 36 + .../rustc-args-required-const.stderr | 14 + .../rustc-args-required-const2.rs | 20 + .../rustc-args-required-const2.stderr | 8 + src/test/ui/compile-fail-migration/rustc-error.rs | 16 + .../ui/compile-fail-migration/rustc-error.stderr | 10 + .../safe-extern-statics-mut.rs | 25 + .../safe-extern-statics-mut.stderr | 35 + .../compile-fail-migration/safe-extern-statics.rs | 31 + .../safe-extern-statics.stderr | 43 ++ src/test/ui/compile-fail-migration/self-infer.rs | 18 + .../ui/compile-fail-migration/self-infer.stderr | 15 + .../self-vs-path-ambiguity.rs | 22 + .../self-vs-path-ambiguity.stderr | 8 + .../compile-fail-migration/self_type_keyword-2.rs | 23 + .../self_type_keyword-2.stderr | 28 + .../ui/compile-fail-migration/self_type_keyword.rs | 51 ++ .../self_type_keyword.stderr | 62 ++ src/test/ui/compile-fail-migration/seq-args.rs | 21 + src/test/ui/compile-fail-migration/seq-args.stderr | 15 + .../shadowed-trait-methods.rs | 24 + .../shadowed-trait-methods.stderr | 15 + .../shadowed-use-visibility.rs | 26 + .../shadowed-use-visibility.stderr | 15 + .../shadowing-in-the-same-pattern.rs | 17 + .../shadowing-in-the-same-pattern.stderr | 15 + .../shift-various-bad-types.rs | 41 ++ .../shift-various-bad-types.stderr | 34 + ...ould-fail-no_gate_irrefutable_if_let_pattern.rs | 15 + ...-fail-no_gate_irrefutable_if_let_pattern.stderr | 9 + ...ould-fail-with_gate_irrefutable_pattern_deny.rs | 17 + ...-fail-with_gate_irrefutable_pattern_deny.stderr | 10 + .../simd-intrinsic-declaration-type.rs | 68 ++ .../simd-intrinsic-declaration-type.stderr | 75 +++ .../simd-intrinsic-generic-arithmetic.rs | 103 +++ .../simd-intrinsic-generic-arithmetic.stderr | 87 +++ .../simd-intrinsic-generic-cast.rs | 51 ++ .../simd-intrinsic-generic-cast.stderr | 27 + .../simd-intrinsic-generic-comparison.rs | 75 +++ .../simd-intrinsic-generic-comparison.stderr | 111 ++++ .../simd-intrinsic-generic-elements.rs | 97 +++ .../simd-intrinsic-generic-elements.stderr | 93 +++ .../simd-intrinsic-generic-reduction.rs | 81 +++ .../simd-intrinsic-generic-reduction.stderr | 75 +++ .../simd-intrinsic-generic-select.rs | 56 ++ .../simd-intrinsic-generic-select.stderr | 21 + .../simd-intrinsic-single-nominal-type.rs | 33 + .../simd-intrinsic-single-nominal-type.stderr | 15 + .../simd-type-generic-monomorphisation.rs | 21 + .../simd-type-generic-monomorphisation.stderr | 4 + src/test/ui/compile-fail-migration/simd-type.rs | 22 + .../ui/compile-fail-migration/simd-type.stderr | 22 + .../single-primitive-inherent-impl.rs | 23 + .../single-primitive-inherent-impl.stderr | 19 + .../ui/compile-fail-migration/sized-cycle-note.rs | 26 + .../compile-fail-migration/sized-cycle-note.stderr | 23 + src/test/ui/compile-fail-migration/slice-2.rs | 21 + src/test/ui/compile-fail-migration/slice-2.stderr | 27 + .../compile-fail-migration/slice-mut-2.nll.stderr | 12 + src/test/ui/compile-fail-migration/slice-mut-2.rs | 18 + .../ui/compile-fail-migration/slice-mut-2.stderr | 9 + src/test/ui/compile-fail-migration/slice-mut.rs | 22 + .../ui/compile-fail-migration/slice-mut.stderr | 12 + .../slightly-nice-generic-literal-messages.rs | 24 + .../slightly-nice-generic-literal-messages.stderr | 12 + .../specialization/README.md | 21 + .../specialization-feature-gate-default.rs | 21 + .../specialization-feature-gate-default.stderr | 13 + .../defaultimpl/specialization-no-default.rs | 95 +++ .../defaultimpl/specialization-no-default.stderr | 70 ++ .../specialization-trait-item-not-implemented.rs | 33 + ...pecialization-trait-item-not-implemented.stderr | 12 + .../specialization-trait-not-implemented.rs | 34 + .../specialization-trait-not-implemented.stderr | 18 + .../defaultimpl/specialization-wfcheck.rs | 20 + .../defaultimpl/specialization-wfcheck.stderr | 11 + .../specialization/defaultimpl/validation.rs | 23 + .../specialization/defaultimpl/validation.stderr | 34 + .../specialization/issue-52050.rs | 42 ++ .../specialization/issue-52050.stderr | 18 + .../specialization-default-projection.rs | 46 ++ .../specialization-default-projection.stderr | 29 + .../specialization/specialization-default-types.rs | 45 ++ .../specialization-default-types.stderr | 25 + .../specialization/specialization-no-default.rs | 95 +++ .../specialization-no-default.stderr | 70 ++ .../specialization-overlap-negative.rs | 21 + .../specialization-overlap-negative.stderr | 11 + .../specialization/specialization-overlap.rs | 29 + .../specialization/specialization-overlap.stderr | 35 + .../specialization/specialization-polarity.rs | 26 + .../specialization/specialization-polarity.stderr | 19 + .../stability-attribute-issue-43027.rs | 20 + .../stability-attribute-issue-43027.stderr | 8 + .../stability-attribute-issue.rs | 24 + .../stability-attribute-issue.stderr | 19 + ...tability-attribute-non-staged-force-unstable.rs | 16 + ...lity-attribute-non-staged-force-unstable.stderr | 20 + .../stability-attribute-non-staged.rs | 14 + .../stability-attribute-non-staged.stderr | 20 + .../stability-attribute-sanity-2.rs | 26 + .../stability-attribute-sanity-2.stderr | 22 + .../stability-attribute-sanity-3.rs | 22 + .../stability-attribute-sanity-3.stderr | 10 + .../stability-attribute-sanity.rs | 101 +++ .../stability-attribute-sanity.stderr | 142 ++++ .../ui/compile-fail-migration/stable-features.rs | 24 + .../compile-fail-migration/stable-features.stderr | 20 + .../ui/compile-fail-migration/static-closures.rs | 14 + .../compile-fail-migration/static-closures.stderr | 9 + .../ui/compile-fail-migration/static-drop-scope.rs | 41 ++ .../static-drop-scope.stderr | 60 ++ .../static-items-cant-move.rs | 29 + .../static-items-cant-move.stderr | 9 + .../static-lifetime-bound.nll.stderr | 21 + .../static-lifetime-bound.rs | 16 + .../static-lifetime-bound.stderr | 21 + .../static-method-privacy.rs | 20 + .../static-method-privacy.stderr | 9 + .../compile-fail-migration/static-mut-bad-types.rs | 17 + .../static-mut-bad-types.stderr | 9 + .../static-mut-foreign-requires-unsafe.rs | 19 + .../static-mut-foreign-requires-unsafe.stderr | 27 + .../static-mut-not-constant.rs | 16 + .../static-mut-not-constant.stderr | 9 + .../compile-fail-migration/static-mut-not-pat.rs | 53 ++ .../static-mut-not-pat.stderr | 21 + .../static-mut-requires-unsafe.rs | 17 + .../static-mut-requires-unsafe.stderr | 27 + .../static-priv-by-default.rs | 37 ++ .../static-priv-by-default.stderr | 21 + .../static-priv-by-default2.rs | 40 ++ .../static-priv-by-default2.stderr | 15 + .../static-reference-to-fn-1.rs | 34 + .../static-reference-to-fn-1.stderr | 12 + .../static-reference-to-fn-2.nll.stderr | 68 ++ .../static-reference-to-fn-2.rs | 64 ++ .../static-reference-to-fn-2.stderr | 71 ++ .../compile-fail-migration/static-region-bound.rs | 22 + .../static-region-bound.stderr | 14 + .../static-vec-repeat-not-constant.rs | 16 + .../static-vec-repeat-not-constant.stderr | 9 + .../compile-fail-migration/staticness-mismatch.rs | 21 + .../staticness-mismatch.stderr | 12 + .../std-uncopyable-atomics.rs | 26 + .../std-uncopyable-atomics.stderr | 39 ++ .../stmt_expr_attrs_no_feature.rs | 150 +++++ .../stmt_expr_attrs_no_feature.stderr | 67 ++ src/test/ui/compile-fail-migration/str-idx.rs | 14 + src/test/ui/compile-fail-migration/str-idx.stderr | 11 + src/test/ui/compile-fail-migration/str-mut-idx.rs | 21 + .../ui/compile-fail-migration/str-mut-idx.stderr | 35 + .../struct-base-wrong-type-2.rs | 29 + .../struct-base-wrong-type-2.stderr | 21 + .../struct-base-wrong-type.rs | 37 ++ .../struct-base-wrong-type.stderr | 21 + .../ui/compile-fail-migration/struct-field-cfg.rs | 28 + .../compile-fail-migration/struct-field-cfg.stderr | 30 + .../compile-fail-migration/struct-field-privacy.rs | 48 ++ .../struct-field-privacy.stderr | 33 + .../compile-fail-migration/struct-fields-dupe.rs | 20 + .../struct-fields-dupe.stderr | 11 + .../struct-fields-missing.rs | 21 + .../struct-fields-missing.stderr | 9 + .../struct-fields-shorthand-unresolved.rs | 22 + .../struct-fields-shorthand-unresolved.stderr | 9 + .../struct-fields-shorthand.rs | 22 + .../struct-fields-shorthand.stderr | 11 + .../compile-fail-migration/struct-fields-typo.rs | 24 + .../struct-fields-typo.stderr | 9 + .../struct-like-enum-nonexhaustive.rs | 22 + .../struct-like-enum-nonexhaustive.stderr | 9 + .../struct-pat-derived-error.rs | 24 + .../struct-pat-derived-error.stderr | 22 + .../struct-path-alias-bounds.rs | 21 + .../struct-path-alias-bounds.stderr | 15 + .../struct-path-associated-type.rs | 48 ++ .../struct-path-associated-type.stderr | 64 ++ .../ui/compile-fail-migration/struct-path-self.rs | 47 ++ .../compile-fail-migration/struct-path-self.stderr | 40 ++ .../struct-pattern-match-useless.rs | 25 + .../struct-pattern-match-useless.stderr | 14 + .../struct-variant-privacy-xc.rs | 20 + .../struct-variant-privacy-xc.stderr | 15 + .../struct-variant-privacy.rs | 22 + .../struct-variant-privacy.stderr | 15 + .../structure-constructor-type-mismatch.rs | 83 +++ .../structure-constructor-type-mismatch.stderr | 115 ++++ .../substs-ppaux.normal.stderr | 55 ++ src/test/ui/compile-fail-migration/substs-ppaux.rs | 61 ++ .../substs-ppaux.verbose.stderr | 55 ++ .../suffixed-literal-meta.rs | 25 + .../suffixed-literal-meta.stderr | 98 +++ .../compile-fail-migration/super-at-top-level.rs | 14 + .../super-at-top-level.stderr | 9 + .../ui/compile-fail-migration/suppressed-error.rs | 18 + .../compile-fail-migration/suppressed-error.stderr | 12 + .../compile-fail-migration/symbol-names/basic.rs | 16 + .../symbol-names/basic.stderr | 14 + .../compile-fail-migration/symbol-names/impl1.rs | 35 + .../symbol-names/impl1.stderr | 26 + .../syntax-extension-minor.rs | 24 + .../syntax-extension-minor.stderr | 9 + .../syntax-trait-polarity-feature-gate.rs | 20 + .../syntax-trait-polarity-feature-gate.stderr | 11 + .../syntax-trait-polarity.rs | 37 ++ .../syntax-trait-polarity.stderr | 40 ++ .../ui/compile-fail-migration/synthetic-param.rs | 38 ++ .../compile-fail-migration/synthetic-param.stderr | 21 + .../tag-that-dare-not-speak-its-name.rs | 27 + .../tag-that-dare-not-speak-its-name.stderr | 12 + .../ui/compile-fail-migration/tag-type-args.rs | 17 + .../ui/compile-fail-migration/tag-type-args.stderr | 9 + .../tag-variant-cast-non-nullary.rs | 19 + .../tag-variant-cast-non-nullary.stderr | 11 + .../compile-fail-migration/tag-variant-disr-dup.rs | 23 + .../tag-variant-disr-dup.stderr | 11 + src/test/ui/compile-fail-migration/tail-typeck.rs | 17 + .../ui/compile-fail-migration/tail-typeck.stderr | 9 + .../ui/compile-fail-migration/terr-in-field.rs | 29 + .../ui/compile-fail-migration/terr-in-field.stderr | 12 + src/test/ui/compile-fail-migration/terr-sorts.rs | 26 + .../ui/compile-fail-migration/terr-sorts.stderr | 12 + src/test/ui/compile-fail-migration/test-cfg.rs | 18 + src/test/ui/compile-fail-migration/test-cfg.stderr | 9 + .../compile-fail-migration/test-warns-dead-code.rs | 17 + .../test-warns-dead-code.stderr | 14 + .../thread-local-in-ctfe.nll.stderr | 54 ++ .../compile-fail-migration/thread-local-in-ctfe.rs | 33 + .../thread-local-in-ctfe.stderr | 33 + src/test/ui/compile-fail-migration/tool_lints.rs | 18 + .../ui/compile-fail-migration/tool_lints.stderr | 14 + .../compile-fail-migration/trace_macros-format.rs | 28 + .../trace_macros-format.stderr | 38 ++ .../ui/compile-fail-migration/trace_macros-gate.rs | 30 + .../trace_macros-gate.stderr | 62 ++ src/test/ui/compile-fail-migration/trait-alias.rs | 27 + .../ui/compile-fail-migration/trait-alias.stderr | 44 ++ .../trait-as-struct-constructor.rs | 16 + .../trait-as-struct-constructor.stderr | 9 + .../trait-bounds-not-on-bare-trait.rs | 21 + .../trait-bounds-not-on-bare-trait.stderr | 13 + .../trait-bounds-not-on-struct.rs | 19 + .../trait-bounds-not-on-struct.stderr | 15 + .../trait-bounds-on-structs-and-enums-in-fns.rs | 30 + ...trait-bounds-on-structs-and-enums-in-fns.stderr | 27 + .../trait-bounds-on-structs-and-enums-in-impls.rs | 35 + ...ait-bounds-on-structs-and-enums-in-impls.stderr | 15 + .../trait-bounds-on-structs-and-enums-locals.rs | 27 + ...trait-bounds-on-structs-and-enums-locals.stderr | 27 + .../trait-bounds-on-structs-and-enums-static.rs | 25 + ...trait-bounds-on-structs-and-enums-static.stderr | 18 + .../trait-bounds-on-structs-and-enums-xc.rs | 24 + .../trait-bounds-on-structs-and-enums-xc.stderr | 19 + .../trait-bounds-on-structs-and-enums-xc1.rs | 25 + .../trait-bounds-on-structs-and-enums-xc1.stderr | 19 + .../trait-bounds-on-structs-and-enums.rs | 53 ++ .../trait-bounds-on-structs-and-enums.stderr | 90 +++ .../compile-fail-migration/trait-bounds-sugar.rs | 29 + .../trait-bounds-sugar.stderr | 12 + .../trait-coercion-generic-bad.rs | 29 + .../trait-coercion-generic-bad.stderr | 13 + .../trait-coercion-generic-regions.nll.stderr | 14 + .../trait-coercion-generic-regions.rs | 29 + .../trait-coercion-generic-regions.stderr | 14 + src/test/ui/compile-fail-migration/trait-impl-1.rs | 26 + .../ui/compile-fail-migration/trait-impl-1.stderr | 9 + .../trait-impl-can-not-have-untraitful-items.rs | 20 + ...trait-impl-can-not-have-untraitful-items.stderr | 22 + .../trait-impl-different-num-params.rs | 22 + .../trait-impl-different-num-params.stderr | 12 + .../trait-impl-for-module.rs | 21 + .../trait-impl-for-module.stderr | 9 + .../trait-impl-method-mismatch.rs | 24 + .../trait-impl-method-mismatch.stderr | 15 + ...-of-supertrait-has-wrong-lifetime-parameters.rs | 41 ++ ...supertrait-has-wrong-lifetime-parameters.stderr | 23 + .../compile-fail-migration/trait-item-privacy.rs | 146 +++++ .../trait-item-privacy.stderr | 176 +++++ .../trait-matching-lifetimes.rs | 30 + .../trait-matching-lifetimes.stderr | 41 ++ .../trait-object-macro-matcher.rs | 21 + .../trait-object-macro-matcher.stderr | 18 + .../compile-fail-migration/trait-object-safety.rs | 27 + .../trait-object-safety.stderr | 20 + .../trait-object-vs-lifetime-2.rs | 23 + .../trait-object-vs-lifetime-2.stderr | 9 + .../trait-object-vs-lifetime.rs | 29 + .../trait-object-vs-lifetime.stderr | 34 + .../trait-or-new-type-instead.rs | 16 + .../trait-or-new-type-instead.stderr | 14 + .../ui/compile-fail-migration/trait-privacy.rs | 35 + .../ui/compile-fail-migration/trait-privacy.stderr | 8 + .../trait-resolution-in-overloaded-op.rs | 21 + .../trait-resolution-in-overloaded-op.stderr | 11 + .../trait-safety-inherent-impl.rs | 19 + .../trait-safety-inherent-impl.stderr | 11 + .../trait-safety-trait-impl-cc.rs | 25 + .../trait-safety-trait-impl-cc.stderr | 13 + .../trait-safety-trait-impl.rs | 28 + .../trait-safety-trait-impl.stderr | 16 + .../trait-static-method-generic-inference.rs | 38 ++ .../trait-static-method-generic-inference.stderr | 15 + src/test/ui/compile-fail-migration/trait-test-2.rs | 24 + .../ui/compile-fail-migration/trait-test-2.stderr | 41 ++ src/test/ui/compile-fail-migration/trait-test.rs | 15 + .../ui/compile-fail-migration/trait-test.stderr | 9 + .../traits-assoc-type-in-supertrait-bad.rs | 26 + .../traits-assoc-type-in-supertrait-bad.stderr | 12 + .../traits-inductive-overflow-simultaneous.rs | 30 + .../traits-inductive-overflow-simultaneous.stderr | 16 + .../traits-inductive-overflow-supertrait-oibit.rs | 27 + ...aits-inductive-overflow-supertrait-oibit.stderr | 23 + .../traits-inductive-overflow-supertrait.rs | 25 + .../traits-inductive-overflow-supertrait.stderr | 16 + .../traits-inductive-overflow-two-traits.rs | 31 + .../traits-inductive-overflow-two-traits.stderr | 15 + .../traits-issue-23003-overflow.rs | 39 ++ .../traits-issue-23003-overflow.stderr | 8 + .../traits-multidispatch-bad.rs | 32 + .../traits-multidispatch-bad.stderr | 9 + .../traits-negative-impls.rs | 78 +++ .../traits-negative-impls.stderr | 101 +++ .../traits-repeated-supertrait-ambig.rs | 53 ++ .../traits-repeated-supertrait-ambig.stderr | 52 ++ .../transmute-different-sizes.rs | 39 ++ .../transmute-different-sizes.stderr | 30 + .../transmute-fat-pointers.rs | 41 ++ .../transmute-fat-pointers.stderr | 39 ++ .../ui/compile-fail-migration/transmute-impl.rs | 33 + .../compile-fail-migration/transmute-impl.stderr | 12 + .../transmute-imut-to-mut.rs | 19 + .../transmute-imut-to-mut.stderr | 10 + .../ui/compile-fail-migration/trivial_casts.rs | 95 +++ .../ui/compile-fail-migration/trivial_casts.stderr | 164 +++++ .../compile-fail-migration/tuple-arity-mismatch.rs | 27 + .../tuple-arity-mismatch.stderr | 21 + .../tuple-index-not-tuple.rs | 20 + .../tuple-index-not-tuple.stderr | 15 + .../tuple-index-out-of-bounds.rs | 24 + .../tuple-index-out-of-bounds.stderr | 15 + .../tuple-struct-nonexhaustive.rs | 19 + .../tuple-struct-nonexhaustive.stderr | 9 + .../tutorial-suffix-inference-test.rs | 34 + .../tutorial-suffix-inference-test.stderr | 25 + .../type-arg-out-of-scope.rs | 15 + .../type-arg-out-of-scope.stderr | 23 + .../type-ascription-precedence.rs | 64 ++ .../type-ascription-precedence.stderr | 72 ++ .../type-ascription-soundness.rs | 23 + .../type-ascription-soundness.stderr | 39 ++ .../type-mismatch-multiple.rs | 20 + .../type-mismatch-multiple.stderr | 18 + .../type-mismatch-same-crate-name.rs | 39 ++ .../type-mismatch-same-crate-name.stderr | 31 + ...pe-parameter-defaults-referencing-Self-ppaux.rs | 27 + ...arameter-defaults-referencing-Self-ppaux.stderr | 24 + .../type-parameter-defaults-referencing-Self.rs | 23 + ...type-parameter-defaults-referencing-Self.stderr | 11 + .../compile-fail-migration/type-parameter-names.rs | 22 + .../type-parameter-names.stderr | 14 + .../type-params-in-different-spaces-1.rs | 28 + .../type-params-in-different-spaces-1.stderr | 12 + .../type-params-in-different-spaces-2.rs | 31 + .../type-params-in-different-spaces-2.stderr | 29 + .../type-params-in-different-spaces-3.rs | 17 + .../type-params-in-different-spaces-3.stderr | 14 + .../type-path-err-node-types.rs | 36 + .../type-path-err-node-types.stderr | 28 + src/test/ui/compile-fail-migration/type-shadow.rs | 18 + .../ui/compile-fail-migration/type-shadow.stderr | 12 + .../ui/compile-fail-migration/type_length_limit.rs | 35 + .../type_length_limit.stderr | 6 + .../typeck-auto-trait-no-supertraits-2.rs | 24 + .../typeck-auto-trait-no-supertraits-2.stderr | 9 + .../typeck-auto-trait-no-supertraits.rs | 48 ++ .../typeck-auto-trait-no-supertraits.stderr | 9 + .../typeck-cast-pointer-to-float.rs | 15 + .../typeck-cast-pointer-to-float.stderr | 9 + .../typeck-default-trait-impl-assoc-type.rs | 25 + .../typeck-default-trait-impl-assoc-type.stderr | 17 + ...ypeck-default-trait-impl-constituent-types-2.rs | 28 + ...k-default-trait-impl-constituent-types-2.stderr | 18 + .../typeck-default-trait-impl-constituent-types.rs | 32 + ...eck-default-trait-impl-constituent-types.stderr | 17 + ...eck-default-trait-impl-cross-crate-coherence.rs | 34 + ...default-trait-impl-cross-crate-coherence.stderr | 37 ++ .../typeck-default-trait-impl-negation-send.rs | 31 + .../typeck-default-trait-impl-negation-send.stderr | 16 + .../typeck-default-trait-impl-negation-sync.rs | 53 ++ .../typeck-default-trait-impl-negation-sync.stderr | 44 ++ .../typeck-default-trait-impl-negation.rs | 38 ++ .../typeck-default-trait-impl-negation.stderr | 31 + .../typeck-default-trait-impl-precedence.rs | 30 + .../typeck-default-trait-impl-precedence.stderr | 16 + .../typeck-default-trait-impl-send-param.rs | 21 + .../typeck-default-trait-impl-send-param.stderr | 17 + .../typeck-negative-impls-builtin.rs | 22 + .../typeck-negative-impls-builtin.stderr | 9 + .../typeck-unsafe-always-share.rs | 42 ++ .../typeck-unsafe-always-share.stderr | 56 ++ .../typeck_type_placeholder_mismatch.rs | 37 ++ .../typeck_type_placeholder_mismatch.stderr | 21 + .../ufcs-explicit-self-bad.rs | 69 ++ .../ufcs-explicit-self-bad.stderr | 107 +++ .../ufcs-partially-resolved.rs | 66 ++ .../ufcs-partially-resolved.stderr | 206 ++++++ .../ufcs-qpath-missing-params.rs | 26 + .../ufcs-qpath-missing-params.stderr | 9 + .../ufcs-qpath-self-mismatch.rs | 20 + .../ufcs-qpath-self-mismatch.stderr | 24 + .../unboxed-closure-feature-gate.rs | 30 + .../unboxed-closure-feature-gate.stderr | 11 + .../unboxed-closure-illegal-move.nll.stderr | 27 + .../unboxed-closure-illegal-move.rs | 48 ++ .../unboxed-closure-illegal-move.stderr | 35 + .../unboxed-closure-immutable-capture.nll.stderr | 75 +++ .../unboxed-closure-immutable-capture.rs | 29 + .../unboxed-closure-immutable-capture.stderr | 69 ++ .../unboxed-closure-region.rs | 18 + .../unboxed-closure-region.stderr | 15 + .../unboxed-closure-sugar-default.rs | 38 ++ .../unboxed-closure-sugar-default.stderr | 15 + .../unboxed-closure-sugar-equiv.rs | 58 ++ .../unboxed-closure-sugar-equiv.stderr | 16 + .../unboxed-closure-sugar-lifetime-elision.rs | 37 ++ .../unboxed-closure-sugar-lifetime-elision.stderr | 11 + .../unboxed-closure-sugar-not-used-on-fn.rs | 22 + .../unboxed-closure-sugar-not-used-on-fn.stderr | 19 + .../unboxed-closure-sugar-region.rs | 46 ++ .../unboxed-closure-sugar-region.stderr | 9 + .../unboxed-closure-sugar-used-on-struct-1.rs | 23 + .../unboxed-closure-sugar-used-on-struct-1.stderr | 9 + .../unboxed-closure-sugar-used-on-struct-3.rs | 28 + .../unboxed-closure-sugar-used-on-struct-3.stderr | 9 + .../unboxed-closure-sugar-used-on-struct.rs | 22 + .../unboxed-closure-sugar-used-on-struct.stderr | 16 + ...-sugar-wrong-number-number-type-parameters-1.rs | 18 + ...ar-wrong-number-number-type-parameters-1.stderr | 9 + ...-sugar-wrong-number-number-type-parameters-3.rs | 20 + ...ar-wrong-number-number-type-parameters-3.stderr | 16 + ...re-sugar-wrong-number-number-type-parameters.rs | 20 + ...ugar-wrong-number-number-type-parameters.stderr | 16 + .../unboxed-closures-borrow-conflict.rs | 18 + .../unboxed-closures-borrow-conflict.stderr | 11 + ...boxed-closures-failed-recursive-fn-1.nll.stderr | 66 ++ .../unboxed-closures-failed-recursive-fn-1.rs | 45 ++ .../unboxed-closures-failed-recursive-fn-1.stderr | 30 + .../unboxed-closures-failed-recursive-fn-2.rs | 39 ++ .../unboxed-closures-failed-recursive-fn-2.stderr | 14 + .../unboxed-closures-fnmut-as-fn.rs | 40 ++ .../unboxed-closures-fnmut-as-fn.stderr | 15 + ...r-argument-types-two-region-pointers.nll.stderr | 18 + ...res-infer-argument-types-two-region-pointers.rs | 29 + ...infer-argument-types-two-region-pointers.stderr | 26 + ...res-infer-fnmut-calling-fnmut-no-mut.nll.stderr | 21 + ...ed-closures-infer-fnmut-calling-fnmut-no-mut.rs | 31 + ...losures-infer-fnmut-calling-fnmut-no-mut.stderr | 22 + ...xed-closures-infer-fnmut-missing-mut.nll.stderr | 11 + .../unboxed-closures-infer-fnmut-missing-mut.rs | 18 + ...unboxed-closures-infer-fnmut-missing-mut.stderr | 11 + ...losures-infer-fnmut-move-missing-mut.nll.stderr | 11 + ...nboxed-closures-infer-fnmut-move-missing-mut.rs | 18 + ...ed-closures-infer-fnmut-move-missing-mut.stderr | 11 + ...xed-closures-infer-fnonce-call-twice.nll.stderr | 11 + .../unboxed-closures-infer-fnonce-call-twice.rs | 21 + ...unboxed-closures-infer-fnonce-call-twice.stderr | 17 + ...losures-infer-fnonce-move-call-twice.nll.stderr | 11 + ...nboxed-closures-infer-fnonce-move-call-twice.rs | 21 + ...ed-closures-infer-fnonce-move-call-twice.stderr | 17 + .../unboxed-closures-mutate-upvar.nll.stderr | 45 ++ .../unboxed-closures-mutate-upvar.rs | 67 ++ .../unboxed-closures-mutate-upvar.stderr | 53 ++ ...es-mutated-upvar-from-fn-closure.ast.nll.stderr | 20 + ...osures-mutated-upvar-from-fn-closure.ast.stderr | 20 + ...osures-mutated-upvar-from-fn-closure.mir.stderr | 20 + ...boxed-closures-mutated-upvar-from-fn-closure.rs | 28 + ...d-closures-recursive-fn-using-fn-mut.nll.stderr | 13 + .../unboxed-closures-recursive-fn-using-fn-mut.rs | 53 ++ ...boxed-closures-recursive-fn-using-fn-mut.stderr | 12 + .../unboxed-closures-static-call-wrong-trait.rs | 18 + ...unboxed-closures-static-call-wrong-trait.stderr | 11 + .../unboxed-closures-type-mismatch.rs | 17 + .../unboxed-closures-type-mismatch.stderr | 9 + .../unboxed-closures-unsafe-extern-fn.rs | 36 + .../unboxed-closures-unsafe-extern-fn.stderr | 39 ++ .../unboxed-closures-wrong-abi.rs | 36 + .../unboxed-closures-wrong-abi.stderr | 39 ++ .../unboxed-closures-wrong-arg-type-extern-fn.rs | 37 ++ ...nboxed-closures-wrong-arg-type-extern-fn.stderr | 39 ++ .../underscore-lifetime-binders.rs | 36 + .../underscore-lifetime-binders.stderr | 45 ++ .../underscore-lifetime-elison-mismatch.nll.stderr | 17 + .../underscore-lifetime-elison-mismatch.rs | 13 + .../underscore-lifetime-elison-mismatch.stderr | 11 + .../uninhabited-enum-cast.rs | 17 + .../uninhabited-enum-cast.stderr | 11 + .../uninhabited-irrefutable.rs | 39 ++ .../uninhabited-irrefutable.stderr | 9 + .../uninhabited-matches-feature-gated.rs | 44 ++ .../uninhabited-matches-feature-gated.stderr | 64 ++ .../compile-fail-migration/uninhabited-patterns.rs | 58 ++ .../uninhabited-patterns.stderr | 38 ++ .../ui/compile-fail-migration/union-ub-fat-ptr.rs | 89 +++ .../compile-fail-migration/union-ub-fat-ptr.stderr | 43 ++ .../union-borrow-move-parent-sibling.nll.stderr | 33 + .../union/union-borrow-move-parent-sibling.rs | 57 ++ .../union/union-borrow-move-parent-sibling.stderr | 64 ++ .../union/union-const-pat.rs | 23 + .../union/union-const-pat.stderr | 8 + .../ui/compile-fail-migration/union/union-copy.rs | 26 + .../compile-fail-migration/union/union-copy.stderr | 12 + .../union/union-derive-clone.rs | 41 ++ .../union/union-derive-clone.stderr | 27 + .../compile-fail-migration/union/union-derive.rs | 26 + .../union/union-derive.stderr | 38 ++ .../ui/compile-fail-migration/union/union-empty.rs | 13 + .../union/union-empty.stderr | 8 + .../compile-fail-migration/union/union-generic.rs | 22 + .../union/union-generic.stderr | 27 + .../union/union-lint-dead-code.rs | 25 + .../union/union-lint-dead-code.stderr | 14 + .../union/union-nonrepresentable.rs | 18 + .../union/union-nonrepresentable.stderr | 14 + .../compile-fail-migration/union/union-repr-c.rs | 28 + .../union/union-repr-c.stderr | 22 + .../compile-fail-migration/union/union-unsafe.rs | 55 ++ .../union/union-unsafe.stderr | 51 ++ .../compile-fail-migration/union/union-unsized.rs | 26 + .../union/union-unsized.stderr | 23 + .../union/union-with-drop-fields-lint.rs | 40 ++ .../union/union-with-drop-fields-lint.stderr | 26 + .../unique-object-noncopyable.rs | 35 + .../unique-object-noncopyable.stderr | 15 + .../compile-fail-migration/unique-pinned-nocopy.rs | 24 + .../unique-pinned-nocopy.stderr | 15 + .../unknown-lint-tool-name.rs | 16 + .../unknown-lint-tool-name.stderr | 15 + .../ui/compile-fail-migration/unknown-tool-name.rs | 14 + .../unknown-tool-name.stderr | 9 + .../unop-move-semantics.nll.stderr | 27 + .../compile-fail-migration/unop-move-semantics.rs | 39 ++ .../unop-move-semantics.stderr | 45 ++ .../ui/compile-fail-migration/unop-neg-bool.rs | 13 + .../ui/compile-fail-migration/unop-neg-bool.stderr | 11 + .../ui/compile-fail-migration/unreachable-arm.rs | 25 + .../compile-fail-migration/unreachable-arm.stderr | 14 + .../ui/compile-fail-migration/unreachable-code.rs | 18 + .../compile-fail-migration/unreachable-code.stderr | 14 + .../compile-fail-migration/unreachable-in-call.rs | 32 + .../unreachable-in-call.stderr | 22 + .../unreachable-loop-patterns.rs | 21 + .../unreachable-loop-patterns.stderr | 14 + .../unreachable-try-pattern.rs | 52 ++ .../unreachable-try-pattern.stderr | 43 ++ .../compile-fail-migration/unreachable-variant.rs | 17 + .../unreachable-variant.stderr | 9 + .../unresolved-extern-mod-suggestion.rs | 15 + .../unresolved-extern-mod-suggestion.stderr | 17 + .../unresolved-import-recovery.rs | 27 + .../unresolved-import-recovery.stderr | 9 + .../ui/compile-fail-migration/unresolved-import.rs | 57 ++ .../unresolved-import.stderr | 44 ++ .../unsafe-around-compiler-generated-unsafe.rs | 17 + .../unsafe-around-compiler-generated-unsafe.stderr | 14 + .../unsafe-fn-assign-deref-ptr.rs | 19 + .../unsafe-fn-assign-deref-ptr.stderr | 11 + .../compile-fail-migration/unsafe-fn-autoderef.rs | 33 + .../unsafe-fn-autoderef.stderr | 9 + .../unsafe-fn-called-from-safe.rs | 16 + .../unsafe-fn-called-from-safe.stderr | 11 + .../compile-fail-migration/unsafe-fn-deref-ptr.rs | 17 + .../unsafe-fn-deref-ptr.stderr | 11 + .../unsafe-fn-used-as-value.rs | 17 + .../unsafe-fn-used-as-value.stderr | 11 + .../compile-fail-migration/unsafe-move-val-init.rs | 20 + .../unsafe-move-val-init.stderr | 11 + .../ui/compile-fail-migration/unsafe-subtyping.rs | 21 + .../compile-fail-migration/unsafe-subtyping.stderr | 14 + .../ui/compile-fail-migration/unsafe-trait-impl.rs | 24 + .../unsafe-trait-impl.stderr | 15 + .../compile-fail-migration/unsized-bare-typaram.rs | 14 + .../unsized-bare-typaram.stderr | 18 + src/test/ui/compile-fail-migration/unsized-enum.rs | 22 + .../ui/compile-fail-migration/unsized-enum.stderr | 18 + .../unsized-inherent-impl-self-type.rs | 21 + .../unsized-inherent-impl-self-type.stderr | 18 + .../ui/compile-fail-migration/unsized-struct.rs | 29 + .../compile-fail-migration/unsized-struct.stderr | 34 + .../unsized-trait-impl-self-type.rs | 24 + .../unsized-trait-impl-self-type.stderr | 18 + .../unsized-trait-impl-trait-arg.rs | 22 + .../unsized-trait-impl-trait-arg.stderr | 13 + src/test/ui/compile-fail-migration/unsized3.rs | 61 ++ src/test/ui/compile-fail-migration/unsized3.stderr | 91 +++ src/test/ui/compile-fail-migration/unsized5.rs | 44 ++ src/test/ui/compile-fail-migration/unsized5.stderr | 67 ++ src/test/ui/compile-fail-migration/unsized6.rs | 54 ++ src/test/ui/compile-fail-migration/unsized6.stderr | 146 +++++ src/test/ui/compile-fail-migration/unsized7.rs | 26 + src/test/ui/compile-fail-migration/unsized7.stderr | 13 + .../unspecified-self-in-trait-ref.rs | 30 + .../unspecified-self-in-trait-ref.stderr | 36 + .../ui/compile-fail-migration/unsupported-cast.rs | 17 + .../compile-fail-migration/unsupported-cast.stderr | 9 + src/test/ui/compile-fail-migration/unused-attr.rs | 60 ++ .../ui/compile-fail-migration/unused-attr.stderr | 98 +++ .../compile-fail-migration/unused-macro-rules.rs | 39 ++ .../unused-macro-rules.stderr | 41 ++ .../unused-macro-with-bad-frag-spec.rs | 19 + .../unused-macro-with-bad-frag-spec.stderr | 10 + .../unused-macro-with-follow-violation.rs | 17 + .../unused-macro-with-follow-violation.stderr | 8 + src/test/ui/compile-fail-migration/unused-macro.rs | 36 + .../ui/compile-fail-migration/unused-macro.stderr | 38 ++ .../unused-mut-warning-captured-var.rs | 17 + .../unused-mut-warning-captured-var.stderr | 16 + .../ui/compile-fail-migration/unused-result.rs | 52 ++ .../ui/compile-fail-migration/unused-result.stderr | 48 ++ .../use-after-move-based-on-type.nll.stderr | 13 + .../use-after-move-based-on-type.rs | 15 + .../use-after-move-based-on-type.stderr | 13 + ...-after-move-implicity-coerced-object.nll.stderr | 13 + .../use-after-move-implicity-coerced-object.rs | 40 ++ .../use-after-move-implicity-coerced-object.stderr | 13 + .../use-after-move-self-based-on-type.rs | 31 + .../use-after-move-self-based-on-type.stderr | 13 + .../use-after-move-self.nll.stderr | 11 + .../compile-fail-migration/use-after-move-self.rs | 29 + .../use-after-move-self.stderr | 13 + .../ui/compile-fail-migration/use-from-trait-xc.rs | 36 + .../use-from-trait-xc.stderr | 58 ++ .../ui/compile-fail-migration/use-from-trait.rs | 40 ++ .../compile-fail-migration/use-from-trait.stderr | 34 + src/test/ui/compile-fail-migration/use-keyword.rs | 27 + .../ui/compile-fail-migration/use-keyword.stderr | 22 + .../ui/compile-fail-migration/use-meta-mismatch.rs | 15 + .../use-meta-mismatch.stderr | 9 + src/test/ui/compile-fail-migration/use-mod-2.rs | 21 + .../ui/compile-fail-migration/use-mod-2.stderr | 15 + src/test/ui/compile-fail-migration/use-mod-3.rs | 22 + .../ui/compile-fail-migration/use-mod-3.stderr | 15 + src/test/ui/compile-fail-migration/use-mod-4.rs | 17 + .../ui/compile-fail-migration/use-mod-4.stderr | 22 + .../compile-fail-migration/use-paths-as-items.rs | 19 + .../use-paths-as-items.stderr | 17 + .../ui/compile-fail-migration/use-self-type.rs | 21 + .../ui/compile-fail-migration/use-self-type.stderr | 16 + .../use-super-global-path.rs | 25 + .../use-super-global-path.stderr | 26 + src/test/ui/compile-fail-migration/used.rs | 28 + src/test/ui/compile-fail-migration/used.stderr | 26 + src/test/ui/compile-fail-migration/useless-pub.rs | 26 + .../ui/compile-fail-migration/useless-pub.stderr | 21 + .../ui/compile-fail-migration/useless_comment.rs | 30 + .../compile-fail-migration/useless_comment.stderr | 32 + .../user-defined-macro-rules.rs | 13 + .../user-defined-macro-rules.stderr | 13 + src/test/ui/compile-fail-migration/utf8_idents.rs | 23 + .../ui/compile-fail-migration/utf8_idents.stderr | 35 + .../ui/compile-fail-migration/variadic-ffi-2.rs | 18 + .../compile-fail-migration/variadic-ffi-2.stderr | 9 + src/test/ui/compile-fail-migration/variadic-ffi.rs | 41 ++ .../ui/compile-fail-migration/variadic-ffi.stderr | 9 + .../variance-associated-types.rs | 32 + .../variance-associated-types.stderr | 19 + .../variance-btree-invariant-types.nll.stderr | 178 +++++ .../variance-btree-invariant-types.rs | 63 ++ .../variance-btree-invariant-types.stderr | 183 ++++++ .../variance-cell-is-invariant.rs | 28 + .../variance-cell-is-invariant.stderr | 15 + .../variance-contravariant-arg-object.nll.stderr | 36 + .../variance-contravariant-arg-object.rs | 35 + .../variance-contravariant-arg-object.stderr | 41 ++ .../variance-contravariant-arg-trait-match.rs | 36 + .../variance-contravariant-arg-trait-match.stderr | 41 ++ .../variance-contravariant-self-trait-match.rs | 37 ++ .../variance-contravariant-self-trait-match.stderr | 41 ++ .../variance-covariant-arg-object.nll.stderr | 36 + .../variance-covariant-arg-object.rs | 35 + .../variance-covariant-arg-object.stderr | 41 ++ .../variance-covariant-arg-trait-match.rs | 35 + .../variance-covariant-arg-trait-match.stderr | 41 ++ .../variance-covariant-self-trait-match.rs | 35 + .../variance-covariant-self-trait-match.stderr | 41 ++ .../variance-invariant-arg-object.nll.stderr | 36 + .../variance-invariant-arg-object.rs | 31 + .../variance-invariant-arg-object.stderr | 41 ++ .../variance-invariant-arg-trait-match.rs | 31 + .../variance-invariant-arg-trait-match.stderr | 41 ++ .../variance-invariant-self-trait-match.rs | 31 + .../variance-invariant-self-trait-match.stderr | 41 ++ .../variance-issue-20533.nll.stderr | 33 + .../compile-fail-migration/variance-issue-20533.rs | 53 ++ .../variance-issue-20533.stderr | 27 + .../variance-object-types.rs | 26 + .../variance-object-types.stderr | 11 + .../variance-regions-direct.rs | 75 +++ .../variance-regions-direct.stderr | 65 ++ .../variance-regions-indirect.rs | 44 ++ .../variance-regions-indirect.stderr | 45 ++ .../variance-regions-unused-direct.rs | 25 + .../variance-regions-unused-direct.stderr | 19 + .../variance-regions-unused-indirect.rs | 21 + .../variance-regions-unused-indirect.stderr | 19 + .../variance-trait-bounds.rs | 45 ++ .../variance-trait-bounds.stderr | 35 + .../variance-trait-matching.nll.stderr | 30 + .../variance-trait-matching.rs | 48 ++ .../variance-trait-matching.stderr | 12 + .../variance-trait-object-bound.rs | 28 + .../variance-trait-object-bound.stderr | 11 + .../variance-types-bounds.rs | 53 ++ .../variance-types-bounds.stderr | 47 ++ .../ui/compile-fail-migration/variance-types.rs | 51 ++ .../compile-fail-migration/variance-types.stderr | 53 ++ .../variance-unused-region-param.rs | 17 + .../variance-unused-region-param.stderr | 19 + .../variance-use-contravariant-struct-1.nll.stderr | 19 + .../variance-use-contravariant-struct-1.rs | 26 + .../variance-use-contravariant-struct-1.stderr | 22 + .../variance-use-contravariant-struct-2.rs | 27 + .../variance-use-contravariant-struct-2.stderr | 8 + .../variance-use-covariant-struct-1.nll.stderr | 19 + .../variance-use-covariant-struct-1.rs | 23 + .../variance-use-covariant-struct-1.stderr | 22 + .../variance-use-covariant-struct-2.rs | 26 + .../variance-use-covariant-struct-2.stderr | 8 + .../variance-use-invariant-struct-1.nll.stderr | 36 + .../variance-use-invariant-struct-1.rs | 33 + .../variance-use-invariant-struct-1.stderr | 41 ++ .../compile-fail-migration/variant-namespacing.rs | 43 ++ .../variant-namespacing.stderr | 93 +++ .../variant-size-differences.rs | 18 + .../variant-size-differences.stderr | 14 + .../compile-fail-migration/variant-used-as-type.rs | 30 + .../variant-used-as-type.stderr | 31 + .../vec-macro-with-comma-only.rs | 13 + .../vec-macro-with-comma-only.stderr | 8 + .../vec-mut-iter-borrow.nll.stderr | 14 + .../compile-fail-migration/vec-mut-iter-borrow.rs | 17 + .../vec-mut-iter-borrow.stderr | 14 + src/test/ui/compile-fail-migration/vec-res-add.rs | 29 + .../ui/compile-fail-migration/vec-res-add.stderr | 11 + .../vector-cast-weirdness.rs | 34 + .../vector-cast-weirdness.stderr | 9 + .../vtable-res-trait-param.rs | 33 + .../vtable-res-trait-param.stderr | 9 + .../walk-struct-literal-with.nll.stderr | 13 + .../walk-struct-literal-with.rs | 27 + .../walk-struct-literal-with.stderr | 13 + .../compile-fail-migration/warn-path-statement.rs | 16 + .../warn-path-statement.stderr | 10 + .../ui/compile-fail-migration/weak-lang-item.rs | 21 + .../compile-fail-migration/weak-lang-item.stderr | 19 + .../compile-fail-migration/wf-array-elem-sized.rs | 21 + .../wf-array-elem-sized.stderr | 13 + .../ui/compile-fail-migration/wf-const-type.rs | 24 + .../ui/compile-fail-migration/wf-const-type.stderr | 16 + .../ui/compile-fail-migration/wf-enum-bound.rs | 26 + .../ui/compile-fail-migration/wf-enum-bound.stderr | 20 + .../wf-enum-fields-struct-variant.rs | 28 + .../wf-enum-fields-struct-variant.stderr | 16 + .../ui/compile-fail-migration/wf-enum-fields.rs | 26 + .../compile-fail-migration/wf-enum-fields.stderr | 16 + .../compile-fail-migration/wf-fn-where-clause.rs | 24 + .../wf-fn-where-clause.stderr | 18 + .../wf-impl-associated-type-region.rs | 24 + .../wf-impl-associated-type-region.stderr | 17 + .../wf-impl-associated-type-trait.rs | 32 + .../wf-impl-associated-type-trait.stderr | 16 + src/test/ui/compile-fail-migration/wf-in-fn-arg.rs | 24 + .../ui/compile-fail-migration/wf-in-fn-arg.stderr | 18 + src/test/ui/compile-fail-migration/wf-in-fn-ret.rs | 24 + .../ui/compile-fail-migration/wf-in-fn-ret.stderr | 18 + .../ui/compile-fail-migration/wf-in-fn-type-arg.rs | 22 + .../wf-in-fn-type-arg.stderr | 16 + .../ui/compile-fail-migration/wf-in-fn-type-ret.rs | 22 + .../wf-in-fn-type-ret.stderr | 16 + .../compile-fail-migration/wf-in-fn-type-static.rs | 32 + .../wf-in-fn-type-static.stderr | 33 + .../wf-in-fn-where-clause.rs | 25 + .../wf-in-fn-where-clause.stderr | 19 + .../wf-in-obj-type-static.rs | 28 + .../wf-in-obj-type-static.stderr | 18 + .../compile-fail-migration/wf-in-obj-type-trait.rs | 24 + .../wf-in-obj-type-trait.stderr | 16 + .../wf-inherent-impl-method-where-clause.rs | 27 + .../wf-inherent-impl-method-where-clause.stderr | 17 + .../wf-inherent-impl-where-clause.rs | 26 + .../wf-inherent-impl-where-clause.stderr | 18 + .../wf-misc-methods-issue-28609.nll.stderr | 111 ++++ .../wf-misc-methods-issue-28609.rs | 84 +++ .../wf-misc-methods-issue-28609.stderr | 111 ++++ .../ui/compile-fail-migration/wf-object-safe.rs | 20 + .../compile-fail-migration/wf-object-safe.stderr | 11 + .../wf-outlives-ty-in-fn-or-trait.rs | 32 + .../wf-outlives-ty-in-fn-or-trait.stderr | 31 + .../wf-static-method.nll.stderr | 54 ++ .../ui/compile-fail-migration/wf-static-method.rs | 64 ++ .../compile-fail-migration/wf-static-method.stderr | 109 +++ .../ui/compile-fail-migration/wf-static-type.rs | 24 + .../compile-fail-migration/wf-static-type.stderr | 16 + .../ui/compile-fail-migration/wf-struct-bound.rs | 26 + .../compile-fail-migration/wf-struct-bound.stderr | 20 + .../ui/compile-fail-migration/wf-struct-field.rs | 26 + .../compile-fail-migration/wf-struct-field.stderr | 16 + .../wf-trait-associated-type-bound.rs | 24 + .../wf-trait-associated-type-bound.stderr | 18 + .../wf-trait-associated-type-region.rs | 24 + .../wf-trait-associated-type-region.stderr | 16 + .../wf-trait-associated-type-trait.rs | 26 + .../wf-trait-associated-type-trait.stderr | 16 + .../ui/compile-fail-migration/wf-trait-bound.rs | 25 + .../compile-fail-migration/wf-trait-bound.stderr | 19 + .../wf-trait-default-fn-arg.rs | 29 + .../wf-trait-default-fn-arg.stderr | 20 + .../wf-trait-default-fn-ret.rs | 29 + .../wf-trait-default-fn-ret.stderr | 21 + .../wf-trait-default-fn-where-clause.rs | 29 + .../wf-trait-default-fn-where-clause.stderr | 20 + .../ui/compile-fail-migration/wf-trait-fn-arg.rs | 26 + .../compile-fail-migration/wf-trait-fn-arg.stderr | 16 + .../ui/compile-fail-migration/wf-trait-fn-ret.rs | 26 + .../compile-fail-migration/wf-trait-fn-ret.stderr | 16 + .../wf-trait-fn-where-clause.rs | 27 + .../wf-trait-fn-where-clause.stderr | 16 + .../compile-fail-migration/wf-trait-superbound.rs | 22 + .../wf-trait-superbound.stderr | 17 + ...ause-constraints-are-local-for-inherent-impl.rs | 28 + ...-constraints-are-local-for-inherent-impl.stderr | 16 + ...-clause-constraints-are-local-for-trait-impl.rs | 33 + ...use-constraints-are-local-for-trait-impl.stderr | 16 + .../where-clause-method-substituion.rs | 32 + .../where-clause-method-substituion.stderr | 9 + .../where-clauses-method-unsatisfied.rs | 30 + .../where-clauses-method-unsatisfied.stderr | 9 + .../where-clauses-unsatisfied.rs | 18 + .../where-clauses-unsatisfied.stderr | 15 + .../where-equality-constraints.rs | 16 + .../where-equality-constraints.stderr | 14 + .../ui/compile-fail-migration/where-for-self-2.rs | 33 + .../compile-fail-migration/where-for-self-2.stderr | 19 + .../ui/compile-fail-migration/where-for-self.rs | 29 + .../compile-fail-migration/where-for-self.stderr | 9 + .../where-lifetime-resolution.rs | 23 + .../where-lifetime-resolution.stderr | 22 + src/test/ui/compile-fail-migration/while-let.rs | 35 + .../ui/compile-fail-migration/while-let.stderr | 21 + .../ui/compile-fail-migration/while-type-error.rs | 13 + .../compile-fail-migration/while-type-error.stderr | 12 + .../windows-subsystem-invalid.rs | 15 + .../windows-subsystem-invalid.stderr | 4 + .../write-to-static-mut-in-static.rs | 22 + .../write-to-static-mut-in-static.stderr | 19 + .../writing-to-immutable-vec.nll.stderr | 11 + .../writing-to-immutable-vec.rs | 15 + .../writing-to-immutable-vec.stderr | 11 + .../wrong-mul-method-signature.rs | 79 +++ .../wrong-mul-method-signature.stderr | 30 + .../ui/compile-fail-migration/wrong-ret-type.rs | 13 + .../compile-fail-migration/wrong-ret-type.stderr | 9 + .../ui/compile-fail-migration/xc-private-method.rs | 21 + .../xc-private-method.stderr | 15 + .../compile-fail-migration/xc-private-method2.rs | 21 + .../xc-private-method2.stderr | 15 + .../xcrate-private-by-default.rs | 55 ++ .../xcrate-private-by-default.stderr | 63 ++ .../compile-fail-migration/xcrate-unit-struct.rs | 22 + .../xcrate-unit-struct.stderr | 9 + 5949 files changed, 121146 insertions(+), 61897 deletions(-) delete mode 100644 src/test/compile-fail/.gitattributes delete mode 100644 src/test/compile-fail/E0501.rs delete mode 100644 src/test/compile-fail/E0506.rs delete mode 100644 src/test/compile-fail/E0508.rs delete mode 100644 src/test/compile-fail/E0583.rs delete mode 100644 src/test/compile-fail/E0594.rs delete mode 100644 src/test/compile-fail/E0596.rs delete mode 100644 src/test/compile-fail/absolute-paths-in-nested-use-groups.rs delete mode 100644 src/test/compile-fail/access-mode-in-closures.rs delete mode 100644 src/test/compile-fail/alloc-error-handler-bad-signature-1.rs delete mode 100644 src/test/compile-fail/alloc-error-handler-bad-signature-2.rs delete mode 100644 src/test/compile-fail/alloc-error-handler-bad-signature-3.rs delete mode 100644 src/test/compile-fail/allocator/auxiliary/system-allocator.rs delete mode 100644 src/test/compile-fail/allocator/auxiliary/system-allocator2.rs delete mode 100644 src/test/compile-fail/allocator/function-allocator.rs delete mode 100644 src/test/compile-fail/allocator/not-an-allocator.rs delete mode 100644 src/test/compile-fail/allocator/two-allocators.rs delete mode 100644 src/test/compile-fail/allocator/two-allocators2.rs delete mode 100644 src/test/compile-fail/allocator/two-allocators3.rs delete mode 100644 src/test/compile-fail/anon-params-deprecated.rs delete mode 100644 src/test/compile-fail/arg-count-mismatch.rs delete mode 100644 src/test/compile-fail/arg-type-mismatch.rs delete mode 100644 src/test/compile-fail/array-not-vector.rs delete mode 100644 src/test/compile-fail/array_const_index-0.rs delete mode 100644 src/test/compile-fail/array_const_index-1.rs delete mode 100644 src/test/compile-fail/asm-bad-clobber.rs delete mode 100644 src/test/compile-fail/asm-in-bad-modifier.rs delete mode 100644 src/test/compile-fail/asm-misplaced-option.rs delete mode 100644 src/test/compile-fail/asm-out-no-modifier.rs delete mode 100644 src/test/compile-fail/asm-out-read-uninit.rs delete mode 100644 src/test/compile-fail/asm-src-loc-codegen-units.rs delete mode 100644 src/test/compile-fail/asm-src-loc.rs delete mode 100644 src/test/compile-fail/assign-imm-local-twice.rs delete mode 100644 src/test/compile-fail/assign-to-method.rs delete mode 100644 src/test/compile-fail/assignment-operator-unimplemented.rs delete mode 100644 src/test/compile-fail/assoc-inherent.rs delete mode 100644 src/test/compile-fail/associated-const-ambiguity-report.rs delete mode 100644 src/test/compile-fail/associated-const-array-len.rs delete mode 100644 src/test/compile-fail/associated-const-dead-code.rs delete mode 100644 src/test/compile-fail/associated-const-generic-obligations.rs delete mode 100644 src/test/compile-fail/associated-const-in-trait.rs delete mode 100644 src/test/compile-fail/associated-const-no-item.rs delete mode 100644 src/test/compile-fail/associated-const-private-impl.rs delete mode 100644 src/test/compile-fail/associated-const-type-parameter-arms.rs delete mode 100644 src/test/compile-fail/associated-const-type-parameter-arrays-2.rs delete mode 100644 src/test/compile-fail/associated-const-type-parameter-arrays.rs delete mode 100644 src/test/compile-fail/associated-const-upper-case-lint.rs delete mode 100644 src/test/compile-fail/associated-item-duplicate-names-2.rs delete mode 100644 src/test/compile-fail/associated-item-duplicate-names-3.rs delete mode 100644 src/test/compile-fail/associated-item-duplicate-names.rs delete mode 100644 src/test/compile-fail/associated-path-shl.rs delete mode 100644 src/test/compile-fail/associated-type-projection-ambig-between-bound-and-where-clause.rs delete mode 100644 src/test/compile-fail/associated-type-projection-from-supertrait.rs delete mode 100644 src/test/compile-fail/associated-types-binding-to-type-defined-in-supertrait.rs delete mode 100644 src/test/compile-fail/associated-types-bound-failure.rs delete mode 100644 src/test/compile-fail/associated-types-coherence-failure.rs delete mode 100644 src/test/compile-fail/associated-types-eq-1.rs delete mode 100644 src/test/compile-fail/associated-types-eq-2.rs delete mode 100644 src/test/compile-fail/associated-types-eq-3.rs delete mode 100644 src/test/compile-fail/associated-types-eq-expr-path.rs delete mode 100644 src/test/compile-fail/associated-types-eq-hr.rs delete mode 100644 src/test/compile-fail/associated-types-for-unimpl-trait.rs delete mode 100644 src/test/compile-fail/associated-types-incomplete-object.rs delete mode 100644 src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs delete mode 100644 src/test/compile-fail/associated-types-issue-17359.rs delete mode 100644 src/test/compile-fail/associated-types-issue-20346.rs delete mode 100644 src/test/compile-fail/associated-types-multiple-types-one-trait.rs delete mode 100644 src/test/compile-fail/associated-types-no-suitable-bound.rs delete mode 100644 src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs delete mode 100644 src/test/compile-fail/associated-types-no-suitable-supertrait.rs delete mode 100644 src/test/compile-fail/associated-types-outlives.rs delete mode 100644 src/test/compile-fail/associated-types-overridden-default.rs delete mode 100644 src/test/compile-fail/associated-types-path-1.rs delete mode 100644 src/test/compile-fail/associated-types-path-2.rs delete mode 100644 src/test/compile-fail/associated-types-project-from-hrtb-in-fn-body.rs delete mode 100644 src/test/compile-fail/associated-types-project-from-hrtb-in-fn.rs delete mode 100644 src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs delete mode 100644 src/test/compile-fail/associated-types-project-from-hrtb-in-trait-method.rs delete mode 100644 src/test/compile-fail/associated-types-projection-to-unrelated-trait-in-method-without-default.rs delete mode 100644 src/test/compile-fail/associated-types-subtyping-1.rs delete mode 100644 src/test/compile-fail/associated-types-unconstrained.rs delete mode 100644 src/test/compile-fail/associated-types-unsized.rs delete mode 100644 src/test/compile-fail/associated-types/bound-lifetime-constrained.rs delete mode 100644 src/test/compile-fail/associated-types/bound-lifetime-in-binding-only.rs delete mode 100644 src/test/compile-fail/associated-types/bound-lifetime-in-return-only.rs delete mode 100644 src/test/compile-fail/associated-types/cache/chrono-scan.rs delete mode 100644 src/test/compile-fail/associated-types/cache/elision.rs delete mode 100644 src/test/compile-fail/associated-types/cache/project-fn-ret-contravariant.rs delete mode 100644 src/test/compile-fail/associated-types/cache/project-fn-ret-invariant.rs delete mode 100644 src/test/compile-fail/associated-types/higher-ranked-projection.rs delete mode 100644 src/test/compile-fail/associated-types/issue-36499.rs delete mode 100644 src/test/compile-fail/attempted-access-non-fatal.rs delete mode 100644 src/test/compile-fail/attr-bad-crate-attr.rc delete mode 100644 src/test/compile-fail/attr-usage-inline.rs delete mode 100644 src/test/compile-fail/attrs-with-no-formal-in-generics-1.rs delete mode 100644 src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs delete mode 100644 src/test/compile-fail/attrs-with-no-formal-in-generics-3.rs delete mode 100644 src/test/compile-fail/auto-ref-slice-plus-ref.rs delete mode 100644 src/test/compile-fail/auto-trait-validation.rs delete mode 100644 src/test/compile-fail/autoderef-full-lval.rs delete mode 100644 src/test/compile-fail/auxiliary/ambig_impl_2_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/cci_class.rs delete mode 100644 src/test/compile-fail/auxiliary/cci_class_5.rs delete mode 100644 src/test/compile-fail/auxiliary/cdylib-dep.rs delete mode 100644 src/test/compile-fail/auxiliary/coherence_copy_like_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/coherence_inherent_cc_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/coherence_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/coherence_orphan_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/const_fn_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/crate_a1.rs delete mode 100644 src/test/compile-fail/auxiliary/crate_a2.rs delete mode 100644 src/test/compile-fail/auxiliary/crateresolve1-1.rs delete mode 100644 src/test/compile-fail/auxiliary/crateresolve1-2.rs delete mode 100644 src/test/compile-fail/auxiliary/crateresolve1-3.rs delete mode 100644 src/test/compile-fail/auxiliary/default_ty_param_cross_crate_crate.rs delete mode 100644 src/test/compile-fail/auxiliary/define_macro.rs delete mode 100644 src/test/compile-fail/auxiliary/deprecation-lint.rs delete mode 100644 src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs delete mode 100644 src/test/compile-fail/auxiliary/empty-struct.rs delete mode 100644 src/test/compile-fail/auxiliary/extern-statics.rs delete mode 100644 src/test/compile-fail/auxiliary/go_trait.rs delete mode 100644 src/test/compile-fail/auxiliary/import_crate_var.rs delete mode 100644 src/test/compile-fail/auxiliary/inherited_stability.rs delete mode 100644 src/test/compile-fail/auxiliary/internal_unstable.rs delete mode 100644 src/test/compile-fail/auxiliary/issue-19163.rs delete mode 100644 src/test/compile-fail/auxiliary/issue-21146-inc.rs delete mode 100644 src/test/compile-fail/auxiliary/issue-29181.rs delete mode 100644 src/test/compile-fail/auxiliary/issue-30535.rs delete mode 100644 src/test/compile-fail/auxiliary/issue-36881-aux.rs delete mode 100644 src/test/compile-fail/auxiliary/issue-52489.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_11680.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_16725.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_17718_const_privacy.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_1920.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_21202.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_30123_aux.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_41549.rs delete mode 100644 src/test/compile-fail/auxiliary/issue_5844_aux.rs delete mode 100644 src/test/compile-fail/auxiliary/lifetime_bound_will_change_warning_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_output_format.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_stability.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_stability_fields.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_unused_extern_crate.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_unused_extern_crate2.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_unused_extern_crate3.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_unused_extern_crate4.rs delete mode 100644 src/test/compile-fail/auxiliary/lint_unused_extern_crate5.rs delete mode 100644 src/test/compile-fail/auxiliary/lto-duplicate-symbols1.rs delete mode 100644 src/test/compile-fail/auxiliary/lto-duplicate-symbols2.rs delete mode 100644 src/test/compile-fail/auxiliary/macro_crate_nonterminal.rs delete mode 100644 src/test/compile-fail/auxiliary/namespace-mix.rs delete mode 100644 src/test/compile-fail/auxiliary/namespaced_enums.rs delete mode 100644 src/test/compile-fail/auxiliary/noexporttypelib.rs delete mode 100644 src/test/compile-fail/auxiliary/orphan_check_diagnostics.rs delete mode 100644 src/test/compile-fail/auxiliary/privacy_tuple_struct.rs delete mode 100644 src/test/compile-fail/auxiliary/private-inferred-type.rs delete mode 100644 src/test/compile-fail/auxiliary/private_trait_xc.rs delete mode 100644 src/test/compile-fail/auxiliary/rbmtp_cross_crate_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/recursive_reexports.rs delete mode 100644 src/test/compile-fail/auxiliary/rmeta_meta.rs delete mode 100644 src/test/compile-fail/auxiliary/rmeta_rlib.rs delete mode 100644 src/test/compile-fail/auxiliary/some-panic-impl.rs delete mode 100644 src/test/compile-fail/auxiliary/stability_attribute_issue.rs delete mode 100644 src/test/compile-fail/auxiliary/stability_cfg1.rs delete mode 100644 src/test/compile-fail/auxiliary/stability_cfg2.rs delete mode 100644 src/test/compile-fail/auxiliary/static_priv_by_default.rs delete mode 100644 src/test/compile-fail/auxiliary/struct_field_privacy.rs delete mode 100644 src/test/compile-fail/auxiliary/struct_variant_privacy.rs delete mode 100644 src/test/compile-fail/auxiliary/tdticc_coherence_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/trait_bounds_on_structs_and_enums_xc.rs delete mode 100644 src/test/compile-fail/auxiliary/trait_impl_conflict.rs delete mode 100644 src/test/compile-fail/auxiliary/trait_safety_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/trait_superkinds_in_metadata.rs delete mode 100644 src/test/compile-fail/auxiliary/two_macros.rs delete mode 100644 src/test/compile-fail/auxiliary/unreachable_variant.rs delete mode 100644 src/test/compile-fail/auxiliary/unstable-macros.rs delete mode 100644 src/test/compile-fail/auxiliary/use_from_trait_xc.rs delete mode 100644 src/test/compile-fail/auxiliary/variant-namespacing.rs delete mode 100644 src/test/compile-fail/auxiliary/weak-lang-items.rs delete mode 100644 src/test/compile-fail/auxiliary/xc_private_method_lib.rs delete mode 100644 src/test/compile-fail/auxiliary/xcrate_unit_struct.rs delete mode 100644 src/test/compile-fail/bad-const-type.rs delete mode 100644 src/test/compile-fail/bad-env-capture.rs delete mode 100644 src/test/compile-fail/bad-env-capture2.rs delete mode 100644 src/test/compile-fail/bad-env-capture3.rs delete mode 100644 src/test/compile-fail/bad-expr-lhs.rs delete mode 100644 src/test/compile-fail/bad-expr-path.rs delete mode 100644 src/test/compile-fail/bad-expr-path2.rs delete mode 100644 src/test/compile-fail/bad-extern-link-attrs.rs delete mode 100644 src/test/compile-fail/bad-intrinsic-monomorphization.rs delete mode 100644 src/test/compile-fail/bad-lint-cap.rs delete mode 100644 src/test/compile-fail/bad-lint-cap2.rs delete mode 100644 src/test/compile-fail/bad-lint-cap3.rs delete mode 100644 src/test/compile-fail/bad-main.rs delete mode 100644 src/test/compile-fail/bad-method-typaram-kind.rs delete mode 100644 src/test/compile-fail/bad-mid-path-type-params.rs delete mode 100644 src/test/compile-fail/bad-module.rs delete mode 100644 src/test/compile-fail/bad-sized.rs delete mode 100644 src/test/compile-fail/bad-type-env-capture.rs delete mode 100644 src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs delete mode 100644 src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs delete mode 100644 src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs delete mode 100644 src/test/compile-fail/bind-by-move-no-guards.rs delete mode 100644 src/test/compile-fail/binop-bitxor-str.rs delete mode 100644 src/test/compile-fail/binop-consume-args.rs delete mode 100644 src/test/compile-fail/binop-logic-float.rs delete mode 100644 src/test/compile-fail/binop-logic-int.rs delete mode 100644 src/test/compile-fail/binop-move-semantics.rs delete mode 100644 src/test/compile-fail/binop-mul-bool.rs delete mode 100644 src/test/compile-fail/binop-typeck.rs delete mode 100644 src/test/compile-fail/blind-item-block-item-shadow.rs delete mode 100644 src/test/compile-fail/blind-item-block-middle.rs delete mode 100644 src/test/compile-fail/borrow-immutable-upvar-mutation.rs delete mode 100644 src/test/compile-fail/borrow-tuple-fields.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-access-permissions.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-and-init.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-anon-fields-struct.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-anon-fields-tuple.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-anon-fields-variant.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-argument.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-asm.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-assign-comp-idx.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-assign-comp.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-auto-mut-ref-to-immut-var.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-autoref-3261.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-bad-nested-calls-free.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-bad-nested-calls-move.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-block-unint.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-from-owned-ptr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-from-stack-variable.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-mut-object-twice.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-overloaded-auto-deref.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrow-overloaded-deref.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue-2.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-break-uninit-2.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-break-uninit.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-closures-mut-of-imm.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-closures-two-mut.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-closures-unique-imm.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-closures-unique.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-closures-use-after-free.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-consume-unsize-vec.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-consume-upcast-box.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-drop-from-guard.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-field-sensitivity.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-fn-in-const-a.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-fn-in-const-c.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-for-loop-head-linkage.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-if-no-else.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-if-with-else.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-init-in-called-fn-expr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-init-in-fn-expr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-init-in-fru.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-init-op-equal.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-init-plus-equal.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-insert-during-each.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-issue-14498.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-issue-2657-1.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-issue-2657-2.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-issue-48962.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-lend-flow-if.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-lend-flow.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-blocks-move-cc.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-blocks-move.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-blocks-mut-uniq.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-in-overloaded-op.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-of-static-data-issue-27616.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-rcvr-overloaded-op.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-rcvr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-loan-vec-content.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-by-capture.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-in-irrefut-pat.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-moved-value-into-closure.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-mut-base-ptr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-out-from-array.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-deref.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-out-of-static-item.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-out-of-struct-with-dtor.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-move-subcomponent.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-multiple-captures.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-mut-addr-of-imm-var.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-mut-borrow-linear-errors.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-mut-slice-of-imm-vec.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-mutate-in-guard.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-no-cycle-in-exchange-heap.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-object-lifetime.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-or-init.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-overloaded-call.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-overloaded-index-autoderef.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-overloaded-index-move-from-vec.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-overloaded-index-move-index.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-partial-reinit-1.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-partial-reinit-2.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-partial-reinit-3.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-partial-reinit-4.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-reborrow-from-mut.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-ref-mut-of-imm.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-return-variable-on-stack-via-clone.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-return.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-storage-dead.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-struct-update-with-dtor.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-swap-mut-base-ptr.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-unary-move.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-uninit-after-item.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-uninit-field-access.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-uninit-in-assignop.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-uninit-ref-chain.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-uninit.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-union-borrow.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-union-move-assign.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-union-move.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-union-uninitialized.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-uniq-via-lend.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-use-in-index-lvalue.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-use-mut-borrow.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast-trait.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-vec-pattern-element-loan.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-vec-pattern-loan-from-mut.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-vec-pattern-tail-element-loan.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-while-break.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-while-cond.rs delete mode 100644 src/test/compile-fail/borrowck/borrowck-while.rs delete mode 100644 src/test/compile-fail/borrowck/move-in-static-initializer-issue-38520.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-across-loop.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-cannot-nest-mut-self-calls.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference-2.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs delete mode 100644 src/test/compile-fail/borrowck/two-phase-sneaky.rs delete mode 100644 src/test/compile-fail/bounds-lifetime.rs delete mode 100644 src/test/compile-fail/break-outside-loop.rs delete mode 100644 src/test/compile-fail/builtin-superkinds-double-superkind.rs delete mode 100644 src/test/compile-fail/builtin-superkinds-in-metadata.rs delete mode 100644 src/test/compile-fail/builtin-superkinds-self-type.rs delete mode 100644 src/test/compile-fail/builtin-superkinds-simple.rs delete mode 100644 src/test/compile-fail/builtin-superkinds-typaram-not-send.rs delete mode 100644 src/test/compile-fail/by-move-pattern-binding.rs delete mode 100644 src/test/compile-fail/call-fn-never-arg-wrong-type.rs delete mode 100644 src/test/compile-fail/can-begin-expr-check.rs delete mode 100644 src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs delete mode 100644 src/test/compile-fail/capture1.rs delete mode 100644 src/test/compile-fail/cast-from-nil.rs delete mode 100644 src/test/compile-fail/cast-ptr-to-int-const.rs delete mode 100644 src/test/compile-fail/cast-to-bare-fn.rs delete mode 100644 src/test/compile-fail/cast-to-nil.rs delete mode 100644 src/test/compile-fail/catch-bad-lifetime.rs delete mode 100644 src/test/compile-fail/catch-bad-type.rs delete mode 100644 src/test/compile-fail/catch-in-match.rs delete mode 100644 src/test/compile-fail/catch-in-while.rs delete mode 100644 src/test/compile-fail/catch-maybe-bad-lifetime.rs delete mode 100644 src/test/compile-fail/catch-opt-init.rs delete mode 100644 src/test/compile-fail/cdylib-deps-must-be-static.rs delete mode 100644 src/test/compile-fail/cfg-arg-invalid.rs delete mode 100644 src/test/compile-fail/cfg-attr-cfg-2.rs delete mode 100644 src/test/compile-fail/cfg-attr-crate-2.rs delete mode 100644 src/test/compile-fail/cfg-attr-invalid-predicate.rs delete mode 100644 src/test/compile-fail/cfg-attr-unknown-attribute-macro-expansion.rs delete mode 100644 src/test/compile-fail/cfg-empty-codemap.rs delete mode 100644 src/test/compile-fail/cfg-in-crate-1.rs delete mode 100644 src/test/compile-fail/cfg-non-opt-expr.rs delete mode 100644 src/test/compile-fail/cfg_attr_path.rs delete mode 100644 src/test/compile-fail/check-static-immutable-mut-slices.rs delete mode 100644 src/test/compile-fail/check-static-values-constraints.rs delete mode 100644 src/test/compile-fail/class-cast-to-trait.rs delete mode 100644 src/test/compile-fail/class-method-missing.rs delete mode 100644 src/test/compile-fail/class-missing-self.rs delete mode 100644 src/test/compile-fail/cleanup-rvalue-scopes-cf.rs delete mode 100644 src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs delete mode 100644 src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs delete mode 100644 src/test/compile-fail/closure-bounds-subtype.rs delete mode 100644 src/test/compile-fail/closure-expected-type/README.md delete mode 100644 src/test/compile-fail/closure-expected-type/expect-fn-supply-fn-multiple.rs delete mode 100644 src/test/compile-fail/closure-expected-type/expect-fn-supply-fn.rs delete mode 100644 src/test/compile-fail/closure-expected-type/expect-infer-var-appearing-twice.rs delete mode 100644 src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs delete mode 100644 src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs delete mode 100644 src/test/compile-fail/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs delete mode 100644 src/test/compile-fail/closure-no-fn-1.rs delete mode 100644 src/test/compile-fail/closure-no-fn-2.rs delete mode 100644 src/test/compile-fail/closure-no-fn-3.rs delete mode 100644 src/test/compile-fail/closure-referencing-itself-issue-25954.rs delete mode 100644 src/test/compile-fail/closure-reform-bad.rs delete mode 100644 src/test/compile-fail/closure-wrong-kind.rs delete mode 100644 src/test/compile-fail/closure_promotion.rs delete mode 100644 src/test/compile-fail/coerce-expect-unsized-ascribed.rs delete mode 100644 src/test/compile-fail/coerce-mut.rs delete mode 100644 src/test/compile-fail/coerce-overloaded-autoderef.rs delete mode 100644 src/test/compile-fail/coerce-to-bang-cast.rs delete mode 100644 src/test/compile-fail/coerce-to-bang.rs delete mode 100644 src/test/compile-fail/coerce-unsafe-to-closure.rs delete mode 100644 src/test/compile-fail/coercion-slice.rs delete mode 100644 src/test/compile-fail/coherence-all-remote.rs delete mode 100644 src/test/compile-fail/coherence-bigint-param.rs delete mode 100644 src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs delete mode 100644 src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs delete mode 100644 src/test/compile-fail/coherence-blanket-conflicts-with-specific-cross-crate.rs delete mode 100644 src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs delete mode 100644 src/test/compile-fail/coherence-blanket-conflicts-with-specific-trait.rs delete mode 100644 src/test/compile-fail/coherence-blanket-conflicts-with-specific.rs delete mode 100644 src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs delete mode 100644 src/test/compile-fail/coherence-cow.rs delete mode 100644 src/test/compile-fail/coherence-cross-crate-conflict.rs delete mode 100644 src/test/compile-fail/coherence-default-trait-impl.rs delete mode 100644 src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs delete mode 100644 src/test/compile-fail/coherence-impl-trait-for-trait.rs delete mode 100644 src/test/compile-fail/coherence-impls-send.rs delete mode 100644 src/test/compile-fail/coherence-impls-sized.rs delete mode 100644 src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs delete mode 100644 src/test/compile-fail/coherence-lone-type-parameter.rs delete mode 100644 src/test/compile-fail/coherence-negative-impls-safe.rs delete mode 100644 src/test/compile-fail/coherence-no-direct-lifetime-dispatch.rs delete mode 100644 src/test/compile-fail/coherence-orphan.rs delete mode 100644 src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs delete mode 100644 src/test/compile-fail/coherence-overlap-messages.rs delete mode 100644 src/test/compile-fail/coherence-overlapping-pairs.rs delete mode 100644 src/test/compile-fail/coherence-pair-covered-uncovered-1.rs delete mode 100644 src/test/compile-fail/coherence-pair-covered-uncovered.rs delete mode 100644 src/test/compile-fail/coherence-projection-conflict-orphan.rs delete mode 100644 src/test/compile-fail/coherence-projection-conflict-ty-param.rs delete mode 100644 src/test/compile-fail/coherence-projection-conflict.rs delete mode 100644 src/test/compile-fail/coherence-projection-ok-orphan.rs delete mode 100644 src/test/compile-fail/coherence-projection-ok.rs delete mode 100644 src/test/compile-fail/coherence-tuple-conflict.rs delete mode 100644 src/test/compile-fail/coherence-vec-local-2.rs delete mode 100644 src/test/compile-fail/coherence-vec-local.rs delete mode 100644 src/test/compile-fail/coherence_copy_like_err_fundamental_struct.rs delete mode 100644 src/test/compile-fail/coherence_copy_like_err_fundamental_struct_ref.rs delete mode 100644 src/test/compile-fail/coherence_copy_like_err_fundamental_struct_tuple.rs delete mode 100644 src/test/compile-fail/coherence_copy_like_err_struct.rs delete mode 100644 src/test/compile-fail/coherence_copy_like_err_tuple.rs delete mode 100644 src/test/compile-fail/coherence_inherent.rs delete mode 100644 src/test/compile-fail/coherence_inherent_cc.rs delete mode 100644 src/test/compile-fail/coherence_local.rs delete mode 100644 src/test/compile-fail/coherence_local_err_struct.rs delete mode 100644 src/test/compile-fail/coherence_local_err_tuple.rs delete mode 100644 src/test/compile-fail/coherence_local_ref.rs delete mode 100644 src/test/compile-fail/compile_error_macro.rs delete mode 100644 src/test/compile-fail/concat.rs delete mode 100644 src/test/compile-fail/conflicting-repr-hints.rs delete mode 100644 src/test/compile-fail/conservative_impl_trait.rs delete mode 100644 src/test/compile-fail/const-array-oob-arith.rs delete mode 100644 src/test/compile-fail/const-array-oob.rs delete mode 100644 src/test/compile-fail/const-block-non-item-statement-2.rs delete mode 100644 src/test/compile-fail/const-block-non-item-statement-3.rs delete mode 100644 src/test/compile-fail/const-block-non-item-statement.rs delete mode 100644 src/test/compile-fail/const-call.rs delete mode 100644 src/test/compile-fail/const-cast-different-types.rs delete mode 100644 src/test/compile-fail/const-cast-wrong-type.rs delete mode 100644 src/test/compile-fail/const-err-early.rs delete mode 100644 src/test/compile-fail/const-err-multi.rs delete mode 100644 src/test/compile-fail/const-err.rs delete mode 100644 src/test/compile-fail/const-err2.rs delete mode 100644 src/test/compile-fail/const-err3.rs delete mode 100644 src/test/compile-fail/const-err4.rs delete mode 100644 src/test/compile-fail/const-eval-overflow-3.rs delete mode 100644 src/test/compile-fail/const-eval-overflow-3b.rs delete mode 100644 src/test/compile-fail/const-eval-overflow-4b.rs delete mode 100644 src/test/compile-fail/const-eval-overflow2.rs delete mode 100644 src/test/compile-fail/const-eval-overflow2b.rs delete mode 100644 src/test/compile-fail/const-eval-overflow2c.rs delete mode 100644 src/test/compile-fail/const-fn-destructuring-arg.rs delete mode 100644 src/test/compile-fail/const-fn-not-safe-for-const.rs delete mode 100644 src/test/compile-fail/const-fn-stability-calls-3.rs delete mode 100644 src/test/compile-fail/const-integer-bool-ops.rs delete mode 100644 src/test/compile-fail/const-len-underflow-subspans.rs delete mode 100644 src/test/compile-fail/const-match-check.rs delete mode 100644 src/test/compile-fail/const-match-pattern-arm.rs delete mode 100644 src/test/compile-fail/const-size_of-cycle.rs delete mode 100644 src/test/compile-fail/const-slice-oob.rs delete mode 100644 src/test/compile-fail/const-tup-index-span.rs delete mode 100644 src/test/compile-fail/const-typeid-of.rs delete mode 100644 src/test/compile-fail/constructor-lifetime-args.rs delete mode 100644 src/test/compile-fail/copy-a-resource.rs delete mode 100644 src/test/compile-fail/crate-name-mismatch.rs delete mode 100644 src/test/compile-fail/crateresolve1.rs delete mode 100644 src/test/compile-fail/cross-borrow-trait.rs delete mode 100644 src/test/compile-fail/cross-fn-cache-hole.rs delete mode 100644 src/test/compile-fail/custom_attribute.rs delete mode 100644 src/test/compile-fail/cycle-projection-based-on-where-clause.rs delete mode 100644 src/test/compile-fail/cycle-trait-default-type-trait.rs delete mode 100644 src/test/compile-fail/cycle-trait-supertrait-direct.rs delete mode 100644 src/test/compile-fail/dead-code-closure-bang.rs delete mode 100644 src/test/compile-fail/dead-code-ret.rs delete mode 100644 src/test/compile-fail/defaulted-never-note.rs delete mode 100644 src/test/compile-fail/dep-graph-assoc-type-codegen.rs delete mode 100644 src/test/compile-fail/dep-graph-caller-callee.rs delete mode 100644 src/test/compile-fail/dep-graph-struct-signature.rs delete mode 100644 src/test/compile-fail/dep-graph-trait-impl-two-traits-same-method.rs delete mode 100644 src/test/compile-fail/dep-graph-trait-impl-two-traits.rs delete mode 100644 src/test/compile-fail/dep-graph-trait-impl.rs delete mode 100644 src/test/compile-fail/dep-graph-type-alias.rs delete mode 100644 src/test/compile-fail/dep-graph-variance-alias.rs delete mode 100644 src/test/compile-fail/deprecated_no_stack_check.rs delete mode 100644 src/test/compile-fail/deprecation-in-staged-api.rs delete mode 100644 src/test/compile-fail/deprecation-lint-2.rs delete mode 100644 src/test/compile-fail/deprecation-lint-3.rs delete mode 100644 src/test/compile-fail/deprecation-lint-nested.rs delete mode 100644 src/test/compile-fail/deprecation-lint.rs delete mode 100644 src/test/compile-fail/deref-non-pointer.rs delete mode 100644 src/test/compile-fail/derive-assoc-type-not-impl.rs delete mode 100644 src/test/compile-fail/derive-on-trait-item-or-impl-item.rs delete mode 100644 src/test/compile-fail/derived-errors/issue-30580.rs delete mode 100644 src/test/compile-fail/derived-errors/issue-31997.rs delete mode 100644 src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs delete mode 100644 src/test/compile-fail/derives-span-Clone-enum.rs delete mode 100644 src/test/compile-fail/derives-span-Clone-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Clone-tuple-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs delete mode 100644 src/test/compile-fail/derives-span-Debug-enum.rs delete mode 100644 src/test/compile-fail/derives-span-Debug-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Debug-tuple-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Default-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Default-tuple-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs delete mode 100644 src/test/compile-fail/derives-span-Eq-enum.rs delete mode 100644 src/test/compile-fail/derives-span-Eq-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Eq-tuple-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs delete mode 100644 src/test/compile-fail/derives-span-Hash-enum.rs delete mode 100644 src/test/compile-fail/derives-span-Hash-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Hash-tuple-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs delete mode 100644 src/test/compile-fail/derives-span-Ord-enum.rs delete mode 100644 src/test/compile-fail/derives-span-Ord-struct.rs delete mode 100644 src/test/compile-fail/derives-span-Ord-tuple-struct.rs delete mode 100644 src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs delete mode 100644 src/test/compile-fail/derives-span-PartialEq-enum.rs delete mode 100644 src/test/compile-fail/derives-span-PartialEq-struct.rs delete mode 100644 src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs delete mode 100644 src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs delete mode 100644 src/test/compile-fail/derives-span-PartialOrd-enum.rs delete mode 100644 src/test/compile-fail/derives-span-PartialOrd-struct.rs delete mode 100644 src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs delete mode 100644 src/test/compile-fail/deriving-bounds.rs delete mode 100644 src/test/compile-fail/deriving-copyclone.rs delete mode 100644 src/test/compile-fail/deriving-meta-unknown-trait.rs delete mode 100644 src/test/compile-fail/deriving-no-inner-impl-error-message.rs delete mode 100644 src/test/compile-fail/deriving-non-type.rs delete mode 100644 src/test/compile-fail/deriving-primitive.rs delete mode 100644 src/test/compile-fail/destructure-trait-ref.rs delete mode 100644 src/test/compile-fail/directory_ownership/foo/compiletest-ignore-dir delete mode 100644 src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs delete mode 100644 src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs delete mode 100644 src/test/compile-fail/directory_ownership/macro-expanded-mod.rs delete mode 100644 src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs delete mode 100644 src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs delete mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning.rs delete mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs delete mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir delete mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs delete mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs delete mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux3.rs delete mode 100644 src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs delete mode 100644 src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs delete mode 100644 src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs delete mode 100644 src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs delete mode 100644 src/test/compile-fail/discrim-ill-typed.rs delete mode 100644 src/test/compile-fail/diverging-fn-tail-35849.rs delete mode 100644 src/test/compile-fail/diverging-tuple-parts-39485.rs delete mode 100644 src/test/compile-fail/does-nothing.rs delete mode 100644 src/test/compile-fail/dollar-crate-is-keyword-2.rs delete mode 100644 src/test/compile-fail/dollar-crate-is-keyword.rs delete mode 100644 src/test/compile-fail/double-type-import.rs delete mode 100644 src/test/compile-fail/drop-on-non-struct.rs delete mode 100644 src/test/compile-fail/drop-with-active-borrows-1.rs delete mode 100644 src/test/compile-fail/drop-with-active-borrows-2.rs delete mode 100644 src/test/compile-fail/dropck_no_diverge_on_nonregular_1.rs delete mode 100644 src/test/compile-fail/dropck_no_diverge_on_nonregular_2.rs delete mode 100644 src/test/compile-fail/dropck_no_diverge_on_nonregular_3.rs delete mode 100644 src/test/compile-fail/dropck_trait_cycle_checked.rs delete mode 100644 src/test/compile-fail/dst-bad-assign-2.rs delete mode 100644 src/test/compile-fail/dst-bad-assign-3.rs delete mode 100644 src/test/compile-fail/dst-bad-assign.rs delete mode 100644 src/test/compile-fail/dst-bad-coerce1.rs delete mode 100644 src/test/compile-fail/dst-bad-coerce2.rs delete mode 100644 src/test/compile-fail/dst-bad-coerce3.rs delete mode 100644 src/test/compile-fail/dst-bad-coerce4.rs delete mode 100644 src/test/compile-fail/dst-bad-coercions.rs delete mode 100644 src/test/compile-fail/dst-bad-deep-2.rs delete mode 100644 src/test/compile-fail/dst-bad-deep.rs delete mode 100644 src/test/compile-fail/dst-index.rs delete mode 100644 src/test/compile-fail/dst-object-from-unsized-type.rs delete mode 100644 src/test/compile-fail/dst-rvalue.rs delete mode 100644 src/test/compile-fail/dst-sized-trait-param.rs delete mode 100644 src/test/compile-fail/dupe-symbols-1.rs delete mode 100644 src/test/compile-fail/dupe-symbols-2.rs delete mode 100644 src/test/compile-fail/dupe-symbols-3.rs delete mode 100644 src/test/compile-fail/dupe-symbols-4.rs delete mode 100644 src/test/compile-fail/dupe-symbols-5.rs delete mode 100644 src/test/compile-fail/dupe-symbols-6.rs delete mode 100644 src/test/compile-fail/dupe-symbols-7.rs delete mode 100644 src/test/compile-fail/duplicate-parameter.rs delete mode 100644 src/test/compile-fail/duplicate-type-parameter.rs delete mode 100644 src/test/compile-fail/duplicate_entry_error.rs delete mode 100644 src/test/compile-fail/dyn-trait-compatibility.rs delete mode 100644 src/test/compile-fail/edition-extern-crate-allowed.rs delete mode 100644 src/test/compile-fail/edition-feature-ok.rs delete mode 100644 src/test/compile-fail/edition-raw-pointer-method-2015.rs delete mode 100644 src/test/compile-fail/edition-raw-pointer-method-2018.rs delete mode 100644 src/test/compile-fail/elided-test.rs delete mode 100644 src/test/compile-fail/empty-comment.rs delete mode 100644 src/test/compile-fail/empty-extern-arg.rs delete mode 100644 src/test/compile-fail/empty-linkname.rs delete mode 100644 src/test/compile-fail/empty-macro-use.rs delete mode 100644 src/test/compile-fail/empty-never-array.rs delete mode 100644 src/test/compile-fail/empty-struct-braces-expr.rs delete mode 100644 src/test/compile-fail/empty-struct-braces-pat-1.rs delete mode 100644 src/test/compile-fail/empty-struct-braces-pat-2.rs delete mode 100644 src/test/compile-fail/empty-struct-braces-pat-3.rs delete mode 100644 src/test/compile-fail/empty-struct-tuple-pat.rs delete mode 100644 src/test/compile-fail/empty-struct-unit-pat.rs delete mode 100644 src/test/compile-fail/enable-unstable-lib-feature.rs delete mode 100644 src/test/compile-fail/enum-discrim-autosizing.rs delete mode 100644 src/test/compile-fail/enum-discrim-too-small.rs delete mode 100644 src/test/compile-fail/enum-discrim-too-small2.rs delete mode 100644 src/test/compile-fail/enum-in-scope.rs delete mode 100644 src/test/compile-fail/enum-to-float-cast-2.rs delete mode 100644 src/test/compile-fail/enum-to-float-cast.rs delete mode 100644 src/test/compile-fail/enum-variant-type-2.rs delete mode 100644 src/test/compile-fail/enums-pats-not-idents.rs delete mode 100644 src/test/compile-fail/error-should-say-copy-not-pod.rs delete mode 100644 src/test/compile-fail/estr-subtyping.rs delete mode 100644 src/test/compile-fail/eval-enum.rs delete mode 100644 src/test/compile-fail/exclusive-drop-and-copy.rs delete mode 100644 src/test/compile-fail/exclusive_range_pattern_syntax_collision.rs delete mode 100644 src/test/compile-fail/exclusive_range_pattern_syntax_collision2.rs delete mode 100644 src/test/compile-fail/exclusive_range_pattern_syntax_collision3.rs delete mode 100644 src/test/compile-fail/expanded-cfg.rs delete mode 100644 src/test/compile-fail/explicit-call-to-dtor.rs delete mode 100644 src/test/compile-fail/explicit-call-to-supertrait-dtor.rs delete mode 100644 src/test/compile-fail/explicit-self-lifetime-mismatch.rs delete mode 100644 src/test/compile-fail/export-fully-qualified.rs delete mode 100644 src/test/compile-fail/export-import.rs delete mode 100644 src/test/compile-fail/export-tag-variant.rs delete mode 100644 src/test/compile-fail/export.rs delete mode 100644 src/test/compile-fail/export2.rs delete mode 100644 src/test/compile-fail/expr_attr_paren_order.rs delete mode 100644 src/test/compile-fail/ext-nonexistent.rs delete mode 100644 src/test/compile-fail/extenv-arg-2-not-string-literal.rs delete mode 100644 src/test/compile-fail/extenv-no-args.rs delete mode 100644 src/test/compile-fail/extenv-not-defined-custom.rs delete mode 100644 src/test/compile-fail/extenv-not-defined-default.rs delete mode 100644 src/test/compile-fail/extenv-not-string-literal.rs delete mode 100644 src/test/compile-fail/extenv-too-many-args.rs delete mode 100644 src/test/compile-fail/extern-crate-visibility.rs delete mode 100644 src/test/compile-fail/extern-macro.rs delete mode 100644 src/test/compile-fail/extern-main-fn.rs delete mode 100644 src/test/compile-fail/extern-types-distinct-types.rs delete mode 100644 src/test/compile-fail/extern-types-not-sync-send.rs delete mode 100644 src/test/compile-fail/extern-types-unsized.rs delete mode 100644 src/test/compile-fail/extern-with-type-bounds.rs delete mode 100644 src/test/compile-fail/extern-wrong-value-type.rs delete mode 100644 src/test/compile-fail/external-doc-error.rs delete mode 100644 src/test/compile-fail/extoption_env-no-args.rs delete mode 100644 src/test/compile-fail/extoption_env-not-string-literal.rs delete mode 100644 src/test/compile-fail/extoption_env-too-many-args.rs delete mode 100644 src/test/compile-fail/fail-no-dead-code-core.rs delete mode 100644 src/test/compile-fail/fail-no-dead-code.rs delete mode 100644 src/test/compile-fail/fail-simple.rs delete mode 100644 src/test/compile-fail/feature-gate-alloc-error-handler.rs delete mode 100644 src/test/compile-fail/feature-gate-panic-implementation.rs delete mode 100644 src/test/compile-fail/feature-gate-tool_lints.rs delete mode 100644 src/test/compile-fail/feature-gate-without_gate_irrefutable_pattern.rs delete mode 100644 src/test/compile-fail/feature-gated-feature-in-macro-arg.rs delete mode 100644 src/test/compile-fail/float-literal-inference-restrictions.rs delete mode 100644 src/test/compile-fail/fn-bad-block-type.rs delete mode 100644 src/test/compile-fail/fn-compare-mismatch.rs delete mode 100644 src/test/compile-fail/fn-item-type.rs delete mode 100644 src/test/compile-fail/fn-trait-formatting.rs delete mode 100644 src/test/compile-fail/for-expn.rs delete mode 100644 src/test/compile-fail/for-loop-bogosity.rs delete mode 100644 src/test/compile-fail/for-loop-refutable-pattern-error-message.rs delete mode 100644 src/test/compile-fail/for-loop-type-error.rs delete mode 100644 src/test/compile-fail/for-loop-unconstrained-element-type.rs delete mode 100644 src/test/compile-fail/foreign-fn-return-lifetime.rs delete mode 100644 src/test/compile-fail/foreign-unsafe-fn-called.rs delete mode 100644 src/test/compile-fail/fully-qualified-type-name1.rs delete mode 100644 src/test/compile-fail/fully-qualified-type-name2.rs delete mode 100644 src/test/compile-fail/fully-qualified-type-name3.rs delete mode 100644 src/test/compile-fail/fully-qualified-type-name4.rs delete mode 100644 src/test/compile-fail/functional-struct-update-noncopyable.rs delete mode 100644 src/test/compile-fail/functional-struct-update-respects-privacy.rs delete mode 100644 src/test/compile-fail/future-incompatible-lint-group.rs delete mode 100644 src/test/compile-fail/gated-attr-literals.rs delete mode 100644 src/test/compile-fail/gated-bad-feature.rs delete mode 100644 src/test/compile-fail/generator-yielding-or-returning-itself.rs delete mode 100644 src/test/compile-fail/generic-extern-lifetime.rs delete mode 100644 src/test/compile-fail/generic-extern.rs delete mode 100644 src/test/compile-fail/generic-impl-less-params-with-defaults.rs delete mode 100644 src/test/compile-fail/generic-impl-more-params-with-defaults.rs delete mode 100644 src/test/compile-fail/generic-lifetime-trait-impl.rs delete mode 100644 src/test/compile-fail/generic-no-mangle.rs delete mode 100644 src/test/compile-fail/generic-non-trailing-defaults.rs delete mode 100644 src/test/compile-fail/generic-type-params-forward-mention.rs delete mode 100644 src/test/compile-fail/generic-type-params-name-repr.rs delete mode 100644 src/test/compile-fail/glob-cycles.rs delete mode 100644 src/test/compile-fail/glob-resolve1.rs delete mode 100644 src/test/compile-fail/hashmap-iter-value-lifetime.rs delete mode 100644 src/test/compile-fail/hashmap-lifetimes.rs delete mode 100644 src/test/compile-fail/hidden-rt-injection.rs delete mode 100644 src/test/compile-fail/hidden-rt-injection2.rs delete mode 100644 src/test/compile-fail/hr-subtype.rs delete mode 100644 src/test/compile-fail/hrtb-conflate-regions.rs delete mode 100644 src/test/compile-fail/hrtb-debruijn-in-receiver.rs delete mode 100644 src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs delete mode 100644 src/test/compile-fail/hrtb-higher-ranker-supertraits.rs delete mode 100644 src/test/compile-fail/hrtb-identity-fn-borrows.rs delete mode 100644 src/test/compile-fail/hrtb-just-for-static.rs delete mode 100644 src/test/compile-fail/hrtb-perfect-forwarding.rs delete mode 100644 src/test/compile-fail/huge-array-simple.rs delete mode 100644 src/test/compile-fail/huge-array.rs delete mode 100644 src/test/compile-fail/huge-enum.rs delete mode 100644 src/test/compile-fail/huge-struct.rs delete mode 100644 src/test/compile-fail/hygienic-label-1.rs delete mode 100644 src/test/compile-fail/hygienic-label-2.rs delete mode 100644 src/test/compile-fail/hygienic-label-3.rs delete mode 100644 src/test/compile-fail/hygienic-label-4.rs delete mode 100644 src/test/compile-fail/if-branch-types.rs delete mode 100644 src/test/compile-fail/if-let.rs delete mode 100644 src/test/compile-fail/if-loop.rs delete mode 100644 src/test/compile-fail/if-typeck.rs delete mode 100644 src/test/compile-fail/if-without-else-result.rs delete mode 100644 src/test/compile-fail/ifmt-bad-format-args.rs delete mode 100644 src/test/compile-fail/ifmt-unimpl.rs delete mode 100644 src/test/compile-fail/ifmt-unknown-trait.rs delete mode 100644 src/test/compile-fail/illegal-ufcs-drop.rs delete mode 100644 src/test/compile-fail/immut-function-arguments.rs delete mode 100644 src/test/compile-fail/impl-bounds-checking.rs delete mode 100644 src/test/compile-fail/impl-trait/impl-generic-mismatch-ab.rs delete mode 100644 src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs delete mode 100644 src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs delete mode 100644 src/test/compile-fail/impl-trait/needs_least_region_or_bound.rs delete mode 100644 src/test/compile-fail/impl-trait/no-trait.rs delete mode 100644 src/test/compile-fail/impl-trait/type_parameters_captured.rs delete mode 100644 src/test/compile-fail/impl-trait/where-allowed.rs delete mode 100644 src/test/compile-fail/impl-unused-tps-inherent.rs delete mode 100644 src/test/compile-fail/impl-unused-tps.rs delete mode 100644 src/test/compile-fail/implicit-method-bind.rs delete mode 100644 src/test/compile-fail/import-crate-var.rs delete mode 100644 src/test/compile-fail/import-from-missing.rs delete mode 100644 src/test/compile-fail/import-glob-0.rs delete mode 100644 src/test/compile-fail/import-glob-circular.rs delete mode 100644 src/test/compile-fail/import-loop-2.rs delete mode 100644 src/test/compile-fail/import-loop.rs delete mode 100644 src/test/compile-fail/import-prefix-macro-1.rs delete mode 100644 src/test/compile-fail/import-prefix-macro-2.rs delete mode 100644 src/test/compile-fail/import-trait-method.rs delete mode 100644 src/test/compile-fail/import.rs delete mode 100644 src/test/compile-fail/import2.rs delete mode 100644 src/test/compile-fail/import3.rs delete mode 100644 src/test/compile-fail/import4.rs delete mode 100644 src/test/compile-fail/imports/reexports.rs delete mode 100644 src/test/compile-fail/imports/unused-macro-use.rs delete mode 100644 src/test/compile-fail/imports/unused.rs delete mode 100644 src/test/compile-fail/inaccessible-test-modules.rs delete mode 100644 src/test/compile-fail/index-bot.rs delete mode 100644 src/test/compile-fail/index_message.rs delete mode 100644 src/test/compile-fail/indexing-requires-a-uint.rs delete mode 100644 src/test/compile-fail/infinite-autoderef.rs delete mode 100644 src/test/compile-fail/infinite-instantiation.rs delete mode 100644 src/test/compile-fail/infinite-macro-expansion.rs delete mode 100644 src/test/compile-fail/infinite-tag-type-recursion.rs delete mode 100644 src/test/compile-fail/infinite-vec-type-recursion.rs delete mode 100644 src/test/compile-fail/inhabitedness-infinite-loop.rs delete mode 100644 src/test/compile-fail/init-unsafe.rs delete mode 100644 src/test/compile-fail/inner-static-type-parameter.rs delete mode 100644 src/test/compile-fail/integer-literal-suffix-inference.rs delete mode 100644 src/test/compile-fail/integral-indexing.rs delete mode 100644 src/test/compile-fail/integral-variable-unification-error.rs delete mode 100644 src/test/compile-fail/internal-unstable-noallow.rs delete mode 100644 src/test/compile-fail/internal-unstable-thread-local.rs delete mode 100644 src/test/compile-fail/internal-unstable.rs delete mode 100644 src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs delete mode 100644 src/test/compile-fail/invalid-crate-type.rs delete mode 100644 src/test/compile-fail/invalid-inline.rs delete mode 100644 src/test/compile-fail/invalid-macro-matcher.rs delete mode 100644 src/test/compile-fail/invalid-plugin-attr.rs delete mode 100644 src/test/compile-fail/invalid_crate_type_syntax.rs delete mode 100644 src/test/compile-fail/isssue-38821.rs delete mode 100644 src/test/compile-fail/issue-10755.rs delete mode 100644 src/test/compile-fail/issue-11593.rs delete mode 100644 src/test/compile-fail/issue-11680.rs delete mode 100644 src/test/compile-fail/issue-15919.rs delete mode 100644 src/test/compile-fail/issue-16725.rs delete mode 100644 src/test/compile-fail/issue-17718-const-privacy.rs delete mode 100644 src/test/compile-fail/issue-17913.rs delete mode 100644 src/test/compile-fail/issue-19163.rs delete mode 100644 src/test/compile-fail/issue-1920-1.rs delete mode 100644 src/test/compile-fail/issue-1920-2.rs delete mode 100644 src/test/compile-fail/issue-1920-3.rs delete mode 100644 src/test/compile-fail/issue-21146.rs delete mode 100644 src/test/compile-fail/issue-21202.rs delete mode 100644 src/test/compile-fail/issue-22638.rs delete mode 100644 src/test/compile-fail/issue-23595-1.rs delete mode 100644 src/test/compile-fail/issue-26548.rs delete mode 100644 src/test/compile-fail/issue-28075.rs delete mode 100644 src/test/compile-fail/issue-28388-1.rs delete mode 100644 src/test/compile-fail/issue-28388-2.rs delete mode 100644 src/test/compile-fail/issue-28388-3.rs delete mode 100644 src/test/compile-fail/issue-28625.rs delete mode 100644 src/test/compile-fail/issue-28848.rs delete mode 100644 src/test/compile-fail/issue-29181.rs delete mode 100644 src/test/compile-fail/issue-30123.rs delete mode 100644 src/test/compile-fail/issue-30535.rs delete mode 100644 src/test/compile-fail/issue-32377.rs delete mode 100644 src/test/compile-fail/issue-36881.rs delete mode 100644 src/test/compile-fail/issue-37131.rs delete mode 100644 src/test/compile-fail/issue-41549.rs delete mode 100644 src/test/compile-fail/issue-43733-2.rs delete mode 100644 src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs delete mode 100644 src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs delete mode 100644 src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs delete mode 100644 src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs delete mode 100644 src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs delete mode 100644 src/test/compile-fail/issue-52489.rs delete mode 100644 src/test/compile-fail/issue-5500-1.rs delete mode 100644 src/test/compile-fail/issue-5844.rs delete mode 100644 src/test/compile-fail/issue32829.rs delete mode 100644 src/test/compile-fail/keyword-extern-as-identifier.rs delete mode 100644 src/test/compile-fail/keyword-false-as-identifier.rs delete mode 100644 src/test/compile-fail/keyword-self-as-identifier.rs delete mode 100644 src/test/compile-fail/keyword-super-as-identifier.rs delete mode 100644 src/test/compile-fail/keyword-super.rs delete mode 100644 src/test/compile-fail/keyword-true-as-identifier.rs delete mode 100644 src/test/compile-fail/kindck-copy.rs delete mode 100644 src/test/compile-fail/kindck-impl-type-params-2.rs delete mode 100644 src/test/compile-fail/kindck-impl-type-params.rs delete mode 100644 src/test/compile-fail/kindck-inherited-copy-bound.rs delete mode 100644 src/test/compile-fail/kindck-nonsendable-1.rs delete mode 100644 src/test/compile-fail/kindck-send-object.rs delete mode 100644 src/test/compile-fail/kindck-send-object1.rs delete mode 100644 src/test/compile-fail/kindck-send-object2.rs delete mode 100644 src/test/compile-fail/kindck-send-owned.rs delete mode 100644 src/test/compile-fail/kindck-send-unsafe.rs delete mode 100644 src/test/compile-fail/kindck-send-unsafe.rs~rust-lang_master delete mode 100644 src/test/compile-fail/label-static.rs delete mode 100644 src/test/compile-fail/label-underscore.rs delete mode 100644 src/test/compile-fail/lang-item-missing.rs delete mode 100644 src/test/compile-fail/lexical-scopes.rs delete mode 100644 src/test/compile-fail/lifetime-bound-will-change-warning.rs delete mode 100644 src/test/compile-fail/lifetime-no-keyword.rs delete mode 100644 src/test/compile-fail/linkage2.rs delete mode 100644 src/test/compile-fail/linkage3.rs delete mode 100644 src/test/compile-fail/linkage4.rs delete mode 100644 src/test/compile-fail/lint-attr-non-item-node.rs delete mode 100644 src/test/compile-fail/lint-change-warnings.rs delete mode 100644 src/test/compile-fail/lint-ctypes-enum.rs delete mode 100644 src/test/compile-fail/lint-dead-code-1.rs delete mode 100644 src/test/compile-fail/lint-dead-code-2.rs delete mode 100644 src/test/compile-fail/lint-dead-code-3.rs delete mode 100644 src/test/compile-fail/lint-dead-code-4.rs delete mode 100644 src/test/compile-fail/lint-dead-code-5.rs delete mode 100644 src/test/compile-fail/lint-dead-code-type-alias.rs delete mode 100644 src/test/compile-fail/lint-dead-code-variant.rs delete mode 100644 src/test/compile-fail/lint-directives-on-use-items-issue-10534.rs delete mode 100644 src/test/compile-fail/lint-exceeding-bitshifts.rs delete mode 100644 src/test/compile-fail/lint-exceeding-bitshifts2.rs delete mode 100644 src/test/compile-fail/lint-forbid-cmdline.rs delete mode 100644 src/test/compile-fail/lint-impl-fn.rs delete mode 100644 src/test/compile-fail/lint-malformed.rs delete mode 100644 src/test/compile-fail/lint-misplaced-attr.rs delete mode 100644 src/test/compile-fail/lint-missing-copy-implementations.rs delete mode 100644 src/test/compile-fail/lint-missing-doc.rs delete mode 100644 src/test/compile-fail/lint-non-camel-case-types.rs delete mode 100644 src/test/compile-fail/lint-non-snake-case-crate-2.rs delete mode 100644 src/test/compile-fail/lint-non-snake-case-crate.rs delete mode 100644 src/test/compile-fail/lint-non-snake-case-functions.rs delete mode 100644 src/test/compile-fail/lint-non-snake-case-lifetimes.rs delete mode 100644 src/test/compile-fail/lint-non-snake-case-modules.rs delete mode 100644 src/test/compile-fail/lint-non-uppercase-statics.rs delete mode 100644 src/test/compile-fail/lint-obsolete-attr.rs delete mode 100644 src/test/compile-fail/lint-output-format.rs delete mode 100644 src/test/compile-fail/lint-owned-heap-memory.rs delete mode 100644 src/test/compile-fail/lint-qualification.rs delete mode 100644 src/test/compile-fail/lint-removed-allow.rs delete mode 100644 src/test/compile-fail/lint-removed-cmdline.rs delete mode 100644 src/test/compile-fail/lint-removed.rs delete mode 100644 src/test/compile-fail/lint-renamed-allow.rs delete mode 100644 src/test/compile-fail/lint-renamed-cmdline.rs delete mode 100644 src/test/compile-fail/lint-renamed.rs delete mode 100644 src/test/compile-fail/lint-shorthand-field.rs delete mode 100644 src/test/compile-fail/lint-stability-2.rs delete mode 100644 src/test/compile-fail/lint-stability-deprecated.rs delete mode 100644 src/test/compile-fail/lint-stability-fields-deprecated.rs delete mode 100644 src/test/compile-fail/lint-stability-fields.rs delete mode 100644 src/test/compile-fail/lint-stability.rs delete mode 100644 src/test/compile-fail/lint-stability2.rs delete mode 100644 src/test/compile-fail/lint-stability3.rs delete mode 100644 src/test/compile-fail/lint-type-limits.rs delete mode 100644 src/test/compile-fail/lint-type-limits2.rs delete mode 100644 src/test/compile-fail/lint-type-limits3.rs delete mode 100644 src/test/compile-fail/lint-type-overflow.rs delete mode 100644 src/test/compile-fail/lint-type-overflow2.rs delete mode 100644 src/test/compile-fail/lint-unexported-no-mangle.rs delete mode 100644 src/test/compile-fail/lint-unknown-attr.rs delete mode 100644 src/test/compile-fail/lint-unknown-feature-default.rs delete mode 100644 src/test/compile-fail/lint-unknown-feature.rs delete mode 100644 src/test/compile-fail/lint-unknown-lint-cmdline.rs delete mode 100644 src/test/compile-fail/lint-unknown-lint.rs delete mode 100644 src/test/compile-fail/lint-unnecessary-import-braces.rs delete mode 100644 src/test/compile-fail/lint-unnecessary-parens.rs delete mode 100644 src/test/compile-fail/lint-unsafe-code.rs delete mode 100644 src/test/compile-fail/lint-unused-extern-crate.rs delete mode 100644 src/test/compile-fail/lint-unused-imports.rs delete mode 100644 src/test/compile-fail/lint-unused-mut-self.rs delete mode 100644 src/test/compile-fail/lint-unused-mut-variables.rs delete mode 100644 src/test/compile-fail/lint-uppercase-variables.rs delete mode 100644 src/test/compile-fail/liveness-assign-imm-local-in-loop.rs delete mode 100644 src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs delete mode 100644 src/test/compile-fail/liveness-assign-imm-local-with-drop.rs delete mode 100644 src/test/compile-fail/liveness-assign-imm-local-with-init.rs delete mode 100644 src/test/compile-fail/liveness-closure-require-ret.rs delete mode 100644 src/test/compile-fail/liveness-dead.rs delete mode 100644 src/test/compile-fail/liveness-forgot-ret.rs delete mode 100644 src/test/compile-fail/liveness-issue-2163.rs delete mode 100644 src/test/compile-fail/liveness-missing-ret2.rs delete mode 100644 src/test/compile-fail/liveness-move-call-arg.rs delete mode 100644 src/test/compile-fail/liveness-move-in-loop.rs delete mode 100644 src/test/compile-fail/liveness-move-in-while.rs delete mode 100644 src/test/compile-fail/liveness-unused.rs delete mode 100644 src/test/compile-fail/liveness-use-after-move.rs delete mode 100644 src/test/compile-fail/liveness-use-after-send.rs delete mode 100644 src/test/compile-fail/loop-break-value.rs delete mode 100644 src/test/compile-fail/loop-labeled-break-value.rs delete mode 100644 src/test/compile-fail/loop-proper-liveness.rs delete mode 100644 src/test/compile-fail/loop-properly-diverging-2.rs delete mode 100644 src/test/compile-fail/lto-duplicate-symbols.rs delete mode 100644 src/test/compile-fail/lub-if.rs delete mode 100644 src/test/compile-fail/lub-match.rs delete mode 100644 src/test/compile-fail/macro-attribute.rs delete mode 100644 src/test/compile-fail/macro-comma-behavior.rs delete mode 100644 src/test/compile-fail/macro-comma-support.rs delete mode 100644 src/test/compile-fail/macro-crate-nonterminal-non-root.rs delete mode 100644 src/test/compile-fail/macro-error.rs delete mode 100644 src/test/compile-fail/macro-expanded-include/file.txt delete mode 100644 src/test/compile-fail/macro-expanded-include/foo/mod.rs delete mode 100644 src/test/compile-fail/macro-expanded-include/test.rs delete mode 100644 src/test/compile-fail/macro-expansion-tests.rs delete mode 100644 src/test/compile-fail/macro-follow.rs delete mode 100644 src/test/compile-fail/macro-followed-by-seq-bad.rs delete mode 100644 src/test/compile-fail/macro-inner-attributes.rs delete mode 100644 src/test/compile-fail/macro-input-future-proofing.rs delete mode 100644 src/test/compile-fail/macro-local-data-key-priv.rs delete mode 100644 src/test/compile-fail/macro-match-nonterminal.rs delete mode 100644 src/test/compile-fail/macro-missing-delimiters.rs delete mode 100644 src/test/compile-fail/macro-missing-fragment.rs delete mode 100644 src/test/compile-fail/macro-non-lifetime.rs delete mode 100644 src/test/compile-fail/macro-outer-attributes.rs delete mode 100644 src/test/compile-fail/macro-parameter-span.rs delete mode 100644 src/test/compile-fail/macro-stability.rs delete mode 100644 src/test/compile-fail/macro-stmt-matchers.rs delete mode 100644 src/test/compile-fail/macro-tt-matchers.rs delete mode 100644 src/test/compile-fail/macro-use-bad-args-1.rs delete mode 100644 src/test/compile-fail/macro-use-bad-args-2.rs delete mode 100644 src/test/compile-fail/macro-use-scope.rs delete mode 100644 src/test/compile-fail/macro-use-undef.rs delete mode 100644 src/test/compile-fail/macro-use-wrong-name.rs delete mode 100644 src/test/compile-fail/macro-with-seps-err-msg.rs delete mode 100644 src/test/compile-fail/macros-in-extern.rs delete mode 100644 src/test/compile-fail/macros-nonfatal-errors.rs delete mode 100644 src/test/compile-fail/main-wrong-type.rs delete mode 100644 src/test/compile-fail/malformed-derive-entry.rs delete mode 100644 src/test/compile-fail/malformed-plugin-1.rs delete mode 100644 src/test/compile-fail/malformed-plugin-2.rs delete mode 100644 src/test/compile-fail/malformed-plugin-3.rs delete mode 100644 src/test/compile-fail/malformed_macro_lhs.rs delete mode 100644 src/test/compile-fail/manual-link-bad-form.rs delete mode 100644 src/test/compile-fail/manual-link-bad-kind.rs delete mode 100644 src/test/compile-fail/manual-link-bad-search-path.rs delete mode 100644 src/test/compile-fail/manual-link-framework.rs delete mode 100644 src/test/compile-fail/map-types.rs delete mode 100644 src/test/compile-fail/match-argm-statics-2.rs delete mode 100644 src/test/compile-fail/match-arm-statics.rs delete mode 100644 src/test/compile-fail/match-byte-array-patterns-2.rs delete mode 100644 src/test/compile-fail/match-byte-array-patterns.rs delete mode 100644 src/test/compile-fail/match-ill-type2.rs delete mode 100644 src/test/compile-fail/match-join.rs delete mode 100644 src/test/compile-fail/match-no-arms-unreachable-after.rs delete mode 100644 src/test/compile-fail/match-non-exhaustive.rs delete mode 100644 src/test/compile-fail/match-pattern-field-mismatch-2.rs delete mode 100644 src/test/compile-fail/match-pattern-field-mismatch.rs delete mode 100644 src/test/compile-fail/match-privately-empty.rs delete mode 100644 src/test/compile-fail/match-range-fail-2.rs delete mode 100644 src/test/compile-fail/match-range-fail-dominate.rs delete mode 100644 src/test/compile-fail/match-range-fail.rs delete mode 100644 src/test/compile-fail/match-ref-ice.rs delete mode 100644 src/test/compile-fail/match-ref-mut-invariance.rs delete mode 100644 src/test/compile-fail/match-ref-mut-let-invariance.rs delete mode 100644 src/test/compile-fail/match-slice-patterns.rs delete mode 100644 src/test/compile-fail/match-static-const-lc.rs delete mode 100644 src/test/compile-fail/match-struct.rs delete mode 100644 src/test/compile-fail/match-tag-nullary.rs delete mode 100644 src/test/compile-fail/match-tag-unary.rs delete mode 100644 src/test/compile-fail/match-unreachable-warning-with-diverging-discrim.rs delete mode 100644 src/test/compile-fail/match-unresolved-one-arm.rs delete mode 100644 src/test/compile-fail/match-vec-fixed.rs delete mode 100644 src/test/compile-fail/match-vec-mismatch-2.rs delete mode 100644 src/test/compile-fail/match-vec-mismatch.rs delete mode 100644 src/test/compile-fail/match-vec-unreachable.rs delete mode 100644 src/test/compile-fail/maybe-bounds-where-cpass.rs delete mode 100644 src/test/compile-fail/maybe-bounds-where.rs delete mode 100644 src/test/compile-fail/meta-expected-error-correct-rev.rs delete mode 100644 src/test/compile-fail/meta-expected-error-wrong-rev.rs delete mode 100644 src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs delete mode 100644 src/test/compile-fail/method-ambig-two-traits-cross-crate.rs delete mode 100644 src/test/compile-fail/method-ambig-two-traits-from-bounds.rs delete mode 100644 src/test/compile-fail/method-ambig-two-traits-with-default-method.rs delete mode 100644 src/test/compile-fail/method-call-lifetime-args-lint.rs delete mode 100644 src/test/compile-fail/method-call-lifetime-args-subst-index.rs delete mode 100644 src/test/compile-fail/method-call-lifetime-args-unresolved.rs delete mode 100644 src/test/compile-fail/method-call-lifetime-args.rs delete mode 100644 src/test/compile-fail/method-call-type-binding.rs delete mode 100644 src/test/compile-fail/method-macro-backtrace.rs delete mode 100644 src/test/compile-fail/method-path-in-pattern.rs delete mode 100644 src/test/compile-fail/method-resolvable-path-in-pattern.rs delete mode 100644 src/test/compile-fail/method-self-arg-1.rs delete mode 100644 src/test/compile-fail/method-self-arg-2.rs delete mode 100644 src/test/compile-fail/minus-string.rs delete mode 100644 src/test/compile-fail/mir-dataflow/README.md delete mode 100644 src/test/compile-fail/mir-dataflow/def-inits-1.rs delete mode 100644 src/test/compile-fail/mir-dataflow/inits-1.rs delete mode 100644 src/test/compile-fail/mir-dataflow/uninits-1.rs delete mode 100644 src/test/compile-fail/mir-dataflow/uninits-2.rs delete mode 100644 src/test/compile-fail/mir-unpretty.rs delete mode 100644 src/test/compile-fail/missing-derivable-attr.rs delete mode 100644 src/test/compile-fail/missing-macro-use.rs delete mode 100644 src/test/compile-fail/missing-main.rs delete mode 100644 src/test/compile-fail/missing-return.rs delete mode 100644 src/test/compile-fail/missing-semicolon-warning.rs delete mode 100644 src/test/compile-fail/missing-stability.rs delete mode 100644 src/test/compile-fail/missing_debug_impls.rs delete mode 100644 src/test/compile-fail/mod_file_aux.rs delete mode 100644 src/test/compile-fail/mod_file_correct_spans.rs delete mode 100644 src/test/compile-fail/mod_file_disambig.rs delete mode 100644 src/test/compile-fail/mod_file_disambig_aux.rs delete mode 100644 src/test/compile-fail/mod_file_disambig_aux/mod.rs delete mode 100644 src/test/compile-fail/module-macro_use-arguments.rs delete mode 100644 src/test/compile-fail/move-guard-same-consts.rs delete mode 100644 src/test/compile-fail/move-in-guard-1.rs delete mode 100644 src/test/compile-fail/move-in-guard-2.rs delete mode 100644 src/test/compile-fail/move-into-dead-array-1.rs delete mode 100644 src/test/compile-fail/move-into-dead-array-2.rs delete mode 100644 src/test/compile-fail/move-out-of-array-1.rs delete mode 100644 src/test/compile-fail/move-out-of-slice-1.rs delete mode 100644 src/test/compile-fail/move-out-of-tuple-field.rs delete mode 100644 src/test/compile-fail/moves-based-on-type-access-to-field.rs delete mode 100644 src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs delete mode 100644 src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs delete mode 100644 src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs delete mode 100644 src/test/compile-fail/moves-based-on-type-exprs.rs delete mode 100644 src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs delete mode 100644 src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs delete mode 100644 src/test/compile-fail/moves-sru-moved-field.rs delete mode 100644 src/test/compile-fail/multiple-main-2.rs delete mode 100644 src/test/compile-fail/multiple-main-3.rs delete mode 100644 src/test/compile-fail/multiple-plugin-registrars.rs delete mode 100644 src/test/compile-fail/mut-cant-alias.rs delete mode 100644 src/test/compile-fail/mut-cross-borrowing.rs delete mode 100644 src/test/compile-fail/mut-pattern-internal-mutability.rs delete mode 100644 src/test/compile-fail/mut-pattern-mismatched.rs delete mode 100644 src/test/compile-fail/mut-suggestion.rs delete mode 100644 src/test/compile-fail/mutable-class-fields-2.rs delete mode 100644 src/test/compile-fail/mutable-class-fields.rs delete mode 100644 src/test/compile-fail/mutable-enum-indirect.rs delete mode 100644 src/test/compile-fail/mutexguard-sync.rs delete mode 100644 src/test/compile-fail/namespace-mix.rs delete mode 100644 src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs delete mode 100644 src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs delete mode 100644 src/test/compile-fail/nested-cfg-attrs.rs delete mode 100644 src/test/compile-fail/nested-ty-params.rs delete mode 100644 src/test/compile-fail/never-assign-dead-code.rs delete mode 100644 src/test/compile-fail/never-assign-wrong-type.rs delete mode 100644 src/test/compile-fail/never_transmute_never.rs delete mode 100644 src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs delete mode 100644 src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs delete mode 100644 src/test/compile-fail/nll/loan_ends_mid_block_pair.rs delete mode 100644 src/test/compile-fail/nll/loan_ends_mid_block_vec.rs delete mode 100644 src/test/compile-fail/nll/match-guards-always-borrow.rs delete mode 100644 src/test/compile-fail/nll/reference-carried-through-struct-field.rs delete mode 100644 src/test/compile-fail/nll/region-ends-after-if-condition.rs delete mode 100644 src/test/compile-fail/nll/return_from_loop.rs delete mode 100644 src/test/compile-fail/nll/unused-mut-issue-50343.rs delete mode 100644 src/test/compile-fail/nll/where_clauses_in_functions.rs delete mode 100644 src/test/compile-fail/nll/where_clauses_in_structs.rs delete mode 100644 src/test/compile-fail/no-capture-arc.rs delete mode 100644 src/test/compile-fail/no-implicit-prelude-nested.rs delete mode 100644 src/test/compile-fail/no-implicit-prelude.rs delete mode 100644 src/test/compile-fail/no-link.rs delete mode 100644 src/test/compile-fail/no-patterns-in-args-2.rs delete mode 100644 src/test/compile-fail/no-patterns-in-args-macro.rs delete mode 100644 src/test/compile-fail/no-reuse-move-arc.rs delete mode 100644 src/test/compile-fail/no-send-res-ports.rs delete mode 100644 src/test/compile-fail/no-std-inject.rs delete mode 100644 src/test/compile-fail/no-type-for-node-ice.rs delete mode 100644 src/test/compile-fail/no-warn-on-field-replace-issue-34101.rs delete mode 100644 src/test/compile-fail/no_crate_type.rs delete mode 100644 src/test/compile-fail/no_owned_box_lang_item.rs delete mode 100644 src/test/compile-fail/no_send-enum.rs delete mode 100644 src/test/compile-fail/no_send-rc.rs delete mode 100644 src/test/compile-fail/no_send-struct.rs delete mode 100644 src/test/compile-fail/no_share-enum.rs delete mode 100644 src/test/compile-fail/no_share-struct.rs delete mode 100644 src/test/compile-fail/noexporttypeexe.rs delete mode 100644 src/test/compile-fail/nolink-with-link-args.rs delete mode 100644 src/test/compile-fail/non-constant-in-const-path.rs delete mode 100644 src/test/compile-fail/non-copyable-void.rs delete mode 100644 src/test/compile-fail/non-exhaustive-match-nested.rs delete mode 100644 src/test/compile-fail/non-exhaustive-match.rs delete mode 100644 src/test/compile-fail/non-interger-atomic.rs delete mode 100644 src/test/compile-fail/noncopyable-class.rs delete mode 100644 src/test/compile-fail/nonscalar-cast.rs delete mode 100644 src/test/compile-fail/not-clone-closure.rs delete mode 100644 src/test/compile-fail/not-copy-closure.rs delete mode 100644 src/test/compile-fail/not-panic-safe-2.rs delete mode 100644 src/test/compile-fail/not-panic-safe-3.rs delete mode 100644 src/test/compile-fail/not-panic-safe-4.rs delete mode 100644 src/test/compile-fail/not-panic-safe-5.rs delete mode 100644 src/test/compile-fail/not-panic-safe-6.rs delete mode 100644 src/test/compile-fail/not-panic-safe.rs delete mode 100644 src/test/compile-fail/not-sync.rs delete mode 100644 src/test/compile-fail/not-utf8.bin delete mode 100644 src/test/compile-fail/not-utf8.rs delete mode 100644 src/test/compile-fail/object-does-not-impl-trait.rs delete mode 100644 src/test/compile-fail/object-lifetime-default-ambiguous.rs delete mode 100644 src/test/compile-fail/object-lifetime-default-elision.rs delete mode 100644 src/test/compile-fail/object-lifetime-default-from-box-error.rs delete mode 100644 src/test/compile-fail/object-lifetime-default-from-rptr-box-error.rs delete mode 100644 src/test/compile-fail/object-lifetime-default-from-rptr-struct-error.rs delete mode 100644 src/test/compile-fail/object-lifetime-default-mybox.rs delete mode 100644 src/test/compile-fail/object-lifetime-default.rs delete mode 100644 src/test/compile-fail/object-pointer-types.rs delete mode 100644 src/test/compile-fail/object-safety-by-value-self-use.rs delete mode 100644 src/test/compile-fail/object-safety-by-value-self.rs delete mode 100644 src/test/compile-fail/object-safety-issue-22040.rs delete mode 100644 src/test/compile-fail/object-safety-no-static.rs delete mode 100644 src/test/compile-fail/object-safety-phantom-fn.rs delete mode 100644 src/test/compile-fail/object-safety-sized-2.rs delete mode 100644 src/test/compile-fail/occurs-check-2.rs delete mode 100644 src/test/compile-fail/occurs-check-3.rs delete mode 100644 src/test/compile-fail/occurs-check.rs delete mode 100644 src/test/compile-fail/old-suffixes-are-really-forbidden.rs delete mode 100644 src/test/compile-fail/once-cant-call-twice-on-heap.rs delete mode 100644 src/test/compile-fail/opt-in-copy.rs delete mode 100644 src/test/compile-fail/or-patter-mismatch.rs delete mode 100644 src/test/compile-fail/orphan-check-diagnostics.rs delete mode 100644 src/test/compile-fail/osx-frameworks.rs delete mode 100644 src/test/compile-fail/out-of-order-shadowing.rs delete mode 100644 src/test/compile-fail/output-type-mismatch.rs delete mode 100644 src/test/compile-fail/overlap-marker-trait.rs delete mode 100644 src/test/compile-fail/overloaded-calls-nontuple.rs delete mode 100644 src/test/compile-fail/packed-struct-generic-transmute.rs delete mode 100644 src/test/compile-fail/packed-struct-transmute.rs delete mode 100644 src/test/compile-fail/panic-implementation-bad-signature-1.rs delete mode 100644 src/test/compile-fail/panic-implementation-bad-signature-2.rs delete mode 100644 src/test/compile-fail/panic-implementation-bad-signature-3.rs delete mode 100644 src/test/compile-fail/panic-implementation-bad-signature-4.rs delete mode 100644 src/test/compile-fail/panic-implementation-duplicate.rs delete mode 100644 src/test/compile-fail/panic-implementation-missing.rs delete mode 100644 src/test/compile-fail/panic-implementation-requires-panic-info.rs delete mode 100644 src/test/compile-fail/panic-implementation-std.rs delete mode 100644 src/test/compile-fail/panic-implementation-twice.rs delete mode 100644 src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/depends.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/needs-panic-runtime.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-abort.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-lang-items.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind2.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-abort.rs delete mode 100644 src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs delete mode 100644 src/test/compile-fail/panic-runtime/bad-panic-flag1.rs delete mode 100644 src/test/compile-fail/panic-runtime/bad-panic-flag2.rs delete mode 100644 src/test/compile-fail/panic-runtime/libtest-unwinds.rs delete mode 100644 src/test/compile-fail/panic-runtime/needs-gate.rs delete mode 100644 src/test/compile-fail/panic-runtime/runtime-depend-on-needs-runtime.rs delete mode 100644 src/test/compile-fail/panic-runtime/transitive-link-a-bunch.rs delete mode 100644 src/test/compile-fail/panic-runtime/two-panic-runtimes.rs delete mode 100644 src/test/compile-fail/panic-runtime/want-abort-got-unwind.rs delete mode 100644 src/test/compile-fail/panic-runtime/want-abort-got-unwind2.rs delete mode 100644 src/test/compile-fail/panic-runtime/want-unwind-got-abort.rs delete mode 100644 src/test/compile-fail/panic-runtime/want-unwind-got-abort2.rs delete mode 100644 src/test/compile-fail/panic_implementation-closures.rs delete mode 100644 src/test/compile-fail/paren-span.rs delete mode 100644 src/test/compile-fail/parse-error-correct.rs delete mode 100644 src/test/compile-fail/parser-recovery-1.rs delete mode 100644 src/test/compile-fail/parser-recovery-2.rs delete mode 100644 src/test/compile-fail/pat-shadow-in-nested-binding.rs delete mode 100644 src/test/compile-fail/pat-tuple-bad-type.rs delete mode 100644 src/test/compile-fail/pat-tuple-overfield.rs delete mode 100644 src/test/compile-fail/patkind-litrange-no-expr.rs delete mode 100644 src/test/compile-fail/pattern-binding-disambiguation.rs delete mode 100644 src/test/compile-fail/pattern-bindings-after-at.rs delete mode 100644 src/test/compile-fail/pattern-error-continue.rs delete mode 100644 src/test/compile-fail/pattern-ident-path-generics.rs delete mode 100644 src/test/compile-fail/pattern-tyvar-2.rs delete mode 100644 src/test/compile-fail/pattern-tyvar.rs delete mode 100644 src/test/compile-fail/phantom-oibit.rs delete mode 100644 src/test/compile-fail/platform-intrinsic-params.rs delete mode 100644 src/test/compile-fail/pptypedef.rs delete mode 100644 src/test/compile-fail/prim-with-args.rs delete mode 100644 src/test/compile-fail/priv-in-bad-locations.rs delete mode 100644 src/test/compile-fail/privacy-in-paths.rs delete mode 100644 src/test/compile-fail/privacy-ns1.rs delete mode 100644 src/test/compile-fail/privacy-ns2.rs delete mode 100644 src/test/compile-fail/privacy-sanity.rs delete mode 100644 src/test/compile-fail/privacy-ufcs.rs delete mode 100644 src/test/compile-fail/privacy/associated-item-privacy-inherent.rs delete mode 100644 src/test/compile-fail/privacy/associated-item-privacy-trait.rs delete mode 100644 src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs delete mode 100644 src/test/compile-fail/privacy/legacy-ctor-visibility.rs delete mode 100644 src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs delete mode 100644 src/test/compile-fail/privacy/restricted/lookup-ignores-private.rs delete mode 100644 src/test/compile-fail/privacy/restricted/private-in-public.rs delete mode 100644 src/test/compile-fail/privacy/restricted/struct-literal-field.rs delete mode 100644 src/test/compile-fail/privacy/restricted/test.rs delete mode 100644 src/test/compile-fail/privacy/union-field-privacy-1.rs delete mode 100644 src/test/compile-fail/privacy/union-field-privacy-2.rs delete mode 100644 src/test/compile-fail/privacy1.rs delete mode 100644 src/test/compile-fail/privacy2.rs delete mode 100644 src/test/compile-fail/privacy3.rs delete mode 100644 src/test/compile-fail/privacy4.rs delete mode 100644 src/test/compile-fail/privacy5.rs delete mode 100644 src/test/compile-fail/private-impl-method.rs delete mode 100644 src/test/compile-fail/private-in-public-assoc-ty.rs delete mode 100644 src/test/compile-fail/private-in-public-ill-formed.rs delete mode 100644 src/test/compile-fail/private-in-public-lint.rs delete mode 100644 src/test/compile-fail/private-in-public-warn.rs delete mode 100644 src/test/compile-fail/private-in-public.rs delete mode 100644 src/test/compile-fail/private-inferred-type-1.rs delete mode 100644 src/test/compile-fail/private-inferred-type-2.rs delete mode 100644 src/test/compile-fail/private-inferred-type-3.rs delete mode 100644 src/test/compile-fail/private-inferred-type.rs delete mode 100644 src/test/compile-fail/private-item-simple.rs delete mode 100644 src/test/compile-fail/private-method-cross-crate.rs delete mode 100644 src/test/compile-fail/private-method-inherited.rs delete mode 100644 src/test/compile-fail/private-method.rs delete mode 100644 src/test/compile-fail/private-struct-field-cross-crate.rs delete mode 100644 src/test/compile-fail/private-struct-field-ctor.rs delete mode 100644 src/test/compile-fail/private-struct-field-pattern.rs delete mode 100644 src/test/compile-fail/private-struct-field.rs delete mode 100644 src/test/compile-fail/private-type-in-interface.rs delete mode 100644 src/test/compile-fail/private-variant-reexport.rs delete mode 100644 src/test/compile-fail/ptr-coercion.rs delete mode 100644 src/test/compile-fail/pub-reexport-priv-extern-crate.rs delete mode 100644 src/test/compile-fail/qualified-path-params.rs delete mode 100644 src/test/compile-fail/question-mark-type-infer.rs delete mode 100644 src/test/compile-fail/quote-with-interpolated.rs delete mode 100644 src/test/compile-fail/range-1.rs delete mode 100644 src/test/compile-fail/range_traits-1.rs delete mode 100644 src/test/compile-fail/range_traits-2.rs delete mode 100644 src/test/compile-fail/range_traits-3.rs delete mode 100644 src/test/compile-fail/range_traits-4.rs delete mode 100644 src/test/compile-fail/range_traits-5.rs delete mode 100644 src/test/compile-fail/range_traits-6.rs delete mode 100644 src/test/compile-fail/range_traits-7.rs delete mode 100644 src/test/compile-fail/recursion.rs delete mode 100644 src/test/compile-fail/recursive-enum.rs delete mode 100644 src/test/compile-fail/recursive-reexports.rs delete mode 100644 src/test/compile-fail/recursive-static-definition.rs delete mode 100644 src/test/compile-fail/recursive-types-are-not-uninhabited.rs delete mode 100644 src/test/compile-fail/ref-suggestion.rs delete mode 100644 src/test/compile-fail/refutable-pattern-errors.rs delete mode 100644 src/test/compile-fail/refutable-pattern-in-fn-arg.rs delete mode 100644 src/test/compile-fail/region-borrow-params-issue-29793-big.rs delete mode 100644 src/test/compile-fail/region-bound-extra-bound-in-inherent-impl.rs delete mode 100644 src/test/compile-fail/region-bound-on-closure-outlives-call.rs delete mode 100644 src/test/compile-fail/region-bound-same-bounds-in-trait-and-impl.rs delete mode 100644 src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs delete mode 100644 src/test/compile-fail/region-invariant-static-error-reporting.rs delete mode 100644 src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs delete mode 100644 src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs delete mode 100644 src/test/compile-fail/region-object-lifetime-1.rs delete mode 100644 src/test/compile-fail/region-object-lifetime-2.rs delete mode 100644 src/test/compile-fail/region-object-lifetime-3.rs delete mode 100644 src/test/compile-fail/region-object-lifetime-4.rs delete mode 100644 src/test/compile-fail/region-object-lifetime-5.rs delete mode 100644 src/test/compile-fail/region-object-lifetime-in-coercion.rs delete mode 100644 src/test/compile-fail/regions-addr-of-arg.rs delete mode 100644 src/test/compile-fail/regions-addr-of-self.rs delete mode 100644 src/test/compile-fail/regions-addr-of-upvar-self.rs delete mode 100644 src/test/compile-fail/regions-adjusted-lvalue-op.rs delete mode 100644 src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs delete mode 100644 src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs delete mode 100644 src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs delete mode 100644 src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs delete mode 100644 src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs delete mode 100644 src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs delete mode 100644 src/test/compile-fail/regions-bounded-method-type-parameters.rs delete mode 100644 src/test/compile-fail/regions-bounds.rs delete mode 100644 src/test/compile-fail/regions-close-associated-type-into-object.rs delete mode 100644 src/test/compile-fail/regions-close-object-into-object-1.rs delete mode 100644 src/test/compile-fail/regions-close-object-into-object-2.rs delete mode 100644 src/test/compile-fail/regions-close-object-into-object-3.rs delete mode 100644 src/test/compile-fail/regions-close-object-into-object-4.rs delete mode 100644 src/test/compile-fail/regions-close-object-into-object-5.rs delete mode 100644 src/test/compile-fail/regions-close-over-type-parameter-1.rs delete mode 100644 src/test/compile-fail/regions-close-over-type-parameter-multiple.rs delete mode 100644 src/test/compile-fail/regions-close-param-into-object.rs delete mode 100644 src/test/compile-fail/regions-creating-enums.rs delete mode 100644 src/test/compile-fail/regions-creating-enums3.rs delete mode 100644 src/test/compile-fail/regions-creating-enums4.rs delete mode 100644 src/test/compile-fail/regions-early-bound-error-method.rs delete mode 100644 src/test/compile-fail/regions-early-bound-error.rs delete mode 100644 src/test/compile-fail/regions-enum-not-wf.rs delete mode 100644 src/test/compile-fail/regions-escape-method.rs delete mode 100644 src/test/compile-fail/regions-escape-via-trait-or-not.rs delete mode 100644 src/test/compile-fail/regions-fn-subtyping-return-static.rs delete mode 100644 src/test/compile-fail/regions-free-region-ordering-callee-4.rs delete mode 100644 src/test/compile-fail/regions-free-region-ordering-callee.rs delete mode 100644 src/test/compile-fail/regions-free-region-ordering-caller.rs delete mode 100644 src/test/compile-fail/regions-free-region-ordering-caller1.rs delete mode 100644 src/test/compile-fail/regions-free-region-ordering-incorrect.rs delete mode 100644 src/test/compile-fail/regions-glb-free-free.rs delete mode 100644 src/test/compile-fail/regions-implied-bounds-projection-gap-1.rs delete mode 100644 src/test/compile-fail/regions-implied-bounds-projection-gap-2.rs delete mode 100644 src/test/compile-fail/regions-implied-bounds-projection-gap-3.rs delete mode 100644 src/test/compile-fail/regions-implied-bounds-projection-gap-4.rs delete mode 100644 src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs delete mode 100644 src/test/compile-fail/regions-in-enums-anon.rs delete mode 100644 src/test/compile-fail/regions-in-enums.rs delete mode 100644 src/test/compile-fail/regions-in-structs-anon.rs delete mode 100644 src/test/compile-fail/regions-in-structs.rs delete mode 100644 src/test/compile-fail/regions-infer-at-fn-not-param.rs delete mode 100644 src/test/compile-fail/regions-infer-borrow-scope-too-big.rs delete mode 100644 src/test/compile-fail/regions-infer-bound-from-trait-self.rs delete mode 100644 src/test/compile-fail/regions-infer-bound-from-trait.rs delete mode 100644 src/test/compile-fail/regions-infer-call-3.rs delete mode 100644 src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs delete mode 100644 src/test/compile-fail/regions-infer-covariance-due-to-decl.rs delete mode 100644 src/test/compile-fail/regions-infer-invariance-due-to-decl.rs delete mode 100644 src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs delete mode 100644 src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs delete mode 100644 src/test/compile-fail/regions-infer-not-param.rs delete mode 100644 src/test/compile-fail/regions-infer-paramd-indirect.rs delete mode 100644 src/test/compile-fail/regions-infer-proc-static-upvar.rs delete mode 100644 src/test/compile-fail/regions-lifetime-bounds-on-fns.rs delete mode 100644 src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs delete mode 100644 src/test/compile-fail/regions-name-duplicated.rs delete mode 100644 src/test/compile-fail/regions-name-static.rs delete mode 100644 src/test/compile-fail/regions-name-undeclared.rs delete mode 100644 src/test/compile-fail/regions-nested-fns.rs delete mode 100644 src/test/compile-fail/regions-normalize-in-where-clause-list.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-enum-type-rev.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-enum-type.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-struct-region-rev.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-struct-region.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-struct-type-rev.rs delete mode 100644 src/test/compile-fail/regions-outlives-nominal-type-struct-type.rs delete mode 100644 src/test/compile-fail/regions-outlives-projection-container-hrtb.rs delete mode 100644 src/test/compile-fail/regions-outlives-projection-container-wc.rs delete mode 100644 src/test/compile-fail/regions-outlives-projection-container.rs delete mode 100644 src/test/compile-fail/regions-outlives-projection-hrtype.rs delete mode 100644 src/test/compile-fail/regions-outlives-projection-trait-def.rs delete mode 100644 src/test/compile-fail/regions-outlives-scalar.rs delete mode 100644 src/test/compile-fail/regions-pattern-typing-issue-19552.rs delete mode 100644 src/test/compile-fail/regions-pattern-typing-issue-19997.rs delete mode 100644 src/test/compile-fail/regions-proc-bound-capture.rs delete mode 100644 src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs delete mode 100644 src/test/compile-fail/regions-reborrow-from-shorter-mut-ref.rs delete mode 100644 src/test/compile-fail/regions-ref-in-fn-arg.rs delete mode 100644 src/test/compile-fail/regions-ret-borrowed-1.rs delete mode 100644 src/test/compile-fail/regions-ret-borrowed.rs delete mode 100644 src/test/compile-fail/regions-ret.rs delete mode 100644 src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs delete mode 100644 src/test/compile-fail/regions-return-stack-allocated-vec.rs delete mode 100644 src/test/compile-fail/regions-static-bound.rs delete mode 100644 src/test/compile-fail/regions-steal-closure.rs delete mode 100644 src/test/compile-fail/regions-struct-not-wf.rs delete mode 100644 src/test/compile-fail/regions-trait-1.rs delete mode 100644 src/test/compile-fail/regions-trait-object-subtyping.rs delete mode 100644 src/test/compile-fail/regions-trait-variance.rs delete mode 100644 src/test/compile-fail/regions-undeclared.rs delete mode 100644 src/test/compile-fail/regions-var-type-out-of-scope.rs delete mode 100644 src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs delete mode 100644 src/test/compile-fail/regions-variance-contravariant-use-covariant.rs delete mode 100644 src/test/compile-fail/regions-variance-covariant-use-contravariant.rs delete mode 100644 src/test/compile-fail/regions-variance-invariant-use-contravariant.rs delete mode 100644 src/test/compile-fail/regions-variance-invariant-use-covariant.rs delete mode 100644 src/test/compile-fail/regions-wf-trait-object.rs delete mode 100644 src/test/compile-fail/reject-specialized-drops-8142.rs delete mode 100644 src/test/compile-fail/repeat-to-run-dtor-twice.rs delete mode 100644 src/test/compile-fail/repeat_count.rs delete mode 100644 src/test/compile-fail/repr-align.rs delete mode 100644 src/test/compile-fail/repr-packed-contains-align.rs delete mode 100644 src/test/compile-fail/repr-transparent-other-items.rs delete mode 100644 src/test/compile-fail/repr-transparent-other-reprs.rs delete mode 100644 src/test/compile-fail/repr-transparent.rs delete mode 100644 src/test/compile-fail/required-lang-item.rs delete mode 100644 src/test/compile-fail/reserved-attr-on-macro.rs delete mode 100644 src/test/compile-fail/reserved-become.rs delete mode 100644 src/test/compile-fail/resolve-bad-import-prefix.rs delete mode 100644 src/test/compile-fail/resolve-bad-visibility.rs delete mode 100644 src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs delete mode 100644 src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs delete mode 100644 src/test/compile-fail/resolve-conflict-import-vs-import.rs delete mode 100644 src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs delete mode 100644 src/test/compile-fail/resolve-conflict-type-vs-import.rs delete mode 100644 src/test/compile-fail/resolve-inconsistent-binding-mode.rs delete mode 100644 src/test/compile-fail/resolve-label.rs delete mode 100644 src/test/compile-fail/resolve-primitive-fallback.rs delete mode 100644 src/test/compile-fail/resolve-self-in-impl-2.rs delete mode 100644 src/test/compile-fail/resolve-self-in-impl.rs delete mode 100644 src/test/compile-fail/resolve-type-param-in-item-in-trait.rs delete mode 100644 src/test/compile-fail/resolve-unknown-trait.rs delete mode 100644 src/test/compile-fail/resolve-variant-assoc-item.rs delete mode 100644 src/test/compile-fail/resolve_self_super_hint.rs delete mode 100644 src/test/compile-fail/ret-non-nil.rs delete mode 100644 src/test/compile-fail/retslot-cast.rs delete mode 100644 src/test/compile-fail/return-from-diverging.rs delete mode 100644 src/test/compile-fail/return-unit-from-diverging.rs delete mode 100644 src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-i32.rs delete mode 100644 src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/enums.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/structs.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/variants.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/enum.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/invalid-attribute.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/structs.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/variants.rs delete mode 100644 src/test/compile-fail/rfc-2008-non-exhaustive/variants_create.rs delete mode 100644 src/test/compile-fail/rfc-2126-crate-paths/crate-path-non-absolute.rs delete mode 100644 src/test/compile-fail/rfc-2126-crate-paths/keyword-crate-as-identifier.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-in-paths/auxiliary/xcrate.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-1.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-2.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-3.rs delete mode 100644 src/test/compile-fail/rfc-2126-extern-in-paths/single-segment.rs delete mode 100644 src/test/compile-fail/rfc1445/feature-gate.rs delete mode 100644 src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs delete mode 100644 src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs delete mode 100644 src/test/compile-fail/rfc1623.rs delete mode 100644 src/test/compile-fail/rfc1717/missing-link-attr.rs delete mode 100644 src/test/compile-fail/rfc1717/multiple-renames.rs delete mode 100644 src/test/compile-fail/rfc1717/rename-to-empty.rs delete mode 100644 src/test/compile-fail/rmeta-lib-pass.rs delete mode 100644 src/test/compile-fail/rmeta-pass.rs delete mode 100644 src/test/compile-fail/rmeta-priv-warn.rs delete mode 100644 src/test/compile-fail/rmeta.rs delete mode 100644 src/test/compile-fail/rmeta_lib.rs delete mode 100644 src/test/compile-fail/rmeta_meta_main.rs delete mode 100644 src/test/compile-fail/rust-unstable-column-gated.rs delete mode 100644 src/test/compile-fail/rustc-args-required-const.rs delete mode 100644 src/test/compile-fail/rustc-args-required-const2.rs delete mode 100644 src/test/compile-fail/rustc-error.rs delete mode 100644 src/test/compile-fail/safe-extern-statics-mut.rs delete mode 100644 src/test/compile-fail/safe-extern-statics.rs delete mode 100644 src/test/compile-fail/self-infer.rs delete mode 100644 src/test/compile-fail/self-vs-path-ambiguity.rs delete mode 100644 src/test/compile-fail/self_type_keyword-2.rs delete mode 100644 src/test/compile-fail/self_type_keyword.rs delete mode 100644 src/test/compile-fail/seq-args.rs delete mode 100644 src/test/compile-fail/shadowed-trait-methods.rs delete mode 100644 src/test/compile-fail/shadowed-use-visibility.rs delete mode 100644 src/test/compile-fail/shadowing-in-the-same-pattern.rs delete mode 100644 src/test/compile-fail/shift-various-bad-types.rs delete mode 100644 src/test/compile-fail/should-fail-no_gate_irrefutable_if_let_pattern.rs delete mode 100644 src/test/compile-fail/should-fail-with_gate_irrefutable_pattern_deny.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-declaration-type.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-generic-arithmetic.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-generic-cast.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-generic-comparison.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-generic-elements.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-generic-reduction.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-generic-select.rs delete mode 100644 src/test/compile-fail/simd-intrinsic-single-nominal-type.rs delete mode 100644 src/test/compile-fail/simd-type-generic-monomorphisation.rs delete mode 100644 src/test/compile-fail/simd-type.rs delete mode 100644 src/test/compile-fail/single-primitive-inherent-impl.rs delete mode 100644 src/test/compile-fail/sized-cycle-note.rs delete mode 100644 src/test/compile-fail/slice-2.rs delete mode 100644 src/test/compile-fail/slice-mut-2.rs delete mode 100644 src/test/compile-fail/slice-mut.rs delete mode 100644 src/test/compile-fail/slightly-nice-generic-literal-messages.rs delete mode 100644 src/test/compile-fail/specialization/README.md delete mode 100644 src/test/compile-fail/specialization/defaultimpl/specialization-feature-gate-default.rs delete mode 100644 src/test/compile-fail/specialization/defaultimpl/specialization-no-default.rs delete mode 100644 src/test/compile-fail/specialization/defaultimpl/specialization-trait-item-not-implemented.rs delete mode 100644 src/test/compile-fail/specialization/defaultimpl/specialization-trait-not-implemented.rs delete mode 100644 src/test/compile-fail/specialization/defaultimpl/specialization-wfcheck.rs delete mode 100644 src/test/compile-fail/specialization/defaultimpl/validation.rs delete mode 100644 src/test/compile-fail/specialization/issue-52050.rs delete mode 100644 src/test/compile-fail/specialization/specialization-default-projection.rs delete mode 100644 src/test/compile-fail/specialization/specialization-default-types.rs delete mode 100644 src/test/compile-fail/specialization/specialization-no-default.rs delete mode 100644 src/test/compile-fail/specialization/specialization-overlap-negative.rs delete mode 100644 src/test/compile-fail/specialization/specialization-overlap.rs delete mode 100644 src/test/compile-fail/specialization/specialization-polarity.rs delete mode 100644 src/test/compile-fail/stability-attribute-issue-43027.rs delete mode 100644 src/test/compile-fail/stability-attribute-issue.rs delete mode 100644 src/test/compile-fail/stability-attribute-non-staged-force-unstable.rs delete mode 100644 src/test/compile-fail/stability-attribute-non-staged.rs delete mode 100644 src/test/compile-fail/stability-attribute-sanity-2.rs delete mode 100644 src/test/compile-fail/stability-attribute-sanity-3.rs delete mode 100644 src/test/compile-fail/stability-attribute-sanity.rs delete mode 100644 src/test/compile-fail/stable-features.rs delete mode 100644 src/test/compile-fail/static-closures.rs delete mode 100644 src/test/compile-fail/static-drop-scope.rs delete mode 100644 src/test/compile-fail/static-items-cant-move.rs delete mode 100644 src/test/compile-fail/static-lifetime-bound.rs delete mode 100644 src/test/compile-fail/static-method-privacy.rs delete mode 100644 src/test/compile-fail/static-mut-bad-types.rs delete mode 100644 src/test/compile-fail/static-mut-foreign-requires-unsafe.rs delete mode 100644 src/test/compile-fail/static-mut-not-constant.rs delete mode 100644 src/test/compile-fail/static-mut-not-pat.rs delete mode 100644 src/test/compile-fail/static-mut-requires-unsafe.rs delete mode 100644 src/test/compile-fail/static-priv-by-default.rs delete mode 100644 src/test/compile-fail/static-priv-by-default2.rs delete mode 100644 src/test/compile-fail/static-reference-to-fn-1.rs delete mode 100644 src/test/compile-fail/static-reference-to-fn-2.rs delete mode 100644 src/test/compile-fail/static-region-bound.rs delete mode 100644 src/test/compile-fail/static-vec-repeat-not-constant.rs delete mode 100644 src/test/compile-fail/staticness-mismatch.rs delete mode 100644 src/test/compile-fail/std-uncopyable-atomics.rs delete mode 100644 src/test/compile-fail/stmt_expr_attrs_no_feature.rs delete mode 100644 src/test/compile-fail/str-idx.rs delete mode 100644 src/test/compile-fail/str-mut-idx.rs delete mode 100644 src/test/compile-fail/struct-base-wrong-type-2.rs delete mode 100644 src/test/compile-fail/struct-base-wrong-type.rs delete mode 100644 src/test/compile-fail/struct-field-cfg.rs delete mode 100644 src/test/compile-fail/struct-field-privacy.rs delete mode 100644 src/test/compile-fail/struct-fields-dupe.rs delete mode 100644 src/test/compile-fail/struct-fields-missing.rs delete mode 100644 src/test/compile-fail/struct-fields-shorthand-unresolved.rs delete mode 100644 src/test/compile-fail/struct-fields-shorthand.rs delete mode 100644 src/test/compile-fail/struct-fields-typo.rs delete mode 100644 src/test/compile-fail/struct-like-enum-nonexhaustive.rs delete mode 100644 src/test/compile-fail/struct-pat-derived-error.rs delete mode 100644 src/test/compile-fail/struct-path-alias-bounds.rs delete mode 100644 src/test/compile-fail/struct-path-associated-type.rs delete mode 100644 src/test/compile-fail/struct-path-self.rs delete mode 100644 src/test/compile-fail/struct-pattern-match-useless.rs delete mode 100644 src/test/compile-fail/struct-variant-privacy-xc.rs delete mode 100644 src/test/compile-fail/struct-variant-privacy.rs delete mode 100644 src/test/compile-fail/structure-constructor-type-mismatch.rs delete mode 100644 src/test/compile-fail/substs-ppaux.rs delete mode 100644 src/test/compile-fail/suffixed-literal-meta.rs delete mode 100644 src/test/compile-fail/super-at-top-level.rs delete mode 100644 src/test/compile-fail/suppressed-error.rs delete mode 100644 src/test/compile-fail/symbol-names/basic.rs delete mode 100644 src/test/compile-fail/symbol-names/impl1.rs delete mode 100644 src/test/compile-fail/syntax-extension-minor.rs delete mode 100644 src/test/compile-fail/syntax-trait-polarity-feature-gate.rs delete mode 100644 src/test/compile-fail/syntax-trait-polarity.rs delete mode 100644 src/test/compile-fail/synthetic-param.rs delete mode 100644 src/test/compile-fail/tag-that-dare-not-speak-its-name.rs delete mode 100644 src/test/compile-fail/tag-type-args.rs delete mode 100644 src/test/compile-fail/tag-variant-cast-non-nullary.rs delete mode 100644 src/test/compile-fail/tag-variant-disr-dup.rs delete mode 100644 src/test/compile-fail/tail-typeck.rs delete mode 100644 src/test/compile-fail/terr-in-field.rs delete mode 100644 src/test/compile-fail/terr-sorts.rs delete mode 100644 src/test/compile-fail/test-cfg.rs delete mode 100644 src/test/compile-fail/test-warns-dead-code.rs delete mode 100644 src/test/compile-fail/thread-local-in-ctfe.rs delete mode 100644 src/test/compile-fail/tool_lints.rs delete mode 100644 src/test/compile-fail/trace_macros-format.rs delete mode 100644 src/test/compile-fail/trace_macros-gate.rs delete mode 100644 src/test/compile-fail/trait-alias.rs delete mode 100644 src/test/compile-fail/trait-as-struct-constructor.rs delete mode 100644 src/test/compile-fail/trait-bounds-not-on-bare-trait.rs delete mode 100644 src/test/compile-fail/trait-bounds-not-on-struct.rs delete mode 100644 src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs delete mode 100644 src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs delete mode 100644 src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs delete mode 100644 src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs delete mode 100644 src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs delete mode 100644 src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs delete mode 100644 src/test/compile-fail/trait-bounds-on-structs-and-enums.rs delete mode 100644 src/test/compile-fail/trait-bounds-sugar.rs delete mode 100644 src/test/compile-fail/trait-coercion-generic-bad.rs delete mode 100644 src/test/compile-fail/trait-coercion-generic-regions.rs delete mode 100644 src/test/compile-fail/trait-impl-1.rs delete mode 100644 src/test/compile-fail/trait-impl-can-not-have-untraitful-items.rs delete mode 100644 src/test/compile-fail/trait-impl-different-num-params.rs delete mode 100644 src/test/compile-fail/trait-impl-for-module.rs delete mode 100644 src/test/compile-fail/trait-impl-method-mismatch.rs delete mode 100644 src/test/compile-fail/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs delete mode 100644 src/test/compile-fail/trait-item-privacy.rs delete mode 100644 src/test/compile-fail/trait-matching-lifetimes.rs delete mode 100644 src/test/compile-fail/trait-object-macro-matcher.rs delete mode 100644 src/test/compile-fail/trait-object-safety.rs delete mode 100644 src/test/compile-fail/trait-object-vs-lifetime-2.rs delete mode 100644 src/test/compile-fail/trait-object-vs-lifetime.rs delete mode 100644 src/test/compile-fail/trait-or-new-type-instead.rs delete mode 100644 src/test/compile-fail/trait-privacy.rs delete mode 100644 src/test/compile-fail/trait-resolution-in-overloaded-op.rs delete mode 100644 src/test/compile-fail/trait-safety-inherent-impl.rs delete mode 100644 src/test/compile-fail/trait-safety-trait-impl-cc.rs delete mode 100644 src/test/compile-fail/trait-safety-trait-impl.rs delete mode 100644 src/test/compile-fail/trait-static-method-generic-inference.rs delete mode 100644 src/test/compile-fail/trait-test-2.rs delete mode 100644 src/test/compile-fail/trait-test.rs delete mode 100644 src/test/compile-fail/traits-assoc-type-in-supertrait-bad.rs delete mode 100644 src/test/compile-fail/traits-inductive-overflow-simultaneous.rs delete mode 100644 src/test/compile-fail/traits-inductive-overflow-supertrait-oibit.rs delete mode 100644 src/test/compile-fail/traits-inductive-overflow-supertrait.rs delete mode 100644 src/test/compile-fail/traits-inductive-overflow-two-traits.rs delete mode 100644 src/test/compile-fail/traits-issue-23003-overflow.rs delete mode 100644 src/test/compile-fail/traits-multidispatch-bad.rs delete mode 100644 src/test/compile-fail/traits-negative-impls.rs delete mode 100644 src/test/compile-fail/traits-repeated-supertrait-ambig.rs delete mode 100644 src/test/compile-fail/transmute-different-sizes.rs delete mode 100644 src/test/compile-fail/transmute-fat-pointers.rs delete mode 100644 src/test/compile-fail/transmute-impl.rs delete mode 100644 src/test/compile-fail/transmute-imut-to-mut.rs delete mode 100644 src/test/compile-fail/trivial_casts.rs delete mode 100644 src/test/compile-fail/tuple-arity-mismatch.rs delete mode 100644 src/test/compile-fail/tuple-index-not-tuple.rs delete mode 100644 src/test/compile-fail/tuple-index-out-of-bounds.rs delete mode 100644 src/test/compile-fail/tuple-struct-nonexhaustive.rs delete mode 100644 src/test/compile-fail/tutorial-suffix-inference-test.rs delete mode 100644 src/test/compile-fail/type-arg-out-of-scope.rs delete mode 100644 src/test/compile-fail/type-ascription-precedence.rs delete mode 100644 src/test/compile-fail/type-ascription-soundness.rs delete mode 100644 src/test/compile-fail/type-mismatch-multiple.rs delete mode 100644 src/test/compile-fail/type-mismatch-same-crate-name.rs delete mode 100644 src/test/compile-fail/type-parameter-defaults-referencing-Self-ppaux.rs delete mode 100644 src/test/compile-fail/type-parameter-defaults-referencing-Self.rs delete mode 100644 src/test/compile-fail/type-parameter-names.rs delete mode 100644 src/test/compile-fail/type-params-in-different-spaces-1.rs delete mode 100644 src/test/compile-fail/type-params-in-different-spaces-2.rs delete mode 100644 src/test/compile-fail/type-params-in-different-spaces-3.rs delete mode 100644 src/test/compile-fail/type-path-err-node-types.rs delete mode 100644 src/test/compile-fail/type-shadow.rs delete mode 100644 src/test/compile-fail/type_length_limit.rs delete mode 100644 src/test/compile-fail/typeck-auto-trait-no-supertraits-2.rs delete mode 100644 src/test/compile-fail/typeck-auto-trait-no-supertraits.rs delete mode 100644 src/test/compile-fail/typeck-cast-pointer-to-float.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-negation-send.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-negation.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-precedence.rs delete mode 100644 src/test/compile-fail/typeck-default-trait-impl-send-param.rs delete mode 100644 src/test/compile-fail/typeck-negative-impls-builtin.rs delete mode 100644 src/test/compile-fail/typeck-unsafe-always-share.rs delete mode 100644 src/test/compile-fail/typeck_type_placeholder_mismatch.rs delete mode 100644 src/test/compile-fail/ufcs-explicit-self-bad.rs delete mode 100644 src/test/compile-fail/ufcs-partially-resolved.rs delete mode 100644 src/test/compile-fail/ufcs-qpath-missing-params.rs delete mode 100644 src/test/compile-fail/ufcs-qpath-self-mismatch.rs delete mode 100644 src/test/compile-fail/unboxed-closure-feature-gate.rs delete mode 100644 src/test/compile-fail/unboxed-closure-illegal-move.rs delete mode 100644 src/test/compile-fail/unboxed-closure-immutable-capture.rs delete mode 100644 src/test/compile-fail/unboxed-closure-region.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-default.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-equiv.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-region.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs delete mode 100644 src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs delete mode 100644 src/test/compile-fail/unboxed-closures-borrow-conflict.rs delete mode 100644 src/test/compile-fail/unboxed-closures-failed-recursive-fn-1.rs delete mode 100644 src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs delete mode 100644 src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs delete mode 100644 src/test/compile-fail/unboxed-closures-infer-argument-types-two-region-pointers.rs delete mode 100644 src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs delete mode 100644 src/test/compile-fail/unboxed-closures-infer-fnmut-missing-mut.rs delete mode 100644 src/test/compile-fail/unboxed-closures-infer-fnmut-move-missing-mut.rs delete mode 100644 src/test/compile-fail/unboxed-closures-infer-fnonce-call-twice.rs delete mode 100644 src/test/compile-fail/unboxed-closures-infer-fnonce-move-call-twice.rs delete mode 100644 src/test/compile-fail/unboxed-closures-mutate-upvar.rs delete mode 100644 src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs delete mode 100644 src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs delete mode 100644 src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs delete mode 100644 src/test/compile-fail/unboxed-closures-type-mismatch.rs delete mode 100644 src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs delete mode 100644 src/test/compile-fail/unboxed-closures-wrong-abi.rs delete mode 100644 src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs delete mode 100644 src/test/compile-fail/underscore-lifetime-binders.rs delete mode 100644 src/test/compile-fail/underscore-lifetime-elison-mismatch.rs delete mode 100644 src/test/compile-fail/uninhabited-enum-cast.rs delete mode 100644 src/test/compile-fail/uninhabited-irrefutable.rs delete mode 100644 src/test/compile-fail/uninhabited-matches-feature-gated.rs delete mode 100644 src/test/compile-fail/uninhabited-patterns.rs delete mode 100644 src/test/compile-fail/union-ub-fat-ptr.rs delete mode 100644 src/test/compile-fail/union/union-borrow-move-parent-sibling.rs delete mode 100644 src/test/compile-fail/union/union-const-pat.rs delete mode 100644 src/test/compile-fail/union/union-copy.rs delete mode 100644 src/test/compile-fail/union/union-derive-clone.rs delete mode 100644 src/test/compile-fail/union/union-derive.rs delete mode 100644 src/test/compile-fail/union/union-empty.rs delete mode 100644 src/test/compile-fail/union/union-generic.rs delete mode 100644 src/test/compile-fail/union/union-lint-dead-code.rs delete mode 100644 src/test/compile-fail/union/union-nonrepresentable.rs delete mode 100644 src/test/compile-fail/union/union-repr-c.rs delete mode 100644 src/test/compile-fail/union/union-unsafe.rs delete mode 100644 src/test/compile-fail/union/union-unsized.rs delete mode 100644 src/test/compile-fail/union/union-with-drop-fields-lint.rs delete mode 100644 src/test/compile-fail/unique-object-noncopyable.rs delete mode 100644 src/test/compile-fail/unique-pinned-nocopy.rs delete mode 100644 src/test/compile-fail/unknown-lint-tool-name.rs delete mode 100644 src/test/compile-fail/unknown-tool-name.rs delete mode 100644 src/test/compile-fail/unop-move-semantics.rs delete mode 100644 src/test/compile-fail/unop-neg-bool.rs delete mode 100644 src/test/compile-fail/unreachable-arm.rs delete mode 100644 src/test/compile-fail/unreachable-code.rs delete mode 100644 src/test/compile-fail/unreachable-in-call.rs delete mode 100644 src/test/compile-fail/unreachable-loop-patterns.rs delete mode 100644 src/test/compile-fail/unreachable-try-pattern.rs delete mode 100644 src/test/compile-fail/unreachable-variant.rs delete mode 100644 src/test/compile-fail/unresolved-extern-mod-suggestion.rs delete mode 100644 src/test/compile-fail/unresolved-import-recovery.rs delete mode 100644 src/test/compile-fail/unresolved-import.rs delete mode 100644 src/test/compile-fail/unsafe-around-compiler-generated-unsafe.rs delete mode 100644 src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs delete mode 100644 src/test/compile-fail/unsafe-fn-autoderef.rs delete mode 100644 src/test/compile-fail/unsafe-fn-called-from-safe.rs delete mode 100644 src/test/compile-fail/unsafe-fn-deref-ptr.rs delete mode 100644 src/test/compile-fail/unsafe-fn-used-as-value.rs delete mode 100644 src/test/compile-fail/unsafe-move-val-init.rs delete mode 100644 src/test/compile-fail/unsafe-subtyping.rs delete mode 100644 src/test/compile-fail/unsafe-trait-impl.rs delete mode 100644 src/test/compile-fail/unsized-bare-typaram.rs delete mode 100644 src/test/compile-fail/unsized-enum.rs delete mode 100644 src/test/compile-fail/unsized-inherent-impl-self-type.rs delete mode 100644 src/test/compile-fail/unsized-struct.rs delete mode 100644 src/test/compile-fail/unsized-trait-impl-self-type.rs delete mode 100644 src/test/compile-fail/unsized-trait-impl-trait-arg.rs delete mode 100644 src/test/compile-fail/unsized3.rs delete mode 100644 src/test/compile-fail/unsized5.rs delete mode 100644 src/test/compile-fail/unsized6.rs delete mode 100644 src/test/compile-fail/unsized7.rs delete mode 100644 src/test/compile-fail/unspecified-self-in-trait-ref.rs delete mode 100644 src/test/compile-fail/unsupported-cast.rs delete mode 100644 src/test/compile-fail/unused-attr.rs delete mode 100644 src/test/compile-fail/unused-macro-rules.rs delete mode 100644 src/test/compile-fail/unused-macro-with-bad-frag-spec.rs delete mode 100644 src/test/compile-fail/unused-macro-with-follow-violation.rs delete mode 100644 src/test/compile-fail/unused-macro.rs delete mode 100644 src/test/compile-fail/unused-mut-warning-captured-var.rs delete mode 100644 src/test/compile-fail/unused-result.rs delete mode 100644 src/test/compile-fail/use-after-move-based-on-type.rs delete mode 100644 src/test/compile-fail/use-after-move-implicity-coerced-object.rs delete mode 100644 src/test/compile-fail/use-after-move-self-based-on-type.rs delete mode 100644 src/test/compile-fail/use-after-move-self.rs delete mode 100644 src/test/compile-fail/use-from-trait-xc.rs delete mode 100644 src/test/compile-fail/use-from-trait.rs delete mode 100644 src/test/compile-fail/use-keyword.rs delete mode 100644 src/test/compile-fail/use-meta-mismatch.rs delete mode 100644 src/test/compile-fail/use-mod-2.rs delete mode 100644 src/test/compile-fail/use-mod-3.rs delete mode 100644 src/test/compile-fail/use-mod-4.rs delete mode 100644 src/test/compile-fail/use-paths-as-items.rs delete mode 100644 src/test/compile-fail/use-self-type.rs delete mode 100644 src/test/compile-fail/use-super-global-path.rs delete mode 100644 src/test/compile-fail/used.rs delete mode 100644 src/test/compile-fail/useless-pub.rs delete mode 100644 src/test/compile-fail/useless_comment.rs delete mode 100644 src/test/compile-fail/user-defined-macro-rules.rs delete mode 100644 src/test/compile-fail/utf8_idents.rs delete mode 100644 src/test/compile-fail/variadic-ffi-2.rs delete mode 100644 src/test/compile-fail/variadic-ffi.rs delete mode 100644 src/test/compile-fail/variance-associated-types.rs delete mode 100644 src/test/compile-fail/variance-btree-invariant-types.rs delete mode 100644 src/test/compile-fail/variance-cell-is-invariant.rs delete mode 100644 src/test/compile-fail/variance-contravariant-arg-object.rs delete mode 100644 src/test/compile-fail/variance-contravariant-arg-trait-match.rs delete mode 100644 src/test/compile-fail/variance-contravariant-self-trait-match.rs delete mode 100644 src/test/compile-fail/variance-covariant-arg-object.rs delete mode 100644 src/test/compile-fail/variance-covariant-arg-trait-match.rs delete mode 100644 src/test/compile-fail/variance-covariant-self-trait-match.rs delete mode 100644 src/test/compile-fail/variance-invariant-arg-object.rs delete mode 100644 src/test/compile-fail/variance-invariant-arg-trait-match.rs delete mode 100644 src/test/compile-fail/variance-invariant-self-trait-match.rs delete mode 100644 src/test/compile-fail/variance-issue-20533.rs delete mode 100644 src/test/compile-fail/variance-object-types.rs delete mode 100644 src/test/compile-fail/variance-regions-direct.rs delete mode 100644 src/test/compile-fail/variance-regions-indirect.rs delete mode 100644 src/test/compile-fail/variance-regions-unused-direct.rs delete mode 100644 src/test/compile-fail/variance-regions-unused-indirect.rs delete mode 100644 src/test/compile-fail/variance-trait-bounds.rs delete mode 100644 src/test/compile-fail/variance-trait-matching.rs delete mode 100644 src/test/compile-fail/variance-trait-object-bound.rs delete mode 100644 src/test/compile-fail/variance-types-bounds.rs delete mode 100644 src/test/compile-fail/variance-types.rs delete mode 100644 src/test/compile-fail/variance-unused-region-param.rs delete mode 100644 src/test/compile-fail/variance-use-contravariant-struct-1.rs delete mode 100644 src/test/compile-fail/variance-use-contravariant-struct-2.rs delete mode 100644 src/test/compile-fail/variance-use-covariant-struct-1.rs delete mode 100644 src/test/compile-fail/variance-use-covariant-struct-2.rs delete mode 100644 src/test/compile-fail/variance-use-invariant-struct-1.rs delete mode 100644 src/test/compile-fail/variant-namespacing.rs delete mode 100644 src/test/compile-fail/variant-size-differences.rs delete mode 100644 src/test/compile-fail/variant-used-as-type.rs delete mode 100644 src/test/compile-fail/vec-macro-with-comma-only.rs delete mode 100644 src/test/compile-fail/vec-mut-iter-borrow.rs delete mode 100644 src/test/compile-fail/vec-res-add.rs delete mode 100644 src/test/compile-fail/vector-cast-weirdness.rs delete mode 100644 src/test/compile-fail/vtable-res-trait-param.rs delete mode 100644 src/test/compile-fail/walk-struct-literal-with.rs delete mode 100644 src/test/compile-fail/warn-path-statement.rs delete mode 100644 src/test/compile-fail/weak-lang-item.rs delete mode 100644 src/test/compile-fail/wf-array-elem-sized.rs delete mode 100644 src/test/compile-fail/wf-const-type.rs delete mode 100644 src/test/compile-fail/wf-enum-bound.rs delete mode 100644 src/test/compile-fail/wf-enum-fields-struct-variant.rs delete mode 100644 src/test/compile-fail/wf-enum-fields.rs delete mode 100644 src/test/compile-fail/wf-fn-where-clause.rs delete mode 100644 src/test/compile-fail/wf-impl-associated-type-region.rs delete mode 100644 src/test/compile-fail/wf-impl-associated-type-trait.rs delete mode 100644 src/test/compile-fail/wf-in-fn-arg.rs delete mode 100644 src/test/compile-fail/wf-in-fn-ret.rs delete mode 100644 src/test/compile-fail/wf-in-fn-type-arg.rs delete mode 100644 src/test/compile-fail/wf-in-fn-type-ret.rs delete mode 100644 src/test/compile-fail/wf-in-fn-type-static.rs delete mode 100644 src/test/compile-fail/wf-in-fn-where-clause.rs delete mode 100644 src/test/compile-fail/wf-in-obj-type-static.rs delete mode 100644 src/test/compile-fail/wf-in-obj-type-trait.rs delete mode 100644 src/test/compile-fail/wf-inherent-impl-method-where-clause.rs delete mode 100644 src/test/compile-fail/wf-inherent-impl-where-clause.rs delete mode 100644 src/test/compile-fail/wf-misc-methods-issue-28609.rs delete mode 100644 src/test/compile-fail/wf-object-safe.rs delete mode 100644 src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs delete mode 100644 src/test/compile-fail/wf-static-method.rs delete mode 100644 src/test/compile-fail/wf-static-type.rs delete mode 100644 src/test/compile-fail/wf-struct-bound.rs delete mode 100644 src/test/compile-fail/wf-struct-field.rs delete mode 100644 src/test/compile-fail/wf-trait-associated-type-bound.rs delete mode 100644 src/test/compile-fail/wf-trait-associated-type-region.rs delete mode 100644 src/test/compile-fail/wf-trait-associated-type-trait.rs delete mode 100644 src/test/compile-fail/wf-trait-bound.rs delete mode 100644 src/test/compile-fail/wf-trait-default-fn-arg.rs delete mode 100644 src/test/compile-fail/wf-trait-default-fn-ret.rs delete mode 100644 src/test/compile-fail/wf-trait-default-fn-where-clause.rs delete mode 100644 src/test/compile-fail/wf-trait-fn-arg.rs delete mode 100644 src/test/compile-fail/wf-trait-fn-ret.rs delete mode 100644 src/test/compile-fail/wf-trait-fn-where-clause.rs delete mode 100644 src/test/compile-fail/wf-trait-superbound.rs delete mode 100644 src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs delete mode 100644 src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs delete mode 100644 src/test/compile-fail/where-clause-method-substituion.rs delete mode 100644 src/test/compile-fail/where-clauses-method-unsatisfied.rs delete mode 100644 src/test/compile-fail/where-clauses-unsatisfied.rs delete mode 100644 src/test/compile-fail/where-equality-constraints.rs delete mode 100644 src/test/compile-fail/where-for-self-2.rs delete mode 100644 src/test/compile-fail/where-for-self.rs delete mode 100644 src/test/compile-fail/where-lifetime-resolution.rs delete mode 100644 src/test/compile-fail/while-let.rs delete mode 100644 src/test/compile-fail/while-type-error.rs delete mode 100644 src/test/compile-fail/windows-subsystem-invalid.rs delete mode 100644 src/test/compile-fail/write-to-static-mut-in-static.rs delete mode 100644 src/test/compile-fail/writing-to-immutable-vec.rs delete mode 100644 src/test/compile-fail/wrong-mul-method-signature.rs delete mode 100644 src/test/compile-fail/wrong-ret-type.rs delete mode 100644 src/test/compile-fail/xc-private-method.rs delete mode 100644 src/test/compile-fail/xc-private-method2.rs delete mode 100644 src/test/compile-fail/xcrate-private-by-default.rs delete mode 100644 src/test/compile-fail/xcrate-unit-struct.rs create mode 100644 src/test/ui/compile-fail-migration/.gitattributes create mode 100644 src/test/ui/compile-fail-migration/E0501.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/E0501.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/E0501.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/E0501.rs create mode 100644 src/test/ui/compile-fail-migration/E0506.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/E0506.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/E0506.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/E0506.rs create mode 100644 src/test/ui/compile-fail-migration/E0508.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/E0508.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/E0508.rs create mode 100644 src/test/ui/compile-fail-migration/E0583.rs create mode 100644 src/test/ui/compile-fail-migration/E0583.stderr create mode 100644 src/test/ui/compile-fail-migration/E0594.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/E0594.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/E0594.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/E0594.rs create mode 100644 src/test/ui/compile-fail-migration/E0596.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/E0596.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/E0596.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/E0596.rs create mode 100644 src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.rs create mode 100644 src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.stderr create mode 100644 src/test/ui/compile-fail-migration/access-mode-in-closures.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/access-mode-in-closures.rs create mode 100644 src/test/ui/compile-fail-migration/access-mode-in-closures.stderr create mode 100644 src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.rs create mode 100644 src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.stderr create mode 100644 src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.rs create mode 100644 src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.stderr create mode 100644 src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.rs create mode 100644 src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.stderr create mode 100644 src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator.rs create mode 100644 src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator2.rs create mode 100644 src/test/ui/compile-fail-migration/allocator/function-allocator.rs create mode 100644 src/test/ui/compile-fail-migration/allocator/function-allocator.stderr create mode 100644 src/test/ui/compile-fail-migration/allocator/not-an-allocator.rs create mode 100644 src/test/ui/compile-fail-migration/allocator/not-an-allocator.stderr create mode 100644 src/test/ui/compile-fail-migration/allocator/two-allocators.rs create mode 100644 src/test/ui/compile-fail-migration/allocator/two-allocators.stderr create mode 100644 src/test/ui/compile-fail-migration/allocator/two-allocators2.rs create mode 100644 src/test/ui/compile-fail-migration/allocator/two-allocators2.stderr create mode 100644 src/test/ui/compile-fail-migration/allocator/two-allocators3.rs create mode 100644 src/test/ui/compile-fail-migration/allocator/two-allocators3.stderr create mode 100644 src/test/ui/compile-fail-migration/anon-params-deprecated.rs create mode 100644 src/test/ui/compile-fail-migration/anon-params-deprecated.stderr create mode 100644 src/test/ui/compile-fail-migration/arg-count-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/arg-count-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/arg-type-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/arg-type-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/array-not-vector.rs create mode 100644 src/test/ui/compile-fail-migration/array-not-vector.stderr create mode 100644 src/test/ui/compile-fail-migration/array_const_index-0.rs create mode 100644 src/test/ui/compile-fail-migration/array_const_index-0.stderr create mode 100644 src/test/ui/compile-fail-migration/array_const_index-1.rs create mode 100644 src/test/ui/compile-fail-migration/array_const_index-1.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-bad-clobber.rs create mode 100644 src/test/ui/compile-fail-migration/asm-bad-clobber.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-in-bad-modifier.rs create mode 100644 src/test/ui/compile-fail-migration/asm-in-bad-modifier.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-misplaced-option.rs create mode 100644 src/test/ui/compile-fail-migration/asm-misplaced-option.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-out-no-modifier.rs create mode 100644 src/test/ui/compile-fail-migration/asm-out-no-modifier.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-out-read-uninit.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-out-read-uninit.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-out-read-uninit.rs create mode 100644 src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.rs create mode 100644 src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.stderr create mode 100644 src/test/ui/compile-fail-migration/asm-src-loc.rs create mode 100644 src/test/ui/compile-fail-migration/asm-src-loc.stderr create mode 100644 src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/assign-imm-local-twice.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/assign-imm-local-twice.rs create mode 100644 src/test/ui/compile-fail-migration/assign-to-method.rs create mode 100644 src/test/ui/compile-fail-migration/assign-to-method.stderr create mode 100644 src/test/ui/compile-fail-migration/assignment-operator-unimplemented.rs create mode 100644 src/test/ui/compile-fail-migration/assignment-operator-unimplemented.stderr create mode 100644 src/test/ui/compile-fail-migration/assoc-inherent.rs create mode 100644 src/test/ui/compile-fail-migration/assoc-inherent.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-ambiguity-report.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-ambiguity-report.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-array-len.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-array-len.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-dead-code.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-dead-code.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-generic-obligations.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-generic-obligations.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-in-trait.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-in-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-no-item.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-no-item.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-private-impl.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-private-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-const-upper-case-lint.rs create mode 100644 src/test/ui/compile-fail-migration/associated-const-upper-case-lint.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.rs create mode 100644 src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.rs create mode 100644 src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-item-duplicate-names.rs create mode 100644 src/test/ui/compile-fail-migration/associated-item-duplicate-names.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-path-shl.rs create mode 100644 src/test/ui/compile-fail-migration/associated-path-shl.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.rs create mode 100644 src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-bound-failure.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-bound-failure.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-coherence-failure.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-coherence-failure.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-1.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-1.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-2.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-2.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-3.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-3.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-expr-path.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-expr-path.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-hr.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-eq-hr.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-incomplete-object.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-incomplete-object.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-issue-17359.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-issue-17359.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-issue-20346.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-issue-20346.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-outlives.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-outlives.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-outlives.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-overridden-default.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-overridden-default.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-path-1.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-path-1.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-path-2.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-path-2.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-subtyping-1.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-subtyping-1.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-unconstrained.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-unconstrained.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types-unsized.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types-unsized.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.clause.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.func.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.object.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.angle.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.elision.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.ok.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.paren.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.elision.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.local.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.ok.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.sig.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.structure.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/elision.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/elision.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.ok.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.ok.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.bad.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.good.stderr create mode 100644 src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/issue-36499.rs create mode 100644 src/test/ui/compile-fail-migration/associated-types/issue-36499.stderr create mode 100644 src/test/ui/compile-fail-migration/attempted-access-non-fatal.rs create mode 100644 src/test/ui/compile-fail-migration/attempted-access-non-fatal.stderr create mode 100644 src/test/ui/compile-fail-migration/attr-bad-crate-attr.rc create mode 100644 src/test/ui/compile-fail-migration/attr-usage-inline.rs create mode 100644 src/test/ui/compile-fail-migration/attr-usage-inline.stderr create mode 100644 src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.rs create mode 100644 src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.stderr create mode 100644 src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.rs create mode 100644 src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.stderr create mode 100644 src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.rs create mode 100644 src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.stderr create mode 100644 src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.rs create mode 100644 src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.stderr create mode 100644 src/test/ui/compile-fail-migration/auto-trait-validation.rs create mode 100644 src/test/ui/compile-fail-migration/auto-trait-validation.stderr create mode 100644 src/test/ui/compile-fail-migration/autoderef-full-lval.rs create mode 100644 src/test/ui/compile-fail-migration/autoderef-full-lval.stderr create mode 100644 src/test/ui/compile-fail-migration/auxiliary/ambig_impl_2_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/cci_class.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/cci_class_5.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/cdylib-dep.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/coherence_copy_like_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/coherence_inherent_cc_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/coherence_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/coherence_orphan_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/const_fn_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/crate_a1.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/crate_a2.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/crateresolve1-1.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/crateresolve1-2.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/crateresolve1-3.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/default_ty_param_cross_crate_crate.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/define_macro.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/deprecation-lint.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/edition-extern-crate-allowed.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/empty-struct.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/extern-statics.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/go_trait.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/import_crate_var.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/inherited_stability.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/internal_unstable.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue-19163.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue-21146-inc.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue-29181.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue-30535.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue-36881-aux.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue-52489.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_11680.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_16725.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_17718_const_privacy.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_1920.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_21202.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_30123_aux.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_41549.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/issue_5844_aux.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lifetime_bound_will_change_warning_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_output_format.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_stability.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_stability_fields.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate2.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate3.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate4.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate5.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols1.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols2.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/macro_crate_nonterminal.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/namespace-mix.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/namespaced_enums.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/noexporttypelib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/orphan_check_diagnostics.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/privacy_tuple_struct.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/private-inferred-type.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/private_trait_xc.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/rbmtp_cross_crate_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/recursive_reexports.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/rmeta_meta.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/rmeta_rlib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/some-panic-impl.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/stability_attribute_issue.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/stability_cfg1.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/stability_cfg2.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/static_priv_by_default.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/struct_field_privacy.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/struct_variant_privacy.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/tdticc_coherence_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/trait_bounds_on_structs_and_enums_xc.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/trait_impl_conflict.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/trait_safety_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/trait_superkinds_in_metadata.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/two_macros.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/unreachable_variant.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/unstable-macros.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/use_from_trait_xc.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/variant-namespacing.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/weak-lang-items.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/xc_private_method_lib.rs create mode 100644 src/test/ui/compile-fail-migration/auxiliary/xcrate_unit_struct.rs create mode 100644 src/test/ui/compile-fail-migration/bad-const-type.rs create mode 100644 src/test/ui/compile-fail-migration/bad-const-type.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-env-capture.rs create mode 100644 src/test/ui/compile-fail-migration/bad-env-capture.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-env-capture2.rs create mode 100644 src/test/ui/compile-fail-migration/bad-env-capture2.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-env-capture3.rs create mode 100644 src/test/ui/compile-fail-migration/bad-env-capture3.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-expr-lhs.rs create mode 100644 src/test/ui/compile-fail-migration/bad-expr-lhs.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-expr-path.rs create mode 100644 src/test/ui/compile-fail-migration/bad-expr-path.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-expr-path2.rs create mode 100644 src/test/ui/compile-fail-migration/bad-expr-path2.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-extern-link-attrs.rs create mode 100644 src/test/ui/compile-fail-migration/bad-extern-link-attrs.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.rs create mode 100644 src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-lint-cap.rs create mode 100644 src/test/ui/compile-fail-migration/bad-lint-cap.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-lint-cap2.rs create mode 100644 src/test/ui/compile-fail-migration/bad-lint-cap2.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-lint-cap3.rs create mode 100644 src/test/ui/compile-fail-migration/bad-lint-cap3.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-main.rs create mode 100644 src/test/ui/compile-fail-migration/bad-main.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-method-typaram-kind.rs create mode 100644 src/test/ui/compile-fail-migration/bad-method-typaram-kind.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-mid-path-type-params.rs create mode 100644 src/test/ui/compile-fail-migration/bad-mid-path-type-params.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-module.rs create mode 100644 src/test/ui/compile-fail-migration/bad-module.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-sized.rs create mode 100644 src/test/ui/compile-fail-migration/bad-sized.stderr create mode 100644 src/test/ui/compile-fail-migration/bad-type-env-capture.rs create mode 100644 src/test/ui/compile-fail-migration/bad-type-env-capture.stderr create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.rs create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.stderr create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.rs create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.stderr create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.rs create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.stderr create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-no-guards.rs create mode 100644 src/test/ui/compile-fail-migration/bind-by-move-no-guards.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-bitxor-str.rs create mode 100644 src/test/ui/compile-fail-migration/binop-bitxor-str.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-consume-args.rs create mode 100644 src/test/ui/compile-fail-migration/binop-consume-args.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-logic-float.rs create mode 100644 src/test/ui/compile-fail-migration/binop-logic-float.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-logic-int.rs create mode 100644 src/test/ui/compile-fail-migration/binop-logic-int.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-move-semantics.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-move-semantics.rs create mode 100644 src/test/ui/compile-fail-migration/binop-move-semantics.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-mul-bool.rs create mode 100644 src/test/ui/compile-fail-migration/binop-mul-bool.stderr create mode 100644 src/test/ui/compile-fail-migration/binop-typeck.rs create mode 100644 src/test/ui/compile-fail-migration/binop-typeck.stderr create mode 100644 src/test/ui/compile-fail-migration/blind-item-block-item-shadow.rs create mode 100644 src/test/ui/compile-fail-migration/blind-item-block-item-shadow.stderr create mode 100644 src/test/ui/compile-fail-migration/blind-item-block-middle.rs create mode 100644 src/test/ui/compile-fail-migration/blind-item-block-middle.stderr create mode 100644 src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.rs create mode 100644 src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.stderr create mode 100644 src/test/ui/compile-fail-migration/borrow-tuple-fields.rs create mode 100644 src/test/ui/compile-fail-migration/borrow-tuple-fields.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-argument.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-argument.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-argument.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-asm.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-asm.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-return.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-return.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-while.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/borrowck-while.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.nll_target.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.rs create mode 100644 src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.stderr create mode 100644 src/test/ui/compile-fail-migration/bounds-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/bounds-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/break-outside-loop.rs create mode 100644 src/test/ui/compile-fail-migration/break-outside-loop.stderr create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.rs create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.stderr create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.rs create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.stderr create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-self-type.rs create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-self-type.stderr create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-simple.rs create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-simple.stderr create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.rs create mode 100644 src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.stderr create mode 100644 src/test/ui/compile-fail-migration/by-move-pattern-binding.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/by-move-pattern-binding.rs create mode 100644 src/test/ui/compile-fail-migration/by-move-pattern-binding.stderr create mode 100644 src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.rs create mode 100644 src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.stderr create mode 100644 src/test/ui/compile-fail-migration/can-begin-expr-check.rs create mode 100644 src/test/ui/compile-fail-migration/can-begin-expr-check.stderr create mode 100644 src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.rs create mode 100644 src/test/ui/compile-fail-migration/capture1.rs create mode 100644 src/test/ui/compile-fail-migration/capture1.stderr create mode 100644 src/test/ui/compile-fail-migration/cast-from-nil.rs create mode 100644 src/test/ui/compile-fail-migration/cast-from-nil.stderr create mode 100644 src/test/ui/compile-fail-migration/cast-ptr-to-int-const.rs create mode 100644 src/test/ui/compile-fail-migration/cast-ptr-to-int-const.stderr create mode 100644 src/test/ui/compile-fail-migration/cast-to-bare-fn.rs create mode 100644 src/test/ui/compile-fail-migration/cast-to-bare-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/cast-to-nil.rs create mode 100644 src/test/ui/compile-fail-migration/cast-to-nil.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-bad-lifetime.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-bad-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/catch-bad-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-bad-type.rs create mode 100644 src/test/ui/compile-fail-migration/catch-bad-type.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-in-match.rs create mode 100644 src/test/ui/compile-fail-migration/catch-in-match.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-in-while.rs create mode 100644 src/test/ui/compile-fail-migration/catch-in-while.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-opt-init.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/catch-opt-init.rs create mode 100644 src/test/ui/compile-fail-migration/catch-opt-init.stderr create mode 100644 src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.rs create mode 100644 src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.stderr create mode 100644 src/test/ui/compile-fail-migration/cfg-arg-invalid.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-cfg-2.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-cfg-2.stderr create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-crate-2.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-crate-2.stderr create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.stderr create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.stderr create mode 100644 src/test/ui/compile-fail-migration/cfg-empty-codemap.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-in-crate-1.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-in-crate-1.stderr create mode 100644 src/test/ui/compile-fail-migration/cfg-non-opt-expr.rs create mode 100644 src/test/ui/compile-fail-migration/cfg-non-opt-expr.stderr create mode 100644 src/test/ui/compile-fail-migration/cfg_attr_path.rs create mode 100644 src/test/ui/compile-fail-migration/cfg_attr_path.stderr create mode 100644 src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.rs create mode 100644 src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.stderr create mode 100644 src/test/ui/compile-fail-migration/check-static-values-constraints.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/check-static-values-constraints.rs create mode 100644 src/test/ui/compile-fail-migration/check-static-values-constraints.stderr create mode 100644 src/test/ui/compile-fail-migration/class-cast-to-trait.rs create mode 100644 src/test/ui/compile-fail-migration/class-cast-to-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/class-method-missing.rs create mode 100644 src/test/ui/compile-fail-migration/class-method-missing.stderr create mode 100644 src/test/ui/compile-fail-migration/class-missing-self.rs create mode 100644 src/test/ui/compile-fail-migration/class-missing-self.stderr create mode 100644 src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.rs create mode 100644 src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.rs create mode 100644 src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.rs create mode 100644 src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-bounds-subtype.rs create mode 100644 src/test/ui/compile-fail-migration/closure-bounds-subtype.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/README.md create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn-multiple.rs create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.rs create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.rs create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs create mode 100644 src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-no-fn-1.rs create mode 100644 src/test/ui/compile-fail-migration/closure-no-fn-1.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-no-fn-2.rs create mode 100644 src/test/ui/compile-fail-migration/closure-no-fn-2.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-no-fn-3.rs create mode 100644 src/test/ui/compile-fail-migration/closure-no-fn-3.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.rs create mode 100644 src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-reform-bad.rs create mode 100644 src/test/ui/compile-fail-migration/closure-reform-bad.stderr create mode 100644 src/test/ui/compile-fail-migration/closure-wrong-kind.rs create mode 100644 src/test/ui/compile-fail-migration/closure-wrong-kind.stderr create mode 100644 src/test/ui/compile-fail-migration/closure_promotion.rs create mode 100644 src/test/ui/compile-fail-migration/closure_promotion.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.rs create mode 100644 src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-mut.rs create mode 100644 src/test/ui/compile-fail-migration/coerce-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.rs create mode 100644 src/test/ui/compile-fail-migration/coerce-to-bang-cast.rs create mode 100644 src/test/ui/compile-fail-migration/coerce-to-bang-cast.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-to-bang.rs create mode 100644 src/test/ui/compile-fail-migration/coerce-to-bang.stderr create mode 100644 src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.rs create mode 100644 src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.stderr create mode 100644 src/test/ui/compile-fail-migration/coercion-slice.rs create mode 100644 src/test/ui/compile-fail-migration/coercion-slice.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-all-remote.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-all-remote.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-bigint-param.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-bigint-param.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-cow.a.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-cow.b.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-cow.c.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-cow.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-default-trait-impl.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-default-trait-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-impls-send.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-impls-send.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-impls-sized.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-impls-sized.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-lone-type-parameter.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-lone-type-parameter.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-negative-impls-safe.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-negative-impls-safe.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-orphan.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-orphan.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-overlap-messages.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-overlap-messages.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-overlapping-pairs.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-overlapping-pairs.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-conflict.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-conflict.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-ok.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-projection-ok.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-tuple-conflict.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-tuple-conflict.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-vec-local-2.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-vec-local-2.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence-vec-local.rs create mode 100644 src/test/ui/compile-fail-migration/coherence-vec-local.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_inherent.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_inherent.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_inherent_cc.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_inherent_cc.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_local.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_local.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_local_err_struct.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_local_err_struct.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_local_err_tuple.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_local_err_tuple.stderr create mode 100644 src/test/ui/compile-fail-migration/coherence_local_ref.rs create mode 100644 src/test/ui/compile-fail-migration/coherence_local_ref.stderr create mode 100644 src/test/ui/compile-fail-migration/compile_error_macro.rs create mode 100644 src/test/ui/compile-fail-migration/compile_error_macro.stderr create mode 100644 src/test/ui/compile-fail-migration/concat.rs create mode 100644 src/test/ui/compile-fail-migration/concat.stderr create mode 100644 src/test/ui/compile-fail-migration/conflicting-repr-hints.rs create mode 100644 src/test/ui/compile-fail-migration/conflicting-repr-hints.stderr create mode 100644 src/test/ui/compile-fail-migration/conservative_impl_trait.rs create mode 100644 src/test/ui/compile-fail-migration/conservative_impl_trait.stderr create mode 100644 src/test/ui/compile-fail-migration/const-array-oob-arith.rs create mode 100644 src/test/ui/compile-fail-migration/const-array-oob-arith.stderr create mode 100644 src/test/ui/compile-fail-migration/const-array-oob.rs create mode 100644 src/test/ui/compile-fail-migration/const-array-oob.stderr create mode 100644 src/test/ui/compile-fail-migration/const-block-non-item-statement-2.rs create mode 100644 src/test/ui/compile-fail-migration/const-block-non-item-statement-2.stderr create mode 100644 src/test/ui/compile-fail-migration/const-block-non-item-statement-3.rs create mode 100644 src/test/ui/compile-fail-migration/const-block-non-item-statement-3.stderr create mode 100644 src/test/ui/compile-fail-migration/const-block-non-item-statement.rs create mode 100644 src/test/ui/compile-fail-migration/const-block-non-item-statement.stderr create mode 100644 src/test/ui/compile-fail-migration/const-call.rs create mode 100644 src/test/ui/compile-fail-migration/const-call.stderr create mode 100644 src/test/ui/compile-fail-migration/const-cast-different-types.rs create mode 100644 src/test/ui/compile-fail-migration/const-cast-different-types.stderr create mode 100644 src/test/ui/compile-fail-migration/const-cast-wrong-type.rs create mode 100644 src/test/ui/compile-fail-migration/const-cast-wrong-type.stderr create mode 100644 src/test/ui/compile-fail-migration/const-err-early.rs create mode 100644 src/test/ui/compile-fail-migration/const-err-early.stderr create mode 100644 src/test/ui/compile-fail-migration/const-err-multi.rs create mode 100644 src/test/ui/compile-fail-migration/const-err-multi.stderr create mode 100644 src/test/ui/compile-fail-migration/const-err.rs create mode 100644 src/test/ui/compile-fail-migration/const-err.stderr create mode 100644 src/test/ui/compile-fail-migration/const-err2.rs create mode 100644 src/test/ui/compile-fail-migration/const-err2.stderr create mode 100644 src/test/ui/compile-fail-migration/const-err3.rs create mode 100644 src/test/ui/compile-fail-migration/const-err3.stderr create mode 100644 src/test/ui/compile-fail-migration/const-err4.rs create mode 100644 src/test/ui/compile-fail-migration/const-err4.stderr create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow-3.rs create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow-3.stderr create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow-3b.rs create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow-3b.stderr create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow-4b.rs create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow-4b.stderr create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow2.rs create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow2.stderr create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow2b.rs create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow2b.stderr create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow2c.rs create mode 100644 src/test/ui/compile-fail-migration/const-eval-overflow2c.stderr create mode 100644 src/test/ui/compile-fail-migration/const-fn-destructuring-arg.rs create mode 100644 src/test/ui/compile-fail-migration/const-fn-destructuring-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.rs create mode 100644 src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.stderr create mode 100644 src/test/ui/compile-fail-migration/const-fn-stability-calls-3.rs create mode 100644 src/test/ui/compile-fail-migration/const-fn-stability-calls-3.stderr create mode 100644 src/test/ui/compile-fail-migration/const-integer-bool-ops.rs create mode 100644 src/test/ui/compile-fail-migration/const-integer-bool-ops.stderr create mode 100644 src/test/ui/compile-fail-migration/const-len-underflow-subspans.rs create mode 100644 src/test/ui/compile-fail-migration/const-len-underflow-subspans.stderr create mode 100644 src/test/ui/compile-fail-migration/const-match-check.eval1.stderr create mode 100644 src/test/ui/compile-fail-migration/const-match-check.eval2.stderr create mode 100644 src/test/ui/compile-fail-migration/const-match-check.matchck.stderr create mode 100644 src/test/ui/compile-fail-migration/const-match-check.rs create mode 100644 src/test/ui/compile-fail-migration/const-match-pattern-arm.rs create mode 100644 src/test/ui/compile-fail-migration/const-match-pattern-arm.stderr create mode 100644 src/test/ui/compile-fail-migration/const-size_of-cycle.rs create mode 100644 src/test/ui/compile-fail-migration/const-size_of-cycle.stderr create mode 100644 src/test/ui/compile-fail-migration/const-slice-oob.rs create mode 100644 src/test/ui/compile-fail-migration/const-slice-oob.stderr create mode 100644 src/test/ui/compile-fail-migration/const-tup-index-span.rs create mode 100644 src/test/ui/compile-fail-migration/const-tup-index-span.stderr create mode 100644 src/test/ui/compile-fail-migration/const-typeid-of.rs create mode 100644 src/test/ui/compile-fail-migration/const-typeid-of.stderr create mode 100644 src/test/ui/compile-fail-migration/constructor-lifetime-args.rs create mode 100644 src/test/ui/compile-fail-migration/constructor-lifetime-args.stderr create mode 100644 src/test/ui/compile-fail-migration/copy-a-resource.rs create mode 100644 src/test/ui/compile-fail-migration/copy-a-resource.stderr create mode 100644 src/test/ui/compile-fail-migration/crate-name-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/crate-name-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/crateresolve1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/crateresolve1.rs create mode 100644 src/test/ui/compile-fail-migration/crateresolve1.stderr create mode 100644 src/test/ui/compile-fail-migration/cross-borrow-trait.rs create mode 100644 src/test/ui/compile-fail-migration/cross-borrow-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/cross-fn-cache-hole.rs create mode 100644 src/test/ui/compile-fail-migration/cross-fn-cache-hole.stderr create mode 100644 src/test/ui/compile-fail-migration/custom_attribute.rs create mode 100644 src/test/ui/compile-fail-migration/custom_attribute.stderr create mode 100644 src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.rs create mode 100644 src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.rs create mode 100644 src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.stderr create mode 100644 src/test/ui/compile-fail-migration/dead-code-closure-bang.rs create mode 100644 src/test/ui/compile-fail-migration/dead-code-ret.rs create mode 100644 src/test/ui/compile-fail-migration/dead-code-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/defaulted-never-note.rs create mode 100644 src/test/ui/compile-fail-migration/defaulted-never-note.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-caller-callee.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-caller-callee.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-struct-signature.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-struct-signature.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-trait-impl.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-trait-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-type-alias.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-type-alias.stderr create mode 100644 src/test/ui/compile-fail-migration/dep-graph-variance-alias.rs create mode 100644 src/test/ui/compile-fail-migration/dep-graph-variance-alias.stderr create mode 100644 src/test/ui/compile-fail-migration/deprecated_no_stack_check.rs create mode 100644 src/test/ui/compile-fail-migration/deprecated_no_stack_check.stderr create mode 100644 src/test/ui/compile-fail-migration/deprecation-in-staged-api.rs create mode 100644 src/test/ui/compile-fail-migration/deprecation-in-staged-api.stderr create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint-2.rs create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint-2.stderr create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint-3.rs create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint-3.stderr create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint-nested.rs create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint-nested.stderr create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint.rs create mode 100644 src/test/ui/compile-fail-migration/deprecation-lint.stderr create mode 100644 src/test/ui/compile-fail-migration/deref-non-pointer.rs create mode 100644 src/test/ui/compile-fail-migration/deref-non-pointer.stderr create mode 100644 src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.rs create mode 100644 src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.rs create mode 100644 src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.stderr create mode 100644 src/test/ui/compile-fail-migration/derived-errors/issue-30580.rs create mode 100644 src/test/ui/compile-fail-migration/derived-errors/issue-30580.stderr create mode 100644 src/test/ui/compile-fail-migration/derived-errors/issue-31997.rs create mode 100644 src/test/ui/compile-fail-migration/derived-errors/issue-31997.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-enum.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-enum.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Default-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Default-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-enum.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-enum.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-enum.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.rs create mode 100644 src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/deriving-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/deriving-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/deriving-copyclone.rs create mode 100644 src/test/ui/compile-fail-migration/deriving-copyclone.stderr create mode 100644 src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.rs create mode 100644 src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.rs create mode 100644 src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.stderr create mode 100644 src/test/ui/compile-fail-migration/deriving-non-type.rs create mode 100644 src/test/ui/compile-fail-migration/deriving-non-type.stderr create mode 100644 src/test/ui/compile-fail-migration/deriving-primitive.rs create mode 100644 src/test/ui/compile-fail-migration/deriving-primitive.stderr create mode 100644 src/test/ui/compile-fail-migration/destructure-trait-ref.rs create mode 100644 src/test/ui/compile-fail-migration/destructure-trait-ref.stderr create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/foo/compiletest-ignore-dir create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning/aux2.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning_aux2.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.stderr create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/bar.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/mod.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.stderr create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux2.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux3.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.stderr create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.rs create mode 100644 src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.stderr create mode 100644 src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.rs create mode 100644 src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.stderr create mode 100644 src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.rs create mode 100644 src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.stderr create mode 100644 src/test/ui/compile-fail-migration/discrim-ill-typed.rs create mode 100644 src/test/ui/compile-fail-migration/discrim-ill-typed.stderr create mode 100644 src/test/ui/compile-fail-migration/diverging-fn-tail-35849.rs create mode 100644 src/test/ui/compile-fail-migration/diverging-fn-tail-35849.stderr create mode 100644 src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.rs create mode 100644 src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.stderr create mode 100644 src/test/ui/compile-fail-migration/does-nothing.rs create mode 100644 src/test/ui/compile-fail-migration/does-nothing.stderr create mode 100644 src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.rs create mode 100644 src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.stderr create mode 100644 src/test/ui/compile-fail-migration/dollar-crate-is-keyword.rs create mode 100644 src/test/ui/compile-fail-migration/dollar-crate-is-keyword.stderr create mode 100644 src/test/ui/compile-fail-migration/double-type-import.rs create mode 100644 src/test/ui/compile-fail-migration/double-type-import.stderr create mode 100644 src/test/ui/compile-fail-migration/drop-on-non-struct.rs create mode 100644 src/test/ui/compile-fail-migration/drop-on-non-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/drop-with-active-borrows-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/drop-with-active-borrows-1.rs create mode 100644 src/test/ui/compile-fail-migration/drop-with-active-borrows-1.stderr create mode 100644 src/test/ui/compile-fail-migration/drop-with-active-borrows-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/drop-with-active-borrows-2.rs create mode 100644 src/test/ui/compile-fail-migration/drop-with-active-borrows-2.stderr create mode 100644 src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.rs create mode 100644 src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.stderr create mode 100644 src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.rs create mode 100644 src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.stderr create mode 100644 src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.rs create mode 100644 src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.stderr create mode 100644 src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.rs create mode 100644 src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-assign-2.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-assign-2.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-assign-3.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-assign-3.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-assign.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-assign.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce1.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce1.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce2.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce2.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce3.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce3.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce3.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce4.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coerce4.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coercions.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-coercions.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-deep-2.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-deep-2.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-bad-deep.rs create mode 100644 src/test/ui/compile-fail-migration/dst-bad-deep.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-index.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-index.rs create mode 100644 src/test/ui/compile-fail-migration/dst-index.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-object-from-unsized-type.rs create mode 100644 src/test/ui/compile-fail-migration/dst-object-from-unsized-type.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-rvalue.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-rvalue.rs create mode 100644 src/test/ui/compile-fail-migration/dst-rvalue.stderr create mode 100644 src/test/ui/compile-fail-migration/dst-sized-trait-param.rs create mode 100644 src/test/ui/compile-fail-migration/dst-sized-trait-param.stderr create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-1.rs create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-1.stderr create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-2.rs create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-2.stderr create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-3.rs create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-3.stderr create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-4.rs create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-4.stderr create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-5.rs create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-5.stderr create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-6.rs create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-6.stderr create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-7.rs create mode 100644 src/test/ui/compile-fail-migration/dupe-symbols-7.stderr create mode 100644 src/test/ui/compile-fail-migration/duplicate-parameter.rs create mode 100644 src/test/ui/compile-fail-migration/duplicate-parameter.stderr create mode 100644 src/test/ui/compile-fail-migration/duplicate-type-parameter.rs create mode 100644 src/test/ui/compile-fail-migration/duplicate-type-parameter.stderr create mode 100644 src/test/ui/compile-fail-migration/duplicate_entry_error.rs create mode 100644 src/test/ui/compile-fail-migration/duplicate_entry_error.stderr create mode 100644 src/test/ui/compile-fail-migration/dyn-trait-compatibility.rs create mode 100644 src/test/ui/compile-fail-migration/dyn-trait-compatibility.stderr create mode 100644 src/test/ui/compile-fail-migration/edition-extern-crate-allowed.rs create mode 100644 src/test/ui/compile-fail-migration/edition-extern-crate-allowed.stderr create mode 100644 src/test/ui/compile-fail-migration/edition-feature-ok.rs create mode 100644 src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.rs create mode 100644 src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.stderr create mode 100644 src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.rs create mode 100644 src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.stderr create mode 100644 src/test/ui/compile-fail-migration/elided-test.rs create mode 100644 src/test/ui/compile-fail-migration/elided-test.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-comment.rs create mode 100644 src/test/ui/compile-fail-migration/empty-comment.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-extern-arg.rs create mode 100644 src/test/ui/compile-fail-migration/empty-extern-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-linkname.rs create mode 100644 src/test/ui/compile-fail-migration/empty-linkname.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-macro-use.rs create mode 100644 src/test/ui/compile-fail-migration/empty-macro-use.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-never-array.rs create mode 100644 src/test/ui/compile-fail-migration/empty-never-array.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-expr.rs create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-expr.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.rs create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.rs create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.rs create mode 100644 src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-struct-tuple-pat.rs create mode 100644 src/test/ui/compile-fail-migration/empty-struct-tuple-pat.stderr create mode 100644 src/test/ui/compile-fail-migration/empty-struct-unit-pat.rs create mode 100644 src/test/ui/compile-fail-migration/empty-struct-unit-pat.stderr create mode 100644 src/test/ui/compile-fail-migration/enable-unstable-lib-feature.rs create mode 100644 src/test/ui/compile-fail-migration/enable-unstable-lib-feature.stderr create mode 100644 src/test/ui/compile-fail-migration/enum-discrim-autosizing.rs create mode 100644 src/test/ui/compile-fail-migration/enum-discrim-autosizing.stderr create mode 100644 src/test/ui/compile-fail-migration/enum-discrim-too-small.rs create mode 100644 src/test/ui/compile-fail-migration/enum-discrim-too-small.stderr create mode 100644 src/test/ui/compile-fail-migration/enum-discrim-too-small2.rs create mode 100644 src/test/ui/compile-fail-migration/enum-discrim-too-small2.stderr create mode 100644 src/test/ui/compile-fail-migration/enum-in-scope.rs create mode 100644 src/test/ui/compile-fail-migration/enum-in-scope.stderr create mode 100644 src/test/ui/compile-fail-migration/enum-to-float-cast-2.rs create mode 100644 src/test/ui/compile-fail-migration/enum-to-float-cast-2.stderr create mode 100644 src/test/ui/compile-fail-migration/enum-to-float-cast.rs create mode 100644 src/test/ui/compile-fail-migration/enum-to-float-cast.stderr create mode 100644 src/test/ui/compile-fail-migration/enum-variant-type-2.rs create mode 100644 src/test/ui/compile-fail-migration/enum-variant-type-2.stderr create mode 100644 src/test/ui/compile-fail-migration/enums-pats-not-idents.rs create mode 100644 src/test/ui/compile-fail-migration/enums-pats-not-idents.stderr create mode 100644 src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.rs create mode 100644 src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.stderr create mode 100644 src/test/ui/compile-fail-migration/estr-subtyping.rs create mode 100644 src/test/ui/compile-fail-migration/estr-subtyping.stderr create mode 100644 src/test/ui/compile-fail-migration/eval-enum.rs create mode 100644 src/test/ui/compile-fail-migration/eval-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/exclusive-drop-and-copy.rs create mode 100644 src/test/ui/compile-fail-migration/exclusive-drop-and-copy.stderr create mode 100644 src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.rs create mode 100644 src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.stderr create mode 100644 src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.rs create mode 100644 src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.stderr create mode 100644 src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.rs create mode 100644 src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.stderr create mode 100644 src/test/ui/compile-fail-migration/expanded-cfg.rs create mode 100644 src/test/ui/compile-fail-migration/expanded-cfg.stderr create mode 100644 src/test/ui/compile-fail-migration/explicit-call-to-dtor.rs create mode 100644 src/test/ui/compile-fail-migration/explicit-call-to-dtor.stderr create mode 100644 src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.rs create mode 100644 src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.stderr create mode 100644 src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/export-fully-qualified.rs create mode 100644 src/test/ui/compile-fail-migration/export-fully-qualified.stderr create mode 100644 src/test/ui/compile-fail-migration/export-import.rs create mode 100644 src/test/ui/compile-fail-migration/export-import.stderr create mode 100644 src/test/ui/compile-fail-migration/export-tag-variant.rs create mode 100644 src/test/ui/compile-fail-migration/export-tag-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/export.rs create mode 100644 src/test/ui/compile-fail-migration/export.stderr create mode 100644 src/test/ui/compile-fail-migration/export2.rs create mode 100644 src/test/ui/compile-fail-migration/export2.stderr create mode 100644 src/test/ui/compile-fail-migration/expr_attr_paren_order.rs create mode 100644 src/test/ui/compile-fail-migration/expr_attr_paren_order.stderr create mode 100644 src/test/ui/compile-fail-migration/ext-nonexistent.rs create mode 100644 src/test/ui/compile-fail-migration/ext-nonexistent.stderr create mode 100644 src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.rs create mode 100644 src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.stderr create mode 100644 src/test/ui/compile-fail-migration/extenv-no-args.rs create mode 100644 src/test/ui/compile-fail-migration/extenv-no-args.stderr create mode 100644 src/test/ui/compile-fail-migration/extenv-not-defined-custom.rs create mode 100644 src/test/ui/compile-fail-migration/extenv-not-defined-custom.stderr create mode 100644 src/test/ui/compile-fail-migration/extenv-not-defined-default.rs create mode 100644 src/test/ui/compile-fail-migration/extenv-not-defined-default.stderr create mode 100644 src/test/ui/compile-fail-migration/extenv-not-string-literal.rs create mode 100644 src/test/ui/compile-fail-migration/extenv-not-string-literal.stderr create mode 100644 src/test/ui/compile-fail-migration/extenv-too-many-args.rs create mode 100644 src/test/ui/compile-fail-migration/extenv-too-many-args.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-crate-visibility.rs create mode 100644 src/test/ui/compile-fail-migration/extern-crate-visibility.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-macro.rs create mode 100644 src/test/ui/compile-fail-migration/extern-macro.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-main-fn.rs create mode 100644 src/test/ui/compile-fail-migration/extern-main-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-types-distinct-types.rs create mode 100644 src/test/ui/compile-fail-migration/extern-types-distinct-types.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-types-not-sync-send.rs create mode 100644 src/test/ui/compile-fail-migration/extern-types-not-sync-send.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-types-unsized.rs create mode 100644 src/test/ui/compile-fail-migration/extern-types-unsized.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-with-type-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/extern-with-type-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/extern-wrong-value-type.rs create mode 100644 src/test/ui/compile-fail-migration/extern-wrong-value-type.stderr create mode 100644 src/test/ui/compile-fail-migration/external-doc-error.rs create mode 100644 src/test/ui/compile-fail-migration/external-doc-error.stderr create mode 100644 src/test/ui/compile-fail-migration/extoption_env-no-args.rs create mode 100644 src/test/ui/compile-fail-migration/extoption_env-no-args.stderr create mode 100644 src/test/ui/compile-fail-migration/extoption_env-not-string-literal.rs create mode 100644 src/test/ui/compile-fail-migration/extoption_env-not-string-literal.stderr create mode 100644 src/test/ui/compile-fail-migration/extoption_env-too-many-args.rs create mode 100644 src/test/ui/compile-fail-migration/extoption_env-too-many-args.stderr create mode 100644 src/test/ui/compile-fail-migration/fail-no-dead-code-core.rs create mode 100644 src/test/ui/compile-fail-migration/fail-no-dead-code-core.stderr create mode 100644 src/test/ui/compile-fail-migration/fail-no-dead-code.rs create mode 100644 src/test/ui/compile-fail-migration/fail-no-dead-code.stderr create mode 100644 src/test/ui/compile-fail-migration/fail-simple.rs create mode 100644 src/test/ui/compile-fail-migration/fail-simple.stderr create mode 100644 src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.rs create mode 100644 src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.stderr create mode 100644 src/test/ui/compile-fail-migration/feature-gate-panic-implementation.rs create mode 100644 src/test/ui/compile-fail-migration/feature-gate-panic-implementation.stderr create mode 100644 src/test/ui/compile-fail-migration/feature-gate-tool_lints.rs create mode 100644 src/test/ui/compile-fail-migration/feature-gate-tool_lints.stderr create mode 100644 src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.rs create mode 100644 src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.rs create mode 100644 src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/float-literal-inference-restrictions.rs create mode 100644 src/test/ui/compile-fail-migration/float-literal-inference-restrictions.stderr create mode 100644 src/test/ui/compile-fail-migration/fn-bad-block-type.rs create mode 100644 src/test/ui/compile-fail-migration/fn-bad-block-type.stderr create mode 100644 src/test/ui/compile-fail-migration/fn-compare-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/fn-compare-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/fn-item-type.rs create mode 100644 src/test/ui/compile-fail-migration/fn-item-type.stderr create mode 100644 src/test/ui/compile-fail-migration/fn-trait-formatting.rs create mode 100644 src/test/ui/compile-fail-migration/fn-trait-formatting.stderr create mode 100644 src/test/ui/compile-fail-migration/for-expn.rs create mode 100644 src/test/ui/compile-fail-migration/for-expn.stderr create mode 100644 src/test/ui/compile-fail-migration/for-loop-bogosity.rs create mode 100644 src/test/ui/compile-fail-migration/for-loop-bogosity.stderr create mode 100644 src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.rs create mode 100644 src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.stderr create mode 100644 src/test/ui/compile-fail-migration/for-loop-type-error.rs create mode 100644 src/test/ui/compile-fail-migration/for-loop-type-error.stderr create mode 100644 src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.rs create mode 100644 src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.stderr create mode 100644 src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.rs create mode 100644 src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.stderr create mode 100644 src/test/ui/compile-fail-migration/fully-qualified-type-name1.rs create mode 100644 src/test/ui/compile-fail-migration/fully-qualified-type-name1.stderr create mode 100644 src/test/ui/compile-fail-migration/fully-qualified-type-name2.rs create mode 100644 src/test/ui/compile-fail-migration/fully-qualified-type-name2.stderr create mode 100644 src/test/ui/compile-fail-migration/fully-qualified-type-name3.rs create mode 100644 src/test/ui/compile-fail-migration/fully-qualified-type-name4.rs create mode 100644 src/test/ui/compile-fail-migration/fully-qualified-type-name4.stderr create mode 100644 src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.rs create mode 100644 src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.stderr create mode 100644 src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.rs create mode 100644 src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.stderr create mode 100644 src/test/ui/compile-fail-migration/future-incompatible-lint-group.rs create mode 100644 src/test/ui/compile-fail-migration/future-incompatible-lint-group.stderr create mode 100644 src/test/ui/compile-fail-migration/gated-attr-literals.rs create mode 100644 src/test/ui/compile-fail-migration/gated-attr-literals.stderr create mode 100644 src/test/ui/compile-fail-migration/gated-bad-feature.rs create mode 100644 src/test/ui/compile-fail-migration/gated-bad-feature.stderr create mode 100644 src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.rs create mode 100644 src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-extern-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/generic-extern-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-extern.rs create mode 100644 src/test/ui/compile-fail-migration/generic-extern.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.rs create mode 100644 src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.rs create mode 100644 src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.rs create mode 100644 src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-no-mangle.rs create mode 100644 src/test/ui/compile-fail-migration/generic-no-mangle.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-non-trailing-defaults.rs create mode 100644 src/test/ui/compile-fail-migration/generic-non-trailing-defaults.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-type-params-forward-mention.rs create mode 100644 src/test/ui/compile-fail-migration/generic-type-params-forward-mention.stderr create mode 100644 src/test/ui/compile-fail-migration/generic-type-params-name-repr.rs create mode 100644 src/test/ui/compile-fail-migration/generic-type-params-name-repr.stderr create mode 100644 src/test/ui/compile-fail-migration/glob-cycles.rs create mode 100644 src/test/ui/compile-fail-migration/glob-cycles.stderr create mode 100644 src/test/ui/compile-fail-migration/glob-resolve1.rs create mode 100644 src/test/ui/compile-fail-migration/glob-resolve1.stderr create mode 100644 src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/hashmap-lifetimes.rs create mode 100644 src/test/ui/compile-fail-migration/hashmap-lifetimes.stderr create mode 100644 src/test/ui/compile-fail-migration/hidden-rt-injection.rs create mode 100644 src/test/ui/compile-fail-migration/hidden-rt-injection.stderr create mode 100644 src/test/ui/compile-fail-migration/hidden-rt-injection2.rs create mode 100644 src/test/ui/compile-fail-migration/hidden-rt-injection2.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_vs_bound_a.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_a.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_b.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_free_x.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_vs_bound_co_b.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_x.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.stderr create mode 100644 src/test/ui/compile-fail-migration/hr-subtype.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-conflate-regions.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-conflate-regions.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-just-for-static.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-just-for-static.stderr create mode 100644 src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.rs create mode 100644 src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.stderr create mode 100644 src/test/ui/compile-fail-migration/huge-array-simple.rs create mode 100644 src/test/ui/compile-fail-migration/huge-array.rs create mode 100644 src/test/ui/compile-fail-migration/huge-array.stderr create mode 100644 src/test/ui/compile-fail-migration/huge-enum.rs create mode 100644 src/test/ui/compile-fail-migration/huge-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/huge-struct.rs create mode 100644 src/test/ui/compile-fail-migration/huge-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-1.rs create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-1.stderr create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-2.rs create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-2.stderr create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-3.rs create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-3.stderr create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-4.rs create mode 100644 src/test/ui/compile-fail-migration/hygienic-label-4.stderr create mode 100644 src/test/ui/compile-fail-migration/if-branch-types.rs create mode 100644 src/test/ui/compile-fail-migration/if-branch-types.stderr create mode 100644 src/test/ui/compile-fail-migration/if-let.rs create mode 100644 src/test/ui/compile-fail-migration/if-let.stderr create mode 100644 src/test/ui/compile-fail-migration/if-loop.rs create mode 100644 src/test/ui/compile-fail-migration/if-loop.stderr create mode 100644 src/test/ui/compile-fail-migration/if-typeck.rs create mode 100644 src/test/ui/compile-fail-migration/if-typeck.stderr create mode 100644 src/test/ui/compile-fail-migration/if-without-else-result.rs create mode 100644 src/test/ui/compile-fail-migration/if-without-else-result.stderr create mode 100644 src/test/ui/compile-fail-migration/ifmt-bad-format-args.rs create mode 100644 src/test/ui/compile-fail-migration/ifmt-bad-format-args.stderr create mode 100644 src/test/ui/compile-fail-migration/ifmt-unimpl.rs create mode 100644 src/test/ui/compile-fail-migration/ifmt-unimpl.stderr create mode 100644 src/test/ui/compile-fail-migration/ifmt-unknown-trait.rs create mode 100644 src/test/ui/compile-fail-migration/ifmt-unknown-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/illegal-ufcs-drop.rs create mode 100644 src/test/ui/compile-fail-migration/illegal-ufcs-drop.stderr create mode 100644 src/test/ui/compile-fail-migration/immut-function-arguments.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/immut-function-arguments.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/immut-function-arguments.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/immut-function-arguments.rs create mode 100644 src/test/ui/compile-fail-migration/impl-bounds-checking.rs create mode 100644 src/test/ui/compile-fail-migration/impl-bounds-checking.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.rs create mode 100644 src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.rs create mode 100644 src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.rs create mode 100644 src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.rs create mode 100644 src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/no-trait.rs create mode 100644 src/test/ui/compile-fail-migration/impl-trait/no-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.rs create mode 100644 src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-trait/where-allowed.rs create mode 100644 src/test/ui/compile-fail-migration/impl-trait/where-allowed.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-unused-tps-inherent.rs create mode 100644 src/test/ui/compile-fail-migration/impl-unused-tps-inherent.stderr create mode 100644 src/test/ui/compile-fail-migration/impl-unused-tps.rs create mode 100644 src/test/ui/compile-fail-migration/impl-unused-tps.stderr create mode 100644 src/test/ui/compile-fail-migration/implicit-method-bind.rs create mode 100644 src/test/ui/compile-fail-migration/implicit-method-bind.stderr create mode 100644 src/test/ui/compile-fail-migration/import-crate-var.rs create mode 100644 src/test/ui/compile-fail-migration/import-crate-var.stderr create mode 100644 src/test/ui/compile-fail-migration/import-from-missing.rs create mode 100644 src/test/ui/compile-fail-migration/import-from-missing.stderr create mode 100644 src/test/ui/compile-fail-migration/import-glob-0.rs create mode 100644 src/test/ui/compile-fail-migration/import-glob-0.stderr create mode 100644 src/test/ui/compile-fail-migration/import-glob-circular.rs create mode 100644 src/test/ui/compile-fail-migration/import-glob-circular.stderr create mode 100644 src/test/ui/compile-fail-migration/import-loop-2.rs create mode 100644 src/test/ui/compile-fail-migration/import-loop-2.stderr create mode 100644 src/test/ui/compile-fail-migration/import-loop.rs create mode 100644 src/test/ui/compile-fail-migration/import-loop.stderr create mode 100644 src/test/ui/compile-fail-migration/import-prefix-macro-1.rs create mode 100644 src/test/ui/compile-fail-migration/import-prefix-macro-1.stderr create mode 100644 src/test/ui/compile-fail-migration/import-prefix-macro-2.rs create mode 100644 src/test/ui/compile-fail-migration/import-prefix-macro-2.stderr create mode 100644 src/test/ui/compile-fail-migration/import-trait-method.rs create mode 100644 src/test/ui/compile-fail-migration/import-trait-method.stderr create mode 100644 src/test/ui/compile-fail-migration/import.rs create mode 100644 src/test/ui/compile-fail-migration/import.stderr create mode 100644 src/test/ui/compile-fail-migration/import2.rs create mode 100644 src/test/ui/compile-fail-migration/import2.stderr create mode 100644 src/test/ui/compile-fail-migration/import3.rs create mode 100644 src/test/ui/compile-fail-migration/import3.stderr create mode 100644 src/test/ui/compile-fail-migration/import4.rs create mode 100644 src/test/ui/compile-fail-migration/import4.stderr create mode 100644 src/test/ui/compile-fail-migration/imports/reexports.rs create mode 100644 src/test/ui/compile-fail-migration/imports/reexports.stderr create mode 100644 src/test/ui/compile-fail-migration/imports/unused-macro-use.rs create mode 100644 src/test/ui/compile-fail-migration/imports/unused-macro-use.stderr create mode 100644 src/test/ui/compile-fail-migration/imports/unused.rs create mode 100644 src/test/ui/compile-fail-migration/imports/unused.stderr create mode 100644 src/test/ui/compile-fail-migration/inaccessible-test-modules.rs create mode 100644 src/test/ui/compile-fail-migration/inaccessible-test-modules.stderr create mode 100644 src/test/ui/compile-fail-migration/index-bot.rs create mode 100644 src/test/ui/compile-fail-migration/index-bot.stderr create mode 100644 src/test/ui/compile-fail-migration/index_message.rs create mode 100644 src/test/ui/compile-fail-migration/index_message.stderr create mode 100644 src/test/ui/compile-fail-migration/indexing-requires-a-uint.rs create mode 100644 src/test/ui/compile-fail-migration/indexing-requires-a-uint.stderr create mode 100644 src/test/ui/compile-fail-migration/infinite-autoderef.rs create mode 100644 src/test/ui/compile-fail-migration/infinite-autoderef.stderr create mode 100644 src/test/ui/compile-fail-migration/infinite-instantiation.rs create mode 100644 src/test/ui/compile-fail-migration/infinite-instantiation.stderr create mode 100644 src/test/ui/compile-fail-migration/infinite-macro-expansion.rs create mode 100644 src/test/ui/compile-fail-migration/infinite-macro-expansion.stderr create mode 100644 src/test/ui/compile-fail-migration/infinite-tag-type-recursion.rs create mode 100644 src/test/ui/compile-fail-migration/infinite-tag-type-recursion.stderr create mode 100644 src/test/ui/compile-fail-migration/infinite-vec-type-recursion.rs create mode 100644 src/test/ui/compile-fail-migration/infinite-vec-type-recursion.stderr create mode 100644 src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.rs create mode 100644 src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.stderr create mode 100644 src/test/ui/compile-fail-migration/init-unsafe.rs create mode 100644 src/test/ui/compile-fail-migration/init-unsafe.stderr create mode 100644 src/test/ui/compile-fail-migration/inner-static-type-parameter.rs create mode 100644 src/test/ui/compile-fail-migration/inner-static-type-parameter.stderr create mode 100644 src/test/ui/compile-fail-migration/integer-literal-suffix-inference.rs create mode 100644 src/test/ui/compile-fail-migration/integer-literal-suffix-inference.stderr create mode 100644 src/test/ui/compile-fail-migration/integral-indexing.rs create mode 100644 src/test/ui/compile-fail-migration/integral-indexing.stderr create mode 100644 src/test/ui/compile-fail-migration/integral-variable-unification-error.rs create mode 100644 src/test/ui/compile-fail-migration/integral-variable-unification-error.stderr create mode 100644 src/test/ui/compile-fail-migration/internal-unstable-noallow.rs create mode 100644 src/test/ui/compile-fail-migration/internal-unstable-noallow.stderr create mode 100644 src/test/ui/compile-fail-migration/internal-unstable-thread-local.rs create mode 100644 src/test/ui/compile-fail-migration/internal-unstable-thread-local.stderr create mode 100644 src/test/ui/compile-fail-migration/internal-unstable.rs create mode 100644 src/test/ui/compile-fail-migration/internal-unstable.stderr create mode 100644 src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.rs create mode 100644 src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.stderr create mode 100644 src/test/ui/compile-fail-migration/invalid-crate-type.rs create mode 100644 src/test/ui/compile-fail-migration/invalid-crate-type.stderr create mode 100644 src/test/ui/compile-fail-migration/invalid-inline.rs create mode 100644 src/test/ui/compile-fail-migration/invalid-inline.stderr create mode 100644 src/test/ui/compile-fail-migration/invalid-macro-matcher.rs create mode 100644 src/test/ui/compile-fail-migration/invalid-macro-matcher.stderr create mode 100644 src/test/ui/compile-fail-migration/invalid-plugin-attr.rs create mode 100644 src/test/ui/compile-fail-migration/invalid-plugin-attr.stderr create mode 100644 src/test/ui/compile-fail-migration/invalid_crate_type_syntax.rs create mode 100644 src/test/ui/compile-fail-migration/invalid_crate_type_syntax.stderr create mode 100644 src/test/ui/compile-fail-migration/isssue-38821.rs create mode 100644 src/test/ui/compile-fail-migration/isssue-38821.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-10755.rs create mode 100644 src/test/ui/compile-fail-migration/issue-10755.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-11593.rs create mode 100644 src/test/ui/compile-fail-migration/issue-11593.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-11680.rs create mode 100644 src/test/ui/compile-fail-migration/issue-11680.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-15919.rs create mode 100644 src/test/ui/compile-fail-migration/issue-15919.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-16725.rs create mode 100644 src/test/ui/compile-fail-migration/issue-16725.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-17718-const-privacy.rs create mode 100644 src/test/ui/compile-fail-migration/issue-17718-const-privacy.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-17913.rs create mode 100644 src/test/ui/compile-fail-migration/issue-17913.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-19163.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-19163.rs create mode 100644 src/test/ui/compile-fail-migration/issue-19163.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-1920-1.rs create mode 100644 src/test/ui/compile-fail-migration/issue-1920-1.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-1920-2.rs create mode 100644 src/test/ui/compile-fail-migration/issue-1920-2.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-1920-3.rs create mode 100644 src/test/ui/compile-fail-migration/issue-1920-3.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-21146.rs create mode 100644 src/test/ui/compile-fail-migration/issue-21146.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-21202.rs create mode 100644 src/test/ui/compile-fail-migration/issue-21202.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-22638.rs create mode 100644 src/test/ui/compile-fail-migration/issue-22638.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-23595-1.rs create mode 100644 src/test/ui/compile-fail-migration/issue-23595-1.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-26548.rs create mode 100644 src/test/ui/compile-fail-migration/issue-26548.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-28075.rs create mode 100644 src/test/ui/compile-fail-migration/issue-28075.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-28388-1.rs create mode 100644 src/test/ui/compile-fail-migration/issue-28388-1.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-28388-2.rs create mode 100644 src/test/ui/compile-fail-migration/issue-28388-2.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-28388-3.rs create mode 100644 src/test/ui/compile-fail-migration/issue-28388-3.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-28625.rs create mode 100644 src/test/ui/compile-fail-migration/issue-28625.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-28848.rs create mode 100644 src/test/ui/compile-fail-migration/issue-28848.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-29181.rs create mode 100644 src/test/ui/compile-fail-migration/issue-29181.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-30123.rs create mode 100644 src/test/ui/compile-fail-migration/issue-30123.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-30535.rs create mode 100644 src/test/ui/compile-fail-migration/issue-30535.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-32377.rs create mode 100644 src/test/ui/compile-fail-migration/issue-32377.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-36881.rs create mode 100644 src/test/ui/compile-fail-migration/issue-36881.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-37131.rs create mode 100644 src/test/ui/compile-fail-migration/issue-37131.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-41549.rs create mode 100644 src/test/ui/compile-fail-migration/issue-41549.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-43733-2.rs create mode 100644 src/test/ui/compile-fail-migration/issue-43733-2.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.rs create mode 100644 src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.rs create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.rs create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.rs create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.rs create mode 100644 src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-52489.rs create mode 100644 src/test/ui/compile-fail-migration/issue-52489.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-5500-1.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-5500-1.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/issue-5500-1.rs create mode 100644 src/test/ui/compile-fail-migration/issue-5844.rs create mode 100644 src/test/ui/compile-fail-migration/issue-5844.stderr create mode 100644 src/test/ui/compile-fail-migration/issue32829.rs create mode 100644 src/test/ui/compile-fail-migration/issue32829.stderr create mode 100644 src/test/ui/compile-fail-migration/keyword-extern-as-identifier.rs create mode 100644 src/test/ui/compile-fail-migration/keyword-extern-as-identifier.stderr create mode 100644 src/test/ui/compile-fail-migration/keyword-false-as-identifier.rs create mode 100644 src/test/ui/compile-fail-migration/keyword-false-as-identifier.stderr create mode 100644 src/test/ui/compile-fail-migration/keyword-self-as-identifier.rs create mode 100644 src/test/ui/compile-fail-migration/keyword-self-as-identifier.stderr create mode 100644 src/test/ui/compile-fail-migration/keyword-super-as-identifier.rs create mode 100644 src/test/ui/compile-fail-migration/keyword-super-as-identifier.stderr create mode 100644 src/test/ui/compile-fail-migration/keyword-super.rs create mode 100644 src/test/ui/compile-fail-migration/keyword-super.stderr create mode 100644 src/test/ui/compile-fail-migration/keyword-true-as-identifier.rs create mode 100644 src/test/ui/compile-fail-migration/keyword-true-as-identifier.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-copy.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-copy.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-impl-type-params-2.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-impl-type-params-2.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-impl-type-params.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-impl-type-params.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-impl-type-params.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-nonsendable-1.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-nonsendable-1.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-send-object.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-send-object.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-send-object1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-send-object1.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-send-object1.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-send-object2.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-send-object2.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-send-owned.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-send-owned.stderr create mode 100644 src/test/ui/compile-fail-migration/kindck-send-unsafe.rs create mode 100644 src/test/ui/compile-fail-migration/kindck-send-unsafe.rs~rust-lang_master create mode 100644 src/test/ui/compile-fail-migration/kindck-send-unsafe.stderr create mode 100644 src/test/ui/compile-fail-migration/label-static.rs create mode 100644 src/test/ui/compile-fail-migration/label-static.stderr create mode 100644 src/test/ui/compile-fail-migration/label-underscore.rs create mode 100644 src/test/ui/compile-fail-migration/label-underscore.stderr create mode 100644 src/test/ui/compile-fail-migration/lang-item-missing.rs create mode 100644 src/test/ui/compile-fail-migration/lang-item-missing.stderr create mode 100644 src/test/ui/compile-fail-migration/lexical-scopes.rs create mode 100644 src/test/ui/compile-fail-migration/lexical-scopes.stderr create mode 100644 src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.rs create mode 100644 src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.stderr create mode 100644 src/test/ui/compile-fail-migration/lifetime-no-keyword.rs create mode 100644 src/test/ui/compile-fail-migration/lifetime-no-keyword.stderr create mode 100644 src/test/ui/compile-fail-migration/linkage2.rs create mode 100644 src/test/ui/compile-fail-migration/linkage2.stderr create mode 100644 src/test/ui/compile-fail-migration/linkage3.rs create mode 100644 src/test/ui/compile-fail-migration/linkage3.stderr create mode 100644 src/test/ui/compile-fail-migration/linkage4.rs create mode 100644 src/test/ui/compile-fail-migration/linkage4.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-attr-non-item-node.rs create mode 100644 src/test/ui/compile-fail-migration/lint-attr-non-item-node.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-change-warnings.rs create mode 100644 src/test/ui/compile-fail-migration/lint-change-warnings.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-ctypes-enum.rs create mode 100644 src/test/ui/compile-fail-migration/lint-ctypes-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-1.rs create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-1.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-2.rs create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-2.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-3.rs create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-3.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-4.rs create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-4.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-5.rs create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-5.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-type-alias.rs create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-type-alias.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-variant.rs create mode 100644 src/test/ui/compile-fail-migration/lint-dead-code-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.rs create mode 100644 src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.rs create mode 100644 src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.rs create mode 100644 src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-forbid-cmdline.rs create mode 100644 src/test/ui/compile-fail-migration/lint-forbid-cmdline.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-impl-fn.rs create mode 100644 src/test/ui/compile-fail-migration/lint-impl-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-malformed.rs create mode 100644 src/test/ui/compile-fail-migration/lint-malformed.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-misplaced-attr.rs create mode 100644 src/test/ui/compile-fail-migration/lint-misplaced-attr.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-missing-copy-implementations.rs create mode 100644 src/test/ui/compile-fail-migration/lint-missing-copy-implementations.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-missing-doc.rs create mode 100644 src/test/ui/compile-fail-migration/lint-missing-doc.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-non-camel-case-types.rs create mode 100644 src/test/ui/compile-fail-migration/lint-non-camel-case-types.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.rs create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-crate.rs create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-functions.rs create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-functions.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.rs create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-modules.rs create mode 100644 src/test/ui/compile-fail-migration/lint-non-snake-case-modules.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-non-uppercase-statics.rs create mode 100644 src/test/ui/compile-fail-migration/lint-non-uppercase-statics.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-obsolete-attr.rs create mode 100644 src/test/ui/compile-fail-migration/lint-obsolete-attr.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-output-format.rs create mode 100644 src/test/ui/compile-fail-migration/lint-output-format.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-owned-heap-memory.rs create mode 100644 src/test/ui/compile-fail-migration/lint-owned-heap-memory.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-qualification.rs create mode 100644 src/test/ui/compile-fail-migration/lint-qualification.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-removed-allow.rs create mode 100644 src/test/ui/compile-fail-migration/lint-removed-allow.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-removed-cmdline.rs create mode 100644 src/test/ui/compile-fail-migration/lint-removed-cmdline.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-removed.rs create mode 100644 src/test/ui/compile-fail-migration/lint-removed.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-renamed-allow.rs create mode 100644 src/test/ui/compile-fail-migration/lint-renamed-allow.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-renamed-cmdline.rs create mode 100644 src/test/ui/compile-fail-migration/lint-renamed-cmdline.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-renamed.rs create mode 100644 src/test/ui/compile-fail-migration/lint-renamed.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-shorthand-field.rs create mode 100644 src/test/ui/compile-fail-migration/lint-shorthand-field.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-stability-2.rs create mode 100644 src/test/ui/compile-fail-migration/lint-stability-2.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-stability-deprecated.rs create mode 100644 src/test/ui/compile-fail-migration/lint-stability-deprecated.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.rs create mode 100644 src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-stability-fields.rs create mode 100644 src/test/ui/compile-fail-migration/lint-stability-fields.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-stability.rs create mode 100644 src/test/ui/compile-fail-migration/lint-stability.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-stability2.rs create mode 100644 src/test/ui/compile-fail-migration/lint-stability2.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-stability3.rs create mode 100644 src/test/ui/compile-fail-migration/lint-stability3.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-type-limits.rs create mode 100644 src/test/ui/compile-fail-migration/lint-type-limits.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-type-limits2.rs create mode 100644 src/test/ui/compile-fail-migration/lint-type-limits2.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-type-limits3.rs create mode 100644 src/test/ui/compile-fail-migration/lint-type-limits3.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-type-overflow.rs create mode 100644 src/test/ui/compile-fail-migration/lint-type-overflow.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-type-overflow2.rs create mode 100644 src/test/ui/compile-fail-migration/lint-type-overflow2.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unexported-no-mangle.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unexported-no-mangle.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-attr.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-attr.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-feature-default.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-feature-default.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-feature.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-feature.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-lint.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unknown-lint.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unnecessary-parens.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unnecessary-parens.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unsafe-code.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unsafe-code.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unused-extern-crate.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unused-extern-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unused-imports.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unused-imports.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unused-mut-self.rs create mode 100644 src/test/ui/compile-fail-migration/lint-unused-mut-self.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unused-mut-variables.lexical.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unused-mut-variables.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/lint-unused-mut-variables.rs create mode 100644 src/test/ui/compile-fail-migration/lint-uppercase-variables.rs create mode 100644 src/test/ui/compile-fail-migration/lint-uppercase-variables.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-closure-require-ret.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-closure-require-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-dead.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-dead.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-forgot-ret.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-forgot-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-issue-2163.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-issue-2163.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-missing-ret2.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-missing-ret2.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-move-call-arg.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-move-call-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-move-in-loop.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-move-in-loop.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-move-in-while.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-move-in-while.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-move-in-while.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-unused.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-unused.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-use-after-move.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-use-after-move.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-use-after-move.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-use-after-send.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/liveness-use-after-send.rs create mode 100644 src/test/ui/compile-fail-migration/liveness-use-after-send.stderr create mode 100644 src/test/ui/compile-fail-migration/loop-break-value.rs create mode 100644 src/test/ui/compile-fail-migration/loop-break-value.stderr create mode 100644 src/test/ui/compile-fail-migration/loop-labeled-break-value.rs create mode 100644 src/test/ui/compile-fail-migration/loop-labeled-break-value.stderr create mode 100644 src/test/ui/compile-fail-migration/loop-proper-liveness.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/loop-proper-liveness.rs create mode 100644 src/test/ui/compile-fail-migration/loop-proper-liveness.stderr create mode 100644 src/test/ui/compile-fail-migration/loop-properly-diverging-2.rs create mode 100644 src/test/ui/compile-fail-migration/loop-properly-diverging-2.stderr create mode 100644 src/test/ui/compile-fail-migration/lto-duplicate-symbols.rs create mode 100644 src/test/ui/compile-fail-migration/lto-duplicate-symbols.stderr create mode 100644 src/test/ui/compile-fail-migration/lub-if.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/lub-if.rs create mode 100644 src/test/ui/compile-fail-migration/lub-if.stderr create mode 100644 src/test/ui/compile-fail-migration/lub-match.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/lub-match.rs create mode 100644 src/test/ui/compile-fail-migration/lub-match.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-attribute.rs create mode 100644 src/test/ui/compile-fail-migration/macro-attribute.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-comma-behavior.core.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-comma-behavior.rs create mode 100644 src/test/ui/compile-fail-migration/macro-comma-behavior.std.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-comma-support.rs create mode 100644 src/test/ui/compile-fail-migration/macro-comma-support.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.rs create mode 100644 src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-error.rs create mode 100644 src/test/ui/compile-fail-migration/macro-error.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-expanded-include/file.txt create mode 100644 src/test/ui/compile-fail-migration/macro-expanded-include/foo/mod.rs create mode 100644 src/test/ui/compile-fail-migration/macro-expanded-include/test.rs create mode 100644 src/test/ui/compile-fail-migration/macro-expanded-include/test.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-expansion-tests.rs create mode 100644 src/test/ui/compile-fail-migration/macro-expansion-tests.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-follow.rs create mode 100644 src/test/ui/compile-fail-migration/macro-follow.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.rs create mode 100644 src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-inner-attributes.rs create mode 100644 src/test/ui/compile-fail-migration/macro-inner-attributes.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-input-future-proofing.rs create mode 100644 src/test/ui/compile-fail-migration/macro-input-future-proofing.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-local-data-key-priv.rs create mode 100644 src/test/ui/compile-fail-migration/macro-local-data-key-priv.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-match-nonterminal.rs create mode 100644 src/test/ui/compile-fail-migration/macro-match-nonterminal.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-missing-delimiters.rs create mode 100644 src/test/ui/compile-fail-migration/macro-missing-delimiters.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-missing-fragment.rs create mode 100644 src/test/ui/compile-fail-migration/macro-missing-fragment.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-non-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/macro-non-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-outer-attributes.rs create mode 100644 src/test/ui/compile-fail-migration/macro-outer-attributes.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-parameter-span.rs create mode 100644 src/test/ui/compile-fail-migration/macro-parameter-span.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-stability.rs create mode 100644 src/test/ui/compile-fail-migration/macro-stability.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-stmt-matchers.rs create mode 100644 src/test/ui/compile-fail-migration/macro-stmt-matchers.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-tt-matchers.rs create mode 100644 src/test/ui/compile-fail-migration/macro-tt-matchers.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-use-bad-args-1.rs create mode 100644 src/test/ui/compile-fail-migration/macro-use-bad-args-1.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-use-bad-args-2.rs create mode 100644 src/test/ui/compile-fail-migration/macro-use-bad-args-2.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-use-scope.rs create mode 100644 src/test/ui/compile-fail-migration/macro-use-scope.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-use-undef.rs create mode 100644 src/test/ui/compile-fail-migration/macro-use-undef.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-use-wrong-name.rs create mode 100644 src/test/ui/compile-fail-migration/macro-use-wrong-name.stderr create mode 100644 src/test/ui/compile-fail-migration/macro-with-seps-err-msg.rs create mode 100644 src/test/ui/compile-fail-migration/macro-with-seps-err-msg.stderr create mode 100644 src/test/ui/compile-fail-migration/macros-in-extern.rs create mode 100644 src/test/ui/compile-fail-migration/macros-in-extern.stderr create mode 100644 src/test/ui/compile-fail-migration/macros-nonfatal-errors.rs create mode 100644 src/test/ui/compile-fail-migration/macros-nonfatal-errors.stderr create mode 100644 src/test/ui/compile-fail-migration/main-wrong-type.rs create mode 100644 src/test/ui/compile-fail-migration/main-wrong-type.stderr create mode 100644 src/test/ui/compile-fail-migration/malformed-derive-entry.rs create mode 100644 src/test/ui/compile-fail-migration/malformed-derive-entry.stderr create mode 100644 src/test/ui/compile-fail-migration/malformed-plugin-1.rs create mode 100644 src/test/ui/compile-fail-migration/malformed-plugin-1.stderr create mode 100644 src/test/ui/compile-fail-migration/malformed-plugin-2.rs create mode 100644 src/test/ui/compile-fail-migration/malformed-plugin-2.stderr create mode 100644 src/test/ui/compile-fail-migration/malformed-plugin-3.rs create mode 100644 src/test/ui/compile-fail-migration/malformed-plugin-3.stderr create mode 100644 src/test/ui/compile-fail-migration/malformed_macro_lhs.rs create mode 100644 src/test/ui/compile-fail-migration/malformed_macro_lhs.stderr create mode 100644 src/test/ui/compile-fail-migration/manual-link-bad-form.rs create mode 100644 src/test/ui/compile-fail-migration/manual-link-bad-form.stderr create mode 100644 src/test/ui/compile-fail-migration/manual-link-bad-kind.rs create mode 100644 src/test/ui/compile-fail-migration/manual-link-bad-kind.stderr create mode 100644 src/test/ui/compile-fail-migration/manual-link-bad-search-path.rs create mode 100644 src/test/ui/compile-fail-migration/manual-link-bad-search-path.stderr create mode 100644 src/test/ui/compile-fail-migration/manual-link-framework.rs create mode 100644 src/test/ui/compile-fail-migration/manual-link-framework.stderr create mode 100644 src/test/ui/compile-fail-migration/map-types.rs create mode 100644 src/test/ui/compile-fail-migration/map-types.stderr create mode 100644 src/test/ui/compile-fail-migration/match-argm-statics-2.rs create mode 100644 src/test/ui/compile-fail-migration/match-argm-statics-2.stderr create mode 100644 src/test/ui/compile-fail-migration/match-arm-statics.rs create mode 100644 src/test/ui/compile-fail-migration/match-arm-statics.stderr create mode 100644 src/test/ui/compile-fail-migration/match-byte-array-patterns-2.rs create mode 100644 src/test/ui/compile-fail-migration/match-byte-array-patterns-2.stderr create mode 100644 src/test/ui/compile-fail-migration/match-byte-array-patterns.rs create mode 100644 src/test/ui/compile-fail-migration/match-byte-array-patterns.stderr create mode 100644 src/test/ui/compile-fail-migration/match-ill-type2.rs create mode 100644 src/test/ui/compile-fail-migration/match-ill-type2.stderr create mode 100644 src/test/ui/compile-fail-migration/match-join.rs create mode 100644 src/test/ui/compile-fail-migration/match-join.stderr create mode 100644 src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.rs create mode 100644 src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.stderr create mode 100644 src/test/ui/compile-fail-migration/match-non-exhaustive.rs create mode 100644 src/test/ui/compile-fail-migration/match-non-exhaustive.stderr create mode 100644 src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.rs create mode 100644 src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.stderr create mode 100644 src/test/ui/compile-fail-migration/match-pattern-field-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/match-pattern-field-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/match-privately-empty.rs create mode 100644 src/test/ui/compile-fail-migration/match-privately-empty.stderr create mode 100644 src/test/ui/compile-fail-migration/match-range-fail-2.rs create mode 100644 src/test/ui/compile-fail-migration/match-range-fail-2.stderr create mode 100644 src/test/ui/compile-fail-migration/match-range-fail-dominate.rs create mode 100644 src/test/ui/compile-fail-migration/match-range-fail-dominate.stderr create mode 100644 src/test/ui/compile-fail-migration/match-range-fail.rs create mode 100644 src/test/ui/compile-fail-migration/match-range-fail.stderr create mode 100644 src/test/ui/compile-fail-migration/match-ref-ice.rs create mode 100644 src/test/ui/compile-fail-migration/match-ref-ice.stderr create mode 100644 src/test/ui/compile-fail-migration/match-ref-mut-invariance.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/match-ref-mut-invariance.rs create mode 100644 src/test/ui/compile-fail-migration/match-ref-mut-invariance.stderr create mode 100644 src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.rs create mode 100644 src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.stderr create mode 100644 src/test/ui/compile-fail-migration/match-slice-patterns.rs create mode 100644 src/test/ui/compile-fail-migration/match-slice-patterns.stderr create mode 100644 src/test/ui/compile-fail-migration/match-static-const-lc.rs create mode 100644 src/test/ui/compile-fail-migration/match-static-const-lc.stderr create mode 100644 src/test/ui/compile-fail-migration/match-struct.rs create mode 100644 src/test/ui/compile-fail-migration/match-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/match-tag-nullary.rs create mode 100644 src/test/ui/compile-fail-migration/match-tag-nullary.stderr create mode 100644 src/test/ui/compile-fail-migration/match-tag-unary.rs create mode 100644 src/test/ui/compile-fail-migration/match-tag-unary.stderr create mode 100644 src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.rs create mode 100644 src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.stderr create mode 100644 src/test/ui/compile-fail-migration/match-unresolved-one-arm.rs create mode 100644 src/test/ui/compile-fail-migration/match-unresolved-one-arm.stderr create mode 100644 src/test/ui/compile-fail-migration/match-vec-fixed.rs create mode 100644 src/test/ui/compile-fail-migration/match-vec-fixed.stderr create mode 100644 src/test/ui/compile-fail-migration/match-vec-mismatch-2.rs create mode 100644 src/test/ui/compile-fail-migration/match-vec-mismatch-2.stderr create mode 100644 src/test/ui/compile-fail-migration/match-vec-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/match-vec-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/match-vec-unreachable.rs create mode 100644 src/test/ui/compile-fail-migration/match-vec-unreachable.stderr create mode 100644 src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.rs create mode 100644 src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.stderr create mode 100644 src/test/ui/compile-fail-migration/maybe-bounds-where.rs create mode 100644 src/test/ui/compile-fail-migration/maybe-bounds-where.stderr create mode 100644 src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.a.stderr create mode 100644 src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.rs create mode 100644 src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.a.stderr create mode 100644 src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.rs create mode 100644 src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.rs create mode 100644 src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.stderr create mode 100644 src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.rs create mode 100644 src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.rs create mode 100644 src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.stderr create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.rs create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.stderr create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.rs create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.stderr create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.rs create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.stderr create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args.rs create mode 100644 src/test/ui/compile-fail-migration/method-call-lifetime-args.stderr create mode 100644 src/test/ui/compile-fail-migration/method-call-type-binding.rs create mode 100644 src/test/ui/compile-fail-migration/method-call-type-binding.stderr create mode 100644 src/test/ui/compile-fail-migration/method-macro-backtrace.rs create mode 100644 src/test/ui/compile-fail-migration/method-macro-backtrace.stderr create mode 100644 src/test/ui/compile-fail-migration/method-path-in-pattern.rs create mode 100644 src/test/ui/compile-fail-migration/method-path-in-pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.rs create mode 100644 src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/method-self-arg-1.rs create mode 100644 src/test/ui/compile-fail-migration/method-self-arg-1.stderr create mode 100644 src/test/ui/compile-fail-migration/method-self-arg-2.rs create mode 100644 src/test/ui/compile-fail-migration/method-self-arg-2.stderr create mode 100644 src/test/ui/compile-fail-migration/minus-string.rs create mode 100644 src/test/ui/compile-fail-migration/minus-string.stderr create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/README.md create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.rs create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.stderr create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/inits-1.rs create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/inits-1.stderr create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.rs create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.stderr create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.rs create mode 100644 src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.stderr create mode 100644 src/test/ui/compile-fail-migration/mir-unpretty.rs create mode 100644 src/test/ui/compile-fail-migration/mir-unpretty.stderr create mode 100644 src/test/ui/compile-fail-migration/missing-derivable-attr.rs create mode 100644 src/test/ui/compile-fail-migration/missing-derivable-attr.stderr create mode 100644 src/test/ui/compile-fail-migration/missing-macro-use.rs create mode 100644 src/test/ui/compile-fail-migration/missing-macro-use.stderr create mode 100644 src/test/ui/compile-fail-migration/missing-main.rs create mode 100644 src/test/ui/compile-fail-migration/missing-main.stderr create mode 100644 src/test/ui/compile-fail-migration/missing-return.rs create mode 100644 src/test/ui/compile-fail-migration/missing-return.stderr create mode 100644 src/test/ui/compile-fail-migration/missing-semicolon-warning.rs create mode 100644 src/test/ui/compile-fail-migration/missing-semicolon-warning.stderr create mode 100644 src/test/ui/compile-fail-migration/missing-stability.rs create mode 100644 src/test/ui/compile-fail-migration/missing-stability.stderr create mode 100644 src/test/ui/compile-fail-migration/missing_debug_impls.rs create mode 100644 src/test/ui/compile-fail-migration/missing_debug_impls.stderr create mode 100644 src/test/ui/compile-fail-migration/mod_file_aux.rs create mode 100644 src/test/ui/compile-fail-migration/mod_file_correct_spans.rs create mode 100644 src/test/ui/compile-fail-migration/mod_file_correct_spans.stderr create mode 100644 src/test/ui/compile-fail-migration/mod_file_disambig.rs create mode 100644 src/test/ui/compile-fail-migration/mod_file_disambig.stderr create mode 100644 src/test/ui/compile-fail-migration/mod_file_disambig_aux.rs create mode 100644 src/test/ui/compile-fail-migration/mod_file_disambig_aux/mod.rs create mode 100644 src/test/ui/compile-fail-migration/module-macro_use-arguments.rs create mode 100644 src/test/ui/compile-fail-migration/module-macro_use-arguments.stderr create mode 100644 src/test/ui/compile-fail-migration/move-guard-same-consts.rs create mode 100644 src/test/ui/compile-fail-migration/move-guard-same-consts.stderr create mode 100644 src/test/ui/compile-fail-migration/move-in-guard-1.rs create mode 100644 src/test/ui/compile-fail-migration/move-in-guard-1.stderr create mode 100644 src/test/ui/compile-fail-migration/move-in-guard-2.rs create mode 100644 src/test/ui/compile-fail-migration/move-in-guard-2.stderr create mode 100644 src/test/ui/compile-fail-migration/move-into-dead-array-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/move-into-dead-array-1.rs create mode 100644 src/test/ui/compile-fail-migration/move-into-dead-array-1.stderr create mode 100644 src/test/ui/compile-fail-migration/move-into-dead-array-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/move-into-dead-array-2.rs create mode 100644 src/test/ui/compile-fail-migration/move-into-dead-array-2.stderr create mode 100644 src/test/ui/compile-fail-migration/move-out-of-array-1.rs create mode 100644 src/test/ui/compile-fail-migration/move-out-of-array-1.stderr create mode 100644 src/test/ui/compile-fail-migration/move-out-of-slice-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/move-out-of-slice-1.rs create mode 100644 src/test/ui/compile-fail-migration/move-out-of-slice-1.stderr create mode 100644 src/test/ui/compile-fail-migration/move-out-of-tuple-field.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/move-out-of-tuple-field.rs create mode 100644 src/test/ui/compile-fail-migration/move-out-of-tuple-field.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.rs create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.rs create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.rs create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.rs create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-exprs.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-exprs.rs create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-exprs.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.rs create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.rs create mode 100644 src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-sru-moved-field.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/moves-sru-moved-field.rs create mode 100644 src/test/ui/compile-fail-migration/moves-sru-moved-field.stderr create mode 100644 src/test/ui/compile-fail-migration/multiple-main-2.rs create mode 100644 src/test/ui/compile-fail-migration/multiple-main-2.stderr create mode 100644 src/test/ui/compile-fail-migration/multiple-main-3.rs create mode 100644 src/test/ui/compile-fail-migration/multiple-main-3.stderr create mode 100644 src/test/ui/compile-fail-migration/multiple-plugin-registrars.rs create mode 100644 src/test/ui/compile-fail-migration/multiple-plugin-registrars.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-cant-alias.rs create mode 100644 src/test/ui/compile-fail-migration/mut-cant-alias.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-cross-borrowing.rs create mode 100644 src/test/ui/compile-fail-migration/mut-cross-borrowing.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.rs create mode 100644 src/test/ui/compile-fail-migration/mut-pattern-mismatched.rs create mode 100644 src/test/ui/compile-fail-migration/mut-pattern-mismatched.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-suggestion.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/mut-suggestion.rs create mode 100644 src/test/ui/compile-fail-migration/mut-suggestion.stderr create mode 100644 src/test/ui/compile-fail-migration/mutable-class-fields-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/mutable-class-fields-2.rs create mode 100644 src/test/ui/compile-fail-migration/mutable-class-fields-2.stderr create mode 100644 src/test/ui/compile-fail-migration/mutable-class-fields.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/mutable-class-fields.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/mutable-class-fields.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/mutable-class-fields.rs create mode 100644 src/test/ui/compile-fail-migration/mutable-enum-indirect.rs create mode 100644 src/test/ui/compile-fail-migration/mutable-enum-indirect.stderr create mode 100644 src/test/ui/compile-fail-migration/mutexguard-sync.rs create mode 100644 src/test/ui/compile-fail-migration/mutexguard-sync.stderr create mode 100644 src/test/ui/compile-fail-migration/namespace-mix.rs create mode 100644 src/test/ui/compile-fail-migration/namespace-mix.stderr create mode 100644 src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.rs create mode 100644 src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.stderr create mode 100644 src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.rs create mode 100644 src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.stderr create mode 100644 src/test/ui/compile-fail-migration/nested-cfg-attrs.rs create mode 100644 src/test/ui/compile-fail-migration/nested-cfg-attrs.stderr create mode 100644 src/test/ui/compile-fail-migration/nested-ty-params.rs create mode 100644 src/test/ui/compile-fail-migration/nested-ty-params.stderr create mode 100644 src/test/ui/compile-fail-migration/never-assign-dead-code.rs create mode 100644 src/test/ui/compile-fail-migration/never-assign-dead-code.stderr create mode 100644 src/test/ui/compile-fail-migration/never-assign-wrong-type.rs create mode 100644 src/test/ui/compile-fail-migration/never-assign-wrong-type.stderr create mode 100644 src/test/ui/compile-fail-migration/never_transmute_never.rs create mode 100644 src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.rs create mode 100644 src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.rs create mode 100644 src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.rs create mode 100644 src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.rs create mode 100644 src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.rs create mode 100644 src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.rs create mode 100644 src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.rs create mode 100644 src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/return_from_loop.rs create mode 100644 src/test/ui/compile-fail-migration/nll/return_from_loop.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.rs create mode 100644 src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.rs create mode 100644 src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.stderr create mode 100644 src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.rs create mode 100644 src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.stderr create mode 100644 src/test/ui/compile-fail-migration/no-capture-arc.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/no-capture-arc.rs create mode 100644 src/test/ui/compile-fail-migration/no-capture-arc.stderr create mode 100644 src/test/ui/compile-fail-migration/no-implicit-prelude-nested.rs create mode 100644 src/test/ui/compile-fail-migration/no-implicit-prelude-nested.stderr create mode 100644 src/test/ui/compile-fail-migration/no-implicit-prelude.rs create mode 100644 src/test/ui/compile-fail-migration/no-implicit-prelude.stderr create mode 100644 src/test/ui/compile-fail-migration/no-link.rs create mode 100644 src/test/ui/compile-fail-migration/no-link.stderr create mode 100644 src/test/ui/compile-fail-migration/no-patterns-in-args-2.rs create mode 100644 src/test/ui/compile-fail-migration/no-patterns-in-args-2.stderr create mode 100644 src/test/ui/compile-fail-migration/no-patterns-in-args-macro.rs create mode 100644 src/test/ui/compile-fail-migration/no-patterns-in-args-macro.stderr create mode 100644 src/test/ui/compile-fail-migration/no-reuse-move-arc.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/no-reuse-move-arc.rs create mode 100644 src/test/ui/compile-fail-migration/no-reuse-move-arc.stderr create mode 100644 src/test/ui/compile-fail-migration/no-send-res-ports.rs create mode 100644 src/test/ui/compile-fail-migration/no-send-res-ports.stderr create mode 100644 src/test/ui/compile-fail-migration/no-std-inject.rs create mode 100644 src/test/ui/compile-fail-migration/no-std-inject.stderr create mode 100644 src/test/ui/compile-fail-migration/no-type-for-node-ice.rs create mode 100644 src/test/ui/compile-fail-migration/no-type-for-node-ice.stderr create mode 100644 src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.rs create mode 100644 src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.stderr create mode 100644 src/test/ui/compile-fail-migration/no_crate_type.rs create mode 100644 src/test/ui/compile-fail-migration/no_crate_type.stderr create mode 100644 src/test/ui/compile-fail-migration/no_owned_box_lang_item.rs create mode 100644 src/test/ui/compile-fail-migration/no_owned_box_lang_item.stderr create mode 100644 src/test/ui/compile-fail-migration/no_send-enum.rs create mode 100644 src/test/ui/compile-fail-migration/no_send-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/no_send-rc.rs create mode 100644 src/test/ui/compile-fail-migration/no_send-rc.stderr create mode 100644 src/test/ui/compile-fail-migration/no_send-struct.rs create mode 100644 src/test/ui/compile-fail-migration/no_send-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/no_share-enum.rs create mode 100644 src/test/ui/compile-fail-migration/no_share-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/no_share-struct.rs create mode 100644 src/test/ui/compile-fail-migration/no_share-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/noexporttypeexe.rs create mode 100644 src/test/ui/compile-fail-migration/noexporttypeexe.stderr create mode 100644 src/test/ui/compile-fail-migration/nolink-with-link-args.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/nolink-with-link-args.rs create mode 100644 src/test/ui/compile-fail-migration/nolink-with-link-args.stderr create mode 100644 src/test/ui/compile-fail-migration/non-constant-in-const-path.rs create mode 100644 src/test/ui/compile-fail-migration/non-constant-in-const-path.stderr create mode 100644 src/test/ui/compile-fail-migration/non-copyable-void.rs create mode 100644 src/test/ui/compile-fail-migration/non-copyable-void.stderr create mode 100644 src/test/ui/compile-fail-migration/non-exhaustive-match-nested.rs create mode 100644 src/test/ui/compile-fail-migration/non-exhaustive-match-nested.stderr create mode 100644 src/test/ui/compile-fail-migration/non-exhaustive-match.rs create mode 100644 src/test/ui/compile-fail-migration/non-exhaustive-match.stderr create mode 100644 src/test/ui/compile-fail-migration/non-interger-atomic.rs create mode 100644 src/test/ui/compile-fail-migration/non-interger-atomic.stderr create mode 100644 src/test/ui/compile-fail-migration/noncopyable-class.rs create mode 100644 src/test/ui/compile-fail-migration/noncopyable-class.stderr create mode 100644 src/test/ui/compile-fail-migration/nonscalar-cast.rs create mode 100644 src/test/ui/compile-fail-migration/nonscalar-cast.stderr create mode 100644 src/test/ui/compile-fail-migration/not-clone-closure.rs create mode 100644 src/test/ui/compile-fail-migration/not-clone-closure.stderr create mode 100644 src/test/ui/compile-fail-migration/not-copy-closure.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/not-copy-closure.rs create mode 100644 src/test/ui/compile-fail-migration/not-copy-closure.stderr create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-2.rs create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-2.stderr create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-3.rs create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-3.stderr create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-4.rs create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-4.stderr create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-5.rs create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-5.stderr create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-6.rs create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe-6.stderr create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe.rs create mode 100644 src/test/ui/compile-fail-migration/not-panic-safe.stderr create mode 100644 src/test/ui/compile-fail-migration/not-sync.rs create mode 100644 src/test/ui/compile-fail-migration/not-sync.stderr create mode 100644 src/test/ui/compile-fail-migration/not-utf8.bin create mode 100644 src/test/ui/compile-fail-migration/not-utf8.rs create mode 100644 src/test/ui/compile-fail-migration/not-utf8.stderr create mode 100644 src/test/ui/compile-fail-migration/object-does-not-impl-trait.rs create mode 100644 src/test/ui/compile-fail-migration/object-does-not-impl-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.rs create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-elision.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-elision.rs create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-elision.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.rs create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.rs create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.rs create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-mybox.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-mybox.rs create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default-mybox.stderr create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default.rs create mode 100644 src/test/ui/compile-fail-migration/object-lifetime-default.stderr create mode 100644 src/test/ui/compile-fail-migration/object-pointer-types.rs create mode 100644 src/test/ui/compile-fail-migration/object-pointer-types.stderr create mode 100644 src/test/ui/compile-fail-migration/object-safety-by-value-self-use.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/object-safety-by-value-self-use.rs create mode 100644 src/test/ui/compile-fail-migration/object-safety-by-value-self-use.stderr create mode 100644 src/test/ui/compile-fail-migration/object-safety-by-value-self.rs create mode 100644 src/test/ui/compile-fail-migration/object-safety-by-value-self.stderr create mode 100644 src/test/ui/compile-fail-migration/object-safety-issue-22040.rs create mode 100644 src/test/ui/compile-fail-migration/object-safety-issue-22040.stderr create mode 100644 src/test/ui/compile-fail-migration/object-safety-no-static.rs create mode 100644 src/test/ui/compile-fail-migration/object-safety-no-static.stderr create mode 100644 src/test/ui/compile-fail-migration/object-safety-phantom-fn.rs create mode 100644 src/test/ui/compile-fail-migration/object-safety-phantom-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/object-safety-sized-2.rs create mode 100644 src/test/ui/compile-fail-migration/object-safety-sized-2.stderr create mode 100644 src/test/ui/compile-fail-migration/occurs-check-2.rs create mode 100644 src/test/ui/compile-fail-migration/occurs-check-2.stderr create mode 100644 src/test/ui/compile-fail-migration/occurs-check-3.rs create mode 100644 src/test/ui/compile-fail-migration/occurs-check-3.stderr create mode 100644 src/test/ui/compile-fail-migration/occurs-check.rs create mode 100644 src/test/ui/compile-fail-migration/occurs-check.stderr create mode 100644 src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.rs create mode 100644 src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.stderr create mode 100644 src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.rs create mode 100644 src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.stderr create mode 100644 src/test/ui/compile-fail-migration/opt-in-copy.rs create mode 100644 src/test/ui/compile-fail-migration/opt-in-copy.stderr create mode 100644 src/test/ui/compile-fail-migration/or-patter-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/or-patter-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/orphan-check-diagnostics.rs create mode 100644 src/test/ui/compile-fail-migration/orphan-check-diagnostics.stderr create mode 100644 src/test/ui/compile-fail-migration/osx-frameworks.rs create mode 100644 src/test/ui/compile-fail-migration/osx-frameworks.stderr create mode 100644 src/test/ui/compile-fail-migration/out-of-order-shadowing.rs create mode 100644 src/test/ui/compile-fail-migration/out-of-order-shadowing.stderr create mode 100644 src/test/ui/compile-fail-migration/output-type-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/output-type-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/overlap-marker-trait.rs create mode 100644 src/test/ui/compile-fail-migration/overlap-marker-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/overloaded-calls-nontuple.rs create mode 100644 src/test/ui/compile-fail-migration/overloaded-calls-nontuple.stderr create mode 100644 src/test/ui/compile-fail-migration/packed-struct-generic-transmute.rs create mode 100644 src/test/ui/compile-fail-migration/packed-struct-generic-transmute.stderr create mode 100644 src/test/ui/compile-fail-migration/packed-struct-transmute.rs create mode 100644 src/test/ui/compile-fail-migration/packed-struct-transmute.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-duplicate.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-duplicate.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-missing.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-missing.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-std.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-std.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-twice.rs create mode 100644 src/test/ui/compile-fail-migration/panic-implementation-twice.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/depends.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/needs-panic-runtime.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-abort.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-lang-items.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind2.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-abort.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/needs-gate.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/needs-gate.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.stderr create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.rs create mode 100644 src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.stderr create mode 100644 src/test/ui/compile-fail-migration/panic_implementation-closures.rs create mode 100644 src/test/ui/compile-fail-migration/paren-span.rs create mode 100644 src/test/ui/compile-fail-migration/paren-span.stderr create mode 100644 src/test/ui/compile-fail-migration/parse-error-correct.rs create mode 100644 src/test/ui/compile-fail-migration/parse-error-correct.stderr create mode 100644 src/test/ui/compile-fail-migration/parser-recovery-1.rs create mode 100644 src/test/ui/compile-fail-migration/parser-recovery-1.stderr create mode 100644 src/test/ui/compile-fail-migration/parser-recovery-2.rs create mode 100644 src/test/ui/compile-fail-migration/parser-recovery-2.stderr create mode 100644 src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.rs create mode 100644 src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.stderr create mode 100644 src/test/ui/compile-fail-migration/pat-tuple-bad-type.rs create mode 100644 src/test/ui/compile-fail-migration/pat-tuple-bad-type.stderr create mode 100644 src/test/ui/compile-fail-migration/pat-tuple-overfield.rs create mode 100644 src/test/ui/compile-fail-migration/pat-tuple-overfield.stderr create mode 100644 src/test/ui/compile-fail-migration/patkind-litrange-no-expr.rs create mode 100644 src/test/ui/compile-fail-migration/patkind-litrange-no-expr.stderr create mode 100644 src/test/ui/compile-fail-migration/pattern-binding-disambiguation.rs create mode 100644 src/test/ui/compile-fail-migration/pattern-binding-disambiguation.stderr create mode 100644 src/test/ui/compile-fail-migration/pattern-bindings-after-at.rs create mode 100644 src/test/ui/compile-fail-migration/pattern-bindings-after-at.stderr create mode 100644 src/test/ui/compile-fail-migration/pattern-error-continue.rs create mode 100644 src/test/ui/compile-fail-migration/pattern-error-continue.stderr create mode 100644 src/test/ui/compile-fail-migration/pattern-ident-path-generics.rs create mode 100644 src/test/ui/compile-fail-migration/pattern-ident-path-generics.stderr create mode 100644 src/test/ui/compile-fail-migration/pattern-tyvar-2.rs create mode 100644 src/test/ui/compile-fail-migration/pattern-tyvar-2.stderr create mode 100644 src/test/ui/compile-fail-migration/pattern-tyvar.rs create mode 100644 src/test/ui/compile-fail-migration/pattern-tyvar.stderr create mode 100644 src/test/ui/compile-fail-migration/phantom-oibit.rs create mode 100644 src/test/ui/compile-fail-migration/phantom-oibit.stderr create mode 100644 src/test/ui/compile-fail-migration/platform-intrinsic-params.rs create mode 100644 src/test/ui/compile-fail-migration/platform-intrinsic-params.stderr create mode 100644 src/test/ui/compile-fail-migration/pptypedef.rs create mode 100644 src/test/ui/compile-fail-migration/pptypedef.stderr create mode 100644 src/test/ui/compile-fail-migration/prim-with-args.rs create mode 100644 src/test/ui/compile-fail-migration/prim-with-args.stderr create mode 100644 src/test/ui/compile-fail-migration/priv-in-bad-locations.rs create mode 100644 src/test/ui/compile-fail-migration/priv-in-bad-locations.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy-in-paths.rs create mode 100644 src/test/ui/compile-fail-migration/privacy-in-paths.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy-ns1.rs create mode 100644 src/test/ui/compile-fail-migration/privacy-ns1.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy-ns2.rs create mode 100644 src/test/ui/compile-fail-migration/privacy-ns2.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy-sanity.rs create mode 100644 src/test/ui/compile-fail-migration/privacy-sanity.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy-ufcs.rs create mode 100644 src/test/ui/compile-fail-migration/privacy-ufcs.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/auxiliary/pub_restricted.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/test.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/restricted/test.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.rs create mode 100644 src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy1.rs create mode 100644 src/test/ui/compile-fail-migration/privacy1.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy2.rs create mode 100644 src/test/ui/compile-fail-migration/privacy2.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy3.rs create mode 100644 src/test/ui/compile-fail-migration/privacy3.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy4.rs create mode 100644 src/test/ui/compile-fail-migration/privacy4.stderr create mode 100644 src/test/ui/compile-fail-migration/privacy5.rs create mode 100644 src/test/ui/compile-fail-migration/privacy5.stderr create mode 100644 src/test/ui/compile-fail-migration/private-impl-method.rs create mode 100644 src/test/ui/compile-fail-migration/private-impl-method.stderr create mode 100644 src/test/ui/compile-fail-migration/private-in-public-assoc-ty.rs create mode 100644 src/test/ui/compile-fail-migration/private-in-public-assoc-ty.stderr create mode 100644 src/test/ui/compile-fail-migration/private-in-public-ill-formed.rs create mode 100644 src/test/ui/compile-fail-migration/private-in-public-ill-formed.stderr create mode 100644 src/test/ui/compile-fail-migration/private-in-public-lint.rs create mode 100644 src/test/ui/compile-fail-migration/private-in-public-lint.stderr create mode 100644 src/test/ui/compile-fail-migration/private-in-public-warn.rs create mode 100644 src/test/ui/compile-fail-migration/private-in-public-warn.stderr create mode 100644 src/test/ui/compile-fail-migration/private-in-public.rs create mode 100644 src/test/ui/compile-fail-migration/private-in-public.stderr create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type-1.rs create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type-1.stderr create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type-2.rs create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type-2.stderr create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type-3.rs create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type-3.stderr create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type.rs create mode 100644 src/test/ui/compile-fail-migration/private-inferred-type.stderr create mode 100644 src/test/ui/compile-fail-migration/private-item-simple.rs create mode 100644 src/test/ui/compile-fail-migration/private-item-simple.stderr create mode 100644 src/test/ui/compile-fail-migration/private-method-cross-crate.rs create mode 100644 src/test/ui/compile-fail-migration/private-method-cross-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/private-method-inherited.rs create mode 100644 src/test/ui/compile-fail-migration/private-method-inherited.stderr create mode 100644 src/test/ui/compile-fail-migration/private-method.rs create mode 100644 src/test/ui/compile-fail-migration/private-method.stderr create mode 100644 src/test/ui/compile-fail-migration/private-struct-field-cross-crate.rs create mode 100644 src/test/ui/compile-fail-migration/private-struct-field-cross-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/private-struct-field-ctor.rs create mode 100644 src/test/ui/compile-fail-migration/private-struct-field-ctor.stderr create mode 100644 src/test/ui/compile-fail-migration/private-struct-field-pattern.rs create mode 100644 src/test/ui/compile-fail-migration/private-struct-field-pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/private-struct-field.rs create mode 100644 src/test/ui/compile-fail-migration/private-struct-field.stderr create mode 100644 src/test/ui/compile-fail-migration/private-type-in-interface.rs create mode 100644 src/test/ui/compile-fail-migration/private-type-in-interface.stderr create mode 100644 src/test/ui/compile-fail-migration/private-variant-reexport.rs create mode 100644 src/test/ui/compile-fail-migration/private-variant-reexport.stderr create mode 100644 src/test/ui/compile-fail-migration/ptr-coercion.rs create mode 100644 src/test/ui/compile-fail-migration/ptr-coercion.stderr create mode 100644 src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.rs create mode 100644 src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/qualified-path-params.rs create mode 100644 src/test/ui/compile-fail-migration/qualified-path-params.stderr create mode 100644 src/test/ui/compile-fail-migration/question-mark-type-infer.rs create mode 100644 src/test/ui/compile-fail-migration/question-mark-type-infer.stderr create mode 100644 src/test/ui/compile-fail-migration/quote-with-interpolated.rs create mode 100644 src/test/ui/compile-fail-migration/quote-with-interpolated.stderr create mode 100644 src/test/ui/compile-fail-migration/range-1.rs create mode 100644 src/test/ui/compile-fail-migration/range-1.stderr create mode 100644 src/test/ui/compile-fail-migration/range_traits-1.rs create mode 100644 src/test/ui/compile-fail-migration/range_traits-1.stderr create mode 100644 src/test/ui/compile-fail-migration/range_traits-2.rs create mode 100644 src/test/ui/compile-fail-migration/range_traits-2.stderr create mode 100644 src/test/ui/compile-fail-migration/range_traits-3.rs create mode 100644 src/test/ui/compile-fail-migration/range_traits-3.stderr create mode 100644 src/test/ui/compile-fail-migration/range_traits-4.rs create mode 100644 src/test/ui/compile-fail-migration/range_traits-4.stderr create mode 100644 src/test/ui/compile-fail-migration/range_traits-5.rs create mode 100644 src/test/ui/compile-fail-migration/range_traits-5.stderr create mode 100644 src/test/ui/compile-fail-migration/range_traits-6.rs create mode 100644 src/test/ui/compile-fail-migration/range_traits-6.stderr create mode 100644 src/test/ui/compile-fail-migration/range_traits-7.rs create mode 100644 src/test/ui/compile-fail-migration/range_traits-7.stderr create mode 100644 src/test/ui/compile-fail-migration/recursion.rs create mode 100644 src/test/ui/compile-fail-migration/recursion.stderr create mode 100644 src/test/ui/compile-fail-migration/recursive-enum.rs create mode 100644 src/test/ui/compile-fail-migration/recursive-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/recursive-reexports.rs create mode 100644 src/test/ui/compile-fail-migration/recursive-reexports.stderr create mode 100644 src/test/ui/compile-fail-migration/recursive-static-definition.rs create mode 100644 src/test/ui/compile-fail-migration/recursive-static-definition.stderr create mode 100644 src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.rs create mode 100644 src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.stderr create mode 100644 src/test/ui/compile-fail-migration/ref-suggestion.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/ref-suggestion.rs create mode 100644 src/test/ui/compile-fail-migration/ref-suggestion.stderr create mode 100644 src/test/ui/compile-fail-migration/refutable-pattern-errors.rs create mode 100644 src/test/ui/compile-fail-migration/refutable-pattern-errors.stderr create mode 100644 src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.rs create mode 100644 src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.rs create mode 100644 src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.rs create mode 100644 src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.rs create mode 100644 src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.stderr create mode 100644 src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.rs create mode 100644 src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.rs create mode 100644 src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.stderr create mode 100644 src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.rs create mode 100644 src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.stderr create mode 100644 src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-1.rs create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-1.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-2.rs create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-2.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-3.rs create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-3.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-4.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-4.rs create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-4.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-5.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-5.rs create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-5.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.rs create mode 100644 src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-arg.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-arg.rs create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-self.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-self.rs create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-self.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.rs create mode 100644 src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.rs create mode 100644 src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.rs create mode 100644 src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.rs create mode 100644 src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.rs create mode 100644 src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.rs create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.rs create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.rs create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.rs create mode 100644 src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounds.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/regions-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-1.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-1.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-2.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-2.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-3.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-3.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-3.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-4.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-4.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-4.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-5.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-5.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-object-into-object-5.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-param-into-object.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-close-param-into-object.rs create mode 100644 src/test/ui/compile-fail-migration/regions-close-param-into-object.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums.rs create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums3.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums3.rs create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums3.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums4.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums4.rs create mode 100644 src/test/ui/compile-fail-migration/regions-creating-enums4.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-early-bound-error-method.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-early-bound-error-method.rs create mode 100644 src/test/ui/compile-fail-migration/regions-early-bound-error-method.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-early-bound-error.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-early-bound-error.rs create mode 100644 src/test/ui/compile-fail-migration/regions-early-bound-error.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-enum-not-wf.rs create mode 100644 src/test/ui/compile-fail-migration/regions-enum-not-wf.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-escape-method.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-escape-method.rs create mode 100644 src/test/ui/compile-fail-migration/regions-escape-method.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.rs create mode 100644 src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.rs create mode 100644 src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.rs create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.rs create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.rs create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.rs create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.rs create mode 100644 src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-glb-free-free.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-glb-free-free.rs create mode 100644 src/test/ui/compile-fail-migration/regions-glb-free-free.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.rs create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.rs create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.rs create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.rs create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.rs create mode 100644 src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-in-enums-anon.rs create mode 100644 src/test/ui/compile-fail-migration/regions-in-enums-anon.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-in-enums.rs create mode 100644 src/test/ui/compile-fail-migration/regions-in-enums.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-in-structs-anon.rs create mode 100644 src/test/ui/compile-fail-migration/regions-in-structs-anon.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-in-structs.rs create mode 100644 src/test/ui/compile-fail-migration/regions-in-structs.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-call-3.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-call-3.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-call-3.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-not-param.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-not-param.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-not-param.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.rs create mode 100644 src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.rs create mode 100644 src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.rs create mode 100644 src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-name-duplicated.rs create mode 100644 src/test/ui/compile-fail-migration/regions-name-duplicated.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-name-static.rs create mode 100644 src/test/ui/compile-fail-migration/regions-name-static.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-name-undeclared.rs create mode 100644 src/test/ui/compile-fail-migration/regions-name-undeclared.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-nested-fns.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-nested-fns.rs create mode 100644 src/test/ui/compile-fail-migration/regions-nested-fns.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.rs create mode 100644 src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-container.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-container.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-scalar.rs create mode 100644 src/test/ui/compile-fail-migration/regions-outlives-scalar.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.rs create mode 100644 src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.rs create mode 100644 src/test/ui/compile-fail-migration/regions-proc-bound-capture.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-proc-bound-capture.rs create mode 100644 src/test/ui/compile-fail-migration/regions-proc-bound-capture.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.rs create mode 100644 src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.rs create mode 100644 src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.rs create mode 100644 src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ret-borrowed-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ret-borrowed-1.rs create mode 100644 src/test/ui/compile-fail-migration/regions-ret-borrowed-1.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ret-borrowed.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ret-borrowed.rs create mode 100644 src/test/ui/compile-fail-migration/regions-ret-borrowed.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ret.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-ret.rs create mode 100644 src/test/ui/compile-fail-migration/regions-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.rs create mode 100644 src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.rs create mode 100644 src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-static-bound.ll.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-static-bound.ll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-static-bound.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-static-bound.rs create mode 100644 src/test/ui/compile-fail-migration/regions-steal-closure.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-steal-closure.rs create mode 100644 src/test/ui/compile-fail-migration/regions-steal-closure.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-struct-not-wf.lexical.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-struct-not-wf.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-struct-not-wf.rs create mode 100644 src/test/ui/compile-fail-migration/regions-trait-1.rs create mode 100644 src/test/ui/compile-fail-migration/regions-trait-1.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-trait-object-subtyping.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-trait-object-subtyping.rs create mode 100644 src/test/ui/compile-fail-migration/regions-trait-object-subtyping.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-trait-variance.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-trait-variance.rs create mode 100644 src/test/ui/compile-fail-migration/regions-trait-variance.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-undeclared.rs create mode 100644 src/test/ui/compile-fail-migration/regions-undeclared.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.rs create mode 100644 src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.rs create mode 100644 src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.rs create mode 100644 src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.rs create mode 100644 src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.rs create mode 100644 src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.rs create mode 100644 src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.stderr create mode 100644 src/test/ui/compile-fail-migration/regions-wf-trait-object.rs create mode 100644 src/test/ui/compile-fail-migration/regions-wf-trait-object.stderr create mode 100644 src/test/ui/compile-fail-migration/reject-specialized-drops-8142.rs create mode 100644 src/test/ui/compile-fail-migration/reject-specialized-drops-8142.stderr create mode 100644 src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.rs create mode 100644 src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.stderr create mode 100644 src/test/ui/compile-fail-migration/repeat_count.rs create mode 100644 src/test/ui/compile-fail-migration/repeat_count.stderr create mode 100644 src/test/ui/compile-fail-migration/repr-align.rs create mode 100644 src/test/ui/compile-fail-migration/repr-align.stderr create mode 100644 src/test/ui/compile-fail-migration/repr-packed-contains-align.rs create mode 100644 src/test/ui/compile-fail-migration/repr-packed-contains-align.stderr create mode 100644 src/test/ui/compile-fail-migration/repr-transparent-other-items.rs create mode 100644 src/test/ui/compile-fail-migration/repr-transparent-other-items.stderr create mode 100644 src/test/ui/compile-fail-migration/repr-transparent-other-reprs.rs create mode 100644 src/test/ui/compile-fail-migration/repr-transparent-other-reprs.stderr create mode 100644 src/test/ui/compile-fail-migration/repr-transparent.rs create mode 100644 src/test/ui/compile-fail-migration/repr-transparent.stderr create mode 100644 src/test/ui/compile-fail-migration/required-lang-item.rs create mode 100644 src/test/ui/compile-fail-migration/required-lang-item.stderr create mode 100644 src/test/ui/compile-fail-migration/reserved-attr-on-macro.rs create mode 100644 src/test/ui/compile-fail-migration/reserved-attr-on-macro.stderr create mode 100644 src/test/ui/compile-fail-migration/reserved-become.rs create mode 100644 src/test/ui/compile-fail-migration/reserved-become.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-bad-import-prefix.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-bad-import-prefix.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-bad-visibility.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-bad-visibility.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-label.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-label.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-primitive-fallback.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-primitive-fallback.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-self-in-impl-2.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-self-in-impl-2.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-self-in-impl.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-self-in-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-unknown-trait.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-unknown-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve-variant-assoc-item.rs create mode 100644 src/test/ui/compile-fail-migration/resolve-variant-assoc-item.stderr create mode 100644 src/test/ui/compile-fail-migration/resolve_self_super_hint.rs create mode 100644 src/test/ui/compile-fail-migration/resolve_self_super_hint.stderr create mode 100644 src/test/ui/compile-fail-migration/ret-non-nil.rs create mode 100644 src/test/ui/compile-fail-migration/ret-non-nil.stderr create mode 100644 src/test/ui/compile-fail-migration/retslot-cast.rs create mode 100644 src/test/ui/compile-fail-migration/retslot-cast.stderr create mode 100644 src/test/ui/compile-fail-migration/return-from-diverging.rs create mode 100644 src/test/ui/compile-fail-migration/return-from-diverging.stderr create mode 100644 src/test/ui/compile-fail-migration/return-unit-from-diverging.rs create mode 100644 src/test/ui/compile-fail-migration/return-unit-from-diverging.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/enums.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/structs.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/variants.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/auxiliary/xcrate.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.rs create mode 100644 src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1445/feature-gate.no_gate.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1445/feature-gate.rs create mode 100644 src/test/ui/compile-fail-migration/rfc1445/feature-gate.with_gate.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.rs create mode 100644 src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.rs create mode 100644 src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1623.rs create mode 100644 src/test/ui/compile-fail-migration/rfc1623.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.rs create mode 100644 src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1717/multiple-renames.rs create mode 100644 src/test/ui/compile-fail-migration/rfc1717/multiple-renames.stderr create mode 100644 src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.rs create mode 100644 src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.stderr create mode 100644 src/test/ui/compile-fail-migration/rmeta-lib-pass.rs create mode 100644 src/test/ui/compile-fail-migration/rmeta-pass.rs create mode 100644 src/test/ui/compile-fail-migration/rmeta-priv-warn.rs create mode 100644 src/test/ui/compile-fail-migration/rmeta.rs create mode 100644 src/test/ui/compile-fail-migration/rmeta.stderr create mode 100644 src/test/ui/compile-fail-migration/rmeta_lib.rs create mode 100644 src/test/ui/compile-fail-migration/rmeta_lib.stderr create mode 100644 src/test/ui/compile-fail-migration/rmeta_meta_main.rs create mode 100644 src/test/ui/compile-fail-migration/rmeta_meta_main.stderr create mode 100644 src/test/ui/compile-fail-migration/rust-unstable-column-gated.rs create mode 100644 src/test/ui/compile-fail-migration/rust-unstable-column-gated.stderr create mode 100644 src/test/ui/compile-fail-migration/rustc-args-required-const.rs create mode 100644 src/test/ui/compile-fail-migration/rustc-args-required-const.stderr create mode 100644 src/test/ui/compile-fail-migration/rustc-args-required-const2.rs create mode 100644 src/test/ui/compile-fail-migration/rustc-args-required-const2.stderr create mode 100644 src/test/ui/compile-fail-migration/rustc-error.rs create mode 100644 src/test/ui/compile-fail-migration/rustc-error.stderr create mode 100644 src/test/ui/compile-fail-migration/safe-extern-statics-mut.rs create mode 100644 src/test/ui/compile-fail-migration/safe-extern-statics-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/safe-extern-statics.rs create mode 100644 src/test/ui/compile-fail-migration/safe-extern-statics.stderr create mode 100644 src/test/ui/compile-fail-migration/self-infer.rs create mode 100644 src/test/ui/compile-fail-migration/self-infer.stderr create mode 100644 src/test/ui/compile-fail-migration/self-vs-path-ambiguity.rs create mode 100644 src/test/ui/compile-fail-migration/self-vs-path-ambiguity.stderr create mode 100644 src/test/ui/compile-fail-migration/self_type_keyword-2.rs create mode 100644 src/test/ui/compile-fail-migration/self_type_keyword-2.stderr create mode 100644 src/test/ui/compile-fail-migration/self_type_keyword.rs create mode 100644 src/test/ui/compile-fail-migration/self_type_keyword.stderr create mode 100644 src/test/ui/compile-fail-migration/seq-args.rs create mode 100644 src/test/ui/compile-fail-migration/seq-args.stderr create mode 100644 src/test/ui/compile-fail-migration/shadowed-trait-methods.rs create mode 100644 src/test/ui/compile-fail-migration/shadowed-trait-methods.stderr create mode 100644 src/test/ui/compile-fail-migration/shadowed-use-visibility.rs create mode 100644 src/test/ui/compile-fail-migration/shadowed-use-visibility.stderr create mode 100644 src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.rs create mode 100644 src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/shift-various-bad-types.rs create mode 100644 src/test/ui/compile-fail-migration/shift-various-bad-types.stderr create mode 100644 src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.rs create mode 100644 src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.rs create mode 100644 src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.rs create mode 100644 src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.rs create mode 100644 src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.stderr create mode 100644 src/test/ui/compile-fail-migration/simd-type.rs create mode 100644 src/test/ui/compile-fail-migration/simd-type.stderr create mode 100644 src/test/ui/compile-fail-migration/single-primitive-inherent-impl.rs create mode 100644 src/test/ui/compile-fail-migration/single-primitive-inherent-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/sized-cycle-note.rs create mode 100644 src/test/ui/compile-fail-migration/sized-cycle-note.stderr create mode 100644 src/test/ui/compile-fail-migration/slice-2.rs create mode 100644 src/test/ui/compile-fail-migration/slice-2.stderr create mode 100644 src/test/ui/compile-fail-migration/slice-mut-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/slice-mut-2.rs create mode 100644 src/test/ui/compile-fail-migration/slice-mut-2.stderr create mode 100644 src/test/ui/compile-fail-migration/slice-mut.rs create mode 100644 src/test/ui/compile-fail-migration/slice-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.rs create mode 100644 src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/README.md create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/issue-52050.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/issue-52050.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-default-projection.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-default-projection.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-default-types.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-default-types.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-no-default.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-no-default.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-overlap.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-overlap.stderr create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-polarity.rs create mode 100644 src/test/ui/compile-fail-migration/specialization/specialization-polarity.stderr create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-issue-43027.rs create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-issue-43027.stderr create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-issue.rs create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-issue.stderr create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.rs create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.stderr create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-non-staged.rs create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-non-staged.stderr create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-sanity-2.rs create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-sanity-2.stderr create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-sanity-3.rs create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-sanity-3.stderr create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-sanity.rs create mode 100644 src/test/ui/compile-fail-migration/stability-attribute-sanity.stderr create mode 100644 src/test/ui/compile-fail-migration/stable-features.rs create mode 100644 src/test/ui/compile-fail-migration/stable-features.stderr create mode 100644 src/test/ui/compile-fail-migration/static-closures.rs create mode 100644 src/test/ui/compile-fail-migration/static-closures.stderr create mode 100644 src/test/ui/compile-fail-migration/static-drop-scope.rs create mode 100644 src/test/ui/compile-fail-migration/static-drop-scope.stderr create mode 100644 src/test/ui/compile-fail-migration/static-items-cant-move.rs create mode 100644 src/test/ui/compile-fail-migration/static-items-cant-move.stderr create mode 100644 src/test/ui/compile-fail-migration/static-lifetime-bound.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/static-lifetime-bound.rs create mode 100644 src/test/ui/compile-fail-migration/static-lifetime-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/static-method-privacy.rs create mode 100644 src/test/ui/compile-fail-migration/static-method-privacy.stderr create mode 100644 src/test/ui/compile-fail-migration/static-mut-bad-types.rs create mode 100644 src/test/ui/compile-fail-migration/static-mut-bad-types.stderr create mode 100644 src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.rs create mode 100644 src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.stderr create mode 100644 src/test/ui/compile-fail-migration/static-mut-not-constant.rs create mode 100644 src/test/ui/compile-fail-migration/static-mut-not-constant.stderr create mode 100644 src/test/ui/compile-fail-migration/static-mut-not-pat.rs create mode 100644 src/test/ui/compile-fail-migration/static-mut-not-pat.stderr create mode 100644 src/test/ui/compile-fail-migration/static-mut-requires-unsafe.rs create mode 100644 src/test/ui/compile-fail-migration/static-mut-requires-unsafe.stderr create mode 100644 src/test/ui/compile-fail-migration/static-priv-by-default.rs create mode 100644 src/test/ui/compile-fail-migration/static-priv-by-default.stderr create mode 100644 src/test/ui/compile-fail-migration/static-priv-by-default2.rs create mode 100644 src/test/ui/compile-fail-migration/static-priv-by-default2.stderr create mode 100644 src/test/ui/compile-fail-migration/static-reference-to-fn-1.rs create mode 100644 src/test/ui/compile-fail-migration/static-reference-to-fn-1.stderr create mode 100644 src/test/ui/compile-fail-migration/static-reference-to-fn-2.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/static-reference-to-fn-2.rs create mode 100644 src/test/ui/compile-fail-migration/static-reference-to-fn-2.stderr create mode 100644 src/test/ui/compile-fail-migration/static-region-bound.rs create mode 100644 src/test/ui/compile-fail-migration/static-region-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.rs create mode 100644 src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.stderr create mode 100644 src/test/ui/compile-fail-migration/staticness-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/staticness-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/std-uncopyable-atomics.rs create mode 100644 src/test/ui/compile-fail-migration/std-uncopyable-atomics.stderr create mode 100644 src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.rs create mode 100644 src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.stderr create mode 100644 src/test/ui/compile-fail-migration/str-idx.rs create mode 100644 src/test/ui/compile-fail-migration/str-idx.stderr create mode 100644 src/test/ui/compile-fail-migration/str-mut-idx.rs create mode 100644 src/test/ui/compile-fail-migration/str-mut-idx.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-base-wrong-type-2.rs create mode 100644 src/test/ui/compile-fail-migration/struct-base-wrong-type-2.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-base-wrong-type.rs create mode 100644 src/test/ui/compile-fail-migration/struct-base-wrong-type.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-field-cfg.rs create mode 100644 src/test/ui/compile-fail-migration/struct-field-cfg.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-field-privacy.rs create mode 100644 src/test/ui/compile-fail-migration/struct-field-privacy.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-fields-dupe.rs create mode 100644 src/test/ui/compile-fail-migration/struct-fields-dupe.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-fields-missing.rs create mode 100644 src/test/ui/compile-fail-migration/struct-fields-missing.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.rs create mode 100644 src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-fields-shorthand.rs create mode 100644 src/test/ui/compile-fail-migration/struct-fields-shorthand.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-fields-typo.rs create mode 100644 src/test/ui/compile-fail-migration/struct-fields-typo.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.rs create mode 100644 src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-pat-derived-error.rs create mode 100644 src/test/ui/compile-fail-migration/struct-pat-derived-error.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-path-alias-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/struct-path-alias-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-path-associated-type.rs create mode 100644 src/test/ui/compile-fail-migration/struct-path-associated-type.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-path-self.rs create mode 100644 src/test/ui/compile-fail-migration/struct-path-self.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-pattern-match-useless.rs create mode 100644 src/test/ui/compile-fail-migration/struct-pattern-match-useless.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-variant-privacy-xc.rs create mode 100644 src/test/ui/compile-fail-migration/struct-variant-privacy-xc.stderr create mode 100644 src/test/ui/compile-fail-migration/struct-variant-privacy.rs create mode 100644 src/test/ui/compile-fail-migration/struct-variant-privacy.stderr create mode 100644 src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/substs-ppaux.normal.stderr create mode 100644 src/test/ui/compile-fail-migration/substs-ppaux.rs create mode 100644 src/test/ui/compile-fail-migration/substs-ppaux.verbose.stderr create mode 100644 src/test/ui/compile-fail-migration/suffixed-literal-meta.rs create mode 100644 src/test/ui/compile-fail-migration/suffixed-literal-meta.stderr create mode 100644 src/test/ui/compile-fail-migration/super-at-top-level.rs create mode 100644 src/test/ui/compile-fail-migration/super-at-top-level.stderr create mode 100644 src/test/ui/compile-fail-migration/suppressed-error.rs create mode 100644 src/test/ui/compile-fail-migration/suppressed-error.stderr create mode 100644 src/test/ui/compile-fail-migration/symbol-names/basic.rs create mode 100644 src/test/ui/compile-fail-migration/symbol-names/basic.stderr create mode 100644 src/test/ui/compile-fail-migration/symbol-names/impl1.rs create mode 100644 src/test/ui/compile-fail-migration/symbol-names/impl1.stderr create mode 100644 src/test/ui/compile-fail-migration/syntax-extension-minor.rs create mode 100644 src/test/ui/compile-fail-migration/syntax-extension-minor.stderr create mode 100644 src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.rs create mode 100644 src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.stderr create mode 100644 src/test/ui/compile-fail-migration/syntax-trait-polarity.rs create mode 100644 src/test/ui/compile-fail-migration/syntax-trait-polarity.stderr create mode 100644 src/test/ui/compile-fail-migration/synthetic-param.rs create mode 100644 src/test/ui/compile-fail-migration/synthetic-param.stderr create mode 100644 src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.rs create mode 100644 src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.stderr create mode 100644 src/test/ui/compile-fail-migration/tag-type-args.rs create mode 100644 src/test/ui/compile-fail-migration/tag-type-args.stderr create mode 100644 src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.rs create mode 100644 src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.stderr create mode 100644 src/test/ui/compile-fail-migration/tag-variant-disr-dup.rs create mode 100644 src/test/ui/compile-fail-migration/tag-variant-disr-dup.stderr create mode 100644 src/test/ui/compile-fail-migration/tail-typeck.rs create mode 100644 src/test/ui/compile-fail-migration/tail-typeck.stderr create mode 100644 src/test/ui/compile-fail-migration/terr-in-field.rs create mode 100644 src/test/ui/compile-fail-migration/terr-in-field.stderr create mode 100644 src/test/ui/compile-fail-migration/terr-sorts.rs create mode 100644 src/test/ui/compile-fail-migration/terr-sorts.stderr create mode 100644 src/test/ui/compile-fail-migration/test-cfg.rs create mode 100644 src/test/ui/compile-fail-migration/test-cfg.stderr create mode 100644 src/test/ui/compile-fail-migration/test-warns-dead-code.rs create mode 100644 src/test/ui/compile-fail-migration/test-warns-dead-code.stderr create mode 100644 src/test/ui/compile-fail-migration/thread-local-in-ctfe.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/thread-local-in-ctfe.rs create mode 100644 src/test/ui/compile-fail-migration/thread-local-in-ctfe.stderr create mode 100644 src/test/ui/compile-fail-migration/tool_lints.rs create mode 100644 src/test/ui/compile-fail-migration/tool_lints.stderr create mode 100644 src/test/ui/compile-fail-migration/trace_macros-format.rs create mode 100644 src/test/ui/compile-fail-migration/trace_macros-format.stderr create mode 100644 src/test/ui/compile-fail-migration/trace_macros-gate.rs create mode 100644 src/test/ui/compile-fail-migration/trace_macros-gate.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-alias.rs create mode 100644 src/test/ui/compile-fail-migration/trait-alias.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-as-struct-constructor.rs create mode 100644 src/test/ui/compile-fail-migration/trait-as-struct-constructor.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-not-on-bare-trait.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-not-on-bare-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-sugar.rs create mode 100644 src/test/ui/compile-fail-migration/trait-bounds-sugar.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-coercion-generic-bad.rs create mode 100644 src/test/ui/compile-fail-migration/trait-coercion-generic-bad.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-coercion-generic-regions.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-coercion-generic-regions.rs create mode 100644 src/test/ui/compile-fail-migration/trait-coercion-generic-regions.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-impl-1.rs create mode 100644 src/test/ui/compile-fail-migration/trait-impl-1.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-impl-can-not-have-untraitful-items.rs create mode 100644 src/test/ui/compile-fail-migration/trait-impl-can-not-have-untraitful-items.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-impl-different-num-params.rs create mode 100644 src/test/ui/compile-fail-migration/trait-impl-different-num-params.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-impl-for-module.rs create mode 100644 src/test/ui/compile-fail-migration/trait-impl-for-module.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-impl-method-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/trait-impl-method-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs create mode 100644 src/test/ui/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-item-privacy.rs create mode 100644 src/test/ui/compile-fail-migration/trait-item-privacy.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-matching-lifetimes.rs create mode 100644 src/test/ui/compile-fail-migration/trait-matching-lifetimes.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-object-macro-matcher.rs create mode 100644 src/test/ui/compile-fail-migration/trait-object-macro-matcher.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-object-safety.rs create mode 100644 src/test/ui/compile-fail-migration/trait-object-safety.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.rs create mode 100644 src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-object-vs-lifetime.rs create mode 100644 src/test/ui/compile-fail-migration/trait-object-vs-lifetime.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-or-new-type-instead.rs create mode 100644 src/test/ui/compile-fail-migration/trait-or-new-type-instead.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-privacy.rs create mode 100644 src/test/ui/compile-fail-migration/trait-privacy.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.rs create mode 100644 src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-safety-inherent-impl.rs create mode 100644 src/test/ui/compile-fail-migration/trait-safety-inherent-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-safety-trait-impl-cc.rs create mode 100644 src/test/ui/compile-fail-migration/trait-safety-trait-impl-cc.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-safety-trait-impl.rs create mode 100644 src/test/ui/compile-fail-migration/trait-safety-trait-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-static-method-generic-inference.rs create mode 100644 src/test/ui/compile-fail-migration/trait-static-method-generic-inference.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-test-2.rs create mode 100644 src/test/ui/compile-fail-migration/trait-test-2.stderr create mode 100644 src/test/ui/compile-fail-migration/trait-test.rs create mode 100644 src/test/ui/compile-fail-migration/trait-test.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-assoc-type-in-supertrait-bad.rs create mode 100644 src/test/ui/compile-fail-migration/traits-assoc-type-in-supertrait-bad.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.rs create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.rs create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait.rs create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.rs create mode 100644 src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-issue-23003-overflow.rs create mode 100644 src/test/ui/compile-fail-migration/traits-issue-23003-overflow.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-multidispatch-bad.rs create mode 100644 src/test/ui/compile-fail-migration/traits-multidispatch-bad.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-negative-impls.rs create mode 100644 src/test/ui/compile-fail-migration/traits-negative-impls.stderr create mode 100644 src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.rs create mode 100644 src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.stderr create mode 100644 src/test/ui/compile-fail-migration/transmute-different-sizes.rs create mode 100644 src/test/ui/compile-fail-migration/transmute-different-sizes.stderr create mode 100644 src/test/ui/compile-fail-migration/transmute-fat-pointers.rs create mode 100644 src/test/ui/compile-fail-migration/transmute-fat-pointers.stderr create mode 100644 src/test/ui/compile-fail-migration/transmute-impl.rs create mode 100644 src/test/ui/compile-fail-migration/transmute-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/transmute-imut-to-mut.rs create mode 100644 src/test/ui/compile-fail-migration/transmute-imut-to-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/trivial_casts.rs create mode 100644 src/test/ui/compile-fail-migration/trivial_casts.stderr create mode 100644 src/test/ui/compile-fail-migration/tuple-arity-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/tuple-arity-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/tuple-index-not-tuple.rs create mode 100644 src/test/ui/compile-fail-migration/tuple-index-not-tuple.stderr create mode 100644 src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.rs create mode 100644 src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.stderr create mode 100644 src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.rs create mode 100644 src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.stderr create mode 100644 src/test/ui/compile-fail-migration/type-arg-out-of-scope.rs create mode 100644 src/test/ui/compile-fail-migration/type-arg-out-of-scope.stderr create mode 100644 src/test/ui/compile-fail-migration/type-ascription-precedence.rs create mode 100644 src/test/ui/compile-fail-migration/type-ascription-precedence.stderr create mode 100644 src/test/ui/compile-fail-migration/type-ascription-soundness.rs create mode 100644 src/test/ui/compile-fail-migration/type-ascription-soundness.stderr create mode 100644 src/test/ui/compile-fail-migration/type-mismatch-multiple.rs create mode 100644 src/test/ui/compile-fail-migration/type-mismatch-multiple.stderr create mode 100644 src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.rs create mode 100644 src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.stderr create mode 100644 src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.rs create mode 100644 src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.stderr create mode 100644 src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.rs create mode 100644 src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.stderr create mode 100644 src/test/ui/compile-fail-migration/type-parameter-names.rs create mode 100644 src/test/ui/compile-fail-migration/type-parameter-names.stderr create mode 100644 src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.rs create mode 100644 src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.stderr create mode 100644 src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.rs create mode 100644 src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.stderr create mode 100644 src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.rs create mode 100644 src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.stderr create mode 100644 src/test/ui/compile-fail-migration/type-path-err-node-types.rs create mode 100644 src/test/ui/compile-fail-migration/type-path-err-node-types.stderr create mode 100644 src/test/ui/compile-fail-migration/type-shadow.rs create mode 100644 src/test/ui/compile-fail-migration/type-shadow.stderr create mode 100644 src/test/ui/compile-fail-migration/type_length_limit.rs create mode 100644 src/test/ui/compile-fail-migration/type_length_limit.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits-2.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits-2.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck-unsafe-always-share.rs create mode 100644 src/test/ui/compile-fail-migration/typeck-unsafe-always-share.stderr create mode 100644 src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.rs create mode 100644 src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.stderr create mode 100644 src/test/ui/compile-fail-migration/ufcs-partially-resolved.rs create mode 100644 src/test/ui/compile-fail-migration/ufcs-partially-resolved.stderr create mode 100644 src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.rs create mode 100644 src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.stderr create mode 100644 src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-region.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-region.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.stderr create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.rs create mode 100644 src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.stderr create mode 100644 src/test/ui/compile-fail-migration/underscore-lifetime-binders.rs create mode 100644 src/test/ui/compile-fail-migration/underscore-lifetime-binders.stderr create mode 100644 src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/uninhabited-enum-cast.rs create mode 100644 src/test/ui/compile-fail-migration/uninhabited-enum-cast.stderr create mode 100644 src/test/ui/compile-fail-migration/uninhabited-irrefutable.rs create mode 100644 src/test/ui/compile-fail-migration/uninhabited-irrefutable.stderr create mode 100644 src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.rs create mode 100644 src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.stderr create mode 100644 src/test/ui/compile-fail-migration/uninhabited-patterns.rs create mode 100644 src/test/ui/compile-fail-migration/uninhabited-patterns.stderr create mode 100644 src/test/ui/compile-fail-migration/union-ub-fat-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/union-ub-fat-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-const-pat.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-const-pat.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-copy.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-copy.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-derive-clone.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-derive-clone.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-derive.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-derive.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-empty.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-empty.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-generic.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-generic.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-lint-dead-code.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-lint-dead-code.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-nonrepresentable.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-nonrepresentable.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-repr-c.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-repr-c.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-unsafe.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-unsafe.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-unsized.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-unsized.stderr create mode 100644 src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.rs create mode 100644 src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.stderr create mode 100644 src/test/ui/compile-fail-migration/unique-object-noncopyable.rs create mode 100644 src/test/ui/compile-fail-migration/unique-object-noncopyable.stderr create mode 100644 src/test/ui/compile-fail-migration/unique-pinned-nocopy.rs create mode 100644 src/test/ui/compile-fail-migration/unique-pinned-nocopy.stderr create mode 100644 src/test/ui/compile-fail-migration/unknown-lint-tool-name.rs create mode 100644 src/test/ui/compile-fail-migration/unknown-lint-tool-name.stderr create mode 100644 src/test/ui/compile-fail-migration/unknown-tool-name.rs create mode 100644 src/test/ui/compile-fail-migration/unknown-tool-name.stderr create mode 100644 src/test/ui/compile-fail-migration/unop-move-semantics.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/unop-move-semantics.rs create mode 100644 src/test/ui/compile-fail-migration/unop-move-semantics.stderr create mode 100644 src/test/ui/compile-fail-migration/unop-neg-bool.rs create mode 100644 src/test/ui/compile-fail-migration/unop-neg-bool.stderr create mode 100644 src/test/ui/compile-fail-migration/unreachable-arm.rs create mode 100644 src/test/ui/compile-fail-migration/unreachable-arm.stderr create mode 100644 src/test/ui/compile-fail-migration/unreachable-code.rs create mode 100644 src/test/ui/compile-fail-migration/unreachable-code.stderr create mode 100644 src/test/ui/compile-fail-migration/unreachable-in-call.rs create mode 100644 src/test/ui/compile-fail-migration/unreachable-in-call.stderr create mode 100644 src/test/ui/compile-fail-migration/unreachable-loop-patterns.rs create mode 100644 src/test/ui/compile-fail-migration/unreachable-loop-patterns.stderr create mode 100644 src/test/ui/compile-fail-migration/unreachable-try-pattern.rs create mode 100644 src/test/ui/compile-fail-migration/unreachable-try-pattern.stderr create mode 100644 src/test/ui/compile-fail-migration/unreachable-variant.rs create mode 100644 src/test/ui/compile-fail-migration/unreachable-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.rs create mode 100644 src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.stderr create mode 100644 src/test/ui/compile-fail-migration/unresolved-import-recovery.rs create mode 100644 src/test/ui/compile-fail-migration/unresolved-import-recovery.stderr create mode 100644 src/test/ui/compile-fail-migration/unresolved-import.rs create mode 100644 src/test/ui/compile-fail-migration/unresolved-import.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-autoderef.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-autoderef.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-used-as-value.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-fn-used-as-value.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-move-val-init.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-move-val-init.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-subtyping.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-subtyping.stderr create mode 100644 src/test/ui/compile-fail-migration/unsafe-trait-impl.rs create mode 100644 src/test/ui/compile-fail-migration/unsafe-trait-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized-bare-typaram.rs create mode 100644 src/test/ui/compile-fail-migration/unsized-bare-typaram.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized-enum.rs create mode 100644 src/test/ui/compile-fail-migration/unsized-enum.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.rs create mode 100644 src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized-struct.rs create mode 100644 src/test/ui/compile-fail-migration/unsized-struct.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.rs create mode 100644 src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.rs create mode 100644 src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized3.rs create mode 100644 src/test/ui/compile-fail-migration/unsized3.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized5.rs create mode 100644 src/test/ui/compile-fail-migration/unsized5.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized6.rs create mode 100644 src/test/ui/compile-fail-migration/unsized6.stderr create mode 100644 src/test/ui/compile-fail-migration/unsized7.rs create mode 100644 src/test/ui/compile-fail-migration/unsized7.stderr create mode 100644 src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.rs create mode 100644 src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.stderr create mode 100644 src/test/ui/compile-fail-migration/unsupported-cast.rs create mode 100644 src/test/ui/compile-fail-migration/unsupported-cast.stderr create mode 100644 src/test/ui/compile-fail-migration/unused-attr.rs create mode 100644 src/test/ui/compile-fail-migration/unused-attr.stderr create mode 100644 src/test/ui/compile-fail-migration/unused-macro-rules.rs create mode 100644 src/test/ui/compile-fail-migration/unused-macro-rules.stderr create mode 100644 src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.rs create mode 100644 src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.stderr create mode 100644 src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.rs create mode 100644 src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.stderr create mode 100644 src/test/ui/compile-fail-migration/unused-macro.rs create mode 100644 src/test/ui/compile-fail-migration/unused-macro.stderr create mode 100644 src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.rs create mode 100644 src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.stderr create mode 100644 src/test/ui/compile-fail-migration/unused-result.rs create mode 100644 src/test/ui/compile-fail-migration/unused-result.stderr create mode 100644 src/test/ui/compile-fail-migration/use-after-move-based-on-type.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/use-after-move-based-on-type.rs create mode 100644 src/test/ui/compile-fail-migration/use-after-move-based-on-type.stderr create mode 100644 src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.rs create mode 100644 src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.stderr create mode 100644 src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.rs create mode 100644 src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.stderr create mode 100644 src/test/ui/compile-fail-migration/use-after-move-self.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/use-after-move-self.rs create mode 100644 src/test/ui/compile-fail-migration/use-after-move-self.stderr create mode 100644 src/test/ui/compile-fail-migration/use-from-trait-xc.rs create mode 100644 src/test/ui/compile-fail-migration/use-from-trait-xc.stderr create mode 100644 src/test/ui/compile-fail-migration/use-from-trait.rs create mode 100644 src/test/ui/compile-fail-migration/use-from-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/use-keyword.rs create mode 100644 src/test/ui/compile-fail-migration/use-keyword.stderr create mode 100644 src/test/ui/compile-fail-migration/use-meta-mismatch.rs create mode 100644 src/test/ui/compile-fail-migration/use-meta-mismatch.stderr create mode 100644 src/test/ui/compile-fail-migration/use-mod-2.rs create mode 100644 src/test/ui/compile-fail-migration/use-mod-2.stderr create mode 100644 src/test/ui/compile-fail-migration/use-mod-3.rs create mode 100644 src/test/ui/compile-fail-migration/use-mod-3.stderr create mode 100644 src/test/ui/compile-fail-migration/use-mod-4.rs create mode 100644 src/test/ui/compile-fail-migration/use-mod-4.stderr create mode 100644 src/test/ui/compile-fail-migration/use-paths-as-items.rs create mode 100644 src/test/ui/compile-fail-migration/use-paths-as-items.stderr create mode 100644 src/test/ui/compile-fail-migration/use-self-type.rs create mode 100644 src/test/ui/compile-fail-migration/use-self-type.stderr create mode 100644 src/test/ui/compile-fail-migration/use-super-global-path.rs create mode 100644 src/test/ui/compile-fail-migration/use-super-global-path.stderr create mode 100644 src/test/ui/compile-fail-migration/used.rs create mode 100644 src/test/ui/compile-fail-migration/used.stderr create mode 100644 src/test/ui/compile-fail-migration/useless-pub.rs create mode 100644 src/test/ui/compile-fail-migration/useless-pub.stderr create mode 100644 src/test/ui/compile-fail-migration/useless_comment.rs create mode 100644 src/test/ui/compile-fail-migration/useless_comment.stderr create mode 100644 src/test/ui/compile-fail-migration/user-defined-macro-rules.rs create mode 100644 src/test/ui/compile-fail-migration/user-defined-macro-rules.stderr create mode 100644 src/test/ui/compile-fail-migration/utf8_idents.rs create mode 100644 src/test/ui/compile-fail-migration/utf8_idents.stderr create mode 100644 src/test/ui/compile-fail-migration/variadic-ffi-2.rs create mode 100644 src/test/ui/compile-fail-migration/variadic-ffi-2.stderr create mode 100644 src/test/ui/compile-fail-migration/variadic-ffi.rs create mode 100644 src/test/ui/compile-fail-migration/variadic-ffi.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-associated-types.rs create mode 100644 src/test/ui/compile-fail-migration/variance-associated-types.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-btree-invariant-types.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-btree-invariant-types.rs create mode 100644 src/test/ui/compile-fail-migration/variance-btree-invariant-types.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-cell-is-invariant.rs create mode 100644 src/test/ui/compile-fail-migration/variance-cell-is-invariant.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-contravariant-arg-object.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-contravariant-arg-object.rs create mode 100644 src/test/ui/compile-fail-migration/variance-contravariant-arg-object.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.rs create mode 100644 src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.rs create mode 100644 src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-covariant-arg-object.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-covariant-arg-object.rs create mode 100644 src/test/ui/compile-fail-migration/variance-covariant-arg-object.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.rs create mode 100644 src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.rs create mode 100644 src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-invariant-arg-object.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-invariant-arg-object.rs create mode 100644 src/test/ui/compile-fail-migration/variance-invariant-arg-object.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.rs create mode 100644 src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.rs create mode 100644 src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-issue-20533.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-issue-20533.rs create mode 100644 src/test/ui/compile-fail-migration/variance-issue-20533.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-object-types.rs create mode 100644 src/test/ui/compile-fail-migration/variance-object-types.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-regions-direct.rs create mode 100644 src/test/ui/compile-fail-migration/variance-regions-direct.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-regions-indirect.rs create mode 100644 src/test/ui/compile-fail-migration/variance-regions-indirect.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-regions-unused-direct.rs create mode 100644 src/test/ui/compile-fail-migration/variance-regions-unused-direct.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-regions-unused-indirect.rs create mode 100644 src/test/ui/compile-fail-migration/variance-regions-unused-indirect.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-trait-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/variance-trait-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-trait-matching.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-trait-matching.rs create mode 100644 src/test/ui/compile-fail-migration/variance-trait-matching.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-trait-object-bound.rs create mode 100644 src/test/ui/compile-fail-migration/variance-trait-object-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-types-bounds.rs create mode 100644 src/test/ui/compile-fail-migration/variance-types-bounds.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-types.rs create mode 100644 src/test/ui/compile-fail-migration/variance-types.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-unused-region-param.rs create mode 100644 src/test/ui/compile-fail-migration/variance-unused-region-param.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.rs create mode 100644 src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.rs create mode 100644 src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.rs create mode 100644 src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.rs create mode 100644 src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.rs create mode 100644 src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.stderr create mode 100644 src/test/ui/compile-fail-migration/variant-namespacing.rs create mode 100644 src/test/ui/compile-fail-migration/variant-namespacing.stderr create mode 100644 src/test/ui/compile-fail-migration/variant-size-differences.rs create mode 100644 src/test/ui/compile-fail-migration/variant-size-differences.stderr create mode 100644 src/test/ui/compile-fail-migration/variant-used-as-type.rs create mode 100644 src/test/ui/compile-fail-migration/variant-used-as-type.stderr create mode 100644 src/test/ui/compile-fail-migration/vec-macro-with-comma-only.rs create mode 100644 src/test/ui/compile-fail-migration/vec-macro-with-comma-only.stderr create mode 100644 src/test/ui/compile-fail-migration/vec-mut-iter-borrow.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/vec-mut-iter-borrow.rs create mode 100644 src/test/ui/compile-fail-migration/vec-mut-iter-borrow.stderr create mode 100644 src/test/ui/compile-fail-migration/vec-res-add.rs create mode 100644 src/test/ui/compile-fail-migration/vec-res-add.stderr create mode 100644 src/test/ui/compile-fail-migration/vector-cast-weirdness.rs create mode 100644 src/test/ui/compile-fail-migration/vector-cast-weirdness.stderr create mode 100644 src/test/ui/compile-fail-migration/vtable-res-trait-param.rs create mode 100644 src/test/ui/compile-fail-migration/vtable-res-trait-param.stderr create mode 100644 src/test/ui/compile-fail-migration/walk-struct-literal-with.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/walk-struct-literal-with.rs create mode 100644 src/test/ui/compile-fail-migration/walk-struct-literal-with.stderr create mode 100644 src/test/ui/compile-fail-migration/warn-path-statement.rs create mode 100644 src/test/ui/compile-fail-migration/warn-path-statement.stderr create mode 100644 src/test/ui/compile-fail-migration/weak-lang-item.rs create mode 100644 src/test/ui/compile-fail-migration/weak-lang-item.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-array-elem-sized.rs create mode 100644 src/test/ui/compile-fail-migration/wf-array-elem-sized.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-const-type.rs create mode 100644 src/test/ui/compile-fail-migration/wf-const-type.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-enum-bound.rs create mode 100644 src/test/ui/compile-fail-migration/wf-enum-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.rs create mode 100644 src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-enum-fields.rs create mode 100644 src/test/ui/compile-fail-migration/wf-enum-fields.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-fn-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/wf-fn-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-impl-associated-type-region.rs create mode 100644 src/test/ui/compile-fail-migration/wf-impl-associated-type-region.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.rs create mode 100644 src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-arg.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-ret.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-type-arg.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-type-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-type-ret.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-type-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-type-static.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-type-static.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-fn-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-obj-type-static.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-obj-type-static.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-in-obj-type-trait.rs create mode 100644 src/test/ui/compile-fail-migration/wf-in-obj-type-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.rs create mode 100644 src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-object-safe.rs create mode 100644 src/test/ui/compile-fail-migration/wf-object-safe.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.rs create mode 100644 src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-static-method.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-static-method.rs create mode 100644 src/test/ui/compile-fail-migration/wf-static-method.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-static-type.rs create mode 100644 src/test/ui/compile-fail-migration/wf-static-type.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-struct-bound.rs create mode 100644 src/test/ui/compile-fail-migration/wf-struct-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-struct-field.rs create mode 100644 src/test/ui/compile-fail-migration/wf-struct-field.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-associated-type-region.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-associated-type-region.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-bound.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-bound.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-fn-arg.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-fn-arg.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-fn-ret.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-fn-ret.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.stderr create mode 100644 src/test/ui/compile-fail-migration/wf-trait-superbound.rs create mode 100644 src/test/ui/compile-fail-migration/wf-trait-superbound.stderr create mode 100644 src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.rs create mode 100644 src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.rs create mode 100644 src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.stderr create mode 100644 src/test/ui/compile-fail-migration/where-clause-method-substituion.rs create mode 100644 src/test/ui/compile-fail-migration/where-clause-method-substituion.stderr create mode 100644 src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.rs create mode 100644 src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.stderr create mode 100644 src/test/ui/compile-fail-migration/where-clauses-unsatisfied.rs create mode 100644 src/test/ui/compile-fail-migration/where-clauses-unsatisfied.stderr create mode 100644 src/test/ui/compile-fail-migration/where-equality-constraints.rs create mode 100644 src/test/ui/compile-fail-migration/where-equality-constraints.stderr create mode 100644 src/test/ui/compile-fail-migration/where-for-self-2.rs create mode 100644 src/test/ui/compile-fail-migration/where-for-self-2.stderr create mode 100644 src/test/ui/compile-fail-migration/where-for-self.rs create mode 100644 src/test/ui/compile-fail-migration/where-for-self.stderr create mode 100644 src/test/ui/compile-fail-migration/where-lifetime-resolution.rs create mode 100644 src/test/ui/compile-fail-migration/where-lifetime-resolution.stderr create mode 100644 src/test/ui/compile-fail-migration/while-let.rs create mode 100644 src/test/ui/compile-fail-migration/while-let.stderr create mode 100644 src/test/ui/compile-fail-migration/while-type-error.rs create mode 100644 src/test/ui/compile-fail-migration/while-type-error.stderr create mode 100644 src/test/ui/compile-fail-migration/windows-subsystem-invalid.rs create mode 100644 src/test/ui/compile-fail-migration/windows-subsystem-invalid.stderr create mode 100644 src/test/ui/compile-fail-migration/write-to-static-mut-in-static.rs create mode 100644 src/test/ui/compile-fail-migration/write-to-static-mut-in-static.stderr create mode 100644 src/test/ui/compile-fail-migration/writing-to-immutable-vec.nll.stderr create mode 100644 src/test/ui/compile-fail-migration/writing-to-immutable-vec.rs create mode 100644 src/test/ui/compile-fail-migration/writing-to-immutable-vec.stderr create mode 100644 src/test/ui/compile-fail-migration/wrong-mul-method-signature.rs create mode 100644 src/test/ui/compile-fail-migration/wrong-mul-method-signature.stderr create mode 100644 src/test/ui/compile-fail-migration/wrong-ret-type.rs create mode 100644 src/test/ui/compile-fail-migration/wrong-ret-type.stderr create mode 100644 src/test/ui/compile-fail-migration/xc-private-method.rs create mode 100644 src/test/ui/compile-fail-migration/xc-private-method.stderr create mode 100644 src/test/ui/compile-fail-migration/xc-private-method2.rs create mode 100644 src/test/ui/compile-fail-migration/xc-private-method2.stderr create mode 100644 src/test/ui/compile-fail-migration/xcrate-private-by-default.rs create mode 100644 src/test/ui/compile-fail-migration/xcrate-private-by-default.stderr create mode 100644 src/test/ui/compile-fail-migration/xcrate-unit-struct.rs create mode 100644 src/test/ui/compile-fail-migration/xcrate-unit-struct.stderr (limited to 'src') diff --git a/src/test/compile-fail/.gitattributes b/src/test/compile-fail/.gitattributes deleted file mode 100644 index 825f664bf9f..00000000000 --- a/src/test/compile-fail/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -trailing-carriage-return-in-string.rs -text \ No newline at end of file diff --git a/src/test/compile-fail/E0501.rs b/src/test/compile-fail/E0501.rs deleted file mode 100644 index 5643e1ef091..00000000000 --- a/src/test/compile-fail/E0501.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn inside_closure(x: &mut i32) { -} - -fn outside_closure_1(x: &mut i32) { -} - -fn outside_closure_2(x: &i32) { -} - -fn foo(a: &mut i32) { - let bar = || { - inside_closure(a) - }; - outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - //[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - - outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access - //[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access - - drop(bar); -} - -fn main() { -} diff --git a/src/test/compile-fail/E0506.rs b/src/test/compile-fail/E0506.rs deleted file mode 100644 index c4a7f257394..00000000000 --- a/src/test/compile-fail/E0506.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -struct FancyNum { - num: u8, -} - -fn main() { - let mut fancy_num = FancyNum { num: 5 }; - let fancy_ref = &fancy_num; - fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 - //[mir]~^ ERROR [E0506] - - println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); -} diff --git a/src/test/compile-fail/E0508.rs b/src/test/compile-fail/E0508.rs deleted file mode 100644 index 0c3dce6b034..00000000000 --- a/src/test/compile-fail/E0508.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -struct NonCopy; - -fn main() { - let array = [NonCopy; 1]; - let _value = array[0]; //[ast]~ ERROR [E0508] - //[mir]~^ ERROR [E0508] -} diff --git a/src/test/compile-fail/E0583.rs b/src/test/compile-fail/E0583.rs deleted file mode 100644 index 3a5255d0f5f..00000000000 --- a/src/test/compile-fail/E0583.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod module_that_doesnt_exist; //~ ERROR E0583 - -fn main() { -} diff --git a/src/test/compile-fail/E0594.rs b/src/test/compile-fail/E0594.rs deleted file mode 100644 index e5e96451d13..00000000000 --- a/src/test/compile-fail/E0594.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -static NUM: i32 = 18; - -fn main() { - NUM = 20; //[ast]~ ERROR E0594 - //[mir]~^ ERROR cannot assign to immutable static item `NUM` -} diff --git a/src/test/compile-fail/E0596.rs b/src/test/compile-fail/E0596.rs deleted file mode 100644 index 52bdff55d86..00000000000 --- a/src/test/compile-fail/E0596.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn main() { - let x = 1; - let y = &mut x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] -} diff --git a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs deleted file mode 100644 index fe052f2f47f..00000000000 --- a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_imports)] - -mod foo {} - -use foo::{ - ::bar, //~ ERROR crate root in paths can only be used in start position - super::bar, //~ ERROR `super` in paths can only be used in start position - self::bar, //~ ERROR `self` in paths can only be used in start position -}; - -fn main() {} diff --git a/src/test/compile-fail/access-mode-in-closures.rs b/src/test/compile-fail/access-mode-in-closures.rs deleted file mode 100644 index bad192fc2cf..00000000000 --- a/src/test/compile-fail/access-mode-in-closures.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct sty(Vec ); - -fn unpack(_unpack: F) where F: FnOnce(&sty) -> Vec {} - -fn main() { - let _foo = unpack(|s| { - // Test that `s` is moved here. - match *s { sty(v) => v } //~ ERROR cannot move out - }); -} diff --git a/src/test/compile-fail/alloc-error-handler-bad-signature-1.rs b/src/test/compile-fail/alloc-error-handler-bad-signature-1.rs deleted file mode 100644 index e398f16a065..00000000000 --- a/src/test/compile-fail/alloc-error-handler-bad-signature-1.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(alloc_error_handler, panic_implementation)] -#![no_std] -#![no_main] - -use core::alloc::Layout; - -#[alloc_error_handler] -fn oom( - info: &Layout, //~ ERROR argument should be `Layout` -) -> () //~ ERROR return type should be `!` -{ - loop {} -} - -#[panic_implementation] -fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/compile-fail/alloc-error-handler-bad-signature-2.rs b/src/test/compile-fail/alloc-error-handler-bad-signature-2.rs deleted file mode 100644 index 4fee9d27e51..00000000000 --- a/src/test/compile-fail/alloc-error-handler-bad-signature-2.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(alloc_error_handler, panic_implementation)] -#![no_std] -#![no_main] - -struct Layout; - -#[alloc_error_handler] -fn oom( - info: Layout, //~ ERROR argument should be `Layout` -) { //~ ERROR return type should be `!` - loop {} -} - -#[panic_implementation] -fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/compile-fail/alloc-error-handler-bad-signature-3.rs b/src/test/compile-fail/alloc-error-handler-bad-signature-3.rs deleted file mode 100644 index 828a78055d5..00000000000 --- a/src/test/compile-fail/alloc-error-handler-bad-signature-3.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(alloc_error_handler, panic_implementation)] -#![no_std] -#![no_main] - -struct Layout; - -#[alloc_error_handler] -fn oom() -> ! { //~ ERROR function should have one argument - loop {} -} - -#[panic_implementation] -fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/compile-fail/allocator/auxiliary/system-allocator.rs b/src/test/compile-fail/allocator/auxiliary/system-allocator.rs deleted file mode 100644 index e5650d5b7b0..00000000000 --- a/src/test/compile-fail/allocator/auxiliary/system-allocator.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -use std::alloc::System; - -#[global_allocator] -static A: System = System; diff --git a/src/test/compile-fail/allocator/auxiliary/system-allocator2.rs b/src/test/compile-fail/allocator/auxiliary/system-allocator2.rs deleted file mode 100644 index e5650d5b7b0..00000000000 --- a/src/test/compile-fail/allocator/auxiliary/system-allocator2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -use std::alloc::System; - -#[global_allocator] -static A: System = System; diff --git a/src/test/compile-fail/allocator/function-allocator.rs b/src/test/compile-fail/allocator/function-allocator.rs deleted file mode 100644 index 989c102b86e..00000000000 --- a/src/test/compile-fail/allocator/function-allocator.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#[global_allocator] -fn foo() {} //~ ERROR: allocators must be statics - -fn main() {} diff --git a/src/test/compile-fail/allocator/not-an-allocator.rs b/src/test/compile-fail/allocator/not-an-allocator.rs deleted file mode 100644 index 6559335960a..00000000000 --- a/src/test/compile-fail/allocator/not-an-allocator.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[global_allocator] -static A: usize = 0; -//~^ the trait bound `usize: -//~| the trait bound `usize: -//~| the trait bound `usize: -//~| the trait bound `usize: - -fn main() {} diff --git a/src/test/compile-fail/allocator/two-allocators.rs b/src/test/compile-fail/allocator/two-allocators.rs deleted file mode 100644 index 7a97a11df20..00000000000 --- a/src/test/compile-fail/allocator/two-allocators.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::alloc::System; - -#[global_allocator] -static A: System = System; -#[global_allocator] -static B: System = System; -//~^ ERROR: cannot define more than one #[global_allocator] - -fn main() {} - diff --git a/src/test/compile-fail/allocator/two-allocators2.rs b/src/test/compile-fail/allocator/two-allocators2.rs deleted file mode 100644 index e747140dfe5..00000000000 --- a/src/test/compile-fail/allocator/two-allocators2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:system-allocator.rs -// no-prefer-dynamic -// error-pattern: the #[global_allocator] in - -extern crate system_allocator; - -use std::alloc::System; - -#[global_allocator] -static A: System = System; - -fn main() {} - diff --git a/src/test/compile-fail/allocator/two-allocators3.rs b/src/test/compile-fail/allocator/two-allocators3.rs deleted file mode 100644 index dd86b02bd20..00000000000 --- a/src/test/compile-fail/allocator/two-allocators3.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:system-allocator.rs -// aux-build:system-allocator2.rs -// no-prefer-dynamic -// error-pattern: the #[global_allocator] in - - -extern crate system_allocator; -extern crate system_allocator2; - -fn main() {} diff --git a/src/test/compile-fail/anon-params-deprecated.rs b/src/test/compile-fail/anon-params-deprecated.rs deleted file mode 100644 index 4d37ba920f3..00000000000 --- a/src/test/compile-fail/anon-params-deprecated.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![forbid(anonymous_parameters)] -// Test for the anonymous_parameters deprecation lint (RFC 1685) - -trait T { - fn foo(i32); //~ ERROR anonymous parameters are deprecated - //~| WARNING hard error - - fn bar_with_default_impl(String, String) {} - //~^ ERROR anonymous parameters are deprecated - //~| WARNING hard error - //~| ERROR anonymous parameters are deprecated - //~| WARNING hard error -} - -fn main() {} diff --git a/src/test/compile-fail/arg-count-mismatch.rs b/src/test/compile-fail/arg-count-mismatch.rs deleted file mode 100644 index 673314ec4c9..00000000000 --- a/src/test/compile-fail/arg-count-mismatch.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: parameters were supplied - -fn f(x: isize) { } - -fn main() { let i: (); i = f(); } diff --git a/src/test/compile-fail/arg-type-mismatch.rs b/src/test/compile-fail/arg-type-mismatch.rs deleted file mode 100644 index 1f657ca5832..00000000000 --- a/src/test/compile-fail/arg-type-mismatch.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern: mismatched types - -fn f(x: isize) { } - -fn main() { let i: (); i = f(()); } diff --git a/src/test/compile-fail/array-not-vector.rs b/src/test/compile-fail/array-not-vector.rs deleted file mode 100644 index 47e1c09f380..00000000000 --- a/src/test/compile-fail/array-not-vector.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let _x: i32 = [1, 2, 3]; - //~^ ERROR mismatched types - //~| expected type `i32` - //~| found type `[{integer}; 3]` - //~| expected i32, found array of 3 elements - - let x: &[i32] = &[1, 2, 3]; - let _y: &i32 = x; - //~^ ERROR mismatched types - //~| expected type `&i32` - //~| found type `&[i32]` - //~| expected i32, found slice -} diff --git a/src/test/compile-fail/array_const_index-0.rs b/src/test/compile-fail/array_const_index-0.rs deleted file mode 100644 index 91007fcd63a..00000000000 --- a/src/test/compile-fail/array_const_index-0.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -const A: &'static [i32] = &[]; -const B: i32 = (&A)[1]; -//~^ index out of bounds: the len is 0 but the index is 1 -//~| ERROR this constant cannot be used - -fn main() { - let _ = B; -} diff --git a/src/test/compile-fail/array_const_index-1.rs b/src/test/compile-fail/array_const_index-1.rs deleted file mode 100644 index 66739d308a7..00000000000 --- a/src/test/compile-fail/array_const_index-1.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -const A: [i32; 0] = []; -const B: i32 = A[1]; -//~^ index out of bounds: the len is 0 but the index is 1 -//~| ERROR this constant cannot be used - -fn main() { - let _ = B; -} diff --git a/src/test/compile-fail/asm-bad-clobber.rs b/src/test/compile-fail/asm-bad-clobber.rs deleted file mode 100644 index c2b54e37e39..00000000000 --- a/src/test/compile-fail/asm-bad-clobber.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android -// ignore-arm -// ignore-aarch64 -// ignore-s390x -// ignore-emscripten -// ignore-powerpc -// ignore-powerpc64 -// ignore-powerpc64le -// ignore-sparc -// ignore-sparc64 -// ignore-mips -// ignore-mips64 - -#![feature(asm, rustc_attrs)] - -#[cfg(any(target_arch = "x86", - target_arch = "x86_64"))] -#[rustc_error] -pub fn main() { - unsafe { - // clobber formatted as register input/output - asm!("xor %eax, %eax" : : : "{eax}"); - //~^ ERROR clobber should not be surrounded by braces - } -} diff --git a/src/test/compile-fail/asm-in-bad-modifier.rs b/src/test/compile-fail/asm-in-bad-modifier.rs deleted file mode 100644 index 2eefd4235bc..00000000000 --- a/src/test/compile-fail/asm-in-bad-modifier.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-s390x -// ignore-emscripten -// ignore-powerpc -// ignore-powerpc64 -// ignore-powerpc64le -// ignore-sparc -// ignore-sparc64 -// ignore-mips -// ignore-mips64 - -#![feature(asm)] - -fn foo(x: isize) { println!("{}", x); } - -#[cfg(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64"))] -pub fn main() { - let x: isize; - let y: isize; - unsafe { - asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '=' - asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+' - } - foo(x); - foo(y); -} - -#[cfg(not(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64")))] -pub fn main() {} diff --git a/src/test/compile-fail/asm-misplaced-option.rs b/src/test/compile-fail/asm-misplaced-option.rs deleted file mode 100644 index bfc1fd68fe0..00000000000 --- a/src/test/compile-fail/asm-misplaced-option.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android -// ignore-arm -// ignore-aarch64 -// ignore-s390x -// ignore-emscripten -// ignore-powerpc -// ignore-powerpc64 -// ignore-powerpc64le -// ignore-sparc -// ignore-sparc64 -// ignore-mips -// ignore-mips64 - -#![feature(asm, rustc_attrs)] - -#![allow(dead_code, non_upper_case_globals)] - -#[cfg(any(target_arch = "x86", - target_arch = "x86_64"))] -#[rustc_error] -pub fn main() { //~ ERROR compilation successful - // assignment not dead - let mut x: isize = 0; - unsafe { - // extra colon - asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc"); - //~^ WARNING unrecognized option - } - assert_eq!(x, 5); - - unsafe { - // comma in place of a colon - asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile"); - //~^ WARNING expected a clobber, found an option - } - assert_eq!(x, 13); -} diff --git a/src/test/compile-fail/asm-out-no-modifier.rs b/src/test/compile-fail/asm-out-no-modifier.rs deleted file mode 100644 index 40d2ded8a88..00000000000 --- a/src/test/compile-fail/asm-out-no-modifier.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-s390x -// ignore-emscripten -// ignore-powerpc -// ignore-powerpc64 -// ignore-powerpc64le -// ignore-sparc -// ignore-sparc64 -// ignore-mips -// ignore-mips64 - -#![feature(asm)] - -fn foo(x: isize) { println!("{}", x); } - -#[cfg(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64"))] -pub fn main() { - let x: isize; - unsafe { - asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '=' - } - foo(x); -} - -#[cfg(not(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64")))] -pub fn main() {} diff --git a/src/test/compile-fail/asm-out-read-uninit.rs b/src/test/compile-fail/asm-out-read-uninit.rs deleted file mode 100644 index c308a9f0850..00000000000 --- a/src/test/compile-fail/asm-out-read-uninit.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-s390x -// ignore-emscripten -// ignore-powerpc -// ignore-powerpc64 -// ignore-powerpc64le -// ignore-sparc -// ignore-sparc64 -// ignore-mips -// ignore-mips64 - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(asm)] - -fn foo(x: isize) { println!("{}", x); } - -#[cfg(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64"))] -pub fn main() { - let x: isize; - unsafe { - asm!("mov $1, $0" : "=r"(x) : "r"(x)); - //[ast]~^ ERROR use of possibly uninitialized variable: `x` - //[mir]~^^ ERROR use of possibly uninitialized variable: `x` - } - foo(x); -} - -#[cfg(not(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64")))] -pub fn main() {} diff --git a/src/test/compile-fail/asm-src-loc-codegen-units.rs b/src/test/compile-fail/asm-src-loc-codegen-units.rs deleted file mode 100644 index 6c5c5b00776..00000000000 --- a/src/test/compile-fail/asm-src-loc-codegen-units.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// WONTFIX(#20184) Needs landing pads (not present in stage1) or the compiler hangs. -// ignore-stage1 -// compile-flags: -C codegen-units=2 -// ignore-emscripten - -#![feature(asm)] - -fn main() { - unsafe { - asm!("nowayisthisavalidinstruction"); //~ ERROR instruction - } -} diff --git a/src/test/compile-fail/asm-src-loc.rs b/src/test/compile-fail/asm-src-loc.rs deleted file mode 100644 index 59b47c2408d..00000000000 --- a/src/test/compile-fail/asm-src-loc.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-emscripten - -#![feature(asm)] - -fn main() { - unsafe { - asm!("nowayisthisavalidinstruction"); //~ ERROR instruction - } -} diff --git a/src/test/compile-fail/assign-imm-local-twice.rs b/src/test/compile-fail/assign-imm-local-twice.rs deleted file mode 100644 index ee9dafdd49e..00000000000 --- a/src/test/compile-fail/assign-imm-local-twice.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - -fn test() { - let v: isize; - //[mir]~^ NOTE consider changing this to `mut v` - v = 1; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - println!("v={}", v); - v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable - println!("v={}", v); -} - -fn main() { -} diff --git a/src/test/compile-fail/assign-to-method.rs b/src/test/compile-fail/assign-to-method.rs deleted file mode 100644 index 4518ce36b6d..00000000000 --- a/src/test/compile-fail/assign-to-method.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct cat { - meows : usize, - - how_hungry : isize, -} - -impl cat { - pub fn speak(&self) { self.meows += 1; } -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -fn main() { - let nyan : cat = cat(52, 99); - nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method -} diff --git a/src/test/compile-fail/assignment-operator-unimplemented.rs b/src/test/compile-fail/assignment-operator-unimplemented.rs deleted file mode 100644 index 5b24c6bd79f..00000000000 --- a/src/test/compile-fail/assignment-operator-unimplemented.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo; - -fn main() { - let mut a = Foo; - let ref b = Foo; - a += *b; //~ Error: binary assignment operation `+=` cannot be applied to type `Foo` -} diff --git a/src/test/compile-fail/assoc-inherent.rs b/src/test/compile-fail/assoc-inherent.rs deleted file mode 100644 index 7eab831258f..00000000000 --- a/src/test/compile-fail/assoc-inherent.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test associated types are forbidden in inherent impls. - -struct Foo; - -impl Foo { - type Bar = isize; //~ERROR associated types are not allowed in inherent impls -} - -fn main() {} diff --git a/src/test/compile-fail/associated-const-ambiguity-report.rs b/src/test/compile-fail/associated-const-ambiguity-report.rs deleted file mode 100644 index 5051e78d1ba..00000000000 --- a/src/test/compile-fail/associated-const-ambiguity-report.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -trait Foo { - const ID: i32; -} - -trait Bar { - const ID: i32; -} - -impl Foo for i32 { - const ID: i32 = 1; -} - -impl Bar for i32 { - const ID: i32 = 3; -} - -const X: i32 = ::ID; //~ ERROR E0034 - -fn main() { - assert_eq!(1, X); -} diff --git a/src/test/compile-fail/associated-const-array-len.rs b/src/test/compile-fail/associated-const-array-len.rs deleted file mode 100644 index 2cc10f0f956..00000000000 --- a/src/test/compile-fail/associated-const-array-len.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -trait Foo { - const ID: usize; -} - -const X: [i32; ::ID] = [0, 1, 2]; -//~^ ERROR the trait bound `i32: Foo` is not satisfied - -fn main() { - assert_eq!(1, X); -} diff --git a/src/test/compile-fail/associated-const-dead-code.rs b/src/test/compile-fail/associated-const-dead-code.rs deleted file mode 100644 index 42db13f4f3b..00000000000 --- a/src/test/compile-fail/associated-const-dead-code.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(dead_code)] - -struct MyFoo; - -impl MyFoo { - const BAR: u32 = 1; - //~^ ERROR associated const is never used: `BAR` -} - -fn main() { - let _: MyFoo = MyFoo; -} diff --git a/src/test/compile-fail/associated-const-generic-obligations.rs b/src/test/compile-fail/associated-const-generic-obligations.rs deleted file mode 100644 index 45f53418dca..00000000000 --- a/src/test/compile-fail/associated-const-generic-obligations.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -trait Foo { - type Out: Sized; -} - -impl Foo for String { - type Out = String; -} - -trait Bar: Foo { - const FROM: Self::Out; -} - -impl Bar for T { - const FROM: &'static str = "foo"; - //~^ ERROR the trait bound `T: Foo` is not satisfied [E0277] -} - -fn main() {} diff --git a/src/test/compile-fail/associated-const-in-trait.rs b/src/test/compile-fail/associated-const-in-trait.rs deleted file mode 100644 index f837d9ab8e5..00000000000 --- a/src/test/compile-fail/associated-const-in-trait.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// #29924 - -#![feature(const_fn, associated_consts)] - -trait Trait { - const N: usize; -} - -impl Trait { - //~^ ERROR the trait `Trait` cannot be made into an object [E0038] - const fn n() -> usize { Self::N } -} - -fn main() {} diff --git a/src/test/compile-fail/associated-const-no-item.rs b/src/test/compile-fail/associated-const-no-item.rs deleted file mode 100644 index f9a57cd6d75..00000000000 --- a/src/test/compile-fail/associated-const-no-item.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -trait Foo { - const ID: i32; -} - -const X: i32 = ::ID; -//~^ ERROR no associated item named `ID` found for type `i32` - -fn main() { - assert_eq!(1, X); -} diff --git a/src/test/compile-fail/associated-const-private-impl.rs b/src/test/compile-fail/associated-const-private-impl.rs deleted file mode 100644 index b5accfff5bb..00000000000 --- a/src/test/compile-fail/associated-const-private-impl.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -mod bar1 { - pub use self::bar2::Foo; - mod bar2 { - pub struct Foo; - - impl Foo { - const ID: i32 = 1; - } - } -} - -fn main() { - assert_eq!(1, bar1::Foo::ID); - //~^ERROR associated constant `ID` is private -} diff --git a/src/test/compile-fail/associated-const-type-parameter-arms.rs b/src/test/compile-fail/associated-const-type-parameter-arms.rs deleted file mode 100644 index 630a234fa66..00000000000 --- a/src/test/compile-fail/associated-const-type-parameter-arms.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub enum EFoo { A, B, C, D } - -pub trait Foo { - const X: EFoo; -} - -struct Abc; - -impl Foo for Abc { - const X: EFoo = EFoo::B; -} - -struct Def; -impl Foo for Def { - const X: EFoo = EFoo::D; -} - -pub fn test(arg: EFoo) { - match arg { - A::X => println!("A::X"), - //~^ error: associated consts cannot be referenced in patterns [E0158] - B::X => println!("B::X"), - //~^ error: associated consts cannot be referenced in patterns [E0158] - _ => (), - } -} - -fn main() { -} diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs b/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs deleted file mode 100644 index d196cf22156..00000000000 --- a/src/test/compile-fail/associated-const-type-parameter-arrays-2.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub trait Foo { - const Y: usize; -} - -struct Abc; -impl Foo for Abc { - const Y: usize = 8; -} - -struct Def; -impl Foo for Def { - const Y: usize = 33; -} - -pub fn test() { - let _array = [4; ::Y]; - //~^ ERROR the trait bound `A: Foo` is not satisfied [E0277] -} - -fn main() { -} diff --git a/src/test/compile-fail/associated-const-type-parameter-arrays.rs b/src/test/compile-fail/associated-const-type-parameter-arrays.rs deleted file mode 100644 index 0b24cab2a68..00000000000 --- a/src/test/compile-fail/associated-const-type-parameter-arrays.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub trait Foo { - const Y: usize; -} - -struct Abc; -impl Foo for Abc { - const Y: usize = 8; -} - -struct Def; -impl Foo for Def { - const Y: usize = 33; -} - -pub fn test() { - let _array: [u32; ::Y]; - //~^ ERROR the trait bound `A: Foo` is not satisfied [E0277] -} - -fn main() { -} diff --git a/src/test/compile-fail/associated-const-upper-case-lint.rs b/src/test/compile-fail/associated-const-upper-case-lint.rs deleted file mode 100644 index 497ff426b2f..00000000000 --- a/src/test/compile-fail/associated-const-upper-case-lint.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(non_upper_case_globals)] -#![allow(dead_code)] - -struct Foo; - -impl Foo { - const not_upper: bool = true; -} -//~^^ ERROR associated constant `not_upper` should have an upper case name such as `NOT_UPPER` - -fn main() {} diff --git a/src/test/compile-fail/associated-item-duplicate-names-2.rs b/src/test/compile-fail/associated-item-duplicate-names-2.rs deleted file mode 100644 index 85ea949b9c8..00000000000 --- a/src/test/compile-fail/associated-item-duplicate-names-2.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct Foo; - -impl Foo { - const bar: bool = true; - fn bar() {} //~ ERROR duplicate definitions -} - -fn main() {} diff --git a/src/test/compile-fail/associated-item-duplicate-names-3.rs b/src/test/compile-fail/associated-item-duplicate-names-3.rs deleted file mode 100644 index 12cab13d0b9..00000000000 --- a/src/test/compile-fail/associated-item-duplicate-names-3.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// Before the introduction of the "duplicate associated type" error, the -// program below used to result in the "ambiguous associated type" error E0223, -// which is unexpected. - -trait Foo { - type Bar; -} - -struct Baz; - -impl Foo for Baz { - type Bar = i16; - type Bar = u16; //~ ERROR duplicate definitions -} - -fn main() { - let x: Baz::Bar = 5; -} diff --git a/src/test/compile-fail/associated-item-duplicate-names.rs b/src/test/compile-fail/associated-item-duplicate-names.rs deleted file mode 100644 index a2fc1bc0177..00000000000 --- a/src/test/compile-fail/associated-item-duplicate-names.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for issue #23969 - - -trait Foo { - type Ty; - const BAR: u32; -} - -impl Foo for () { - type Ty = (); - type Ty = usize; //~ ERROR duplicate definitions - const BAR: u32 = 7; - const BAR: u32 = 8; //~ ERROR duplicate definitions -} - -fn main() { - let _: <() as Foo>::Ty = (); - let _: u32 = <() as Foo>::BAR; -} diff --git a/src/test/compile-fail/associated-path-shl.rs b/src/test/compile-fail/associated-path-shl.rs deleted file mode 100644 index 7daf0d3c4e2..00000000000 --- a/src/test/compile-fail/associated-path-shl.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that associated paths starting with `<<` are successfully parsed. - -fn main() { - let _: <::B>::C; //~ ERROR cannot find type `A` in this scope - let _ = <::B>::C; //~ ERROR cannot find type `A` in this scope - let <::B>::C; //~ ERROR cannot find type `A` in this scope - let 0 ..= <::B>::C; //~ ERROR cannot find type `A` in this scope - //~^ ERROR only char and numeric types are allowed in range patterns - <::B>::C; //~ ERROR cannot find type `A` in this scope -} diff --git a/src/test/compile-fail/associated-type-projection-ambig-between-bound-and-where-clause.rs b/src/test/compile-fail/associated-type-projection-ambig-between-bound-and-where-clause.rs deleted file mode 100644 index ce97019a2b2..00000000000 --- a/src/test/compile-fail/associated-type-projection-ambig-between-bound-and-where-clause.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test equality constraints in a where clause where the type being -// equated appears in a supertrait. - -pub trait Vehicle { - type Color; - - fn go(&self) { } -} - -pub trait Box { - type Color; - - fn mail(&self) { } -} - -fn a(_: C::Color) { - //~^ ERROR ambiguous associated type `Color` in bounds of `C` -} - -fn b(_: C::Color) where C : Vehicle+Box { - //~^ ERROR ambiguous associated type `Color` in bounds of `C` -} - -fn c(_: C::Color) where C : Vehicle, C : Box { - //~^ ERROR ambiguous associated type `Color` in bounds of `C` -} - -struct D; -impl D where X : Vehicle { - fn d(&self, _: X::Color) where X : Box { } - //~^ ERROR ambiguous associated type `Color` in bounds of `X` -} - -trait E { - fn e(&self, _: X::Color) where X : Box; - //~^ ERROR ambiguous associated type `Color` in bounds of `X` - - fn f(&self, _: X::Color) where X : Box { } - //~^ ERROR ambiguous associated type `Color` in bounds of `X` -} - -pub fn main() { } diff --git a/src/test/compile-fail/associated-type-projection-from-supertrait.rs b/src/test/compile-fail/associated-type-projection-from-supertrait.rs deleted file mode 100644 index b388b6a28e3..00000000000 --- a/src/test/compile-fail/associated-type-projection-from-supertrait.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test equality constraints in a where clause where the type being -// equated appears in a supertrait. - -pub trait Vehicle { - type Color; - - fn go(&self) { } -} - -pub trait Car : Vehicle { - fn honk(&self) { } - fn chip_paint(&self, c: Self::Color) { } -} - -/////////////////////////////////////////////////////////////////////////// - -struct Black; -struct ModelT; -impl Vehicle for ModelT { type Color = Black; } -impl Car for ModelT { } - -/////////////////////////////////////////////////////////////////////////// - -struct Blue; -struct ModelU; -impl Vehicle for ModelU { type Color = Blue; } -impl Car for ModelU { } - -/////////////////////////////////////////////////////////////////////////// - -fn dent(c: C, color: C::Color) { c.chip_paint(color) } -fn a() { dent(ModelT, Black); } -fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types -fn c() { dent(ModelU, Black); } //~ ERROR mismatched types -fn d() { dent(ModelU, Blue); } - -/////////////////////////////////////////////////////////////////////////// - -fn e() { ModelT.chip_paint(Black); } -fn f() { ModelT.chip_paint(Blue); } //~ ERROR mismatched types -fn g() { ModelU.chip_paint(Black); } //~ ERROR mismatched types -fn h() { ModelU.chip_paint(Blue); } - -pub fn main() { } diff --git a/src/test/compile-fail/associated-types-binding-to-type-defined-in-supertrait.rs b/src/test/compile-fail/associated-types-binding-to-type-defined-in-supertrait.rs deleted file mode 100644 index b1194154911..00000000000 --- a/src/test/compile-fail/associated-types-binding-to-type-defined-in-supertrait.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test equality constraints in a where clause where the type being -// equated appears in a supertrait. - -pub trait Vehicle { - type Color; - - fn go(&self) { } -} - -pub trait Car : Vehicle { - fn honk(&self) { } -} - -/////////////////////////////////////////////////////////////////////////// - -struct Black; -struct ModelT; -impl Vehicle for ModelT { type Color = Black; } -impl Car for ModelT { } - -/////////////////////////////////////////////////////////////////////////// - -struct Blue; -struct ModelU; -impl Vehicle for ModelU { type Color = Blue; } -impl Car for ModelU { } - -/////////////////////////////////////////////////////////////////////////// - -fn black_car>(c: C) { -} - -fn blue_car>(c: C) { -} - -fn a() { black_car(ModelT); } -fn b() { blue_car(ModelT); } //~ ERROR type mismatch -fn c() { black_car(ModelU); } //~ ERROR type mismatch -fn d() { blue_car(ModelU); } - -pub fn main() { } diff --git a/src/test/compile-fail/associated-types-bound-failure.rs b/src/test/compile-fail/associated-types-bound-failure.rs deleted file mode 100644 index cd21fb949cb..00000000000 --- a/src/test/compile-fail/associated-types-bound-failure.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test equality constraints on associated types in a where clause. - -pub trait ToInt { - fn to_int(&self) -> isize; -} - -pub trait GetToInt -{ - type R; - - fn get(&self) -> ::R; -} - -fn foo(g: G) -> isize - where G : GetToInt -{ - ToInt::to_int(&g.get()) //~ ERROR E0277 -} - -fn bar(g: G) -> isize - where G::R : ToInt -{ - ToInt::to_int(&g.get()) // OK -} - -pub fn main() { -} diff --git a/src/test/compile-fail/associated-types-coherence-failure.rs b/src/test/compile-fail/associated-types-coherence-failure.rs deleted file mode 100644 index 786a25500a8..00000000000 --- a/src/test/compile-fail/associated-types-coherence-failure.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that coherence detects overlap when some of the types in the -// impls are projections of associated type. Issue #20624. - -use std::marker::PhantomData; -use std::ops::Deref; - -pub struct Cow<'a, B: ?Sized>(PhantomData<(&'a (),B)>); - -/// Trait for moving into a `Cow` -pub trait IntoCow<'a, B: ?Sized> { - /// Moves `self` into `Cow` - fn into_cow(self) -> Cow<'a, B>; -} - -impl<'a, B: ?Sized> IntoCow<'a, B> for ::Owned where B: ToOwned { - fn into_cow(self) -> Cow<'a, B> { - Cow(PhantomData) - } -} - -impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned { -//~^ ERROR E0119 - fn into_cow(self) -> Cow<'a, B> { - self - } -} - -impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned { -//~^ ERROR E0119 - fn into_cow(self) -> Cow<'a, B> { - Cow(PhantomData) - } -} - -impl ToOwned for u8 { - type Owned = &'static u8; - fn to_owned(&self) -> &'static u8 { panic!() } -} - -/// A generalization of Clone to borrowed data. -pub trait ToOwned { - type Owned; - - /// Create owned data from borrowed data, usually by copying. - fn to_owned(&self) -> Self::Owned; -} - - -fn main() {} diff --git a/src/test/compile-fail/associated-types-eq-1.rs b/src/test/compile-fail/associated-types-eq-1.rs deleted file mode 100644 index 6f2ee854543..00000000000 --- a/src/test/compile-fail/associated-types-eq-1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test equality constraints on associated types. Check that unsupported syntax -// does not ICE. - -pub trait Foo { - type A; - fn boo(&self) -> ::A; -} - -fn foo2(x: I) { - let _: A = x.boo(); //~ ERROR cannot find type `A` in this scope -} - -pub fn main() {} diff --git a/src/test/compile-fail/associated-types-eq-2.rs b/src/test/compile-fail/associated-types-eq-2.rs deleted file mode 100644 index 755a9f2d73f..00000000000 --- a/src/test/compile-fail/associated-types-eq-2.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test equality constraints on associated types. Check we get an error when an -// equality constraint is used in a qualified path. - -pub trait Foo { - type A; - fn boo(&self) -> ::A; -} - -struct Bar; - -impl Foo for isize { - type A = usize; - fn boo(&self) -> usize { 42 } -} - -fn baz(x: &>::A) {} -//~^ ERROR associated type bindings are not allowed here - -pub fn main() {} diff --git a/src/test/compile-fail/associated-types-eq-3.rs b/src/test/compile-fail/associated-types-eq-3.rs deleted file mode 100644 index cb952f6534f..00000000000 --- a/src/test/compile-fail/associated-types-eq-3.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test equality constraints on associated types. Check we get type errors -// where we should. - -pub trait Foo { - type A; - fn boo(&self) -> ::A; -} - -struct Bar; - -impl Foo for isize { - type A = usize; - fn boo(&self) -> usize { - 42 - } -} - -fn foo1>(x: I) { - let _: Bar = x.boo(); -} - -fn foo2(x: I) { - let _: Bar = x.boo(); - //~^ ERROR mismatched types - //~| expected type `Bar` - //~| found type `::A` - //~| expected struct `Bar`, found associated type -} - - -pub fn baz(x: &Foo) { - let _: Bar = x.boo(); -} - - -pub fn main() { - let a = 42; - foo1(a); - //~^ ERROR type mismatch resolving - //~| expected usize, found struct `Bar` - baz(&a); - //~^ ERROR type mismatch resolving - //~| expected usize, found struct `Bar` -} diff --git a/src/test/compile-fail/associated-types-eq-expr-path.rs b/src/test/compile-fail/associated-types-eq-expr-path.rs deleted file mode 100644 index 847393ba2b8..00000000000 --- a/src/test/compile-fail/associated-types-eq-expr-path.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that an associated type cannot be bound in an expression path. - -trait Foo { - type A; - fn bar() -> isize; -} - -impl Foo for isize { - type A = usize; - fn bar() -> isize { 42 } -} - -pub fn main() { - let x: isize = Foo::::bar(); - //~^ ERROR associated type bindings are not allowed here -} diff --git a/src/test/compile-fail/associated-types-eq-hr.rs b/src/test/compile-fail/associated-types-eq-hr.rs deleted file mode 100644 index 52a2ca9082d..00000000000 --- a/src/test/compile-fail/associated-types-eq-hr.rs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check testing of equality constraints in a higher-ranked context. - -pub trait TheTrait { - type A; - - fn get(&self, t: T) -> Self::A; -} - -struct IntStruct { - x: isize -} - -impl<'a> TheTrait<&'a isize> for IntStruct { - type A = &'a isize; - - fn get(&self, t: &'a isize) -> &'a isize { - t - } -} - -struct UintStruct { - x: isize -} - -impl<'a> TheTrait<&'a isize> for UintStruct { - type A = &'a usize; - - fn get(&self, t: &'a isize) -> &'a usize { - panic!() - } -} - -struct Tuple { -} - -impl<'a> TheTrait<(&'a isize, &'a isize)> for Tuple { - type A = &'a isize; - - fn get(&self, t: (&'a isize, &'a isize)) -> &'a isize { - t.0 - } -} - -fn foo() - where T : for<'x> TheTrait<&'x isize, A = &'x isize> -{ - // ok for IntStruct, but not UintStruct -} - -fn bar() - where T : for<'x> TheTrait<&'x isize, A = &'x usize> -{ - // ok for UintStruct, but not IntStruct -} - -fn tuple_one() - where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> -{ - // not ok for tuple, two lifetimes and we pick first -} - -fn tuple_two() - where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> -{ - // not ok for tuple, two lifetimes and we pick second -} - -fn tuple_three() - where T : for<'x> TheTrait<(&'x isize, &'x isize), A = &'x isize> -{ - // ok for tuple -} - -fn tuple_four() - where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)> -{ - // not ok for tuple, two lifetimes, and lifetime matching is invariant -} - -pub fn main() { - foo::(); - foo::(); //~ ERROR type mismatch - - bar::(); //~ ERROR type mismatch - bar::(); - - tuple_one::(); - //~^ ERROR E0277 - //~| ERROR type mismatch - - tuple_two::(); - //~^ ERROR E0277 - //~| ERROR type mismatch - - tuple_three::(); - - tuple_four::(); - //~^ ERROR E0277 -} diff --git a/src/test/compile-fail/associated-types-for-unimpl-trait.rs b/src/test/compile-fail/associated-types-for-unimpl-trait.rs deleted file mode 100644 index a6fcb9cff13..00000000000 --- a/src/test/compile-fail/associated-types-for-unimpl-trait.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Get { - type Value; - fn get(&self) -> ::Value; -} - -trait Other { - fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait bound `Self: Get` is not satisfied -} - -fn main() { -} diff --git a/src/test/compile-fail/associated-types-incomplete-object.rs b/src/test/compile-fail/associated-types-incomplete-object.rs deleted file mode 100644 index c1feb8ac459..00000000000 --- a/src/test/compile-fail/associated-types-incomplete-object.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that the user gets an errror if they omit a binding from an -// object type. - -pub trait Foo { - type A; - type B; - fn boo(&self) -> ::A; -} - -struct Bar; - -impl Foo for isize { - type A = usize; - type B = char; - fn boo(&self) -> usize { - 42 - } -} - -pub fn main() { - let a = &42isize as &Foo; - - let b = &42isize as &Foo; - //~^ ERROR the value of the associated type `B` (from the trait `Foo`) must be specified - - let c = &42isize as &Foo; - //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified - - let d = &42isize as &Foo; - //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified - //~| ERROR the value of the associated type `B` (from the trait `Foo`) must be specified -} diff --git a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs b/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs deleted file mode 100644 index 83726a1676d..00000000000 --- a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we report an error if the trait ref in a qualified type -// uses invalid type arguments. - -trait Foo { - type Bar; - fn get_bar(&self) -> Self::Bar; -} - -fn f>(t: &T) { - let u: >::Bar = t.get_bar(); - //~^ ERROR the trait bound `T: Foo` is not satisfied -} - -fn main() { } diff --git a/src/test/compile-fail/associated-types-issue-17359.rs b/src/test/compile-fail/associated-types-issue-17359.rs deleted file mode 100644 index 82258f124d3..00000000000 --- a/src/test/compile-fail/associated-types-issue-17359.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we do not ICE when an impl is missing an associated type (and that we report -// a useful error, of course). - -trait Trait { - type Type; -} - -impl Trait for isize {} //~ ERROR missing: `Type` - -fn main() {} diff --git a/src/test/compile-fail/associated-types-issue-20346.rs b/src/test/compile-fail/associated-types-issue-20346.rs deleted file mode 100644 index a00aa8364bd..00000000000 --- a/src/test/compile-fail/associated-types-issue-20346.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we reliably check the value of the associated type. - -#![crate_type = "lib"] -#![no_implicit_prelude] - -use std::option::Option::{self, None, Some}; -use std::vec::Vec; - -trait Iterator { - type Item; - - fn next(&mut self) -> Option; -} - -fn is_iterator_of>(_: &I) {} - -struct Adapter { - iter: I, - found_none: bool, -} - -impl Iterator for Adapter where I: Iterator> { - type Item = T; - - fn next(&mut self) -> Option { - loop {} - } -} - -fn test_adapter>>(it: I) { - is_iterator_of::, _>(&it); // Sanity check - let adapter = Adapter { iter: it, found_none: false }; - is_iterator_of::(&adapter); // OK - is_iterator_of::, _>(&adapter); //~ ERROR type mismatch -} diff --git a/src/test/compile-fail/associated-types-multiple-types-one-trait.rs b/src/test/compile-fail/associated-types-multiple-types-one-trait.rs deleted file mode 100644 index 9436f825de8..00000000000 --- a/src/test/compile-fail/associated-types-multiple-types-one-trait.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - type X; - type Y; -} - -fn have_x_want_x>(t: &T) -{ - want_x(t); -} - -fn have_x_want_y>(t: &T) -{ - want_y(t); //~ ERROR type mismatch -} - -fn have_y_want_x>(t: &T) -{ - want_x(t); //~ ERROR type mismatch -} - -fn have_y_want_y>(t: &T) -{ - want_y(t); -} - -fn have_xy_want_x>(t: &T) -{ - want_x(t); -} - -fn have_xy_want_y>(t: &T) -{ - want_y(t); -} - -fn have_xy_want_xy>(t: &T) -{ - want_x(t); - want_y(t); -} - -fn want_x>(t: &T) { } - -fn want_y>(t: &T) { } - -fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-bound.rs b/src/test/compile-fail/associated-types-no-suitable-bound.rs deleted file mode 100644 index baf56ffec86..00000000000 --- a/src/test/compile-fail/associated-types-no-suitable-bound.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Get { - type Value; - fn get(&self) -> ::Value; -} - -struct Struct { - x: isize, -} - -impl Struct { - fn uhoh(foo: ::Value) {} - //~^ ERROR the trait bound `T: Get` is not satisfied -} - -fn main() { -} diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs deleted file mode 100644 index e0f0f3c47ae..00000000000 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we get an error when you use `::Value` in -// the trait definition but `Self` does not, in fact, implement `Get`. -// -// See also associated-types-no-suitable-supertrait.rs, which checks -// that we see the same error when making this mistake on an impl -// rather than the default method impl. -// -// See also run-pass/associated-types-projection-to-unrelated-trait.rs, -// which checks that the trait interface itself is not considered an -// error as long as all impls satisfy the constraint. - -trait Get { - type Value; -} - -trait Other { - fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait bound `Self: Get` is not satisfied -} - -fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs deleted file mode 100644 index ec38595e8fe..00000000000 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we get an error when you use `::Value` in -// the trait definition but `Self` does not, in fact, implement `Get`. -// -// See also associated-types-no-suitable-supertrait-2.rs, which checks -// that we see the same error if we get around to checking the default -// method body. -// -// See also run-pass/associated-types-projection-to-unrelated-trait.rs, -// which checks that the trait interface itself is not considered an -// error as long as all impls satisfy the constraint. - -trait Get { - type Value; -} - -trait Other { - fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait bound `Self: Get` is not satisfied -} - -impl Other for T { - fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} - //~^ ERROR the trait bound `(T, U): Get` is not satisfied -} - -fn main() { } diff --git a/src/test/compile-fail/associated-types-outlives.rs b/src/test/compile-fail/associated-types-outlives.rs deleted file mode 100644 index f070ab6799c..00000000000 --- a/src/test/compile-fail/associated-types-outlives.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #24622. The older associated types code -// was erroneously assuming that all projections outlived the current -// fn body, causing this (invalid) code to be accepted. - -pub trait Foo<'a> { - type Bar; -} - -impl<'a, T:'a> Foo<'a> for T { - type Bar = &'a T; -} - -fn denormalise<'a, T>(t: &'a T) -> >::Bar { - t -} - -pub fn free_and_use Foo<'a>, - F: for<'a> FnOnce(>::Bar)>(x: T, f: F) { - let y; - 'body: loop { // lifetime annotations added for clarity - 's: loop { y = denormalise(&x); break } - drop(x); //~ ERROR cannot move out of `x` because it is borrowed - return f(y); - } -} - -pub fn main() { -} diff --git a/src/test/compile-fail/associated-types-overridden-default.rs b/src/test/compile-fail/associated-types-overridden-default.rs deleted file mode 100644 index 946a4b2f73a..00000000000 --- a/src/test/compile-fail/associated-types-overridden-default.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(associated_type_defaults)] - -pub trait Tr { - type Assoc = u8; - type Assoc2 = Self::Assoc; - const C: u8 = 11; - fn foo(&self) {} -} - -impl Tr for () { - type Assoc = (); - //~^ ERROR need to be reimplemented as `Assoc` was overridden: `Assoc2`, `C`, `foo` -} - -fn main() {} diff --git a/src/test/compile-fail/associated-types-path-1.rs b/src/test/compile-fail/associated-types-path-1.rs deleted file mode 100644 index ab061ca4d8d..00000000000 --- a/src/test/compile-fail/associated-types-path-1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we have one and only one associated type per ref. - -pub trait Foo { - type A; -} -pub trait Bar { - type A; -} - -pub fn f1(a: T, x: T::A) {} //~ERROR associated type `A` not found -pub fn f2(a: T, x: T::A) {} //~ERROR ambiguous associated type `A` - -pub fn main() {} diff --git a/src/test/compile-fail/associated-types-path-2.rs b/src/test/compile-fail/associated-types-path-2.rs deleted file mode 100644 index d62f6b0f1a3..00000000000 --- a/src/test/compile-fail/associated-types-path-2.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test type checking of uses of associated types via sugary paths. - -pub trait Foo { - type A; - - fn dummy(&self) { } -} - -impl Foo for i32 { - type A = u32; -} - -pub fn f1(a: T, x: T::A) {} -pub fn f2(a: T) -> T::A { - panic!(); -} - -pub fn f1_int_int() { - f1(2i32, 4i32); - //~^ ERROR mismatched types - //~| expected u32, found i32 -} - -pub fn f1_int_uint() { - f1(2i32, 4u32); -} - -pub fn f1_uint_uint() { - f1(2u32, 4u32); - //~^ ERROR `u32: Foo` is not satisfied - //~| ERROR `u32: Foo` is not satisfied -} - -pub fn f1_uint_int() { - f1(2u32, 4i32); - //~^ ERROR `u32: Foo` is not satisfied - //~| ERROR `u32: Foo` is not satisfied -} - -pub fn f2_int() { - let _: i32 = f2(2i32); - //~^ ERROR mismatched types - //~| expected i32, found u32 -} - -pub fn main() { } diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-fn-body.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-fn-body.rs deleted file mode 100644 index 5451a20d816..00000000000 --- a/src/test/compile-fail/associated-types-project-from-hrtb-in-fn-body.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check projection of an associated type out of a higher-ranked -// trait-bound in the context of a function body. - -pub trait Foo { - type A; - - fn get(&self, t: T) -> Self::A; -} - -fn foo<'a, I : for<'x> Foo<&'x isize>>( - x: >::A) -{ - let y: I::A = x; -} - -fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( - x: >::A, - y: >::A, - cond: bool) -{ - // x and y here have two distinct lifetimes: - let z: I::A = if cond { x } else { y }; - //~^ ERROR lifetime mismatch -} - -pub fn main() {} diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-fn.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-fn.rs deleted file mode 100644 index a79d5c4649a..00000000000 --- a/src/test/compile-fail/associated-types-project-from-hrtb-in-fn.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check projection of an associated type out of a higher-ranked trait-bound -// in the context of a function signature. - -pub trait Foo { - type A; - - fn get(&self, t: T) -> Self::A; -} - -fn foo2 Foo<&'x isize>>( - x: I::A) - //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context -{ - // This case is illegal because we have to instantiate `'x`, and - // we don't know what region to instantiate it with. - // - // This could perhaps be made equivalent to the examples below, - // specifically for fn signatures. -} - -fn foo3 Foo<&'x isize>>( - x: >::A) -{ - // OK, in this case we spelled out the precise regions involved, though we left one of - // them anonymous. -} - -fn foo4<'a, I : for<'x> Foo<&'x isize>>( - x: >::A) -{ - // OK, in this case we spelled out the precise regions involved. -} - - -pub fn main() {} diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs deleted file mode 100644 index e6251a0d318..00000000000 --- a/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check projection of an associated type out of a higher-ranked trait-bound -// in the context of a struct definition. - -pub trait Foo { - type A; - - fn get(&self, t: T) -> Self::A; -} - -struct SomeStruct Foo<&'x isize>> { - field: I::A - //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context -} - -// FIXME(eddyb) This one doesn't even compile because of the unsupported syntax. - -// struct AnotherStruct Foo<&'x isize>> { -// field: Foo<&'y isize>>::A -// } - -struct YetAnotherStruct<'a, I : for<'x> Foo<&'x isize>> { - field: >::A -} - -pub fn main() {} diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-trait-method.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-trait-method.rs deleted file mode 100644 index af46a1b42d0..00000000000 --- a/src/test/compile-fail/associated-types-project-from-hrtb-in-trait-method.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check projection of an associated type out of a higher-ranked trait-bound -// in the context of a method definition in a trait. - -pub trait Foo { - type A; - - fn get(&self, t: T) -> Self::A; -} - -trait SomeTrait Foo<&'x isize>> { - fn some_method(&self, arg: I::A); - //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context -} - -trait AnotherTrait Foo<&'x isize>> { - fn some_method(&self, arg: >::A); -} - -trait YetAnotherTrait Foo<&'x isize>> { - fn some_method<'a>(&self, arg: >::A); -} - -pub fn main() {} diff --git a/src/test/compile-fail/associated-types-projection-to-unrelated-trait-in-method-without-default.rs b/src/test/compile-fail/associated-types-projection-to-unrelated-trait-in-method-without-default.rs deleted file mode 100644 index 3f72391ff90..00000000000 --- a/src/test/compile-fail/associated-types-projection-to-unrelated-trait-in-method-without-default.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we get an error when you use `::Value` in -// the trait definition even if there is no default method. - -trait Get { - type Value; -} - -trait Other { - fn okay(&self, foo: U, bar: ::Value); - //~^ ERROR E0277 -} - -impl Get for () { - type Value = f32; -} - -impl Get for f64 { - type Value = u32; -} - -impl Other for () { - fn okay(&self, _foo: U, _bar: ::Value) { } -} - -impl Other for f64 { - fn okay(&self, _foo: U, _bar: ::Value) { } -} - -fn main() { } diff --git a/src/test/compile-fail/associated-types-subtyping-1.rs b/src/test/compile-fail/associated-types-subtyping-1.rs deleted file mode 100644 index 64dcdd39e7c..00000000000 --- a/src/test/compile-fail/associated-types-subtyping-1.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] - -trait Trait<'a> { - type Type; - - fn method(&'a self) { } -} - -fn method1<'a,'b,T>(x: &'a T, y: &'b T) - where T : for<'z> Trait<'z>, 'a : 'b -{ - // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; - let _: >::Type = a; -} - -fn method2<'a,'b,T>(x: &'a T, y: &'b T) - where T : for<'z> Trait<'z>, 'a : 'b -{ - // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; - let _: >::Type = a; //~ ERROR E0623 -} - -fn method3<'a,'b,T>(x: &'a T, y: &'b T) - where T : for<'z> Trait<'z>, 'a : 'b -{ - // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; - let _: >::Type = b; //~ ERROR E0623 -} - -fn method4<'a,'b,T>(x: &'a T, y: &'b T) - where T : for<'z> Trait<'z>, 'a : 'b -{ - // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; - let _: >::Type = b; -} - -fn main() { } diff --git a/src/test/compile-fail/associated-types-unconstrained.rs b/src/test/compile-fail/associated-types-unconstrained.rs deleted file mode 100644 index aecbf217a5b..00000000000 --- a/src/test/compile-fail/associated-types-unconstrained.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that an associated type cannot be bound in an expression path. - -trait Foo { - type A; - fn bar() -> isize; -} - -impl Foo for isize { - type A = usize; - fn bar() -> isize { 42 } -} - -pub fn main() { - let x: isize = Foo::bar(); - //~^ ERROR type annotations required -} diff --git a/src/test/compile-fail/associated-types-unsized.rs b/src/test/compile-fail/associated-types-unsized.rs deleted file mode 100644 index c561ae861ed..00000000000 --- a/src/test/compile-fail/associated-types-unsized.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Get { - type Value: ?Sized; - fn get(&self) -> ::Value; -} - -fn foo(t: T) { - let x = t.get(); //~ ERROR the size for values of type -} - -fn main() { -} diff --git a/src/test/compile-fail/associated-types/bound-lifetime-constrained.rs b/src/test/compile-fail/associated-types/bound-lifetime-constrained.rs deleted file mode 100644 index 9ba5045f2a0..00000000000 --- a/src/test/compile-fail/associated-types/bound-lifetime-constrained.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: func object clause - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -trait Foo<'a> { - type Item; -} - -impl<'a> Foo<'a> for() { - type Item = (); -} - -// Check that appearing in a projection input in the argument is not enough: -#[cfg(func)] -fn func1(_: for<'a> fn(<() as Foo<'a>>::Item) -> &'a i32) { - //[func]~^ ERROR E0581 -} - -// Check that appearing in a projection input in the return still -// causes an error: -#[cfg(func)] -fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) { - //[func]~^ ERROR E0581 -} - -#[cfg(object)] -fn object1(_: Box Fn(<() as Foo<'a>>::Item) -> &'a i32>) { - //[object]~^ ERROR E0582 -} - -#[cfg(object)] -fn object2(_: Box Fn() -> <() as Foo<'a>>::Item>) { - //[object]~^ ERROR E0582 -} - -#[cfg(clause)] -fn clause1() where T: for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32 { - //[clause]~^ ERROR `Output` references lifetime `'a` -} - -#[cfg(clause)] -fn clause2() where T: for<'a> Fn() -> <() as Foo<'a>>::Item { - //[clause]~^ ERROR `Output` references lifetime `'a` -} - -#[rustc_error] -fn main() { } //[ok]~ ERROR compilation successful diff --git a/src/test/compile-fail/associated-types/bound-lifetime-in-binding-only.rs b/src/test/compile-fail/associated-types/bound-lifetime-in-binding-only.rs deleted file mode 100644 index 7cb0623315e..00000000000 --- a/src/test/compile-fail/associated-types/bound-lifetime-in-binding-only.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: angle paren ok elision - -#![allow(dead_code)] -#![feature(rustc_attrs)] -#![feature(unboxed_closures)] - -trait Foo { - type Item; -} - -#[cfg(angle)] -fn angle Foo>() { - //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` -} - -#[cfg(angle)] -fn angle1() where T: for<'a> Foo { - //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` -} - -#[cfg(angle)] -fn angle2() where for<'a> T: Foo { - //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` -} - -#[cfg(angle)] -fn angle3(_: &for<'a> Foo) { - //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` -} - -#[cfg(paren)] -fn paren Fn() -> &'a i32>() { - //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` -} - -#[cfg(paren)] -fn paren1() where T: for<'a> Fn() -> &'a i32 { - //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` -} - -#[cfg(paren)] -fn paren2() where for<'a> T: Fn() -> &'a i32 { - //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` -} - -#[cfg(paren)] -fn paren3(_: &for<'a> Fn() -> &'a i32) { - //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` -} - -#[cfg(elision)] -fn elision &i32>() { - //[elision]~^ ERROR E0106 -} - -struct Parameterized<'a> { x: &'a str } - -#[cfg(ok)] -fn ok1 Fn(&Parameterized<'a>) -> &'a i32>() { -} - -#[cfg(ok)] -fn ok2 Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() { -} - -#[cfg(ok)] -fn ok3() where for<'a> Parameterized<'a>: Foo { -} - -#[rustc_error] -fn main() { } //[ok]~ ERROR compilation successful diff --git a/src/test/compile-fail/associated-types/bound-lifetime-in-return-only.rs b/src/test/compile-fail/associated-types/bound-lifetime-in-return-only.rs deleted file mode 100644 index b9b1317cef5..00000000000 --- a/src/test/compile-fail/associated-types/bound-lifetime-in-return-only.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: sig local structure ok elision - -#![allow(dead_code)] -#![feature(rustc_attrs)] -#![feature(unboxed_closures)] - -trait Foo { - type Item; -} - -#[cfg(sig)] -fn sig1(_: for<'a> fn() -> &'a i32) { - //[sig]~^ ERROR return type references lifetime `'a` -} - -#[cfg(sig)] -fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32) { - //[sig]~^ ERROR return type references lifetime `'a` -} - -#[cfg(local)] -fn local1() { - let _: for<'a> fn() -> &'a i32 = loop { }; - //[local]~^ ERROR return type references lifetime `'a` -} - -#[cfg(structure)] -struct Struct1 { - x: for<'a> fn() -> &'a i32 - //[structure]~^ ERROR return type references lifetime `'a` -} - -#[cfg(elision)] -fn elision(_: fn() -> &i32) { - //[elision]~^ ERROR E0106 -} - -struct Parameterized<'a> { x: &'a str } - -#[cfg(ok)] -fn ok1(_: &for<'a> Fn(&Parameterized<'a>) -> &'a i32) { -} - -#[cfg(ok)] -fn ok2(_: &for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { -} - -#[rustc_error] -fn main() { } //[ok]~ ERROR compilation successful diff --git a/src/test/compile-fail/associated-types/cache/chrono-scan.rs b/src/test/compile-fail/associated-types/cache/chrono-scan.rs deleted file mode 100644 index a753527ea53..00000000000 --- a/src/test/compile-fail/associated-types/cache/chrono-scan.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -pub type ParseResult = Result; - -pub enum Item<'a> { Literal(&'a str), - } - -pub fn colon_or_space(s: &str) -> ParseResult<&str> { - unimplemented!() -} - -pub fn timezone_offset_zulu(s: &str, colon: F) -> ParseResult<(&str, i32)> - where F: FnMut(&str) -> ParseResult<&str> { - unimplemented!() -} - -pub fn parse<'a, I>(mut s: &str, items: I) -> ParseResult<()> - where I: Iterator> { - macro_rules! try_consume { - ($e:expr) => ({ let (s_, v) = try!($e); s = s_; v }) - } - let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space)); - let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space)); - Ok(()) -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/associated-types/cache/elision.rs b/src/test/compile-fail/associated-types/cache/elision.rs deleted file mode 100644 index d1117328c86..00000000000 --- a/src/test/compile-fail/associated-types/cache/elision.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -// Check that you are allowed to implement using elision but write -// trait without elision (a bug in this cropped up during -// bootstrapping, so this is a regression test). - -pub struct SplitWhitespace<'a> { - x: &'a u8 -} - -pub trait UnicodeStr { - fn split_whitespace<'a>(&'a self) -> SplitWhitespace<'a>; -} - -impl UnicodeStr for str { - #[inline] - fn split_whitespace(&self) -> SplitWhitespace { - unimplemented!() - } -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/associated-types/cache/project-fn-ret-contravariant.rs b/src/test/compile-fail/associated-types/cache/project-fn-ret-contravariant.rs deleted file mode 100644 index a5e8f4068e6..00000000000 --- a/src/test/compile-fail/associated-types/cache/project-fn-ret-contravariant.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] -#![feature(rustc_attrs)] - -// Test for projection cache. We should be able to project distinct -// lifetimes from `foo` as we reinstantiate it multiple times, but not -// if we do it just once. In this variant, the region `'a` is used in -// an contravariant position, which affects the results. - -// revisions: ok oneuse transmute krisskross - -#![allow(dead_code, unused_variables)] - -fn foo<'a>() -> &'a u32 { loop { } } - -fn bar(t: T, x: T::Output) -> T::Output - where T: FnOnce<()> -{ - t() -} - -#[cfg(ok)] // two instantiations: OK -fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - let a = bar(foo, x); - let b = bar(foo, y); - (a, b) -} - -#[cfg(oneuse)] // one instantiation: OK (surprisingly) -fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - let f /* : fn() -> &'static u32 */ = foo; // <-- inferred type annotated - let a = bar(f, x); // this is considered ok because fn args are contravariant... - let b = bar(f, y); // ...and hence we infer T to distinct values in each call. - (a, b) -} - -#[cfg(transmute)] // one instantiations: BAD -fn baz<'a,'b>(x: &'a u32) -> &'static u32 { - bar(foo, x) //[transmute]~ ERROR E0495 -} - -#[cfg(krisskross)] // two instantiations, mixing and matching: BAD -fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - let a = bar(foo, y); - let b = bar(foo, x); - (a, b) //[krisskross]~ ERROR 55:5: 55:6: lifetime mismatch [E0623] - //[krisskross]~^ ERROR 55:8: 55:9: lifetime mismatch [E0623] -} - -#[rustc_error] -fn main() { } -//[ok]~^ ERROR compilation successful -//[oneuse]~^^ ERROR compilation successful diff --git a/src/test/compile-fail/associated-types/cache/project-fn-ret-invariant.rs b/src/test/compile-fail/associated-types/cache/project-fn-ret-invariant.rs deleted file mode 100644 index 6e4bdd4b21c..00000000000 --- a/src/test/compile-fail/associated-types/cache/project-fn-ret-invariant.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] -#![feature(rustc_attrs)] - -// Test for projection cache. We should be able to project distinct -// lifetimes from `foo` as we reinstantiate it multiple times, but not -// if we do it just once. In this variant, the region `'a` is used in -// an invariant position, which affects the results. - -// revisions: ok oneuse transmute krisskross - -#![allow(dead_code, unused_variables)] - -use std::marker::PhantomData; - -struct Type<'a> { - // Invariant - data: PhantomData &'a u32> -} - -fn foo<'a>() -> Type<'a> { loop { } } - -fn bar(t: T, x: T::Output) -> T::Output - where T: FnOnce<()> -{ - t() -} - -#[cfg(ok)] // two instantiations: OK -fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { - let a = bar(foo, x); - let b = bar(foo, y); - (a, b) -} - -#[cfg(oneuse)] // one instantiation: BAD -fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { - let f = foo; // <-- No consistent type can be inferred for `f` here. - let a = bar(f, x); - let b = bar(f, y); //[oneuse]~ ERROR 49:19: 49:20: lifetime mismatch [E0623] - (a, b) -} - -#[cfg(transmute)] // one instantiations: BAD -fn baz<'a,'b>(x: Type<'a>) -> Type<'static> { - // Cannot instantiate `foo` with any lifetime other than `'a`, - // since it is provided as input. - - bar(foo, x) //[transmute]~ ERROR E0495 -} - -#[cfg(krisskross)] // two instantiations, mixing and matching: BAD -fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { - let a = bar(foo, y); //[krisskross]~ ERROR E0623 - let b = bar(foo, x); - (a, b) //[krisskross]~ ERROR E0623 -} - -#[rustc_error] -fn main() { } -//[ok]~^ ERROR compilation successful diff --git a/src/test/compile-fail/associated-types/higher-ranked-projection.rs b/src/test/compile-fail/associated-types/higher-ranked-projection.rs deleted file mode 100644 index 12341fa8db3..00000000000 --- a/src/test/compile-fail/associated-types/higher-ranked-projection.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -// revisions: good bad - -trait Mirror { - type Image; -} - -impl Mirror for T { - type Image = T; -} - -#[cfg(bad)] -fn foo(_t: T) - where for<'a> &'a T: Mirror -{} - -#[cfg(good)] -fn foo(_t: T) - where for<'a> &'a T: Mirror -{} - -#[rustc_error] -fn main() { //[good]~ ERROR compilation successful - foo(()); - //[bad]~^ ERROR type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _` - //[bad]~| expected bound lifetime parameter 'a, found concrete lifetime -} diff --git a/src/test/compile-fail/associated-types/issue-36499.rs b/src/test/compile-fail/associated-types/issue-36499.rs deleted file mode 100644 index b5b3ecbb580..00000000000 --- a/src/test/compile-fail/associated-types/issue-36499.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: aborting due to previous error - -fn main() { - 2 + +2; -} diff --git a/src/test/compile-fail/attempted-access-non-fatal.rs b/src/test/compile-fail/attempted-access-non-fatal.rs deleted file mode 100644 index 3d6c46f5ce3..00000000000 --- a/src/test/compile-fail/attempted-access-non-fatal.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that bogus field access is non-fatal -fn main() { - let x = 0; - let _ = x.foo; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610] - let _ = x.bar; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610] -} diff --git a/src/test/compile-fail/attr-bad-crate-attr.rc b/src/test/compile-fail/attr-bad-crate-attr.rc deleted file mode 100644 index 4ab07f4fa99..00000000000 --- a/src/test/compile-fail/attr-bad-crate-attr.rc +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: expected item - -#![attr = "val"] -#[attr = "val"] // Unterminated diff --git a/src/test/compile-fail/attr-usage-inline.rs b/src/test/compile-fail/attr-usage-inline.rs deleted file mode 100644 index 250905dbdcd..00000000000 --- a/src/test/compile-fail/attr-usage-inline.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -#[inline] -fn f() {} - -#[inline] //~ ERROR: attribute should be applied to function or closure -struct S; - -fn main() {} diff --git a/src/test/compile-fail/attrs-with-no-formal-in-generics-1.rs b/src/test/compile-fail/attrs-with-no-formal-in-generics-1.rs deleted file mode 100644 index ec7885f1f44..00000000000 --- a/src/test/compile-fail/attrs-with-no-formal-in-generics-1.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test checks variations on `<#[attr] 'a, #[oops]>`, where -// `#[oops]` is left dangling (that is, it is unattached, with no -// formal binding following it). - -#![feature(rustc_attrs)] - -struct RefIntPair<'a, 'b>(&'a u32, &'b u32); - -impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { - //~^ ERROR trailing attribute after lifetime parameters -} - -fn main() { - -} diff --git a/src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs b/src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs deleted file mode 100644 index efe2d5561a8..00000000000 --- a/src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test checks variations on `<#[attr] 'a, #[oops]>`, where -// `#[oops]` is left dangling (that is, it is unattached, with no -// formal binding following it). - -#![feature(rustc_attrs)] - -struct RefAny<'a, T>(&'a T); - -impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} -//~^ ERROR trailing attribute after type parameters - -fn main() {} diff --git a/src/test/compile-fail/attrs-with-no-formal-in-generics-3.rs b/src/test/compile-fail/attrs-with-no-formal-in-generics-3.rs deleted file mode 100644 index e7d5b94d242..00000000000 --- a/src/test/compile-fail/attrs-with-no-formal-in-generics-3.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test checks variations on `<#[attr] 'a, #[oops]>`, where -// `#[oops]` is left dangling (that is, it is unattached, with no -// formal binding following it). - -struct RefIntPair<'a, 'b>(&'a u32, &'b u32); - -fn hof_lt(_: Q) - where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32 - //~^ ERROR trailing attribute after lifetime parameters -{ - -} - -fn main() { - -} diff --git a/src/test/compile-fail/auto-ref-slice-plus-ref.rs b/src/test/compile-fail/auto-ref-slice-plus-ref.rs deleted file mode 100644 index 324e9259647..00000000000 --- a/src/test/compile-fail/auto-ref-slice-plus-ref.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012-14 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn main() { - - // Testing that method lookup does not automatically borrow - // vectors to slices then automatically create a self reference. - - let mut a = vec![0]; - a.test_mut(); //~ ERROR no method named `test_mut` found - a.test(); //~ ERROR no method named `test` found - - ([1]).test(); //~ ERROR no method named `test` found - (&[1]).test(); //~ ERROR no method named `test` found -} - -trait MyIter { - fn test_mut(&mut self); - fn test(&self); -} - -impl<'a> MyIter for &'a [isize] { - fn test_mut(&mut self) { } - fn test(&self) { } -} - -impl<'a> MyIter for &'a str { - fn test_mut(&mut self) { } - fn test(&self) { } -} diff --git a/src/test/compile-fail/auto-trait-validation.rs b/src/test/compile-fail/auto-trait-validation.rs deleted file mode 100644 index 92b222e1322..00000000000 --- a/src/test/compile-fail/auto-trait-validation.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -auto trait Generic {} -//~^ auto traits cannot have generic parameters [E0567] -auto trait Bound : Copy {} -//~^ auto traits cannot have super traits [E0568] -auto trait MyTrait { fn foo() {} } -//~^ auto traits cannot have methods or associated items [E0380] -fn main() {} diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs deleted file mode 100644 index c152fdd9296..00000000000 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct clam { - x: Box, - y: Box, -} - -struct fish { - a: Box, -} - -fn main() { - let a: clam = clam{x: box 1, y: box 2}; - let b: clam = clam{x: box 10, y: box 20}; - let z: isize = a.x + b.y; - //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box` - println!("{}", z); - assert_eq!(z, 21); - let forty: fish = fish{a: box 40}; - let two: fish = fish{a: box 2}; - let answer: isize = forty.a + two.a; - //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box` - println!("{}", answer); - assert_eq!(answer, 42); -} diff --git a/src/test/compile-fail/auxiliary/ambig_impl_2_lib.rs b/src/test/compile-fail/auxiliary/ambig_impl_2_lib.rs deleted file mode 100644 index 4ba0ccdba9b..00000000000 --- a/src/test/compile-fail/auxiliary/ambig_impl_2_lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait me { - fn me(&self) -> usize; -} -impl me for usize { fn me(&self) -> usize { *self } } diff --git a/src/test/compile-fail/auxiliary/cci_class.rs b/src/test/compile-fail/auxiliary/cci_class.rs deleted file mode 100644 index 08a13fd8bcc..00000000000 --- a/src/test/compile-fail/auxiliary/cci_class.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitties { - pub struct cat { - meows : usize, - - pub how_hungry : isize, - } - - pub fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } - } -} diff --git a/src/test/compile-fail/auxiliary/cci_class_5.rs b/src/test/compile-fail/auxiliary/cci_class_5.rs deleted file mode 100644 index 7fe608f1634..00000000000 --- a/src/test/compile-fail/auxiliary/cci_class_5.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitties { - pub struct cat { - meows : usize, - pub how_hungry : isize, - } - - impl cat { - fn nap(&self) {} - } - - pub fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } - } -} diff --git a/src/test/compile-fail/auxiliary/cdylib-dep.rs b/src/test/compile-fail/auxiliary/cdylib-dep.rs deleted file mode 100644 index a3d0222a14c..00000000000 --- a/src/test/compile-fail/auxiliary/cdylib-dep.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] diff --git a/src/test/compile-fail/auxiliary/coherence_copy_like_lib.rs b/src/test/compile-fail/auxiliary/coherence_copy_like_lib.rs deleted file mode 100644 index d3d389c6a8b..00000000000 --- a/src/test/compile-fail/auxiliary/coherence_copy_like_lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(fundamental)] - -pub trait MyCopy { } -impl MyCopy for i32 { } - -pub struct MyStruct(T); - -#[fundamental] -pub struct MyFundamentalStruct(T); diff --git a/src/test/compile-fail/auxiliary/coherence_inherent_cc_lib.rs b/src/test/compile-fail/auxiliary/coherence_inherent_cc_lib.rs deleted file mode 100644 index 0458636a401..00000000000 --- a/src/test/compile-fail/auxiliary/coherence_inherent_cc_lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// See coherence_inherent_cc.rs - -pub trait TheTrait { - fn the_fn(&self); -} - -pub struct TheStruct; - -impl TheTrait for TheStruct { - fn the_fn(&self) {} -} diff --git a/src/test/compile-fail/auxiliary/coherence_lib.rs b/src/test/compile-fail/auxiliary/coherence_lib.rs deleted file mode 100644 index daa123849e4..00000000000 --- a/src/test/compile-fail/auxiliary/coherence_lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub trait Remote { - fn foo(&self) { } -} - -pub trait Remote1 { - fn foo(&self, t: T) { } -} - -pub trait Remote2 { - fn foo(&self, t: T, u: U) { } -} - -pub struct Pair(T,U); diff --git a/src/test/compile-fail/auxiliary/coherence_orphan_lib.rs b/src/test/compile-fail/auxiliary/coherence_orphan_lib.rs deleted file mode 100644 index b22d12300c7..00000000000 --- a/src/test/compile-fail/auxiliary/coherence_orphan_lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait TheTrait { - fn the_fn(&self); -} diff --git a/src/test/compile-fail/auxiliary/const_fn_lib.rs b/src/test/compile-fail/auxiliary/const_fn_lib.rs deleted file mode 100644 index b0d5a6b1272..00000000000 --- a/src/test/compile-fail/auxiliary/const_fn_lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Crate that exports a const fn. Used for testing cross-crate. - -#![crate_type="rlib"] -#![feature(const_fn)] - -pub const fn foo() -> usize { 22 } //~ ERROR const fn is unstable diff --git a/src/test/compile-fail/auxiliary/crate_a1.rs b/src/test/compile-fail/auxiliary/crate_a1.rs deleted file mode 100644 index 70f7cac94de..00000000000 --- a/src/test/compile-fail/auxiliary/crate_a1.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo; - -pub trait Bar{} - -pub fn bar() -> Box { - unimplemented!() -} - - -pub fn try_foo(x: Foo){} -pub fn try_bar(x: Box){} diff --git a/src/test/compile-fail/auxiliary/crate_a2.rs b/src/test/compile-fail/auxiliary/crate_a2.rs deleted file mode 100644 index d801f25ba2e..00000000000 --- a/src/test/compile-fail/auxiliary/crate_a2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo; - -pub trait Bar{} - -pub fn bar() -> Box { - unimplemented!() -} diff --git a/src/test/compile-fail/auxiliary/crateresolve1-1.rs b/src/test/compile-fail/auxiliary/crateresolve1-1.rs deleted file mode 100644 index 050f2fe7329..00000000000 --- a/src/test/compile-fail/auxiliary/crateresolve1-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C extra-filename=-1 -#![crate_name = "crateresolve1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 10 } diff --git a/src/test/compile-fail/auxiliary/crateresolve1-2.rs b/src/test/compile-fail/auxiliary/crateresolve1-2.rs deleted file mode 100644 index d19b3bafba5..00000000000 --- a/src/test/compile-fail/auxiliary/crateresolve1-2.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C extra-filename=-2 -#![crate_name = "crateresolve1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 20 } diff --git a/src/test/compile-fail/auxiliary/crateresolve1-3.rs b/src/test/compile-fail/auxiliary/crateresolve1-3.rs deleted file mode 100644 index c5096ac49a8..00000000000 --- a/src/test/compile-fail/auxiliary/crateresolve1-3.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C extra-filename=-3 -#![crate_name = "crateresolve1"] -#![crate_type = "lib"] - -pub fn f() -> isize { 30 } diff --git a/src/test/compile-fail/auxiliary/default_ty_param_cross_crate_crate.rs b/src/test/compile-fail/auxiliary/default_ty_param_cross_crate_crate.rs deleted file mode 100644 index 4bd8ecacb96..00000000000 --- a/src/test/compile-fail/auxiliary/default_ty_param_cross_crate_crate.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![crate_name = "default_param_test"] -#![feature(default_type_parameter_fallback)] - -use std::marker::PhantomData; - -pub struct Foo(PhantomData<(A, B)>); - -pub fn bleh() -> Foo { Foo(PhantomData) } - diff --git a/src/test/compile-fail/auxiliary/define_macro.rs b/src/test/compile-fail/auxiliary/define_macro.rs deleted file mode 100644 index 6b6b14a896b..00000000000 --- a/src/test/compile-fail/auxiliary/define_macro.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_export] -macro_rules! define_macro { - ($i:ident) => { - macro_rules! $i { () => {} } - } -} diff --git a/src/test/compile-fail/auxiliary/deprecation-lint.rs b/src/test/compile-fail/auxiliary/deprecation-lint.rs deleted file mode 100644 index 17510289875..00000000000 --- a/src/test/compile-fail/auxiliary/deprecation-lint.rs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(deprecated)] - -#[deprecated(since = "1.0.0", note = "text")] -pub fn deprecated() {} -#[deprecated(since = "1.0.0", note = "text")] -pub fn deprecated_text() {} - -pub struct MethodTester; - -impl MethodTester { - #[deprecated(since = "1.0.0", note = "text")] - pub fn method_deprecated(&self) {} - #[deprecated(since = "1.0.0", note = "text")] - pub fn method_deprecated_text(&self) {} -} - -pub trait Trait { - #[deprecated(since = "1.0.0", note = "text")] - fn trait_deprecated(&self) {} - #[deprecated(since = "1.0.0", note = "text")] - fn trait_deprecated_text(&self) {} -} - -#[deprecated(since = "1.0.0", note = "text")] -pub trait DeprecatedTrait { fn dummy(&self) { } } - -impl Trait for MethodTester {} - -#[deprecated(since = "1.0.0", note = "text")] -pub struct DeprecatedStruct { - pub i: isize -} - -#[deprecated(since = "1.0.0", note = "text")] -pub struct DeprecatedUnitStruct; - -pub enum Enum { - #[deprecated(since = "1.0.0", note = "text")] - DeprecatedVariant, -} - -#[deprecated(since = "1.0.0", note = "text")] -pub struct DeprecatedTupleStruct(pub isize); - -pub mod nested { - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedStruct { - pub i: isize - } - - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedUnitStruct; - - pub enum Enum { - #[deprecated(since = "1.0.0", note = "text")] - DeprecatedVariant, - } - - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedTupleStruct(pub isize); -} - -pub struct Stable { - #[deprecated(since = "1.0.0", note = "text")] - pub override2: u8, -} - -pub struct Stable2(pub u8, pub u8, #[deprecated(since = "1.0.0", note = "text")] pub u8); - -#[deprecated(since = "1.0.0", note = "text")] -pub struct Deprecated { - pub inherit: u8, -} - -#[deprecated(since = "1.0.0", note = "text")] -pub struct Deprecated2(pub u8, - pub u8, - pub u8); - -#[deprecated(since = "1.0.0", note = "text")] -pub mod deprecated_mod { - pub fn deprecated() {} -} - -#[macro_export] -macro_rules! macro_test { - () => (deprecated()); -} - -#[macro_export] -macro_rules! macro_test_arg { - ($func:expr) => ($func); -} - -#[macro_export] -macro_rules! macro_test_arg_nested { - ($func:ident) => (macro_test_arg!($func())); -} diff --git a/src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs b/src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs deleted file mode 100644 index d26ab6d3518..00000000000 --- a/src/test/compile-fail/auxiliary/edition-extern-crate-allowed.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// intentionally empty diff --git a/src/test/compile-fail/auxiliary/empty-struct.rs b/src/test/compile-fail/auxiliary/empty-struct.rs deleted file mode 100644 index 4a302865634..00000000000 --- a/src/test/compile-fail/auxiliary/empty-struct.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct XEmpty1 {} -pub struct XEmpty2; -pub struct XEmpty6(); - -pub enum XE { - XEmpty3 {}, - XEmpty4, - XEmpty5(), -} diff --git a/src/test/compile-fail/auxiliary/extern-statics.rs b/src/test/compile-fail/auxiliary/extern-statics.rs deleted file mode 100644 index 07f70b177b3..00000000000 --- a/src/test/compile-fail/auxiliary/extern-statics.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - pub static XA: u8; - pub static mut XB: u8; -} diff --git a/src/test/compile-fail/auxiliary/go_trait.rs b/src/test/compile-fail/auxiliary/go_trait.rs deleted file mode 100644 index 044bb606b40..00000000000 --- a/src/test/compile-fail/auxiliary/go_trait.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. - -pub trait Go { - fn go(&self, arg: isize); -} - -pub fn go(this: &G, arg: isize) { - this.go(arg) -} - -pub trait GoMut { - fn go_mut(&mut self, arg: isize); -} - -pub fn go_mut(this: &mut G, arg: isize) { - this.go_mut(arg) -} - -pub trait GoOnce { - fn go_once(self, arg: isize); -} - -pub fn go_once(this: G, arg: isize) { - this.go_once(arg) -} - -impl GoMut for G - where G : Go -{ - default fn go_mut(&mut self, arg: isize) { - go(&*self, arg) - } -} - -impl GoOnce for G - where G : GoMut -{ - default fn go_once(mut self, arg: isize) { - go_mut(&mut self, arg) - } -} diff --git a/src/test/compile-fail/auxiliary/import_crate_var.rs b/src/test/compile-fail/auxiliary/import_crate_var.rs deleted file mode 100644 index a8a55afa41a..00000000000 --- a/src/test/compile-fail/auxiliary/import_crate_var.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn f() {} - -#[macro_export] -macro_rules! m { () => { - use $crate; - import_crate_var::f(); -} } diff --git a/src/test/compile-fail/auxiliary/inherited_stability.rs b/src/test/compile-fail/auxiliary/inherited_stability.rs deleted file mode 100644 index f690cbd029d..00000000000 --- a/src/test/compile-fail/auxiliary/inherited_stability.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![crate_name="inherited_stability"] -#![crate_type = "lib"] -#![unstable(feature = "unstable_test_feature", issue = "0")] -#![feature(staged_api)] - -pub fn unstable() {} - -#[stable(feature = "rust1", since = "1.0.0")] -pub fn stable() {} - -#[stable(feature = "rust1", since = "1.0.0")] -pub mod stable_mod { - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn unstable() {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn stable() {} -} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub mod unstable_mod { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn deprecated() {} - - pub fn unstable() {} -} - -#[stable(feature = "rust1", since = "1.0.0")] -pub trait Stable { - #[unstable(feature = "unstable_test_feature", issue = "0")] - fn unstable(&self); - - #[stable(feature = "rust1", since = "1.0.0")] - fn stable(&self); -} - -impl Stable for usize { - fn unstable(&self) {} - fn stable(&self) {} -} - -pub enum Unstable { - UnstableVariant, - #[stable(feature = "rust1", since = "1.0.0")] - StableVariant -} diff --git a/src/test/compile-fail/auxiliary/internal_unstable.rs b/src/test/compile-fail/auxiliary/internal_unstable.rs deleted file mode 100644 index a4cd487eb65..00000000000 --- a/src/test/compile-fail/auxiliary/internal_unstable.rs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(staged_api, allow_internal_unstable)] -#![stable(feature = "stable", since = "1.0.0")] - -#[unstable(feature = "function", issue = "0")] -pub fn unstable() {} - - -#[stable(feature = "stable", since = "1.0.0")] -pub struct Foo { - #[unstable(feature = "struct_field", issue = "0")] - pub x: u8 -} - -impl Foo { - #[unstable(feature = "method", issue = "0")] - pub fn method(&self) {} -} - -#[stable(feature = "stable", since = "1.0.0")] -pub struct Bar { - #[unstable(feature = "struct2_field", issue = "0")] - pub x: u8 -} - -#[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] -#[macro_export] -macro_rules! call_unstable_allow { - () => { $crate::unstable() } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] -#[macro_export] -macro_rules! construct_unstable_allow { - ($e: expr) => { - $crate::Foo { x: $e } - } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] -#[macro_export] -macro_rules! call_method_allow { - ($e: expr) => { $e.method() } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] -#[macro_export] -macro_rules! access_field_allow { - ($e: expr) => { $e.x } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[allow_internal_unstable] -#[macro_export] -macro_rules! pass_through_allow { - ($e: expr) => { $e } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[macro_export] -macro_rules! call_unstable_noallow { - () => { $crate::unstable() } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[macro_export] -macro_rules! construct_unstable_noallow { - ($e: expr) => { - $crate::Foo { x: $e } - } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[macro_export] -macro_rules! call_method_noallow { - ($e: expr) => { $e.method() } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[macro_export] -macro_rules! access_field_noallow { - ($e: expr) => { $e.x } -} - -#[stable(feature = "stable", since = "1.0.0")] -#[macro_export] -macro_rules! pass_through_noallow { - ($e: expr) => { $e } -} diff --git a/src/test/compile-fail/auxiliary/issue-19163.rs b/src/test/compile-fail/auxiliary/issue-19163.rs deleted file mode 100644 index 76c5cdafd7c..00000000000 --- a/src/test/compile-fail/auxiliary/issue-19163.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[macro_export] -macro_rules! mywrite { - ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*))) -} diff --git a/src/test/compile-fail/auxiliary/issue-21146-inc.rs b/src/test/compile-fail/auxiliary/issue-21146-inc.rs deleted file mode 100644 index 1b740d112e9..00000000000 --- a/src/test/compile-fail/auxiliary/issue-21146-inc.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// include file for issue-21146.rs - -parse_error diff --git a/src/test/compile-fail/auxiliary/issue-29181.rs b/src/test/compile-fail/auxiliary/issue-29181.rs deleted file mode 100644 index 361f1ea5509..00000000000 --- a/src/test/compile-fail/auxiliary/issue-29181.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub mod foo { - pub use super::*; -} diff --git a/src/test/compile-fail/auxiliary/issue-30535.rs b/src/test/compile-fail/auxiliary/issue-30535.rs deleted file mode 100644 index 8d44e8d1016..00000000000 --- a/src/test/compile-fail/auxiliary/issue-30535.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub enum Foo { - FooV { data: () } -} diff --git a/src/test/compile-fail/auxiliary/issue-36881-aux.rs b/src/test/compile-fail/auxiliary/issue-36881-aux.rs deleted file mode 100644 index 33ac11feb2d..00000000000 --- a/src/test/compile-fail/auxiliary/issue-36881-aux.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Foo {} diff --git a/src/test/compile-fail/auxiliary/issue-52489.rs b/src/test/compile-fail/auxiliary/issue-52489.rs deleted file mode 100644 index 68d1ef8d776..00000000000 --- a/src/test/compile-fail/auxiliary/issue-52489.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![unstable(feature = "issue_52489_unstable", issue = "0")] -#![feature(staged_api)] diff --git a/src/test/compile-fail/auxiliary/issue_11680.rs b/src/test/compile-fail/auxiliary/issue_11680.rs deleted file mode 100644 index 18f78750b15..00000000000 --- a/src/test/compile-fail/auxiliary/issue_11680.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Foo { - Bar(isize) -} - -pub mod test { - enum Foo { - Bar(isize) - } -} diff --git a/src/test/compile-fail/auxiliary/issue_16725.rs b/src/test/compile-fail/auxiliary/issue_16725.rs deleted file mode 100644 index b3b04b4a5ac..00000000000 --- a/src/test/compile-fail/auxiliary/issue_16725.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - fn bar(); -} diff --git a/src/test/compile-fail/auxiliary/issue_17718_const_privacy.rs b/src/test/compile-fail/auxiliary/issue_17718_const_privacy.rs deleted file mode 100644 index 3901d73382f..00000000000 --- a/src/test/compile-fail/auxiliary/issue_17718_const_privacy.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub use foo::FOO2; - -pub const FOO: usize = 3; -const BAR: usize = 3; - -mod foo { - pub const FOO2: usize = 3; -} diff --git a/src/test/compile-fail/auxiliary/issue_1920.rs b/src/test/compile-fail/auxiliary/issue_1920.rs deleted file mode 100644 index 55065174ca7..00000000000 --- a/src/test/compile-fail/auxiliary/issue_1920.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Just exporting some type to test for correct diagnostics when this -// crate is pulled in at a non-root location in client crate. - -pub struct S; diff --git a/src/test/compile-fail/auxiliary/issue_21202.rs b/src/test/compile-fail/auxiliary/issue_21202.rs deleted file mode 100644 index afdbf78aa82..00000000000 --- a/src/test/compile-fail/auxiliary/issue_21202.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod A { - pub struct Foo; - impl Foo { - fn foo(&self) { } - } -} diff --git a/src/test/compile-fail/auxiliary/issue_30123_aux.rs b/src/test/compile-fail/auxiliary/issue_30123_aux.rs deleted file mode 100644 index f60311a9400..00000000000 --- a/src/test/compile-fail/auxiliary/issue_30123_aux.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker::PhantomData; - -pub struct Directed; -pub struct Undirected; - -pub struct Graph { - nodes: Vec>, - edges: Vec>, - ty: PhantomData, -} - - -impl Graph { - pub fn new() -> Self { - Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData} - } -} - -impl Graph { - pub fn new_undirected() -> Self { - Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData} - } -} diff --git a/src/test/compile-fail/auxiliary/issue_41549.rs b/src/test/compile-fail/auxiliary/issue_41549.rs deleted file mode 100644 index 5a6db789282..00000000000 --- a/src/test/compile-fail/auxiliary/issue_41549.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub trait Trait { - const CONST: u32; -} diff --git a/src/test/compile-fail/auxiliary/issue_5844_aux.rs b/src/test/compile-fail/auxiliary/issue_5844_aux.rs deleted file mode 100644 index 7fa937e93b3..00000000000 --- a/src/test/compile-fail/auxiliary/issue_5844_aux.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern "C" { - pub fn rand() -> u32; -} diff --git a/src/test/compile-fail/auxiliary/lifetime_bound_will_change_warning_lib.rs b/src/test/compile-fail/auxiliary/lifetime_bound_will_change_warning_lib.rs deleted file mode 100644 index 95f8b39c487..00000000000 --- a/src/test/compile-fail/auxiliary/lifetime_bound_will_change_warning_lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -// Helper for testing that we get suitable warnings when lifetime -// bound change will cause breakage. - -pub fn just_ref(x: &Fn()) { -} - -pub fn ref_obj(x: &Box) { - // this will change to &Box... -} diff --git a/src/test/compile-fail/auxiliary/lint_output_format.rs b/src/test/compile-fail/auxiliary/lint_output_format.rs deleted file mode 100644 index 6ba66f3e45f..00000000000 --- a/src/test/compile-fail/auxiliary/lint_output_format.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="lint_output_format"] -#![crate_type = "lib"] -#![feature(staged_api)] -#![unstable(feature = "unstable_test_feature", issue = "0")] - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub fn foo() -> usize { - 20 -} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub fn bar() -> usize { - 40 -} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub fn baz() -> usize { - 30 -} diff --git a/src/test/compile-fail/auxiliary/lint_stability.rs b/src/test/compile-fail/auxiliary/lint_stability.rs deleted file mode 100644 index 5547458abbe..00000000000 --- a/src/test/compile-fail/auxiliary/lint_stability.rs +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="lint_stability"] -#![crate_type = "lib"] -#![feature(staged_api)] -#![feature(associated_type_defaults)] -#![stable(feature = "lint_stability", since = "1.0.0")] - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub fn deprecated() {} -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub fn deprecated_text() {} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "99.99.99", reason = "text")] -pub fn deprecated_future() {} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub fn deprecated_unstable() {} -#[unstable(feature = "unstable_test_feature", issue = "0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub fn deprecated_unstable_text() {} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub fn unstable() {} -#[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] -pub fn unstable_text() {} - -#[stable(feature = "rust1", since = "1.0.0")] -pub fn stable() {} -#[stable(feature = "rust1", since = "1.0.0")] -pub fn stable_text() {} - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct MethodTester; - -impl MethodTester { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated(&self) {} - #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated_unstable_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn method_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - pub fn method_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable_text(&self) {} -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -pub trait Trait { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated(&self) {} - #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated_unstable_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - fn trait_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - fn trait_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable_text(&self) {} -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -pub trait TraitWithAssociatedTypes { - #[unstable(feature = "unstable_test_feature", issue = "0")] - type TypeUnstable = u8; - #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - type TypeDeprecated = u8; -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -impl Trait for MethodTester {} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub trait UnstableTrait { fn dummy(&self) { } } - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub trait DeprecatedTrait { - #[stable(feature = "stable_test_feature", since = "1.0.0")] fn dummy(&self) { } -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct DeprecatedStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize -} -#[unstable(feature = "unstable_test_feature", issue = "0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct DeprecatedUnstableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize -} -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub struct UnstableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize -} -#[stable(feature = "rust1", since = "1.0.0")] -pub struct StableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize -} -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub enum UnstableEnum {} -#[stable(feature = "rust1", since = "1.0.0")] -pub enum StableEnum {} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct DeprecatedUnitStruct; -#[unstable(feature = "unstable_test_feature", issue = "0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct DeprecatedUnstableUnitStruct; -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub struct UnstableUnitStruct; -#[stable(feature = "rust1", since = "1.0.0")] -pub struct StableUnitStruct; - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -pub enum Enum { - #[stable(feature = "stable_test_feature", since = "1.0.0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - DeprecatedVariant, - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - DeprecatedUnstableVariant, - #[unstable(feature = "unstable_test_feature", issue = "0")] - UnstableVariant, - - #[stable(feature = "rust1", since = "1.0.0")] - StableVariant, -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct DeprecatedTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); -#[unstable(feature = "unstable_test_feature", issue = "0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct DeprecatedUnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub struct UnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); -#[stable(feature = "rust1", since = "1.0.0")] -pub struct StableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[macro_export] -macro_rules! macro_test { - () => (deprecated()); -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[macro_export] -macro_rules! macro_test_arg { - ($func:expr) => ($func); -} - -#[stable(feature = "stable_test_feature", since = "1.0.0")] -#[macro_export] -macro_rules! macro_test_arg_nested { - ($func:ident) => (macro_test_arg!($func())); -} diff --git a/src/test/compile-fail/auxiliary/lint_stability_fields.rs b/src/test/compile-fail/auxiliary/lint_stability_fields.rs deleted file mode 100644 index 6b79c36fc05..00000000000 --- a/src/test/compile-fail/auxiliary/lint_stability_fields.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(staged_api)] -#![stable(feature = "rust1", since = "1.0.0")] - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Stable { - #[stable(feature = "rust1", since = "1.0.0")] - pub inherit: u8, // it's a lie (stable doesn't inherit) - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub override2: u8, -} - -#[stable(feature = "rust1", since = "1.0.0")] -pub struct Stable2(#[stable(feature = "rust1", since = "1.0.0")] pub u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] pub u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8); - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub struct Unstable { - pub inherit: u8, - #[stable(feature = "rust1", since = "1.0.0")] - pub override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub override2: u8, -} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub struct Unstable2(pub u8, - #[stable(feature = "rust1", since = "1.0.0")] pub u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8); - -#[unstable(feature = "unstable_test_feature", issue = "0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct Deprecated { - pub inherit: u8, - #[stable(feature = "rust1", since = "1.0.0")] - pub override1: u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub override2: u8, -} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -#[rustc_deprecated(since = "1.0.0", reason = "text")] -pub struct Deprecated2(pub u8, - #[stable(feature = "rust1", since = "1.0.0")] pub u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] pub u8); diff --git a/src/test/compile-fail/auxiliary/lint_unused_extern_crate.rs b/src/test/compile-fail/auxiliary/lint_unused_extern_crate.rs deleted file mode 100644 index 2661b1f4eb4..00000000000 --- a/src/test/compile-fail/auxiliary/lint_unused_extern_crate.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/compile-fail/auxiliary/lint_unused_extern_crate2.rs b/src/test/compile-fail/auxiliary/lint_unused_extern_crate2.rs deleted file mode 100644 index b61667cfd88..00000000000 --- a/src/test/compile-fail/auxiliary/lint_unused_extern_crate2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/compile-fail/auxiliary/lint_unused_extern_crate3.rs b/src/test/compile-fail/auxiliary/lint_unused_extern_crate3.rs deleted file mode 100644 index b61667cfd88..00000000000 --- a/src/test/compile-fail/auxiliary/lint_unused_extern_crate3.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/compile-fail/auxiliary/lint_unused_extern_crate4.rs b/src/test/compile-fail/auxiliary/lint_unused_extern_crate4.rs deleted file mode 100644 index fc4bca865c9..00000000000 --- a/src/test/compile-fail/auxiliary/lint_unused_extern_crate4.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/compile-fail/auxiliary/lint_unused_extern_crate5.rs b/src/test/compile-fail/auxiliary/lint_unused_extern_crate5.rs deleted file mode 100644 index fc4bca865c9..00000000000 --- a/src/test/compile-fail/auxiliary/lint_unused_extern_crate5.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/compile-fail/auxiliary/lto-duplicate-symbols1.rs b/src/test/compile-fail/auxiliary/lto-duplicate-symbols1.rs deleted file mode 100644 index ea09327bd19..00000000000 --- a/src/test/compile-fail/auxiliary/lto-duplicate-symbols1.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -#[no_mangle] -pub extern fn foo() {} diff --git a/src/test/compile-fail/auxiliary/lto-duplicate-symbols2.rs b/src/test/compile-fail/auxiliary/lto-duplicate-symbols2.rs deleted file mode 100644 index ea09327bd19..00000000000 --- a/src/test/compile-fail/auxiliary/lto-duplicate-symbols2.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -#[no_mangle] -pub extern fn foo() {} diff --git a/src/test/compile-fail/auxiliary/macro_crate_nonterminal.rs b/src/test/compile-fail/auxiliary/macro_crate_nonterminal.rs deleted file mode 100644 index 4f75e2b5d75..00000000000 --- a/src/test/compile-fail/auxiliary/macro_crate_nonterminal.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn increment(x: usize) -> usize { - x + 1 -} - -#[macro_export] -macro_rules! increment { - ($x:expr) => ($crate::increment($x)) -} - -pub fn check_local() { - assert_eq!(increment!(3), 4); -} diff --git a/src/test/compile-fail/auxiliary/namespace-mix.rs b/src/test/compile-fail/auxiliary/namespace-mix.rs deleted file mode 100644 index d82e9bb7022..00000000000 --- a/src/test/compile-fail/auxiliary/namespace-mix.rs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod c { - pub struct S {} - pub struct TS(); - pub struct US; - pub enum E { - V {}, - TV(), - UV, - } - - pub struct Item; -} - -pub mod xm1 { - pub use ::c::*; - pub type S = ::c::Item; -} -pub mod xm2 { - pub use ::c::*; - pub const S: ::c::Item = ::c::Item; -} - -pub mod xm3 { - pub use ::c::*; - pub type TS = ::c::Item; -} -pub mod xm4 { - pub use ::c::*; - pub const TS: ::c::Item = ::c::Item; -} - -pub mod xm5 { - pub use ::c::*; - pub type US = ::c::Item; -} -pub mod xm6 { - pub use ::c::*; - pub const US: ::c::Item = ::c::Item; -} - -pub mod xm7 { - pub use ::c::E::*; - pub type V = ::c::Item; -} -pub mod xm8 { - pub use ::c::E::*; - pub const V: ::c::Item = ::c::Item; -} - -pub mod xm9 { - pub use ::c::E::*; - pub type TV = ::c::Item; -} -pub mod xmA { - pub use ::c::E::*; - pub const TV: ::c::Item = ::c::Item; -} - -pub mod xmB { - pub use ::c::E::*; - pub type UV = ::c::Item; -} -pub mod xmC { - pub use ::c::E::*; - pub const UV: ::c::Item = ::c::Item; -} diff --git a/src/test/compile-fail/auxiliary/namespaced_enums.rs b/src/test/compile-fail/auxiliary/namespaced_enums.rs deleted file mode 100644 index 3bf39b788db..00000000000 --- a/src/test/compile-fail/auxiliary/namespaced_enums.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub enum Foo { - A, - B(isize), - C { a: isize }, -} - -impl Foo { - pub fn foo() {} - pub fn bar(&self) {} -} diff --git a/src/test/compile-fail/auxiliary/noexporttypelib.rs b/src/test/compile-fail/auxiliary/noexporttypelib.rs deleted file mode 100644 index 5ae8e0d298e..00000000000 --- a/src/test/compile-fail/auxiliary/noexporttypelib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub type oint = Option; -pub fn foo() -> oint { Some(3) } diff --git a/src/test/compile-fail/auxiliary/orphan_check_diagnostics.rs b/src/test/compile-fail/auxiliary/orphan_check_diagnostics.rs deleted file mode 100644 index cf3e9903b5a..00000000000 --- a/src/test/compile-fail/auxiliary/orphan_check_diagnostics.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait RemoteTrait { fn dummy(&self) { } } diff --git a/src/test/compile-fail/auxiliary/privacy_tuple_struct.rs b/src/test/compile-fail/auxiliary/privacy_tuple_struct.rs deleted file mode 100644 index 141b6bdd604..00000000000 --- a/src/test/compile-fail/auxiliary/privacy_tuple_struct.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct A(()); -pub struct B(isize); -pub struct C(pub isize, isize); -pub struct D(pub isize); diff --git a/src/test/compile-fail/auxiliary/private-inferred-type.rs b/src/test/compile-fail/auxiliary/private-inferred-type.rs deleted file mode 100644 index fc43765f63c..00000000000 --- a/src/test/compile-fail/auxiliary/private-inferred-type.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(decl_macro)] - -fn priv_fn() {} -static PRIV_STATIC: u8 = 0; -enum PrivEnum { Variant } -pub enum PubEnum { Variant } -trait PrivTrait { fn method() {} } -impl PrivTrait for u8 {} -pub trait PubTrait { fn method() {} } -impl PubTrait for u8 {} -struct PrivTupleStruct(u8); -pub struct PubTupleStruct(u8); -impl PubTupleStruct { fn method() {} } - -struct Priv; -pub type Alias = Priv; -pub struct Pub(pub T); - -impl Pub { - pub fn static_method() {} -} -impl Pub { - fn priv_method(&self) {} -} - -pub macro m() { - priv_fn; - PRIV_STATIC; - PrivEnum::Variant; - PubEnum::Variant; - ::method; - ::method; - PrivTupleStruct; - PubTupleStruct; - Pub(0u8).priv_method(); -} diff --git a/src/test/compile-fail/auxiliary/private_trait_xc.rs b/src/test/compile-fail/auxiliary/private_trait_xc.rs deleted file mode 100644 index 37ee10c8d37..00000000000 --- a/src/test/compile-fail/auxiliary/private_trait_xc.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo {} diff --git a/src/test/compile-fail/auxiliary/rbmtp_cross_crate_lib.rs b/src/test/compile-fail/auxiliary/rbmtp_cross_crate_lib.rs deleted file mode 100644 index f49ac4fc8e4..00000000000 --- a/src/test/compile-fail/auxiliary/rbmtp_cross_crate_lib.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that method bounds declared on traits/impls in a cross-crate -// scenario work. This is the library portion of the test. - -pub enum MaybeOwned<'a> { - Owned(isize), - Borrowed(&'a isize) -} - -pub struct Inv<'a> { // invariant w/r/t 'a - x: &'a mut &'a isize -} - -// I encountered a bug at some point with encoding the IntoMaybeOwned -// trait, so I'll use that as the template for this test. -pub trait IntoMaybeOwned<'a> { - fn into_maybe_owned(self) -> MaybeOwned<'a>; - - // Note: without this `into_inv` method, the trait is - // contravariant w/r/t `'a`, since if you look strictly at the - // interface, it only returns `'a`. This complicates the - // downstream test since it wants invariance to force an error. - // Hence we add this method. - fn into_inv(self) -> Inv<'a>; - - fn bigger_region<'b:'a>(self, b: Inv<'b>); -} - -impl<'a> IntoMaybeOwned<'a> for Inv<'a> { - fn into_maybe_owned(self) -> MaybeOwned<'a> { panic!() } - fn into_inv(self) -> Inv<'a> { panic!() } - fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() } -} diff --git a/src/test/compile-fail/auxiliary/recursive_reexports.rs b/src/test/compile-fail/auxiliary/recursive_reexports.rs deleted file mode 100644 index 1186e3d62f7..00000000000 --- a/src/test/compile-fail/auxiliary/recursive_reexports.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod foo { - pub use foo; -} diff --git a/src/test/compile-fail/auxiliary/rmeta_meta.rs b/src/test/compile-fail/auxiliary/rmeta_meta.rs deleted file mode 100644 index 4207fc2373b..00000000000 --- a/src/test/compile-fail/auxiliary/rmeta_meta.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: --emit=metadata - -#![crate_type="rlib"] - -pub struct Foo { - pub field: i32, -} diff --git a/src/test/compile-fail/auxiliary/rmeta_rlib.rs b/src/test/compile-fail/auxiliary/rmeta_rlib.rs deleted file mode 100644 index 6096c4df05b..00000000000 --- a/src/test/compile-fail/auxiliary/rmeta_rlib.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -pub struct Foo { - pub field: i32, -} diff --git a/src/test/compile-fail/auxiliary/some-panic-impl.rs b/src/test/compile-fail/auxiliary/some-panic-impl.rs deleted file mode 100644 index db16ac325ac..00000000000 --- a/src/test/compile-fail/auxiliary/some-panic-impl.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![feature(panic_implementation)] -#![no_std] - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic(info: &PanicInfo) -> ! { - loop {} -} diff --git a/src/test/compile-fail/auxiliary/stability_attribute_issue.rs b/src/test/compile-fail/auxiliary/stability_attribute_issue.rs deleted file mode 100644 index 1ee623c34fb..00000000000 --- a/src/test/compile-fail/auxiliary/stability_attribute_issue.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(staged_api)] -#![stable(feature = "stable_test_feature", since = "1.2.0")] - - -#[unstable(feature = "unstable_test_feature", issue = "1")] -pub fn unstable() {} - -#[unstable(feature = "unstable_test_feature", reason = "message", issue = "2")] -pub fn unstable_msg() {} diff --git a/src/test/compile-fail/auxiliary/stability_cfg1.rs b/src/test/compile-fail/auxiliary/stability_cfg1.rs deleted file mode 100644 index c839993b047..00000000000 --- a/src/test/compile-fail/auxiliary/stability_cfg1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![cfg_attr(foo, experimental)] -#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] -#![feature(staged_api)] diff --git a/src/test/compile-fail/auxiliary/stability_cfg2.rs b/src/test/compile-fail/auxiliary/stability_cfg2.rs deleted file mode 100644 index a59f4b4e8f4..00000000000 --- a/src/test/compile-fail/auxiliary/stability_cfg2.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:--cfg foo - -#![cfg_attr(foo, unstable(feature = "unstable_test_feature", issue = "0"))] -#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] -#![feature(staged_api)] diff --git a/src/test/compile-fail/auxiliary/static_priv_by_default.rs b/src/test/compile-fail/auxiliary/static_priv_by_default.rs deleted file mode 100644 index 73597e51f08..00000000000 --- a/src/test/compile-fail/auxiliary/static_priv_by_default.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -static private: isize = 0; -pub static public: isize = 0; - -pub struct A(()); - -impl A { - fn foo() {} -} - -mod foo { - pub static a: isize = 0; - pub fn b() {} - pub struct c; - pub enum d {} - pub type e = isize; - - pub struct A(()); - - impl A { - fn foo() {} - } - - // these are public so the parent can re-export them. - pub static reexported_a: isize = 0; - pub fn reexported_b() {} - pub struct reexported_c; - pub enum reexported_d {} - pub type reexported_e = isize; -} - -pub mod bar { - pub use foo::reexported_a as e; - pub use foo::reexported_b as f; - pub use foo::reexported_c as g; - pub use foo::reexported_d as h; - pub use foo::reexported_e as i; -} - -pub static a: isize = 0; -pub fn b() {} -pub struct c; -pub enum d {} -pub type e = isize; - -static j: isize = 0; -fn k() {} -struct l; -enum m {} -type n = isize; diff --git a/src/test/compile-fail/auxiliary/struct_field_privacy.rs b/src/test/compile-fail/auxiliary/struct_field_privacy.rs deleted file mode 100644 index 5fea97da03e..00000000000 --- a/src/test/compile-fail/auxiliary/struct_field_privacy.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct A { - a: isize, - pub b: isize, -} - -pub struct B { - pub a: isize, - b: isize, -} diff --git a/src/test/compile-fail/auxiliary/struct_variant_privacy.rs b/src/test/compile-fail/auxiliary/struct_variant_privacy.rs deleted file mode 100644 index 40868fa3f70..00000000000 --- a/src/test/compile-fail/auxiliary/struct_variant_privacy.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Bar { - Baz { a: isize } -} diff --git a/src/test/compile-fail/auxiliary/tdticc_coherence_lib.rs b/src/test/compile-fail/auxiliary/tdticc_coherence_lib.rs deleted file mode 100644 index f6f7a250174..00000000000 --- a/src/test/compile-fail/auxiliary/tdticc_coherence_lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits, core)] -#![crate_type = "rlib"] - -pub auto trait DefaultedTrait { } - -pub struct Something { t: T } diff --git a/src/test/compile-fail/auxiliary/trait_bounds_on_structs_and_enums_xc.rs b/src/test/compile-fail/auxiliary/trait_bounds_on_structs_and_enums_xc.rs deleted file mode 100644 index 29cb0bc176a..00000000000 --- a/src/test/compile-fail/auxiliary/trait_bounds_on_structs_and_enums_xc.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Trait { - fn dummy(&self) { } -} - -pub struct Foo { - pub x: T, -} - -pub enum Bar { - ABar(isize), - BBar(T), - CBar(usize), -} diff --git a/src/test/compile-fail/auxiliary/trait_impl_conflict.rs b/src/test/compile-fail/auxiliary/trait_impl_conflict.rs deleted file mode 100644 index 3190ce430ad..00000000000 --- a/src/test/compile-fail/auxiliary/trait_impl_conflict.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Foo { - fn foo() {} -} - -impl Foo for isize { -} diff --git a/src/test/compile-fail/auxiliary/trait_safety_lib.rs b/src/test/compile-fail/auxiliary/trait_safety_lib.rs deleted file mode 100644 index 585a756fd07..00000000000 --- a/src/test/compile-fail/auxiliary/trait_safety_lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Simple smoke test that unsafe traits can be compiled etc. - -pub unsafe trait Foo { - fn foo(&self) -> isize; -} - -unsafe impl Foo for isize { - fn foo(&self) -> isize { *self } -} diff --git a/src/test/compile-fail/auxiliary/trait_superkinds_in_metadata.rs b/src/test/compile-fail/auxiliary/trait_superkinds_in_metadata.rs deleted file mode 100644 index 0fa2d3459f4..00000000000 --- a/src/test/compile-fail/auxiliary/trait_superkinds_in_metadata.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test library crate for cross-crate usages of traits inheriting -// from the builtin kinds. Mostly tests metadata correctness. - -#![crate_type="lib"] - -pub trait RequiresShare : Sync { } -pub trait RequiresRequiresShareAndSend : RequiresShare + Send { } -pub trait RequiresCopy : Copy { } diff --git a/src/test/compile-fail/auxiliary/two_macros.rs b/src/test/compile-fail/auxiliary/two_macros.rs deleted file mode 100644 index 060960f0dbc..00000000000 --- a/src/test/compile-fail/auxiliary/two_macros.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_export] -macro_rules! macro_one { () => ("one") } - -#[macro_export] -macro_rules! macro_two { () => ("two") } diff --git a/src/test/compile-fail/auxiliary/unreachable_variant.rs b/src/test/compile-fail/auxiliary/unreachable_variant.rs deleted file mode 100644 index 8ca85f20ab2..00000000000 --- a/src/test/compile-fail/auxiliary/unreachable_variant.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod super_sekrit { - pub enum sooper_sekrit { - quux, baz - } -} diff --git a/src/test/compile-fail/auxiliary/unstable-macros.rs b/src/test/compile-fail/auxiliary/unstable-macros.rs deleted file mode 100644 index 836164a721a..00000000000 --- a/src/test/compile-fail/auxiliary/unstable-macros.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(staged_api)] -#![stable(feature = "unit_test", since = "1.0.0")] - -#[unstable(feature = "unstable_macros", issue = "0")] -#[macro_export] -macro_rules! unstable_macro{ () => () } diff --git a/src/test/compile-fail/auxiliary/use_from_trait_xc.rs b/src/test/compile-fail/auxiliary/use_from_trait_xc.rs deleted file mode 100644 index 9a6d176d088..00000000000 --- a/src/test/compile-fail/auxiliary/use_from_trait_xc.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub use self::sub::{Bar, Baz}; - -pub trait Trait { - fn foo(&self); - type Assoc; - const CONST: u32; -} - -struct Foo; - -impl Foo { - pub fn new() {} - - pub const C: u32 = 0; -} - -mod sub { - pub struct Bar; - - impl Bar { - pub fn new() {} - } - - pub enum Baz {} - - impl Baz { - pub fn new() {} - } -} diff --git a/src/test/compile-fail/auxiliary/variant-namespacing.rs b/src/test/compile-fail/auxiliary/variant-namespacing.rs deleted file mode 100644 index d7fd2968495..00000000000 --- a/src/test/compile-fail/auxiliary/variant-namespacing.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub enum XE { - XStruct { a: u8 }, - XTuple(u8), - XUnit, -} diff --git a/src/test/compile-fail/auxiliary/weak-lang-items.rs b/src/test/compile-fail/auxiliary/weak-lang-items.rs deleted file mode 100644 index 6434e62b6f7..00000000000 --- a/src/test/compile-fail/auxiliary/weak-lang-items.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -// This aux-file will require the eh_personality function to be codegen'd, but -// it hasn't been defined just yet. Make sure we don't explode. - -#![no_std] -#![crate_type = "rlib"] - -struct A; - -impl core::ops::Drop for A { - fn drop(&mut self) {} -} - -pub fn foo() { - let _a = A; - panic!("wut"); -} - -mod std { - pub use core::{option, fmt}; -} diff --git a/src/test/compile-fail/auxiliary/xc_private_method_lib.rs b/src/test/compile-fail/auxiliary/xc_private_method_lib.rs deleted file mode 100644 index 5e7bc61943b..00000000000 --- a/src/test/compile-fail/auxiliary/xc_private_method_lib.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub struct Struct { - pub x: isize -} - -impl Struct { - fn static_meth_struct() -> Struct { - Struct { x: 1 } - } - - fn meth_struct(&self) -> isize { - self.x - } -} - -pub enum Enum { - Variant1(isize), - Variant2(isize) -} - -impl Enum { - fn static_meth_enum() -> Enum { - Enum::Variant2(10) - } - - fn meth_enum(&self) -> isize { - match *self { - Enum::Variant1(x) | - Enum::Variant2(x) => x - } - } -} diff --git a/src/test/compile-fail/auxiliary/xcrate_unit_struct.rs b/src/test/compile-fail/auxiliary/xcrate_unit_struct.rs deleted file mode 100644 index 7a69be2b06c..00000000000 --- a/src/test/compile-fail/auxiliary/xcrate_unit_struct.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -// used by the rpass test - -#[derive(Copy, Clone)] -pub struct Struct; - -#[derive(Copy, Clone)] -pub enum Unit { - UnitVariant, - Argument(Struct) -} - -#[derive(Copy, Clone)] -pub struct TupleStruct(pub usize, pub &'static str); - -// used by the cfail test - -#[derive(Copy, Clone)] -pub struct StructWithFields { - foo: isize, -} - -#[derive(Copy, Clone)] -pub enum EnumWithVariants { - EnumVariant, - EnumVariantArg(isize) -} diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs deleted file mode 100644 index 5547d19868d..00000000000 --- a/src/test/compile-fail/bad-const-type.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static i: String = 10; -//~^ ERROR mismatched types -//~| expected type `std::string::String` -//~| found type `{integer}` -//~| expected struct `std::string::String`, found integral variable -fn main() { println!("{}", i); } diff --git a/src/test/compile-fail/bad-env-capture.rs b/src/test/compile-fail/bad-env-capture.rs deleted file mode 100644 index 6a5e4cfef89..00000000000 --- a/src/test/compile-fail/bad-env-capture.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: can't capture dynamic environment in a fn item -fn foo() { - let x: isize; - fn bar() { log(debug, x); } -} -fn main() { foo(); } diff --git a/src/test/compile-fail/bad-env-capture2.rs b/src/test/compile-fail/bad-env-capture2.rs deleted file mode 100644 index cf67c73c539..00000000000 --- a/src/test/compile-fail/bad-env-capture2.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: can't capture dynamic environment in a fn item -fn foo(x: isize) { - fn bar() { log(debug, x); } -} -fn main() { foo(2); } diff --git a/src/test/compile-fail/bad-env-capture3.rs b/src/test/compile-fail/bad-env-capture3.rs deleted file mode 100644 index a30c6770b87..00000000000 --- a/src/test/compile-fail/bad-env-capture3.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: can't capture dynamic environment in a fn item -fn foo(x: isize) { - fn mth() { - fn bar() { log(debug, x); } - } -} - -fn main() { foo(2); } diff --git a/src/test/compile-fail/bad-expr-lhs.rs b/src/test/compile-fail/bad-expr-lhs.rs deleted file mode 100644 index c7d2f2c472f..00000000000 --- a/src/test/compile-fail/bad-expr-lhs.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - 1 = 2; //~ ERROR invalid left-hand side expression - 1 += 2; //~ ERROR invalid left-hand side expression - (1, 2) = (3, 4); //~ ERROR invalid left-hand side expression - - let (a, b) = (1, 2); - (a, b) = (3, 4); //~ ERROR invalid left-hand side expression - - None = Some(3); //~ ERROR invalid left-hand side expression -} diff --git a/src/test/compile-fail/bad-expr-path.rs b/src/test/compile-fail/bad-expr-path.rs deleted file mode 100644 index bd62dc66377..00000000000 --- a/src/test/compile-fail/bad-expr-path.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m1 {} - -fn main(arguments: Vec) { //~ ERROR main function has wrong type - log(debug, m1::arguments); - //~^ ERROR cannot find function `log` in this scope - //~| ERROR cannot find value `debug` in this scope - //~| ERROR cannot find value `arguments` in module `m1` -} diff --git a/src/test/compile-fail/bad-expr-path2.rs b/src/test/compile-fail/bad-expr-path2.rs deleted file mode 100644 index 06b72d1ed47..00000000000 --- a/src/test/compile-fail/bad-expr-path2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m1 { - pub mod arguments {} -} - -fn main(arguments: Vec) { //~ ERROR main function has wrong type - log(debug, m1::arguments); - //~^ ERROR cannot find function `log` in this scope - //~| ERROR cannot find value `debug` in this scope - //~| ERROR expected value, found module `m1::arguments` -} diff --git a/src/test/compile-fail/bad-extern-link-attrs.rs b/src/test/compile-fail/bad-extern-link-attrs.rs deleted file mode 100644 index ff63d4b739a..00000000000 --- a/src/test/compile-fail/bad-extern-link-attrs.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link()] //~ ERROR: specified without `name = -#[link(name = "")] //~ ERROR: with empty name -#[link(name = "foo")] -#[link(name = "foo", kind = "bar")] //~ ERROR: unknown kind -extern {} - -fn main() {} diff --git a/src/test/compile-fail/bad-intrinsic-monomorphization.rs b/src/test/compile-fail/bad-intrinsic-monomorphization.rs deleted file mode 100644 index 2fe94d43acd..00000000000 --- a/src/test/compile-fail/bad-intrinsic-monomorphization.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics, core_intrinsics)] -#![allow(warnings)] -#![crate_type = "rlib"] - -// Bad monomorphizations could previously cause LLVM asserts even though the -// error was caught in the compiler. - -extern "platform-intrinsic" { - fn simd_add(x: T, y: T) -> T; -} - -use std::intrinsics; - -#[derive(Copy, Clone)] -pub struct Foo(i64); - -pub unsafe fn test_cttz(v: Foo) -> Foo { - intrinsics::cttz(v) - //~^ ERROR `cttz` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_fadd_fast(a: Foo, b: Foo) -> Foo { - intrinsics::fadd_fast(a, b) - //~^ ERROR `fadd_fast` intrinsic: expected basic float type, found `Foo` -} - -pub unsafe fn test_simd_add(a: Foo, b: Foo) -> Foo { - simd_add(a, b) - //~^ ERROR `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` -} diff --git a/src/test/compile-fail/bad-lint-cap.rs b/src/test/compile-fail/bad-lint-cap.rs deleted file mode 100644 index cb9c347af60..00000000000 --- a/src/test/compile-fail/bad-lint-cap.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --cap-lints test -// error-pattern: unknown lint level: `test` - -fn main() {} diff --git a/src/test/compile-fail/bad-lint-cap2.rs b/src/test/compile-fail/bad-lint-cap2.rs deleted file mode 100644 index cb9fb973a01..00000000000 --- a/src/test/compile-fail/bad-lint-cap2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --cap-lints deny - -#![warn(unused)] -#![deny(warnings)] - -use std::option; //~ ERROR - -fn main() {} diff --git a/src/test/compile-fail/bad-lint-cap3.rs b/src/test/compile-fail/bad-lint-cap3.rs deleted file mode 100644 index c9394954c5f..00000000000 --- a/src/test/compile-fail/bad-lint-cap3.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --cap-lints warn - -#![warn(unused)] -#![deny(warnings)] -#![feature(rustc_attrs)] - -use std::option; //~ WARN - -#[rustc_error] -fn main() {} //~ ERROR: compilation successful - diff --git a/src/test/compile-fail/bad-main.rs b/src/test/compile-fail/bad-main.rs deleted file mode 100644 index b73b4a6af6e..00000000000 --- a/src/test/compile-fail/bad-main.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main(x: isize) { } //~ ERROR: main function has wrong type [E0580] diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs deleted file mode 100644 index 7cef3f13dfc..00000000000 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() { - 1.bar::(); //~ ERROR `T` cannot be sent between threads safely -} - -trait bar { - fn bar(&self); -} - -impl bar for usize { - fn bar(&self) { - } -} - -fn main() {} diff --git a/src/test/compile-fail/bad-mid-path-type-params.rs b/src/test/compile-fail/bad-mid-path-type-params.rs deleted file mode 100644 index 20ac757354f..00000000000 --- a/src/test/compile-fail/bad-mid-path-type-params.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S { - contents: T, -} - -impl S { - fn new(x: T, _: U) -> S { - S { - contents: x, - } - } -} - -trait Trait { - fn new(x: T, y: U) -> Self; -} - -struct S2 { - contents: isize, -} - -impl Trait for S2 { - fn new(x: isize, _: U) -> S2 { - S2 { - contents: x, - } - } -} - -fn foo<'a>() { - let _ = S::new::(1, 1.0); - //~^ ERROR too many type parameters provided - - let _ = S::<'a,isize>::new::(1, 1.0); - //~^ ERROR wrong number of lifetime parameters - - let _: S2 = Trait::new::(1, 1.0); - //~^ ERROR too many type parameters provided - - let _: S2 = Trait::<'a,isize>::new::(1, 1.0); - //~^ ERROR too many lifetime parameters provided -} - -fn main() {} diff --git a/src/test/compile-fail/bad-module.rs b/src/test/compile-fail/bad-module.rs deleted file mode 100644 index 6987d06ef12..00000000000 --- a/src/test/compile-fail/bad-module.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let foo = thing::len(Vec::new()); - //~^ ERROR failed to resolve. Use of undeclared type or module `thing` - - let foo = foo::bar::baz(); - //~^ ERROR failed to resolve. Use of undeclared type or module `foo` -} diff --git a/src/test/compile-fail/bad-sized.rs b/src/test/compile-fail/bad-sized.rs deleted file mode 100644 index a58aebee77b..00000000000 --- a/src/test/compile-fail/bad-sized.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait {} - -pub fn main() { - let x: Vec = Vec::new(); - //~^ ERROR only auto traits can be used as additional traits in a trait object - //~| ERROR the size for values of type - //~| ERROR the size for values of type -} diff --git a/src/test/compile-fail/bad-type-env-capture.rs b/src/test/compile-fail/bad-type-env-capture.rs deleted file mode 100644 index c1547dd82b3..00000000000 --- a/src/test/compile-fail/bad-type-env-capture.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() { - fn bar(b: T) { } //~ ERROR can't use type parameters from outer -} -fn main() { } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs deleted file mode 100644 index 2a5c7136dc3..00000000000 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct X { x: (), } - -impl Drop for X { - fn drop(&mut self) { - println!("destructor runs"); - } -} - -fn main() { - let x = Some((X { x: () }, X { x: () })); - match x { - Some((ref _y, _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => panic!() - } -} diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs deleted file mode 100644 index 3d3ccb606bf..00000000000 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct X { x: (), } - -impl Drop for X { - fn drop(&mut self) { - println!("destructor runs"); - } -} - -enum double_option { some2(T,U), none2 } - -fn main() { - let x = double_option::some2(X { x: () }, X { x: () }); - match x { - double_option::some2(ref _y, _z) => { }, - //~^ ERROR cannot bind by-move and by-ref in the same pattern - double_option::none2 => panic!() - } -} diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs deleted file mode 100644 index 8c7542fbe6b..00000000000 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct X { x: (), } - -impl Drop for X { - fn drop(&mut self) { - println!("destructor runs"); - } -} - -fn main() { - let x = Some((X { x: () }, X { x: () })); - match x { - Some((_y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => panic!() - } -} diff --git a/src/test/compile-fail/bind-by-move-no-guards.rs b/src/test/compile-fail/bind-by-move-no-guards.rs deleted file mode 100644 index bb6060f2543..00000000000 --- a/src/test/compile-fail/bind-by-move-no-guards.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::sync::mpsc::channel; - -fn main() { - let (tx, rx) = channel(); - let x = Some(rx); - tx.send(false); - match x { - Some(z) if z.recv().unwrap() => { panic!() }, - //~^ ERROR cannot bind by-move into a pattern guard - Some(z) => { assert!(!z.recv().unwrap()); }, - None => panic!() - } -} diff --git a/src/test/compile-fail/binop-bitxor-str.rs b/src/test/compile-fail/binop-bitxor-str.rs deleted file mode 100644 index 3f26e3ce904..00000000000 --- a/src/test/compile-fail/binop-bitxor-str.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:`^` cannot be applied to type `std::string::String` - -fn main() { let x = "a".to_string() ^ "b".to_string(); } diff --git a/src/test/compile-fail/binop-consume-args.rs b/src/test/compile-fail/binop-consume-args.rs deleted file mode 100644 index c525a67c7e9..00000000000 --- a/src/test/compile-fail/binop-consume-args.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that binary operators consume their arguments - -use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitXor, BitOr, Shl, Shr}; - -fn add, B>(lhs: A, rhs: B) { - lhs + rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn sub, B>(lhs: A, rhs: B) { - lhs - rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn mul, B>(lhs: A, rhs: B) { - lhs * rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn div, B>(lhs: A, rhs: B) { - lhs / rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn rem, B>(lhs: A, rhs: B) { - lhs % rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn bitand, B>(lhs: A, rhs: B) { - lhs & rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn bitor, B>(lhs: A, rhs: B) { - lhs | rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn bitxor, B>(lhs: A, rhs: B) { - lhs ^ rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn shl, B>(lhs: A, rhs: B) { - lhs << rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn shr, B>(lhs: A, rhs: B) { - lhs >> rhs; - drop(lhs); //~ ERROR use of moved value: `lhs` - drop(rhs); //~ ERROR use of moved value: `rhs` -} - -fn main() {} diff --git a/src/test/compile-fail/binop-logic-float.rs b/src/test/compile-fail/binop-logic-float.rs deleted file mode 100644 index f3fb5a08c85..00000000000 --- a/src/test/compile-fail/binop-logic-float.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { let x = 1.0_f32 || 2.0_f32; } -//~^ ERROR mismatched types -//~| ERROR mismatched types - diff --git a/src/test/compile-fail/binop-logic-int.rs b/src/test/compile-fail/binop-logic-int.rs deleted file mode 100644 index f5e53f84c16..00000000000 --- a/src/test/compile-fail/binop-logic-int.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { let x = 1 && 2; } -//~^ ERROR mismatched types -//~| ERROR mismatched types diff --git a/src/test/compile-fail/binop-move-semantics.rs b/src/test/compile-fail/binop-move-semantics.rs deleted file mode 100644 index cff0064497a..00000000000 --- a/src/test/compile-fail/binop-move-semantics.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that move restrictions are enforced on overloaded binary operations - -use std::ops::Add; - -fn double_move>(x: T) { - x - + - x; //~ ERROR: use of moved value -} - -fn move_then_borrow + Clone>(x: T) { - x - + - x.clone(); //~ ERROR: use of moved value -} - -fn move_borrowed>(x: T, mut y: T) { - let m = &x; - let n = &mut y; - - x //~ ERROR: cannot move out of `x` because it is borrowed - + - y; //~ ERROR: cannot move out of `y` because it is borrowed -} - -fn illegal_dereference>(mut x: T, y: T) { - let m = &mut x; - let n = &y; - - *m //~ ERROR: cannot move out of borrowed content - + - *n; //~ ERROR: cannot move out of borrowed content -} - -struct Foo; - -impl<'a, 'b> Add<&'b Foo> for &'a mut Foo { - type Output = (); - - fn add(self, _: &Foo) {} -} - -impl<'a, 'b> Add<&'b mut Foo> for &'a Foo { - type Output = (); - - fn add(self, _: &mut Foo) {} -} - -fn mut_plus_immut() { - let mut f = Foo; - - &mut f - + - &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable -} - -fn immut_plus_mut() { - let mut f = Foo; - - &f - + - &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable -} - -fn main() {} diff --git a/src/test/compile-fail/binop-mul-bool.rs b/src/test/compile-fail/binop-mul-bool.rs deleted file mode 100644 index a36477fc183..00000000000 --- a/src/test/compile-fail/binop-mul-bool.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:`*` cannot be applied to type `bool` - -fn main() { let x = true * false; } diff --git a/src/test/compile-fail/binop-typeck.rs b/src/test/compile-fail/binop-typeck.rs deleted file mode 100644 index 8f17288e991..00000000000 --- a/src/test/compile-fail/binop-typeck.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// issue #500 - -fn main() { - let x = true; - let y = 1; - let z = x + y; - //~^ ERROR binary operation `+` cannot be applied to type `bool` -} diff --git a/src/test/compile-fail/blind-item-block-item-shadow.rs b/src/test/compile-fail/blind-item-block-item-shadow.rs deleted file mode 100644 index eeadecf627d..00000000000 --- a/src/test/compile-fail/blind-item-block-item-shadow.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { pub struct Bar; } - -fn main() { - { - struct Bar; - use foo::Bar; - //~^ ERROR the name `Bar` is defined multiple times - } -} diff --git a/src/test/compile-fail/blind-item-block-middle.rs b/src/test/compile-fail/blind-item-block-middle.rs deleted file mode 100644 index a501a5cd3ec..00000000000 --- a/src/test/compile-fail/blind-item-block-middle.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { pub struct bar; } - -fn main() { - let bar = 5; - //~^ ERROR mismatched types - use foo::bar; -} diff --git a/src/test/compile-fail/borrow-immutable-upvar-mutation.rs b/src/test/compile-fail/borrow-immutable-upvar-mutation.rs deleted file mode 100644 index 00f51973a41..00000000000 --- a/src/test/compile-fail/borrow-immutable-upvar-mutation.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] - -// Tests that we can't assign to or mutably borrow upvars from `Fn` -// closures (issue #17780) - -fn set(x: &mut usize) { *x = 5; } - -fn to_fn>(f: F) -> F { f } -fn to_fn_mut>(f: F) -> F { f } - -fn main() { - // By-ref captures - { - let mut x = 0; - let _f = to_fn(|| x = 42); //~ ERROR cannot assign - - let mut y = 0; - let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow - - let mut z = 0; - let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign - } - - // By-value captures - { - let mut x = 0; - let _f = to_fn(move || x = 42); //~ ERROR cannot assign - - let mut y = 0; - let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow - - let mut z = 0; - let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign - } -} diff --git a/src/test/compile-fail/borrow-tuple-fields.rs b/src/test/compile-fail/borrow-tuple-fields.rs deleted file mode 100644 index f3417fafe90..00000000000 --- a/src/test/compile-fail/borrow-tuple-fields.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct Foo(Box, isize); - -struct Bar(isize, isize); - -fn main() { - let x: (Box<_>, _) = (box 1, 2); - let r = &x.0; - let y = x; //~ ERROR cannot move out of `x` because it is borrowed - - let mut x = (1, 2); - let a = &x.0; - let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as - - let mut x = (1, 2); - let a = &mut x.0; - let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time - - - let x = Foo(box 1, 2); - let r = &x.0; - let y = x; //~ ERROR cannot move out of `x` because it is borrowed - - let mut x = Bar(1, 2); - let a = &x.0; - let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as - - let mut x = Bar(1, 2); - let a = &mut x.0; - let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time -} diff --git a/src/test/compile-fail/borrowck/borrowck-access-permissions.rs b/src/test/compile-fail/borrowck/borrowck-access-permissions.rs deleted file mode 100644 index 00a3da86074..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-access-permissions.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -static static_x : i32 = 1; -static mut static_x_mut : i32 = 1; - -fn main() { - let x = 1; - let mut x_mut = 1; - - { // borrow of local - let _y1 = &mut x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] - let _y2 = &mut x_mut; // No error - } - - { // borrow of static - let _y1 = &mut static_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] - unsafe { let _y2 = &mut static_x_mut; } // No error - } - - { // borrow of deref to box - let box_x = Box::new(1); - let mut box_x_mut = Box::new(1); - - let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] - let _y2 = &mut *box_x_mut; // No error - } - - { // borrow of deref to reference - let ref_x = &x; - let ref_x_mut = &mut x_mut; - - let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] - let _y2 = &mut *ref_x_mut; // No error - } - - { // borrow of deref to pointer - let ptr_x : *const _ = &x; - let ptr_mut_x : *mut _ = &mut x_mut; - - unsafe { - let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] - let _y2 = &mut *ptr_mut_x; // No error - } - } - - { // borrowing mutably through an immutable reference - struct Foo<'a> { f: &'a mut i32, g: &'a i32 }; - let mut foo = Foo { f: &mut x_mut, g: &x }; - let foo_ref = &foo; - let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] - //[mir]~^ ERROR [E0596] - // FIXME: Wrong error in MIR - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-and-init.rs b/src/test/compile-fail/borrowck/borrowck-and-init.rs deleted file mode 100644 index 92f16d8ffce..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-and-init.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let i: isize; - - println!("{}", false && { i = 5; true }); - println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` -} diff --git a/src/test/compile-fail/borrowck/borrowck-anon-fields-struct.rs b/src/test/compile-fail/borrowck/borrowck-anon-fields-struct.rs deleted file mode 100644 index 5ee2b89dd98..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-anon-fields-struct.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that we are able to distinguish when loans borrow different -// anonymous fields of a tuple vs the same anonymous field. - -struct Y(usize, usize); - -fn distinct_variant() { - let mut y = Y(1, 2); - - let a = match y { - Y(ref mut a, _) => a - }; - - let b = match y { - Y(_, ref mut b) => b - }; - - *a += 1; - *b += 1; -} - -fn same_variant() { - let mut y = Y(1, 2); - - let a = match y { - Y(ref mut a, _) => a - }; - - let b = match y { - Y(ref mut b, _) => b //~ ERROR cannot borrow - }; - - *a += 1; - *b += 1; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-anon-fields-tuple.rs b/src/test/compile-fail/borrowck/borrowck-anon-fields-tuple.rs deleted file mode 100644 index ebaed01756f..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-anon-fields-tuple.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that we are able to distinguish when loans borrow different -// anonymous fields of a tuple vs the same anonymous field. - -fn distinct_variant() { - let mut y = (1, 2); - - let a = match y { - (ref mut a, _) => a - }; - - let b = match y { - (_, ref mut b) => b - }; - - *a += 1; - *b += 1; -} - -fn same_variant() { - let mut y = (1, 2); - - let a = match y { - (ref mut a, _) => a - }; - - let b = match y { - (ref mut b, _) => b //~ ERROR cannot borrow - }; - - *a += 1; - *b += 1; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-anon-fields-variant.rs b/src/test/compile-fail/borrowck/borrowck-anon-fields-variant.rs deleted file mode 100644 index 4e1b85283a6..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-anon-fields-variant.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that we are able to distinguish when loans borrow different -// anonymous fields of an enum variant vs the same anonymous field. - -enum Foo { - X, Y(usize, usize) -} - -fn distinct_variant() { - let mut y = Foo::Y(1, 2); - - let a = match y { - Foo::Y(ref mut a, _) => a, - Foo::X => panic!() - }; - - let b = match y { - Foo::Y(_, ref mut b) => b, - Foo::X => panic!() - }; - - *a += 1; - *b += 1; -} - -fn same_variant() { - let mut y = Foo::Y(1, 2); - - let a = match y { - Foo::Y(ref mut a, _) => a, - Foo::X => panic!() - }; - - let b = match y { - Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow - Foo::X => panic!() - }; - - *a += 1; - *b += 1; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-argument.rs b/src/test/compile-fail/borrowck/borrowck-argument.rs deleted file mode 100644 index 3230689e53c..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-argument.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Copy, Clone)] -struct S; - -impl S { - fn mutate(&mut self) { - } -} - -fn func(arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument -} - -impl S { - fn method(&self, arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument - } -} - -trait T { - fn default(&self, arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument - } -} - -impl T for S {} - -fn main() { - let s = S; - func(s); - s.method(s); - s.default(s); - (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument -} diff --git a/src/test/compile-fail/borrowck/borrowck-asm.rs b/src/test/compile-fail/borrowck/borrowck-asm.rs deleted file mode 100644 index d9816401b33..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-asm.rs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-s390x -// ignore-emscripten -// ignore-powerpc -// ignore-powerpc64 -// ignore-powerpc64le -// ignore-sparc -// ignore-sparc64 - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(asm)] - -#[cfg(any(target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "mips", - target_arch = "mips64"))] -mod test_cases { - fn is_move() { - let y: &mut isize; - let x = &mut 0isize; - unsafe { - asm!("nop" : : "r"(x)); - } - let z = x; //[ast]~ ERROR use of moved value: `x` - //[mir]~^ ERROR use of moved value: `x` - } - - fn in_is_read() { - let mut x = 3; - let y = &mut x; - unsafe { - asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use - //[mir]~^ ERROR cannot use - } - let z = y; - } - - fn out_is_assign() { - let x = 3; - unsafe { - asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - //[mir]~^ ERROR cannot assign twice - } - let mut a = &mut 3; - let b = &*a; - unsafe { - asm!("nop" : "=r"(a)); //[ast]~ ERROR cannot assign to `a` because it is borrowed - // No MIR error, this is a shallow write. - } - let c = b; - let d = *a; - } - - fn rw_is_assign() { - let x = 3; - unsafe { - asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - //[mir]~^ ERROR cannot assign twice - } - } - - fn indirect_is_not_init() { - let x: i32; - unsafe { - asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable - //[mir]~^ ERROR use of possibly uninitialized variable - } - } - - fn rw_is_read() { - let mut x = &mut 3; - let y = &*x; - unsafe { - asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - //[mir]~^ ERROR cannot assign to `x` because it is borrowed - } - let z = y; - } - - fn two_moves() { - let x = &mut 2; - unsafe { - asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value - //[mir]~^ ERROR use of moved value - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck/borrowck-assign-comp-idx.rs deleted file mode 100644 index 1e665a12a19..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-assign-comp-idx.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Point { - x: isize, - y: isize, -} - -fn a() { - let mut p = vec![1]; - - // Create an immutable pointer into p's contents: - let q: &isize = &p[0]; - - p[0] = 5; //~ ERROR cannot borrow - - println!("{}", *q); -} - -fn borrow(_x: &[isize], _f: F) where F: FnOnce() {} - -fn b() { - // here we alias the mutable vector into an imm slice and try to - // modify the original: - - let mut p = vec![1]; - - borrow( - &p, - || p[0] = 5); //~ ERROR cannot borrow `p` as mutable -} - -fn c() { - // Legal because the scope of the borrow does not include the - // modification: - let mut p = vec![1]; - borrow(&p, ||{}); - p[0] = 5; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-assign-comp.rs b/src/test/compile-fail/borrowck/borrowck-assign-comp.rs deleted file mode 100644 index d68420eb205..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-assign-comp.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -struct point { x: isize, y: isize } - -fn a() { - let mut p = point {x: 3, y: 4}; - let q = &p; - - // This assignment is illegal because the field x is not - // inherently mutable; since `p` was made immutable, `p.x` is now - // immutable. Otherwise the type of &_q.x (&isize) would be wrong. - p.x = 5; //[ast]~ ERROR cannot assign to `p.x` - //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed - q.x; -} - -fn c() { - // this is sort of the opposite. We take a loan to the interior of `p` - // and then try to overwrite `p` as a whole. - - let mut p = point {x: 3, y: 4}; - let q = &p.y; - p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` - //[mir]~^ ERROR cannot assign to `p` because it is borrowed - p.x; // silence warning - *q; // stretch loan -} - -fn d() { - // just for completeness's sake, the easy case, where we take the - // address of a subcomponent and then modify that subcomponent: - - let mut p = point {x: 3, y: 4}; - let q = &p.y; - p.y = 5; //[ast]~ ERROR cannot assign to `p.y` - //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed - *q; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs b/src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs deleted file mode 100644 index d66cdb99a74..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that assignments to an `&mut` pointer which is found in a -// borrowed (but otherwise non-aliasable) location is illegal. - -struct S<'a> { - pointer: &'a mut isize -} - -fn a(s: &S) { - *s.pointer += 1; //~ ERROR cannot assign -} - -fn b(s: &mut S) { - *s.pointer += 1; -} - -fn c(s: & &mut S) { - *s.pointer += 1; //~ ERROR cannot assign -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs b/src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs deleted file mode 100644 index 77aa57ef1b5..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that assignments to an `&mut` pointer which is found in a -// borrowed (but otherwise non-aliasable) location is illegal. - -struct S<'a> { - pointer: &'a mut isize -} - -fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> { - S { pointer: &mut *p.pointer } -} - -fn main() { - let mut x = 1; - - { - let mut y = S { pointer: &mut x }; - let z = copy_borrowed_ptr(&mut y); - *y.pointer += 1; //~ ERROR cannot assign - *z.pointer += 1; - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs b/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs deleted file mode 100644 index 57002dd40fc..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-assign-to-constants.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -static foo: isize = 5; - -fn main() { - // assigning to various global constants - foo = 6; //[ast]~ ERROR cannot assign to immutable static item - //[mir]~^ ERROR cannot assign to immutable static item `foo` -} diff --git a/src/test/compile-fail/borrowck/borrowck-auto-mut-ref-to-immut-var.rs b/src/test/compile-fail/borrowck/borrowck-auto-mut-ref-to-immut-var.rs deleted file mode 100644 index ea020dc0685..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-auto-mut-ref-to-immut-var.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that auto-ref can't create mutable aliases to immutable memory. - -struct Foo { - x: isize -} - -impl Foo { - pub fn printme(&mut self) { - println!("{}", self.x); - } -} - -fn main() { - let x = Foo { x: 3 }; - x.printme(); //~ ERROR cannot borrow -} diff --git a/src/test/compile-fail/borrowck/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck/borrowck-autoref-3261.rs deleted file mode 100644 index d5f09305808..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-autoref-3261.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Either { Left(T), Right(U) } - -struct X(Either<(usize,usize), fn()>); - -impl X { - pub fn with(&self, blk: F) where F: FnOnce(&Either<(usize, usize), fn()>) { - let X(ref e) = *self; - blk(e) - } -} - -fn main() { - let mut x = X(Either::Right(main as fn())); - (&mut x).with( - |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time - match opt { - &Either::Right(ref f) => { - x = X(Either::Left((0, 0))); - (*f)() - }, - _ => panic!() - } - }) -} diff --git a/src/test/compile-fail/borrowck/borrowck-bad-nested-calls-free.rs b/src/test/compile-fail/borrowck/borrowck-bad-nested-calls-free.rs deleted file mode 100644 index 7913f9ac903..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-bad-nested-calls-free.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we detect nested calls that could free pointers evaluated -// for earlier arguments. - -#![feature(box_syntax)] - -fn rewrite(v: &mut Box) -> usize { - *v = box 22; - **v -} - -fn add(v: &usize, w: usize) -> usize { - *v + w -} - -fn implicit() { - let mut a: Box<_> = box 1; - - // Note the danger here: - // - // the pointer for the first argument has already been - // evaluated, but it gets freed when evaluating the second - // argument! - add( - &*a, - rewrite(&mut a)); //~ ERROR cannot borrow -} - -fn explicit() { - let mut a: Box<_> = box 1; - add( - &*a, - rewrite(&mut a)); //~ ERROR cannot borrow -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-bad-nested-calls-move.rs b/src/test/compile-fail/borrowck/borrowck-bad-nested-calls-move.rs deleted file mode 100644 index e24d4e87add..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-bad-nested-calls-move.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we detect nested calls that could free pointers evaluated -// for earlier arguments. - -#![feature(box_syntax)] - -fn rewrite(v: &mut Box) -> usize { - *v = box 22; - **v -} - -fn add(v: &usize, w: Box) -> usize { - *v + *w -} - -fn implicit() { - let mut a: Box<_> = box 1; - - // Note the danger here: - // - // the pointer for the first argument has already been - // evaluated, but it gets moved when evaluating the second - // argument! - add( - &*a, - a); //~ ERROR cannot move -} - -fn explicit() { - let mut a: Box<_> = box 1; - add( - &*a, - a); //~ ERROR cannot move -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-block-unint.rs b/src/test/compile-fail/borrowck/borrowck-block-unint.rs deleted file mode 100644 index a09ee439245..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-block-unint.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn force(f: F) where F: FnOnce() { f(); } -fn main() { - let x: isize; - force(|| { //~ ERROR capture of possibly uninitialized variable: `x` - println!("{}", x); - }); -} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck/borrowck-borrow-from-owned-ptr.rs deleted file mode 100644 index e5091a92581..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-from-owned-ptr.rs +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#[derive(Copy, Clone)] -struct Foo { - bar1: Bar, - bar2: Bar -} - -#[derive(Copy, Clone)] -struct Bar { - int1: isize, - int2: isize, -} - -fn make_foo() -> Box { panic!() } - -fn borrow_same_field_twice_mut_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_same_field_twice_mut_imm() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _bar2 = &foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_same_field_twice_imm_mut() { - let mut foo = make_foo(); - let bar1 = &foo.bar1; - let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_same_field_twice_imm_imm() { - let mut foo = make_foo(); - let bar1 = &foo.bar1; - let _bar2 = &foo.bar1; - *bar1; -} - -fn borrow_both_fields_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar2; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_both_mut_pattern() { - let mut foo = make_foo(); - match *foo { - Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} - //~^ ERROR cannot borrow - } -} - -fn borrow_var_and_pattern() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - match *foo { - Foo { bar1: ref mut _bar1, bar2: _ } => {} - //~^ ERROR cannot borrow - } - *bar1; -} - -fn borrow_mut_and_base_imm() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let _foo1 = &foo.bar1; //~ ERROR cannot borrow - let _foo2 = &*foo; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_mut_and_base_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_mut_and_base_mut2() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let _foo2 = &mut *foo; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_imm_and_base_mut() { - let mut foo = make_foo(); - let bar1 = &foo.bar1.int1; - let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_imm_and_base_mut2() { - let mut foo = make_foo(); - let bar1 = &foo.bar1.int1; - let _foo2 = &mut *foo; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_imm_and_base_imm() { - let mut foo = make_foo(); - let bar1 = &foo.bar1.int1; - let _foo1 = &foo.bar1; - let _foo2 = &*foo; - *bar1; -} - -fn borrow_mut_and_imm() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _foo1 = &foo.bar2; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_mut_from_imm() { - let foo = make_foo(); - let bar1 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_long_path_both_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let foo1 = &mut foo.bar2.int2; //~ ERROR cannot borrow - *bar1; - *foo1; -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-from-stack-variable.rs b/src/test/compile-fail/borrowck/borrowck-borrow-from-stack-variable.rs deleted file mode 100644 index 440be93dfdc..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-from-stack-variable.rs +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Copy, Clone)] -struct Foo { - bar1: Bar, - bar2: Bar -} - -#[derive(Copy, Clone)] -struct Bar { - int1: isize, - int2: isize, -} - -fn make_foo() -> Foo { panic!() } - -fn borrow_same_field_twice_mut_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_same_field_twice_mut_imm() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _bar2 = &foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_same_field_twice_imm_mut() { - let mut foo = make_foo(); - let bar1 = &foo.bar1; - let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_same_field_twice_imm_imm() { - let mut foo = make_foo(); - let bar1 = &foo.bar1; - let _bar2 = &foo.bar1; - *bar1; -} - -fn borrow_both_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar2; - *bar1; -} - -fn borrow_both_mut_pattern() { - let mut foo = make_foo(); - match foo { - Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} - } -} - -fn borrow_var_and_pattern() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - match foo { - Foo { bar1: ref mut _bar1, bar2: _ } => {} // - //~^ ERROR cannot borrow - } - *bar1; -} - -fn borrow_mut_and_base_imm() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let _foo1 = &foo.bar1; //~ ERROR cannot borrow - let _foo2 = &foo; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_mut_and_base_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_mut_and_base_mut2() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let _foo2 = &mut foo; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_imm_and_base_mut() { - let mut foo = make_foo(); - let bar1 = &foo.bar1.int1; - let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_imm_and_base_mut2() { - let mut foo = make_foo(); - let bar1 = &foo.bar1.int1; - let _foo2 = &mut foo; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_imm_and_base_imm() { - let mut foo = make_foo(); - let bar1 = &foo.bar1.int1; - let _foo1 = &foo.bar1; - let _foo2 = &foo; - *bar1; -} - -fn borrow_mut_and_imm() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1; - let _foo1 = &foo.bar2; - *bar1; -} - -fn borrow_mut_from_imm() { - let foo = make_foo(); - let bar1 = &mut foo.bar1; //~ ERROR cannot borrow - *bar1; -} - -fn borrow_long_path_both_mut() { - let mut foo = make_foo(); - let bar1 = &mut foo.bar1.int1; - let _foo1 = &mut foo.bar2.int2; - *bar1; -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs b/src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs deleted file mode 100644 index f7514df800d..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-from-temporary.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test lifetimes are linked properly when we take reference -// to interior. - -fn id(x: T) -> T { x } - -struct Foo(isize); - -fn foo<'a>() -> &'a isize { - let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough - x -} - -pub fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs b/src/test/compile-fail/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs deleted file mode 100644 index 3662e23a412..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct A; - -impl A { - fn foo(&mut self) { - } -} - -pub fn main() { - let a: Box<_> = box A; - a.foo(); - //~^ ERROR cannot borrow immutable `Box` content `*a` as mutable -} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs b/src/test/compile-fail/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs deleted file mode 100644 index d60751eddc7..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that attempt to reborrow an `&mut` pointer in an aliasable -// location yields an error. -// -// Example from src/librustc_borrowck/borrowck/README.md - -fn foo(t0: & &mut isize) { - let t1 = t0; - let p: &isize = &**t0; - **t1 = 22; //~ ERROR cannot assign -} - -fn foo3(t0: &mut &mut isize) { - let t1 = &mut *t0; - let p: &isize = &**t0; //~ ERROR cannot borrow - **t1 = 22; -} - -fn foo4(t0: & &mut isize) { - let x: &mut isize = &mut **t0; //~ ERROR cannot borrow - *x += 1; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-mut-object-twice.rs b/src/test/compile-fail/borrowck/borrowck-borrow-mut-object-twice.rs deleted file mode 100644 index 7175194355b..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-mut-object-twice.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that `&mut` objects cannot be borrowed twice, just like -// other `&mut` pointers. - -trait Foo { - fn f1(&mut self) -> &(); - fn f2(&mut self); -} - -fn test(x: &mut Foo) { - let _y = x.f1(); - x.f2(); //~ ERROR cannot borrow `*x` as mutable -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-overloaded-auto-deref.rs b/src/test/compile-fail/borrowck/borrowck-borrow-overloaded-auto-deref.rs deleted file mode 100644 index 693ed29bd05..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-overloaded-auto-deref.rs +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test how overloaded deref interacts with borrows when only -// Deref and not DerefMut is implemented. - -use std::ops::Deref; - -struct Rc { - value: *const T -} - -impl Deref for Rc { - type Target = T; - - fn deref(&self) -> &T { - unsafe { &*self.value } - } -} - -struct Point { - x: isize, - y: isize -} - -impl Point { - fn get(&self) -> (isize, isize) { - (self.x, self.y) - } - - fn set(&mut self, x: isize, y: isize) { - self.x = x; - self.y = y; - } - - fn x_ref(&self) -> &isize { - &self.x - } - - fn y_mut(&mut self) -> &mut isize { - &mut self.y - } -} - -fn deref_imm_field(x: Rc) { - let __isize = &x.y; -} - -fn deref_mut_field1(x: Rc) { - let __isize = &mut x.y; //~ ERROR cannot borrow -} - -fn deref_mut_field2(mut x: Rc) { - let __isize = &mut x.y; //~ ERROR cannot borrow -} - -fn deref_extend_field(x: &Rc) -> &isize { - &x.y -} - -fn deref_extend_mut_field1(x: &Rc) -> &mut isize { - &mut x.y //~ ERROR cannot borrow -} - -fn deref_extend_mut_field2(x: &mut Rc) -> &mut isize { - &mut x.y //~ ERROR cannot borrow -} - -fn assign_field1<'a>(x: Rc) { - x.y = 3; //~ ERROR cannot assign -} - -fn assign_field2<'a>(x: &'a Rc) { - x.y = 3; //~ ERROR cannot assign -} - -fn assign_field3<'a>(x: &'a mut Rc) { - x.y = 3; //~ ERROR cannot assign -} - -fn deref_imm_method(x: Rc) { - let __isize = x.get(); -} - -fn deref_mut_method1(x: Rc) { - x.set(0, 0); //~ ERROR cannot borrow -} - -fn deref_mut_method2(mut x: Rc) { - x.set(0, 0); //~ ERROR cannot borrow -} - -fn deref_extend_method(x: &Rc) -> &isize { - x.x_ref() -} - -fn deref_extend_mut_method1(x: &Rc) -> &mut isize { - x.y_mut() //~ ERROR cannot borrow -} - -fn deref_extend_mut_method2(x: &mut Rc) -> &mut isize { - x.y_mut() //~ ERROR cannot borrow -} - -fn assign_method1<'a>(x: Rc) { - *x.y_mut() = 3; //~ ERROR cannot borrow -} - -fn assign_method2<'a>(x: &'a Rc) { - *x.y_mut() = 3; //~ ERROR cannot borrow -} - -fn assign_method3<'a>(x: &'a mut Rc) { - *x.y_mut() = 3; //~ ERROR cannot borrow -} - -pub fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-borrow-overloaded-deref.rs b/src/test/compile-fail/borrowck/borrowck-borrow-overloaded-deref.rs deleted file mode 100644 index 5b916243b9e..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrow-overloaded-deref.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test how overloaded deref interacts with borrows when only -// Deref and not DerefMut is implemented. - -use std::ops::Deref; - -struct Rc { - value: *const T -} - -impl Deref for Rc { - type Target = T; - - fn deref<'a>(&'a self) -> &'a T { - unsafe { &*self.value } - } -} - -fn deref_imm(x: Rc) { - let __isize = &*x; -} - -fn deref_mut1(x: Rc) { - let __isize = &mut *x; //~ ERROR cannot borrow -} - -fn deref_mut2(mut x: Rc) { - let __isize = &mut *x; //~ ERROR cannot borrow -} - -fn deref_extend<'a>(x: &'a Rc) -> &'a isize { - &**x -} - -fn deref_extend_mut1<'a>(x: &'a Rc) -> &'a mut isize { - &mut **x //~ ERROR cannot borrow -} - -fn deref_extend_mut2<'a>(x: &'a mut Rc) -> &'a mut isize { - &mut **x //~ ERROR cannot borrow -} - -fn assign1<'a>(x: Rc) { - *x = 3; //~ ERROR cannot assign -} - -fn assign2<'a>(x: &'a Rc) { - **x = 3; //~ ERROR cannot assign -} - -fn assign3<'a>(x: &'a mut Rc) { - **x = 3; //~ ERROR cannot assign -} - -pub fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue-2.rs deleted file mode 100644 index 9178aadeeeb..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue-2.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: borrowed value does not live long enough - -struct defer<'a> { - x: &'a [&'a str], -} - -impl<'a> Drop for defer<'a> { - fn drop(&mut self) { - unsafe { - println!("{:?}", self.x); - } - } -} - -fn defer<'r>(x: &'r [&'r str]) -> defer<'r> { - defer { - x: x - } -} - -fn main() { - let x = defer(&vec!["Goodbye", "world!"]); - x.x[0]; -} diff --git a/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs deleted file mode 100644 index f58eca7c8ae..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//buggy.rs - -#![feature(box_syntax)] - -use std::collections::HashMap; - -fn main() { - let tmp: Box<_>; - let mut buggy_map: HashMap = HashMap::new(); - buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough - - // but it is ok if we use a temporary - tmp = box 2; - buggy_map.insert(43, &*tmp); -} diff --git a/src/test/compile-fail/borrowck/borrowck-break-uninit-2.rs b/src/test/compile-fail/borrowck/borrowck-break-uninit-2.rs deleted file mode 100644 index 82a6c92abaf..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-break-uninit-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() -> isize { - let x: isize; - - while 1 != 2 { - break; - x = 0; - } - - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - - return 17; -} - -fn main() { println!("{}", foo()); } diff --git a/src/test/compile-fail/borrowck/borrowck-break-uninit.rs b/src/test/compile-fail/borrowck/borrowck-break-uninit.rs deleted file mode 100644 index 8a6a036945b..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-break-uninit.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() -> isize { - let x: isize; - - loop { - break; - x = 0; - } - - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` - - return 17; -} - -fn main() { println!("{}", foo()); } diff --git a/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs b/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs deleted file mode 100644 index 9057ba07907..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-closures-mut-and-imm.rs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that two closures cannot simultaneously have mutable -// and immutable access to the variable. Issue #6801. - -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(box_syntax)] - -fn get(x: &isize) -> isize { - *x -} - -fn set(x: &mut isize) { - *x = 4; -} - -fn a() { - let mut x = 3; - let c1 = || x = 4; - let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable - drop(c1); -} - -fn b() { - let mut x = 3; - let c1 = || set(&mut x); - let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable - drop(c1); -} - -fn c() { - let mut x = 3; - let c1 = || set(&mut x); - let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable - drop(c1); -} - -fn d() { - let mut x = 3; - let c2 = || x * 5; - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed - drop(c2); -} - -fn e() { - let mut x = 3; - let c1 = || get(&x); - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed - drop(c1); -} - -fn f() { - let mut x: Box<_> = box 3; - let c1 = || get(&*x); - *x = 5; //[ast]~ ERROR cannot assign to `*x` - //[mir]~^ ERROR cannot assign to `*x` because it is borrowed - drop(c1); -} - -fn g() { - struct Foo { - f: Box - } - - let mut x: Box<_> = box Foo { f: box 3 }; - let c1 = || get(&*x.f); - *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` - //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed - drop(c1); -} - -fn h() { - struct Foo { - f: Box - } - - let mut x: Box<_> = box Foo { f: box 3 }; - let c1 = || get(&*x.f); - let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable - //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - drop(c1); -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-closures-mut-of-imm.rs b/src/test/compile-fail/borrowck/borrowck-closures-mut-of-imm.rs deleted file mode 100644 index dc2f0e8395f..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-closures-mut-of-imm.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that two closures cannot simultaneously have mutable -// and immutable access to the variable. Issue #6801. - -fn get(x: &isize) -> isize { - *x -} - -fn set(x: &mut isize) { - *x = 4; -} - -fn a(x: &isize) { - let c1 = || set(&mut *x); - //~^ ERROR cannot borrow - let c2 = || set(&mut *x); - //~^ ERROR cannot borrow - //~| ERROR two closures require unique access to `x` at the same time -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-closures-two-mut.rs b/src/test/compile-fail/borrowck/borrowck-closures-two-mut.rs deleted file mode 100644 index 29546abe0bb..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-closures-two-mut.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that two closures cannot simultaneously have mutable -// access to the variable, whether that mutable access be used -// for direct assignment or for taking mutable ref. Issue #6801. - -#![feature(box_syntax)] - -fn to_fn_mut(f: F) -> F { f } - -fn a() { - let mut x = 3; - let c1 = to_fn_mut(|| x = 4); - let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once -} - -fn set(x: &mut isize) { - *x = 4; -} - -fn b() { - let mut x = 3; - let c1 = to_fn_mut(|| set(&mut x)); - let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once -} - -fn c() { - let mut x = 3; - let c1 = to_fn_mut(|| x = 5); - let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once -} - -fn d() { - let mut x = 3; - let c1 = to_fn_mut(|| x = 5); - let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) - //~^ ERROR cannot borrow `x` as mutable more than once -} - -fn g() { - struct Foo { - f: Box - } - - let mut x: Box<_> = box Foo { f: box 3 }; - let c1 = to_fn_mut(|| set(&mut *x.f)); - let c2 = to_fn_mut(|| set(&mut *x.f)); - //~^ ERROR cannot borrow `x` as mutable more than once -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-closures-unique-imm.rs b/src/test/compile-fail/borrowck/borrowck-closures-unique-imm.rs deleted file mode 100644 index 247a4fe89a5..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-closures-unique-imm.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - x: isize, -} - -pub fn main() { - let mut this = &mut Foo { - x: 1, - }; - let mut r = || { - let p = &this.x; - &mut this.x; //~ ERROR cannot borrow - }; - r() -} diff --git a/src/test/compile-fail/borrowck/borrowck-closures-unique.rs b/src/test/compile-fail/borrowck/borrowck-closures-unique.rs deleted file mode 100644 index 1b22dc4d2c6..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-closures-unique.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that a closure which requires mutable access to the referent -// of an `&mut` requires a "unique" borrow -- that is, the variable to -// be borrowed (here, `x`) will not be borrowed *mutably*, but -// may be *immutable*, but we cannot allow -// multiple borrows. - -fn get(x: &isize) -> isize { - *x -} - -fn set(x: &mut isize) -> isize { - *x -} - -fn a(x: &mut isize) { - let c1 = || get(x); - let c2 = || get(x); -} - -fn b(x: &mut isize) { - let c1 = || get(x); - let c2 = || set(x); //~ ERROR closure requires unique access to `x` -} - -fn c(x: &mut isize) { - let c1 = || get(x); - let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x` -} - -fn d(x: &mut isize) { - let c1 = || set(x); - let c2 = || set(x); //~ ERROR two closures require unique access to `x` at the same time -} - -fn e(x: &mut isize) { - let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable argument -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-closures-use-after-free.rs b/src/test/compile-fail/borrowck/borrowck-closures-use-after-free.rs deleted file mode 100644 index bb474342a7c..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-closures-use-after-free.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that a closure which mutates a local variable -// cannot also be supplied a borrowed version of that -// variable's contents. Issue #11192. - -#![feature(box_syntax)] - -struct Foo { - x: isize -} - -impl Drop for Foo { - fn drop(&mut self) { - println!("drop {}", self.x); - } -} - -fn main() { - let mut ptr: Box<_> = box Foo { x: 0 }; - let mut test = |foo: &Foo| { - ptr = box Foo { x: ptr.x + 1 }; - }; - test(&*ptr); //~ ERROR cannot borrow `*ptr` -} diff --git a/src/test/compile-fail/borrowck/borrowck-consume-unsize-vec.rs b/src/test/compile-fail/borrowck/borrowck-consume-unsize-vec.rs deleted file mode 100644 index 32490e0dc7d..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-consume-unsize-vec.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we report an error if an upcast box is moved twice. - -fn consume(_: Box<[i32]>) { -} - -fn foo(b: Box<[i32;5]>) { - consume(b); - consume(b); //~ ERROR use of moved value -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-consume-upcast-box.rs b/src/test/compile-fail/borrowck/borrowck-consume-upcast-box.rs deleted file mode 100644 index 5bcafa675c7..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-consume-upcast-box.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we report an error if an upcast box is moved twice. - -trait Foo { fn dummy(&self); } - -fn consume(_: Box) { -} - -fn foo(b: Box) { - consume(b); - consume(b); //~ ERROR use of moved value -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs b/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs deleted file mode 100644 index b821c7cfa34..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(slice_patterns)] - -pub struct Foo { - x: u32 -} - -pub struct Bar(u32); - -pub enum Baz { - X(u32) -} - -union U { - a: u8, - b: u64, -} - -impl Foo { - fn x(&mut self) -> &mut u32 { &mut self.x } -} - -impl Bar { - fn x(&mut self) -> &mut u32 { &mut self.0 } -} - -impl Baz { - fn x(&mut self) -> &mut u32 { - match *self { - Baz::X(ref mut value) => value - } - } -} - -fn main() { - // Local and field from struct - { - let mut f = Foo { x: 22 }; - let x = f.x(); - f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed - drop(x); - } - // Local and field from tuple-struct - { - let mut g = Bar(22); - let x = g.x(); - g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed - drop(x); - } - // Local and field from tuple - { - let mut h = (22, 23); - let x = &mut h.0; - h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed - drop(x); - } - // Local and field from enum - { - let mut e = Baz::X(2); - let x = e.x(); - match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed - Baz::X(value) => value - //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed - }; - drop(x); - } - // Local and field from union - unsafe { - let mut u = U { b: 0 }; - let x = &mut u.a; - u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed - drop(x); - } - // Deref and field from struct - { - let mut f = Box::new(Foo { x: 22 }); - let x = f.x(); - f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed - drop(x); - } - // Deref and field from tuple-struct - { - let mut g = Box::new(Bar(22)); - let x = g.x(); - g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed - drop(x); - } - // Deref and field from tuple - { - let mut h = Box::new((22, 23)); - let x = &mut h.0; - h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed - drop(x); - } - // Deref and field from enum - { - let mut e = Box::new(Baz::X(3)); - let x = e.x(); - match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed - Baz::X(value) => value - //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed - }; - drop(x); - } - // Deref and field from union - unsafe { - let mut u = Box::new(U { b: 0 }); - let x = &mut u.a; - u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed - drop(x); - } - // Constant index - { - let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - let x = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[x, _, .., _, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[_, x, .., _, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[_, _, .., x, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[_, _, .., _, x] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - drop(x); - } - // Subslices - { - let mut v = &[1, 2, 3, 4, 5]; - let x = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[x..] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[_, x..] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[x.., _] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[_, x.., _] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed - _ => panic!("other case"), - } - drop(x); - } - // Downcasted field - { - enum E { A(X), B { x: X } } - - let mut e = E::A(3); - let x = &mut e; - match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed - E::A(ref ax) => - //[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable - //[mir]~| ERROR cannot use `e` because it was mutably borrowed - println!("e.ax: {:?}", ax), - E::B { x: ref bx } => - //[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable - println!("e.bx: {:?}", bx), - } - drop(x); - } - // Field in field - { - struct F { x: u32, y: u32 }; - struct S { x: F, y: (u32, u32), }; - let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) }; - let x = &mut s; - match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed - S { y: (ref y0, _), .. } => - //[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable - println!("y0: {:?}", y0), - _ => panic!("other case"), - } - match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed - S { x: F { y: ref x0, .. }, .. } => - //[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable - println!("x0: {:?}", x0), - _ => panic!("other case"), - } - drop(x); - } - // Field of ref - { - struct Block<'a> { - current: &'a u8, - unrelated: &'a u8, - }; - - fn bump<'a>(mut block: &mut Block<'a>) { - let x = &mut block; - let p: &'a u8 = &*block.current; - //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable - // No errors in AST because of issue rust#38899 - drop(x); - } - } - // Field of ptr - { - struct Block2 { - current: *const u8, - unrelated: *const u8, - } - - unsafe fn bump2(mut block: *mut Block2) { - let x = &mut block; - let p : *const u8 = &*(*block).current; - //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable - // No errors in AST because of issue rust#38899 - drop(x); - } - } - // Field of index - { - struct F {x: u32, y: u32}; - let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; - let x = &mut v; - v[0].y; - //[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed - //[mir]~| ERROR cannot use `*v` because it was mutably borrowed - drop(x); - } - // Field of constant index - { - struct F {x: u32, y: u32}; - let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; - let x = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - &[_, F {x: ref xf, ..}] => println!("{}", xf), - //[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - // No errors in AST - _ => panic!("other case") - } - drop(x); - } - // Field from upvar - { - let mut x = 0; - || { - let y = &mut x; - &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time - *y = 1; - }; - } - // Field from upvar nested - { - // FIXME(#49824) -- the free region error below should probably not be there - let mut x = 0; - || { - || { //[mir]~ ERROR unsatisfied lifetime constraints - let y = &mut x; - &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time - *y = 1; - drop(y); - } - }; - } - { - fn foo(x: Vec) { - let c = || { - drop(x); - drop(x); //[ast]~ ERROR use of moved value: `x` - //[mir]~^ ERROR use of moved value: `x` - }; - c(); - } - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-drop-from-guard.rs b/src/test/compile-fail/borrowck/borrowck-drop-from-guard.rs deleted file mode 100644 index 496aa84b593..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-drop-from-guard.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -//compile-flags: -Z borrowck=mir - -fn foo(_:String) {} - -fn main() -{ - let my_str = "hello".to_owned(); - match Some(42) { - Some(_) if { drop(my_str); false } => {} - Some(_) => {} - None => { foo(my_str); } //~ ERROR [E0382] - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-field-sensitivity.rs b/src/test/compile-fail/borrowck/borrowck-field-sensitivity.rs deleted file mode 100644 index 13fd5fce955..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-field-sensitivity.rs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct A { a: isize, b: Box } - -fn deref_after_move() { - let x = A { a: 1, b: box 2 }; - drop(x.b); - drop(*x.b); //~ ERROR use of moved value: `*x.b` -} - -fn deref_after_fu_move() { - let x = A { a: 1, b: box 2 }; - let y = A { a: 3, .. x }; - drop(*x.b); //~ ERROR use of moved value: `*x.b` -} - -fn borrow_after_move() { - let x = A { a: 1, b: box 2 }; - drop(x.b); - let p = &x.b; //~ ERROR use of moved value: `x.b` - drop(**p); -} - -fn borrow_after_fu_move() { - let x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - let p = &x.b; //~ ERROR use of moved value: `x.b` - drop(**p); -} - -fn move_after_borrow() { - let x = A { a: 1, b: box 2 }; - let p = &x.b; - drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed - drop(**p); -} - -fn fu_move_after_borrow() { - let x = A { a: 1, b: box 2 }; - let p = &x.b; - let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed - drop(**p); -} - -fn mut_borrow_after_mut_borrow() { - let mut x = A { a: 1, b: box 2 }; - let p = &mut x.a; - let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time - drop(*p); - drop(*q); -} - -fn move_after_move() { - let x = A { a: 1, b: box 2 }; - drop(x.b); - drop(x.b); //~ ERROR use of moved value: `x.b` -} - -fn move_after_fu_move() { - let x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - drop(x.b); //~ ERROR use of moved value: `x.b` -} - -fn fu_move_after_move() { - let x = A { a: 1, b: box 2 }; - drop(x.b); - let _z = A { a: 3, .. x }; //~ ERROR use of moved value: `x.b` -} - -fn fu_move_after_fu_move() { - let x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - let _z = A { a: 4, .. x }; //~ ERROR use of moved value: `x.b` -} - -// The following functions aren't yet accepted, but they should be. - -fn copy_after_field_assign_after_uninit() { - let mut x: A; - x.a = 1; - drop(x.a); //~ ERROR use of possibly uninitialized variable: `x.a` -} - -fn borrow_after_field_assign_after_uninit() { - let mut x: A; - x.a = 1; - let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a` - drop(*p); -} - -fn move_after_field_assign_after_uninit() { - let mut x: A; - x.b = box 1; - drop(x.b); //~ ERROR use of possibly uninitialized variable: `x.b` -} - -fn main() { - deref_after_move(); - deref_after_fu_move(); - - borrow_after_move(); - borrow_after_fu_move(); - move_after_borrow(); - fu_move_after_borrow(); - mut_borrow_after_mut_borrow(); - - move_after_move(); - move_after_fu_move(); - fu_move_after_move(); - fu_move_after_fu_move(); - - copy_after_field_assign_after_uninit(); - borrow_after_field_assign_after_uninit(); - move_after_field_assign_after_uninit(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-fn-in-const-a.rs b/src/test/compile-fail/borrowck/borrowck-fn-in-const-a.rs deleted file mode 100644 index 33b78cb26d8..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-fn-in-const-a.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Check that we check fns appearing in constant declarations. -// Issue #22382. - -const MOVE: fn(&String) -> String = { - fn broken(x: &String) -> String { - return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] - //[mir]~^ ERROR [E0507] - } - broken -}; - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-fn-in-const-c.rs b/src/test/compile-fail/borrowck/borrowck-fn-in-const-c.rs deleted file mode 100644 index e607397e920..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-fn-in-const-c.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we check fns appearing in constant declarations. -// Issue #22382. - -// Returning local references? -struct DropString { - inner: String -} -impl Drop for DropString { - fn drop(&mut self) { - self.inner.clear(); - self.inner.push_str("dropped"); - } -} -const LOCAL_REF: fn() -> &'static str = { - fn broken() -> &'static str { - let local = DropString { inner: format!("Some local string") }; - return &local.inner; //~ ERROR does not live long enough - } - broken -}; - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs b/src/test/compile-fail/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs deleted file mode 100644 index 31ec5aea7f3..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #16205. - -#![feature(box_syntax)] - -struct Foo { - a: [Box; 3], -} - -fn main() { - let mut y = 1; - let x = Some(&mut y); - for &a in x.iter() { //~ ERROR cannot move out - } - - let f = Foo { - a: [box 3, box 4, box 5], - }; - for &a in &f.a { //~ ERROR cannot move out - } - - let x: Option> = Some(box 1); - for &a in x.iter() { //~ ERROR cannot move out - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-for-loop-head-linkage.rs b/src/test/compile-fail/borrowck/borrowck-for-loop-head-linkage.rs deleted file mode 100644 index b79fc5b2bf6..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-for-loop-head-linkage.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::iter::repeat; - -fn main() { - let mut vector = vec![1, 2]; - for &x in &vector { - let cap = vector.capacity(); - vector.extend(repeat(0)); //~ ERROR cannot borrow - vector[1] = 5; //~ ERROR cannot borrow - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-if-no-else.rs b/src/test/compile-fail/borrowck/borrowck-if-no-else.rs deleted file mode 100644 index 74b542800b9..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-if-no-else.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: isize) { println!("{}", x); } - -fn main() { - let x: isize; if 1 > 2 { x = 10; } - foo(x); //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/borrowck/borrowck-if-with-else.rs b/src/test/compile-fail/borrowck/borrowck-if-with-else.rs deleted file mode 100644 index f3b02d12854..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-if-with-else.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: isize) { println!("{}", x); } - -fn main() { - let x: isize; - if 1 > 2 { - println!("whoops"); - } else { - x = 10; - } - foo(x); //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs b/src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs deleted file mode 100644 index 6f0e0f43f60..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn main() { - let mut _a = 3; - let b = &mut _a; - { - let c = &*b; - _a = 4; //[ast]~ ERROR cannot assign to `_a` - //[mir]~^ ERROR cannot assign to `_a` because it is borrowed - drop(c); - } - drop(b); -} diff --git a/src/test/compile-fail/borrowck/borrowck-init-in-called-fn-expr.rs b/src/test/compile-fail/borrowck/borrowck-init-in-called-fn-expr.rs deleted file mode 100644 index 5b32fd2d198..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-init-in-called-fn-expr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let j = || -> isize { - let i: isize; - i //~ ERROR use of possibly uninitialized variable: `i` - }; - j(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-init-in-fn-expr.rs b/src/test/compile-fail/borrowck/borrowck-init-in-fn-expr.rs deleted file mode 100644 index 65f1a1fa098..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-init-in-fn-expr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let f = || -> isize { - let i: isize; - i //~ ERROR use of possibly uninitialized variable: `i` - }; - println!("{}", f()); -} diff --git a/src/test/compile-fail/borrowck/borrowck-init-in-fru.rs b/src/test/compile-fail/borrowck/borrowck-init-in-fru.rs deleted file mode 100644 index 1ec0f980774..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-init-in-fru.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#[derive(Clone)] -struct point { - x: isize, - y: isize, -} - -fn main() { - let mut origin: point; - origin = point {x: 10,.. origin}; - //[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381] - //[mir]~^^ ERROR [E0381] - origin.clone(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-init-op-equal.rs b/src/test/compile-fail/borrowck/borrowck-init-op-equal.rs deleted file mode 100644 index e0d93fd1d47..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-init-op-equal.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn test() { - let v: isize; - v += 1; //~ ERROR use of possibly uninitialized variable: `v` - v.clone(); -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-init-plus-equal.rs b/src/test/compile-fail/borrowck/borrowck-init-plus-equal.rs deleted file mode 100644 index a036286f363..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-init-plus-equal.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test() { - let mut v: isize; - v = v + 1; //~ ERROR use of possibly uninitialized variable: `v` - v.clone(); -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-insert-during-each.rs b/src/test/compile-fail/borrowck/borrowck-insert-during-each.rs deleted file mode 100644 index 8499ebb8ac3..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-insert-during-each.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::collections::HashSet; - -struct Foo { - n: HashSet, -} - -impl Foo { - pub fn foo(&mut self, mut fun: F) where F: FnMut(&isize) { - for f in &self.n { - fun(f); - } - } -} - -fn bar(f: &mut Foo) { - f.foo( - |a| { //~ ERROR closure requires unique access to `f` - f.n.insert(*a); - }) -} - -fn main() { - let mut f = Foo { n: HashSet::new() }; - bar(&mut f); -} diff --git a/src/test/compile-fail/borrowck/borrowck-issue-14498.rs b/src/test/compile-fail/borrowck/borrowck-issue-14498.rs deleted file mode 100644 index 3c5f932af47..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-issue-14498.rs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This tests that we can't modify Box<&mut T> contents while they -// are borrowed (#14498). -// -// Also includes tests of the errors reported when the Box in question -// is immutable (#14270). - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(box_syntax)] - -struct A { a: isize } -struct B<'a> { a: Box<&'a mut isize> } - -fn indirect_write_to_imm_box() { - let mut x: isize = 1; - let y: Box<_> = box &mut x; - let p = &y; - ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference - //[mir]~^ ERROR cannot assign to `***p` - drop(p); -} - -fn borrow_in_var_from_var() { - let mut x: isize = 1; - let mut y: Box<_> = box &mut x; - let p = &y; - let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed - drop(p); - drop(q); -} - -fn borrow_in_var_from_var_via_imm_box() { - let mut x: isize = 1; - let y: Box<_> = box &mut x; - let p = &y; - let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed - drop(p); - drop(q); -} - -fn borrow_in_var_from_field() { - let mut x = A { a: 1 }; - let mut y: Box<_> = box &mut x.a; - let p = &y; - let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed - drop(p); - drop(q); -} - -fn borrow_in_var_from_field_via_imm_box() { - let mut x = A { a: 1 }; - let y: Box<_> = box &mut x.a; - let p = &y; - let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed - drop(p); - drop(q); -} - -fn borrow_in_field_from_var() { - let mut x: isize = 1; - let mut y = B { a: box &mut x }; - let p = &y.a; - let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed - drop(p); - drop(q); -} - -fn borrow_in_field_from_var_via_imm_box() { - let mut x: isize = 1; - let y = B { a: box &mut x }; - let p = &y.a; - let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed - drop(p); - drop(q); -} - -fn borrow_in_field_from_field() { - let mut x = A { a: 1 }; - let mut y = B { a: box &mut x.a }; - let p = &y.a; - let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed - drop(p); - drop(q); -} - -fn borrow_in_field_from_field_via_imm_box() { - let mut x = A { a: 1 }; - let y = B { a: box &mut x.a }; - let p = &y.a; - let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed - drop(p); - drop(q); -} - -fn main() { - indirect_write_to_imm_box(); - borrow_in_var_from_var(); - borrow_in_var_from_var_via_imm_box(); - borrow_in_var_from_field(); - borrow_in_var_from_field_via_imm_box(); - borrow_in_field_from_var(); - borrow_in_field_from_var_via_imm_box(); - borrow_in_field_from_field(); - borrow_in_field_from_field_via_imm_box(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-issue-2657-1.rs b/src/test/compile-fail/borrowck/borrowck-issue-2657-1.rs deleted file mode 100644 index 0e1712137d3..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-issue-2657-1.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn main() { - let x: Option> = Some(box 1); - match x { - Some(ref _y) => { - let _a = x; //~ ERROR cannot move - } - _ => {} - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-issue-2657-2.rs b/src/test/compile-fail/borrowck/borrowck-issue-2657-2.rs deleted file mode 100644 index a389a4a5593..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-issue-2657-2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn main() { - let x: Option> = Some(box 1); - match x { - Some(ref y) => { - let _b = *y; //~ ERROR cannot move out - } - _ => {} - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-issue-48962.rs b/src/test/compile-fail/borrowck/borrowck-issue-48962.rs deleted file mode 100644 index e3bbfd9d5fe..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-issue-48962.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(nll)] - -struct Node { - elem: i32, - next: Option>, -} - -fn a() { - let mut node = Node { - elem: 5, - next: None, - }; - - let mut src = &mut node; - {src}; - src.next = None; //~ ERROR use of moved value: `src` [E0382] -} - -fn b() { - let mut src = &mut (22, 44); - {src}; - src.0 = 66; //~ ERROR use of moved value: `src` [E0382] -} - -fn main() { - a(); - b(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-lend-flow-if.rs b/src/test/compile-fail/borrowck/borrowck-lend-flow-if.rs deleted file mode 100644 index a6ce36a5507..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-lend-flow-if.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Note: the borrowck analysis is currently flow-insensitive. -// Therefore, some of these errors are marked as spurious and could be -// corrected by a simple change to the analysis. The others are -// either genuine or would require more advanced changes. The latter -// cases are noted. - -#![feature(box_syntax)] - -fn borrow(_v: &isize) {} -fn borrow_mut(_v: &mut isize) {} -fn cond() -> bool { panic!() } -fn for_func(_f: F) where F: FnOnce() -> bool { panic!() } -fn produce() -> T { panic!(); } - -fn inc(v: &mut Box) { - *v = box (**v + 1); -} - -fn pre_freeze_cond() { - // In this instance, the freeze is conditional and starts before - // the mut borrow. - - let mut v: Box<_> = box 3; - let _w; - if cond() { - _w = &v; - } - borrow_mut(&mut *v); //~ ERROR cannot borrow -} - -fn pre_freeze_else() { - // In this instance, the freeze and mut borrow are on separate sides - // of the if. - - let mut v: Box<_> = box 3; - let _w; - if cond() { - _w = &v; - } else { - borrow_mut(&mut *v); - } -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs deleted file mode 100644 index f09e7ffd7e4..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-lend-flow-loop.rs +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Note: the borrowck analysis is currently flow-insensitive. -// Therefore, some of these errors are marked as spurious and could be -// corrected by a simple change to the analysis. The others are -// either genuine or would require more advanced changes. The latter -// cases are noted. - -#![feature(box_syntax)] - -fn borrow(_v: &isize) {} -fn borrow_mut(_v: &mut isize) {} -fn cond() -> bool { panic!() } -fn produce() -> T { panic!(); } - -fn inc(v: &mut Box) { - *v = box (**v + 1); -} - -fn loop_overarching_alias_mut() { - // In this instance, the borrow encompasses the entire loop. - - let mut v: Box<_> = box 3; - let mut x = &mut v; - **x += 1; - loop { - borrow(&*v); //~ ERROR cannot borrow - } -} - -fn block_overarching_alias_mut() { - // In this instance, the borrow encompasses the entire closure call. - - let mut v: Box<_> = box 3; - let mut x = &mut v; - for _ in 0..3 { - borrow(&*v); //~ ERROR cannot borrow - } - *x = box 5; -} - -fn loop_aliased_mut() { - // In this instance, the borrow is carried through the loop. - - let mut v: Box<_> = box 3; - let mut w: Box<_> = box 4; - let mut _x = &w; - loop { - borrow_mut(&mut *v); //~ ERROR cannot borrow - _x = &v; - } -} - -fn while_aliased_mut() { - // In this instance, the borrow is carried through the loop. - - let mut v: Box<_> = box 3; - let mut w: Box<_> = box 4; - let mut _x = &w; - while cond() { - borrow_mut(&mut *v); //~ ERROR cannot borrow - _x = &v; - } -} - - -fn loop_aliased_mut_break() { - // In this instance, the borrow is carried through the loop. - - let mut v: Box<_> = box 3; - let mut w: Box<_> = box 4; - let mut _x = &w; - loop { - borrow_mut(&mut *v); - _x = &v; - break; - } - borrow_mut(&mut *v); //~ ERROR cannot borrow -} - -fn while_aliased_mut_break() { - // In this instance, the borrow is carried through the loop. - - let mut v: Box<_> = box 3; - let mut w: Box<_> = box 4; - let mut _x = &w; - while cond() { - borrow_mut(&mut *v); - _x = &v; - break; - } - borrow_mut(&mut *v); //~ ERROR cannot borrow -} - -fn while_aliased_mut_cond(cond: bool, cond2: bool) { - let mut v: Box<_> = box 3; - let mut w: Box<_> = box 4; - let mut x = &mut w; - while cond { - **x += 1; - borrow(&*v); //~ ERROR cannot borrow - if cond2 { - x = &mut v; //~ ERROR cannot borrow - } - } -} - -fn loop_break_pops_scopes<'r, F>(_v: &'r mut [usize], mut f: F) where - F: FnMut(&'r mut usize) -> bool, -{ - // Here we check that when you break out of an inner loop, the - // borrows that go out of scope as you exit the inner loop are - // removed from the bitset. - - while cond() { - while cond() { - // this borrow is limited to the scope of `r`... - let r: &'r mut usize = produce(); - if !f(&mut *r) { - break; // ...so it is not live as exit the `while` loop here - } - } - } -} - -fn loop_loop_pops_scopes<'r, F>(_v: &'r mut [usize], mut f: F) - where F: FnMut(&'r mut usize) -> bool -{ - // Similar to `loop_break_pops_scopes` but for the `loop` keyword - - while cond() { - while cond() { - // this borrow is limited to the scope of `r`... - let r: &'r mut usize = produce(); - if !f(&mut *r) { - continue; // ...so it is not live as exit (and re-enter) the `while` loop here - } - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs b/src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs deleted file mode 100644 index f2f3e791422..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-lend-flow-match.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![allow(unused_variables)] -#![allow(unused_assignments)] - -fn separate_arms() { - // Here both arms perform assignments, but only is illegal. - - let mut x = None; - match x { - None => { - // It is ok to reassign x here, because there is in - // fact no outstanding loan of x! - x = Some(0); - } - Some(ref r) => { - x = Some(1); //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed - drop(r); - } - } - x.clone(); // just to prevent liveness warnings -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-lend-flow.rs b/src/test/compile-fail/borrowck/borrowck-lend-flow.rs deleted file mode 100644 index 1ed779cfaac..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-lend-flow.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Note: the borrowck analysis is currently flow-insensitive. -// Therefore, some of these errors are marked as spurious and could be -// corrected by a simple change to the analysis. The others are -// either genuine or would require more advanced changes. The latter -// cases are noted. - -#![feature(box_syntax)] - -fn borrow(_v: &isize) {} -fn borrow_mut(_v: &mut isize) {} -fn cond() -> bool { panic!() } -fn for_func(_f: F) where F: FnOnce() -> bool { panic!() } -fn produce() -> T { panic!(); } - -fn inc(v: &mut Box) { - *v = box (**v + 1); -} - -fn pre_freeze() { - // In this instance, the freeze starts before the mut borrow. - - let mut v: Box<_> = box 3; - let _w = &v; - borrow_mut(&mut *v); //~ ERROR cannot borrow -} - -fn post_freeze() { - // In this instance, the const alias starts after the borrow. - - let mut v: Box<_> = box 3; - borrow_mut(&mut *v); - let _w = &v; -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck/borrowck-loan-blocks-move-cc.rs deleted file mode 100644 index 57b584a8959..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-blocks-move-cc.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -use std::thread; - -fn borrow(v: &isize, f: F) where F: FnOnce(&isize) { - f(v); -} - -fn box_imm() { - let v: Box<_> = box 3; - let _w = &v; - thread::spawn(move|| { - println!("v={}", *v); - //~^ ERROR cannot move `v` into closure - }); -} - -fn box_imm_explicit() { - let v: Box<_> = box 3; - let _w = &v; - thread::spawn(move|| { - println!("v={}", *v); - //~^ ERROR cannot move - }); -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-blocks-move.rs b/src/test/compile-fail/borrowck/borrowck-loan-blocks-move.rs deleted file mode 100644 index f3f18807314..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-blocks-move.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn take(_v: Box) { -} - -fn box_imm() { - let v = box 3; - let _w = &v; - take(v); //~ ERROR cannot move out of `v` because it is borrowed -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-blocks-mut-uniq.rs b/src/test/compile-fail/borrowck/borrowck-loan-blocks-mut-uniq.rs deleted file mode 100644 index 32d8088549d..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-blocks-mut-uniq.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn borrow(v: &isize, f: F) where F: FnOnce(&isize) { - f(v); -} - -fn box_imm() { - let mut v: Box<_> = box 3; - borrow(&*v, - |w| { //~ ERROR cannot borrow `v` as mutable - v = box 4; - assert_eq!(*v, 3); - assert_eq!(*w, 4); - }) -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-in-overloaded-op.rs b/src/test/compile-fail/borrowck/borrowck-loan-in-overloaded-op.rs deleted file mode 100644 index a9079cfc27d..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-in-overloaded-op.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_patterns)] -#![feature(box_syntax)] - -use std::ops::Add; - -#[derive(Clone)] -struct foo(Box); - -impl Add for foo { - type Output = foo; - - fn add(self, f: foo) -> foo { - let foo(box i) = self; - let foo(box j) = f; - foo(box (i + j)) - } -} - -fn main() { - let x = foo(box 3); - let _y = {x} + x.clone(); // the `{x}` forces a move to occur - //~^ ERROR use of moved value: `x` -} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-of-static-data-issue-27616.rs b/src/test/compile-fail/borrowck/borrowck-loan-of-static-data-issue-27616.rs deleted file mode 100644 index 228e71025fd..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-of-static-data-issue-27616.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem; - -fn leak(mut b: Box) -> &'static mut T { - // isn't this supposed to be safe? - let inner = &mut *b as *mut _; - mem::forget(b); - unsafe { &mut *inner } -} - -fn evil(mut s: &'static mut String) -{ - // create alias - let alias: &'static mut String = s; - let inner: &str = &alias; - // free value - *s = String::new(); //~ ERROR cannot assign - let _spray = "0wned".to_owned(); - // ... and then use it - println!("{}", inner); -} - -fn main() { - evil(leak(Box::new("hello".to_owned()))); -} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-rcvr-overloaded-op.rs b/src/test/compile-fail/borrowck/borrowck-loan-rcvr-overloaded-op.rs deleted file mode 100644 index cce55b6c941..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-rcvr-overloaded-op.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Add; - -#[derive(Copy, Clone)] -struct Point { - x: isize, - y: isize, -} - -impl Add for Point { - type Output = isize; - - fn add(self, z: isize) -> isize { - self.x + self.y + z - } -} - -impl Point { - pub fn times(&self, z: isize) -> isize { - self.x * self.y * z - } -} - -fn a() { - let mut p = Point {x: 3, y: 4}; - - // ok (we can loan out rcvr) - p + 3; - p.times(3); -} - -fn b() { - let mut p = Point {x: 3, y: 4}; - - // Here I create an outstanding loan and check that we get conflicts: - - let q = &mut p; - - p + 3; //~ ERROR cannot use `p` - p.times(3); //~ ERROR cannot borrow `p` - - *q + 3; // OK to use the new alias `q` - q.x += 1; // and OK to mutate it -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-rcvr.rs b/src/test/compile-fail/borrowck/borrowck-loan-rcvr.rs deleted file mode 100644 index 014b27f9659..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-rcvr.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct point { x: isize, y: isize } - -trait methods { - fn impurem(&self); - fn blockm(&self, f: F) where F: FnOnce(); -} - -impl methods for point { - fn impurem(&self) { - } - - fn blockm(&self, f: F) where F: FnOnce() { f() } -} - -fn a() { - let mut p = point {x: 3, y: 4}; - - // Here: it's ok to call even though receiver is mutable, because we - // can loan it out. - p.impurem(); - - // But in this case we do not honor the loan: - p.blockm(|| { //~ ERROR cannot borrow `p` as mutable - p.x = 10; - }) -} - -fn b() { - let mut p = point {x: 3, y: 4}; - - // Here I create an outstanding loan and check that we get conflicts: - - let l = &mut p; - p.impurem(); //~ ERROR cannot borrow - - l.x += 1; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-loan-vec-content.rs b/src/test/compile-fail/borrowck/borrowck-loan-vec-content.rs deleted file mode 100644 index c5de95f8fc0..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-loan-vec-content.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Here we check that it is allowed to lend out an element of a -// (locally rooted) mutable, unique vector, and that we then prevent -// modifications to the contents. - -fn takes_imm_elt(_v: &isize, f: F) where F: FnOnce() { - f(); -} - -fn has_mut_vec_and_does_not_try_to_change_it() { - let mut v: Vec = vec![1, 2, 3]; - takes_imm_elt(&v[0], || {}) -} - -fn has_mut_vec_but_tries_to_change_it() { - let mut v: Vec = vec![1, 2, 3]; - takes_imm_elt( - &v[0], - || { //~ ERROR cannot borrow `v` as mutable - v[1] = 4; - }) -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs b/src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs deleted file mode 100644 index 0d5feb6b9cc..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-local-borrow-outlives-fn.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn cplusplus_mode(x: isize) -> &'static isize { - &x - //[ast]~^ ERROR `x` does not live long enough [E0597] - //[mir]~^^ ERROR `x` does not live long enough [E0597] -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs b/src/test/compile-fail/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs deleted file mode 100644 index 2c9ace4825d..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) { - let mut z = (0, 0); - *x = Some(&mut z.1); - //[ast]~^ ERROR `z.1` does not live long enough [E0597] - //[mir]~^^ ERROR `z.1` does not live long enough [E0597] - panic!("catch me for a dangling pointer!") -} - -fn main() { - cplusplus_mode_exceptionally_unsafe(&mut None); -} diff --git a/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs b/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs deleted file mode 100644 index c2136e62a7b..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -enum Foo { - A(i32), - B -} - -fn match_enum() { - let mut foo = Foo::B; - let p = &mut foo; - let _ = match foo { //[mir]~ ERROR [E0503] - Foo::B => 1, //[mir]~ ERROR [E0503] - _ => 2, - Foo::A(x) => x //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] - }; - drop(p); -} - - -fn main() { - let mut x = 1; - let r = &mut x; - let _ = match x { //[mir]~ ERROR [E0503] - x => x + 1, //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] - y => y + 2, //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] - }; - drop(r); -} diff --git a/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs b/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs deleted file mode 100644 index 30047f84041..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-match-binding-is-assignment.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Test that immutable pattern bindings cannot be reassigned. - -enum E { - Foo(isize) -} - -struct S { - bar: isize, -} - -pub fn main() { - match 1 { - x => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] - } - } - - match E::Foo(1) { - E::Foo(x) => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] - } - } - - match (S { bar: 1 }) { - S { bar: x } => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] - } - } - - match (1,) { - (x,) => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] - } - } - - match [1,2,3] { - [x,_,_] => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] - } - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-by-capture.rs b/src/test/compile-fail/borrowck/borrowck-move-by-capture.rs deleted file mode 100644 index bad52121043..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-by-capture.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax,unboxed_closures)] - -fn to_fn_mut>(f: F) -> F { f } -fn to_fn_once>(f: F) -> F { f } - -pub fn main() { - let bar: Box<_> = box 3; - let _g = to_fn_mut(|| { - let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of - }); -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs b/src/test/compile-fail/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs deleted file mode 100644 index c02c6a71514..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// verify that an error is raised when trying to move out of a -// borrowed path. - -#![feature(box_syntax)] - -fn main() { - let a: Box> = box box 2; - let b = &a; - - let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs b/src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs deleted file mode 100644 index 9a39ff6206b..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-from-unsafe-ptr.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -unsafe fn foo(x: *const Box) -> Box { - let y = *x; //~ ERROR cannot move out of dereference of raw pointer - return y; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-in-irrefut-pat.rs b/src/test/compile-fail/borrowck/borrowck-move-in-irrefut-pat.rs deleted file mode 100644 index 5fdde484f82..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-in-irrefut-pat.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn with(f: F) where F: FnOnce(&String) {} - -fn arg_item(&_x: &String) {} - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] - -fn arg_closure() { - with(|&_x| ()) - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] -} - -fn let_pat() { - let &_x = &"hi".to_string(); - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] -} - -pub fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-move-moved-value-into-closure.rs b/src/test/compile-fail/borrowck/borrowck-move-moved-value-into-closure.rs deleted file mode 100644 index 2bd6f75df1b..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-moved-value-into-closure.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(box_syntax)] - -fn call_f isize>(f: F) -> isize { - f() -} - -fn main() { - let t: Box<_> = box 3; - - call_f(move|| { *t + 1 }); - call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value - //[mir]~^ ERROR use of moved value -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-mut-base-ptr.rs b/src/test/compile-fail/borrowck/borrowck-move-mut-base-ptr.rs deleted file mode 100644 index 2fb89e6364b..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-mut-base-ptr.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that attempt to move `&mut` pointer while pointee is borrowed -// yields an error. -// -// Example from src/librustc_borrowck/borrowck/README.md - -fn foo(t0: &mut isize) { - let p: &isize = &*t0; // Freezes `*t0` - let t1 = t0; //~ ERROR cannot move out of `t0` - *t1 = 22; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-out-from-array.rs b/src/test/compile-fail/borrowck/borrowck-move-out-from-array.rs deleted file mode 100644 index 0db31cef0ed..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-out-from-array.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(box_syntax)] -#![feature(slice_patterns)] - -fn move_out_from_begin_and_end() { - let a = [box 1, box 2]; - let [_, _x] = a; - let [.., _y] = a; //[ast]~ ERROR [E0382] - //[mir]~^ ERROR [E0382] -} - -fn move_out_by_const_index_and_subslice() { - let a = [box 1, box 2]; - let [_x, _] = a; - let [_y..] = a; //[ast]~ ERROR [E0382] - //[mir]~^ ERROR [E0382] -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs b/src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs deleted file mode 100644 index af9202d8d77..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -use std::rc::Rc; - -pub fn main() { - let _x = Rc::new(vec![1, 2]).into_iter(); - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-deref.rs b/src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-deref.rs deleted file mode 100644 index fffcf575ab0..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-out-of-overloaded-deref.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::rc::Rc; - -pub fn main() { - let _x = *Rc::new("hi".to_string()); - //~^ ERROR cannot move out of borrowed content -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-out-of-static-item.rs b/src/test/compile-fail/borrowck/borrowck-move-out-of-static-item.rs deleted file mode 100644 index 79eb68c95a0..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-out-of-static-item.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Ensure that moves out of static items is forbidden - -struct Foo { - foo: isize, -} - -static BAR: Foo = Foo { foo: 5 }; - - -fn test(f: Foo) { - let _f = Foo{foo: 4, ..f}; -} - -fn main() { - test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] - //[mir]~^ ERROR [E0507] -} diff --git a/src/test/compile-fail/borrowck/borrowck-move-out-of-struct-with-dtor.rs b/src/test/compile-fail/borrowck/borrowck-move-out-of-struct-with-dtor.rs deleted file mode 100644 index 4bb66ace026..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-out-of-struct-with-dtor.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -struct S {f:String} -impl Drop for S { - fn drop(&mut self) { println!("{}", self.f); } -} - -fn move_in_match() { - match (S {f:"foo".to_string()}) { - //[mir]~^ ERROR [E0509] - S {f:_s} => {} - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] - } -} - -fn move_in_let() { - let S {f:_s} = S {f:"foo".to_string()}; - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] - //[mir]~^^ ERROR [E0509] -} - -fn move_in_fn_arg(S {f:_s}: S) { - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] - //[mir]~^^ ERROR [E0509] -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs b/src/test/compile-fail/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs deleted file mode 100644 index f5fedb8d487..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S(String); -impl Drop for S { - fn drop(&mut self) { } -} - -fn move_in_match() { - match S("foo".to_string()) { - S(_s) => {} - //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait - } -} - -fn move_in_let() { - let S(_s) = S("foo".to_string()); - //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait -} - -fn move_in_fn_arg(S(_s): S) { - //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-move-subcomponent.rs b/src/test/compile-fail/borrowck/borrowck-move-subcomponent.rs deleted file mode 100644 index 88871dda659..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-move-subcomponent.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that the borrow checker checks all components of a path when moving -// out. - -#![feature(box_syntax)] - -struct S { - x : Box -} - -fn f(_: T) {} - -fn main() { - let a : S = S { x : box 1 }; - let pb = &a; - let S { x: ax } = a; //~ ERROR cannot move out - f(pb); -} diff --git a/src/test/compile-fail/borrowck/borrowck-multiple-captures.rs b/src/test/compile-fail/borrowck/borrowck-multiple-captures.rs deleted file mode 100644 index 042b914ce41..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-multiple-captures.rs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -use std::thread; - -fn borrow(_: &T) { } - -fn different_vars_after_borrows() { - let x1: Box<_> = box 1; - let p1 = &x1; - let x2: Box<_> = box 2; - let p2 = &x2; - thread::spawn(move|| { - drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed - drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed - }); - borrow(&*p1); - borrow(&*p2); -} - -fn different_vars_after_moves() { - let x1: Box<_> = box 1; - drop(x1); - let x2: Box<_> = box 2; - drop(x2); - thread::spawn(move|| { - drop(x1); //~ ERROR capture of moved value: `x1` - drop(x2); //~ ERROR capture of moved value: `x2` - }); -} - -fn same_var_after_borrow() { - let x: Box<_> = box 1; - let p = &x; - thread::spawn(move|| { - drop(x); //~ ERROR cannot move `x` into closure because it is borrowed - drop(x); //~ ERROR use of moved value: `x` - }); - borrow(&*p); -} - -fn same_var_after_move() { - let x: Box<_> = box 1; - drop(x); - thread::spawn(move|| { - drop(x); //~ ERROR capture of moved value: `x` - drop(x); //~ ERROR use of moved value: `x` - }); -} - -fn main() { - different_vars_after_borrows(); - different_vars_after_moves(); - same_var_after_borrow(); - same_var_after_move(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-mut-addr-of-imm-var.rs b/src/test/compile-fail/borrowck/borrowck-mut-addr-of-imm-var.rs deleted file mode 100644 index b6626a835e4..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-mut-addr-of-imm-var.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x: isize = 3; - let y: &mut isize = &mut x; //~ ERROR cannot borrow - *y = 5; - println!("{}", *y); -} diff --git a/src/test/compile-fail/borrowck/borrowck-mut-borrow-linear-errors.rs b/src/test/compile-fail/borrowck/borrowck-mut-borrow-linear-errors.rs deleted file mode 100644 index 7b0a71815a5..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-mut-borrow-linear-errors.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test to ensure we only report an error for the first issued loan that -// conflicts with a new loan, as opposed to every issued loan. This keeps us -// down to O(n) errors (for n problem lines), instead of O(n^2) errors. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn main() { - let mut x = 1; - let mut addr = vec![]; - loop { - match 1 { - 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] - 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] - _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] - } - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs b/src/test/compile-fail/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs deleted file mode 100644 index bdeb7ea69bd..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that attempt to mutably borrow `&mut` pointer while pointee is -// borrowed yields an error. -// -// Example from src/librustc_borrowck/borrowck/README.md - -fn foo<'a>(mut t0: &'a mut isize, - mut t1: &'a mut isize) { - let p: &isize = &*t0; // Freezes `*t0` - let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` - **t2 += 1; // Mutates `*t0` -} - -fn bar<'a>(mut t0: &'a mut isize, - mut t1: &'a mut isize) { - let p: &mut isize = &mut *t0; // Claims `*t0` - let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` - **t2 += 1; // Mutates `*t0` but not through `*p` -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-mut-slice-of-imm-vec.rs b/src/test/compile-fail/borrowck/borrowck-mut-slice-of-imm-vec.rs deleted file mode 100644 index 4e0304e20c0..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-mut-slice-of-imm-vec.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn write(v: &mut [isize]) { - v[0] += 1; -} - -fn main() { - let v = vec![1, 2, 3]; - write(&mut v); //~ ERROR cannot borrow -} diff --git a/src/test/compile-fail/borrowck/borrowck-mutate-in-guard.rs b/src/test/compile-fail/borrowck/borrowck-mutate-in-guard.rs deleted file mode 100644 index e35edca639e..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-mutate-in-guard.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Enum<'a> { - A(&'a isize), - B(bool), -} - -fn foo() -> isize { - let mut n = 42; - let mut x = Enum::A(&mut n); - match x { - Enum::A(_) if { x = Enum::B(false); false } => 1, - //~^ ERROR cannot assign in a pattern guard - Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - //~^ ERROR cannot mutably borrow in a pattern guard - //~^^ ERROR cannot assign in a pattern guard - Enum::A(p) => *p, - Enum::B(_) => 2, - } -} - -fn main() { - foo(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-no-cycle-in-exchange-heap.rs b/src/test/compile-fail/borrowck/borrowck-no-cycle-in-exchange-heap.rs deleted file mode 100644 index 8cb7423f3cb..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-no-cycle-in-exchange-heap.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct node_ { - a: Box -} - -enum cycle { - node(node_), - empty -} -fn main() { - let mut x: Box<_> = box cycle::node(node_ {a: box cycle::empty}); - // Create a cycle! - match *x { - cycle::node(ref mut y) => { - y.a = x; //~ ERROR cannot move out of - } - cycle::empty => {} - }; -} diff --git a/src/test/compile-fail/borrowck/borrowck-object-lifetime.rs b/src/test/compile-fail/borrowck/borrowck-object-lifetime.rs deleted file mode 100644 index 021b3f38e00..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-object-lifetime.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that borrows that occur due to calls to object methods -// properly "claim" the object path. - -trait Foo { - fn borrowed(&self) -> &(); - fn mut_borrowed(&mut self) -> &(); -} - -fn borrowed_receiver(x: &Foo) { - let _y = x.borrowed(); - let _z = x.borrowed(); -} - -fn mut_borrowed_receiver(x: &mut Foo) { - let _y = x.borrowed(); - let _z = x.mut_borrowed(); //~ ERROR cannot borrow -} - -fn mut_owned_receiver(mut x: Box) { - let _y = x.borrowed(); - let _z = &mut x; //~ ERROR cannot borrow -} - -fn imm_owned_receiver(mut x: Box) { - let _y = x.borrowed(); - let _z = &x; -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-or-init.rs b/src/test/compile-fail/borrowck/borrowck-or-init.rs deleted file mode 100644 index 27871a6ab16..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-or-init.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let i: isize; - - println!("{}", false || { i = 5; true }); - println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` -} diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-call.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-call.rs deleted file mode 100644 index 41f3e472cd1..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-call.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(fn_traits, unboxed_closures)] - -use std::ops::{Fn, FnMut, FnOnce}; - -struct SFn { - x: isize, - y: isize, -} - -impl Fn<(isize,)> for SFn { - extern "rust-call" fn call(&self, (z,): (isize,)) -> isize { - self.x * self.y * z - } -} - -impl FnMut<(isize,)> for SFn { - extern "rust-call" fn call_mut(&mut self, args: (isize,)) -> isize { self.call(args) } -} - -impl FnOnce<(isize,)> for SFn { - type Output = isize; - extern "rust-call" fn call_once(self, args: (isize,)) -> isize { self.call(args) } -} - -struct SFnMut { - x: isize, - y: isize, -} - -impl FnMut<(isize,)> for SFnMut { - extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize { - self.x * self.y * z - } -} - -impl FnOnce<(isize,)> for SFnMut { - type Output = isize; - extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) } -} - -struct SFnOnce { - x: String, -} - -impl FnOnce<(String,)> for SFnOnce { - type Output = usize; - - extern "rust-call" fn call_once(self, (z,): (String,)) -> usize { - self.x.len() + z.len() - } -} - -fn f() { - let mut s = SFn { - x: 1, - y: 2, - }; - let sp = &mut s; - s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable -} - -fn g() { - let s = SFnMut { - x: 1, - y: 2, - }; - s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable -} - -fn h() { - let s = SFnOnce { - x: "hello".to_string(), - }; - s(" world".to_string()); - s(" world".to_string()); //~ ERROR use of moved value: `s` -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs deleted file mode 100644 index 931d053ae7b..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we properly record borrows when we are doing an -// overloaded, autoderef of a value obtained via an overloaded index -// operator. The accounting of the all the implicit things going on -// here is rather subtle. Issue #20232. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -use std::ops::{Deref, Index}; - -struct MyVec { x: T } - -impl Index for MyVec { - type Output = T; - fn index(&self, _: usize) -> &T { - &self.x - } -} - -struct MyPtr { x: T } - -impl Deref for MyPtr { - type Target = T; - fn deref(&self) -> &T { - &self.x - } -} - -struct Foo { f: usize } - -fn main() { - let mut v = MyVec { x: MyPtr { x: Foo { f: 22 } } }; - let i = &v[0].f; - v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - //[ast]~^ ERROR cannot assign to `v` - //[mir]~^^ ERROR cannot assign to `v` because it is borrowed - read(*i); -} - -fn read(_: usize) { } diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-autoderef.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-autoderef.rs deleted file mode 100644 index b726c46d5d5..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-autoderef.rs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we still see borrowck errors of various kinds when using -// indexing and autoderef in combination. - -use std::ops::{Index, IndexMut}; - -struct Foo { - x: isize, - y: isize, -} - -impl<'a> Index<&'a String> for Foo { - type Output = isize; - - fn index(&self, z: &String) -> &isize { - if *z == "x" { - &self.x - } else { - &self.y - } - } -} - -impl<'a> IndexMut<&'a String> for Foo { - fn index_mut(&mut self, z: &String) -> &mut isize { - if *z == "x" { - &mut self.x - } else { - &mut self.y - } - } -} - -fn test1(mut f: Box, s: String) { - let _p = &mut f[&s]; - let _q = &f[&s]; //~ ERROR cannot borrow -} - -fn test2(mut f: Box, s: String) { - let _p = &mut f[&s]; - let _q = &mut f[&s]; //~ ERROR cannot borrow -} - -struct Bar { - foo: Foo -} - -fn test3(mut f: Box, s: String) { - let _p = &mut f.foo[&s]; - let _q = &mut f.foo[&s]; //~ ERROR cannot borrow -} - -fn test4(mut f: Box, s: String) { - let _p = &f.foo[&s]; - let _q = &f.foo[&s]; -} - -fn test5(mut f: Box, s: String) { - let _p = &f.foo[&s]; - let _q = &mut f.foo[&s]; //~ ERROR cannot borrow -} - -fn test6(mut f: Box, g: Foo, s: String) { - let _p = &f.foo[&s]; - f.foo = g; //~ ERROR cannot assign -} - -fn test7(mut f: Box, g: Bar, s: String) { - let _p = &f.foo[&s]; - *f = g; //~ ERROR cannot assign -} - -fn test8(mut f: Box, g: Foo, s: String) { - let _p = &mut f.foo[&s]; - f.foo = g; //~ ERROR cannot assign -} - -fn test9(mut f: Box, g: Bar, s: String) { - let _p = &mut f.foo[&s]; - *f = g; //~ ERROR cannot assign -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-move-from-vec.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-move-from-vec.rs deleted file mode 100644 index df72c2b0af7..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-move-from-vec.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -use std::ops::Index; - -struct MyVec { - data: Vec, -} - -impl Index for MyVec { - type Output = T; - - fn index(&self, i: usize) -> &T { - &self.data[i] - } -} - -fn main() { - let v = MyVec::> { data: vec![box 1, box 2, box 3] }; - let good = &v[0]; // Shouldn't fail here - let bad = v[0]; - //~^ ERROR cannot move out of indexed content -} diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-move-index.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-move-index.rs deleted file mode 100644 index d8615d19053..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-move-index.rs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::{Index, IndexMut}; - -struct Foo { - x: isize, - y: isize, -} - -impl Index for Foo { - type Output = isize; - - fn index(&self, z: String) -> &isize { - if z == "x" { - &self.x - } else { - &self.y - } - } -} - -impl IndexMut for Foo { - fn index_mut(&mut self, z: String) -> &mut isize { - if z == "x" { - &mut self.x - } else { - &mut self.y - } - } -} - -struct Bar { - x: isize, -} - -impl Index for Bar { - type Output = isize; - - fn index<'a>(&'a self, z: isize) -> &'a isize { - &self.x - } -} - -fn main() { - let mut f = Foo { - x: 1, - y: 2, - }; - let mut s = "hello".to_string(); - let rs = &mut s; - - println!("{}", f[s]); - //~^ ERROR cannot move out of `s` because it is borrowed - - f[s] = 10; - //~^ ERROR cannot move out of `s` because it is borrowed - //~| ERROR use of moved value: `s` - - let s = Bar { - x: 1, - }; - let i = 2; - let _j = &i; - println!("{}", s[i]); // no error, i is copy - println!("{}", s[i]); -} diff --git a/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs b/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs deleted file mode 100644 index f4f40e0407f..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-overloaded-index-ref-index.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -use std::ops::{Index, IndexMut}; - -struct Foo { - x: isize, - y: isize, -} - -impl<'a> Index<&'a String> for Foo { - type Output = isize; - - fn index(&self, z: &String) -> &isize { - if *z == "x" { - &self.x - } else { - &self.y - } - } -} - -impl<'a> IndexMut<&'a String> for Foo { - fn index_mut(&mut self, z: &String) -> &mut isize { - if *z == "x" { - &mut self.x - } else { - &mut self.y - } - } -} - -struct Bar { - x: isize, -} - -impl Index for Bar { - type Output = isize; - - fn index<'a>(&'a self, z: isize) -> &'a isize { - &self.x - } -} - -fn main() { - let mut f = Foo { - x: 1, - y: 2, - }; - let mut s = "hello".to_string(); - let rs = &mut s; - println!("{}", f[&s]); - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - f[&s] = 10; - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - let s = Bar { - x: 1, - }; - s[2] = 20; - //[ast]~^ ERROR cannot assign to immutable indexed content - //[mir]~^^ ERROR cannot assign to data in a `&` reference - drop(rs); -} diff --git a/src/test/compile-fail/borrowck/borrowck-partial-reinit-1.rs b/src/test/compile-fail/borrowck/borrowck-partial-reinit-1.rs deleted file mode 100644 index 1ee040a0705..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-partial-reinit-1.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Test; - -struct Test2 { - b: Option, -} - -struct Test3(Option); - -impl Drop for Test { - fn drop(&mut self) { - println!("dropping!"); - } -} - -impl Drop for Test2 { - fn drop(&mut self) {} -} - -impl Drop for Test3 { - fn drop(&mut self) {} -} - -fn stuff() { - let mut t = Test2 { b: None }; - let u = Test; - drop(t); - t.b = Some(u); - //~^ ERROR partial reinitialization of uninitialized structure `t` - - let mut t = Test3(None); - let u = Test; - drop(t); - t.0 = Some(u); - //~^ ERROR partial reinitialization of uninitialized structure `t` -} - -fn main() { - stuff() -} diff --git a/src/test/compile-fail/borrowck/borrowck-partial-reinit-2.rs b/src/test/compile-fail/borrowck/borrowck-partial-reinit-2.rs deleted file mode 100644 index c9cdeff9c7a..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-partial-reinit-2.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Test { - a: isize, - b: Option>, -} - -impl Drop for Test { - fn drop(&mut self) { - println!("Dropping {}", self.a); - } -} - -fn stuff() { - let mut t = Test { a: 1, b: None}; - let mut u = Test { a: 2, b: Some(Box::new(t))}; - t.b = Some(Box::new(u)); - //~^ ERROR partial reinitialization of uninitialized structure `t` - println!("done"); -} - -fn main() { - stuff(); - println!("Hello, world!") -} diff --git a/src/test/compile-fail/borrowck/borrowck-partial-reinit-3.rs b/src/test/compile-fail/borrowck/borrowck-partial-reinit-3.rs deleted file mode 100644 index 0aa73892b82..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-partial-reinit-3.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -use std::mem; - -struct Test { f: usize } -impl Drop for Test { - fn drop(&mut self) {} -} - -fn main() { - let mut x = (Test { f: 2 }, Test { f: 4 }); - mem::drop(x.0); - x.0.f = 3; - //~^ ERROR partial reinitialization of uninitialized structure `x.0` -} diff --git a/src/test/compile-fail/borrowck/borrowck-partial-reinit-4.rs b/src/test/compile-fail/borrowck/borrowck-partial-reinit-4.rs deleted file mode 100644 index 774e04ecb29..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-partial-reinit-4.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Test; - -struct Test2(Option); - -impl Drop for Test { - fn drop(&mut self) { - println!("dropping!"); - } -} - -impl Drop for Test2 { - fn drop(&mut self) {} -} - -fn stuff() { - let mut x : (Test2, Test2); - (x.0).0 = Some(Test); - //~^ ERROR partial reinitialization of uninitialized structure `x.0` -} - -fn main() { - stuff() -} diff --git a/src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs b/src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs deleted file mode 100644 index d917a0abb88..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-pat-reassign-binding.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn main() { - let mut x: Option = None; - match x { - None => { - // Note: on this branch, no borrow has occurred. - x = Some(0); - } - Some(ref i) => { - // But on this branch, `i` is an outstanding borrow - x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` - //[mir]~^ ERROR cannot assign to `x` because it is borrowed - drop(i); - } - } - x.clone(); // just to prevent liveness warnings -} diff --git a/src/test/compile-fail/borrowck/borrowck-reborrow-from-mut.rs b/src/test/compile-fail/borrowck/borrowck-reborrow-from-mut.rs deleted file mode 100644 index 6f5dfa67be5..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-reborrow-from-mut.rs +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - bar1: Bar, - bar2: Bar -} - -struct Bar { - int1: isize, - int2: isize, -} - -fn borrow_same_field_twice_mut_mut(foo: &mut Foo) { - let _bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow -} - -fn borrow_same_field_twice_mut_imm(foo: &mut Foo) { - let _bar1 = &mut foo.bar1; - let _bar2 = &foo.bar1; //~ ERROR cannot borrow -} - -fn borrow_same_field_twice_imm_mut(foo: &mut Foo) { - let _bar1 = &foo.bar1; - let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow -} - -fn borrow_same_field_twice_imm_imm(foo: &mut Foo) { - let _bar1 = &foo.bar1; - let _bar2 = &foo.bar1; -} - -fn borrow_both_mut(foo: &mut Foo) { - let _bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar2; -} - -fn borrow_both_mut_pattern(foo: &mut Foo) { - match *foo { - Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} - } -} - -fn borrow_var_and_pattern(foo: &mut Foo) { - let _bar1 = &mut foo.bar1; - match *foo { - Foo { bar1: ref mut _bar1, bar2: _ } => {} - //~^ ERROR cannot borrow - } -} - -fn borrow_mut_and_base_imm(foo: &mut Foo) { - let _bar1 = &mut foo.bar1.int1; - let _foo1 = &foo.bar1; //~ ERROR cannot borrow - let _foo2 = &*foo; //~ ERROR cannot borrow -} - -fn borrow_mut_and_base_mut(foo: &mut Foo) { - let _bar1 = &mut foo.bar1.int1; - let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow -} - -fn borrow_mut_and_base_mut2(foo: &mut Foo) { - let _bar1 = &mut foo.bar1.int1; - let _foo2 = &mut *foo; //~ ERROR cannot borrow -} - -fn borrow_imm_and_base_mut(foo: &mut Foo) { - let _bar1 = &foo.bar1.int1; - let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow -} - -fn borrow_imm_and_base_mut2(foo: &mut Foo) { - let _bar1 = &foo.bar1.int1; - let _foo2 = &mut *foo; //~ ERROR cannot borrow -} - -fn borrow_imm_and_base_imm(foo: &mut Foo) { - let _bar1 = &foo.bar1.int1; - let _foo1 = &foo.bar1; - let _foo2 = &*foo; -} - -fn borrow_mut_and_imm(foo: &mut Foo) { - let _bar1 = &mut foo.bar1; - let _foo1 = &foo.bar2; -} - -fn borrow_mut_from_imm(foo: &Foo) { - let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow -} - -fn borrow_long_path_both_mut(foo: &mut Foo) { - let _bar1 = &mut foo.bar1.int1; - let _foo1 = &mut foo.bar2.int2; -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs b/src/test/compile-fail/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs deleted file mode 100644 index af85e68f5de..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that assignments to an `&mut` pointer which is found in a -// borrowed (but otherwise non-aliasable) location is illegal. - -struct S<'a> { - pointer: &'a mut isize -} - -fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { - S { pointer: &mut *p.pointer } - //~^ ERROR lifetime mismatch -} - -fn main() { - let mut x = 1; - - { - let mut y = S { pointer: &mut x }; - let z = copy_borrowed_ptr(&mut y); - *y.pointer += 1; - *z.pointer += 1; - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-ref-mut-of-imm.rs b/src/test/compile-fail/borrowck/borrowck-ref-mut-of-imm.rs deleted file mode 100644 index 1784b72a699..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-ref-mut-of-imm.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn destructure(x: Option) -> isize { - match x { - None => 0, - Some(ref mut v) => *v //~ ERROR cannot borrow - } -} - -fn main() { - assert_eq!(destructure(Some(22)), 22); -} diff --git a/src/test/compile-fail/borrowck/borrowck-return-variable-on-stack-via-clone.rs b/src/test/compile-fail/borrowck/borrowck-return-variable-on-stack-via-clone.rs deleted file mode 100644 index 7529943f0bc..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-return-variable-on-stack-via-clone.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that when we clone a `&T` pointer we properly relate the -// lifetime of the pointer which results to the pointer being cloned. -// Bugs in method resolution have sometimes broken this connection. -// Issue #19261. - -fn leak<'a, T>(x: T) -> &'a T { - (&x).clone() //~ ERROR `x` does not live long enough -} - -fn main() { } diff --git a/src/test/compile-fail/borrowck/borrowck-return.rs b/src/test/compile-fail/borrowck/borrowck-return.rs deleted file mode 100644 index 74d435b35e7..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-return.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() -> isize { - let x: isize; - return x; //~ ERROR use of possibly uninitialized variable: `x` -} - -fn main() { f(); } diff --git a/src/test/compile-fail/borrowck/borrowck-storage-dead.rs b/src/test/compile-fail/borrowck/borrowck-storage-dead.rs deleted file mode 100644 index bc01088696d..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-storage-dead.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z borrowck=compare - -fn ok() { - loop { - let _x = 1; - } -} - -fn also_ok() { - loop { - let _x = String::new(); - } -} - -fn fail() { - loop { - let x: i32; - let _ = x + 1; //~ERROR (Ast) [E0381] - //~^ ERROR (Mir) [E0381] - } -} - -fn main() { - ok(); - also_ok(); - fail(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-struct-update-with-dtor.rs b/src/test/compile-fail/borrowck/borrowck-struct-update-with-dtor.rs deleted file mode 100644 index f90651687a5..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-struct-update-with-dtor.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Issue 4691: Ensure that functional-struct-update can only copy, not -// move, when the struct implements Drop. - -struct B; -struct S { a: isize, b: B } -impl Drop for S { fn drop(&mut self) { } } - -struct T { a: isize, mv: Box } -impl Drop for T { fn drop(&mut self) { } } - -fn f(s0:S) { - let _s2 = S{a: 2, ..s0}; - //[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait - //[mir]~^^ ERROR [E0509] -} - -fn g(s0:T) { - let _s2 = T{a: 2, ..s0}; - //[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait - //[mir]~^^ ERROR [E0509] -} - -fn main() { } diff --git a/src/test/compile-fail/borrowck/borrowck-swap-mut-base-ptr.rs b/src/test/compile-fail/borrowck/borrowck-swap-mut-base-ptr.rs deleted file mode 100644 index 552fcec8e28..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-swap-mut-base-ptr.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that attempt to swap `&mut` pointer while pointee is borrowed -// yields an error. -// -// Example from src/librustc_borrowck/borrowck/README.md - -use std::mem::swap; - -fn foo<'a>(mut t0: &'a mut isize, - mut t1: &'a mut isize) { - let p: &isize = &*t0; // Freezes `*t0` - swap(&mut t0, &mut t1); //~ ERROR cannot borrow `t0` - *t1 = 22; -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs b/src/test/compile-fail/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs deleted file mode 100644 index 7aa02558446..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(thread_local)] - -#[thread_local] -static FOO: u8 = 3; - -fn assert_static(_t: &'static u8) {} -fn main() { - assert_static(&FOO); //[ast]~ ERROR [E0597] - //[mir]~^ ERROR [E0712] -} diff --git a/src/test/compile-fail/borrowck/borrowck-unary-move.rs b/src/test/compile-fail/borrowck/borrowck-unary-move.rs deleted file mode 100644 index 8163ce29939..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-unary-move.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn foo(x: Box) -> isize { - let y = &*x; - free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed - //[mir]~^ ERROR cannot move out of `x` because it is borrowed - *y -} - -fn free(_x: Box) { -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs b/src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs deleted file mode 100644 index 4813b4b6a72..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-unboxed-closures.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn a isize>(mut f: F) { - let g = &mut f; - f(1, 2); //~ ERROR cannot borrow `f` as immutable -} - -fn b isize>(f: F) { - f(1, 2); //~ ERROR cannot borrow immutable argument -} - -fn c isize>(f: F) { - f(1, 2); - f(1, 2); //~ ERROR use of moved value -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-uninit-after-item.rs b/src/test/compile-fail/borrowck/borrowck-uninit-after-item.rs deleted file mode 100644 index acd827d6c62..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-uninit-after-item.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let bar; - fn baz(_x: isize) { } - baz(bar); //~ ERROR use of possibly uninitialized variable: `bar` -} diff --git a/src/test/compile-fail/borrowck/borrowck-uninit-field-access.rs b/src/test/compile-fail/borrowck/borrowck-uninit-field-access.rs deleted file mode 100644 index eec7df84c82..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-uninit-field-access.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Check that do not allow access to fields of uninitialized or moved -// structs. - -#[derive(Default)] -struct Point { - x: isize, - y: isize, -} - -#[derive(Default)] -struct Line { - origin: Point, - middle: Point, - target: Point, -} - -impl Line { fn consume(self) { } } - -fn main() { - let mut a: Point; - let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` - //[mir]~^ ERROR [E0381] - - let mut line1 = Line::default(); - let _moved = line1.origin; - let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` - //[mir]~^ [E0382] - - let mut line2 = Line::default(); - let _moved = (line2.origin, line2.middle); - line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] - //[mir]~^ [E0382] -} diff --git a/src/test/compile-fail/borrowck/borrowck-uninit-in-assignop.rs b/src/test/compile-fail/borrowck/borrowck-uninit-in-assignop.rs deleted file mode 100644 index e253ecc74b9..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-uninit-in-assignop.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that the use of uninitialized variable in assignment operator -// expression is detected. - -pub fn main() { - let x: isize; - x += 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x -= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x *= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x /= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x %= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x ^= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x &= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x |= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x <<= 1; //~ ERROR use of possibly uninitialized variable: `x` - - let x: isize; - x >>= 1; //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/borrowck/borrowck-uninit-ref-chain.rs b/src/test/compile-fail/borrowck/borrowck-uninit-ref-chain.rs deleted file mode 100644 index c52b1f0bf64..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-uninit-ref-chain.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -struct S { - x: X, - y: Y, -} - -fn main() { - let x: &&Box; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] - - let x: &&S; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] - - let x: &&i32; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] - - - let mut a: S; - a.x = 0; - let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] - // (deliberately *not* an error under MIR-borrowck) - - let mut a: S<&&i32, &&i32>; - a.x = &&0; - let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] - // (deliberately *not* an error under MIR-borrowck) - - - let mut a: S; - a.x = 0; - let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] - //[mir]~^ ERROR [E0381] - - let mut a: S<&&i32, &&i32>; - a.x = &&0; - let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] - //[mir]~^ ERROR [E0381] -} diff --git a/src/test/compile-fail/borrowck/borrowck-uninit.rs b/src/test/compile-fail/borrowck/borrowck-uninit.rs deleted file mode 100644 index f4b73bc889f..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-uninit.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: isize) { println!("{}", x); } - -fn main() { - let x: isize; - foo(x); //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs b/src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs deleted file mode 100644 index 6298c87453c..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-union-borrow-nested.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Clone, Copy)] -struct S { - a: u8, - b: u16, -} - -#[derive(Clone, Copy)] -union U { - s: S, - c: u32, -} - -fn main() { - unsafe { - { - let mut u = U { s: S { a: 0, b: 1 } }; - let ra = &mut u.s.a; - let b = u.s.b; // OK - } - { - let mut u = U { s: S { a: 0, b: 1 } }; - let ra = &mut u.s.a; - let b = u.c; //~ ERROR cannot use `u.c` because it was mutably borrowed - } - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-union-borrow.rs b/src/test/compile-fail/borrowck/borrowck-union-borrow.rs deleted file mode 100644 index 97193bd0191..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-union-borrow.rs +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#[derive(Clone, Copy)] -union U { - a: u8, - b: u64, -} - -fn main() { - unsafe { - let mut u = U { b: 0 }; - // Imm borrow, same field - { - let ra = &u.a; - let ra2 = &u.a; // OK - drop(ra); - } - { - let ra = &u.a; - let a = u.a; // OK - drop(ra); - } - { - let ra = &u.a; - let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable - //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable - drop(ra); - } - { - let ra = &u.a; - u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed - drop(ra); - } - // Imm borrow, other field - { - let ra = &u.a; - let rb = &u.b; // OK - drop(ra); - } - { - let ra = &u.a; - let b = u.b; // OK - drop(ra); - } - { - let ra = &u.a; - let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) - //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable - drop(ra); - } - { - let ra = &u.a; - u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed - //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed - drop(ra); - } - // Mut borrow, same field - { - let rma = &mut u.a; - let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable - //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable - drop(rma); - } - { - let ra = &mut u.a; - let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed - drop(ra); - } - { - let rma = &mut u.a; - let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time - drop(rma); - } - { - let rma = &mut u.a; - u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed - drop(rma); - } - // Mut borrow, other field - { - let rma = &mut u.a; - let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) - //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable - drop(rma); - } - { - let ra = &mut u.a; - let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.b` because it was mutably borrowed - - drop(ra); - } - { - let rma = &mut u.a; - let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time - drop(rma); - } - { - let rma = &mut u.a; - u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed - //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed - drop(rma); - } - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-union-move-assign.rs b/src/test/compile-fail/borrowck/borrowck-union-move-assign.rs deleted file mode 100644 index d4d7bc6b0f7..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-union-move-assign.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] - -// Non-copy -struct A; -struct B; - -union U { - a: A, - b: B, -} - -fn main() { - unsafe { - { - let mut u = U { a: A }; - let a = u.a; - let a = u.a; //~ ERROR use of moved value: `u.a` - } - { - let mut u = U { a: A }; - let a = u.a; - u.a = A; - let a = u.a; // OK - } - { - let mut u = U { a: A }; - let a = u.a; - u.b = B; - let a = u.a; // OK - } - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-union-move.rs b/src/test/compile-fail/borrowck/borrowck-union-move.rs deleted file mode 100644 index 5320244cf43..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-union-move.rs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] - -#[derive(Clone, Copy)] -struct Copy; -struct NonCopy; - -union Unn { - n1: NonCopy, - n2: NonCopy, -} -union Ucc { - c1: Copy, - c2: Copy, -} -union Ucn { - c: Copy, - n: NonCopy, -} - -fn main() { - unsafe { - // 2 NonCopy - { - let mut u = Unn { n1: NonCopy }; - let a = u.n1; - let a = u.n1; //~ ERROR use of moved value: `u.n1` - } - { - let mut u = Unn { n1: NonCopy }; - let a = u.n1; - let a = u; //~ ERROR use of partially moved value: `u` - } - { - let mut u = Unn { n1: NonCopy }; - let a = u.n1; - let a = u.n2; //~ ERROR use of moved value: `u.n2` - } - // 2 Copy - { - let mut u = Ucc { c1: Copy }; - let a = u.c1; - let a = u.c1; // OK - } - { - let mut u = Ucc { c1: Copy }; - let a = u.c1; - let a = u; // OK - } - { - let mut u = Ucc { c1: Copy }; - let a = u.c1; - let a = u.c2; // OK - } - // 1 Copy, 1 NonCopy - { - let mut u = Ucn { c: Copy }; - let a = u.c; - let a = u.c; // OK - } - { - let mut u = Ucn { c: Copy }; - let a = u.n; - let a = u.n; //~ ERROR use of moved value: `u.n` - } - { - let mut u = Ucn { c: Copy }; - let a = u.n; - let a = u.c; //~ ERROR use of moved value: `u.c` - } - { - let mut u = Ucn { c: Copy }; - let a = u.c; - let a = u.n; // OK - } - { - let mut u = Ucn { c: Copy }; - let a = u.c; - let a = u; // OK - } - { - let mut u = Ucn { c: Copy }; - let a = u.n; - let a = u; //~ ERROR use of partially moved value: `u` - } - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-union-uninitialized.rs b/src/test/compile-fail/borrowck/borrowck-union-uninitialized.rs deleted file mode 100644 index 81376a1a169..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-union-uninitialized.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S { - a: u8, -} - -union U { - a: u8, -} - -fn main() { - unsafe { - let mut s: S; - let mut u: U; - s.a = 0; - u.a = 0; - let sa = s.a; //~ ERROR use of possibly uninitialized variable: `s.a` - let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` - } -} diff --git a/src/test/compile-fail/borrowck/borrowck-uniq-via-lend.rs b/src/test/compile-fail/borrowck/borrowck-uniq-via-lend.rs deleted file mode 100644 index f36dc0ca43f..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-uniq-via-lend.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn borrow(_v: &isize) {} - -fn local() { - let mut v: Box<_> = box 3; - borrow(&*v); -} - -fn local_rec() { - struct F { f: Box } - let mut v = F {f: box 3}; - borrow(&*v.f); -} - -fn local_recs() { - struct F { f: G } - struct G { g: H } - struct H { h: Box } - let mut v = F {f: G {g: H {h: box 3}}}; - borrow(&*v.f.g.h); -} - -fn aliased_imm() { - let mut v: Box<_> = box 3; - let _w = &v; - borrow(&*v); -} - -fn aliased_mut() { - let mut v: Box<_> = box 3; - let _w = &mut v; - borrow(&*v); //~ ERROR cannot borrow `*v` -} - -fn aliased_other() { - let mut v: Box<_> = box 3; - let mut w: Box<_> = box 4; - let _x = &mut w; - borrow(&*v); -} - -fn aliased_other_reassign() { - let mut v: Box<_> = box 3; - let mut w: Box<_> = box 4; - let mut _x = &mut w; - _x = &mut v; - borrow(&*v); //~ ERROR cannot borrow `*v` -} - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/borrowck-use-in-index-lvalue.rs b/src/test/compile-fail/borrowck/borrowck-use-in-index-lvalue.rs deleted file mode 100644 index eb99f78f461..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-use-in-index-lvalue.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn test() { - let w: &mut [isize]; - w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - //[mir]~^ ERROR [E0381] - - let mut w: &mut [isize]; - w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - //[mir]~^ ERROR [E0381] -} - -fn main() { test(); } diff --git a/src/test/compile-fail/borrowck/borrowck-use-mut-borrow.rs b/src/test/compile-fail/borrowck/borrowck-use-mut-borrow.rs deleted file mode 100644 index c11e58651aa..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-use-mut-borrow.rs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -#[derive(Copy, Clone)] -struct A { a: isize, b: isize } - -struct B { a: isize, b: Box } - -fn var_copy_after_var_borrow() { - let mut x: isize = 1; - let p = &mut x; - drop(x); //~ ERROR cannot use `x` because it was mutably borrowed - *p = 2; -} - -fn var_copy_after_field_borrow() { - let mut x = A { a: 1, b: 2 }; - let p = &mut x.a; - drop(x); //~ ERROR cannot use `x` because it was mutably borrowed - *p = 3; -} - -fn field_copy_after_var_borrow() { - let mut x = A { a: 1, b: 2 }; - let p = &mut x; - drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed - p.a = 3; -} - -fn field_copy_after_field_borrow() { - let mut x = A { a: 1, b: 2 }; - let p = &mut x.a; - drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed - *p = 3; -} - -fn fu_field_copy_after_var_borrow() { - let mut x = A { a: 1, b: 2 }; - let p = &mut x; - let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed - drop(y); - p.a = 4; -} - -fn fu_field_copy_after_field_borrow() { - let mut x = A { a: 1, b: 2 }; - let p = &mut x.a; - let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed - drop(y); - *p = 4; -} - -fn var_deref_after_var_borrow() { - let mut x: Box = box 1; - let p = &mut x; - drop(*x); //~ ERROR cannot use `*x` because it was mutably borrowed - **p = 2; -} - -fn field_deref_after_var_borrow() { - let mut x = B { a: 1, b: box 2 }; - let p = &mut x; - drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed - p.a = 3; -} - -fn field_deref_after_field_borrow() { - let mut x = B { a: 1, b: box 2 }; - let p = &mut x.b; - drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed - **p = 3; -} - -fn main() { - var_copy_after_var_borrow(); - var_copy_after_field_borrow(); - - field_copy_after_var_borrow(); - field_copy_after_field_borrow(); - - fu_field_copy_after_var_borrow(); - fu_field_copy_after_field_borrow(); - - var_deref_after_var_borrow(); - field_deref_after_var_borrow(); - field_deref_after_field_borrow(); -} diff --git a/src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast-trait.rs b/src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast-trait.rs deleted file mode 100644 index 57c2d508356..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast-trait.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Variation on `borrowck-use-uninitialized-in-cast` in which we do a -// trait cast from an uninitialized source. Issue #20791. - -trait Foo { fn dummy(&self) { } } -impl Foo for i32 { } - -fn main() { - let x: &i32; - let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` - //[mir]~^ ERROR [E0381] -} diff --git a/src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast.rs b/src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast.rs deleted file mode 100644 index dbc20d02057..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-use-uninitialized-in-cast.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Check that we detect unused values that are cast to other things. -// The problem was specified to casting to `*`, as creating unsafe -// pointers was not being fully checked. Issue #20791. - -fn main() { - let x: &i32; - let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] - //[mir]~^ ERROR [E0381] -} diff --git a/src/test/compile-fail/borrowck/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck/borrowck-vec-pattern-element-loan.rs deleted file mode 100644 index 0fd6923326a..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-vec-pattern-element-loan.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] - -fn a<'a>() -> &'a [isize] { - let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough - let tail = match vec { - &[_, ref tail..] => tail, - _ => panic!("a") - }; - tail -} - -fn b<'a>() -> &'a [isize] { - let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough - let init = match vec { - &[ref init.., _] => init, - _ => panic!("b") - }; - init -} - -fn c<'a>() -> &'a [isize] { - let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough - let slice = match vec { - &[_, ref slice.., _] => slice, - _ => panic!("c") - }; - slice -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-vec-pattern-loan-from-mut.rs b/src/test/compile-fail/borrowck/borrowck-vec-pattern-loan-from-mut.rs deleted file mode 100644 index 505c8c6d535..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-vec-pattern-loan-from-mut.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] - -fn a() { - let mut v = vec![1, 2, 3]; - let vb: &mut [isize] = &mut v; - match vb { - &mut [_a, ref tail..] => { - v.push(tail[0] + tail[1]); //~ ERROR cannot borrow - } - _ => {} - }; -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs b/src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs deleted file mode 100644 index 94877b27d58..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-vec-pattern-move-tail.rs +++ /dev/null @@ -1,29 +0,0 @@ - -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast cmp -//[cmp]compile-flags: -Z borrowck=compare - -#![feature(slice_patterns)] - -fn main() { - let mut a = [1, 2, 3, 4]; - let t = match a { - [1, 2, ref tail..] => tail, - _ => unreachable!() - }; - println!("t[0]: {}", t[0]); - a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed - //[cmp]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast) - //[cmp]~| ERROR cannot assign to `a[..]` because it is borrowed (Mir) - println!("t[0]: {}", t[0]); - t[0]; -} diff --git a/src/test/compile-fail/borrowck/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck/borrowck-vec-pattern-tail-element-loan.rs deleted file mode 100644 index cd8f3ebefe6..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-vec-pattern-tail-element-loan.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] - -fn a<'a>() -> &'a isize { - let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough - let tail = match vec { - &[_a, ref tail..] => &tail[0], - _ => panic!("foo") - }; - tail -} - -fn main() { - let fifth = a(); - println!("{}", *fifth); -} diff --git a/src/test/compile-fail/borrowck/borrowck-while-break.rs b/src/test/compile-fail/borrowck/borrowck-while-break.rs deleted file mode 100644 index 8cdf1da5c93..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-while-break.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test(cond: bool) { - let v; - while cond { - v = 3; - break; - } - println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` -} - -fn main() { - test(true); -} diff --git a/src/test/compile-fail/borrowck/borrowck-while-cond.rs b/src/test/compile-fail/borrowck/borrowck-while-cond.rs deleted file mode 100644 index 27d42d666ea..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-while-cond.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x: bool; - while x { } //~ ERROR use of possibly uninitialized variable: `x` -} diff --git a/src/test/compile-fail/borrowck/borrowck-while.rs b/src/test/compile-fail/borrowck/borrowck-while.rs deleted file mode 100644 index e3566e9bb92..00000000000 --- a/src/test/compile-fail/borrowck/borrowck-while.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() -> isize { - let mut x: isize; - while 1 == 1 { x = 10; } - return x; //~ ERROR use of possibly uninitialized variable: `x` -} - -fn main() { f(); } diff --git a/src/test/compile-fail/borrowck/move-in-static-initializer-issue-38520.rs b/src/test/compile-fail/borrowck/move-in-static-initializer-issue-38520.rs deleted file mode 100644 index 508e09318ae..00000000000 --- a/src/test/compile-fail/borrowck/move-in-static-initializer-issue-38520.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Regression test for #38520. Check that moves of `Foo` are not -// permitted as `Foo` is not copy (even in a static/const -// initializer). - -#![feature(const_fn)] - -struct Foo(usize); - -const fn get(x: Foo) -> usize { - x.0 -} - -const X: Foo = Foo(22); -static Y: usize = get(*&X); //[ast]~ ERROR E0507 - //[mir]~^ ERROR [E0507] -const Z: usize = get(*&X); //[ast]~ ERROR E0507 - //[mir]~^ ERROR [E0507] - -fn main() { -} diff --git a/src/test/compile-fail/borrowck/two-phase-across-loop.rs b/src/test/compile-fail/borrowck/two-phase-across-loop.rs deleted file mode 100644 index e03a0355b48..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-across-loop.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a borrow which starts as a 2-phase borrow and gets -// carried around a loop winds up conflicting with itself. - -#![feature(nll)] - -struct Foo { x: String } - -impl Foo { - fn get_string(&mut self) -> &str { - &self.x - } -} - -fn main() { - let mut foo = Foo { x: format!("Hello, world") }; - let mut strings = vec![]; - - loop { - strings.push(foo.get_string()); //~ ERROR cannot borrow `foo` as mutable - if strings.len() > 2 { break; } - } - - println!("{:?}", strings); -} diff --git a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs b/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs deleted file mode 100644 index 77b237e34f2..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -// revisions: nll_target - -// The following revisions are disabled due to missing support from two-phase beyond autorefs -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref - -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// This is an important corner case pointed out by Niko: one is -// allowed to initiate a shared borrow during a reservation, but it -// *must end* before the activation occurs. -// -// FIXME: for clarity, diagnostics for these cases might be better off -// if they specifically said "cannot activate mutable borrow of `x`" -// -// The convention for the listed revisions: "lxl" means lexical -// lifetimes (which can be easier to reason about). "nll" means -// non-lexical lifetimes. "nll_target" means the initial conservative -// two-phase borrows that only applies to autoref-introduced borrows. -// "nll_beyond" means the generalization of two-phase borrows to all -// `&mut`-borrows (doing so makes it easier to write code for specific -// corner cases). - -#![allow(dead_code)] - -fn read(_: &i32) { } - -fn ok() { - let mut x = 3; - let y = &mut x; - { let z = &x; read(z); } - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable - *y += 1; -} - -fn not_ok() { - let mut x = 3; - let y = &mut x; - let z = &x; - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable - *y += 1; - //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - //[nll_beyond]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - read(z); -} - -fn should_be_ok_with_nll() { - let mut x = 3; - let y = &mut x; - let z = &x; - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable - read(z); - *y += 1; - //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - // (okay with (generalized) nll today) -} - -fn should_also_eventually_be_ok_with_nll() { - let mut x = 3; - let y = &mut x; - let _z = &x; - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable - *y += 1; - //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - // (okay with (generalized) nll today) -} - -fn main() { } diff --git a/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs b/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs deleted file mode 100644 index 5deabf93764..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -// revisions: nll_target - -// The following revisions are disabled due to missing support for two_phase_beyond_autoref -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref - -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// This is the second counter-example from Niko's blog post -// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ -// -// It is "artificial". It is meant to illustrate directly that we -// should allow an aliasing access during reservation, but *not* while -// the mutable borrow is active. -// -// The convention for the listed revisions: "lxl" means lexical -// lifetimes (which can be easier to reason about). "nll" means -// non-lexical lifetimes. "nll_target" means the initial conservative -// two-phase borrows that only applies to autoref-introduced borrows. -// "nll_beyond" means the generalization of two-phase borrows to all -// `&mut`-borrows (doing so makes it easier to write code for specific -// corner cases). - -fn main() { - /*0*/ let mut i = 0; - - /*1*/ let p = &mut i; // (reservation of `i` starts here) - - /*2*/ let j = i; // OK: `i` is only reserved here - //[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] - - /*3*/ *p += 1; // (mutable borrow of `i` starts here, since `p` is used) - - /*4*/ let k = i; //[nll_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503] - //[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] - - /*5*/ *p += 1; - - let _ = (j, k, p); -} diff --git a/src/test/compile-fail/borrowck/two-phase-cannot-nest-mut-self-calls.rs b/src/test/compile-fail/borrowck/two-phase-cannot-nest-mut-self-calls.rs deleted file mode 100644 index 15700a1d61a..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-cannot-nest-mut-self-calls.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// This is the third counter-example from Niko's blog post -// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ -// -// It shows that not all nested method calls on `self` are magically -// allowed by this change. In particular, a nested `&mut` borrow is -// still disallowed. - -fn main() { - - - let mut vec = vec![0, 1]; - vec.get({ - - vec.push(2); - //~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable - - 0 - }); -} diff --git a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs deleted file mode 100644 index 30752e8ddb1..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast nll -//[ast]compile-flags: -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows - -//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -// the above revision is disabled until two-phase-beyond-autoref support is better - -// This is a test checking that when we limit two-phase borrows to -// method receivers, we do not let other kinds of auto-ref to leak -// through. -// -// The g2p revision illustrates the "undesirable" behavior you would -// otherwise observe without limiting the phasing to autoref on method -// receivers (namely, in many cases demonstrated below, the error -// would not arise). - -// (If we revise the compiler or this test so that the g2p revision -// passes, turn the `rustc_attrs` feature back on and tag the `fn -// main` with `#[rustc_error]` so that this remains a valid -// compile-fail test.) -// -// #![feature(rustc_attrs)] - -use std::ops::{Index, IndexMut}; - -fn foo(x: &mut u32, y: u32) { - *x += y; -} - -fn deref_coercion(x: &mut u32) { - foo(x, *x); - //[ast]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503] - // Above error is a known limitation of AST borrowck -} - -// While adding a flag to adjustments (indicating whether they -// should support two-phase borrows, here are the cases I -// encountered: -// -// - [x] Resolving overloaded_call_traits (call, call_mut, call_once) -// - [x] deref_coercion (shown above) -// - [x] coerce_unsized e.g. `&[T; n]`, `&mut [T; n] -> &[T]`, -// `&mut [T; n] -> &mut [T]`, `&Concrete -> &Trait` -// - [x] Method Call Receivers (the case we want to support!) -// - [x] ExprKind::Index and ExprKind::Unary Deref; only need to handle coerce_index_op -// - [x] overloaded_binops - -fn overloaded_call_traits() { - // Regarding overloaded call traits, note that there is no - // scenario where adding two-phase borrows should "fix" these - // cases, because either we will resolve both invocations to - // `call_mut` (in which case the inner call requires a mutable - // borrow which will conflict with the outer reservation), or we - // will resolve both to `call` (which will just work, regardless - // of two-phase borrow support), or we will resolve both to - // `call_once` (in which case the inner call requires moving the - // receiver, invalidating the outer call). - - fn twice_ten_sm i32>(f: &mut F) { - f(f(10)); - //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time - } - fn twice_ten_si i32>(f: &mut F) { - f(f(10)); - } - fn twice_ten_so i32>(f: Box) { - f(f(10)); - //[nll]~^ ERROR use of moved value: `*f` - //[g2p]~^^ ERROR use of moved value: `*f` - //[ast]~^^^ ERROR use of moved value: `*f` - } - - fn twice_ten_om(f: &mut FnMut(i32) -> i32) { - f(f(10)); - //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time - } - fn twice_ten_oi(f: &mut Fn(i32) -> i32) { - f(f(10)); - } - fn twice_ten_oo(f: Box i32>) { - f(f(10)); - //[nll]~^ ERROR cannot move a value of type - //[nll]~^^ ERROR cannot move a value of type - //[nll]~^^^ ERROR use of moved value: `*f` - //[g2p]~^^^^ ERROR cannot move a value of type - //[g2p]~^^^^^ ERROR cannot move a value of type - //[g2p]~^^^^^^ ERROR use of moved value: `*f` - //[ast]~^^^^^^^ ERROR use of moved value: `*f` - } - - twice_ten_sm(&mut |x| x + 1); - twice_ten_si(&mut |x| x + 1); - twice_ten_so(Box::new(|x| x + 1)); - twice_ten_om(&mut |x| x + 1); - twice_ten_oi(&mut |x| x + 1); - twice_ten_oo(Box::new(|x| x + 1)); -} - -trait TwoMethods { - fn m(&mut self, x: i32) -> i32 { x + 1 } - fn i(&self, x: i32) -> i32 { x + 1 } -} - -struct T; - -impl TwoMethods for T { } - -struct S; - -impl S { - fn m(&mut self, x: i32) -> i32 { x + 1 } - fn i(&self, x: i32) -> i32 { x + 1 } -} - -impl TwoMethods for [i32; 3] { } - -fn double_access(m: &mut [X], s: &[X]) { - m[0] = s[1]; -} - -fn coerce_unsized() { - let mut a = [1, 2, 3]; - - // This is not okay. - double_access(&mut a, &a); - //[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - - // But this is okay. - a.m(a.i(10)); - //[ast]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - // Above error is an expected limitation of AST borrowck -} - -struct I(i32); - -impl Index for I { - type Output = i32; - fn index(&self, _: i32) -> &i32 { - &self.0 - } -} - -impl IndexMut for I { - fn index_mut(&mut self, _: i32) -> &mut i32 { - &mut self.0 - } -} - -fn coerce_index_op() { - let mut i = I(10); - i[i[3]] = 4; - //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - - i[3] = i[4]; - - i[i[3]] = i[4]; - //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] -} - -fn main() { - - // As a reminder, this is the basic case we want to ensure we handle. - let mut v = vec![1, 2, 3]; - v.push(v.len()); - //[ast]~^ ERROR cannot borrow `v` as immutable because it is also borrowed as mutable [E0502] - // Error above is an expected limitation of AST borrowck - - // (as a rule, pnkfelix does not like to write tests with dead code.) - - deref_coercion(&mut 5); - overloaded_call_traits(); - - - let mut s = S; - s.m(s.i(10)); - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable [E0502] - // Error above is an expected limitation of AST borrowck - - let mut t = T; - t.m(t.i(10)); - //[ast]~^ ERROR cannot borrow `t` as immutable because it is also borrowed as mutable [E0502] - // Error above is an expected limitation of AST borrowck - - coerce_unsized(); - coerce_index_op(); -} diff --git a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference-2.rs b/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference-2.rs deleted file mode 100644 index f9326d944b8..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference-2.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// This is similar to two-phase-reservation-sharing-interference.rs -// in that it shows a reservation that overlaps with a shared borrow. -// -// Currently, this test fails with lexical lifetimes, but succeeds -// with non-lexical lifetimes. (The reason is because the activation -// of the mutable borrow ends up overlapping with a lexically-scoped -// shared borrow; but a non-lexical shared borrow can end before the -// activation occurs.) -// -// So this test is just making a note of the current behavior. - -#![feature(rustc_attrs)] - -#[rustc_error] -fn main() { //~ ERROR compilation successful - let mut v = vec![0, 1, 2]; - let shared = &v; - - v.push(shared.len()); - - assert_eq!(v, [0, 1, 2, 3]); -} diff --git a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs b/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs deleted file mode 100644 index 1e86603c19e..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -// revisions: nll_target - -// The following revisions are disabled due to missing support from two-phase beyond autorefs -//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -//[nll_beyond] should-fail - -//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// This is a corner case that the current implementation is (probably) -// treating more conservatively than is necessary. But it also does -// not seem like a terribly important use case to cover. -// -// So this test is just making a note of the current behavior, with -// the caveat that in the future, the rules may be loosened, at which -// point this test might be thrown out. -// -// The convention for the listed revisions: "lxl" means lexical -// lifetimes (which can be easier to reason about). "nll" means -// non-lexical lifetimes. "nll_target" means the initial conservative -// two-phase borrows that only applies to autoref-introduced borrows. -// "nll_beyond" means the generalization of two-phase borrows to all -// `&mut`-borrows (doing so makes it easier to write code for specific -// corner cases). - -fn main() { - let mut vec = vec![0, 1]; - let delay: &mut Vec<_>; - { - let shared = &vec; - - // we reserve here, which could (on its own) be compatible - // with the shared borrow. But in the current implementation, - // its an error. - delay = &mut vec; - //[nll_beyond]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable - //[nll_target]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable - - shared[0]; - } - - // the &mut-borrow only becomes active way down here. - // - // (At least in theory; part of the reason this test fails is that - // the constructed MIR throws in extra &mut reborrows which - // flummoxes our attmpt to delay the activation point here.) - delay.push(2); -} - diff --git a/src/test/compile-fail/borrowck/two-phase-sneaky.rs b/src/test/compile-fail/borrowck/two-phase-sneaky.rs deleted file mode 100644 index eec4b470d75..00000000000 --- a/src/test/compile-fail/borrowck/two-phase-sneaky.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// cmpile-flags: -Z borrowck=mir -Z two-phase-borrows - -// This is the first counter-example from Niko's blog post -// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ -// of a danger for code to crash if we just turned off the check for whether -// a mutable-borrow aliases another borrow. - -fn main() { - let mut v: Vec = vec![format!("Hello, ")]; - v[0].push_str({ - - v.push(format!("foo")); - //~^ ERROR cannot borrow `v` as mutable more than once at a time [E0499] - - "World!" - }); -} diff --git a/src/test/compile-fail/bounds-lifetime.rs b/src/test/compile-fail/bounds-lifetime.rs deleted file mode 100644 index 5bfaa6c54fa..00000000000 --- a/src/test/compile-fail/bounds-lifetime.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -type A = for<'b, 'a: 'b> fn(); //~ ERROR lifetime bounds cannot be used in this context -type B = for<'b, 'a: 'b,> fn(); //~ ERROR lifetime bounds cannot be used in this context -type C = for<'b, 'a: 'b +> fn(); //~ ERROR lifetime bounds cannot be used in this context -type D = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context -type E = for Fn(); //~ ERROR only lifetime parameters can be used in this context - -fn main() {} diff --git a/src/test/compile-fail/break-outside-loop.rs b/src/test/compile-fail/break-outside-loop.rs deleted file mode 100644 index 1f257b8a5cb..00000000000 --- a/src/test/compile-fail/break-outside-loop.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - t: String -} - -fn cond() -> bool { true } - -fn foo(_: F) where F: FnOnce() {} - -fn main() { - let pth = break; //~ ERROR: `break` outside of loop - if cond() { continue } //~ ERROR: `continue` outside of loop - - while cond() { - if cond() { break } - if cond() { continue } - foo(|| { - if cond() { break } //~ ERROR: `break` inside of a closure - if cond() { continue } //~ ERROR: `continue` inside of a closure - }) - } - - let rs: Foo = Foo{t: pth}; - - let unconstrained = break; //~ ERROR: `break` outside of loop -} diff --git a/src/test/compile-fail/builtin-superkinds-double-superkind.rs b/src/test/compile-fail/builtin-superkinds-double-superkind.rs deleted file mode 100644 index 3f7f2adabdf..00000000000 --- a/src/test/compile-fail/builtin-superkinds-double-superkind.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for traits that inherit from multiple builtin kinds at once, -// testing that all such kinds must be present on implementing types. - -trait Foo : Send+Sync { } - -impl Foo for (T,) { } -//~^ ERROR `T` cannot be sent between threads safely [E0277] - -impl Foo for (T,T) { } -//~^ ERROR `T` cannot be shared between threads safely [E0277] - -impl Foo for (T,T,T) { } // (ok) - -fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-in-metadata.rs b/src/test/compile-fail/builtin-superkinds-in-metadata.rs deleted file mode 100644 index 88b5a3fbb55..00000000000 --- a/src/test/compile-fail/builtin-superkinds-in-metadata.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// aux-build:trait_superkinds_in_metadata.rs - -// Test for traits inheriting from the builtin kinds cross-crate. -// Mostly tests correctness of metadata. - -extern crate trait_superkinds_in_metadata; -use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; - -struct X(T); - -impl RequiresShare for X { } - -impl RequiresRequiresShareAndSend for X { } -//~^ ERROR `T` cannot be sent between threads safely [E0277] - -fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-self-type.rs b/src/test/compile-fail/builtin-superkinds-self-type.rs deleted file mode 100644 index 3065ecfaa30..00000000000 --- a/src/test/compile-fail/builtin-superkinds-self-type.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests (negatively) the ability for the Self type in default methods -// to use capabilities granted by builtin kinds as supertraits. - -use std::sync::mpsc::{channel, Sender}; - -trait Foo : Sized+Sync+'static { - fn foo(self, mut chan: Sender) { } -} - -impl Foo for T { } -//~^ ERROR the parameter type `T` may not live long enough - -fn main() { - let (tx, rx) = channel(); - 1193182.foo(tx); - assert_eq!(rx.recv(), 1193182); -} diff --git a/src/test/compile-fail/builtin-superkinds-simple.rs b/src/test/compile-fail/builtin-superkinds-simple.rs deleted file mode 100644 index 22dc9598d29..00000000000 --- a/src/test/compile-fail/builtin-superkinds-simple.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Basic test for traits inheriting from the builtin kinds, checking -// the type contents of the implementing type (that's not a typaram). - -trait Foo : Send { } - -impl Foo for std::rc::Rc { } -//~^ ERROR `std::rc::Rc` cannot be sent between threads safely - -fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs deleted file mode 100644 index e0b2043c110..00000000000 --- a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Basic test for traits inheriting from the builtin kinds. - -trait Foo : Send { } - -impl Foo for T { } -//~^ ERROR `T` cannot be sent between threads safely - -fn main() { } diff --git a/src/test/compile-fail/by-move-pattern-binding.rs b/src/test/compile-fail/by-move-pattern-binding.rs deleted file mode 100644 index a49256d1bfc..00000000000 --- a/src/test/compile-fail/by-move-pattern-binding.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum E { - Foo, - Bar(String) -} - -struct S { - x: E -} - -fn f(x: String) {} - -fn main() { - let s = S { x: E::Bar("hello".to_string()) }; - match &s.x { - &E::Foo => {} - &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move - }; - match &s.x { - &E::Foo => {} - &E::Bar(ref identifier) => println!("{}", *identifier) - }; -} diff --git a/src/test/compile-fail/call-fn-never-arg-wrong-type.rs b/src/test/compile-fail/call-fn-never-arg-wrong-type.rs deleted file mode 100644 index 583befed1e8..00000000000 --- a/src/test/compile-fail/call-fn-never-arg-wrong-type.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can't pass other types for ! - -#![feature(never_type)] - -fn foo(x: !) -> ! { - x -} - -fn main() { - foo("wow"); //~ ERROR mismatched types -} - diff --git a/src/test/compile-fail/can-begin-expr-check.rs b/src/test/compile-fail/can-begin-expr-check.rs deleted file mode 100644 index 68f219c6ed9..00000000000 --- a/src/test/compile-fail/can-begin-expr-check.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - - return; - return (); - return as (); - return return as (); - return return return; - - return if true { - () - } else { - () - }; - - loop { - return break as (); - } - - return enum; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `enum` -} diff --git a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs b/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs deleted file mode 100644 index 6bd52f00788..00000000000 --- a/src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(unboxed_closures)] - -use std::io::Read; - -fn to_fn_once>(f: F) -> F { f } - -fn main() { - let x = 1; - to_fn_once(move|| { x = 2; }); - //[ast]~^ ERROR: cannot assign to immutable captured outer variable - //[mir]~^^ ERROR: cannot assign to `x`, as it is not declared as mutable - - let s = std::io::stdin(); - to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - //[ast]~^ ERROR: cannot borrow immutable captured outer variable - //[mir]~^^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable -} diff --git a/src/test/compile-fail/capture1.rs b/src/test/compile-fail/capture1.rs deleted file mode 100644 index 984385f4cc0..00000000000 --- a/src/test/compile-fail/capture1.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern: can't capture dynamic environment in a fn item - -fn main() { - let bar: isize = 5; - fn foo() -> isize { return bar; } -} diff --git a/src/test/compile-fail/cast-from-nil.rs b/src/test/compile-fail/cast-from-nil.rs deleted file mode 100644 index ab22d352480..00000000000 --- a/src/test/compile-fail/cast-from-nil.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: non-primitive cast: `()` as `u32` -fn main() { let u = (assert!(true) as u32); } diff --git a/src/test/compile-fail/cast-ptr-to-int-const.rs b/src/test/compile-fail/cast-ptr-to-int-const.rs deleted file mode 100644 index 8764cb72b8c..00000000000 --- a/src/test/compile-fail/cast-ptr-to-int-const.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// gate-test-const_raw_ptr_to_usize_cast - -fn main() { - const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable - const Y: u32 = 0; - const Z: u32 = &Y as *const u32 as u32; //~ ERROR is unstable -} diff --git a/src/test/compile-fail/cast-to-bare-fn.rs b/src/test/compile-fail/cast-to-bare-fn.rs deleted file mode 100644 index d5a998c6e4b..00000000000 --- a/src/test/compile-fail/cast-to-bare-fn.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(_x: isize) { } - -fn main() { - let v: u64 = 5; - let x = foo as extern "C" fn() -> isize; - //~^ ERROR non-primitive cast - let y = v as extern "Rust" fn(isize) -> (isize, isize); - //~^ ERROR non-primitive cast - y(x()); -} diff --git a/src/test/compile-fail/cast-to-nil.rs b/src/test/compile-fail/cast-to-nil.rs deleted file mode 100644 index 27d9e8a42b1..00000000000 --- a/src/test/compile-fail/cast-to-nil.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: non-primitive cast: `u32` as `()` -fn main() { let u = 0u32 as (); } diff --git a/src/test/compile-fail/catch-bad-lifetime.rs b/src/test/compile-fail/catch-bad-lifetime.rs deleted file mode 100644 index f332ffd4494..00000000000 --- a/src/test/compile-fail/catch-bad-lifetime.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(catch_expr)] - -// This test checks that borrows made and returned inside catch blocks are properly constrained -pub fn main() { - { - // Test that borrows returned from a catch block must be valid for the lifetime of the - // result variable - let _result: Result<(), &str> = do catch { - let my_string = String::from(""); - let my_str: & str = & my_string; - //~^ ERROR `my_string` does not live long enough - Err(my_str) ?; - Err("") ?; - }; - } - - { - // Test that borrows returned from catch blocks freeze their referent - let mut i = 5; - let k = &mut i; - let mut j: Result<(), &mut i32> = do catch { - Err(k) ?; - i = 10; //~ ERROR cannot assign to `i` because it is borrowed - }; - ::std::mem::drop(k); //~ ERROR use of moved value: `k` - i = 40; //~ ERROR cannot assign to `i` because it is borrowed - - let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") }; - *i_ptr = 50; - } -} - diff --git a/src/test/compile-fail/catch-bad-type.rs b/src/test/compile-fail/catch-bad-type.rs deleted file mode 100644 index b369847699b..00000000000 --- a/src/test/compile-fail/catch-bad-type.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(catch_expr)] - -pub fn main() { - let res: Result = do catch { - Err("")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied - 5 - }; - - let res: Result = do catch { - "" //~ ERROR type mismatch - }; - - let res: Result = do catch { }; //~ ERROR type mismatch - - let res: () = do catch { }; //~ the trait bound `(): std::ops::Try` is not satisfied - - let res: i32 = do catch { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied -} diff --git a/src/test/compile-fail/catch-in-match.rs b/src/test/compile-fail/catch-in-match.rs deleted file mode 100644 index 9f9968e8124..00000000000 --- a/src/test/compile-fail/catch-in-match.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(catch_expr)] - -fn main() { - match do catch { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `do` -} diff --git a/src/test/compile-fail/catch-in-while.rs b/src/test/compile-fail/catch-in-while.rs deleted file mode 100644 index cb8613ee60b..00000000000 --- a/src/test/compile-fail/catch-in-while.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(catch_expr)] - -fn main() { - while do catch { false } {} //~ ERROR expected expression, found reserved keyword `do` -} diff --git a/src/test/compile-fail/catch-maybe-bad-lifetime.rs b/src/test/compile-fail/catch-maybe-bad-lifetime.rs deleted file mode 100644 index faefb5ef18a..00000000000 --- a/src/test/compile-fail/catch-maybe-bad-lifetime.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(catch_expr)] - -// This test checks that borrows made and returned inside catch blocks are properly constrained -pub fn main() { - { - // Test that a borrow which *might* be returned still freezes its referent - let mut i = 222; - let x: Result<&i32, ()> = do catch { - Err(())?; - &i - }; - x.ok().cloned(); - i = 0; //~ ERROR cannot assign to `i` because it is borrowed - let _ = i; - } - - { - let x = String::new(); - let _y: Result<(), ()> = do catch { - Err(())?; - ::std::mem::drop(x); - }; - println!("{}", x); //~ ERROR use of moved value: `x` - } - - { - // Test that a borrow which *might* be assigned to an outer variable still freezes - // its referent - let mut i = 222; - let j; - let x: Result<(), ()> = do catch { - Err(())?; - j = &i; - }; - i = 0; //~ ERROR cannot assign to `i` because it is borrowed - let _ = i; - } -} - diff --git a/src/test/compile-fail/catch-opt-init.rs b/src/test/compile-fail/catch-opt-init.rs deleted file mode 100644 index 0c41102e3be..00000000000 --- a/src/test/compile-fail/catch-opt-init.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(catch_expr)] - -fn use_val(_x: T) {} - -pub fn main() { - let cfg_res; - let _: Result<(), ()> = do catch { - Err(())?; - cfg_res = 5; - Ok::<(), ()>(())?; - use_val(cfg_res); - }; - assert_eq!(cfg_res, 5); //~ ERROR use of possibly uninitialized variable -} - diff --git a/src/test/compile-fail/cdylib-deps-must-be-static.rs b/src/test/compile-fail/cdylib-deps-must-be-static.rs deleted file mode 100644 index 0a06e01cab0..00000000000 --- a/src/test/compile-fail/cdylib-deps-must-be-static.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: crate `cdylib_dep` required to be available in rlib format, but was not found -// aux-build:cdylib-dep.rs -// ignore-musl -// ignore-cloudabi -// ignore-emscripten - -#![crate_type = "cdylib"] - -extern crate cdylib_dep; diff --git a/src/test/compile-fail/cfg-arg-invalid.rs b/src/test/compile-fail/cfg-arg-invalid.rs deleted file mode 100644 index 404630399c6..00000000000 --- a/src/test/compile-fail/cfg-arg-invalid.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --cfg a{b} -// error-pattern: invalid --cfg argument: a{b} -fn main() {} diff --git a/src/test/compile-fail/cfg-attr-cfg-2.rs b/src/test/compile-fail/cfg-attr-cfg-2.rs deleted file mode 100644 index 58a62d45ea5..00000000000 --- a/src/test/compile-fail/cfg-attr-cfg-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// error-pattern: `main` function not found -// compile-flags: --cfg foo - -// main is conditionally compiled, but the conditional compilation -// is conditional too! - -#[cfg_attr(foo, cfg(bar))] -fn main() { } diff --git a/src/test/compile-fail/cfg-attr-crate-2.rs b/src/test/compile-fail/cfg-attr-crate-2.rs deleted file mode 100644 index a79c7663861..00000000000 --- a/src/test/compile-fail/cfg-attr-crate-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// compile-flags: --cfg broken - -// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 - -#![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental - -fn main() { } diff --git a/src/test/compile-fail/cfg-attr-invalid-predicate.rs b/src/test/compile-fail/cfg-attr-invalid-predicate.rs deleted file mode 100644 index 09fe6cec49c..00000000000 --- a/src/test/compile-fail/cfg-attr-invalid-predicate.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(foo(bar))] //~ ERROR invalid predicate `foo` -fn main() {} diff --git a/src/test/compile-fail/cfg-attr-unknown-attribute-macro-expansion.rs b/src/test/compile-fail/cfg-attr-unknown-attribute-macro-expansion.rs deleted file mode 100644 index afcb896b43c..00000000000 --- a/src/test/compile-fail/cfg-attr-unknown-attribute-macro-expansion.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - () => { - #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown - fn foo() {} - } -} - -foo!(); - -fn main() {} diff --git a/src/test/compile-fail/cfg-empty-codemap.rs b/src/test/compile-fail/cfg-empty-codemap.rs deleted file mode 100644 index 8868a5a9549..00000000000 --- a/src/test/compile-fail/cfg-empty-codemap.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that empty codemaps don't ICE (#23301) - -// compile-flags: --cfg "" - -// error-pattern: expected identifier, found - -pub fn main() { -} diff --git a/src/test/compile-fail/cfg-in-crate-1.rs b/src/test/compile-fail/cfg-in-crate-1.rs deleted file mode 100644 index bbccf2bcd0f..00000000000 --- a/src/test/compile-fail/cfg-in-crate-1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: `main` function not found - -#![cfg(bar)] diff --git a/src/test/compile-fail/cfg-non-opt-expr.rs b/src/test/compile-fail/cfg-non-opt-expr.rs deleted file mode 100644 index a4b24fa8b4b..00000000000 --- a/src/test/compile-fail/cfg-non-opt-expr.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(stmt_expr_attributes)] - -fn main() { - let _ = #[cfg(unset)] (); - //~^ ERROR removing an expression is not supported in this position - let _ = 1 + 2 + #[cfg(unset)] 3; - //~^ ERROR removing an expression is not supported in this position - let _ = [1, 2, 3][#[cfg(unset)] 1]; - //~^ ERROR removing an expression is not supported in this position - let _ = #[test] (); - //~^ ERROR removing an expression is not supported in this position -} diff --git a/src/test/compile-fail/cfg_attr_path.rs b/src/test/compile-fail/cfg_attr_path.rs deleted file mode 100644 index 7d799850a65..00000000000 --- a/src/test/compile-fail/cfg_attr_path.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![deny(unused_attributes)] // c.f #35584 - -mod auxiliary { - #[cfg_attr(any(), path = "nonexistent_file.rs")] pub mod namespaced_enums; - #[cfg_attr(all(), path = "namespaced_enums.rs")] pub mod nonexistent_file; -} - -#[rustc_error] -fn main() { //~ ERROR compilation successful - let _ = auxiliary::namespaced_enums::Foo::A; - let _ = auxiliary::nonexistent_file::Foo::A; -} diff --git a/src/test/compile-fail/check-static-immutable-mut-slices.rs b/src/test/compile-fail/check-static-immutable-mut-slices.rs deleted file mode 100644 index 1804b9e04c2..00000000000 --- a/src/test/compile-fail/check-static-immutable-mut-slices.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks that immutable static items can't have mutable slices - -static TEST: &'static mut [isize] = &mut []; -//~^ ERROR references in statics may only refer to immutable values - -pub fn main() { } diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs deleted file mode 100644 index 37f665960c8..00000000000 --- a/src/test/compile-fail/check-static-values-constraints.rs +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Verifies all possible restrictions for statics values. - -#![allow(warnings)] -#![feature(box_syntax)] - -use std::marker; - -struct WithDtor; - -impl Drop for WithDtor { - fn drop(&mut self) {} -} - -// This enum will be used to test the following rules: -// 1. Variants are safe for static -// 2. Expr calls are allowed as long as they arguments are safe -// 3. Expr calls with unsafe arguments for statics are rejected -enum SafeEnum { - Variant1, - Variant2(isize), - Variant3(WithDtor), - Variant4(String) -} - -// These should be ok -static STATIC1: SafeEnum = SafeEnum::Variant1; -static STATIC2: SafeEnum = SafeEnum::Variant2(0); -static STATIC3: SafeEnum = SafeEnum::Variant3(WithDtor); - -enum UnsafeEnum { - Variant5, - Variant6(isize) -} - -impl Drop for UnsafeEnum { - fn drop(&mut self) {} -} - - -static STATIC4: UnsafeEnum = UnsafeEnum::Variant5; -static STATIC5: UnsafeEnum = UnsafeEnum::Variant6(0); - - -struct SafeStruct { - field1: SafeEnum, - field2: SafeEnum, -} - - -// Struct fields are safe, hence this static should be safe -static STATIC6: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, field2: SafeEnum::Variant2(0)}; - -static STATIC7: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - field2: SafeEnum::Variant3(WithDtor)}; - -// Test variadic constructor for structs. The base struct should be examined -// as well as every field present in the constructor. -// This example shouldn't fail because all the fields are safe. -static STATIC8: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - ..SafeStruct{field1: SafeEnum::Variant1, - field2: SafeEnum::Variant1}}; - -// This example should fail because field1 in the base struct is not safe -static STATIC9: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), -//~^ ERROR destructors cannot be evaluated at compile-time - field2: SafeEnum::Variant1}}; - -struct UnsafeStruct; - -impl Drop for UnsafeStruct { - fn drop(&mut self) {} -} - -static STATIC10: UnsafeStruct = UnsafeStruct; - -struct MyOwned; - -static STATIC11: Box = box MyOwned; -//~^ ERROR allocations are not allowed in statics - -static mut STATIC12: UnsafeStruct = UnsafeStruct; - -static mut STATIC13: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - field2: SafeEnum::Variant3(WithDtor)}; - -static mut STATIC14: SafeStruct = SafeStruct { - field1: SafeEnum::Variant1, - field2: SafeEnum::Variant4("str".to_string()) -//~^ ERROR calls in statics are limited to constant functions -}; - -static STATIC15: &'static [Box] = &[ - box MyOwned, //~ ERROR allocations are not allowed in statics - box MyOwned, //~ ERROR allocations are not allowed in statics -]; - -static STATIC16: (&'static Box, &'static Box) = ( - &box MyOwned, //~ ERROR allocations are not allowed in statics - &box MyOwned, //~ ERROR allocations are not allowed in statics -); - -static mut STATIC17: SafeEnum = SafeEnum::Variant1; - -static STATIC19: Box = - box 3; -//~^ ERROR allocations are not allowed in statics - -pub fn main() { - let y = { static x: Box = box 3; x }; - //~^ ERROR allocations are not allowed in statics - //~^^ ERROR cannot move out of static item -} diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs deleted file mode 100644 index af83b0ecbf2..00000000000 --- a/src/test/compile-fail/class-cast-to-trait.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -trait noisy { - fn speak(&self); -} - -struct cat { - meows : usize, - - how_hungry : isize, - name : String, -} - -impl cat { - pub fn eat(&self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - println!("Not hungry!"); - return false; - } - } -} - -impl noisy for cat { - fn speak(&self) { self.meow(); } - -} - -impl cat { - fn meow(&self) { - println!("Meow"); - self.meows += 1; - if self.meows % 5 == 0 { - self.how_hungry += 1; - } - } -} - -fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} - -fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; - nyan.eat(); //~ ERROR no method named `eat` found -} diff --git a/src/test/compile-fail/class-method-missing.rs b/src/test/compile-fail/class-method-missing.rs deleted file mode 100644 index 46b100a4d39..00000000000 --- a/src/test/compile-fail/class-method-missing.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait animal { - fn eat(&self); -} - -struct cat { - meows: usize, -} - -impl animal for cat { - //~^ ERROR not all trait items implemented, missing: `eat` -} - -fn cat(in_x : usize) -> cat { - cat { - meows: in_x - } -} - -fn main() { - let nyan = cat(0); -} diff --git a/src/test/compile-fail/class-missing-self.rs b/src/test/compile-fail/class-missing-self.rs deleted file mode 100644 index 372bf4cac87..00000000000 --- a/src/test/compile-fail/class-missing-self.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct cat { - meows : usize, -} - -impl cat { - fn sleep(&self) { loop{} } - fn meow(&self) { - println!("Meow"); - meows += 1; //~ ERROR cannot find value `meows` in this scope - sleep(); //~ ERROR cannot find function `sleep` in this scope - } - -} - - - fn main() { } diff --git a/src/test/compile-fail/cleanup-rvalue-scopes-cf.rs b/src/test/compile-fail/cleanup-rvalue-scopes-cf.rs deleted file mode 100644 index dcbb25ba5a9..00000000000 --- a/src/test/compile-fail/cleanup-rvalue-scopes-cf.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the borrow checker prevents pointers to temporaries -// with statement lifetimes from escaping. - -use std::ops::Drop; - -static mut FLAGS: u64 = 0; - -struct Box { f: T } -struct AddFlags { bits: u64 } - -fn AddFlags(bits: u64) -> AddFlags { - AddFlags { bits: bits } -} - -fn arg(x: &AddFlags) -> &AddFlags { - x -} - -impl AddFlags { - fn get(&self) -> &AddFlags { - self - } -} - -pub fn main() { - let _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - let _x = &*arg(&AddFlags(1)); //~ ERROR value does not live long enough - let ref _x = *arg(&AddFlags(1)); //~ ERROR value does not live long enough - let &ref _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough -} diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs deleted file mode 100644 index 12e9fb30902..00000000000 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct X where F: FnOnce() + 'static + Send { - field: F, -} - -fn foo(blk: F) -> X where F: FnOnce() + 'static { - //~^ ERROR `F` cannot be sent between threads safely - return X { field: blk }; -} - -fn main() { -} diff --git a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs b/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs deleted file mode 100644 index 1ffba68263a..00000000000 --- a/src/test/compile-fail/closure-bounds-static-cant-capture-borrowed.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn bar(blk: F) where F: FnOnce() + 'static { -} - -fn foo(x: &()) { - bar(|| { - //~^ ERROR explicit lifetime required in the type of `x` [E0621] - let _ = x; - }) -} - -fn main() { -} diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs deleted file mode 100644 index db26535b004..00000000000 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn take_any(_: F) where F: FnOnce() { -} - -fn take_const_owned(_: F) where F: FnOnce() + Sync + Send { -} - -fn give_any(f: F) where F: FnOnce() { - take_any(f); -} - -fn give_owned(f: F) where F: FnOnce() + Send { - take_any(f); - take_const_owned(f); //~ ERROR `F` cannot be shared between threads safely [E0277] -} - -fn main() {} diff --git a/src/test/compile-fail/closure-expected-type/README.md b/src/test/compile-fail/closure-expected-type/README.md deleted file mode 100644 index 9995b00a9a7..00000000000 --- a/src/test/compile-fail/closure-expected-type/README.md +++ /dev/null @@ -1 +0,0 @@ -See `src/test/run-pass/closure-expected-type`. diff --git a/src/test/compile-fail/closure-expected-type/expect-fn-supply-fn-multiple.rs b/src/test/compile-fail/closure-expected-type/expect-fn-supply-fn-multiple.rs deleted file mode 100644 index 32efb01c0fe..00000000000 --- a/src/test/compile-fail/closure-expected-type/expect-fn-supply-fn-multiple.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass - -#![allow(warnings)] - -type Different<'a, 'b> = &'a mut (&'a (), &'b ()); -type Same<'a> = Different<'a, 'a>; - -fn with_closure_expecting_different(_: F) - where F: for<'a, 'b> FnOnce(Different<'a, 'b>) -{ -} - -fn with_closure_expecting_different_anon(_: F) - where F: FnOnce(Different<'_, '_>) -{ -} - -fn supplying_nothing_expecting_anon() { - with_closure_expecting_different_anon(|x: Different| { - }) -} - -fn supplying_nothing_expecting_named() { - with_closure_expecting_different(|x: Different| { - }) -} - -fn supplying_underscore_expecting_anon() { - with_closure_expecting_different_anon(|x: Different<'_, '_>| { - }) -} - -fn supplying_underscore_expecting_named() { - with_closure_expecting_different(|x: Different<'_, '_>| { - }) -} - -fn main() { } diff --git a/src/test/compile-fail/closure-expected-type/expect-fn-supply-fn.rs b/src/test/compile-fail/closure-expected-type/expect-fn-supply-fn.rs deleted file mode 100644 index 63284c98020..00000000000 --- a/src/test/compile-fail/closure-expected-type/expect-fn-supply-fn.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn with_closure_expecting_fn_with_free_region(_: F) - where F: for<'a> FnOnce(fn(&'a u32), &i32) -{ -} - -fn with_closure_expecting_fn_with_bound_region(_: F) - where F: FnOnce(fn(&u32), &i32) -{ -} - -fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { - // Here, the type given for `'x` "obscures" a region from the - // expected signature that is bound at closure level. - with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); - //~^ ERROR mismatched types - //~| ERROR mismatched types -} - -fn expect_free_supply_free_from_closure() { - // A variant on the previous test. Here, the region `'a` will be - // bound at the closure level, just as is expected, so no error - // results. - type Foo<'a> = fn(&'a u32); - with_closure_expecting_fn_with_free_region(|_x: Foo<'_>, y| {}); -} - -fn expect_free_supply_bound() { - // Here, we are given a function whose region is bound at closure level, - // but we expect one bound in the argument. Error results. - with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); - //~^ ERROR type mismatch in closure arguments -} - -fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) { - // Here, we are given a `fn(&u32)` but we expect a `fn(&'x - // u32)`. In principle, this could be ok, but we demand equality. - with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); - //~^ ERROR type mismatch in closure arguments -} - -fn expect_bound_supply_free_from_closure() { - // A variant on the previous test. Here, the region `'a` will be - // bound at the closure level, but we expect something bound at - // the argument level. - type Foo<'a> = fn(&'a u32); - with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {}); - //~^ ERROR type mismatch in closure arguments -} - -fn expect_bound_supply_bound<'x>(x: &'x u32) { - // No error in this case. The supplied type supplies the bound - // regions, and hence we are able to figure out the type of `y` - // from the expected type - with_closure_expecting_fn_with_bound_region(|x: for<'z> fn(&'z u32), y| { - }); -} - -fn main() { } diff --git a/src/test/compile-fail/closure-expected-type/expect-infer-var-appearing-twice.rs b/src/test/compile-fail/closure-expected-type/expect-infer-var-appearing-twice.rs deleted file mode 100644 index bef69a4b0b9..00000000000 --- a/src/test/compile-fail/closure-expected-type/expect-infer-var-appearing-twice.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn with_closure(_: F) - where F: FnOnce(A, A) -{ -} - -fn a() { - with_closure(|x: u32, y| { - // We deduce type of `y` from `x`. - }); -} - -fn b() { - // Here we take the supplied types, resulting in an error later on. - with_closure(|x: u32, y: i32| { - //~^ ERROR type mismatch in closure arguments - }); -} - -fn c() { - with_closure(|x, y: i32| { - // We deduce type of `x` from `y`. - }); -} - -fn main() { } diff --git a/src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs b/src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs deleted file mode 100644 index 6767aa62f78..00000000000 --- a/src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass - -fn with_closure(_: F) - where F: FnOnce(A, &u32) -{ -} - -fn foo() { - // This version works; we infer `A` to be `u32`, and take the type - // of `y` to be `&u32`. - with_closure(|x: u32, y| {}); -} - -fn bar() { - // This version also works. - with_closure(|x: &u32, y| {}); -} - -fn main() { } diff --git a/src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs b/src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs deleted file mode 100644 index aea5cb21e63..00000000000 --- a/src/test/compile-fail/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass - -fn with_closure(_: F) - where F: FnOnce(A, &u32) -{ -} - -fn foo() { - // This version works; we infer `A` to be `u32`, and take the type - // of `y` to be `&u32`. - with_closure(|x: u32, y| {}); -} - -fn bar<'x>(x: &'x u32) { - // Same. - with_closure(|x: &'x u32, y| {}); -} - -fn main() { } diff --git a/src/test/compile-fail/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs b/src/test/compile-fail/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs deleted file mode 100644 index 377eaadbd6a..00000000000 --- a/src/test/compile-fail/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn with_closure(_: F) - where F: FnOnce(A, B) -{ -} - -fn a() { - // Type of `y` is unconstrained. - with_closure(|x: u32, y| {}); //~ ERROR E0282 -} - -fn b() { - with_closure(|x: u32, y: u32| {}); // OK -} - -fn c() { - with_closure(|x: u32, y: u32| {}); // OK -} - -fn main() { } diff --git a/src/test/compile-fail/closure-no-fn-1.rs b/src/test/compile-fail/closure-no-fn-1.rs deleted file mode 100644 index 10c99703a97..00000000000 --- a/src/test/compile-fail/closure-no-fn-1.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that capturing closures are never coerced to fns -// Especially interesting as non-capturing closures can be. - -fn main() { - let mut a = 0u8; - let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; - //~^ ERROR mismatched types -} diff --git a/src/test/compile-fail/closure-no-fn-2.rs b/src/test/compile-fail/closure-no-fn-2.rs deleted file mode 100644 index a6438bb5f24..00000000000 --- a/src/test/compile-fail/closure-no-fn-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that capturing closures are never coerced to fns -// Especially interesting as non-capturing closures can be. - -fn main() { - let b = 0u8; - let bar: fn() -> u8 = || { b }; - //~^ ERROR mismatched types -} diff --git a/src/test/compile-fail/closure-no-fn-3.rs b/src/test/compile-fail/closure-no-fn-3.rs deleted file mode 100644 index 6584c16c9de..00000000000 --- a/src/test/compile-fail/closure-no-fn-3.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that capturing closures are never coerced to fns -// Especially interesting as non-capturing closures can be. - -fn main() { - let b = 0u8; - let baz: fn() -> u8 = (|| { b }) as fn() -> u8; - //~^ ERROR non-primitive cast -} diff --git a/src/test/compile-fail/closure-referencing-itself-issue-25954.rs b/src/test/compile-fail/closure-referencing-itself-issue-25954.rs deleted file mode 100644 index 9357d0e7615..00000000000 --- a/src/test/compile-fail/closure-referencing-itself-issue-25954.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for #25954: detect and reject a closure type that -// references itself. - -use std::cell::{Cell, RefCell}; - -struct A { - x: RefCell>, - b: Cell, -} - -fn main() { - let mut p = A{x: RefCell::new(None), b: Cell::new(4i32)}; - - // This is an error about types of infinite size: - let q = || p.b.set(5i32); //~ ERROR mismatched types - - *(p.x.borrow_mut()) = Some(q); -} diff --git a/src/test/compile-fail/closure-reform-bad.rs b/src/test/compile-fail/closure-reform-bad.rs deleted file mode 100644 index 490734d463d..00000000000 --- a/src/test/compile-fail/closure-reform-bad.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -fn call_bare(f: fn(&str)) { - f("Hello "); -} - -fn main() { - let string = "world!"; - let f = |s: &str| println!("{}{}", s, string); - call_bare(f) //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/closure-wrong-kind.rs b/src/test/compile-fail/closure-wrong-kind.rs deleted file mode 100644 index a387e4c5ece..00000000000 --- a/src/test/compile-fail/closure-wrong-kind.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -struct X; -fn foo(_: T) {} -fn bar(_: T) {} - -fn main() { - let x = X; - let closure = |_| foo(x); //~ ERROR E0525 - bar(closure); -} diff --git a/src/test/compile-fail/closure_promotion.rs b/src/test/compile-fail/closure_promotion.rs deleted file mode 100644 index ddc995a1a41..00000000000 --- a/src/test/compile-fail/closure_promotion.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(const_err)] - -// nll successfully compiles this. It is a bug. -// See https://github.com/rust-lang/rust/issues/52384 -fn main() { - let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough -} diff --git a/src/test/compile-fail/coerce-expect-unsized-ascribed.rs b/src/test/compile-fail/coerce-expect-unsized-ascribed.rs deleted file mode 100644 index ef65927fc5d..00000000000 --- a/src/test/compile-fail/coerce-expect-unsized-ascribed.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// A version of coerce-expect-unsized that uses type ascription. -// Doesn't work so far, but supposed to work eventually - -#![feature(box_syntax, type_ascription)] - -use std::fmt::Debug; - -pub fn main() { - let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types - let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types - let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; - //~^ ERROR mismatched types - let _ = box { |x| (x as u8) }: Box _>; //~ ERROR mismatched types - let _ = box if true { false } else { true }: Box; //~ ERROR mismatched types - let _ = box match true { true => 'a', false => 'b' }: Box; //~ ERROR mismatched types - - let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types - let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types - let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; - //~^ ERROR mismatched types - let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types - let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types - let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types - - let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types - let _ = Box::new(|x| (x as u8)): Box _>; //~ ERROR mismatched types - - let _ = vec![ - Box::new(|x| (x as u8)), - box |x| (x as i16 as u8), - ]: Vec _>>; -} diff --git a/src/test/compile-fail/coerce-mut.rs b/src/test/compile-fail/coerce-mut.rs deleted file mode 100644 index bc3d58ef33d..00000000000 --- a/src/test/compile-fail/coerce-mut.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f(x: &mut i32) {} - -fn main() { - let x = 0; - f(&x); - //~^ ERROR mismatched types - //~| expected type `&mut i32` - //~| found type `&{integer}` - //~| types differ in mutability -} diff --git a/src/test/compile-fail/coerce-overloaded-autoderef.rs b/src/test/compile-fail/coerce-overloaded-autoderef.rs deleted file mode 100644 index 5a05f59c6f4..00000000000 --- a/src/test/compile-fail/coerce-overloaded-autoderef.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn borrow_mut(x: &mut T) -> &mut T { x } -fn borrow(x: &T) -> &T { x } - -fn borrow_mut2(_: &mut T, _: &mut T) {} -fn borrow2(_: &mut T, _: &T) {} - -fn double_mut_borrow(x: &mut Box) { - let y = borrow_mut(x); - let z = borrow_mut(x); - //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time - //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time - drop((y, z)); -} - -fn double_imm_borrow(x: &mut Box) { - let y = borrow(x); - let z = borrow(x); - **x += 1; - //[ast]~^ ERROR cannot assign to `**x` because it is borrowed - //[mir]~^^ ERROR cannot assign to `**x` because it is borrowed - drop((y, z)); -} - -fn double_mut_borrow2(x: &mut Box) { - borrow_mut2(x, x); - //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time - //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time -} - -fn double_borrow2(x: &mut Box) { - borrow2(x, x); - //[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable -} - -pub fn main() {} diff --git a/src/test/compile-fail/coerce-to-bang-cast.rs b/src/test/compile-fail/coerce-to-bang-cast.rs deleted file mode 100644 index 14a06b306d8..00000000000 --- a/src/test/compile-fail/coerce-to-bang-cast.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] - -fn foo(x: usize, y: !, z: usize) { } - -fn cast_a() { - let y = {return; 22} as !; - //~^ ERROR non-primitive cast -} - -fn cast_b() { - let y = 22 as !; //~ ERROR non-primitive cast -} - -fn main() { } diff --git a/src/test/compile-fail/coerce-to-bang.rs b/src/test/compile-fail/coerce-to-bang.rs deleted file mode 100644 index 8b4e2c3c051..00000000000 --- a/src/test/compile-fail/coerce-to-bang.rs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] - -fn foo(x: usize, y: !, z: usize) { } - -fn call_foo_a() { - foo(return, 22, 44); - //~^ ERROR mismatched types -} - -fn call_foo_b() { - // Divergence happens in the argument itself, definitely ok. - foo(22, return, 44); -} - -fn call_foo_c() { - // This test fails because the divergence happens **after** the - // coercion to `!`: - foo(22, 44, return); //~ ERROR mismatched types -} - -fn call_foo_d() { - // This test passes because `a` has type `!`: - let a: ! = return; - let b = 22; - let c = 44; - foo(a, b, c); // ... and hence a reference to `a` is expected to diverge. - //~^ ERROR mismatched types -} - -fn call_foo_e() { - // This test probably could pass but we don't *know* that `a` - // has type `!` so we don't let it work. - let a = return; - let b = 22; - let c = 44; - foo(a, b, c); //~ ERROR mismatched types -} - -fn call_foo_f() { - // This fn fails because `a` has type `usize`, and hence a - // reference to is it **not** considered to diverge. - let a: usize = return; - let b = 22; - let c = 44; - foo(a, b, c); //~ ERROR mismatched types -} - -fn array_a() { - // Return is coerced to `!` just fine, but `22` cannot be. - let x: [!; 2] = [return, 22]; //~ ERROR mismatched types -} - -fn array_b() { - // Error: divergence has not yet occurred. - let x: [!; 2] = [22, return]; //~ ERROR mismatched types -} - -fn tuple_a() { - // No divergence at all. - let x: (usize, !, usize) = (22, 44, 66); //~ ERROR mismatched types -} - -fn tuple_b() { - // Divergence happens before coercion: OK - let x: (usize, !, usize) = (return, 44, 66); - //~^ ERROR mismatched types -} - -fn tuple_c() { - // Divergence happens before coercion: OK - let x: (usize, !, usize) = (22, return, 66); -} - -fn tuple_d() { - // Error: divergence happens too late - let x: (usize, !, usize) = (22, 44, return); //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/coerce-unsafe-to-closure.rs b/src/test/compile-fail/coerce-unsafe-to-closure.rs deleted file mode 100644 index 90cbbf242aa..00000000000 --- a/src/test/compile-fail/coerce-unsafe-to-closure.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); - //~^ ERROR E0277 -} diff --git a/src/test/compile-fail/coercion-slice.rs b/src/test/compile-fail/coercion-slice.rs deleted file mode 100644 index 7c5a4e0c3c6..00000000000 --- a/src/test/compile-fail/coercion-slice.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that we forbid coercion from `[T; n]` to `&[T]` - -fn main() { - let _: &[i32] = [0]; - //~^ ERROR mismatched types - //~| expected type `&[i32]` - //~| expected &[i32], found array of 1 elements -} diff --git a/src/test/compile-fail/coherence-all-remote.rs b/src/test/compile-fail/coherence-all-remote.rs deleted file mode 100644 index 7a5340041c2..00000000000 --- a/src/test/compile-fail/coherence-all-remote.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote1; - -impl Remote1 for isize { } -//~^ ERROR E0210 - -fn main() { } diff --git a/src/test/compile-fail/coherence-bigint-param.rs b/src/test/compile-fail/coherence-bigint-param.rs deleted file mode 100644 index 32c5b669381..00000000000 --- a/src/test/compile-fail/coherence-bigint-param.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub struct BigInt; - -impl Remote1 for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs deleted file mode 100644 index 434d77828b4..00000000000 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-implemented.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; -use std::default::Default; - -// Test that two blanket impls conflict (at least without negative -// bounds). After all, some other crate could implement Even or Odd -// for the same type (though this crate doesn't). - -trait MyTrait { - fn get(&self) -> usize; -} - -trait Even { } - -trait Odd { } - -impl Even for isize { } - -impl Odd for usize { } - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for T { //~ ERROR E0119 - fn get(&self) -> usize { 0 } -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs deleted file mode 100644 index 7ad5cd71ca8..00000000000 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-blanket-unimplemented.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; -use std::default::Default; - -// Test that two blanket impls conflict (at least without negative -// bounds). After all, some other crate could implement Even or Odd -// for the same type (though this crate doesn't implement them at all). - -trait MyTrait { - fn get(&self) -> usize; -} - -trait Even {} - -trait Odd {} - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for T { //~ ERROR E0119 - fn get(&self) -> usize { 0 } -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-cross-crate.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-specific-cross-crate.rs deleted file mode 100644 index b3ef79c6cc0..00000000000 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-cross-crate.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:go_trait.rs - -extern crate go_trait; - -use go_trait::{Go,GoMut}; -use std::fmt::Debug; -use std::default::Default; - -struct MyThingy; - -impl Go for MyThingy { - fn go(&self, arg: isize) { } -} - -impl GoMut for MyThingy { //~ ERROR conflicting implementations - fn go_mut(&mut self, arg: isize) { } -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs deleted file mode 100644 index 1defe6c8b20..00000000000 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; -use std::default::Default; - -// Test that a blank impl for all T conflicts with an impl for some -// specific T, even when there are multiple type parameters involved. - -trait MyTrait { - fn get(&self) -> T; -} - -impl MyTrait for T { - fn get(&self) -> T { - panic!() - } -} - -#[derive(Clone)] -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { //~ ERROR E0119 - fn get(&self) -> usize { (*self).clone() } -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-trait.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-specific-trait.rs deleted file mode 100644 index 5c5c4d32d67..00000000000 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-trait.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a blank impl for all T:PartialEq conflicts with an impl for some -// specific T when T:PartialEq. - -trait OtherTrait { - fn noop(&self); -} - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { //~ ERROR E0119 - fn get(&self) -> usize { self.dummy } -} - -impl OtherTrait for MyType { - fn noop(&self) { } -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-specific.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-specific.rs deleted file mode 100644 index 57d71b44b0f..00000000000 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-specific.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; -use std::default::Default; - -// Test that a blank impl for all T conflicts with an impl for some -// specific T. - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { //~ ERROR E0119 - fn get(&self) -> usize { self.dummy } -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs b/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs deleted file mode 100644 index 8e9d1eff345..00000000000 --- a/src/test/compile-fail/coherence-conflicting-negative-trait-impl.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(overlapping_marker_traits)] - -trait MyTrait {} - -struct TestType(::std::marker::PhantomData); - -unsafe impl Send for TestType {} - -impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` - -unsafe impl Send for TestType {} - -impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` - -fn main() {} diff --git a/src/test/compile-fail/coherence-cow.rs b/src/test/compile-fail/coherence-cow.rs deleted file mode 100644 index 86ae5b44d9d..00000000000 --- a/src/test/compile-fail/coherence-cow.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: a b c - -// aux-build:coherence_lib.rs - -// Test that the `Pair` type reports an error if it contains type -// parameters, even when they are covered by local types. This test -// was originally intended to test the opposite, but the rules changed -// with RFC 1023 and this became illegal. - -extern crate coherence_lib as lib; -use lib::{Remote,Pair}; - -pub struct Cover(T); - -#[cfg(a)] -impl Remote for Pair> { } //[a]~ ERROR E0210 - -#[cfg(b)] -impl Remote for Pair,T> { } //[b]~ ERROR E0210 - -#[cfg(c)] -impl Remote for Pair,U> { } -//[c]~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/compile-fail/coherence-cross-crate-conflict.rs b/src/test/compile-fail/coherence-cross-crate-conflict.rs deleted file mode 100644 index aac870293fd..00000000000 --- a/src/test/compile-fail/coherence-cross-crate-conflict.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The error here is strictly due to orphan rules; the impl here -// generalizes the one upstream - -// aux-build:trait_impl_conflict.rs -extern crate trait_impl_conflict; -use trait_impl_conflict::Foo; - -impl Foo for A { - //~^ ERROR type parameter `A` must be used as the type parameter for some local type - //~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` -} - -fn main() { -} diff --git a/src/test/compile-fail/coherence-default-trait-impl.rs b/src/test/compile-fail/coherence-default-trait-impl.rs deleted file mode 100644 index 751d0a14c57..00000000000 --- a/src/test/compile-fail/coherence-default-trait-impl.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -auto trait MySafeTrait {} - -struct Foo; - -unsafe impl MySafeTrait for Foo {} -//~^ ERROR implementing the trait `MySafeTrait` is not unsafe - -unsafe auto trait MyUnsafeTrait {} - -impl MyUnsafeTrait for Foo {} -//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration - -fn main() {} diff --git a/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs b/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs deleted file mode 100644 index 8bb9556fcc0..00000000000 --- a/src/test/compile-fail/coherence-impl-trait-for-trait-object-safe.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we give suitable error messages when the user attempts to -// impl a trait `Trait` for its own object type. - -// If the trait is not object-safe, we give a more tailored message -// because we're such schnuckels: -trait NotObjectSafe { fn eq(&self, other: Self); } -impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 - -fn main() { } diff --git a/src/test/compile-fail/coherence-impl-trait-for-trait.rs b/src/test/compile-fail/coherence-impl-trait-for-trait.rs deleted file mode 100644 index cd75b0e34f2..00000000000 --- a/src/test/compile-fail/coherence-impl-trait-for-trait.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we give suitable error messages when the user attempts to -// impl a trait `Trait` for its own object type. - -trait Foo { fn dummy(&self) { } } -trait Bar: Foo { } -trait Baz: Bar { } - -// Supertraits of Baz are not legal: -impl Foo for Baz { } //~ ERROR E0371 -impl Bar for Baz { } //~ ERROR E0371 -impl Baz for Baz { } //~ ERROR E0371 - -// But other random traits are: -trait Other { } -impl Other for Baz { } // OK, Other not a supertrait of Baz - -fn main() { } diff --git a/src/test/compile-fail/coherence-impls-send.rs b/src/test/compile-fail/coherence-impls-send.rs deleted file mode 100644 index 9caaee41aeb..00000000000 --- a/src/test/compile-fail/coherence-impls-send.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(overlapping_marker_traits)] - -use std::marker::Copy; - -enum TestE { - A -} - -struct MyType; - -struct NotSync; -impl !Sync for NotSync {} - -unsafe impl Send for TestE {} -unsafe impl Send for MyType {} -unsafe impl Send for (MyType, MyType) {} -//~^ ERROR E0117 - -unsafe impl Send for &'static NotSync {} -//~^ ERROR E0321 - -unsafe impl Send for [MyType] {} -//~^ ERROR E0117 - -unsafe impl Send for &'static [NotSync] {} -//~^ ERROR E0117 - -fn main() { -} diff --git a/src/test/compile-fail/coherence-impls-sized.rs b/src/test/compile-fail/coherence-impls-sized.rs deleted file mode 100644 index 60b5d14d158..00000000000 --- a/src/test/compile-fail/coherence-impls-sized.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -use std::marker::Copy; - -enum TestE { - A -} - -struct MyType; - -struct NotSync; -impl !Sync for NotSync {} - -impl Sized for TestE {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for MyType {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for (MyType, MyType) {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static NotSync {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for [MyType] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static [NotSync] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -fn main() { -} diff --git a/src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs b/src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs deleted file mode 100644 index 5db901b5ba1..00000000000 --- a/src/test/compile-fail/coherence-inherited-assoc-ty-cycle-err.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Formerly this ICEd with the following message: -// Tried to project an inherited associated type during coherence checking, -// which is currently not supported. -// -// No we expect to run into a more user-friendly cycle error instead. - -#![feature(specialization)] - -trait Trait { type Assoc; } -//~^ cycle detected - -impl Trait for Vec { - type Assoc = (); -} - -impl Trait for Vec {} - -impl Trait for String { - type Assoc = (); -} - -impl Trait< as Trait>::Assoc> for String {} - -fn main() {} diff --git a/src/test/compile-fail/coherence-lone-type-parameter.rs b/src/test/compile-fail/coherence-lone-type-parameter.rs deleted file mode 100644 index e78f392b386..00000000000 --- a/src/test/compile-fail/coherence-lone-type-parameter.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -impl Remote for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/compile-fail/coherence-negative-impls-safe.rs b/src/test/compile-fail/coherence-negative-impls-safe.rs deleted file mode 100644 index 1ae07b64685..00000000000 --- a/src/test/compile-fail/coherence-negative-impls-safe.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -struct TestType; - -unsafe impl !Send for TestType {} -//~^ ERROR negative impls cannot be unsafe - -fn main() {} diff --git a/src/test/compile-fail/coherence-no-direct-lifetime-dispatch.rs b/src/test/compile-fail/coherence-no-direct-lifetime-dispatch.rs deleted file mode 100644 index 47026cd32d4..00000000000 --- a/src/test/compile-fail/coherence-no-direct-lifetime-dispatch.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that you cannot *directly* dispatch on lifetime requirements - -trait MyTrait { fn foo() {} } - -impl MyTrait for T {} -impl MyTrait for T {} //~ ERROR E0119 - -fn main() {} diff --git a/src/test/compile-fail/coherence-orphan.rs b/src/test/compile-fail/coherence-orphan.rs deleted file mode 100644 index 80efc7b75e2..00000000000 --- a/src/test/compile-fail/coherence-orphan.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_orphan_lib.rs - -#![feature(optin_builtin_traits)] - -extern crate coherence_orphan_lib as lib; - -use lib::TheTrait; - -struct TheType; - -impl TheTrait for isize { } -//~^ ERROR E0117 - -impl TheTrait for isize { } - -impl TheTrait for TheType { } - -impl !Send for Vec { } -//~^ ERROR E0117 - -fn main() { } diff --git a/src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs b/src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs deleted file mode 100644 index 1fad608db6c..00000000000 --- a/src/test/compile-fail/coherence-overlap-all-t-and-tuple.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we detect an overlap here in the case where: -// -// for some type X: -// T = (X,) -// T11 = X, U11 = X -// -// Seems pretty basic, but then there was issue #24241. :) - -trait From { - fn foo() {} -} - -impl From for T { -} - -impl From<(U11,)> for (T11,) { //~ ERROR E0119 -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-overlap-messages.rs b/src/test/compile-fail/coherence-overlap-messages.rs deleted file mode 100644 index a10deeafbe6..00000000000 --- a/src/test/compile-fail/coherence-overlap-messages.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { fn foo() {} } - -impl Foo for T {} -impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: - -trait Bar { fn bar() {} } - -impl Bar for (T, u8) {} -impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: - -trait Baz { fn baz() {} } - -impl Baz for T {} -impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: - -trait Quux { fn quux() {} } - -impl Quux for T {} -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: - -fn main() {} diff --git a/src/test/compile-fail/coherence-overlapping-pairs.rs b/src/test/compile-fail/coherence-overlapping-pairs.rs deleted file mode 100644 index ba9dc53e868..00000000000 --- a/src/test/compile-fail/coherence-overlapping-pairs.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Foo; - -impl Remote for lib::Pair { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs b/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs deleted file mode 100644 index f55efef14fa..00000000000 --- a/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the same coverage rules apply even if the local type appears in the -// list of type parameters, not the self type. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::{Remote1, Pair}; - -pub struct Local(T); - -impl Remote1>> for i32 { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered.rs b/src/test/compile-fail/coherence-pair-covered-uncovered.rs deleted file mode 100644 index 0642dff4b28..00000000000 --- a/src/test/compile-fail/coherence-pair-covered-uncovered.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::{Remote, Pair}; - -struct Local(T); - -impl Remote for Pair> { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/compile-fail/coherence-projection-conflict-orphan.rs b/src/test/compile-fail/coherence-projection-conflict-orphan.rs deleted file mode 100644 index 784ff0cd5e0..00000000000 --- a/src/test/compile-fail/coherence-projection-conflict-orphan.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -// Here we expect a coherence conflict because, even though `i32` does -// not implement `Iterator`, we cannot rely on that negative reasoning -// due to the orphan rules. Therefore, `A::Item` may yet turn out to -// be `i32`. - -pub trait Foo

{ fn foo() {} } - -pub trait Bar { - type Output: 'static; -} - -impl Foo for i32 { } - -impl Foo for A { } //~ ERROR E0119 - -fn main() {} diff --git a/src/test/compile-fail/coherence-projection-conflict-ty-param.rs b/src/test/compile-fail/coherence-projection-conflict-ty-param.rs deleted file mode 100644 index 120d9046389..00000000000 --- a/src/test/compile-fail/coherence-projection-conflict-ty-param.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Coherence error results because we do not know whether `T: Foo

` or not -// for the second impl. - -use std::marker::PhantomData; - -pub trait Foo

{ fn foo() {} } - -impl > Foo

for Option {} - -impl Foo for Option { } //~ ERROR E0119 - -fn main() {} diff --git a/src/test/compile-fail/coherence-projection-conflict.rs b/src/test/compile-fail/coherence-projection-conflict.rs deleted file mode 100644 index 3c32ab38b93..00000000000 --- a/src/test/compile-fail/coherence-projection-conflict.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker::PhantomData; - -pub trait Foo

{ fn foo() {} } - -pub trait Bar { - type Output: 'static; -} - -impl Foo for i32 { } - -impl Foo for A { } //~ ERROR E0119 - -impl Bar for i32 { - type Output = i32; -} - -fn main() {} diff --git a/src/test/compile-fail/coherence-projection-ok-orphan.rs b/src/test/compile-fail/coherence-projection-ok-orphan.rs deleted file mode 100644 index a52af0873a8..00000000000 --- a/src/test/compile-fail/coherence-projection-ok-orphan.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -// Here we do not get a coherence conflict because `Baz: Iterator` -// does not hold and (due to the orphan rules), we can rely on that. - -pub trait Foo

{} - -pub trait Bar { - type Output: 'static; -} - -struct Baz; -impl Foo for Baz { } - -impl Foo for A { } - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/coherence-projection-ok.rs b/src/test/compile-fail/coherence-projection-ok.rs deleted file mode 100644 index af88f3744ea..00000000000 --- a/src/test/compile-fail/coherence-projection-ok.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -pub trait Foo

{ fn foo() {} } + +pub trait Bar { + type Output: 'static; +} + +impl Foo for i32 { } + +impl Foo for A { } //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.stderr b/src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.stderr new file mode 100644 index 00000000000..a0fcf072fa8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict-orphan.rs:26:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | + = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.rs b/src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.rs new file mode 100644 index 00000000000..120d9046389 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Coherence error results because we do not know whether `T: Foo

` or not +// for the second impl. + +use std::marker::PhantomData; + +pub trait Foo

{ fn foo() {} } + +impl > Foo

for Option {} + +impl Foo for Option { } //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.stderr b/src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.stderr new file mode 100644 index 00000000000..cfbf96bc1c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-conflict-ty-param.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`: + --> $DIR/coherence-projection-conflict-ty-param.rs:20:1 + | +LL | impl > Foo

for Option {} + | ---------------------------------------- first implementation here +LL | +LL | impl Foo for Option { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-projection-conflict.rs b/src/test/ui/compile-fail-migration/coherence-projection-conflict.rs new file mode 100644 index 00000000000..3c32ab38b93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-conflict.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker::PhantomData; + +pub trait Foo

{ fn foo() {} } + +pub trait Bar { + type Output: 'static; +} + +impl Foo for i32 { } + +impl Foo for A { } //~ ERROR E0119 + +impl Bar for i32 { + type Output = i32; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-projection-conflict.stderr b/src/test/ui/compile-fail-migration/coherence-projection-conflict.stderr new file mode 100644 index 00000000000..3832faf28d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-conflict.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict.rs:21:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.rs b/src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.rs new file mode 100644 index 00000000000..a52af0873a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +// Here we do not get a coherence conflict because `Baz: Iterator` +// does not hold and (due to the orphan rules), we can rely on that. + +pub trait Foo

{} + +pub trait Bar { + type Output: 'static; +} + +struct Baz; +impl Foo for Baz { } + +impl Foo for A { } + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.stderr b/src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.stderr new file mode 100644 index 00000000000..1b9a32525bf --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-ok-orphan.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/coherence-projection-ok-orphan.rs:29:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/coherence-projection-ok.rs b/src/test/ui/compile-fail-migration/coherence-projection-ok.rs new file mode 100644 index 00000000000..af88f3744ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-ok.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +pub trait Foo

{} + +pub trait Bar { + type Output: 'static; +} + +impl Foo for i32 { } + +impl Foo for A { } + +impl Bar for i32 { + type Output = u32; +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/coherence-projection-ok.stderr b/src/test/ui/compile-fail-migration/coherence-projection-ok.stderr new file mode 100644 index 00000000000..945f3b396b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-ok.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/coherence-projection-ok.rs:28:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/coherence-tuple-conflict.rs b/src/test/ui/compile-fail-migration/coherence-tuple-conflict.rs new file mode 100644 index 00000000000..7807f93df1a --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-tuple-conflict.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; +use std::default::Default; + +// Test that a blank impl for all T conflicts with an impl for some +// specific T. + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for (T,T) { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for (A,B) { //~ ERROR E0119 + fn get(&self) -> usize { self.dummy } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-tuple-conflict.stderr b/src/test/ui/compile-fail-migration/coherence-tuple-conflict.stderr new file mode 100644 index 00000000000..4ceafea0a70 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-tuple-conflict.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(_, _)`: + --> $DIR/coherence-tuple-conflict.rs:25:1 + | +LL | impl MyTrait for (T,T) { + | ------------------------- first implementation here +... +LL | impl MyTrait for (A,B) { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-vec-local-2.rs b/src/test/ui/compile-fail-migration/coherence-vec-local-2.rs new file mode 100644 index 00000000000..196c2f4ee3c --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-vec-local-2.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a local, generic type appearing within a +// *non-fundamental* remote type like `Vec` is not considered local. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Local(T); + +impl Remote for Vec> { } //~ ERROR E0210 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-vec-local-2.stderr b/src/test/ui/compile-fail-migration/coherence-vec-local-2.stderr new file mode 100644 index 00000000000..2980d4a3392 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-vec-local-2.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-vec-local-2.rs:21:1 + | +LL | impl Remote for Vec> { } //~ ERROR E0210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-vec-local.rs b/src/test/ui/compile-fail-migration/coherence-vec-local.rs new file mode 100644 index 00000000000..49822dcfcb3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-vec-local.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a local type (with no type parameters) appearing within a +// *non-fundamental* remote type like `Vec` is not considered local. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Local; + +impl Remote for Vec { } //~ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-vec-local.stderr b/src/test/ui/compile-fail-migration/coherence-vec-local.stderr new file mode 100644 index 00000000000..b3c26160fe5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-vec-local.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-vec-local.rs:21:1 + | +LL | impl Remote for Vec { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.rs b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.rs new file mode 100644 index 00000000000..9fbb7aa4cb1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// `MyFundamentalStruct` is declared fundamental, so we can test that +// +// MyFundamentalStruct: !MyTrait +// +// Huzzah. +impl MyTrait for lib::MyFundamentalStruct { } + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.stderr b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.stderr new file mode 100644 index 00000000000..675dc1b7004 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/coherence_copy_like_err_fundamental_struct.rs:34:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.rs b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.rs new file mode 100644 index 00000000000..2f6dca4f3c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// `MyFundamentalStruct` is declared fundamental, so we can test that +// +// MyFundamentalStruct<&MyTrait>: !MyTrait +// +// Huzzah. +impl<'a> MyTrait for lib::MyFundamentalStruct<&'a MyType> { } + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.stderr b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.stderr new file mode 100644 index 00000000000..5143d4e874b --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_ref.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/coherence_copy_like_err_fundamental_struct_ref.rs:34:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.rs b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.rs new file mode 100644 index 00000000000..f424e887201 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(rustc_attrs)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } + +impl MyTrait for T { } + +// Tuples are not fundamental. +impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.stderr b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.stderr new file mode 100644 index 00000000000..c7c49fe1462 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_fundamental_struct_tuple.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>`: + --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:27:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.rs b/src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.rs new file mode 100644 index 00000000000..04262e65c5a --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_copy_like_lib.rs + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// `MyStruct` is not declared fundamental, therefore this would +// require that +// +// MyStruct: !MyTrait +// +// which we cannot approve. +impl MyTrait for lib::MyStruct { } //~ ERROR E0119 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.stderr b/src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.stderr new file mode 100644 index 00000000000..786a3df0503 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_struct.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct`: + --> $DIR/coherence_copy_like_err_struct.rs:29:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyStruct { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyStruct` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.rs b/src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.rs new file mode 100644 index 00000000000..378a70864f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// Tuples are not fundamental, therefore this would require that +// +// (MyType,): !MyTrait +// +// which we cannot approve. +impl MyTrait for (MyType,) { } //~ ERROR E0119 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.stderr b/src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.stderr new file mode 100644 index 00000000000..3708a38443c --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_copy_like_err_tuple.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(MyType,)`: + --> $DIR/coherence_copy_like_err_tuple.rs:28:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for (MyType,) { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(MyType,)` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `(MyType,)` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence_inherent.rs b/src/test/ui/compile-fail-migration/coherence_inherent.rs new file mode 100644 index 00000000000..087b8c14e35 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_inherent.rs @@ -0,0 +1,45 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that methods that implement a trait cannot be invoked +// unless the trait is imported. + +mod Lib { + pub trait TheTrait { + fn the_fn(&self); + } + + pub struct TheStruct; + + impl TheTrait for TheStruct { + fn the_fn(&self) {} + } +} + +mod Import { + // Trait is in scope here: + use Lib::TheStruct; + use Lib::TheTrait; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); + } +} + +mod NoImport { + // Trait is not in scope here: + use Lib::TheStruct; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); //~ ERROR no method named `the_fn` found + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence_inherent.stderr b/src/test/ui/compile-fail-migration/coherence_inherent.stderr new file mode 100644 index 00000000000..1708979ab11 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_inherent.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope + --> $DIR/coherence_inherent.rs:41:11 + | +LL | s.the_fn(); //~ ERROR no method named `the_fn` found + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use Lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/coherence_inherent_cc.rs b/src/test/ui/compile-fail-migration/coherence_inherent_cc.rs new file mode 100644 index 00000000000..442c4c89de4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_inherent_cc.rs @@ -0,0 +1,37 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_inherent_cc_lib.rs + +// Tests that methods that implement a trait cannot be invoked +// unless the trait is imported. + +extern crate coherence_inherent_cc_lib; + +mod Import { + // Trait is in scope here: + use coherence_inherent_cc_lib::TheStruct; + use coherence_inherent_cc_lib::TheTrait; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); + } +} + +mod NoImport { + // Trait is not in scope here: + use coherence_inherent_cc_lib::TheStruct; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); //~ ERROR no method named `the_fn` found + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence_inherent_cc.stderr b/src/test/ui/compile-fail-migration/coherence_inherent_cc.stderr new file mode 100644 index 00000000000..a3c1b60d09a --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_inherent_cc.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope + --> $DIR/coherence_inherent_cc.rs:33:11 + | +LL | s.the_fn(); //~ ERROR no method named `the_fn` found + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use coherence_inherent_cc_lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/coherence_local.rs b/src/test/ui/compile-fail-migration/coherence_local.rs new file mode 100644 index 00000000000..551577b6b4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// These are all legal because they are all fundamental types: + +impl lib::MyCopy for MyType { } +impl<'a> lib::MyCopy for &'a MyType { } +impl<'a> lib::MyCopy for &'a Box { } +impl lib::MyCopy for Box { } +impl lib::MyCopy for lib::MyFundamentalStruct { } +impl lib::MyCopy for lib::MyFundamentalStruct> { } + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/coherence_local.stderr b/src/test/ui/compile-fail-migration/coherence_local.stderr new file mode 100644 index 00000000000..c4340e8d876 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/coherence_local.rs:33:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/coherence_local_err_struct.rs b/src/test/ui/compile-fail-migration/coherence_local_err_struct.rs new file mode 100644 index 00000000000..01f4c1cd8a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local_err_struct.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// These are all legal because they are all fundamental types: + +// MyStruct is not fundamental. +impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence_local_err_struct.stderr b/src/test/ui/compile-fail-migration/coherence_local_err_struct.stderr new file mode 100644 index 00000000000..c35e95040de --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local_err_struct.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_struct.rs:26:1 + | +LL | impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/coherence_local_err_tuple.rs b/src/test/ui/compile-fail-migration/coherence_local_err_tuple.rs new file mode 100644 index 00000000000..590f68cee59 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local_err_tuple.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// These are all legal because they are all fundamental types: + +// Tuples are not fundamental, so this is not a local impl. +impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence_local_err_tuple.stderr b/src/test/ui/compile-fail-migration/coherence_local_err_tuple.stderr new file mode 100644 index 00000000000..a3f9f2d32b8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local_err_tuple.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_tuple.rs:26:1 + | +LL | impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/coherence_local_ref.rs b/src/test/ui/compile-fail-migration/coherence_local_ref.rs new file mode 100644 index 00000000000..f6e1aab5976 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local_ref.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// naturally, legal +impl lib::MyCopy for MyType { } + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/coherence_local_ref.stderr b/src/test/ui/compile-fail-migration/coherence_local_ref.stderr new file mode 100644 index 00000000000..13d6fdd80f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence_local_ref.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/coherence_local_ref.rs:27:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/compile_error_macro.rs b/src/test/ui/compile-fail-migration/compile_error_macro.rs new file mode 100644 index 00000000000..e9c5993098c --- /dev/null +++ b/src/test/ui/compile-fail-migration/compile_error_macro.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + compile_error!("a very descriptive error message"); //~ ERROR: a very descriptive error message +} diff --git a/src/test/ui/compile-fail-migration/compile_error_macro.stderr b/src/test/ui/compile-fail-migration/compile_error_macro.stderr new file mode 100644 index 00000000000..1abf5accc17 --- /dev/null +++ b/src/test/ui/compile-fail-migration/compile_error_macro.stderr @@ -0,0 +1,8 @@ +error: a very descriptive error message + --> $DIR/compile_error_macro.rs:12:5 + | +LL | compile_error!("a very descriptive error message"); //~ ERROR: a very descriptive error message + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/concat.rs b/src/test/ui/compile-fail-migration/concat.rs new file mode 100644 index 00000000000..e29c6ac5d5e --- /dev/null +++ b/src/test/ui/compile-fail-migration/concat.rs @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + concat!(b'f'); //~ ERROR: cannot concatenate a byte string literal + concat!(b"foo"); //~ ERROR: cannot concatenate a byte string literal + concat!(foo); //~ ERROR: expected a literal + concat!(foo()); //~ ERROR: expected a literal +} diff --git a/src/test/ui/compile-fail-migration/concat.stderr b/src/test/ui/compile-fail-migration/concat.stderr new file mode 100644 index 00000000000..0128811353f --- /dev/null +++ b/src/test/ui/compile-fail-migration/concat.stderr @@ -0,0 +1,30 @@ +error: cannot concatenate a byte string literal + --> $DIR/concat.rs:12:13 + | +LL | concat!(b'f'); //~ ERROR: cannot concatenate a byte string literal + | ^^^^ + +error: cannot concatenate a byte string literal + --> $DIR/concat.rs:13:13 + | +LL | concat!(b"foo"); //~ ERROR: cannot concatenate a byte string literal + | ^^^^^^ + +error: expected a literal + --> $DIR/concat.rs:14:13 + | +LL | concat!(foo); //~ ERROR: expected a literal + | ^^^ + | + = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()` + +error: expected a literal + --> $DIR/concat.rs:15:13 + | +LL | concat!(foo()); //~ ERROR: expected a literal + | ^^^^^ + | + = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/conflicting-repr-hints.rs b/src/test/ui/compile-fail-migration/conflicting-repr-hints.rs new file mode 100644 index 00000000000..426f60c6b09 --- /dev/null +++ b/src/test/ui/compile-fail-migration/conflicting-repr-hints.rs @@ -0,0 +1,67 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![feature(repr_packed)] + +#[repr(C)] +enum A { A } + +#[repr(u64)] +enum B { B } + +#[repr(C, u64)] //~ WARNING conflicting representation hints +enum C { C } + +#[repr(u32, u64)] //~ WARNING conflicting representation hints +enum D { D } + +#[repr(C, packed)] +struct E(i32); + +#[repr(packed, align(8))] +struct F(i32); //~ ERROR type has conflicting packed and align representation hints + +#[repr(packed)] +#[repr(align(8))] +struct G(i32); //~ ERROR type has conflicting packed and align representation hints + +#[repr(align(8))] +#[repr(packed)] +struct H(i32); //~ ERROR type has conflicting packed and align representation hints + +#[repr(packed, packed(2))] +struct I(i32); //~ ERROR type has conflicting packed representation hints + +#[repr(packed(2))] +#[repr(packed)] +struct J(i32); //~ ERROR type has conflicting packed representation hints + +#[repr(packed, packed(1))] +struct K(i32); + +#[repr(packed, align(8))] +union X { //~ ERROR type has conflicting packed and align representation hints + i: i32 +} + +#[repr(packed)] +#[repr(align(8))] +union Y { //~ ERROR type has conflicting packed and align representation hints + i: i32 +} + +#[repr(align(8))] +#[repr(packed)] +union Z { //~ ERROR type has conflicting packed and align representation hints + i: i32 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/conflicting-repr-hints.stderr b/src/test/ui/compile-fail-migration/conflicting-repr-hints.stderr new file mode 100644 index 00000000000..7a4e5a5488a --- /dev/null +++ b/src/test/ui/compile-fail-migration/conflicting-repr-hints.stderr @@ -0,0 +1,70 @@ +warning[E0566]: conflicting representation hints + --> $DIR/conflicting-repr-hints.rs:20:8 + | +LL | #[repr(C, u64)] //~ WARNING conflicting representation hints + | ^ ^^^ + +warning[E0566]: conflicting representation hints + --> $DIR/conflicting-repr-hints.rs:23:8 + | +LL | #[repr(u32, u64)] //~ WARNING conflicting representation hints + | ^^^ ^^^ + +error[E0587]: type has conflicting packed and align representation hints + --> $DIR/conflicting-repr-hints.rs:30:1 + | +LL | struct F(i32); //~ ERROR type has conflicting packed and align representation hints + | ^^^^^^^^^^^^^^ + +error[E0587]: type has conflicting packed and align representation hints + --> $DIR/conflicting-repr-hints.rs:34:1 + | +LL | struct G(i32); //~ ERROR type has conflicting packed and align representation hints + | ^^^^^^^^^^^^^^ + +error[E0587]: type has conflicting packed and align representation hints + --> $DIR/conflicting-repr-hints.rs:38:1 + | +LL | struct H(i32); //~ ERROR type has conflicting packed and align representation hints + | ^^^^^^^^^^^^^^ + +error[E0634]: type has conflicting packed representation hints + --> $DIR/conflicting-repr-hints.rs:41:1 + | +LL | struct I(i32); //~ ERROR type has conflicting packed representation hints + | ^^^^^^^^^^^^^^ + +error[E0634]: type has conflicting packed representation hints + --> $DIR/conflicting-repr-hints.rs:45:1 + | +LL | struct J(i32); //~ ERROR type has conflicting packed representation hints + | ^^^^^^^^^^^^^^ + +error[E0587]: type has conflicting packed and align representation hints + --> $DIR/conflicting-repr-hints.rs:51:1 + | +LL | / union X { //~ ERROR type has conflicting packed and align representation hints +LL | | i: i32 +LL | | } + | |_^ + +error[E0587]: type has conflicting packed and align representation hints + --> $DIR/conflicting-repr-hints.rs:57:1 + | +LL | / union Y { //~ ERROR type has conflicting packed and align representation hints +LL | | i: i32 +LL | | } + | |_^ + +error[E0587]: type has conflicting packed and align representation hints + --> $DIR/conflicting-repr-hints.rs:63:1 + | +LL | / union Z { //~ ERROR type has conflicting packed and align representation hints +LL | | i: i32 +LL | | } + | |_^ + +error: aborting due to 8 previous errors + +Some errors occurred: E0566, E0587, E0634. +For more information about an error, try `rustc --explain E0566`. diff --git a/src/test/ui/compile-fail-migration/conservative_impl_trait.rs b/src/test/ui/compile-fail-migration/conservative_impl_trait.rs new file mode 100644 index 00000000000..30895bce357 --- /dev/null +++ b/src/test/ui/compile-fail-migration/conservative_impl_trait.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #39872, #39553 + +fn will_ice(something: &u32) -> impl Iterator { + //~^ ERROR the trait bound `(): std::iter::Iterator` is not satisfied [E0277] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/conservative_impl_trait.stderr b/src/test/ui/compile-fail-migration/conservative_impl_trait.stderr new file mode 100644 index 00000000000..6fcd384566c --- /dev/null +++ b/src/test/ui/compile-fail-migration/conservative_impl_trait.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied + --> $DIR/conservative_impl_trait.rs:13:33 + | +LL | fn will_ice(something: &u32) -> impl Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method + | + = help: the trait `std::iter::Iterator` is not implemented for `()` + = note: the return type of a function must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/const-array-oob-arith.rs b/src/test/ui/compile-fail-migration/const-array-oob-arith.rs new file mode 100644 index 00000000000..9c07abdc36d --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-array-oob-arith.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_indexing)] + +const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; +const IDX: usize = 3; +const VAL: i32 = ARR[IDX]; +const BONG: [i32; (ARR[0] - 41) as usize] = [5]; +const BLUB: [i32; (ARR[0] - 40) as usize] = [5]; //~ ERROR: mismatched types +const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99]; //~ ERROR: mismatched types + +fn main() { + let _ = VAL; +} diff --git a/src/test/ui/compile-fail-migration/const-array-oob-arith.stderr b/src/test/ui/compile-fail-migration/const-array-oob-arith.stderr new file mode 100644 index 00000000000..5b5f9425e73 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-array-oob-arith.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/const-array-oob-arith.rs:17:45 + | +LL | const BLUB: [i32; (ARR[0] - 40) as usize] = [5]; //~ ERROR: mismatched types + | ^^^ expected an array with a fixed size of 2 elements, found one with 1 elements + | + = note: expected type `[i32; 2]` + found type `[i32; 1]` + +error[E0308]: mismatched types + --> $DIR/const-array-oob-arith.rs:18:44 + | +LL | const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99]; //~ ERROR: mismatched types + | ^^^^^^^ expected an array with a fixed size of 1 elements, found one with 2 elements + | + = note: expected type `[i32; 1]` + found type `[i32; 2]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/const-array-oob.rs b/src/test/ui/compile-fail-migration/const-array-oob.rs new file mode 100644 index 00000000000..22a3c5ceeb7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-array-oob.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +#![feature(const_indexing)] + +const FOO: [usize; 3] = [1, 2, 3]; +const BAR: usize = FOO[5]; // no error, because the error below occurs before regular const eval + +const BLUB: [u32; FOO[4]] = [5, 6]; +//~^ ERROR could not evaluate constant expression [E0080] +//~| index out of bounds: the len is 3 but the index is 4 + +fn main() { + let _ = BAR; +} diff --git a/src/test/ui/compile-fail-migration/const-array-oob.stderr b/src/test/ui/compile-fail-migration/const-array-oob.stderr new file mode 100644 index 00000000000..09e4918bf6e --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-array-oob.stderr @@ -0,0 +1,19 @@ +error: index out of bounds: the len is 3 but the index is 4 + --> $DIR/const-array-oob.rs:18:19 + | +LL | const BLUB: [u32; FOO[4]] = [5, 6]; + | ^^^^^^ + | + = note: #[deny(const_err)] on by default + +error[E0080]: could not evaluate constant expression + --> $DIR/const-array-oob.rs:18:1 + | +LL | const BLUB: [u32; FOO[4]] = [5, 6]; + | ^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^ + | | + | index out of bounds: the len is 3 but the index is 4 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/const-block-non-item-statement-2.rs b/src/test/ui/compile-fail-migration/const-block-non-item-statement-2.rs new file mode 100644 index 00000000000..f80d55cb342 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-block-non-item-statement-2.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const A: usize = { 1; 2 }; +//~^ ERROR statements in constants are unstable + +const B: usize = { { } 2 }; +//~^ ERROR statements in constants are unstable + +macro_rules! foo { + () => (()) //~ ERROR statements in constants are unstable +} +const C: usize = { foo!(); 2 }; + +const D: usize = { let x = 4; 2 }; +//~^ ERROR let bindings in constants are unstable +//~| ERROR statements in constants are unstable +//~| ERROR let bindings in constants are unstable +//~| ERROR statements in constants are unstable + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-block-non-item-statement-2.stderr b/src/test/ui/compile-fail-migration/const-block-non-item-statement-2.stderr new file mode 100644 index 00000000000..580f7e039d1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-block-non-item-statement-2.stderr @@ -0,0 +1,62 @@ +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-2.rs:11:20 + | +LL | const A: usize = { 1; 2 }; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-2.rs:14:20 + | +LL | const B: usize = { { } 2 }; + | ^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-2.rs:18:12 + | +LL | () => (()) //~ ERROR statements in constants are unstable + | ^^ +LL | } +LL | const C: usize = { foo!(); 2 }; + | ------- in this macro invocation + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-2.rs:22:28 + | +LL | const D: usize = { let x = 4; 2 }; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-2.rs:22:28 + | +LL | const D: usize = { let x = 4; 2 }; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-2.rs:22:1 + | +LL | const D: usize = { let x = 4; 2 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-2.rs:22:1 + | +LL | const D: usize = { let x = 4; 2 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/const-block-non-item-statement-3.rs b/src/test/ui/compile-fail-migration/const-block-non-item-statement-3.rs new file mode 100644 index 00000000000..cfa4b778dde --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-block-non-item-statement-3.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +type Array = [u32; { let x = 2; 5 }]; +//~^ ERROR let bindings in constants are unstable +//~| ERROR statements in constants are unstable +//~| ERROR let bindings in constants are unstable +//~| ERROR statements in constants are unstable + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-block-non-item-statement-3.stderr b/src/test/ui/compile-fail-migration/const-block-non-item-statement-3.stderr new file mode 100644 index 00000000000..0124288d43d --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-block-non-item-statement-3.stderr @@ -0,0 +1,35 @@ +error[E0658]: let bindings in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-3.rs:11:31 + | +LL | type Array = [u32; { let x = 2; 5 }]; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-3.rs:11:31 + | +LL | type Array = [u32; { let x = 2; 5 }]; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-3.rs:11:20 + | +LL | type Array = [u32; { let x = 2; 5 }]; + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement-3.rs:11:20 + | +LL | type Array = [u32; { let x = 2; 5 }]; + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/const-block-non-item-statement.rs b/src/test/ui/compile-fail-migration/const-block-non-item-statement.rs new file mode 100644 index 00000000000..f974a24c26f --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-block-non-item-statement.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Foo { + Bar = { let x = 1; 3 } + //~^ ERROR let bindings in constants are unstable + //~| ERROR statements in constants are unstable + //~| ERROR let bindings in constants are unstable + //~| ERROR statements in constants are unstable +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-block-non-item-statement.stderr b/src/test/ui/compile-fail-migration/const-block-non-item-statement.stderr new file mode 100644 index 00000000000..b367a9d9937 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-block-non-item-statement.stderr @@ -0,0 +1,35 @@ +error[E0658]: let bindings in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement.rs:12:21 + | +LL | Bar = { let x = 1; 3 } + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement.rs:12:21 + | +LL | Bar = { let x = 1; 3 } + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement.rs:12:11 + | +LL | Bar = { let x = 1; 3 } + | ^^^^^^^^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/const-block-non-item-statement.rs:12:11 + | +LL | Bar = { let x = 1; 3 } + | ^^^^^^^^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/const-call.rs b/src/test/ui/compile-fail-migration/const-call.rs new file mode 100644 index 00000000000..02264228a6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-call.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f(x: usize) -> usize { + x +} + +fn main() { + let _ = [0; f(2)]; + //~^ ERROR calls in constants are limited to constant functions + //~| E0080 +} diff --git a/src/test/ui/compile-fail-migration/const-call.stderr b/src/test/ui/compile-fail-migration/const-call.stderr new file mode 100644 index 00000000000..efc3c58c681 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-call.stderr @@ -0,0 +1,16 @@ +error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants + --> $DIR/const-call.rs:16:17 + | +LL | let _ = [0; f(2)]; + | ^^^^ + +error[E0080]: could not evaluate repeat length + --> $DIR/const-call.rs:16:17 + | +LL | let _ = [0; f(2)]; + | ^^^^ calling non-const fn `f` + +error: aborting due to 2 previous errors + +Some errors occurred: E0015, E0080. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/compile-fail-migration/const-cast-different-types.rs b/src/test/ui/compile-fail-migration/const-cast-different-types.rs new file mode 100644 index 00000000000..397804566b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-cast-different-types.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static a: &'static str = "foo"; +static b: *const u8 = a as *const u8; //~ ERROR casting +static c: *const u8 = &a as *const u8; //~ ERROR casting + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/const-cast-different-types.stderr b/src/test/ui/compile-fail-migration/const-cast-different-types.stderr new file mode 100644 index 00000000000..bc4d1358697 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-cast-different-types.stderr @@ -0,0 +1,15 @@ +error[E0606]: casting `&'static str` as `*const u8` is invalid + --> $DIR/const-cast-different-types.rs:12:23 + | +LL | static b: *const u8 = a as *const u8; //~ ERROR casting + | ^^^^^^^^^^^^^^ + +error[E0606]: casting `&&'static str` as `*const u8` is invalid + --> $DIR/const-cast-different-types.rs:13:23 + | +LL | static c: *const u8 = &a as *const u8; //~ ERROR casting + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/compile-fail-migration/const-cast-wrong-type.rs b/src/test/ui/compile-fail-migration/const-cast-wrong-type.rs new file mode 100644 index 00000000000..b3597441834 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-cast-wrong-type.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static a: [u8; 3] = ['h' as u8, 'i' as u8, 0 as u8]; +static b: *const i8 = &a as *const i8; //~ ERROR mismatched types + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/const-cast-wrong-type.stderr b/src/test/ui/compile-fail-migration/const-cast-wrong-type.stderr new file mode 100644 index 00000000000..d7ac89cc6a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-cast-wrong-type.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/const-cast-wrong-type.rs:12:23 + | +LL | static b: *const i8 = &a as *const i8; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^ expected u8, found i8 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/const-err-early.rs b/src/test/ui/compile-fail-migration/const-err-early.rs new file mode 100644 index 00000000000..39b1b342eac --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err-early.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(const_err)] + +pub const A: i8 = -std::i8::MIN; //~ ERROR const_err +pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err +pub const C: u8 = 200u8 * 4; //~ ERROR const_err +pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err +pub const E: u8 = [5u8][1]; //~ ERROR const_err + +fn main() { + let _a = A; + let _b = B; + let _c = C; + let _d = D; + let _e = E; + let _e = [6u8][1]; +} diff --git a/src/test/ui/compile-fail-migration/const-err-early.stderr b/src/test/ui/compile-fail-migration/const-err-early.stderr new file mode 100644 index 00000000000..36f3ac1a9bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err-early.stderr @@ -0,0 +1,48 @@ +error: this constant cannot be used + --> $DIR/const-err-early.rs:13:1 + | +LL | pub const A: i8 = -std::i8::MIN; //~ ERROR const_err + | ^^^^^^^^^^^^^^^^^^-------------^ + | | + | attempt to negate with overflow + | +note: lint level defined here + --> $DIR/const-err-early.rs:11:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: this constant cannot be used + --> $DIR/const-err-early.rs:14:1 + | +LL | pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err + | ^^^^^^^^^^^^^^^^^^-------------^ + | | + | attempt to add with overflow + +error: this constant cannot be used + --> $DIR/const-err-early.rs:15:1 + | +LL | pub const C: u8 = 200u8 * 4; //~ ERROR const_err + | ^^^^^^^^^^^^^^^^^^---------^ + | | + | attempt to multiply with overflow + +error: this constant cannot be used + --> $DIR/const-err-early.rs:16:1 + | +LL | pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err + | ^^^^^^^^^^^^^^^^^^-----------------^ + | | + | attempt to subtract with overflow + +error: this constant cannot be used + --> $DIR/const-err-early.rs:17:1 + | +LL | pub const E: u8 = [5u8][1]; //~ ERROR const_err + | ^^^^^^^^^^^^^^^^^^--------^ + | | + | index out of bounds: the len is 1 but the index is 1 + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/const-err-multi.rs b/src/test/ui/compile-fail-migration/const-err-multi.rs new file mode 100644 index 00000000000..f2ee8a7078c --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err-multi.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(const_err)] + +pub const A: i8 = -std::i8::MIN; +//~^ ERROR this constant cannot be used +pub const B: i8 = A; +//~^ ERROR const_err +//~| ERROR const_err +pub const C: u8 = A as u8; +//~^ ERROR const_err +//~| ERROR const_err +pub const D: i8 = 50 - A; +//~^ ERROR const_err +//~| ERROR const_err + +fn main() { + let _ = (A, B, C, D); +} diff --git a/src/test/ui/compile-fail-migration/const-err-multi.stderr b/src/test/ui/compile-fail-migration/const-err-multi.stderr new file mode 100644 index 00000000000..dd3eaa4c47b --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err-multi.stderr @@ -0,0 +1,67 @@ +error: this constant cannot be used + --> $DIR/const-err-multi.rs:13:1 + | +LL | pub const A: i8 = -std::i8::MIN; + | ^^^^^^^^^^^^^^^^^^-------------^ + | | + | attempt to negate with overflow + | +note: lint level defined here + --> $DIR/const-err-multi.rs:11:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: referenced constant has errors + --> $DIR/const-err-multi.rs:15:1 + | +LL | pub const A: i8 = -std::i8::MIN; + | ------------- attempt to negate with overflow +LL | //~^ ERROR this constant cannot be used +LL | pub const B: i8 = A; + | ^^^^^^^^^^^^^^^^^^^^ + +error: this constant cannot be used + --> $DIR/const-err-multi.rs:15:1 + | +LL | pub const B: i8 = A; + | ^^^^^^^^^^^^^^^^^^-^ + | | + | referenced constant has errors + +error: referenced constant has errors + --> $DIR/const-err-multi.rs:18:1 + | +LL | pub const A: i8 = -std::i8::MIN; + | ------------- attempt to negate with overflow +... +LL | pub const C: u8 = A as u8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this constant cannot be used + --> $DIR/const-err-multi.rs:18:1 + | +LL | pub const C: u8 = A as u8; + | ^^^^^^^^^^^^^^^^^^-------^ + | | + | referenced constant has errors + +error: referenced constant has errors + --> $DIR/const-err-multi.rs:21:1 + | +LL | pub const A: i8 = -std::i8::MIN; + | ------------- attempt to negate with overflow +... +LL | pub const D: i8 = 50 - A; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: this constant cannot be used + --> $DIR/const-err-multi.rs:21:1 + | +LL | pub const D: i8 = 50 - A; + | ^^^^^^^^^^^^^^^^^^------^ + | | + | referenced constant has errors + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/compile-fail-migration/const-err.rs b/src/test/ui/compile-fail-migration/const-err.rs new file mode 100644 index 00000000000..8683f6a0231 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err.rs @@ -0,0 +1,32 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Zforce-overflow-checks=on + +// these errors are not actually "const_err", they occur in codegen/consts +// and are unconditional warnings that can't be denied or allowed + +#![allow(exceeding_bitshifts)] +#![allow(const_err)] + +fn black_box(_: T) { + unimplemented!() +} + +// Make sure that the two uses get two errors. +const FOO: u8 = [5u8][1]; +//~^ ERROR constant evaluation error +//~| index out of bounds: the len is 1 but the index is 1 + +fn main() { + black_box((FOO, FOO)); + //~^ ERROR referenced constant has errors + //~| ERROR could not evaluate constant +} diff --git a/src/test/ui/compile-fail-migration/const-err.stderr b/src/test/ui/compile-fail-migration/const-err.stderr new file mode 100644 index 00000000000..1674f99b682 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err.stderr @@ -0,0 +1,26 @@ +error[E0080]: referenced constant has errors + --> $DIR/const-err.rs:29:15 + | +LL | const FOO: u8 = [5u8][1]; + | -------- index out of bounds: the len is 1 but the index is 1 +... +LL | black_box((FOO, FOO)); + | ^^^^^^^^^^ + +error[E0080]: could not evaluate constant + --> $DIR/const-err.rs:29:15 + | +LL | black_box((FOO, FOO)); + | ^^^^^^^^^^ referenced constant has errors + +error[E0080]: constant evaluation error + --> $DIR/const-err.rs:24:1 + | +LL | const FOO: u8 = [5u8][1]; + | ^^^^^^^^^^^^^^^^--------^ + | | + | index out of bounds: the len is 1 but the index is 1 + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/const-err2.rs b/src/test/ui/compile-fail-migration/const-err2.rs new file mode 100644 index 00000000000..9a5cb5a4a83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err2.rs @@ -0,0 +1,39 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// needed because negating int::MIN will behave differently between +// optimized compilation and unoptimized compilation and thus would +// lead to different lints being emitted +// compile-flags: -O + +#![feature(rustc_attrs)] +#![allow(exceeding_bitshifts)] +#![deny(const_err)] + +fn black_box(_: T) { + unimplemented!() +} + +fn main() { + let a = -std::i8::MIN; + //~^ ERROR const_err + let b = 200u8 + 200u8 + 200u8; + //~^ ERROR const_err + let c = 200u8 * 4; + //~^ ERROR const_err + let d = 42u8 - (42u8 + 1); + //~^ ERROR const_err + let _e = [5u8][1]; + //~^ ERROR const_err + black_box(a); + black_box(b); + black_box(c); + black_box(d); +} diff --git a/src/test/ui/compile-fail-migration/const-err2.stderr b/src/test/ui/compile-fail-migration/const-err2.stderr new file mode 100644 index 00000000000..7201ecbc55d --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err2.stderr @@ -0,0 +1,38 @@ +error: this expression will panic at runtime + --> $DIR/const-err2.rs:25:13 + | +LL | let a = -std::i8::MIN; + | ^^^^^^^^^^^^^ attempt to negate with overflow + | +note: lint level defined here + --> $DIR/const-err2.rs:18:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/const-err2.rs:27:13 + | +LL | let b = 200u8 + 200u8 + 200u8; + | ^^^^^^^^^^^^^ attempt to add with overflow + +error: this expression will panic at runtime + --> $DIR/const-err2.rs:29:13 + | +LL | let c = 200u8 * 4; + | ^^^^^^^^^ attempt to multiply with overflow + +error: this expression will panic at runtime + --> $DIR/const-err2.rs:31:13 + | +LL | let d = 42u8 - (42u8 + 1); + | ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow + +error: index out of bounds: the len is 1 but the index is 1 + --> $DIR/const-err2.rs:33:14 + | +LL | let _e = [5u8][1]; + | ^^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/const-err3.rs b/src/test/ui/compile-fail-migration/const-err3.rs new file mode 100644 index 00000000000..f5e43b57e77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err3.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![deny(const_err)] + +fn black_box(_: T) { + unimplemented!() +} + +fn main() { + let b = 200u8 + 200u8 + 200u8; + //~^ ERROR const_err + let c = 200u8 * 4; + //~^ ERROR const_err + let d = 42u8 - (42u8 + 1); + //~^ ERROR const_err + let _e = [5u8][1]; + //~^ ERROR const_err + black_box(b); + black_box(c); + black_box(d); +} diff --git a/src/test/ui/compile-fail-migration/const-err3.stderr b/src/test/ui/compile-fail-migration/const-err3.stderr new file mode 100644 index 00000000000..5be46248fa7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err3.stderr @@ -0,0 +1,32 @@ +error: this expression will panic at runtime + --> $DIR/const-err3.rs:19:13 + | +LL | let b = 200u8 + 200u8 + 200u8; + | ^^^^^^^^^^^^^ attempt to add with overflow + | +note: lint level defined here + --> $DIR/const-err3.rs:12:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: this expression will panic at runtime + --> $DIR/const-err3.rs:21:13 + | +LL | let c = 200u8 * 4; + | ^^^^^^^^^ attempt to multiply with overflow + +error: this expression will panic at runtime + --> $DIR/const-err3.rs:23:13 + | +LL | let d = 42u8 - (42u8 + 1); + | ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow + +error: index out of bounds: the len is 1 but the index is 1 + --> $DIR/const-err3.rs:25:14 + | +LL | let _e = [5u8][1]; + | ^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/const-err4.rs b/src/test/ui/compile-fail-migration/const-err4.rs new file mode 100644 index 00000000000..10376d57809 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err4.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Copy, Clone)] +union Foo { + a: isize, + b: (), +} + +enum Bar { + Boo = [unsafe { Foo { b: () }.a }; 4][3], + //~^ ERROR could not evaluate enum discriminant +} + +fn main() { + assert_ne!(Bar::Boo as isize, 0); +} diff --git a/src/test/ui/compile-fail-migration/const-err4.stderr b/src/test/ui/compile-fail-migration/const-err4.stderr new file mode 100644 index 00000000000..dc64737b22f --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-err4.stderr @@ -0,0 +1,9 @@ +error[E0080]: could not evaluate enum discriminant + --> $DIR/const-err4.rs:18:11 + | +LL | Boo = [unsafe { Foo { b: () }.a }; 4][3], + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow-3.rs b/src/test/ui/compile-fail-migration/const-eval-overflow-3.rs new file mode 100644 index 00000000000..d930cb77047 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow-3.rs @@ -0,0 +1,38 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Evaluation of constants in array-elem count goes through different +// compiler control-flow paths. +// +// This test is checking the count in an array expression. + +// FIXME (#23926): the error output is not consistent between a +// self-hosted and a cross-compiled setup; therefore resorting to +// error-pattern for now. + +// error-pattern: attempt to add with overflow + +#![allow(unused_imports)] + +use std::fmt; +use std::{i8, i16, i32, i64, isize}; +use std::{u8, u16, u32, u64, usize}; + +const A_I8_I + : [u32; (i8::MAX as usize) + 1] + = [0; (i8::MAX + 1) as usize]; + +fn main() { + foo(&A_I8_I[..]); +} + +fn foo(x: T) { + println!("{:?}", x); +} diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow-3.stderr b/src/test/ui/compile-fail-migration/const-eval-overflow-3.stderr new file mode 100644 index 00000000000..f2b4e6b3b56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow-3.stderr @@ -0,0 +1,19 @@ +error: attempt to add with overflow + --> $DIR/const-eval-overflow-3.rs:30:11 + | +LL | = [0; (i8::MAX + 1) as usize]; + | ^^^^^^^^^^^^^ + | + = note: #[deny(const_err)] on by default + +error[E0080]: could not evaluate repeat length + --> $DIR/const-eval-overflow-3.rs:30:11 + | +LL | = [0; (i8::MAX + 1) as usize]; + | -------------^^^^^^^^^ + | | + | attempt to add with overflow + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow-3b.rs b/src/test/ui/compile-fail-migration/const-eval-overflow-3b.rs new file mode 100644 index 00000000000..719b21000f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow-3b.rs @@ -0,0 +1,43 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Evaluation of constants in array-elem count goes through different +// compiler control-flow paths. +// +// This test is checking the count in an array expression. +// +// This is a variation of another such test, but in this case the +// types for the left- and right-hand sides of the addition do not +// match (as well as overflow). + +// FIXME (#23926): the error output is not consistent between a +// self-hosted and a cross-compiled setup; therefore resorting to +// error-pattern for now. + +// error-pattern: mismatched types + +#![allow(unused_imports)] + +use std::fmt; +use std::{i8, i16, i32, i64, isize}; +use std::{u8, u16, u32, u64, usize}; + +const A_I8_I + : [u32; (i8::MAX as usize) + 1] + = [0; (i8::MAX + 1u8) as usize]; + +fn main() { + foo(&A_I8_I[..]); +} + +fn foo(x: T) { + println!("{:?}", x); +} + diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow-3b.stderr b/src/test/ui/compile-fail-migration/const-eval-overflow-3b.stderr new file mode 100644 index 00000000000..4f1163bf9a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow-3b.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/const-eval-overflow-3b.rs:34:22 + | +LL | = [0; (i8::MAX + 1u8) as usize]; + | ^^^ expected i8, found u8 + +error[E0277]: cannot add `u8` to `i8` + --> $DIR/const-eval-overflow-3b.rs:34:20 + | +LL | = [0; (i8::MAX + 1u8) as usize]; + | ^ no implementation for `i8 + u8` + | + = help: the trait `std::ops::Add` is not implemented for `i8` + +error: aborting due to 2 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow-4b.rs b/src/test/ui/compile-fail-migration/const-eval-overflow-4b.rs new file mode 100644 index 00000000000..6028df18839 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow-4b.rs @@ -0,0 +1,39 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Evaluation of constants in array-elem count goes through different +// compiler control-flow paths. +// +// This test is checking the count in an array type. + +#![allow(unused_imports)] + +use std::{i8, i16, i32, i64, isize}; +use std::{u8, u16, u32, u64, usize}; + +const A_I8_T + : [u32; (i8::MAX as i8 + 1u8) as usize] + //~^ ERROR mismatched types + //~| expected i8, found u8 + //~| ERROR cannot add `u8` to `i8` + = [0; (i8::MAX as usize) + 1]; + + +const A_CHAR_USIZE + : [u32; 5u8 as char as usize] + = [0; 5]; + + +const A_BAD_CHAR_USIZE + : [u32; 5i8 as char as usize] + //~^ ERROR only `u8` can be cast as `char`, not `i8` + = [0; 5]; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow-4b.stderr b/src/test/ui/compile-fail-migration/const-eval-overflow-4b.stderr new file mode 100644 index 00000000000..d171e7f09d1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow-4b.stderr @@ -0,0 +1,24 @@ +error[E0308]: mismatched types + --> $DIR/const-eval-overflow-4b.rs:22:30 + | +LL | : [u32; (i8::MAX as i8 + 1u8) as usize] + | ^^^ expected i8, found u8 + +error[E0277]: cannot add `u8` to `i8` + --> $DIR/const-eval-overflow-4b.rs:22:28 + | +LL | : [u32; (i8::MAX as i8 + 1u8) as usize] + | ^ no implementation for `i8 + u8` + | + = help: the trait `std::ops::Add` is not implemented for `i8` + +error[E0604]: only `u8` can be cast as `char`, not `i8` + --> $DIR/const-eval-overflow-4b.rs:35:13 + | +LL | : [u32; 5i8 as char as usize] + | ^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0277, E0308, E0604. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow2.rs b/src/test/ui/compile-fail-migration/const-eval-overflow2.rs new file mode 100644 index 00000000000..88fc5182775 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow2.rs @@ -0,0 +1,83 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_imports)] + +// Note: the relevant lint pass here runs before some of the constant +// evaluation below (e.g. that performed by codegen and llvm), so if you +// change this warn to a deny, then the compiler will exit before +// those errors are detected. + +#![deny(const_err)] + +use std::fmt; +use std::{i8, i16, i32, i64, isize}; +use std::{u8, u16, u32, u64, usize}; + +const VALS_I8: (i8,) = + //~^ ERROR this constant cannot be used + ( + i8::MIN - 1, + ); + +const VALS_I16: (i16,) = + //~^ ERROR this constant cannot be used + ( + i16::MIN - 1, + ); + +const VALS_I32: (i32,) = + //~^ ERROR this constant cannot be used + ( + i32::MIN - 1, + ); + +const VALS_I64: (i64,) = + //~^ ERROR this constant cannot be used + ( + i64::MIN - 1, + ); + +const VALS_U8: (u8,) = + //~^ ERROR this constant cannot be used + ( + u8::MIN - 1, + ); + +const VALS_U16: (u16,) = ( + //~^ ERROR this constant cannot be used + u16::MIN - 1, + ); + +const VALS_U32: (u32,) = ( + //~^ ERROR this constant cannot be used + u32::MIN - 1, + ); + +const VALS_U64: (u64,) = + //~^ ERROR this constant cannot be used + ( + u64::MIN - 1, + ); + +fn main() { + foo(VALS_I8); + foo(VALS_I16); + foo(VALS_I32); + foo(VALS_I64); + + foo(VALS_U8); + foo(VALS_U16); + foo(VALS_U32); + foo(VALS_U64); +} + +fn foo(_: T) { +} diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow2.stderr b/src/test/ui/compile-fail-migration/const-eval-overflow2.stderr new file mode 100644 index 00000000000..5cf5ce367e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow2.stderr @@ -0,0 +1,94 @@ +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:24:1 + | +LL | / const VALS_I8: (i8,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i8::MIN - 1, + | | ----------- attempt to subtract with overflow +LL | | ); + | |_______^ + | +note: lint level defined here + --> $DIR/const-eval-overflow2.rs:18:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:30:1 + | +LL | / const VALS_I16: (i16,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i16::MIN - 1, + | | ------------ attempt to subtract with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:36:1 + | +LL | / const VALS_I32: (i32,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i32::MIN - 1, + | | ------------ attempt to subtract with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:42:1 + | +LL | / const VALS_I64: (i64,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i64::MIN - 1, + | | ------------ attempt to subtract with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:48:1 + | +LL | / const VALS_U8: (u8,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | u8::MIN - 1, + | | ----------- attempt to subtract with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:54:1 + | +LL | / const VALS_U16: (u16,) = ( +LL | | //~^ ERROR this constant cannot be used +LL | | u16::MIN - 1, + | | ------------ attempt to subtract with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:59:1 + | +LL | / const VALS_U32: (u32,) = ( +LL | | //~^ ERROR this constant cannot be used +LL | | u32::MIN - 1, + | | ------------ attempt to subtract with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2.rs:64:1 + | +LL | / const VALS_U64: (u64,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | u64::MIN - 1, + | | ------------ attempt to subtract with overflow +LL | | ); + | |_______^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow2b.rs b/src/test/ui/compile-fail-migration/const-eval-overflow2b.rs new file mode 100644 index 00000000000..1878daea931 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow2b.rs @@ -0,0 +1,83 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_imports)] + +// Note: the relevant lint pass here runs before some of the constant +// evaluation below (e.g. that performed by codegen and llvm), so if you +// change this warn to a deny, then the compiler will exit before +// those errors are detected. + +#![deny(const_err)] + +use std::fmt; +use std::{i8, i16, i32, i64, isize}; +use std::{u8, u16, u32, u64, usize}; + +const VALS_I8: (i8,) = + //~^ ERROR this constant cannot be used + ( + i8::MAX + 1, + ); + +const VALS_I16: (i16,) = + //~^ ERROR this constant cannot be used + ( + i16::MAX + 1, + ); + +const VALS_I32: (i32,) = + //~^ ERROR this constant cannot be used + ( + i32::MAX + 1, + ); + +const VALS_I64: (i64,) = + //~^ ERROR this constant cannot be used + ( + i64::MAX + 1, + ); + +const VALS_U8: (u8,) = + //~^ ERROR this constant cannot be used + ( + u8::MAX + 1, + ); + +const VALS_U16: (u16,) = ( + //~^ ERROR this constant cannot be used + u16::MAX + 1, + ); + +const VALS_U32: (u32,) = ( + //~^ ERROR this constant cannot be used + u32::MAX + 1, + ); + +const VALS_U64: (u64,) = + //~^ ERROR this constant cannot be used + ( + u64::MAX + 1, + ); + +fn main() { + foo(VALS_I8); + foo(VALS_I16); + foo(VALS_I32); + foo(VALS_I64); + + foo(VALS_U8); + foo(VALS_U16); + foo(VALS_U32); + foo(VALS_U64); +} + +fn foo(_: T) { +} diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow2b.stderr b/src/test/ui/compile-fail-migration/const-eval-overflow2b.stderr new file mode 100644 index 00000000000..458a9e11e75 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow2b.stderr @@ -0,0 +1,94 @@ +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:24:1 + | +LL | / const VALS_I8: (i8,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i8::MAX + 1, + | | ----------- attempt to add with overflow +LL | | ); + | |_______^ + | +note: lint level defined here + --> $DIR/const-eval-overflow2b.rs:18:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:30:1 + | +LL | / const VALS_I16: (i16,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i16::MAX + 1, + | | ------------ attempt to add with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:36:1 + | +LL | / const VALS_I32: (i32,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i32::MAX + 1, + | | ------------ attempt to add with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:42:1 + | +LL | / const VALS_I64: (i64,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i64::MAX + 1, + | | ------------ attempt to add with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:48:1 + | +LL | / const VALS_U8: (u8,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | u8::MAX + 1, + | | ----------- attempt to add with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:54:1 + | +LL | / const VALS_U16: (u16,) = ( +LL | | //~^ ERROR this constant cannot be used +LL | | u16::MAX + 1, + | | ------------ attempt to add with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:59:1 + | +LL | / const VALS_U32: (u32,) = ( +LL | | //~^ ERROR this constant cannot be used +LL | | u32::MAX + 1, + | | ------------ attempt to add with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2b.rs:64:1 + | +LL | / const VALS_U64: (u64,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | u64::MAX + 1, + | | ------------ attempt to add with overflow +LL | | ); + | |_______^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow2c.rs b/src/test/ui/compile-fail-migration/const-eval-overflow2c.rs new file mode 100644 index 00000000000..f3d28295bf8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow2c.rs @@ -0,0 +1,83 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_imports)] + +// Note: the relevant lint pass here runs before some of the constant +// evaluation below (e.g. that performed by codegen and llvm), so if you +// change this warn to a deny, then the compiler will exit before +// those errors are detected. + +#![deny(const_err)] + +use std::fmt; +use std::{i8, i16, i32, i64, isize}; +use std::{u8, u16, u32, u64, usize}; + +const VALS_I8: (i8,) = + //~^ ERROR this constant cannot be used + ( + i8::MIN * 2, + ); + +const VALS_I16: (i16,) = + //~^ ERROR this constant cannot be used + ( + i16::MIN * 2, + ); + +const VALS_I32: (i32,) = + //~^ ERROR this constant cannot be used + ( + i32::MIN * 2, + ); + +const VALS_I64: (i64,) = + //~^ ERROR this constant cannot be used + ( + i64::MIN * 2, + ); + +const VALS_U8: (u8,) = + //~^ ERROR this constant cannot be used + ( + u8::MAX * 2, + ); + +const VALS_U16: (u16,) = ( + //~^ ERROR this constant cannot be used + u16::MAX * 2, + ); + +const VALS_U32: (u32,) = ( + //~^ ERROR this constant cannot be used + u32::MAX * 2, + ); + +const VALS_U64: (u64,) = + //~^ ERROR this constant cannot be used + ( + u64::MAX * 2, + ); + +fn main() { + foo(VALS_I8); + foo(VALS_I16); + foo(VALS_I32); + foo(VALS_I64); + + foo(VALS_U8); + foo(VALS_U16); + foo(VALS_U32); + foo(VALS_U64); +} + +fn foo(_: T) { +} diff --git a/src/test/ui/compile-fail-migration/const-eval-overflow2c.stderr b/src/test/ui/compile-fail-migration/const-eval-overflow2c.stderr new file mode 100644 index 00000000000..866860281cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-eval-overflow2c.stderr @@ -0,0 +1,94 @@ +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:24:1 + | +LL | / const VALS_I8: (i8,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i8::MIN * 2, + | | ----------- attempt to multiply with overflow +LL | | ); + | |_______^ + | +note: lint level defined here + --> $DIR/const-eval-overflow2c.rs:18:9 + | +LL | #![deny(const_err)] + | ^^^^^^^^^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:30:1 + | +LL | / const VALS_I16: (i16,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i16::MIN * 2, + | | ------------ attempt to multiply with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:36:1 + | +LL | / const VALS_I32: (i32,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i32::MIN * 2, + | | ------------ attempt to multiply with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:42:1 + | +LL | / const VALS_I64: (i64,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | i64::MIN * 2, + | | ------------ attempt to multiply with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:48:1 + | +LL | / const VALS_U8: (u8,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | u8::MAX * 2, + | | ----------- attempt to multiply with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:54:1 + | +LL | / const VALS_U16: (u16,) = ( +LL | | //~^ ERROR this constant cannot be used +LL | | u16::MAX * 2, + | | ------------ attempt to multiply with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:59:1 + | +LL | / const VALS_U32: (u32,) = ( +LL | | //~^ ERROR this constant cannot be used +LL | | u32::MAX * 2, + | | ------------ attempt to multiply with overflow +LL | | ); + | |_______^ + +error: this constant cannot be used + --> $DIR/const-eval-overflow2c.rs:64:1 + | +LL | / const VALS_U64: (u64,) = +LL | | //~^ ERROR this constant cannot be used +LL | | ( +LL | | u64::MAX * 2, + | | ------------ attempt to multiply with overflow +LL | | ); + | |_______^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/compile-fail-migration/const-fn-destructuring-arg.rs b/src/test/ui/compile-fail-migration/const-fn-destructuring-arg.rs new file mode 100644 index 00000000000..fce1688716d --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-fn-destructuring-arg.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// test that certain things are disallowed in constant functions + +#![feature(const_fn)] + +// no destructuring +const fn i(( + a, + //~^ ERROR arguments of constant functions can only be immutable by-value bindings + b + //~^ ERROR arguments of constant functions can only be immutable by-value bindings + ): (u32, u32)) -> u32 { + a + b + //~^ ERROR let bindings in constant functions are unstable + //~| ERROR let bindings in constant functions are unstable +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-fn-destructuring-arg.stderr b/src/test/ui/compile-fail-migration/const-fn-destructuring-arg.stderr new file mode 100644 index 00000000000..029d63a7720 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-fn-destructuring-arg.stderr @@ -0,0 +1,35 @@ +error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821) + --> $DIR/const-fn-destructuring-arg.rs:17:13 + | +LL | a, + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821) + --> $DIR/const-fn-destructuring-arg.rs:19:13 + | +LL | b + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-destructuring-arg.rs:22:5 + | +LL | a + b + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-destructuring-arg.rs:22:9 + | +LL | a + b + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.rs b/src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.rs new file mode 100644 index 00000000000..341cc7bb491 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.rs @@ -0,0 +1,51 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can't call random fns in a const fn or do other bad things. + +#![feature(const_fn)] + +use std::mem::transmute; + +fn random() -> u32 { 0 } + +const fn sub(x: &u32) -> usize { + unsafe { transmute(x) } //~ ERROR E0015 +} + +const fn sub1() -> u32 { + random() //~ ERROR E0015 +} + +static Y: u32 = 0; + +const fn get_Y() -> u32 { + Y + //~^ ERROR E0013 +} + +const fn get_Y_addr() -> &'static u32 { + &Y + //~^ ERROR E0013 +} + +const fn get() -> u32 { + let x = 22; + //~^ ERROR let bindings in constant functions are unstable + //~| ERROR statements in constant functions are unstable + let y = 44; + //~^ ERROR let bindings in constant functions are unstable + //~| ERROR statements in constant functions are unstable + x + y + //~^ ERROR let bindings in constant functions are unstable + //~| ERROR let bindings in constant functions are unstable +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.stderr b/src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.stderr new file mode 100644 index 00000000000..1e99a4378fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-fn-not-safe-for-const.stderr @@ -0,0 +1,76 @@ +error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants + --> $DIR/const-fn-not-safe-for-const.rs:20:14 + | +LL | unsafe { transmute(x) } //~ ERROR E0015 + | ^^^^^^^^^^^^ + +error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants + --> $DIR/const-fn-not-safe-for-const.rs:24:5 + | +LL | random() //~ ERROR E0015 + | ^^^^^^^^ + +error[E0013]: constant functions cannot refer to statics, use a constant instead + --> $DIR/const-fn-not-safe-for-const.rs:30:5 + | +LL | Y + | ^ + +error[E0013]: constant functions cannot refer to statics, use a constant instead + --> $DIR/const-fn-not-safe-for-const.rs:35:5 + | +LL | &Y + | ^^ + +error[E0658]: let bindings in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-not-safe-for-const.rs:40:13 + | +LL | let x = 22; + | ^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-not-safe-for-const.rs:40:13 + | +LL | let x = 22; + | ^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-not-safe-for-const.rs:43:13 + | +LL | let y = 44; + | ^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-not-safe-for-const.rs:43:13 + | +LL | let y = 44; + | ^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-not-safe-for-const.rs:46:5 + | +LL | x + y + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: let bindings in constant functions are unstable (see issue #48821) + --> $DIR/const-fn-not-safe-for-const.rs:46:9 + | +LL | x + y + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error: aborting due to 10 previous errors + +Some errors occurred: E0013, E0015, E0658. +For more information about an error, try `rustc --explain E0013`. diff --git a/src/test/ui/compile-fail-migration/const-fn-stability-calls-3.rs b/src/test/ui/compile-fail-migration/const-fn-stability-calls-3.rs new file mode 100644 index 00000000000..0f413b0bbc1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-fn-stability-calls-3.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test use of const fn from another crate without a feature gate. + +#![feature(rustc_attrs)] +#![allow(unused_variables)] + +// aux-build:const_fn_lib.rs + +extern crate const_fn_lib; + +use const_fn_lib::foo; + +#[rustc_error] +fn main() { //~ ERROR compilation successful + let x = foo(); // use outside a constant is ok +} diff --git a/src/test/ui/compile-fail-migration/const-fn-stability-calls-3.stderr b/src/test/ui/compile-fail-migration/const-fn-stability-calls-3.stderr new file mode 100644 index 00000000000..50c959d6805 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-fn-stability-calls-3.stderr @@ -0,0 +1,10 @@ +error: compilation successful + --> $DIR/const-fn-stability-calls-3.rs:23:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | let x = foo(); // use outside a constant is ok +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/const-integer-bool-ops.rs b/src/test/ui/compile-fail-migration/const-integer-bool-ops.rs new file mode 100644 index 00000000000..29bc665a22e --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-integer-bool-ops.rs @@ -0,0 +1,85 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const X: usize = 42 && 39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR: [i32; X] = [99; 34]; + +const X1: usize = 42 || 39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR1: [i32; X1] = [99; 47]; + +const X2: usize = -42 || -39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR2: [i32; X2] = [99; 18446744073709551607]; + +const X3: usize = -42 && -39; +//~^ ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected usize, found bool +const ARR3: [i32; X3] = [99; 6]; + +const Y: usize = 42.0 == 42.0; +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR: [i32; Y] = [99; 1]; + +const Y1: usize = 42.0 >= 42.0; +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR1: [i32; Y1] = [99; 1]; + +const Y2: usize = 42.0 <= 42.0; +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR2: [i32; Y2] = [99; 1]; + +const Y3: usize = 42.0 > 42.0; +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR3: [i32; Y3] = [99; 0]; + +const Y4: usize = 42.0 < 42.0; +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR4: [i32; Y4] = [99; 0]; + +const Y5: usize = 42.0 != 42.0; +//~^ ERROR mismatched types +//~| expected usize, found bool +const ARRR5: [i32; Y5] = [99; 0]; + +fn main() { + let _ = ARR; + let _ = ARRR; + let _ = ARRR1; + let _ = ARRR2; + let _ = ARRR3; + let _ = ARRR4; + let _ = ARRR5; +} diff --git a/src/test/ui/compile-fail-migration/const-integer-bool-ops.stderr b/src/test/ui/compile-fail-migration/const-integer-bool-ops.stderr new file mode 100644 index 00000000000..8075a3f0863 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-integer-bool-ops.stderr @@ -0,0 +1,135 @@ +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:11:18 + | +LL | const X: usize = 42 && 39; + | ^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:11:24 + | +LL | const X: usize = 42 && 39; + | ^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:11:18 + | +LL | const X: usize = 42 && 39; + | ^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:20:19 + | +LL | const X1: usize = 42 || 39; + | ^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:20:25 + | +LL | const X1: usize = 42 || 39; + | ^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:20:19 + | +LL | const X1: usize = 42 || 39; + | ^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:29:19 + | +LL | const X2: usize = -42 || -39; + | ^^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:29:26 + | +LL | const X2: usize = -42 || -39; + | ^^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:29:19 + | +LL | const X2: usize = -42 || -39; + | ^^^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:38:19 + | +LL | const X3: usize = -42 && -39; + | ^^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:38:26 + | +LL | const X3: usize = -42 && -39; + | ^^^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:38:19 + | +LL | const X3: usize = -42 && -39; + | ^^^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:47:18 + | +LL | const Y: usize = 42.0 == 42.0; + | ^^^^^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:52:19 + | +LL | const Y1: usize = 42.0 >= 42.0; + | ^^^^^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:57:19 + | +LL | const Y2: usize = 42.0 <= 42.0; + | ^^^^^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:62:19 + | +LL | const Y3: usize = 42.0 > 42.0; + | ^^^^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:67:19 + | +LL | const Y4: usize = 42.0 < 42.0; + | ^^^^^^^^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/const-integer-bool-ops.rs:72:19 + | +LL | const Y5: usize = 42.0 != 42.0; + | ^^^^^^^^^^^^ expected usize, found bool + +error: aborting due to 18 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/const-len-underflow-subspans.rs b/src/test/ui/compile-fail-migration/const-len-underflow-subspans.rs new file mode 100644 index 00000000000..054c272a3d3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-len-underflow-subspans.rs @@ -0,0 +1,21 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that a constant-evaluation underflow highlights the correct +// spot (where the underflow occurred). + +const ONE: usize = 1; +const TWO: usize = 2; + +fn main() { + let a: [i8; ONE - TWO] = unimplemented!(); + //~^ ERROR could not evaluate constant expression + //~| attempt to subtract with overflow +} diff --git a/src/test/ui/compile-fail-migration/const-len-underflow-subspans.stderr b/src/test/ui/compile-fail-migration/const-len-underflow-subspans.stderr new file mode 100644 index 00000000000..860716c1f38 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-len-underflow-subspans.stderr @@ -0,0 +1,19 @@ +error: attempt to subtract with overflow + --> $DIR/const-len-underflow-subspans.rs:18:17 + | +LL | let a: [i8; ONE - TWO] = unimplemented!(); + | ^^^^^^^^^ + | + = note: #[deny(const_err)] on by default + +error[E0080]: could not evaluate constant expression + --> $DIR/const-len-underflow-subspans.rs:18:12 + | +LL | let a: [i8; ONE - TWO] = unimplemented!(); + | ^^^^^---------^ + | | + | attempt to subtract with overflow + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/const-match-check.eval1.stderr b/src/test/ui/compile-fail-migration/const-match-check.eval1.stderr new file mode 100644 index 00000000000..3caf1491aba --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-match-check.eval1.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in local binding: `_` not covered + --> $DIR/const-match-check.rs:35:15 + | +LL | A = { let 0 = 0; 0 }, + | ^ pattern `_` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/const-match-check.eval2.stderr b/src/test/ui/compile-fail-migration/const-match-check.eval2.stderr new file mode 100644 index 00000000000..de85d4d73db --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-match-check.eval2.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in local binding: `_` not covered + --> $DIR/const-match-check.rs:41:24 + | +LL | let x: [i32; { let 0 = 0; 0 }] = []; + | ^ pattern `_` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/const-match-check.matchck.stderr b/src/test/ui/compile-fail-migration/const-match-check.matchck.stderr new file mode 100644 index 00000000000..bbf1169c577 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-match-check.matchck.stderr @@ -0,0 +1,27 @@ +error[E0005]: refutable pattern in local binding: `_` not covered + --> $DIR/const-match-check.rs:14:22 + | +LL | const X: i32 = { let 0 = 0; 0 }; + | ^ pattern `_` not covered + +error[E0005]: refutable pattern in local binding: `_` not covered + --> $DIR/const-match-check.rs:18:23 + | +LL | static Y: i32 = { let 0 = 0; 0 }; + | ^ pattern `_` not covered + +error[E0005]: refutable pattern in local binding: `_` not covered + --> $DIR/const-match-check.rs:23:26 + | +LL | const X: i32 = { let 0 = 0; 0 }; + | ^ pattern `_` not covered + +error[E0005]: refutable pattern in local binding: `_` not covered + --> $DIR/const-match-check.rs:29:26 + | +LL | const X: i32 = { let 0 = 0; 0 }; + | ^ pattern `_` not covered + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/const-match-check.rs b/src/test/ui/compile-fail-migration/const-match-check.rs new file mode 100644 index 00000000000..304eef7847c --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-match-check.rs @@ -0,0 +1,43 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: matchck eval1 eval2 + +#[cfg(matchck)] +const X: i32 = { let 0 = 0; 0 }; +//[matchck]~^ ERROR refutable pattern in local binding + +#[cfg(matchck)] +static Y: i32 = { let 0 = 0; 0 }; +//[matchck]~^ ERROR refutable pattern in local binding + +#[cfg(matchck)] +trait Bar { + const X: i32 = { let 0 = 0; 0 }; + //[matchck]~^ ERROR refutable pattern in local binding +} + +#[cfg(matchck)] +impl Bar for () { + const X: i32 = { let 0 = 0; 0 }; + //[matchck]~^ ERROR refutable pattern in local binding +} + +#[cfg(eval1)] +enum Foo { + A = { let 0 = 0; 0 }, + //[eval1]~^ ERROR refutable pattern in local binding +} + +fn main() { + #[cfg(eval2)] + let x: [i32; { let 0 = 0; 0 }] = []; + //[eval2]~^ ERROR refutable pattern in local binding +} diff --git a/src/test/ui/compile-fail-migration/const-match-pattern-arm.rs b/src/test/ui/compile-fail-migration/const-match-pattern-arm.rs new file mode 100644 index 00000000000..bc944948f3d --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-match-pattern-arm.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(warnings)] + +const x: bool = match Some(true) { + Some(value) => true, + //~^ ERROR: constant contains unimplemented expression type [E0019] + _ => false +}; + +const y: bool = { + match Some(true) { + Some(value) => true, + //~^ ERROR: constant contains unimplemented expression type [E0019] + _ => false + } +}; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-match-pattern-arm.stderr b/src/test/ui/compile-fail-migration/const-match-pattern-arm.stderr new file mode 100644 index 00000000000..201aa7cd5b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-match-pattern-arm.stderr @@ -0,0 +1,15 @@ +error[E0019]: constant contains unimplemented expression type + --> $DIR/const-match-pattern-arm.rs:14:5 + | +LL | Some(value) => true, + | ^^^^^^^^^^^ + +error[E0019]: constant contains unimplemented expression type + --> $DIR/const-match-pattern-arm.rs:21:9 + | +LL | Some(value) => true, + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0019`. diff --git a/src/test/ui/compile-fail-migration/const-size_of-cycle.rs b/src/test/ui/compile-fail-migration/const-size_of-cycle.rs new file mode 100644 index 00000000000..fed8e1885de --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-size_of-cycle.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: cycle detected + +#![feature(const_fn)] + +struct Foo { + bytes: [u8; std::mem::size_of::()] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/const-size_of-cycle.stderr b/src/test/ui/compile-fail-migration/const-size_of-cycle.stderr new file mode 100644 index 00000000000..b10dd509e0b --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-size_of-cycle.stderr @@ -0,0 +1,18 @@ +error[E0391]: cycle detected when computing layout of `Foo` + | +note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`... +note: ...which requires const-evaluating `Foo::bytes::{{constant}}`... + --> $SRC_DIR/libcore/mem.rs:323:14 + | +LL | unsafe { intrinsics::size_of::() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing layout of `Foo`, completing the cycle +note: cycle used when const-evaluating `Foo::bytes::{{constant}}` + --> $SRC_DIR/libcore/mem.rs:323:14 + | +LL | unsafe { intrinsics::size_of::() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/const-slice-oob.rs b/src/test/ui/compile-fail-migration/const-slice-oob.rs new file mode 100644 index 00000000000..6d51ff30998 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-slice-oob.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[deny(const_err)] + +const FOO: &'static[u32] = &[1, 2, 3]; +const BAR: u32 = FOO[5]; +//~^ index out of bounds: the len is 3 but the index is 5 +//~| ERROR this constant cannot be used + +fn main() { + let _ = BAR; +} diff --git a/src/test/ui/compile-fail-migration/const-slice-oob.stderr b/src/test/ui/compile-fail-migration/const-slice-oob.stderr new file mode 100644 index 00000000000..30260c36ffd --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-slice-oob.stderr @@ -0,0 +1,12 @@ +error: this constant cannot be used + --> $DIR/const-slice-oob.rs:14:1 + | +LL | const BAR: u32 = FOO[5]; + | ^^^^^^^^^^^^^^^^^------^ + | | + | index out of bounds: the len is 3 but the index is 5 + | + = note: #[deny(const_err)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/const-tup-index-span.rs b/src/test/ui/compile-fail-migration/const-tup-index-span.rs new file mode 100644 index 00000000000..b42c440f87d --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-tup-index-span.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test spans of errors + +const TUP: (usize,) = 5usize << 64; +//~^ ERROR mismatched types +//~| expected tuple, found usize +const ARR: [i32; TUP.0] = []; + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/const-tup-index-span.stderr b/src/test/ui/compile-fail-migration/const-tup-index-span.stderr new file mode 100644 index 00000000000..e9248629656 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-tup-index-span.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/const-tup-index-span.rs:13:23 + | +LL | const TUP: (usize,) = 5usize << 64; + | ^^^^^^^^^^^^ expected tuple, found usize + | + = note: expected type `(usize,)` + found type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/const-typeid-of.rs b/src/test/ui/compile-fail-migration/const-typeid-of.rs new file mode 100644 index 00000000000..401125cef09 --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-typeid-of.rs @@ -0,0 +1,18 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::any::TypeId; + +struct A; + +fn main() { + const A_ID: TypeId = TypeId::of::(); + //~^ ERROR `std::any::TypeId::of` is not yet stable as a const fn +} diff --git a/src/test/ui/compile-fail-migration/const-typeid-of.stderr b/src/test/ui/compile-fail-migration/const-typeid-of.stderr new file mode 100644 index 00000000000..d13ced9a10a --- /dev/null +++ b/src/test/ui/compile-fail-migration/const-typeid-of.stderr @@ -0,0 +1,10 @@ +error: `std::any::TypeId::of` is not yet stable as a const fn + --> $DIR/const-typeid-of.rs:16:26 + | +LL | const A_ID: TypeId = TypeId::of::(); + | ^^^^^^^^^^^^^^^^^ + | + = help: in Nightly builds, add `#![feature(const_type_id)]` to the crate attributes to enable + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/constructor-lifetime-args.rs b/src/test/ui/compile-fail-migration/constructor-lifetime-args.rs new file mode 100644 index 00000000000..50db9707355 --- /dev/null +++ b/src/test/ui/compile-fail-migration/constructor-lifetime-args.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// All lifetime parameters in struct constructors are currently considered early bound, +// i.e. `S::` is interpreted kinda like an associated item `S::::ctor`. +// This behavior is a bit weird, because if equivalent constructor were written manually +// it would get late bound lifetime parameters. +// Variant constructors behave in the same way, lifetime parameters are considered +// belonging to the enum and being early bound. +// https://github.com/rust-lang/rust/issues/30904 + +struct S<'a, 'b>(&'a u8, &'b u8); +enum E<'a, 'b> { + V(&'a u8), + U(&'b u8), +} + +fn main() { + S(&0, &0); // OK + S::<'static>(&0, &0); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + S::<'static, 'static, 'static>(&0, &0); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters + E::V(&0); // OK + E::V::<'static>(&0); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + E::V::<'static, 'static, 'static>(&0); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters +} diff --git a/src/test/ui/compile-fail-migration/constructor-lifetime-args.stderr b/src/test/ui/compile-fail-migration/constructor-lifetime-args.stderr new file mode 100644 index 00000000000..1710594d255 --- /dev/null +++ b/src/test/ui/compile-fail-migration/constructor-lifetime-args.stderr @@ -0,0 +1,28 @@ +error[E0090]: too few lifetime parameters provided: expected 2 lifetime parameters, found 1 lifetime parameter + --> $DIR/constructor-lifetime-args.rs:27:5 + | +LL | S::<'static>(&0, &0); + | ^^^^^^^^^^^^ expected 2 lifetime parameters + +error[E0088]: too many lifetime parameters provided: expected at most 2 lifetime parameters, found 3 lifetime parameters + --> $DIR/constructor-lifetime-args.rs:29:27 + | +LL | S::<'static, 'static, 'static>(&0, &0); + | ^^^^^^^ expected 2 lifetime parameters + +error[E0090]: too few lifetime parameters provided: expected 2 lifetime parameters, found 1 lifetime parameter + --> $DIR/constructor-lifetime-args.rs:32:5 + | +LL | E::V::<'static>(&0); + | ^^^^^^^^^^^^^^^ expected 2 lifetime parameters + +error[E0088]: too many lifetime parameters provided: expected at most 2 lifetime parameters, found 3 lifetime parameters + --> $DIR/constructor-lifetime-args.rs:34:30 + | +LL | E::V::<'static, 'static, 'static>(&0); + | ^^^^^^^ expected 2 lifetime parameters + +error: aborting due to 4 previous errors + +Some errors occurred: E0088, E0090. +For more information about an error, try `rustc --explain E0088`. diff --git a/src/test/ui/compile-fail-migration/copy-a-resource.rs b/src/test/ui/compile-fail-migration/copy-a-resource.rs new file mode 100644 index 00000000000..70633c92e64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/copy-a-resource.rs @@ -0,0 +1,31 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +struct foo { + i: isize, +} + +impl Drop for foo { + fn drop(&mut self) {} +} + +fn foo(i:isize) -> foo { + foo { + i: i + } +} + +fn main() { + let x = foo(10); + let _y = x.clone(); + //~^ ERROR no method named `clone` found + println!("{:?}", x); +} diff --git a/src/test/ui/compile-fail-migration/copy-a-resource.stderr b/src/test/ui/compile-fail-migration/copy-a-resource.stderr new file mode 100644 index 00000000000..6d8d4884d73 --- /dev/null +++ b/src/test/ui/compile-fail-migration/copy-a-resource.stderr @@ -0,0 +1,16 @@ +error[E0599]: no method named `clone` found for type `foo` in the current scope + --> $DIR/copy-a-resource.rs:28:16 + | +LL | struct foo { + | ---------- method `clone` not found for this +... +LL | let _y = x.clone(); + | ^^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `std::clone::Clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/crate-name-mismatch.rs b/src/test/ui/compile-fail-migration/crate-name-mismatch.rs new file mode 100644 index 00000000000..589c0beb760 --- /dev/null +++ b/src/test/ui/compile-fail-migration/crate-name-mismatch.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --crate-name foo + +#![crate_name = "bar"] +//~^ ERROR: --crate-name and #[crate_name] are required to match, but `foo` != `bar` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/crate-name-mismatch.stderr b/src/test/ui/compile-fail-migration/crate-name-mismatch.stderr new file mode 100644 index 00000000000..26ef91ba8e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/crate-name-mismatch.stderr @@ -0,0 +1,8 @@ +error: --crate-name and #[crate_name] are required to match, but `foo` != `bar` + --> $DIR/crate-name-mismatch.rs:13:1 + | +LL | #![crate_name = "bar"] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/crateresolve1.nll.stderr b/src/test/ui/compile-fail-migration/crateresolve1.nll.stderr new file mode 100644 index 00000000000..536293e0a5d --- /dev/null +++ b/src/test/ui/compile-fail-migration/crateresolve1.nll.stderr @@ -0,0 +1,21 @@ +error[E0464]: multiple matching crates for `crateresolve1` + --> $DIR/crateresolve1.rs:16:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidates: + crate `crateresolve1`: /home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/crateresolve1.nll/auxiliary/libcrateresolve1-1.so + crate `crateresolve1`: /home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/crateresolve1.nll/auxiliary/libcrateresolve1-3.so + crate `crateresolve1`: /home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/crateresolve1.nll/auxiliary/libcrateresolve1-2.so + +error[E0463]: can't find crate for `crateresolve1` + --> $DIR/crateresolve1.rs:16:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate + +error: aborting due to 2 previous errors + +Some errors occurred: E0463, E0464. +For more information about an error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/crateresolve1.rs b/src/test/ui/compile-fail-migration/crateresolve1.rs new file mode 100644 index 00000000000..8c3dbda6802 --- /dev/null +++ b/src/test/ui/compile-fail-migration/crateresolve1.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:crateresolve1-1.rs +// aux-build:crateresolve1-2.rs +// aux-build:crateresolve1-3.rs +// error-pattern:multiple matching crates for `crateresolve1` + +extern crate crateresolve1; + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/crateresolve1.stderr b/src/test/ui/compile-fail-migration/crateresolve1.stderr new file mode 100644 index 00000000000..7dadcfe52ee --- /dev/null +++ b/src/test/ui/compile-fail-migration/crateresolve1.stderr @@ -0,0 +1,21 @@ +error[E0464]: multiple matching crates for `crateresolve1` + --> $DIR/crateresolve1.rs:16:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: candidates: + crate `crateresolve1`: /home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/crateresolve1/auxiliary/libcrateresolve1-1.so + crate `crateresolve1`: /home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/crateresolve1/auxiliary/libcrateresolve1-3.so + crate `crateresolve1`: /home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/crateresolve1/auxiliary/libcrateresolve1-2.so + +error[E0463]: can't find crate for `crateresolve1` + --> $DIR/crateresolve1.rs:16:1 + | +LL | extern crate crateresolve1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate + +error: aborting due to 2 previous errors + +Some errors occurred: E0463, E0464. +For more information about an error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/cross-borrow-trait.rs b/src/test/ui/compile-fail-migration/cross-borrow-trait.rs new file mode 100644 index 00000000000..7c76cf475d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cross-borrow-trait.rs @@ -0,0 +1,23 @@ +// Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that cross-borrowing (implicitly converting from `Box` to `&T`) is +// forbidden when `T` is a trait. + +struct Foo; +trait Trait { fn foo(&self) {} } +impl Trait for Foo {} + +pub fn main() { + let x: Box = Box::new(Foo); + let _y: &Trait = x; //~ ERROR E0308 + //~| expected type `&dyn Trait` + //~| found type `std::boxed::Box` +} diff --git a/src/test/ui/compile-fail-migration/cross-borrow-trait.stderr b/src/test/ui/compile-fail-migration/cross-borrow-trait.stderr new file mode 100644 index 00000000000..d25316d542a --- /dev/null +++ b/src/test/ui/compile-fail-migration/cross-borrow-trait.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/cross-borrow-trait.rs:20:22 + | +LL | let _y: &Trait = x; //~ ERROR E0308 + | ^ + | | + | expected &dyn Trait, found struct `std::boxed::Box` + | help: consider borrowing here: `&x` + | + = note: expected type `&dyn Trait` + found type `std::boxed::Box` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/cross-fn-cache-hole.rs b/src/test/ui/compile-fail-migration/cross-fn-cache-hole.rs new file mode 100644 index 00000000000..d437fc019fd --- /dev/null +++ b/src/test/ui/compile-fail-migration/cross-fn-cache-hole.rs @@ -0,0 +1,41 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that when there are vacuous predicates in the environment +// (which make a fn uncallable) we don't erroneously cache those and +// then consider them satisfied elsewhere. The current technique for +// doing this is to not use global caches when there is a chance that +// the environment contains such a predicate. +// We still error for `i32: Bar` pending #48214 + +trait Foo: Bar { +} + +trait Bar { } + +// We don't always check where clauses for sanity, but in this case +// wfcheck does report an error here: +fn vacuous() //~ ERROR the trait bound `i32: Bar` is not satisfied + where i32: Foo +{ + // ... the original intention was to check that we don't use that + // vacuous where clause (which could never be satisfied) to accept + // the following line and then mess up calls elsewhere. + require::(); +} + +fn require() + where A: Bar +{ +} + +fn main() { + require::(); +} diff --git a/src/test/ui/compile-fail-migration/cross-fn-cache-hole.stderr b/src/test/ui/compile-fail-migration/cross-fn-cache-hole.stderr new file mode 100644 index 00000000000..bfcb83204bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/cross-fn-cache-hole.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `i32: Bar` is not satisfied + --> $DIR/cross-fn-cache-hole.rs:25:1 + | +LL | / fn vacuous() //~ ERROR the trait bound `i32: Bar` is not satisfied +LL | | where i32: Foo +LL | | { +LL | | // ... the original intention was to check that we don't use that +... | +LL | | require::(); +LL | | } + | |_^ the trait `Bar` is not implemented for `i32` + | + = help: see issue #48214 + = help: add #![feature(trivial_bounds)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/custom_attribute.rs b/src/test/ui/compile-fail-migration/custom_attribute.rs new file mode 100644 index 00000000000..eff734230ee --- /dev/null +++ b/src/test/ui/compile-fail-migration/custom_attribute.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(stmt_expr_attributes)] + +#[foo] //~ ERROR The attribute `foo` +fn main() { + #[foo] //~ ERROR The attribute `foo` + let x = (); + #[foo] //~ ERROR The attribute `foo` + x +} diff --git a/src/test/ui/compile-fail-migration/custom_attribute.stderr b/src/test/ui/compile-fail-migration/custom_attribute.stderr new file mode 100644 index 00000000000..7d2a23b7054 --- /dev/null +++ b/src/test/ui/compile-fail-migration/custom_attribute.stderr @@ -0,0 +1,27 @@ +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/custom_attribute.rs:15:5 + | +LL | #[foo] //~ ERROR The attribute `foo` + | ^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/custom_attribute.rs:17:5 + | +LL | #[foo] //~ ERROR The attribute `foo` + | ^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/custom_attribute.rs:13:1 + | +LL | #[foo] //~ ERROR The attribute `foo` + | ^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.rs b/src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.rs new file mode 100644 index 00000000000..56ad1771e00 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Example cycle where a bound on `T` uses a shorthand for `T`. This +// creates a cycle because we have to know the bounds on `T` to figure +// out what trait defines `Item`, but we can't know the bounds on `T` +// without knowing how to handle `T::Item`. +// +// Note that in the future cases like this could perhaps become legal, +// if we got more fine-grained about our cycle detection or changed +// how we handle `T::Item` resolution. + +use std::ops::Add; + +// Preamble. +trait Trait { type Item; } + +struct A + where T : Trait, + T : Add + //~^ ERROR cycle detected + //~| ERROR associated type `Item` not found for `T` +{ + data: T +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.stderr b/src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.stderr new file mode 100644 index 00000000000..c7147bcddc4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cycle-projection-based-on-where-clause.stderr @@ -0,0 +1,23 @@ +error[E0391]: cycle detected when computing the bounds for type parameter `T` + --> $DIR/cycle-projection-based-on-where-clause.rs:27:19 + | +LL | T : Add + | ^^^^^^^ + | + = note: ...which again requires computing the bounds for type parameter `T`, completing the cycle +note: cycle used when processing `A` + --> $DIR/cycle-projection-based-on-where-clause.rs:27:19 + | +LL | T : Add + | ^^^^^^^ + +error[E0220]: associated type `Item` not found for `T` + --> $DIR/cycle-projection-based-on-where-clause.rs:27:19 + | +LL | T : Add + | ^^^^^^^ associated type `Item` not found + +error: aborting due to 2 previous errors + +Some errors occurred: E0220, E0391. +For more information about an error, try `rustc --explain E0220`. diff --git a/src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.rs b/src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.rs new file mode 100644 index 00000000000..b8bae215456 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a cycle where a type parameter on a trait has a default that +// again references the trait. + +trait Foo> { + //~^ ERROR cycle detected +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.stderr b/src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.stderr new file mode 100644 index 00000000000..767a99a3265 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cycle-trait-default-type-trait.stderr @@ -0,0 +1,11 @@ +error[E0391]: cycle detected when processing `Foo::X` + --> $DIR/cycle-trait-default-type-trait.rs:14:19 + | +LL | trait Foo> { + | ^^^ + | + = note: ...which again requires processing `Foo::X`, completing the cycle + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.rs b/src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.rs new file mode 100644 index 00000000000..b802463fcb0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a supertrait cycle where a trait extends itself. + +trait Chromosome: Chromosome { + //~^ ERROR cycle detected +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.stderr b/src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.stderr new file mode 100644 index 00000000000..724d4b1ec67 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cycle-trait-supertrait-direct.stderr @@ -0,0 +1,11 @@ +error[E0391]: cycle detected when computing the supertraits of `Chromosome` + --> $DIR/cycle-trait-supertrait-direct.rs:13:1 + | +LL | trait Chromosome: Chromosome { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which again requires computing the supertraits of `Chromosome`, completing the cycle + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/dead-code-closure-bang.rs b/src/test/ui/compile-fail-migration/dead-code-closure-bang.rs new file mode 100644 index 00000000000..d808d797272 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dead-code-closure-bang.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test FIXME(#20574) + +#![deny(unreachable_code)] + +fn main() { + let x = || panic!(); + x(); + println!("Foo bar"); //~ ERROR: unreachable statement +} diff --git a/src/test/ui/compile-fail-migration/dead-code-ret.rs b/src/test/ui/compile-fail-migration/dead-code-ret.rs new file mode 100644 index 00000000000..250d22db374 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dead-code-ret.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: unreachable statement + +#![deny(unreachable_code)] + +fn main() { + return; + println!("Paul is dead"); +} diff --git a/src/test/ui/compile-fail-migration/dead-code-ret.stderr b/src/test/ui/compile-fail-migration/dead-code-ret.stderr new file mode 100644 index 00000000000..9f940166966 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dead-code-ret.stderr @@ -0,0 +1,15 @@ +error: unreachable statement + --> $DIR/dead-code-ret.rs:17:5 + | +LL | println!("Paul is dead"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/dead-code-ret.rs:13:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/defaulted-never-note.rs b/src/test/ui/compile-fail-migration/defaulted-never-note.rs new file mode 100644 index 00000000000..ac8ac85824e --- /dev/null +++ b/src/test/ui/compile-fail-migration/defaulted-never-note.rs @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// We need to opt inot the `!` feature in order to trigger the +// requirement that this is testing. +#![feature(never_type)] + +#![allow(unused)] + +trait Deserialize: Sized { + fn deserialize() -> Result; +} + +impl Deserialize for () { + fn deserialize() -> Result<(), String> { + Ok(()) + } +} + +trait ImplementedForUnitButNotNever {} + +impl ImplementedForUnitButNotNever for () {} + +fn foo(_t: T) {} +//~^ NOTE required by `foo` + +fn smeg() { + let _x = return; + foo(_x); + //~^ ERROR the trait bound + //~| NOTE the trait `ImplementedForUnitButNotNever` is not implemented + //~| NOTE the trait is implemented for `()` +} + +fn main() { + smeg(); +} + diff --git a/src/test/ui/compile-fail-migration/defaulted-never-note.stderr b/src/test/ui/compile-fail-migration/defaulted-never-note.stderr new file mode 100644 index 00000000000..32922354fe6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/defaulted-never-note.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `!: ImplementedForUnitButNotNever` is not satisfied + --> $DIR/defaulted-never-note.rs:36:5 + | +LL | foo(_x); + | ^^^ the trait `ImplementedForUnitButNotNever` is not implemented for `!` + | + = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: https://github.com/rust-lang/rust/issues/48950 for more info). Consider whether you meant to use the type `()` here instead. +note: required by `foo` + --> $DIR/defaulted-never-note.rs:31:1 + | +LL | fn foo(_t: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.rs b/src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.rs new file mode 100644 index 00000000000..c20cfbc7e23 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.rs @@ -0,0 +1,47 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that when a trait impl changes, fns whose body uses that trait +// must also be recompiled. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(warnings)] + +fn main() { } + +pub trait Foo: Sized { + type T; + fn method(self) { } +} + +mod x { + use Foo; + + #[rustc_if_this_changed] + impl Foo for char { type T = char; } + + impl Foo for u32 { type T = u32; } +} + +mod y { + use Foo; + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + pub fn use_char_assoc() { + // Careful here: in the representation, ::T gets + // normalized away, so at a certain point we had no edge to + // codegen. (But now codegen just depends on typeck.) + let x: ::T = 'a'; + } + + pub fn take_foo(t: T) { } +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.stderr b/src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.stderr new file mode 100644 index 00000000000..e00b3ccf281 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-assoc-type-codegen.stderr @@ -0,0 +1,8 @@ +error: OK + --> $DIR/dep-graph-assoc-type-codegen.rs:38:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/dep-graph-caller-callee.rs b/src/test/ui/compile-fail-migration/dep-graph-caller-callee.rs new file mode 100644 index 00000000000..222c1972005 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-caller-callee.rs @@ -0,0 +1,45 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that immediate callers have to change when callee changes, but +// not callers' callers. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +fn main() { } + +mod x { + #[rustc_if_this_changed] + pub fn x() { } +} + +mod y { + use x; + + // These dependencies SHOULD exist: + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + pub fn y() { + x::x(); + } +} + +mod z { + use y; + + // These are expected to yield errors, because changes to `x` + // affect the BODY of `y`, but not its signature. + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + pub fn z() { + y::y(); + } +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-caller-callee.stderr b/src/test/ui/compile-fail-migration/dep-graph-caller-callee.stderr new file mode 100644 index 00000000000..8943b051c12 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-caller-callee.stderr @@ -0,0 +1,14 @@ +error: OK + --> $DIR/dep-graph-caller-callee.rs:30:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `x::x` to `TypeckTables` + --> $DIR/dep-graph-caller-callee.rs:41:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/dep-graph-struct-signature.rs b/src/test/ui/compile-fail-migration/dep-graph-struct-signature.rs new file mode 100644 index 00000000000..647605ae438 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-struct-signature.rs @@ -0,0 +1,97 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test cases where a changing struct appears in the signature of fns +// and methods. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +fn main() { } + +#[rustc_if_this_changed] +struct WillChange { + x: u32, + y: u32 +} + +struct WontChange { + x: u32, + y: u32 +} + +// these are valid dependencies +mod signatures { + use WillChange; + + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + #[rustc_then_this_would_need(AssociatedItems)] //~ ERROR no path + #[rustc_then_this_would_need(TraitDefOfItem)] //~ ERROR no path + trait Bar { + #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + fn do_something(x: WillChange); + } + + #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + fn some_fn(x: WillChange) { } + + #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + fn new_foo(x: u32, y: u32) -> WillChange { + WillChange { x: x, y: y } + } + + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + impl WillChange { + #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + fn new(x: u32, y: u32) -> WillChange { loop { } } + } + + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + impl WillChange { + #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + fn method(&self, x: u32) { } + } + + struct WillChanges { + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + x: WillChange, + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + y: WillChange + } + + // The fields change, not the type itself. + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + fn indirect(x: WillChanges) { } +} + +mod invalid_signatures { + use WontChange; + + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + trait A { + #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path + fn do_something_else_twice(x: WontChange); + } + + #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + fn b(x: WontChange) { } + + #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange` + fn c(x: u32) { } +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-struct-signature.stderr b/src/test/ui/compile-fail-migration/dep-graph-struct-signature.stderr new file mode 100644 index 00000000000..cbb695d0cf2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-struct-signature.stderr @@ -0,0 +1,140 @@ +error: no path from `WillChange` to `TypeOfItem` + --> $DIR/dep-graph-struct-signature.rs:37:5 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `AssociatedItems` + --> $DIR/dep-graph-struct-signature.rs:38:5 + | +LL | #[rustc_then_this_would_need(AssociatedItems)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `TraitDefOfItem` + --> $DIR/dep-graph-struct-signature.rs:39:5 + | +LL | #[rustc_then_this_would_need(TraitDefOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:45:5 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:46:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:49:5 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:50:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:55:5 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:62:5 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:70:9 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:72:9 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `TypeOfItem` + --> $DIR/dep-graph-struct-signature.rs:77:5 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `TypeOfItem` + --> $DIR/dep-graph-struct-signature.rs:84:5 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `FnSignature` + --> $DIR/dep-graph-struct-signature.rs:90:5 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `TypeckTables` + --> $DIR/dep-graph-struct-signature.rs:91:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `FnSignature` + --> $DIR/dep-graph-struct-signature.rs:94:5 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `TypeckTables` + --> $DIR/dep-graph-struct-signature.rs:95:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:41:9 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `WillChange` to `FnSignature` + --> $DIR/dep-graph-struct-signature.rs:86:9 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:57:9 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:58:9 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:64:9 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-struct-signature.rs:65:9 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 23 previous errors + diff --git a/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.rs b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.rs new file mode 100644 index 00000000000..7dd02f57b36 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.rs @@ -0,0 +1,55 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that adding an impl to a trait `Foo` DOES affect functions +// that only use `Bar` if they have methods in common. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_imports)] + +fn main() { } + +pub trait Foo: Sized { + fn method(self) { } +} + +pub trait Bar: Sized { + fn method(self) { } +} + +mod x { + use {Foo, Bar}; + + #[rustc_if_this_changed] + impl Foo for u32 { } + + impl Bar for char { } +} + +mod y { + use {Foo, Bar}; + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + pub fn with_char() { + char::method('a'); + } +} + +mod z { + use y; + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + pub fn z() { + y::with_char(); + } +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.stderr b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.stderr new file mode 100644 index 00000000000..877a056019f --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits-same-method.stderr @@ -0,0 +1,14 @@ +error: OK + --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:42:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `x::` to `TypeckTables` + --> $DIR/dep-graph-trait-impl-two-traits-same-method.rs:51:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.rs b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.rs new file mode 100644 index 00000000000..6b3525333bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.rs @@ -0,0 +1,54 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that adding an impl to a trait `Foo` does not affect functions +// that only use `Bar`, so long as they do not have methods in common. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(warnings)] + +fn main() { } + +pub trait Foo: Sized { + fn foo(self) { } +} + +pub trait Bar: Sized { + fn bar(self) { } +} + +mod x { + use {Foo, Bar}; + + #[rustc_if_this_changed] + impl Foo for char { } + + impl Bar for char { } +} + +mod y { + use {Foo, Bar}; + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + pub fn call_bar() { + char::bar('a'); + } +} + +mod z { + use y; + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + pub fn z() { + y::call_bar(); + } +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.stderr b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.stderr new file mode 100644 index 00000000000..f939fac3146 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-trait-impl-two-traits.stderr @@ -0,0 +1,14 @@ +error: no path from `x::` to `TypeckTables` + --> $DIR/dep-graph-trait-impl-two-traits.rs:41:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `x::` to `TypeckTables` + --> $DIR/dep-graph-trait-impl-two-traits.rs:50:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/dep-graph-trait-impl.rs b/src/test/ui/compile-fail-migration/dep-graph-trait-impl.rs new file mode 100644 index 00000000000..85b3e69065d --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-trait-impl.rs @@ -0,0 +1,70 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that when a trait impl changes, fns whose body uses that trait +// must also be recompiled. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(warnings)] + +fn main() { } + +pub trait Foo: Sized { + fn method(self) { } +} + +mod x { + use Foo; + + #[rustc_if_this_changed] + impl Foo for char { } + + impl Foo for u32 { } +} + +mod y { + use Foo; + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + pub fn with_char() { + char::method('a'); + } + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + pub fn take_foo_with_char() { + take_foo::('a'); + } + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + pub fn with_u32() { + u32::method(22); + } + + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + pub fn take_foo_with_u32() { + take_foo::(22); + } + + pub fn take_foo(t: T) { } +} + +mod z { + use y; + + // These are expected to yield errors, because changes to `x` + // affect the BODY of `y`, but not its signature. + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + pub fn z() { + y::with_char(); + y::with_u32(); + } +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-trait-impl.stderr b/src/test/ui/compile-fail-migration/dep-graph-trait-impl.stderr new file mode 100644 index 00000000000..c569e8584e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-trait-impl.stderr @@ -0,0 +1,32 @@ +error: OK + --> $DIR/dep-graph-trait-impl.rs:37:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-trait-impl.rs:42:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-trait-impl.rs:47:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-trait-impl.rs:52:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `x::` to `TypeckTables` + --> $DIR/dep-graph-trait-impl.rs:65:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/dep-graph-type-alias.rs b/src/test/ui/compile-fail-migration/dep-graph-type-alias.rs new file mode 100644 index 00000000000..dca1fa4d98f --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-type-alias.rs @@ -0,0 +1,66 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// Test that changing what a `type` points to does not go unnoticed. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +fn main() { } + + +#[rustc_if_this_changed] +type TypeAlias = u32; + +// The type alias directly affects the type of the field, +// not the enclosing struct: +#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path +struct Struct { + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + x: TypeAlias, + y: u32 +} + +#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path +enum Enum { + Variant1 { + #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + t: TypeAlias + }, + Variant2(i32) +} + +#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path +trait Trait { + #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + fn method(&self, _: TypeAlias); +} + +struct SomeType; + +#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path +impl SomeType { + #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + fn method(&self, _: TypeAlias) {} +} + +#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK +type TypeAlias2 = TypeAlias; + +#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK +#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK +fn function(_: TypeAlias) { + +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-type-alias.stderr b/src/test/ui/compile-fail-migration/dep-graph-type-alias.stderr new file mode 100644 index 00000000000..b018c250667 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-type-alias.stderr @@ -0,0 +1,74 @@ +error: no path from `TypeAlias` to `TypeOfItem` + --> $DIR/dep-graph-type-alias.rs:28:1 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:30:5 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `TypeAlias` to `TypeOfItem` + --> $DIR/dep-graph-type-alias.rs:35:1 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:38:9 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `TypeAlias` to `TypeOfItem` + --> $DIR/dep-graph-type-alias.rs:44:1 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: no path from `TypeAlias` to `TypeOfItem` + --> $DIR/dep-graph-type-alias.rs:52:1 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:59:1 + | +LL | #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:62:1 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:63:1 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:46:5 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:54:5 + | +LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: OK + --> $DIR/dep-graph-type-alias.rs:55:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + diff --git a/src/test/ui/compile-fail-migration/dep-graph-variance-alias.rs b/src/test/ui/compile-fail-migration/dep-graph-variance-alias.rs new file mode 100644 index 00000000000..18cfd001804 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-variance-alias.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that changing what a `type` points to does not go unnoticed +// by the variance analysis. + +// compile-flags: -Z query-dep-graph + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +fn main() { } + +struct Foo { + f: T +} + +#[rustc_if_this_changed(Krate)] +type TypeAlias = Foo; + +#[rustc_then_this_would_need(ItemVariances)] //~ ERROR OK +struct Use { + x: TypeAlias +} diff --git a/src/test/ui/compile-fail-migration/dep-graph-variance-alias.stderr b/src/test/ui/compile-fail-migration/dep-graph-variance-alias.stderr new file mode 100644 index 00000000000..a3b12013906 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dep-graph-variance-alias.stderr @@ -0,0 +1,8 @@ +error: OK + --> $DIR/dep-graph-variance-alias.rs:29:1 + | +LL | #[rustc_then_this_would_need(ItemVariances)] //~ ERROR OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/deprecated_no_stack_check.rs b/src/test/ui/compile-fail-migration/deprecated_no_stack_check.rs new file mode 100644 index 00000000000..38aaefd52b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecated_no_stack_check.rs @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(warnings)] +#![feature(no_stack_check)] +//~^ ERROR: 12:12: 12:26: feature has been removed [E0557] +fn main() { + +} diff --git a/src/test/ui/compile-fail-migration/deprecated_no_stack_check.stderr b/src/test/ui/compile-fail-migration/deprecated_no_stack_check.stderr new file mode 100644 index 00000000000..2f847a253e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecated_no_stack_check.stderr @@ -0,0 +1,9 @@ +error[E0557]: feature has been removed + --> $DIR/deprecated_no_stack_check.rs:12:12 + | +LL | #![feature(no_stack_check)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0557`. diff --git a/src/test/ui/compile-fail-migration/deprecation-in-staged-api.rs b/src/test/ui/compile-fail-migration/deprecation-in-staged-api.rs new file mode 100644 index 00000000000..5c6facbf014 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-in-staged-api.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #[deprecated] can't be used in staged api + +#![feature(staged_api)] + +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[deprecated] +fn main() { } //~ERROR `#[deprecated]` cannot be used in staged api diff --git a/src/test/ui/compile-fail-migration/deprecation-in-staged-api.stderr b/src/test/ui/compile-fail-migration/deprecation-in-staged-api.stderr new file mode 100644 index 00000000000..9ad56585015 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-in-staged-api.stderr @@ -0,0 +1,8 @@ +error: `#[deprecated]` cannot be used in staged api, use `#[rustc_deprecated]` instead + --> $DIR/deprecation-in-staged-api.rs:18:1 + | +LL | fn main() { } //~ERROR `#[deprecated]` cannot be used in staged api + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/deprecation-lint-2.rs b/src/test/ui/compile-fail-migration/deprecation-lint-2.rs new file mode 100644 index 00000000000..2817e06652a --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint-2.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:deprecation-lint.rs +// error-pattern: use of deprecated item + +#![deny(deprecated)] + +#[macro_use] +extern crate deprecation_lint; + +use deprecation_lint::*; + +fn main() { + macro_test!(); +} diff --git a/src/test/ui/compile-fail-migration/deprecation-lint-2.stderr b/src/test/ui/compile-fail-migration/deprecation-lint-2.stderr new file mode 100644 index 00000000000..fedc6b22f32 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint-2.stderr @@ -0,0 +1,15 @@ +error: use of deprecated item 'deprecation_lint::deprecated': text + --> $DIR/deprecation-lint-2.rs:22:5 + | +LL | macro_test!(); + | ^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/deprecation-lint-2.rs:14:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/deprecation-lint-3.rs b/src/test/ui/compile-fail-migration/deprecation-lint-3.rs new file mode 100644 index 00000000000..7faaa181d39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint-3.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:deprecation-lint.rs +// error-pattern: use of deprecated item + +#![deny(deprecated)] +#![allow(warnings)] + +#[macro_use] +extern crate deprecation_lint; + +use deprecation_lint::*; + +fn main() { + macro_test_arg_nested!(deprecated_text); +} diff --git a/src/test/ui/compile-fail-migration/deprecation-lint-3.stderr b/src/test/ui/compile-fail-migration/deprecation-lint-3.stderr new file mode 100644 index 00000000000..9dfc44ebc61 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint-3.stderr @@ -0,0 +1,15 @@ +error: use of deprecated item 'deprecation_lint::deprecated_text': text + --> $DIR/deprecation-lint-3.rs:23:5 + | +LL | macro_test_arg_nested!(deprecated_text); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/deprecation-lint-3.rs:14:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/deprecation-lint-nested.rs b/src/test/ui/compile-fail-migration/deprecation-lint-nested.rs new file mode 100644 index 00000000000..eedbba59c6f --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint-nested.rs @@ -0,0 +1,81 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(deprecated)] +#![allow(warnings)] + +#[deprecated] +fn issue_35128() { + format_args!("foo"); +} + +#[deprecated] +fn issue_35128_minimal() { + static FOO: &'static str = "foo"; + let _ = FOO; +} + +#[deprecated] +mod silent { + type DeprecatedType = u8; + struct DeprecatedStruct; + fn deprecated_fn() {} + trait DeprecatedTrait {} + static DEPRECATED_STATIC: u8 = 0; + const DEPRECATED_CONST: u8 = 1; + + struct Foo(DeprecatedType); + + impl DeprecatedTrait for Foo {} + + impl Foo { + fn bar() { + deprecated_fn(); + } + } + + fn foo() -> u8 { + DEPRECATED_STATIC + + DEPRECATED_CONST + } +} + +#[deprecated] +mod loud { + #[deprecated] + type DeprecatedType = u8; + #[deprecated] + struct DeprecatedStruct; + #[deprecated] + fn deprecated_fn() {} + #[deprecated] + trait DeprecatedTrait {} + #[deprecated] + static DEPRECATED_STATIC: u8 = 0; + #[deprecated] + const DEPRECATED_CONST: u8 = 1; + + struct Foo(DeprecatedType); //~ ERROR use of deprecated item + + impl DeprecatedTrait for Foo {} //~ ERROR use of deprecated item + + impl Foo { + fn bar() { //~ ERROR use of deprecated item + deprecated_fn(); //~ ERROR use of deprecated item + } + } + + fn foo() -> u8 { + DEPRECATED_STATIC + //~ ERROR use of deprecated item + DEPRECATED_CONST //~ ERROR use of deprecated item + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/deprecation-lint-nested.stderr b/src/test/ui/compile-fail-migration/deprecation-lint-nested.stderr new file mode 100644 index 00000000000..4e2b462fd1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint-nested.stderr @@ -0,0 +1,44 @@ +error: use of deprecated item 'loud::DeprecatedType' + --> $DIR/deprecation-lint-nested.rs:65:16 + | +LL | struct Foo(DeprecatedType); //~ ERROR use of deprecated item + | ^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/deprecation-lint-nested.rs:11:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: use of deprecated item 'loud::DeprecatedTrait' + --> $DIR/deprecation-lint-nested.rs:67:10 + | +LL | impl DeprecatedTrait for Foo {} //~ ERROR use of deprecated item + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'loud::DEPRECATED_STATIC' + --> $DIR/deprecation-lint-nested.rs:76:9 + | +LL | DEPRECATED_STATIC + //~ ERROR use of deprecated item + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'loud::DEPRECATED_CONST' + --> $DIR/deprecation-lint-nested.rs:77:9 + | +LL | DEPRECATED_CONST //~ ERROR use of deprecated item + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'loud::DeprecatedTrait' + --> $DIR/deprecation-lint-nested.rs:70:19 + | +LL | fn bar() { //~ ERROR use of deprecated item + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'loud::deprecated_fn' + --> $DIR/deprecation-lint-nested.rs:71:13 + | +LL | deprecated_fn(); //~ ERROR use of deprecated item + | ^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/compile-fail-migration/deprecation-lint.rs b/src/test/ui/compile-fail-migration/deprecation-lint.rs new file mode 100644 index 00000000000..93eb6b6b115 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint.rs @@ -0,0 +1,445 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:deprecation-lint.rs +// ignore-tidy-linelength + +#![deny(deprecated)] +#![allow(warnings)] + +#[macro_use] +extern crate deprecation_lint; + +mod cross_crate { + use deprecation_lint::*; + + fn test() { + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated' + foo.method_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' + Foo::method_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' + ::method_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' + foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + + deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text + foo.method_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + ::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + + let _ = DeprecatedStruct { //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedStruct': text + i: 0 //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedStruct::i': text + }; + + let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedUnitStruct': text + + let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'deprecation_lint::Enum::DeprecatedVariant': text + + let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTupleStruct': text + + let _ = nested::DeprecatedStruct { //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedStruct': text + i: 0 //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedStruct::i': text + }; + + let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedUnitStruct': text + + let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'deprecation_lint::nested::Enum::DeprecatedVariant': text + + let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedTupleStruct': text + + // At the moment, the lint checker only checks stability in + // in the arguments of macros. + // Eventually, we will want to lint the contents of the + // macro in the module *defining* it. Also, stability levels + // on macros themselves are not yet linted. + macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text + macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + } + + struct S; + + impl DeprecatedTrait for S {} //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTrait': text + trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTrait': text + + pub fn foo() { + let x = Stable { + override2: 3, + //~^ ERROR use of deprecated item 'deprecation_lint::Stable::override2': text + }; + + let _ = x.override2; + //~^ ERROR use of deprecated item 'deprecation_lint::Stable::override2': text + + let Stable { + override2: _ + //~^ ERROR use of deprecated item 'deprecation_lint::Stable::override2': text + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.2; + //~^ ERROR use of deprecated item 'deprecation_lint::Stable2::2': text + + let Stable2(_, + _, + _) + //~^ ERROR use of deprecated item 'deprecation_lint::Stable2::2': text + = x; + // all fine + let Stable2(..) = x; + + let x = Deprecated { + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated': text + inherit: 1, + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated::inherit': text + }; + + let _ = x.inherit; + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated::inherit': text + + let Deprecated { + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated': text + inherit: _, + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated::inherit': text + } = x; + + let Deprecated + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated': text + { .. } = x; + + let x = Deprecated2(1, 2, 3); + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2': text + + let _ = x.0; + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::0': text + let _ = x.1; + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::1': text + let _ = x.2; + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::2': text + + let Deprecated2 + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2': text + (_, + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::0': text + _, + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::1': text + _) + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::2': text + = x; + let Deprecated2 + //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2': text + // the patterns are all fine: + (..) = x; + } +} + +mod inheritance { + use deprecation_lint::*; + + fn test_inheritance() { + deprecated_mod::deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_mod::deprecated': text + } +} + +mod this_crate { + #[deprecated(since = "1.0.0", note = "text")] + pub fn deprecated() {} + #[deprecated(since = "1.0.0", note = "text")] + pub fn deprecated_text() {} + + #[deprecated(since = "99.99.99", note = "text")] + pub fn deprecated_future() {} + #[deprecated(since = "99.99.99", note = "text")] + pub fn deprecated_future_text() {} + + pub struct MethodTester; + + impl MethodTester { + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated(&self) {} + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated_text(&self) {} + } + + pub trait Trait { + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated(&self) {} + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated_text(&self) {} + } + + impl Trait for MethodTester {} + + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedStruct { + i: isize + } + pub struct UnstableStruct { + i: isize + } + pub struct StableStruct { + i: isize + } + + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedUnitStruct; + + pub enum Enum { + #[deprecated(since = "1.0.0", note = "text")] + DeprecatedVariant, + } + + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedTupleStruct(isize); + + mod nested { + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedStruct { + i: isize + } + + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedUnitStruct; + + pub enum Enum { + #[deprecated(since = "1.0.0", note = "text")] + DeprecatedVariant, + } + + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedTupleStruct(pub isize); + } + + fn test() { + use self::nested; + + // Only the deprecated cases of the following should generate + // errors, because other stability attributes now have meaning + // only *across* crates, not within a single crate. + + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); //~ ERROR use of deprecated item 'this_crate::deprecated' + foo.method_deprecated(); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' + Foo::method_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' + ::method_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' + foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + + deprecated_text(); //~ ERROR use of deprecated item 'this_crate::deprecated_text': text + foo.method_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + ::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + + deprecated_future(); // Fine; no error. + deprecated_future_text(); // Fine; no error. + + let _ = DeprecatedStruct { + //~^ ERROR use of deprecated item 'this_crate::DeprecatedStruct': text + i: 0 //~ ERROR use of deprecated item 'this_crate::DeprecatedStruct::i': text + }; + + let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item 'this_crate::DeprecatedUnitStruct': text + + let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'this_crate::Enum::DeprecatedVariant': text + + let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'this_crate::DeprecatedTupleStruct': text + + let _ = nested::DeprecatedStruct { + //~^ ERROR use of deprecated item 'this_crate::nested::DeprecatedStruct': text + i: 0 //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedStruct::i': text + }; + + let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedUnitStruct': text + + let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'this_crate::nested::Enum::DeprecatedVariant': text + + let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedTupleStruct': text + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + } + + #[deprecated(since = "1.0.0", note = "text")] + fn test_fn_body() { + fn fn_in_body() {} + fn_in_body(); + } + + fn test_fn_closure_body() { + let _ = || { + #[deprecated] + fn bar() { } + bar(); //~ ERROR use of deprecated item 'this_crate::test_fn_closure_body::{{closure}}::bar' + }; + } + + impl MethodTester { + #[deprecated(since = "1.0.0", note = "text")] + fn test_method_body(&self) { + fn fn_in_body() {} + fn_in_body(); + } + } + + #[deprecated(since = "1.0.0", note = "text")] + pub trait DeprecatedTrait { + fn dummy(&self) { } + } + + struct S; + + impl DeprecatedTrait for S { } //~ ERROR use of deprecated item 'this_crate::DeprecatedTrait': text + + trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item 'this_crate::DeprecatedTrait': text +} + +mod this_crate2 { + struct Stable { + #[deprecated(since = "1.0.0", note = "text")] + override2: u8, + } + + struct Stable2(u8, + u8, + #[deprecated(since = "1.0.0", note = "text")] u8); + + #[deprecated(since = "1.0.0", note = "text")] + struct Deprecated { + inherit: u8, + } + + #[deprecated(since = "1.0.0", note = "text")] + struct Deprecated2(u8, + u8, + u8); + + pub fn foo() { + let x = Stable { + override2: 3, + //~^ ERROR use of deprecated item 'this_crate2::Stable::override2': text + }; + + let _ = x.override2; + //~^ ERROR use of deprecated item 'this_crate2::Stable::override2': text + + let Stable { + override2: _ + //~^ ERROR use of deprecated item 'this_crate2::Stable::override2': text + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.2; + //~^ ERROR use of deprecated item 'this_crate2::Stable2::2': text + + let Stable2(_, + _, + _) + //~^ ERROR use of deprecated item 'this_crate2::Stable2::2': text + = x; + // all fine + let Stable2(..) = x; + + let x = Deprecated { + //~^ ERROR use of deprecated item 'this_crate2::Deprecated': text + inherit: 1, + //~^ ERROR use of deprecated item 'this_crate2::Deprecated::inherit': text + }; + + let _ = x.inherit; + //~^ ERROR use of deprecated item 'this_crate2::Deprecated::inherit': text + + let Deprecated { + //~^ ERROR use of deprecated item 'this_crate2::Deprecated': text + inherit: _, + //~^ ERROR use of deprecated item 'this_crate2::Deprecated::inherit': text + } = x; + + let Deprecated + //~^ ERROR use of deprecated item 'this_crate2::Deprecated': text + // the patterns are all fine: + { .. } = x; + + let x = Deprecated2(1, 2, 3); + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2': text + + let _ = x.0; + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::0': text + let _ = x.1; + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::1': text + let _ = x.2; + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::2': text + + let Deprecated2 + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2': text + (_, + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::0': text + _, + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::1': text + _) + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::2': text + = x; + let Deprecated2 + //~^ ERROR use of deprecated item 'this_crate2::Deprecated2': text + // the patterns are all fine: + (..) = x; + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/deprecation-lint.stderr b/src/test/ui/compile-fail-migration/deprecation-lint.stderr new file mode 100644 index 00000000000..addca669917 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deprecation-lint.stderr @@ -0,0 +1,728 @@ +error: use of deprecated item 'deprecation_lint::deprecated': text + --> $DIR/deprecation-lint.rs:27:9 + | +LL | deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated' + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/deprecation-lint.rs:14:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:32:9 + | +LL | Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:34:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::deprecated_text': text + --> $DIR/deprecation-lint.rs:36:9 + | +LL | deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:41:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:43:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::DeprecatedStruct': text + --> $DIR/deprecation-lint.rs:45:17 + | +LL | let _ = DeprecatedStruct { //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedStruct': text + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::DeprecatedUnitStruct': text + --> $DIR/deprecation-lint.rs:49:17 + | +LL | let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedUnitStruct': text + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Enum::DeprecatedVariant': text + --> $DIR/deprecation-lint.rs:51:17 + | +LL | let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'deprecation_lint::Enum::DeprecatedVariant': text + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::DeprecatedTupleStruct': text + --> $DIR/deprecation-lint.rs:53:17 + | +LL | let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTupleStruct': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::nested::DeprecatedStruct': text + --> $DIR/deprecation-lint.rs:55:17 + | +LL | let _ = nested::DeprecatedStruct { //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedStruct': text + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::nested::DeprecatedUnitStruct': text + --> $DIR/deprecation-lint.rs:59:17 + | +LL | let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedUnitStruct': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::nested::Enum::DeprecatedVariant': text + --> $DIR/deprecation-lint.rs:61:17 + | +LL | let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'deprecation_lint::nested::Enum::DeprecatedVariant': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::nested::DeprecatedTupleStruct': text + --> $DIR/deprecation-lint.rs:63:17 + | +LL | let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedTupleStruct': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::deprecated_text': text + --> $DIR/deprecation-lint.rs:70:25 + | +LL | macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::deprecated_text': text + --> $DIR/deprecation-lint.rs:71:41 + | +LL | macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:76:9 + | +LL | Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:78:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:80:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:82:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::DeprecatedTrait': text + --> $DIR/deprecation-lint.rs:92:10 + | +LL | impl DeprecatedTrait for S {} //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTrait': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::DeprecatedTrait': text + --> $DIR/deprecation-lint.rs:93:24 + | +LL | trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTrait': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated': text + --> $DIR/deprecation-lint.rs:124:17 + | +LL | let x = Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated': text + --> $DIR/deprecation-lint.rs:133:13 + | +LL | let Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated': text + --> $DIR/deprecation-lint.rs:139:13 + | +LL | let Deprecated + | ^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated2': text + --> $DIR/deprecation-lint.rs:143:17 + | +LL | let x = Deprecated2(1, 2, 3); + | ^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated2': text + --> $DIR/deprecation-lint.rs:153:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated2': text + --> $DIR/deprecation-lint.rs:162:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::deprecated_mod::deprecated': text + --> $DIR/deprecation-lint.rs:173:9 + | +LL | deprecated_mod::deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_mod::deprecated': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::deprecated': text + --> $DIR/deprecation-lint.rs:256:9 + | +LL | deprecated(); //~ ERROR use of deprecated item 'this_crate::deprecated' + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:261:9 + | +LL | Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:263:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::deprecated_text': text + --> $DIR/deprecation-lint.rs:265:9 + | +LL | deprecated_text(); //~ ERROR use of deprecated item 'this_crate::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:270:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:272:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::DeprecatedStruct': text + --> $DIR/deprecation-lint.rs:277:17 + | +LL | let _ = DeprecatedStruct { + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::DeprecatedUnitStruct': text + --> $DIR/deprecation-lint.rs:282:17 + | +LL | let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item 'this_crate::DeprecatedUnitStruct': text + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Enum::DeprecatedVariant': text + --> $DIR/deprecation-lint.rs:284:17 + | +LL | let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'this_crate::Enum::DeprecatedVariant': text + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::DeprecatedTupleStruct': text + --> $DIR/deprecation-lint.rs:286:17 + | +LL | let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'this_crate::DeprecatedTupleStruct': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::nested::DeprecatedStruct': text + --> $DIR/deprecation-lint.rs:288:17 + | +LL | let _ = nested::DeprecatedStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::nested::DeprecatedUnitStruct': text + --> $DIR/deprecation-lint.rs:293:17 + | +LL | let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedUnitStruct': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::nested::Enum::DeprecatedVariant': text + --> $DIR/deprecation-lint.rs:295:17 + | +LL | let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'this_crate::nested::Enum::DeprecatedVariant': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::nested::DeprecatedTupleStruct': text + --> $DIR/deprecation-lint.rs:297:17 + | +LL | let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedTupleStruct': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:302:9 + | +LL | Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:304:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:306:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:308:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::test_fn_closure_body::{{closure}}::bar' + --> $DIR/deprecation-lint.rs:326:13 + | +LL | bar(); //~ ERROR use of deprecated item 'this_crate::test_fn_closure_body::{{closure}}::bar' + | ^^^ + +error: use of deprecated item 'this_crate::DeprecatedTrait': text + --> $DIR/deprecation-lint.rs:345:10 + | +LL | impl DeprecatedTrait for S { } //~ ERROR use of deprecated item 'this_crate::DeprecatedTrait': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::DeprecatedTrait': text + --> $DIR/deprecation-lint.rs:347:24 + | +LL | trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item 'this_crate::DeprecatedTrait': text + | ^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated': text + --> $DIR/deprecation-lint.rs:399:17 + | +LL | let x = Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated': text + --> $DIR/deprecation-lint.rs:408:13 + | +LL | let Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated': text + --> $DIR/deprecation-lint.rs:414:13 + | +LL | let Deprecated + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated2': text + --> $DIR/deprecation-lint.rs:419:17 + | +LL | let x = Deprecated2(1, 2, 3); + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated2': text + --> $DIR/deprecation-lint.rs:429:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated2': text + --> $DIR/deprecation-lint.rs:438:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::MethodTester::method_deprecated': text + --> $DIR/deprecation-lint.rs:28:13 + | +LL | foo.method_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::MethodTester::method_deprecated': text + --> $DIR/deprecation-lint.rs:29:9 + | +LL | Foo::method_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::MethodTester::method_deprecated': text + --> $DIR/deprecation-lint.rs:30:9 + | +LL | ::method_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:31:13 + | +LL | foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:33:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + --> $DIR/deprecation-lint.rs:37:13 + | +LL | foo.method_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + --> $DIR/deprecation-lint.rs:38:9 + | +LL | Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + --> $DIR/deprecation-lint.rs:39:9 + | +LL | ::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:40:13 + | +LL | foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:42:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::DeprecatedStruct::i': text + --> $DIR/deprecation-lint.rs:46:13 + | +LL | i: 0 //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedStruct::i': text + | ^^^^ + +error: use of deprecated item 'deprecation_lint::nested::DeprecatedStruct::i': text + --> $DIR/deprecation-lint.rs:56:13 + | +LL | i: 0 //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedStruct::i': text + | ^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:75:13 + | +LL | foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:77:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:79:13 + | +LL | foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:81:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:86:13 + | +LL | foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:87:13 + | +LL | foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Stable::override2': text + --> $DIR/deprecation-lint.rs:97:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Stable::override2': text + --> $DIR/deprecation-lint.rs:101:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Stable::override2': text + --> $DIR/deprecation-lint.rs:105:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Stable2::2': text + --> $DIR/deprecation-lint.rs:113:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'deprecation_lint::Stable2::2': text + --> $DIR/deprecation-lint.rs:118:20 + | +LL | _) + | ^ + +error: use of deprecated item 'deprecation_lint::Deprecated::inherit': text + --> $DIR/deprecation-lint.rs:126:13 + | +LL | inherit: 1, + | ^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated::inherit': text + --> $DIR/deprecation-lint.rs:130:17 + | +LL | let _ = x.inherit; + | ^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated::inherit': text + --> $DIR/deprecation-lint.rs:135:13 + | +LL | inherit: _, + | ^^^^^^^^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated2::0': text + --> $DIR/deprecation-lint.rs:146:17 + | +LL | let _ = x.0; + | ^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated2::1': text + --> $DIR/deprecation-lint.rs:148:17 + | +LL | let _ = x.1; + | ^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated2::2': text + --> $DIR/deprecation-lint.rs:150:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'deprecation_lint::Deprecated2::0': text + --> $DIR/deprecation-lint.rs:155:14 + | +LL | (_, + | ^ + +error: use of deprecated item 'deprecation_lint::Deprecated2::1': text + --> $DIR/deprecation-lint.rs:157:14 + | +LL | _, + | ^ + +error: use of deprecated item 'deprecation_lint::Deprecated2::2': text + --> $DIR/deprecation-lint.rs:159:14 + | +LL | _) + | ^ + +error: use of deprecated item 'this_crate::MethodTester::method_deprecated': text + --> $DIR/deprecation-lint.rs:257:13 + | +LL | foo.method_deprecated(); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::MethodTester::method_deprecated': text + --> $DIR/deprecation-lint.rs:258:9 + | +LL | Foo::method_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::MethodTester::method_deprecated': text + --> $DIR/deprecation-lint.rs:259:9 + | +LL | ::method_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:260:13 + | +LL | foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:262:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + --> $DIR/deprecation-lint.rs:266:13 + | +LL | foo.method_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + --> $DIR/deprecation-lint.rs:267:9 + | +LL | Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + --> $DIR/deprecation-lint.rs:268:9 + | +LL | ::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:269:13 + | +LL | foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:271:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::DeprecatedStruct::i': text + --> $DIR/deprecation-lint.rs:279:13 + | +LL | i: 0 //~ ERROR use of deprecated item 'this_crate::DeprecatedStruct::i': text + | ^^^^ + +error: use of deprecated item 'this_crate::nested::DeprecatedStruct::i': text + --> $DIR/deprecation-lint.rs:290:13 + | +LL | i: 0 //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedStruct::i': text + | ^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:301:13 + | +LL | foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:303:9 + | +LL | ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:305:13 + | +LL | foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:307:9 + | +LL | ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/deprecation-lint.rs:312:13 + | +LL | foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/deprecation-lint.rs:313:13 + | +LL | foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Stable::override2': text + --> $DIR/deprecation-lint.rs:372:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Stable::override2': text + --> $DIR/deprecation-lint.rs:376:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Stable::override2': text + --> $DIR/deprecation-lint.rs:380:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Stable2::2': text + --> $DIR/deprecation-lint.rs:388:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'this_crate2::Stable2::2': text + --> $DIR/deprecation-lint.rs:393:20 + | +LL | _) + | ^ + +error: use of deprecated item 'this_crate2::Deprecated::inherit': text + --> $DIR/deprecation-lint.rs:401:13 + | +LL | inherit: 1, + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated::inherit': text + --> $DIR/deprecation-lint.rs:405:17 + | +LL | let _ = x.inherit; + | ^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated::inherit': text + --> $DIR/deprecation-lint.rs:410:13 + | +LL | inherit: _, + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate2::Deprecated2::0': text + --> $DIR/deprecation-lint.rs:422:17 + | +LL | let _ = x.0; + | ^^^ + +error: use of deprecated item 'this_crate2::Deprecated2::1': text + --> $DIR/deprecation-lint.rs:424:17 + | +LL | let _ = x.1; + | ^^^ + +error: use of deprecated item 'this_crate2::Deprecated2::2': text + --> $DIR/deprecation-lint.rs:426:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'this_crate2::Deprecated2::0': text + --> $DIR/deprecation-lint.rs:431:14 + | +LL | (_, + | ^ + +error: use of deprecated item 'this_crate2::Deprecated2::1': text + --> $DIR/deprecation-lint.rs:433:14 + | +LL | _, + | ^ + +error: use of deprecated item 'this_crate2::Deprecated2::2': text + --> $DIR/deprecation-lint.rs:435:14 + | +LL | _) + | ^ + +error: aborting due to 120 previous errors + diff --git a/src/test/ui/compile-fail-migration/deref-non-pointer.rs b/src/test/ui/compile-fail-migration/deref-non-pointer.rs new file mode 100644 index 00000000000..1c711c0145d --- /dev/null +++ b/src/test/ui/compile-fail-migration/deref-non-pointer.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match *1 { //~ ERROR: cannot be dereferenced + _ => { panic!(); } + } +} diff --git a/src/test/ui/compile-fail-migration/deref-non-pointer.stderr b/src/test/ui/compile-fail-migration/deref-non-pointer.stderr new file mode 100644 index 00000000000..3e0ea06123d --- /dev/null +++ b/src/test/ui/compile-fail-migration/deref-non-pointer.stderr @@ -0,0 +1,9 @@ +error[E0614]: type `{integer}` cannot be dereferenced + --> $DIR/deref-non-pointer.rs:12:9 + | +LL | match *1 { //~ ERROR: cannot be dereferenced + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0614`. diff --git a/src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.rs b/src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.rs new file mode 100644 index 00000000000..3799f2ffba4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + type X; + fn method(&self) {} +} + +#[derive(Clone)] +struct Bar { + x: T::X, +} + +struct NotClone; + +impl Foo for NotClone { + type X = i8; +} + +fn main() { + Bar:: { x: 1 }.clone(); //~ ERROR +} diff --git a/src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.stderr b/src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.stderr new file mode 100644 index 00000000000..c49e3387661 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derive-assoc-type-not-impl.stderr @@ -0,0 +1,18 @@ +error[E0599]: no method named `clone` found for type `Bar` in the current scope + --> $DIR/derive-assoc-type-not-impl.rs:28:30 + | +LL | struct Bar { + | ------------------ method `clone` not found for this +... +LL | Bar:: { x: 1 }.clone(); //~ ERROR + | ^^^^^ + | + = note: the method `clone` exists but the following trait bounds were not satisfied: + `Bar : std::clone::Clone` + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `std::clone::Clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.rs b/src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.rs new file mode 100644 index 00000000000..9ff1c14f54c --- /dev/null +++ b/src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + #[derive(Clone)] + //~^ ERROR `derive` may only be applied to structs, enums and unions + type Bar; +} + +impl Bar { + #[derive(Clone)] + //~^ ERROR `derive` may only be applied to structs, enums and unions + fn bar(&self) {} +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.stderr b/src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.stderr new file mode 100644 index 00000000000..8246889b620 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derive-on-trait-item-or-impl-item.stderr @@ -0,0 +1,14 @@ +error: `derive` may only be applied to structs, enums and unions + --> $DIR/derive-on-trait-item-or-impl-item.rs:12:5 + | +LL | #[derive(Clone)] + | ^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/derive-on-trait-item-or-impl-item.rs:18:5 + | +LL | #[derive(Clone)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/derived-errors/issue-30580.rs b/src/test/ui/compile-fail-migration/derived-errors/issue-30580.rs new file mode 100644 index 00000000000..553ad0a3341 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derived-errors/issue-30580.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we do not see uninformative region-related errors +// when we get some basic type-checking failure. See #30580. + +pub struct Foo { a: u32 } +pub struct Pass<'a, 'tcx: 'a>(&'a mut &'a (), &'a &'tcx ()); + +impl<'a, 'tcx> Pass<'a, 'tcx> +{ + pub fn tcx(&self) -> &'a &'tcx () { self.1 } + fn lol(&mut self, b: &Foo) + { + b.c; //~ ERROR no field `c` on type `&Foo` + self.tcx(); + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derived-errors/issue-30580.stderr b/src/test/ui/compile-fail-migration/derived-errors/issue-30580.stderr new file mode 100644 index 00000000000..bf9a5a299e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derived-errors/issue-30580.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `c` on type `&Foo` + --> $DIR/issue-30580.rs:22:11 + | +LL | b.c; //~ ERROR no field `c` on type `&Foo` + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/compile-fail-migration/derived-errors/issue-31997.rs b/src/test/ui/compile-fail-migration/derived-errors/issue-31997.rs new file mode 100644 index 00000000000..2e1d3c55a8f --- /dev/null +++ b/src/test/ui/compile-fail-migration/derived-errors/issue-31997.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the resolve failure does not lead to downstream type errors. +// See issue #31997. + +trait TheTrait { } + +fn closure(x: F) -> Result + where F: FnMut() -> T, T: TheTrait, +{ + unimplemented!() +} + +fn foo() -> Result<(), ()> { + try!(closure(|| bar(0 as *mut _))); //~ ERROR cannot find function `bar` in this scope + Ok(()) +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/derived-errors/issue-31997.stderr b/src/test/ui/compile-fail-migration/derived-errors/issue-31997.stderr new file mode 100644 index 00000000000..25088e8654b --- /dev/null +++ b/src/test/ui/compile-fail-migration/derived-errors/issue-31997.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `bar` in this scope + --> $DIR/issue-31997.rs:23:21 + | +LL | try!(closure(|| bar(0 as *mut _))); //~ ERROR cannot find function `bar` in this scope + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.rs b/src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.rs new file mode 100644 index 00000000000..244acbf6605 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Clone)] +enum Enum { + A { + x: Error //~ ERROR + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.stderr b/src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.stderr new file mode 100644 index 00000000000..fbe9d3f7d69 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-enum-struct-variant.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::clone::Clone` is not satisfied + --> $DIR/derives-span-Clone-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::clone::Clone` is not implemented for `Error` + | + = note: required by `std::clone::Clone::clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-enum.rs b/src/test/ui/compile-fail-migration/derives-span-Clone-enum.rs new file mode 100644 index 00000000000..785a3d35430 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-enum.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Clone)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-enum.stderr b/src/test/ui/compile-fail-migration/derives-span-Clone-enum.stderr new file mode 100644 index 00000000000..b5b3c8bfc85 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-enum.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::clone::Clone` is not satisfied + --> $DIR/derives-span-Clone-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::clone::Clone` is not implemented for `Error` + | + = note: required by `std::clone::Clone::clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Clone-struct.rs new file mode 100644 index 00000000000..b1b1dc7bed1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Clone)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Clone-struct.stderr new file mode 100644 index 00000000000..ebd1e666b38 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::clone::Clone` is not satisfied + --> $DIR/derives-span-Clone-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::clone::Clone` is not implemented for `Error` + | + = note: required by `std::clone::Clone::clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.rs new file mode 100644 index 00000000000..d56e21b9a8a --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Clone)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.stderr new file mode 100644 index 00000000000..6867baad2c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Clone-tuple-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::clone::Clone` is not satisfied + --> $DIR/derives-span-Clone-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::clone::Clone` is not implemented for `Error` + | + = note: required by `std::clone::Clone::clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.rs b/src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.rs new file mode 100644 index 00000000000..4c25e482c2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Debug)] +enum Enum { + A { + x: Error //~ ERROR + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.stderr b/src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.stderr new file mode 100644 index 00000000000..f5939a2e937 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-enum-struct-variant.stderr @@ -0,0 +1,14 @@ +error[E0277]: `Error` doesn't implement `std::fmt::Debug` + --> $DIR/derives-span-Debug-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ `Error` cannot be formatted using `{:?}` + | + = help: the trait `std::fmt::Debug` is not implemented for `Error` + = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `&Error` + = note: required for the cast to the object type `dyn std::fmt::Debug` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-enum.rs b/src/test/ui/compile-fail-migration/derives-span-Debug-enum.rs new file mode 100644 index 00000000000..0cb02aa54e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-enum.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Debug)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-enum.stderr b/src/test/ui/compile-fail-migration/derives-span-Debug-enum.stderr new file mode 100644 index 00000000000..566a5786de7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-enum.stderr @@ -0,0 +1,14 @@ +error[E0277]: `Error` doesn't implement `std::fmt::Debug` + --> $DIR/derives-span-Debug-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ `Error` cannot be formatted using `{:?}` + | + = help: the trait `std::fmt::Debug` is not implemented for `Error` + = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `&Error` + = note: required for the cast to the object type `dyn std::fmt::Debug` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Debug-struct.rs new file mode 100644 index 00000000000..33fa82355ec --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Debug)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Debug-struct.stderr new file mode 100644 index 00000000000..30145a78a26 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-struct.stderr @@ -0,0 +1,14 @@ +error[E0277]: `Error` doesn't implement `std::fmt::Debug` + --> $DIR/derives-span-Debug-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ `Error` cannot be formatted using `{:?}` + | + = help: the trait `std::fmt::Debug` is not implemented for `Error` + = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `&Error` + = note: required for the cast to the object type `dyn std::fmt::Debug` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.rs new file mode 100644 index 00000000000..760ed199f6a --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Debug)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.stderr new file mode 100644 index 00000000000..963fc8a38f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Debug-tuple-struct.stderr @@ -0,0 +1,14 @@ +error[E0277]: `Error` doesn't implement `std::fmt::Debug` + --> $DIR/derives-span-Debug-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ `Error` cannot be formatted using `{:?}` + | + = help: the trait `std::fmt::Debug` is not implemented for `Error` + = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `&Error` + = note: required for the cast to the object type `dyn std::fmt::Debug` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Default-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Default-struct.rs new file mode 100644 index 00000000000..4adfe75adaf --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Default-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Default)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Default-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Default-struct.stderr new file mode 100644 index 00000000000..a9634e64fa9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Default-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::default::Default` is not satisfied + --> $DIR/derives-span-Default-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::default::Default` is not implemented for `Error` + | + = note: required by `std::default::Default::default` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.rs new file mode 100644 index 00000000000..a5e3a7cd49f --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Default)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.stderr new file mode 100644 index 00000000000..eb0ef61a57d --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Default-tuple-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::default::Default` is not satisfied + --> $DIR/derives-span-Default-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::default::Default` is not implemented for `Error` + | + = note: required by `std::default::Default::default` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.rs b/src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.rs new file mode 100644 index 00000000000..6abd1d31e66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(Eq,PartialEq)] +enum Enum { + A { + x: Error //~ ERROR + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.stderr b/src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.stderr new file mode 100644 index 00000000000..b230c014092 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-enum-struct-variant.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied + --> $DIR/derives-span-Eq-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + = note: required by `std::cmp::AssertParamIsEq` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-enum.rs b/src/test/ui/compile-fail-migration/derives-span-Eq-enum.rs new file mode 100644 index 00000000000..f361278a620 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-enum.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(Eq,PartialEq)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-enum.stderr b/src/test/ui/compile-fail-migration/derives-span-Eq-enum.stderr new file mode 100644 index 00000000000..7f6d27a311d --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-enum.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied + --> $DIR/derives-span-Eq-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + = note: required by `std::cmp::AssertParamIsEq` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Eq-struct.rs new file mode 100644 index 00000000000..7067caa6d5c --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(Eq,PartialEq)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Eq-struct.stderr new file mode 100644 index 00000000000..a9db0401959 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied + --> $DIR/derives-span-Eq-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + = note: required by `std::cmp::AssertParamIsEq` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.rs new file mode 100644 index 00000000000..1a09628b770 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(Eq,PartialEq)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.stderr new file mode 100644 index 00000000000..70f39f30eed --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Eq-tuple-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied + --> $DIR/derives-span-Eq-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + = note: required by `std::cmp::AssertParamIsEq` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.rs b/src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.rs new file mode 100644 index 00000000000..907045cce47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Hash)] +enum Enum { + A { + x: Error //~ ERROR + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.stderr b/src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.stderr new file mode 100644 index 00000000000..bde7556f7ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-enum-struct-variant.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied + --> $DIR/derives-span-Hash-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + = note: required by `std::hash::Hash::hash` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-enum.rs b/src/test/ui/compile-fail-migration/derives-span-Hash-enum.rs new file mode 100644 index 00000000000..321b9e71a0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-enum.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Hash)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-enum.stderr b/src/test/ui/compile-fail-migration/derives-span-Hash-enum.stderr new file mode 100644 index 00000000000..72b8f3ada02 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-enum.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied + --> $DIR/derives-span-Hash-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + = note: required by `std::hash::Hash::hash` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Hash-struct.rs new file mode 100644 index 00000000000..7f69c3a8e25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Hash)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Hash-struct.stderr new file mode 100644 index 00000000000..3068bcfe0a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied + --> $DIR/derives-span-Hash-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + = note: required by `std::hash::Hash::hash` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.rs new file mode 100644 index 00000000000..2dee63c4298 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(Hash)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.stderr new file mode 100644 index 00000000000..a65fbd8b6e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Hash-tuple-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::hash::Hash` is not satisfied + --> $DIR/derives-span-Hash-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::hash::Hash` is not implemented for `Error` + | + = note: required by `std::hash::Hash::hash` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.rs b/src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.rs new file mode 100644 index 00000000000..8f4e393c96a --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(Eq,PartialOrd,PartialEq)] +struct Error; + +#[derive(Ord,Eq,PartialOrd,PartialEq)] +enum Enum { + A { + x: Error //~ ERROR + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.stderr b/src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.stderr new file mode 100644 index 00000000000..5968efd5ca1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-enum-struct-variant.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Ord` is not satisfied + --> $DIR/derives-span-Ord-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `Error` + | + = note: required by `std::cmp::Ord::cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-enum.rs b/src/test/ui/compile-fail-migration/derives-span-Ord-enum.rs new file mode 100644 index 00000000000..b8ceacf3753 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-enum.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(Eq,PartialOrd,PartialEq)] +struct Error; + +#[derive(Ord,Eq,PartialOrd,PartialEq)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-enum.stderr b/src/test/ui/compile-fail-migration/derives-span-Ord-enum.stderr new file mode 100644 index 00000000000..074a8f84cec --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-enum.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Ord` is not satisfied + --> $DIR/derives-span-Ord-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::cmp::Ord` is not implemented for `Error` + | + = note: required by `std::cmp::Ord::cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Ord-struct.rs new file mode 100644 index 00000000000..2ff62bac2bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(Eq,PartialOrd,PartialEq)] +struct Error; + +#[derive(Ord,Eq,PartialOrd,PartialEq)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Ord-struct.stderr new file mode 100644 index 00000000000..2e584e6ca87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Ord` is not satisfied + --> $DIR/derives-span-Ord-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `Error` + | + = note: required by `std::cmp::Ord::cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.rs new file mode 100644 index 00000000000..24eacb71d7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(Eq,PartialOrd,PartialEq)] +struct Error; + +#[derive(Ord,Eq,PartialOrd,PartialEq)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.stderr new file mode 100644 index 00000000000..0da452f0a6a --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-Ord-tuple-struct.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Error: std::cmp::Ord` is not satisfied + --> $DIR/derives-span-Ord-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ the trait `std::cmp::Ord` is not implemented for `Error` + | + = note: required by `std::cmp::Ord::cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.rs b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.rs new file mode 100644 index 00000000000..14d94f1599e --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(PartialEq)] +enum Enum { + A { + x: Error //~ ERROR +//~^ ERROR + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.stderr new file mode 100644 index 00000000000..cad446f8326 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum-struct-variant.stderr @@ -0,0 +1,19 @@ +error[E0369]: binary operation `==` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error[E0369]: binary operation `!=` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.rs b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.rs new file mode 100644 index 00000000000..ab58bb938b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(PartialEq)] +enum Enum { + A( + Error //~ ERROR +//~^ ERROR + ) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.stderr new file mode 100644 index 00000000000..e75d0693db5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-enum.stderr @@ -0,0 +1,19 @@ +error[E0369]: binary operation `==` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error[E0369]: binary operation `!=` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.rs b/src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.rs new file mode 100644 index 00000000000..05a0990ff03 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(PartialEq)] +struct Struct { + x: Error //~ ERROR +//~^ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.stderr new file mode 100644 index 00000000000..c8cd509a824 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-struct.stderr @@ -0,0 +1,19 @@ +error[E0369]: binary operation `==` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error[E0369]: binary operation `!=` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.rs new file mode 100644 index 00000000000..cdeb7ce45bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + + +struct Error; + +#[derive(PartialEq)] +struct Struct( + Error //~ ERROR +//~^ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.stderr new file mode 100644 index 00000000000..b66189fb567 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialEq-tuple-struct.stderr @@ -0,0 +1,19 @@ +error[E0369]: binary operation `==` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error[E0369]: binary operation `!=` cannot be applied to type `Error` + --> $DIR/derives-span-PartialEq-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `Error` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.rs b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.rs new file mode 100644 index 00000000000..a5df717e06b --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(PartialOrd,PartialEq)] +enum Enum { + A { + x: Error //~ ERROR + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.stderr new file mode 100644 index 00000000000..7e55ba70c13 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum-struct-variant.stderr @@ -0,0 +1,12 @@ +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum-struct-variant.rs:19:6 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.rs b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.rs new file mode 100644 index 00000000000..3411d2f3119 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(PartialOrd,PartialEq)] +enum Enum { + A( + Error //~ ERROR + ) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.stderr new file mode 100644 index 00000000000..d8b3bd9f1bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-enum.stderr @@ -0,0 +1,12 @@ +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum.rs:19:6 + | +LL | Error //~ ERROR + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.rs b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.rs new file mode 100644 index 00000000000..1feadc2fd83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(PartialOrd,PartialEq)] +struct Struct { + x: Error //~ ERROR +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.stderr new file mode 100644 index 00000000000..afd93dce625 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-struct.stderr @@ -0,0 +1,12 @@ +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-struct.rs:18:5 + | +LL | x: Error //~ ERROR + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.rs b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.rs new file mode 100644 index 00000000000..9db0fed2d9e --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' + +#[derive(PartialEq)] +struct Error; + +#[derive(PartialOrd,PartialEq)] +struct Struct( + Error //~ ERROR +); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.stderr b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.stderr new file mode 100644 index 00000000000..a65ee40f220 --- /dev/null +++ b/src/test/ui/compile-fail-migration/derives-span-PartialOrd-tuple-struct.stderr @@ -0,0 +1,12 @@ +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-tuple-struct.rs:18:5 + | +LL | Error //~ ERROR + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/deriving-bounds.rs b/src/test/ui/compile-fail-migration/deriving-bounds.rs new file mode 100644 index 00000000000..72d06274de4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-bounds.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Send)] +//~^ ERROR this unsafe trait should be implemented explicitly +struct Test; + +#[derive(Sync)] +//~^ ERROR this unsafe trait should be implemented explicitly +struct Test1; + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/deriving-bounds.stderr b/src/test/ui/compile-fail-migration/deriving-bounds.stderr new file mode 100644 index 00000000000..2c42fd1b672 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-bounds.stderr @@ -0,0 +1,14 @@ +error: this unsafe trait should be implemented explicitly + --> $DIR/deriving-bounds.rs:11:10 + | +LL | #[derive(Send)] + | ^^^^ + +error: this unsafe trait should be implemented explicitly + --> $DIR/deriving-bounds.rs:15:10 + | +LL | #[derive(Sync)] + | ^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/deriving-copyclone.rs b/src/test/ui/compile-fail-migration/deriving-copyclone.rs new file mode 100644 index 00000000000..92fb7c5737a --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-copyclone.rs @@ -0,0 +1,48 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// this will get a no-op Clone impl +#[derive(Copy, Clone)] +struct A { + a: i32, + b: i64 +} + +// this will get a deep Clone impl +#[derive(Copy, Clone)] +struct B { + a: i32, + b: T +} + +struct C; // not Copy or Clone +#[derive(Clone)] struct D; // Clone but not Copy + +fn is_copy(_: T) {} +fn is_clone(_: T) {} + +fn main() { + // A can be copied and cloned + is_copy(A { a: 1, b: 2 }); + is_clone(A { a: 1, b: 2 }); + + // B can be copied and cloned + is_copy(B { a: 1, b: 2 }); + is_clone(B { a: 1, b: 2 }); + + // B cannot be copied or cloned + is_copy(B { a: 1, b: C }); //~ERROR Copy + is_clone(B { a: 1, b: C }); //~ERROR Clone + + // B can be cloned but not copied + is_copy(B { a: 1, b: D }); //~ERROR Copy + is_clone(B { a: 1, b: D }); +} + diff --git a/src/test/ui/compile-fail-migration/deriving-copyclone.stderr b/src/test/ui/compile-fail-migration/deriving-copyclone.stderr new file mode 100644 index 00000000000..2d0dc6649e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-copyclone.stderr @@ -0,0 +1,42 @@ +error[E0277]: the trait bound `C: std::marker::Copy` is not satisfied + --> $DIR/deriving-copyclone.rs:41:5 + | +LL | is_copy(B { a: 1, b: C }); //~ERROR Copy + | ^^^^^^^ the trait `std::marker::Copy` is not implemented for `C` + | + = note: required because of the requirements on the impl of `std::marker::Copy` for `B` +note: required by `is_copy` + --> $DIR/deriving-copyclone.rs:28:1 + | +LL | fn is_copy(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `C: std::clone::Clone` is not satisfied + --> $DIR/deriving-copyclone.rs:42:5 + | +LL | is_clone(B { a: 1, b: C }); //~ERROR Clone + | ^^^^^^^^ the trait `std::clone::Clone` is not implemented for `C` + | + = note: required because of the requirements on the impl of `std::clone::Clone` for `B` +note: required by `is_clone` + --> $DIR/deriving-copyclone.rs:29:1 + | +LL | fn is_clone(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `D: std::marker::Copy` is not satisfied + --> $DIR/deriving-copyclone.rs:45:5 + | +LL | is_copy(B { a: 1, b: D }); //~ERROR Copy + | ^^^^^^^ the trait `std::marker::Copy` is not implemented for `D` + | + = note: required because of the requirements on the impl of `std::marker::Copy` for `B` +note: required by `is_copy` + --> $DIR/deriving-copyclone.rs:28:1 + | +LL | fn is_copy(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.rs b/src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.rs new file mode 100644 index 00000000000..d388ece0844 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +#[derive(Eqr)] +//~^ ERROR cannot find derive macro `Eqr` in this scope +struct Foo; + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.stderr b/src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.stderr new file mode 100644 index 00000000000..aa0f1e21213 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-meta-unknown-trait.stderr @@ -0,0 +1,8 @@ +error: cannot find derive macro `Eqr` in this scope + --> $DIR/deriving-meta-unknown-trait.rs:13:10 + | +LL | #[derive(Eqr)] + | ^^^ help: try: `Eq` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.rs b/src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.rs new file mode 100644 index 00000000000..129c859b919 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct NoCloneOrEq; + +#[derive(PartialEq)] +struct E { + x: NoCloneOrEq //~ ERROR binary operation `==` cannot be applied to type `NoCloneOrEq` + //~^ ERROR binary operation `!=` cannot be applied to type `NoCloneOrEq` +} +#[derive(Clone)] +struct C { + x: NoCloneOrEq + //~^ ERROR `NoCloneOrEq: std::clone::Clone` is not satisfied +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.stderr b/src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.stderr new file mode 100644 index 00000000000..48d27ae1474 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-no-inner-impl-error-message.stderr @@ -0,0 +1,28 @@ +error[E0369]: binary operation `==` cannot be applied to type `NoCloneOrEq` + --> $DIR/deriving-no-inner-impl-error-message.rs:15:5 + | +LL | x: NoCloneOrEq //~ ERROR binary operation `==` cannot be applied to type `NoCloneOrEq` + | ^^^^^^^^^^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq` + +error[E0369]: binary operation `!=` cannot be applied to type `NoCloneOrEq` + --> $DIR/deriving-no-inner-impl-error-message.rs:15:5 + | +LL | x: NoCloneOrEq //~ ERROR binary operation `==` cannot be applied to type `NoCloneOrEq` + | ^^^^^^^^^^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq` + +error[E0277]: the trait bound `NoCloneOrEq: std::clone::Clone` is not satisfied + --> $DIR/deriving-no-inner-impl-error-message.rs:20:5 + | +LL | x: NoCloneOrEq + | ^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `NoCloneOrEq` + | + = note: required by `std::clone::Clone::clone` + +error: aborting due to 3 previous errors + +Some errors occurred: E0277, E0369. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/deriving-non-type.rs b/src/test/ui/compile-fail-migration/deriving-non-type.rs new file mode 100644 index 00000000000..84dd22435b8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-non-type.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +struct S; + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +trait T { } + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +impl S { } + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +impl T for S { } + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +static s: usize = 0; + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +const c: usize = 0; + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +mod m { } + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +extern "C" { } + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +type A = usize; + +#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions +fn main() { } diff --git a/src/test/ui/compile-fail-migration/deriving-non-type.stderr b/src/test/ui/compile-fail-migration/deriving-non-type.stderr new file mode 100644 index 00000000000..d9da03afb03 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-non-type.stderr @@ -0,0 +1,56 @@ +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:15:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:18:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:21:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:24:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:27:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:30:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:33:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:36:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/deriving-non-type.rs:39:1 + | +LL | #[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/compile-fail-migration/deriving-primitive.rs b/src/test/ui/compile-fail-migration/deriving-primitive.rs new file mode 100644 index 00000000000..04fdee5e3ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-primitive.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(FromPrimitive)] //~ ERROR cannot find derive macro `FromPrimitive` in this scope +enum Foo {} + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/deriving-primitive.stderr b/src/test/ui/compile-fail-migration/deriving-primitive.stderr new file mode 100644 index 00000000000..bc2d3393290 --- /dev/null +++ b/src/test/ui/compile-fail-migration/deriving-primitive.stderr @@ -0,0 +1,8 @@ +error: cannot find derive macro `FromPrimitive` in this scope + --> $DIR/deriving-primitive.rs:11:10 + | +LL | #[derive(FromPrimitive)] //~ ERROR cannot find derive macro `FromPrimitive` in this scope + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/destructure-trait-ref.rs b/src/test/ui/compile-fail-migration/destructure-trait-ref.rs new file mode 100644 index 00000000000..b5acdc12ca0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/destructure-trait-ref.rs @@ -0,0 +1,55 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The regression test for #15031 to make sure destructuring trait +// reference work properly. + +#![feature(box_patterns)] +#![feature(box_syntax)] + +trait T { fn foo(&self) {} } +impl T for isize {} + +fn main() { + // For an expression of the form: + // + // let &...&x = &..&SomeTrait; + // + // Say we have n `&` at the left hand and m `&` right hand, then: + // if n < m, we are golden; + // if n == m, it's a derefing non-derefable type error; + // if n > m, it's a type mismatch error. + + // n < m + let &x = &(&1isize as &T); + let &x = &&(&1isize as &T); + let &&x = &&(&1isize as &T); + + // n == m + let &x = &1isize as &T; //~ ERROR type `&dyn T` cannot be dereferenced + let &&x = &(&1isize as &T); //~ ERROR type `&dyn T` cannot be dereferenced + let box x = box 1isize as Box; //~ ERROR type `std::boxed::Box` cannot be dereferenced + + // n > m + let &&x = &1isize as &T; + //~^ ERROR mismatched types + //~| expected type `dyn T` + //~| found type `&_` + //~| expected trait T, found reference + let &&&x = &(&1isize as &T); + //~^ ERROR mismatched types + //~| expected type `dyn T` + //~| found type `&_` + //~| expected trait T, found reference + let box box x = box 1isize as Box; + //~^ ERROR mismatched types + //~| expected type `dyn T` + //~| found type `std::boxed::Box<_>` +} diff --git a/src/test/ui/compile-fail-migration/destructure-trait-ref.stderr b/src/test/ui/compile-fail-migration/destructure-trait-ref.stderr new file mode 100644 index 00000000000..0335fff7bce --- /dev/null +++ b/src/test/ui/compile-fail-migration/destructure-trait-ref.stderr @@ -0,0 +1,51 @@ +error[E0033]: type `&dyn T` cannot be dereferenced + --> $DIR/destructure-trait-ref.rs:36:9 + | +LL | let &x = &1isize as &T; //~ ERROR type `&dyn T` cannot be dereferenced + | ^^ type `&dyn T` cannot be dereferenced + +error[E0033]: type `&dyn T` cannot be dereferenced + --> $DIR/destructure-trait-ref.rs:37:10 + | +LL | let &&x = &(&1isize as &T); //~ ERROR type `&dyn T` cannot be dereferenced + | ^^ type `&dyn T` cannot be dereferenced + +error[E0033]: type `std::boxed::Box` cannot be dereferenced + --> $DIR/destructure-trait-ref.rs:38:9 + | +LL | let box x = box 1isize as Box; //~ ERROR type `std::boxed::Box` cannot be dereferenced + | ^^^^^ type `std::boxed::Box` cannot be dereferenced + +error[E0308]: mismatched types + --> $DIR/destructure-trait-ref.rs:41:10 + | +LL | let &&x = &1isize as &T; + | ^^ expected trait T, found reference + | + = note: expected type `dyn T` + found type `&_` + = help: did you mean `x: &dyn T`? + +error[E0308]: mismatched types + --> $DIR/destructure-trait-ref.rs:46:11 + | +LL | let &&&x = &(&1isize as &T); + | ^^ expected trait T, found reference + | + = note: expected type `dyn T` + found type `&_` + = help: did you mean `x: &dyn T`? + +error[E0308]: mismatched types + --> $DIR/destructure-trait-ref.rs:51:13 + | +LL | let box box x = box 1isize as Box; + | ^^^^^ expected trait T, found struct `std::boxed::Box` + | + = note: expected type `dyn T` + found type `std::boxed::Box<_>` + +error: aborting due to 6 previous errors + +Some errors occurred: E0033, E0308. +For more information about an error, try `rustc --explain E0033`. diff --git a/src/test/ui/compile-fail-migration/directory_ownership/foo/compiletest-ignore-dir b/src/test/ui/compile-fail-migration/directory_ownership/foo/compiletest-ignore-dir new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning/aux2.rs b/src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning/aux2.rs new file mode 100644 index 00000000000..fc4bca865c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning/aux2.rs @@ -0,0 +1,9 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning_aux2.rs b/src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning_aux2.rs new file mode 100644 index 00000000000..fc4bca865c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/foo/mod_file_not_owning_aux2.rs @@ -0,0 +1,9 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.rs b/src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.rs new file mode 100644 index 00000000000..8e631a64f7a --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that macro-expanded non-inline modules behave correctly + +macro_rules! mod_decl { + ($i:ident) => { mod $i; } +} + +mod macro_expanded_mod_helper { + mod_decl!(foo); // This should search in the folder `macro_expanded_mod_helper` +} + +fn main() { + mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block +} diff --git a/src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.stderr b/src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.stderr new file mode 100644 index 00000000000..a9efcd883c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/macro-expanded-mod.stderr @@ -0,0 +1,8 @@ +error: Cannot declare a non-inline module inside a block unless it has a path attribute + --> $DIR/macro-expanded-mod.rs:22:15 + | +LL | mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/bar.rs b/src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/bar.rs new file mode 100644 index 00000000000..4ef92981314 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test not a test, auxiliary diff --git a/src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/mod.rs b/src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/mod.rs new file mode 100644 index 00000000000..41a8c288e7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/macro_expanded_mod_helper/foo/mod.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test not a test, auxiliary + +mod_decl!(bar); diff --git a/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.rs b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.rs new file mode 100644 index 00000000000..ff93fddf9b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mod statements in non-mod.rs files are unstable + +mod mod_file_not_owning_aux1; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.stderr b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.stderr new file mode 100644 index 00000000000..e2937573997 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning.stderr @@ -0,0 +1,15 @@ +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/mod_file_not_owning_aux1.rs:14:17 + | +LL | () => { mod mod_file_not_owning_aux2; } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | } +LL | m!(); + | ----- in this macro invocation + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to mod_file_not_owning_aux1/mod.rs + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1.rs b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1.rs new file mode 100644 index 00000000000..4ac94a92e37 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test this is not a test + +macro_rules! m { + () => { mod mod_file_not_owning_aux2; } +} +m!(); diff --git a/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs new file mode 100644 index 00000000000..fc4bca865c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs @@ -0,0 +1,9 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux2.rs b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux2.rs new file mode 100644 index 00000000000..41401d640f6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux2.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test this is not a test diff --git a/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux3.rs b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux3.rs new file mode 100644 index 00000000000..3a164fd55d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/mod_file_not_owning_aux3.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test this is not a test + +mod mod_file_not_owning_aux2; diff --git a/src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.rs b/src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.rs new file mode 100644 index 00000000000..c4ede12e820 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that non-inline modules are not allowed inside blocks. + +fn main() { + mod foo; //~ ERROR Cannot declare a non-inline module inside a block +} diff --git a/src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.stderr b/src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.stderr new file mode 100644 index 00000000000..93debdd675a --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/non-inline-mod-restriction.stderr @@ -0,0 +1,8 @@ +error: Cannot declare a non-inline module inside a block unless it has a path attribute + --> $DIR/non-inline-mod-restriction.rs:14:9 + | +LL | mod foo; //~ ERROR Cannot declare a non-inline module inside a block + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.rs b/src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.rs new file mode 100644 index 00000000000..0cffb7cc9e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mod statements in non-mod.rs files are unstable + +// This is not a directory owner since the file name is not "mod.rs". +#[path = "mod_file_not_owning_aux1.rs"] +mod foo; diff --git a/src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.stderr b/src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.stderr new file mode 100644 index 00000000000..0c0b4281434 --- /dev/null +++ b/src/test/ui/compile-fail-migration/directory_ownership/unowned_mod_with_path.stderr @@ -0,0 +1,15 @@ +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/mod_file_not_owning_aux1.rs:14:17 + | +LL | () => { mod mod_file_not_owning_aux2; } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | } +LL | m!(); + | ----- in this macro invocation + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to foo/mod.rs + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.nll.stderr b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.nll.stderr new file mode 100644 index 00000000000..a8be048d7df --- /dev/null +++ b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.nll.stderr @@ -0,0 +1,12 @@ +error[E0509]: cannot move out of type `X`, which implements the `Drop` trait + --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:22:22 + | +LL | let X { x: y } = x; //~ ERROR cannot move out of type + | - ^ cannot move out of here + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.rs b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.rs new file mode 100644 index 00000000000..2621820c222 --- /dev/null +++ b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct X { + x: String, +} + +impl Drop for X { + fn drop(&mut self) { + println!("value: {}", self.x); + } +} + +fn unwrap(x: X) -> String { + let X { x: y } = x; //~ ERROR cannot move out of type + y +} + +fn main() { + let x = X { x: "hello".to_string() }; + let y = unwrap(x); + println!("contents: {}", y); +} diff --git a/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.stderr b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.stderr new file mode 100644 index 00000000000..cbf5fc61f93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-let.stderr @@ -0,0 +1,12 @@ +error[E0509]: cannot move out of type `X`, which implements the `Drop` trait + --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:22:9 + | +LL | let X { x: y } = x; //~ ERROR cannot move out of type + | ^^^^^^^-^^ + | | | + | | hint: to prevent move, use `ref y` or `ref mut y` + | cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.nll.stderr b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.nll.stderr new file mode 100644 index 00000000000..9f0d2d5f0e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.nll.stderr @@ -0,0 +1,14 @@ +error[E0509]: cannot move out of type `X`, which implements the `Drop` trait + --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:24:11 + | +LL | match x { + | ^ cannot move out of here +LL | X { x: y } => println!("contents: {}", y) + | - + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.rs b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.rs new file mode 100644 index 00000000000..38049209903 --- /dev/null +++ b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.rs @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct X { + x: String, +} + +impl Drop for X { + fn drop(&mut self) { + println!("value: {}", self.x); + } +} + +fn main() { + let x = X { x: "hello".to_string() }; + + match x { + X { x: y } => println!("contents: {}", y) + //~^ ERROR cannot move out of type `X`, which implements the `Drop` trait + } +} diff --git a/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.stderr b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.stderr new file mode 100644 index 00000000000..af2a1a06b56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/disallowed-deconstructing-destructing-struct-match.stderr @@ -0,0 +1,12 @@ +error[E0509]: cannot move out of type `X`, which implements the `Drop` trait + --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:25:9 + | +LL | X { x: y } => println!("contents: {}", y) + | ^^^^^^^-^^ + | | | + | | hint: to prevent move, use `ref y` or `ref mut y` + | cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/discrim-ill-typed.rs b/src/test/ui/compile-fail-migration/discrim-ill-typed.rs new file mode 100644 index 00000000000..62e54c3f237 --- /dev/null +++ b/src/test/ui/compile-fail-migration/discrim-ill-typed.rs @@ -0,0 +1,126 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// When explicit discriminant value has +// a type that does not match the representation +// type, rustc should fail gracefully. + +// See also run-pass/discrim-explicit-23030.rs where the input types +// are correct. + +#![allow(dead_code, unused_variables, unused_imports)] + +use std::{i8,u8,i16,u16,i32,u32,i64, u64}; + +fn f_i8() { + #[repr(i8)] + enum A { + Ok = i8::MAX - 1, + Ok2, + OhNo = 0_u8, + //~^ ERROR mismatched types + //~| expected i8, found u8 + } + + let x = A::Ok; +} + +fn f_u8() { + #[repr(u8)] + enum A { + Ok = u8::MAX - 1, + Ok2, + OhNo = 0_i8, + //~^ ERROR mismatched types + //~| expected u8, found i8 + } + + let x = A::Ok; +} + +fn f_i16() { + #[repr(i16)] + enum A { + Ok = i16::MAX - 1, + Ok2, + OhNo = 0_u16, + //~^ ERROR mismatched types + //~| expected i16, found u16 + } + + let x = A::Ok; +} + +fn f_u16() { + #[repr(u16)] + enum A { + Ok = u16::MAX - 1, + Ok2, + OhNo = 0_i16, + //~^ ERROR mismatched types + //~| expected u16, found i16 + } + + let x = A::Ok; +} + +fn f_i32() { + #[repr(i32)] + enum A { + Ok = i32::MAX - 1, + Ok2, + OhNo = 0_u32, + //~^ ERROR mismatched types + //~| expected i32, found u32 + } + + let x = A::Ok; +} + +fn f_u32() { + #[repr(u32)] + enum A { + Ok = u32::MAX - 1, + Ok2, + OhNo = 0_i32, + //~^ ERROR mismatched types + //~| expected u32, found i32 + } + + let x = A::Ok; +} + +fn f_i64() { + #[repr(i64)] + enum A { + Ok = i64::MAX - 1, + Ok2, + OhNo = 0_u64, + //~^ ERROR mismatched types + //~| expected i64, found u64 + } + + let x = A::Ok; +} + +fn f_u64() { + #[repr(u64)] + enum A { + Ok = u64::MAX - 1, + Ok2, + OhNo = 0_i64, + //~^ ERROR mismatched types + //~| expected u64, found i64 + } + + let x = A::Ok; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/discrim-ill-typed.stderr b/src/test/ui/compile-fail-migration/discrim-ill-typed.stderr new file mode 100644 index 00000000000..50911037794 --- /dev/null +++ b/src/test/ui/compile-fail-migration/discrim-ill-typed.stderr @@ -0,0 +1,51 @@ +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:27:16 + | +LL | OhNo = 0_u8, + | ^^^^ expected i8, found u8 + +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:40:16 + | +LL | OhNo = 0_i8, + | ^^^^ expected u8, found i8 + +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:53:16 + | +LL | OhNo = 0_u16, + | ^^^^^ expected i16, found u16 + +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:66:16 + | +LL | OhNo = 0_i16, + | ^^^^^ expected u16, found i16 + +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:79:16 + | +LL | OhNo = 0_u32, + | ^^^^^ expected i32, found u32 + +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:92:16 + | +LL | OhNo = 0_i32, + | ^^^^^ expected u32, found i32 + +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:105:16 + | +LL | OhNo = 0_u64, + | ^^^^^ expected i64, found u64 + +error[E0308]: mismatched types + --> $DIR/discrim-ill-typed.rs:118:16 + | +LL | OhNo = 0_i64, + | ^^^^^ expected u64, found i64 + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/diverging-fn-tail-35849.rs b/src/test/ui/compile-fail-migration/diverging-fn-tail-35849.rs new file mode 100644 index 00000000000..9ef5159cb77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/diverging-fn-tail-35849.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn assert_sizeof() -> ! { + unsafe { + ::std::mem::transmute::(panic!()) + //~^ ERROR mismatched types + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/diverging-fn-tail-35849.stderr b/src/test/ui/compile-fail-migration/diverging-fn-tail-35849.stderr new file mode 100644 index 00000000000..8f8ab79b25b --- /dev/null +++ b/src/test/ui/compile-fail-migration/diverging-fn-tail-35849.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/diverging-fn-tail-35849.rs:13:9 + | +LL | fn assert_sizeof() -> ! { + | - expected `!` because of return type +LL | unsafe { +LL | ::std::mem::transmute::(panic!()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected !, found array of 8 elements + | + = note: expected type `!` + found type `[u8; 8]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.rs b/src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.rs new file mode 100644 index 00000000000..eedad08ab55 --- /dev/null +++ b/src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// After #39485, this test used to pass, but that change was reverted +// due to numerous inference failures like #39808, so it now fails +// again. #39485 made it so that diverging types never propagate +// upward; but we now do propagate such types upward in many more +// cases. + +fn g() { + &panic!() //~ ERROR mismatched types +} + +fn f() -> isize { + (return 1, return 2) //~ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.stderr b/src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.stderr new file mode 100644 index 00000000000..603f8709c14 --- /dev/null +++ b/src/test/ui/compile-fail-migration/diverging-tuple-parts-39485.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/diverging-tuple-parts-39485.rs:18:5 + | +LL | fn g() { + | - help: try adding a return type: `-> &_` +LL | &panic!() //~ ERROR mismatched types + | ^^^^^^^^^ expected (), found reference + | + = note: expected type `()` + found type `&_` + +error[E0308]: mismatched types + --> $DIR/diverging-tuple-parts-39485.rs:22:5 + | +LL | fn f() -> isize { + | ----- expected `isize` because of return type +LL | (return 1, return 2) //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ expected isize, found tuple + | + = note: expected type `isize` + found type `(!, !)` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/does-nothing.rs b/src/test/ui/compile-fail-migration/does-nothing.rs new file mode 100644 index 00000000000..01de94bddbd --- /dev/null +++ b/src/test/ui/compile-fail-migration/does-nothing.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { println!("doing"); this_does_nothing_what_the; println!("boing"); } +//~^ ERROR cannot find value `this_does_nothing_what_the` in this scope diff --git a/src/test/ui/compile-fail-migration/does-nothing.stderr b/src/test/ui/compile-fail-migration/does-nothing.stderr new file mode 100644 index 00000000000..fa4b1f2f1c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/does-nothing.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `this_does_nothing_what_the` in this scope + --> $DIR/does-nothing.rs:11:32 + | +LL | fn main() { println!("doing"); this_does_nothing_what_the; println!("boing"); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.rs b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.rs new file mode 100644 index 00000000000..87a29038035 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a {} + +macro_rules! m { + () => { + use a::$crate; //~ ERROR unresolved import `a::$crate` + use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position + type A = a::$crate; //~ ERROR `$crate` in paths can only be used in start position + } +} + +m!(); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.stderr b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.stderr new file mode 100644 index 00000000000..c9b4f894ff6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword-2.stderr @@ -0,0 +1,31 @@ +error[E0432]: unresolved import `a::$crate` + --> $DIR/dollar-crate-is-keyword-2.rs:15:13 + | +LL | use a::$crate; //~ ERROR unresolved import `a::$crate` + | ^^^^^^^^^ no `$crate` in `a` +... +LL | m!(); + | ----- in this macro invocation + +error[E0433]: failed to resolve. `$crate` in paths can only be used in start position + --> $DIR/dollar-crate-is-keyword-2.rs:16:16 + | +LL | use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | m!(); + | ----- in this macro invocation + +error[E0433]: failed to resolve. `$crate` in paths can only be used in start position + --> $DIR/dollar-crate-is-keyword-2.rs:17:21 + | +LL | type A = a::$crate; //~ ERROR `$crate` in paths can only be used in start position + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | m!(); + | ----- in this macro invocation + +error: aborting due to 3 previous errors + +Some errors occurred: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/dollar-crate-is-keyword.rs b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword.rs new file mode 100644 index 00000000000..4a667f020ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! m { + () => { + // Avoid having more than one `$crate`-named item in the same module, + // as even though they error, they still parse as `$crate` and conflict. + mod foo { + struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate` + } + + use $crate; // OK + //~^ WARN `$crate` may not be imported + use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate` + //~^ WARN `$crate` may not be imported + } +} + +m!(); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/dollar-crate-is-keyword.stderr b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword.stderr new file mode 100644 index 00000000000..a9898973393 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dollar-crate-is-keyword.stderr @@ -0,0 +1,42 @@ +error: expected identifier, found reserved identifier `$crate` + --> $DIR/dollar-crate-is-keyword.rs:13:16 + | +LL | struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate` + | ^^^^^^ expected identifier, found reserved identifier +... +LL | m!(); + | ----- in this macro invocation + +error: expected identifier, found reserved identifier `$crate` + --> $DIR/dollar-crate-is-keyword.rs:17:23 + | +LL | use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate` + | ^^^^^^ expected identifier, found reserved identifier +... +LL | m!(); + | ----- in this macro invocation + +warning: `$crate` may not be imported + --> $DIR/dollar-crate-is-keyword.rs:15:9 + | +LL | use $crate; // OK + | ^^^^^^^^^^^ +... +LL | m!(); + | ----- in this macro invocation + | + = note: `use $crate;` was erroneously allowed and will become a hard error in a future release + +warning: `$crate` may not be imported + --> $DIR/dollar-crate-is-keyword.rs:17:9 + | +LL | use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate` + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | m!(); + | ----- in this macro invocation + | + = note: `use $crate;` was erroneously allowed and will become a hard error in a future release + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/double-type-import.rs b/src/test/ui/compile-fail-migration/double-type-import.rs new file mode 100644 index 00000000000..9629da735b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/double-type-import.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub use self::bar::X; + use self::bar::X; + //~^ ERROR the name `X` is defined multiple times + + mod bar { + pub struct X; + } +} + +fn main() { + let _ = foo::X; +} diff --git a/src/test/ui/compile-fail-migration/double-type-import.stderr b/src/test/ui/compile-fail-migration/double-type-import.stderr new file mode 100644 index 00000000000..d5d977da4aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/double-type-import.stderr @@ -0,0 +1,17 @@ +error[E0252]: the name `X` is defined multiple times + --> $DIR/double-type-import.rs:13:9 + | +LL | pub use self::bar::X; + | ------------ previous import of the type `X` here +LL | use self::bar::X; + | ^^^^^^^^^^^^ `X` reimported here + | + = note: `X` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | use self::bar::X as OtherX; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff --git a/src/test/ui/compile-fail-migration/drop-on-non-struct.rs b/src/test/ui/compile-fail-migration/drop-on-non-struct.rs new file mode 100644 index 00000000000..26b247d0d0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-on-non-struct.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +impl<'a> Drop for &'a mut isize { + //~^ ERROR the Drop trait may only be implemented on structures + //~^^ ERROR E0117 + fn drop(&mut self) { + println!("kaboom"); + } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/drop-on-non-struct.stderr b/src/test/ui/compile-fail-migration/drop-on-non-struct.stderr new file mode 100644 index 00000000000..6582df6bddc --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-on-non-struct.stderr @@ -0,0 +1,19 @@ +error[E0120]: the Drop trait may only be implemented on structures + --> $DIR/drop-on-non-struct.rs:11:19 + | +LL | impl<'a> Drop for &'a mut isize { + | ^^^^^^^^^^^^^ implementing Drop requires a struct + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/drop-on-non-struct.rs:11:1 + | +LL | impl<'a> Drop for &'a mut isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + +Some errors occurred: E0117, E0120. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.nll.stderr b/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.nll.stderr new file mode 100644 index 00000000000..30f9907401c --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.nll.stderr @@ -0,0 +1,13 @@ +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/drop-with-active-borrows-1.rs:14:10 + | +LL | let b: Vec<&str> = a.lines().collect(); + | - borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` because it is borrowed + | ^ move out of `a` occurs here +LL | for s in &b { + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.rs b/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.rs new file mode 100644 index 00000000000..903365fb909 --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let a = "".to_string(); + let b: Vec<&str> = a.lines().collect(); + drop(a); //~ ERROR cannot move out of `a` because it is borrowed + for s in &b { + println!("{}", *s); + } +} diff --git a/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.stderr b/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.stderr new file mode 100644 index 00000000000..60107427ea5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-with-active-borrows-1.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/drop-with-active-borrows-1.rs:14:10 + | +LL | let b: Vec<&str> = a.lines().collect(); + | - borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` because it is borrowed + | ^ move out of `a` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.nll.stderr b/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.nll.stderr new file mode 100644 index 00000000000..4f792a9c9d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.nll.stderr @@ -0,0 +1,18 @@ +error[E0597]: `raw_lines` does not live long enough + --> $DIR/drop-with-active-borrows-2.rs:13:5 + | +LL | raw_lines.iter().map(|l| l.trim()).collect() + | ^^^^^^^^^ borrowed value does not live long enough +LL | //~^ ERROR `raw_lines` does not live long enough +LL | } + | - `raw_lines` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 11:24... + --> $DIR/drop-with-active-borrows-2.rs:11:24 + | +LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.rs b/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.rs new file mode 100644 index 00000000000..33e4d3e62c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn read_lines_borrowed<'a>() -> Vec<&'a str> { + let raw_lines: Vec = vec!["foo ".to_string(), " bar".to_string()]; + raw_lines.iter().map(|l| l.trim()).collect() + //~^ ERROR `raw_lines` does not live long enough +} + +fn main() { + println!("{:?}", read_lines_borrowed()); +} diff --git a/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.stderr b/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.stderr new file mode 100644 index 00000000000..0fd4bf81039 --- /dev/null +++ b/src/test/ui/compile-fail-migration/drop-with-active-borrows-2.stderr @@ -0,0 +1,18 @@ +error[E0597]: `raw_lines` does not live long enough + --> $DIR/drop-with-active-borrows-2.rs:13:5 + | +LL | raw_lines.iter().map(|l| l.trim()).collect() + | ^^^^^^^^^ borrowed value does not live long enough +LL | //~^ ERROR `raw_lines` does not live long enough +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 11:24... + --> $DIR/drop-with-active-borrows-2.rs:11:24 + | +LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.rs b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.rs new file mode 100644 index 00000000000..f0968853819 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.rs @@ -0,0 +1,37 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue 22443: Reject code using non-regular types that would +// otherwise cause dropck to loop infinitely. + +use std::marker::PhantomData; + +struct Digit { + elem: T +} + +struct Node { m: PhantomData<&'static T> } + + +enum FingerTree { + Single(T), + // Bug report said Digit after Box would stack overflow (versus + // Digit before Box; see dropck_no_diverge_on_nonregular_2). + Deep( + Box>>, + Digit, + ) +} + +fn main() { + let ft = //~ ERROR overflow while adding drop-check rules for FingerTree + FingerTree::Single(1); + //~^ ERROR overflow while adding drop-check rules for FingerTree +} diff --git a/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.stderr b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.stderr new file mode 100644 index 00000000000..f4dd867ec68 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_1.stderr @@ -0,0 +1,19 @@ +error[E0320]: overflow while adding drop-check rules for FingerTree + --> $DIR/dropck_no_diverge_on_nonregular_1.rs:34:9 + | +LL | let ft = //~ ERROR overflow while adding drop-check rules for FingerTree + | ^^ + | + = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +error[E0320]: overflow while adding drop-check rules for FingerTree + --> $DIR/dropck_no_diverge_on_nonregular_1.rs:35:9 + | +LL | FingerTree::Single(1); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0320`. diff --git a/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.rs b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.rs new file mode 100644 index 00000000000..886bd6bea20 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.rs @@ -0,0 +1,36 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue 22443: Reject code using non-regular types that would +// otherwise cause dropck to loop infinitely. + +use std::marker::PhantomData; + +struct Digit { + elem: T +} + +struct Node { m: PhantomData<&'static T> } + +enum FingerTree { + Single(T), + // Bug report said Digit before Box would infinite loop (versus + // Digit after Box; see dropck_no_diverge_on_nonregular_1). + Deep( + Digit, + Box>>, + ) +} + +fn main() { + let ft = //~ ERROR overflow while adding drop-check rules for FingerTree + FingerTree::Single(1); + //~^ ERROR overflow while adding drop-check rules for FingerTree +} diff --git a/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.stderr b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.stderr new file mode 100644 index 00000000000..ae9c50a66a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_2.stderr @@ -0,0 +1,19 @@ +error[E0320]: overflow while adding drop-check rules for FingerTree + --> $DIR/dropck_no_diverge_on_nonregular_2.rs:33:9 + | +LL | let ft = //~ ERROR overflow while adding drop-check rules for FingerTree + | ^^ + | + = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +error[E0320]: overflow while adding drop-check rules for FingerTree + --> $DIR/dropck_no_diverge_on_nonregular_2.rs:34:9 + | +LL | FingerTree::Single(1); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0320`. diff --git a/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.rs b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.rs new file mode 100644 index 00000000000..45531666ecf --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.rs @@ -0,0 +1,46 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue 22443: Reject code using non-regular types that would +// otherwise cause dropck to loop infinitely. +// +// This version is just checking that we still sanely handle a trivial +// wrapper around the non-regular type. (It also demonstrates how the +// error messages will report different types depending on which type +// dropck is analyzing.) + +use std::marker::PhantomData; + +struct Digit { + elem: T +} + +struct Node { m: PhantomData<&'static T> } + +enum FingerTree { + Single(T), + // According to the bug report, Digit before Box would infinite loop. + Deep( + Digit, + Box>>, + ) +} + +enum Wrapper { + Simple, + Other(FingerTree), +} + +fn main() { + let w = //~ ERROR overflow while adding drop-check rules for std::option + Some(Wrapper::Simple::); + //~^ ERROR overflow while adding drop-check rules for std::option::Option + //~| ERROR overflow while adding drop-check rules for Wrapper +} diff --git a/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.stderr b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.stderr new file mode 100644 index 00000000000..e0089f8b298 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_no_diverge_on_nonregular_3.stderr @@ -0,0 +1,27 @@ +error[E0320]: overflow while adding drop-check rules for std::option::Option> + --> $DIR/dropck_no_diverge_on_nonregular_3.rs:42:9 + | +LL | let w = //~ ERROR overflow while adding drop-check rules for std::option + | ^ + | + = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +error[E0320]: overflow while adding drop-check rules for std::option::Option> + --> $DIR/dropck_no_diverge_on_nonregular_3.rs:43:9 + | +LL | Some(Wrapper::Simple::); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +error[E0320]: overflow while adding drop-check rules for Wrapper + --> $DIR/dropck_no_diverge_on_nonregular_3.rs:43:14 + | +LL | Some(Wrapper::Simple::); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: overflowed on FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0320`. diff --git a/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.nll.stderr b/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.nll.stderr new file mode 100644 index 00000000000..4be70a52202 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.nll.stderr @@ -0,0 +1,71 @@ +error[E0597]: `o2` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:121:13 + | +LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `o2` dropped here while still borrowed + | borrow later used here, when `o2` is dropped + +error[E0597]: `o3` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:122:13 + | +LL | o1.set1(&o3); //~ ERROR `o3` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `o3` dropped here while still borrowed + | borrow later used here, when `o3` is dropped + +error[E0597]: `o2` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:123:13 + | +LL | o2.set0(&o2); //~ ERROR `o2` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - `o2` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `o3` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:124:13 + | +LL | o2.set1(&o3); //~ ERROR `o3` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - `o3` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `o1` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:125:13 + | +LL | o3.set0(&o1); //~ ERROR `o1` does not live long enough + | ^^^ borrowed value does not live long enough +LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough +LL | } + | - + | | + | `o1` dropped here while still borrowed + | borrow later used here, when `o1` is dropped + +error[E0597]: `o2` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:126:13 + | +LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough + | ^^^ borrowed value does not live long enough +LL | } + | - `o2` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.rs b/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.rs new file mode 100644 index 00000000000..b6b7fa1a233 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.rs @@ -0,0 +1,131 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Reject mixing cyclic structure and Drop when using trait +// objects to hide the cross-references. +// +// (Compare against compile-fail/dropck_vec_cycle_checked.rs) + +use std::cell::Cell; +use id::Id; + +mod s { + use std::sync::atomic::{AtomicUsize, Ordering}; + + static S_COUNT: AtomicUsize = AtomicUsize::new(0); + + pub fn next_count() -> usize { + S_COUNT.fetch_add(1, Ordering::SeqCst) + 1 + } +} + +mod id { + use s; + #[derive(Debug)] + pub struct Id { + orig_count: usize, + count: usize, + } + + impl Id { + pub fn new() -> Id { + let c = s::next_count(); + println!("building Id {}", c); + Id { orig_count: c, count: c } + } + pub fn count(&self) -> usize { + println!("Id::count on {} returns {}", self.orig_count, self.count); + self.count + } + } + + impl Drop for Id { + fn drop(&mut self) { + println!("dropping Id {}", self.count); + self.count = 0; + } + } +} + +trait HasId { + fn count(&self) -> usize; +} + +#[derive(Debug)] +struct CheckId { + v: T +} + +#[allow(non_snake_case)] +fn CheckId(t: T) -> CheckId { CheckId{ v: t } } + +impl Drop for CheckId { + fn drop(&mut self) { + assert!(self.v.count() > 0); + } +} + +trait Obj<'a> : HasId { + fn set0(&self, b: &'a Box>); + fn set1(&self, b: &'a Box>); +} + +struct O<'a> { + id: Id, + obj0: CheckId>>>>, + obj1: CheckId>>>>, +} + +impl<'a> HasId for O<'a> { + fn count(&self) -> usize { self.id.count() } +} + +impl<'a> O<'a> { + fn new() -> Box> { + Box::new(O { + id: Id::new(), + obj0: CheckId(Cell::new(None)), + obj1: CheckId(Cell::new(None)), + }) + } +} + +impl<'a> HasId for Cell>>> { + fn count(&self) -> usize { + match self.get() { + None => 1, + Some(c) => c.count(), + } + } +} + +impl<'a> Obj<'a> for O<'a> { + fn set0(&self, b: &'a Box>) { + self.obj0.v.set(Some(b)) + } + fn set1(&self, b: &'a Box>) { + self.obj1.v.set(Some(b)) + } +} + + +fn f() { + let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + o1.set0(&o2); //~ ERROR `o2` does not live long enough + o1.set1(&o3); //~ ERROR `o3` does not live long enough + o2.set0(&o2); //~ ERROR `o2` does not live long enough + o2.set1(&o3); //~ ERROR `o3` does not live long enough + o3.set0(&o1); //~ ERROR `o1` does not live long enough + o3.set1(&o2); //~ ERROR `o2` does not live long enough +} + +fn main() { + f(); +} diff --git a/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.stderr b/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.stderr new file mode 100644 index 00000000000..ab255cf0c98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dropck_trait_cycle_checked.stderr @@ -0,0 +1,68 @@ +error[E0597]: `o2` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:121:14 + | +LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `o3` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:122:14 + | +LL | o1.set1(&o3); //~ ERROR `o3` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `o2` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:123:14 + | +LL | o2.set0(&o2); //~ ERROR `o2` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `o3` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:124:14 + | +LL | o2.set1(&o3); //~ ERROR `o3` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `o1` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:125:14 + | +LL | o3.set0(&o1); //~ ERROR `o1` does not live long enough + | ^^ borrowed value does not live long enough +LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `o2` does not live long enough + --> $DIR/dropck_trait_cycle_checked.rs:126:14 + | +LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough + | ^^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-assign-2.rs b/src/test/ui/compile-fail-migration/dst-bad-assign-2.rs new file mode 100644 index 00000000000..372f3187805 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-assign-2.rs @@ -0,0 +1,48 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Forbid assignment into a dynamically sized type. + +struct Fat { + f1: isize, + f2: &'static str, + ptr: T +} + +#[derive(PartialEq,Eq)] +struct Bar; + +#[derive(PartialEq,Eq)] +struct Bar1 { + f: isize +} + +trait ToBar { + fn to_bar(&self) -> Bar; + fn to_val(&self) -> isize; +} + +impl ToBar for Bar1 { + fn to_bar(&self) -> Bar { + Bar + } + fn to_val(&self) -> isize { + self.f + } +} + +pub fn main() { + // Assignment. + let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let z: Box = Box::new(Bar1 {f: 36}); + f5.ptr = *z; + //~^ ERROR the size for values of type + +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-assign-2.stderr b/src/test/ui/compile-fail-migration/dst-bad-assign-2.stderr new file mode 100644 index 00000000000..cfc25ebae57 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-assign-2.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `dyn ToBar` cannot be known at compilation time + --> $DIR/dst-bad-assign-2.rs:45:5 + | +LL | f5.ptr = *z; + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` + = note: to learn more, visit + = note: the left-hand-side of an assignment must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-assign-3.rs b/src/test/ui/compile-fail-migration/dst-bad-assign-3.rs new file mode 100644 index 00000000000..339cfb5443d --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-assign-3.rs @@ -0,0 +1,49 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Forbid assignment into a dynamically sized type. + +#![feature(unsized_tuple_coercion)] + +type Fat = (isize, &'static str, T); + +#[derive(PartialEq,Eq)] +struct Bar; + +#[derive(PartialEq,Eq)] +struct Bar1 { + f: isize +} + +trait ToBar { + fn to_bar(&self) -> Bar; + fn to_val(&self) -> isize; +} + +impl ToBar for Bar1 { + fn to_bar(&self) -> Bar { + Bar + } + fn to_val(&self) -> isize { + self.f + } +} + +pub fn main() { + // Assignment. + let f5: &mut Fat = &mut (5, "some str", Bar1 {f :42}); + let z: Box = Box::new(Bar1 {f: 36}); + f5.2 = Bar1 {f: 36}; + //~^ ERROR mismatched types + //~| expected type `dyn ToBar` + //~| found type `Bar1` + //~| expected trait ToBar, found struct `Bar1` + //~| ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-assign-3.stderr b/src/test/ui/compile-fail-migration/dst-bad-assign-3.stderr new file mode 100644 index 00000000000..5051972406b --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-assign-3.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/dst-bad-assign-3.rs:43:12 + | +LL | f5.2 = Bar1 {f: 36}; + | ^^^^^^^^^^^^ expected trait ToBar, found struct `Bar1` + | + = note: expected type `dyn ToBar` + found type `Bar1` + +error[E0277]: the size for values of type `dyn ToBar` cannot be known at compilation time + --> $DIR/dst-bad-assign-3.rs:43:5 + | +LL | f5.2 = Bar1 {f: 36}; + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` + = note: to learn more, visit + = note: the left-hand-side of an assignment must have a statically known size + +error: aborting due to 2 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-assign.rs b/src/test/ui/compile-fail-migration/dst-bad-assign.rs new file mode 100644 index 00000000000..9a329c636ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-assign.rs @@ -0,0 +1,51 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Forbid assignment into a dynamically sized type. + +struct Fat { + f1: isize, + f2: &'static str, + ptr: T +} + +#[derive(PartialEq,Eq)] +struct Bar; + +#[derive(PartialEq,Eq)] +struct Bar1 { + f: isize +} + +trait ToBar { + fn to_bar(&self) -> Bar; + fn to_val(&self) -> isize; +} + +impl ToBar for Bar1 { + fn to_bar(&self) -> Bar { + Bar + } + fn to_val(&self) -> isize { + self.f + } +} + +pub fn main() { + // Assignment. + let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let z: Box = Box::new(Bar1 {f: 36}); + f5.ptr = Bar1 {f: 36}; + //~^ ERROR mismatched types + //~| expected type `dyn ToBar` + //~| found type `Bar1` + //~| expected trait ToBar, found struct `Bar1` + //~| ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-assign.stderr b/src/test/ui/compile-fail-migration/dst-bad-assign.stderr new file mode 100644 index 00000000000..b911014b362 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-assign.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/dst-bad-assign.rs:45:14 + | +LL | f5.ptr = Bar1 {f: 36}; + | ^^^^^^^^^^^^ expected trait ToBar, found struct `Bar1` + | + = note: expected type `dyn ToBar` + found type `Bar1` + +error[E0277]: the size for values of type `dyn ToBar` cannot be known at compilation time + --> $DIR/dst-bad-assign.rs:45:5 + | +LL | f5.ptr = Bar1 {f: 36}; + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` + = note: to learn more, visit + = note: the left-hand-side of an assignment must have a statically known size + +error: aborting due to 2 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce1.rs b/src/test/ui/compile-fail-migration/dst-bad-coerce1.rs new file mode 100644 index 00000000000..b0de84a5300 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce1.rs @@ -0,0 +1,46 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Attempt to change the type as well as unsizing. + +#![feature(unsized_tuple_coercion)] + +struct Fat { + ptr: T +} + +struct Foo; +trait Bar { fn bar(&self) {} } + +pub fn main() { + // With a vec of isize. + let f1 = Fat { ptr: [1, 2, 3] }; + let f2: &Fat<[isize; 3]> = &f1; + let f3: &Fat<[usize]> = f2; + //~^ ERROR mismatched types + + // With a trait. + let f1 = Fat { ptr: Foo }; + let f2: &Fat = &f1; + let f3: &Fat = f2; + //~^ ERROR `Foo: Bar` is not satisfied + + // Tuple with a vec of isize. + let f1 = ([1, 2, 3],); + let f2: &([isize; 3],) = &f1; + let f3: &([usize],) = f2; + //~^ ERROR mismatched types + + // Tuple with a trait. + let f1 = (Foo,); + let f2: &(Foo,) = &f1; + let f3: &(Bar,) = f2; + //~^ ERROR `Foo: Bar` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce1.stderr b/src/test/ui/compile-fail-migration/dst-bad-coerce1.stderr new file mode 100644 index 00000000000..bb59c4d5617 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce1.stderr @@ -0,0 +1,38 @@ +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce1.rs:26:29 + | +LL | let f3: &Fat<[usize]> = f2; + | ^^ expected slice, found array of 3 elements + | + = note: expected type `&Fat<[usize]>` + found type `&Fat<[isize; 3]>` + +error[E0277]: the trait bound `Foo: Bar` is not satisfied + --> $DIR/dst-bad-coerce1.rs:32:25 + | +LL | let f3: &Fat = f2; + | ^^ the trait `Bar` is not implemented for `Foo` + | + = note: required for the cast to the object type `dyn Bar` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce1.rs:38:27 + | +LL | let f3: &([usize],) = f2; + | ^^ expected slice, found array of 3 elements + | + = note: expected type `&([usize],)` + found type `&([isize; 3],)` + +error[E0277]: the trait bound `Foo: Bar` is not satisfied + --> $DIR/dst-bad-coerce1.rs:44:23 + | +LL | let f3: &(Bar,) = f2; + | ^^ the trait `Bar` is not implemented for `Foo` + | + = note: required for the cast to the object type `dyn Bar` + +error: aborting due to 4 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce2.rs b/src/test/ui/compile-fail-migration/dst-bad-coerce2.rs new file mode 100644 index 00000000000..9e92f649b2d --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce2.rs @@ -0,0 +1,41 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Attempt to change the mutability as well as unsizing. + +struct Fat { + ptr: T +} + +struct Foo; +trait Bar {} +impl Bar for Foo {} + +pub fn main() { + // With a vec of ints. + let f1 = Fat { ptr: [1, 2, 3] }; + let f2: &Fat<[isize; 3]> = &f1; + let f3: &mut Fat<[isize]> = f2; //~ ERROR mismatched types + + // With a trait. + let f1 = Fat { ptr: Foo }; + let f2: &Fat = &f1; + let f3: &mut Fat = f2; //~ ERROR mismatched types + + // Tuple with a vec of ints. + let f1 = ([1, 2, 3],); + let f2: &([isize; 3],) = &f1; + let f3: &mut ([isize],) = f2; //~ ERROR mismatched types + + // Tuple with a trait. + let f1 = (Foo,); + let f2: &(Foo,) = &f1; + let f3: &mut (Bar,) = f2; //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce2.stderr b/src/test/ui/compile-fail-migration/dst-bad-coerce2.stderr new file mode 100644 index 00000000000..51991544a2e --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce2.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce2.rs:25:33 + | +LL | let f3: &mut Fat<[isize]> = f2; //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `&mut Fat<[isize]>` + found type `&Fat<[isize; 3]>` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce2.rs:30:29 + | +LL | let f3: &mut Fat = f2; //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `&mut Fat` + found type `&Fat` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce2.rs:35:31 + | +LL | let f3: &mut ([isize],) = f2; //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `&mut ([isize],)` + found type `&([isize; 3],)` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce2.rs:40:27 + | +LL | let f3: &mut (Bar,) = f2; //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `&mut (dyn Bar,)` + found type `&(Foo,)` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce3.nll.stderr b/src/test/ui/compile-fail-migration/dst-bad-coerce3.nll.stderr new file mode 100644 index 00000000000..bc5b4ca71cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce3.nll.stderr @@ -0,0 +1,63 @@ +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:26:32 + | +LL | let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - `f1` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:31:25 + | +LL | let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - `f1` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:36:30 + | +LL | let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - `f1` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:41:23 + | +LL | let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough + | ^^^ borrowed value does not live long enough +LL | let f3: &'a (Bar,) = f2; +LL | } + | - `f1` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce3.rs b/src/test/ui/compile-fail-migration/dst-bad-coerce3.rs new file mode 100644 index 00000000000..35a147c15bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce3.rs @@ -0,0 +1,47 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Attempt to extend the lifetime as well as unsizing. + +#![feature(unsized_tuple_coercion)] + +struct Fat { + ptr: T +} + +struct Foo; +trait Bar { fn bar(&self) {} } +impl Bar for Foo {} + +fn baz<'a>() { + // With a vec of ints. + let f1 = Fat { ptr: [1, 2, 3] }; + let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough + let f3: &'a Fat<[isize]> = f2; + + // With a trait. + let f1 = Fat { ptr: Foo }; + let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough + let f3: &'a Fat = f2; + + // Tuple with a vec of ints. + let f1 = ([1, 2, 3],); + let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough + let f3: &'a ([isize],) = f2; + + // Tuple with a trait. + let f1 = (Foo,); + let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough + let f3: &'a (Bar,) = f2; +} + +pub fn main() { + baz(); +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce3.stderr b/src/test/ui/compile-fail-migration/dst-bad-coerce3.stderr new file mode 100644 index 00000000000..3c4eb272082 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce3.stderr @@ -0,0 +1,63 @@ +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:26:33 + | +LL | let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:31:26 + | +LL | let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:36:31 + | +LL | let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error[E0597]: `f1` does not live long enough + --> $DIR/dst-bad-coerce3.rs:41:24 + | +LL | let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough + | ^^ borrowed value does not live long enough +LL | let f3: &'a (Bar,) = f2; +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... + --> $DIR/dst-bad-coerce3.rs:23:8 + | +LL | fn baz<'a>() { + | ^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce4.rs b/src/test/ui/compile-fail-migration/dst-bad-coerce4.rs new file mode 100644 index 00000000000..874b7588ff9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce4.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Attempt to coerce from unsized to sized. + +#![feature(unsized_tuple_coercion)] + +struct Fat { + ptr: T +} + +pub fn main() { + // With a vec of isizes. + let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; + let f2: &Fat<[isize; 3]> = f1; + //~^ ERROR mismatched types + //~| expected type `&Fat<[isize; 3]>` + //~| found type `&Fat<[isize]>` + //~| expected array of 3 elements, found slice + + // Tuple with a vec of isizes. + let f1: &([isize],) = &([1, 2, 3],); + let f2: &([isize; 3],) = f1; + //~^ ERROR mismatched types + //~| expected type `&([isize; 3],)` + //~| found type `&([isize],)` + //~| expected array of 3 elements, found slice +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-coerce4.stderr b/src/test/ui/compile-fail-migration/dst-bad-coerce4.stderr new file mode 100644 index 00000000000..279de13cf37 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coerce4.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce4.rs:22:32 + | +LL | let f2: &Fat<[isize; 3]> = f1; + | ^^ expected array of 3 elements, found slice + | + = note: expected type `&Fat<[isize; 3]>` + found type `&Fat<[isize]>` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coerce4.rs:30:30 + | +LL | let f2: &([isize; 3],) = f1; + | ^^ expected array of 3 elements, found slice + | + = note: expected type `&([isize; 3],)` + found type `&([isize],)` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-coercions.rs b/src/test/ui/compile-fail-migration/dst-bad-coercions.rs new file mode 100644 index 00000000000..883c16b0895 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coercions.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test implicit coercions involving DSTs and raw pointers. + +struct S; +trait T {} +impl T for S {} + +struct Foo { + f: T +} + +pub fn main() { + // Test that we cannot convert from *-ptr to &S and &T + let x: *const S = &S; + let y: &S = x; //~ ERROR mismatched types + let y: &T = x; //~ ERROR mismatched types + + // Test that we cannot convert from *-ptr to &S and &T (mut version) + let x: *mut S = &mut S; + let y: &S = x; //~ ERROR mismatched types + let y: &T = x; //~ ERROR mismatched types + + // Test that we cannot convert an immutable ptr to a mutable one using *-ptrs + let x: &mut T = &S; //~ ERROR mismatched types + let x: *mut T = &S; //~ ERROR mismatched types + let x: *mut S = &S; //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-coercions.stderr b/src/test/ui/compile-fail-migration/dst-bad-coercions.stderr new file mode 100644 index 00000000000..8901ef1caaa --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-coercions.stderr @@ -0,0 +1,72 @@ +error[E0308]: mismatched types + --> $DIR/dst-bad-coercions.rs:24:17 + | +LL | let y: &S = x; //~ ERROR mismatched types + | ^ expected &S, found *-ptr + | + = note: expected type `&S` + found type `*const S` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coercions.rs:25:17 + | +LL | let y: &T = x; //~ ERROR mismatched types + | ^ + | | + | expected &dyn T, found *-ptr + | help: consider borrowing here: `&x` + | + = note: expected type `&dyn T` + found type `*const S` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coercions.rs:29:17 + | +LL | let y: &S = x; //~ ERROR mismatched types + | ^ expected &S, found *-ptr + | + = note: expected type `&S` + found type `*mut S` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coercions.rs:30:17 + | +LL | let y: &T = x; //~ ERROR mismatched types + | ^ + | | + | expected &dyn T, found *-ptr + | help: consider borrowing here: `&x` + | + = note: expected type `&dyn T` + found type `*mut S` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coercions.rs:33:21 + | +LL | let x: &mut T = &S; //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `&mut dyn T` + found type `&S` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coercions.rs:34:21 + | +LL | let x: *mut T = &S; //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `*mut dyn T` + found type `&S` + +error[E0308]: mismatched types + --> $DIR/dst-bad-coercions.rs:35:21 + | +LL | let x: *mut S = &S; //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `*mut S` + found type `&S` + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-deep-2.rs b/src/test/ui/compile-fail-migration/dst-bad-deep-2.rs new file mode 100644 index 00000000000..a54301071ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-deep-2.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Try to initialise a DST struct where the lost information is deeply nested. +// This is an error because it requires an unsized rvalue. This is a problem +// because it would require stack allocation of an unsized temporary (*g in the +// test). + +#![feature(unsized_tuple_coercion)] + +pub fn main() { + let f: ([isize; 3],) = ([5, 6, 7],); + let g: &([isize],) = &f; + let h: &(([isize],),) = &(*g,); + //~^ ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-deep-2.stderr b/src/test/ui/compile-fail-migration/dst-bad-deep-2.stderr new file mode 100644 index 00000000000..44c88527da1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-deep-2.stderr @@ -0,0 +1,15 @@ +error[E0277]: the size for values of type `[isize]` cannot be known at compilation time + --> $DIR/dst-bad-deep-2.rs:21:30 + | +LL | let h: &(([isize],),) = &(*g,); + | ^^^^^ doesn't have a size known at compile-time + | + = help: within `(([isize],),)`, the trait `std::marker::Sized` is not implemented for `[isize]` + = note: to learn more, visit + = note: required because it appears within the type `([isize],)` + = note: required because it appears within the type `(([isize],),)` + = note: tuples must have a statically known size to be initialized + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dst-bad-deep.rs b/src/test/ui/compile-fail-migration/dst-bad-deep.rs new file mode 100644 index 00000000000..3d7e2b8f671 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-deep.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Try to initialise a DST struct where the lost information is deeply nested. +// This is an error because it requires an unsized rvalue. This is a problem +// because it would require stack allocation of an unsized temporary (*g in the +// test). + +struct Fat { + ptr: T +} + +pub fn main() { + let f: Fat<[isize; 3]> = Fat { ptr: [5, 6, 7] }; + let g: &Fat<[isize]> = &f; + let h: &Fat> = &Fat { ptr: *g }; + //~^ ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/dst-bad-deep.stderr b/src/test/ui/compile-fail-migration/dst-bad-deep.stderr new file mode 100644 index 00000000000..1ff4b984cd6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-bad-deep.stderr @@ -0,0 +1,15 @@ +error[E0277]: the size for values of type `[isize]` cannot be known at compilation time + --> $DIR/dst-bad-deep.rs:23:34 + | +LL | let h: &Fat> = &Fat { ptr: *g }; + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `Fat>`, the trait `std::marker::Sized` is not implemented for `[isize]` + = note: to learn more, visit + = note: required because it appears within the type `Fat<[isize]>` + = note: required because it appears within the type `Fat>` + = note: structs must have a statically known size to be initialized + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dst-index.nll.stderr b/src/test/ui/compile-fail-migration/dst-index.nll.stderr new file mode 100644 index 00000000000..767d8a84c04 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-index.nll.stderr @@ -0,0 +1,28 @@ +error[E0161]: cannot move a value of type str: the size of str cannot be statically determined + --> $DIR/dst-index.rs:41:5 + | +LL | S[0]; + | ^^^^ + +error[E0507]: cannot move out of borrowed content + --> $DIR/dst-index.rs:41:5 + | +LL | S[0]; + | ^^^^ cannot move out of borrowed content + +error[E0161]: cannot move a value of type dyn std::fmt::Debug: the size of dyn std::fmt::Debug cannot be statically determined + --> $DIR/dst-index.rs:44:5 + | +LL | T[0]; + | ^^^^ + +error[E0507]: cannot move out of borrowed content + --> $DIR/dst-index.rs:44:5 + | +LL | T[0]; + | ^^^^ cannot move out of borrowed content + +error: aborting due to 4 previous errors + +Some errors occurred: E0161, E0507. +For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/dst-index.rs b/src/test/ui/compile-fail-migration/dst-index.rs new file mode 100644 index 00000000000..c52458934bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-index.rs @@ -0,0 +1,47 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that overloaded index expressions with DST result types +// can't be used as rvalues + +use std::ops::Index; +use std::fmt::Debug; + +#[derive(Copy, Clone)] +struct S; + +impl Index for S { + type Output = str; + + fn index(&self, _: usize) -> &str { + "hello" + } +} + +#[derive(Copy, Clone)] +struct T; + +impl Index for T { + type Output = Debug + 'static; + + fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) { + static x: usize = 42; + &x + } +} + +fn main() { + S[0]; + //~^ ERROR cannot move out of indexed content + //~^^ ERROR E0161 + T[0]; + //~^ ERROR cannot move out of indexed content + //~^^ ERROR E0161 +} diff --git a/src/test/ui/compile-fail-migration/dst-index.stderr b/src/test/ui/compile-fail-migration/dst-index.stderr new file mode 100644 index 00000000000..7c5e79dab99 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-index.stderr @@ -0,0 +1,28 @@ +error[E0161]: cannot move a value of type str: the size of str cannot be statically determined + --> $DIR/dst-index.rs:41:5 + | +LL | S[0]; + | ^^^^ + +error[E0161]: cannot move a value of type (dyn std::fmt::Debug + 'static): the size of (dyn std::fmt::Debug + 'static) cannot be statically determined + --> $DIR/dst-index.rs:44:5 + | +LL | T[0]; + | ^^^^ + +error[E0507]: cannot move out of indexed content + --> $DIR/dst-index.rs:41:5 + | +LL | S[0]; + | ^^^^ cannot move out of indexed content + +error[E0507]: cannot move out of indexed content + --> $DIR/dst-index.rs:44:5 + | +LL | T[0]; + | ^^^^ cannot move out of indexed content + +error: aborting due to 4 previous errors + +Some errors occurred: E0161, E0507. +For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/dst-object-from-unsized-type.rs b/src/test/ui/compile-fail-migration/dst-object-from-unsized-type.rs new file mode 100644 index 00000000000..70b46b1bd79 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-object-from-unsized-type.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we cannot create objects from unsized types. + +trait Foo { fn foo(&self) {} } +impl Foo for str {} +impl Foo for [u8] {} + +fn test1(t: &T) { + let u: &Foo = t; + //~^ ERROR the size for values of type +} + +fn test2(t: &T) { + let v: &Foo = t as &Foo; + //~^ ERROR the size for values of type +} + +fn test3() { + let _: &[&Foo] = &["hi"]; + //~^ ERROR the size for values of type +} + +fn test4(x: &[u8]) { + let _: &Foo = x as &Foo; + //~^ ERROR the size for values of type +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/dst-object-from-unsized-type.stderr b/src/test/ui/compile-fail-migration/dst-object-from-unsized-type.stderr new file mode 100644 index 00000000000..67f959f297d --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-object-from-unsized-type.stderr @@ -0,0 +1,45 @@ +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/dst-object-from-unsized-type.rs:18:19 + | +LL | let u: &Foo = t; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `T` + = note: to learn more, visit + = help: consider adding a `where T: std::marker::Sized` bound + = note: required for the cast to the object type `dyn Foo` + +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/dst-object-from-unsized-type.rs:23:19 + | +LL | let v: &Foo = t as &Foo; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `T` + = note: to learn more, visit + = help: consider adding a `where T: std::marker::Sized` bound + = note: required for the cast to the object type `dyn Foo` + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/dst-object-from-unsized-type.rs:28:24 + | +LL | let _: &[&Foo] = &["hi"]; + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit + = note: required for the cast to the object type `dyn Foo` + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/dst-object-from-unsized-type.rs:33:19 + | +LL | let _: &Foo = x as &Foo; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `[u8]` + = note: to learn more, visit + = note: required for the cast to the object type `dyn Foo` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dst-rvalue.nll.stderr b/src/test/ui/compile-fail-migration/dst-rvalue.nll.stderr new file mode 100644 index 00000000000..5eadcc3def5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-rvalue.nll.stderr @@ -0,0 +1,28 @@ +error[E0161]: cannot move a value of type str: the size of str cannot be statically determined + --> $DIR/dst-rvalue.rs:16:28 + | +LL | let _x: Box = box *"hello world"; + | ^^^^^^^^^^^^^^ + +error[E0507]: cannot move out of borrowed content + --> $DIR/dst-rvalue.rs:16:28 + | +LL | let _x: Box = box *"hello world"; + | ^^^^^^^^^^^^^^ cannot move out of borrowed content + +error[E0161]: cannot move a value of type [isize]: the size of [isize] cannot be statically determined + --> $DIR/dst-rvalue.rs:21:32 + | +LL | let _x: Box<[isize]> = box *array; + | ^^^^^^ + +error[E0508]: cannot move out of type `[isize]`, a non-copy slice + --> $DIR/dst-rvalue.rs:21:32 + | +LL | let _x: Box<[isize]> = box *array; + | ^^^^^^ cannot move out of here + +error: aborting due to 4 previous errors + +Some errors occurred: E0161, E0507, E0508. +For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/dst-rvalue.rs b/src/test/ui/compile-fail-migration/dst-rvalue.rs new file mode 100644 index 00000000000..69bda8c1671 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-rvalue.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that dynamically sized rvalues are forbidden + +#![feature(box_syntax)] + +pub fn main() { + let _x: Box = box *"hello world"; + //~^ ERROR E0161 + //~^^ ERROR cannot move out of borrowed content + + let array: &[isize] = &[1, 2, 3]; + let _x: Box<[isize]> = box *array; + //~^ ERROR E0161 + //~^^ ERROR cannot move out of borrowed content +} diff --git a/src/test/ui/compile-fail-migration/dst-rvalue.stderr b/src/test/ui/compile-fail-migration/dst-rvalue.stderr new file mode 100644 index 00000000000..0957105c8a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-rvalue.stderr @@ -0,0 +1,28 @@ +error[E0161]: cannot move a value of type str: the size of str cannot be statically determined + --> $DIR/dst-rvalue.rs:16:28 + | +LL | let _x: Box = box *"hello world"; + | ^^^^^^^^^^^^^^ + +error[E0161]: cannot move a value of type [isize]: the size of [isize] cannot be statically determined + --> $DIR/dst-rvalue.rs:21:32 + | +LL | let _x: Box<[isize]> = box *array; + | ^^^^^^ + +error[E0507]: cannot move out of borrowed content + --> $DIR/dst-rvalue.rs:16:28 + | +LL | let _x: Box = box *"hello world"; + | ^^^^^^^^^^^^^^ cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/dst-rvalue.rs:21:32 + | +LL | let _x: Box<[isize]> = box *array; + | ^^^^^^ cannot move out of borrowed content + +error: aborting due to 4 previous errors + +Some errors occurred: E0161, E0507. +For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/dst-sized-trait-param.rs b/src/test/ui/compile-fail-migration/dst-sized-trait-param.rs new file mode 100644 index 00000000000..7316a48970f --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-sized-trait-param.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that when you implement a trait that has a sized type +// parameter, the corresponding value must be sized. Also that the +// self type must be sized if appropriate. + +trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized + +impl Foo<[isize]> for usize { } +//~^ ERROR the size for values of type + +impl Foo for [usize] { } +//~^ ERROR the size for values of type + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/dst-sized-trait-param.stderr b/src/test/ui/compile-fail-migration/dst-sized-trait-param.stderr new file mode 100644 index 00000000000..111d41baa57 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dst-sized-trait-param.stderr @@ -0,0 +1,21 @@ +error[E0277]: the size for values of type `[isize]` cannot be known at compilation time + --> $DIR/dst-sized-trait-param.rs:17:6 + | +LL | impl Foo<[isize]> for usize { } + | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `[isize]` + = note: to learn more, visit + +error[E0277]: the size for values of type `[usize]` cannot be known at compilation time + --> $DIR/dst-sized-trait-param.rs:20:6 + | +LL | impl Foo for [usize] { } + | ^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `[usize]` + = note: to learn more, visit + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-1.rs b/src/test/ui/compile-fail-migration/dupe-symbols-1.rs new file mode 100644 index 00000000000..9fa4eafcad0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-1.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +#![crate_type="rlib"] +#![allow(warnings)] + +#[export_name="fail"] +pub fn a() { +} + +#[export_name="fail"] +pub fn b() { +//~^ symbol `fail` is already defined +} diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-1.stderr b/src/test/ui/compile-fail-migration/dupe-symbols-1.stderr new file mode 100644 index 00000000000..c702a0f3a1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-1.stderr @@ -0,0 +1,10 @@ +error: symbol `fail` is already defined + --> $DIR/dupe-symbols-1.rs:19:1 + | +LL | / pub fn b() { +LL | | //~^ symbol `fail` is already defined +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-2.rs b/src/test/ui/compile-fail-migration/dupe-symbols-2.rs new file mode 100644 index 00000000000..1f19bd2f249 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-2.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +#![crate_type="rlib"] +#![allow(warnings)] + +pub mod a { + #[no_mangle] + pub extern fn fail() { + } +} + +pub mod b { + #[no_mangle] + pub extern fn fail() { + //~^ symbol `fail` is already defined + } +} diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-2.stderr b/src/test/ui/compile-fail-migration/dupe-symbols-2.stderr new file mode 100644 index 00000000000..5d5e9d73d7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-2.stderr @@ -0,0 +1,10 @@ +error: symbol `fail` is already defined + --> $DIR/dupe-symbols-2.rs:22:5 + | +LL | / pub extern fn fail() { +LL | | //~^ symbol `fail` is already defined +LL | | } + | |_____^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-3.rs b/src/test/ui/compile-fail-migration/dupe-symbols-3.rs new file mode 100644 index 00000000000..98a61c33c58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-3.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +#![crate_type="rlib"] +#![allow(warnings)] + +#[export_name="fail"] +pub fn a() { +} + +#[no_mangle] +pub fn fail() { +//~^ symbol `fail` is already defined +} diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-3.stderr b/src/test/ui/compile-fail-migration/dupe-symbols-3.stderr new file mode 100644 index 00000000000..6801016373d --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-3.stderr @@ -0,0 +1,10 @@ +error: symbol `fail` is already defined + --> $DIR/dupe-symbols-3.rs:19:1 + | +LL | / pub fn fail() { +LL | | //~^ symbol `fail` is already defined +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-4.rs b/src/test/ui/compile-fail-migration/dupe-symbols-4.rs new file mode 100644 index 00000000000..9e730699d25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-4.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// error-pattern: symbol `fail` is already defined +#![crate_type="rlib"] +#![allow(warnings)] + + +pub trait A { + fn fail(self); +} + +struct B; +struct C; + +impl A for B { + #[no_mangle] + fn fail(self) {} +} + +impl A for C { + #[no_mangle] + fn fail(self) {} +} diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-4.stderr b/src/test/ui/compile-fail-migration/dupe-symbols-4.stderr new file mode 100644 index 00000000000..fdbb5ce90c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-4.stderr @@ -0,0 +1,8 @@ +error: symbol `fail` is already defined + --> $DIR/dupe-symbols-4.rs:30:5 + | +LL | fn fail(self) {} + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-5.rs b/src/test/ui/compile-fail-migration/dupe-symbols-5.rs new file mode 100644 index 00000000000..eb4b50d03ca --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-5.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +#![crate_type="rlib"] +#![allow(warnings)] + +#[export_name="fail"] +static HELLO: u8 = 0; + +#[export_name="fail"] +pub fn b() { +//~^ symbol `fail` is already defined +} diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-5.stderr b/src/test/ui/compile-fail-migration/dupe-symbols-5.stderr new file mode 100644 index 00000000000..8ded374127b --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-5.stderr @@ -0,0 +1,10 @@ +error: symbol `fail` is already defined + --> $DIR/dupe-symbols-5.rs:18:1 + | +LL | / pub fn b() { +LL | | //~^ symbol `fail` is already defined +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-6.rs b/src/test/ui/compile-fail-migration/dupe-symbols-6.rs new file mode 100644 index 00000000000..6f412d9a0de --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-6.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![crate_type="rlib"] +#![allow(warnings)] + +#[export_name="fail"] +static HELLO: u8 = 0; + +#[export_name="fail"] +static HELLO_TWICE: u16 = 0; +//~^ symbol `fail` is already defined diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-6.stderr b/src/test/ui/compile-fail-migration/dupe-symbols-6.stderr new file mode 100644 index 00000000000..6dbb831832a --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-6.stderr @@ -0,0 +1,8 @@ +error: symbol `fail` is already defined + --> $DIR/dupe-symbols-6.rs:17:1 + | +LL | static HELLO_TWICE: u16 = 0; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-7.rs b/src/test/ui/compile-fail-migration/dupe-symbols-7.rs new file mode 100644 index 00000000000..c2880ba6f51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-7.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// error-pattern: entry symbol `main` defined multiple times +#![allow(warnings)] + +#[no_mangle] +fn main(){} diff --git a/src/test/ui/compile-fail-migration/dupe-symbols-7.stderr b/src/test/ui/compile-fail-migration/dupe-symbols-7.stderr new file mode 100644 index 00000000000..5fadbd5bd10 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dupe-symbols-7.stderr @@ -0,0 +1,10 @@ +error: entry symbol `main` defined multiple times + --> $DIR/dupe-symbols-7.rs:15:1 + | +LL | fn main(){} + | ^^^^^^^^^^^ + | + = help: did you use #[no_mangle] on `fn main`? Use #[start] instead + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/duplicate-parameter.rs b/src/test/ui/compile-fail-migration/duplicate-parameter.rs new file mode 100644 index 00000000000..7586bc61cd6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/duplicate-parameter.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f(a: isize, a: isize) {} +//~^ ERROR identifier `a` is bound more than once in this parameter list + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/duplicate-parameter.stderr b/src/test/ui/compile-fail-migration/duplicate-parameter.stderr new file mode 100644 index 00000000000..6cc7244ea79 --- /dev/null +++ b/src/test/ui/compile-fail-migration/duplicate-parameter.stderr @@ -0,0 +1,9 @@ +error[E0415]: identifier `a` is bound more than once in this parameter list + --> $DIR/duplicate-parameter.rs:11:16 + | +LL | fn f(a: isize, a: isize) {} + | ^ used as parameter more than once + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0415`. diff --git a/src/test/ui/compile-fail-migration/duplicate-type-parameter.rs b/src/test/ui/compile-fail-migration/duplicate-type-parameter.rs new file mode 100644 index 00000000000..3b0f8ee5bda --- /dev/null +++ b/src/test/ui/compile-fail-migration/duplicate-type-parameter.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +type Foo = Option; +//~^ ERROR the name `T` is already used + +struct Bar(T); +//~^ ERROR the name `T` is already used + +struct Baz { +//~^ ERROR the name `T` is already used + x: T, +} + +enum Boo { +//~^ ERROR the name `T` is already used + A(T), + B, +} + +fn quux(x: T) {} +//~^ ERROR the name `T` is already used + +trait Qux {} +//~^ ERROR the name `T` is already used + +impl Qux for Option {} +//~^ ERROR the name `T` is already used +//~^^ ERROR the type parameter `T` is not constrained + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/duplicate-type-parameter.stderr b/src/test/ui/compile-fail-migration/duplicate-type-parameter.stderr new file mode 100644 index 00000000000..186a1e52bb8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/duplicate-type-parameter.stderr @@ -0,0 +1,66 @@ +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/duplicate-type-parameter.rs:11:12 + | +LL | type Foo = Option; + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/duplicate-type-parameter.rs:14:14 + | +LL | struct Bar(T); + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/duplicate-type-parameter.rs:17:14 + | +LL | struct Baz { + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/duplicate-type-parameter.rs:22:12 + | +LL | enum Boo { + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/duplicate-type-parameter.rs:28:11 + | +LL | fn quux(x: T) {} + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/duplicate-type-parameter.rs:31:13 + | +LL | trait Qux {} + | - ^ already used + | | + | first use of `T` + +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/duplicate-type-parameter.rs:34:8 + | +LL | impl Qux for Option {} + | - ^ already used + | | + | first use of `T` + +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/duplicate-type-parameter.rs:34:6 + | +LL | impl Qux for Option {} + | ^ unconstrained type parameter + +error: aborting due to 8 previous errors + +Some errors occurred: E0207, E0403. +For more information about an error, try `rustc --explain E0207`. diff --git a/src/test/ui/compile-fail-migration/duplicate_entry_error.rs b/src/test/ui/compile-fail-migration/duplicate_entry_error.rs new file mode 100644 index 00000000000..176aa7cca53 --- /dev/null +++ b/src/test/ui/compile-fail-migration/duplicate_entry_error.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note-pattern: first defined in crate `std`. + +// Test for issue #31788 and E0152 + +#![feature(lang_items)] + +use std::panic::PanicInfo; + +#[lang = "panic_impl"] +fn panic_impl(info: &PanicInfo) -> ! { +//~^ ERROR: duplicate lang item found: `panic_impl`. + loop {} +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/duplicate_entry_error.stderr b/src/test/ui/compile-fail-migration/duplicate_entry_error.stderr new file mode 100644 index 00000000000..b330d2f30f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/duplicate_entry_error.stderr @@ -0,0 +1,14 @@ +error[E0152]: duplicate lang item found: `panic_impl`. + --> $DIR/duplicate_entry_error.rs:20:1 + | +LL | / fn panic_impl(info: &PanicInfo) -> ! { +LL | | //~^ ERROR: duplicate lang item found: `panic_impl`. +LL | | loop {} +LL | | } + | |_^ + | + = note: first defined in crate `std`. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0152`. diff --git a/src/test/ui/compile-fail-migration/dyn-trait-compatibility.rs b/src/test/ui/compile-fail-migration/dyn-trait-compatibility.rs new file mode 100644 index 00000000000..454b6d2f566 --- /dev/null +++ b/src/test/ui/compile-fail-migration/dyn-trait-compatibility.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +type A0 = dyn; +//~^ ERROR cannot find type `dyn` in this scope +type A1 = dyn::dyn; +//~^ ERROR Use of undeclared type or module `dyn` +type A2 = dyn; +//~^ ERROR cannot find type `dyn` in this scope +//~| ERROR cannot find type `dyn` in this scope +//~| ERROR cannot find type `dyn` in this scope +type A3 = dyn<::dyn>; +//~^ ERROR cannot find type `dyn` in this scope +//~| ERROR cannot find type `dyn` in this scope +//~| ERROR Use of undeclared type or module `dyn` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/dyn-trait-compatibility.stderr b/src/test/ui/compile-fail-migration/dyn-trait-compatibility.stderr new file mode 100644 index 00000000000..1ff3249371b --- /dev/null +++ b/src/test/ui/compile-fail-migration/dyn-trait-compatibility.stderr @@ -0,0 +1,52 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `dyn` + --> $DIR/dyn-trait-compatibility.rs:13:11 + | +LL | type A1 = dyn::dyn; + | ^^^ Use of undeclared type or module `dyn` + +error[E0433]: failed to resolve. Use of undeclared type or module `dyn` + --> $DIR/dyn-trait-compatibility.rs:19:23 + | +LL | type A3 = dyn<::dyn>; + | ^^^ Use of undeclared type or module `dyn` + +error[E0412]: cannot find type `dyn` in this scope + --> $DIR/dyn-trait-compatibility.rs:11:11 + | +LL | type A0 = dyn; + | ^^^ not found in this scope + +error[E0412]: cannot find type `dyn` in this scope + --> $DIR/dyn-trait-compatibility.rs:15:11 + | +LL | type A2 = dyn; + | ^^^ not found in this scope + +error[E0412]: cannot find type `dyn` in this scope + --> $DIR/dyn-trait-compatibility.rs:15:15 + | +LL | type A2 = dyn; + | ^^^ not found in this scope + +error[E0412]: cannot find type `dyn` in this scope + --> $DIR/dyn-trait-compatibility.rs:15:20 + | +LL | type A2 = dyn; + | ^^^ not found in this scope + +error[E0412]: cannot find type `dyn` in this scope + --> $DIR/dyn-trait-compatibility.rs:19:11 + | +LL | type A3 = dyn<::dyn>; + | ^^^ not found in this scope + +error[E0412]: cannot find type `dyn` in this scope + --> $DIR/dyn-trait-compatibility.rs:19:16 + | +LL | type A3 = dyn<::dyn>; + | ^^^ not found in this scope + +error: aborting due to 8 previous errors + +Some errors occurred: E0412, E0433. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/compile-fail-migration/edition-extern-crate-allowed.rs b/src/test/ui/compile-fail-migration/edition-extern-crate-allowed.rs new file mode 100644 index 00000000000..7368564e250 --- /dev/null +++ b/src/test/ui/compile-fail-migration/edition-extern-crate-allowed.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:edition-extern-crate-allowed.rs +// compile-flags: --edition 2015 +// compile-pass + +#![warn(rust_2018_idioms)] + +extern crate edition_extern_crate_allowed; +//~^ WARNING unused extern crate + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/edition-extern-crate-allowed.stderr b/src/test/ui/compile-fail-migration/edition-extern-crate-allowed.stderr new file mode 100644 index 00000000000..7c1ccc540c5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/edition-extern-crate-allowed.stderr @@ -0,0 +1,13 @@ +warning: unused extern crate + --> $DIR/edition-extern-crate-allowed.rs:17:1 + | +LL | extern crate edition_extern_crate_allowed; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | +note: lint level defined here + --> $DIR/edition-extern-crate-allowed.rs:15:9 + | +LL | #![warn(rust_2018_idioms)] + | ^^^^^^^^^^^^^^^^ + = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)] + diff --git a/src/test/ui/compile-fail-migration/edition-feature-ok.rs b/src/test/ui/compile-fail-migration/edition-feature-ok.rs new file mode 100644 index 00000000000..3a3a6ff95f9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/edition-feature-ok.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:--edition 2018 +// compile-pass + +#![feature(rust_2018_preview)] + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.rs b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.rs new file mode 100644 index 00000000000..4ba44fa54d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// edition:2015 + +// tests that editions work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: type annotations needed [tyvar_behind_raw_pointer] + //~^^ warning: this was previously accepted +} diff --git a/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.stderr b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.stderr new file mode 100644 index 00000000000..7fd098c98e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2015.stderr @@ -0,0 +1,17 @@ +error: type annotations needed + --> $DIR/edition-raw-pointer-method-2015.rs:20:15 + | +LL | let _ = y.is_null(); + | ^^^^^^^ + | +note: lint level defined here + --> $DIR/edition-raw-pointer-method-2015.rs:16:8 + | +LL | #[deny(warnings)] + | ^^^^^^^^ + = note: #[deny(tyvar_behind_raw_pointer)] implied by #[deny(warnings)] + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #46906 + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.rs b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.rs new file mode 100644 index 00000000000..c8548ed35b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// edition:2018 + +// tests that editions work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0699] +} diff --git a/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.stderr b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.stderr new file mode 100644 index 00000000000..0708b4bbd46 --- /dev/null +++ b/src/test/ui/compile-fail-migration/edition-raw-pointer-method-2018.stderr @@ -0,0 +1,9 @@ +error[E0699]: the type of this value must be known to call a method on a raw pointer on it + --> $DIR/edition-raw-pointer-method-2018.rs:20:15 + | +LL | let _ = y.is_null(); + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0699`. diff --git a/src/test/ui/compile-fail-migration/elided-test.rs b/src/test/ui/compile-fail-migration/elided-test.rs new file mode 100644 index 00000000000..0cdd0010a74 --- /dev/null +++ b/src/test/ui/compile-fail-migration/elided-test.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: `main` function not found + +// Since we're not compiling a test runner this function should be elided +// and the build will fail because main doesn't exist +#[test] +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/elided-test.stderr b/src/test/ui/compile-fail-migration/elided-test.stderr new file mode 100644 index 00000000000..d22eee4e8bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/elided-test.stderr @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `elided_test` + | + = note: consider adding a `main` function to `$DIR/elided-test.rs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/empty-comment.rs b/src/test/ui/compile-fail-migration/empty-comment.rs new file mode 100644 index 00000000000..a5568ff826b --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-comment.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// `/**/` was previously regarded as a doc comment because it starts with `/**` and ends with `*/`. +// This could break some internal logic that assumes the length of a doc comment is at least 5, +// leading to an ICE. + +macro_rules! one_arg_macro { + ($fmt:expr) => (print!(concat!($fmt, "\n"))); +} + +fn main() { + one_arg_macro!(/**/); //~ ERROR unexpected end +} diff --git a/src/test/ui/compile-fail-migration/empty-comment.stderr b/src/test/ui/compile-fail-migration/empty-comment.stderr new file mode 100644 index 00000000000..d6990c4eaeb --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-comment.stderr @@ -0,0 +1,8 @@ +error: unexpected end of macro invocation + --> $DIR/empty-comment.rs:20:5 + | +LL | one_arg_macro!(/**/); //~ ERROR unexpected end + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/empty-extern-arg.rs b/src/test/ui/compile-fail-migration/empty-extern-arg.rs new file mode 100644 index 00000000000..8791481d9e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-extern-arg.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --extern std= +// error-pattern: can't find crate for `std` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/empty-extern-arg.stderr b/src/test/ui/compile-fail-migration/empty-extern-arg.stderr new file mode 100644 index 00000000000..c81a647b094 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-extern-arg.stderr @@ -0,0 +1,7 @@ +error: extern location for std does not exist: + +error[E0463]: can't find crate for `std` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/empty-linkname.rs b/src/test/ui/compile-fail-migration/empty-linkname.rs new file mode 100644 index 00000000000..20e0f9cd0b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-linkname.rs @@ -0,0 +1,15 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name = "")] //~ ERROR: given with empty name +extern { +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/empty-linkname.stderr b/src/test/ui/compile-fail-migration/empty-linkname.stderr new file mode 100644 index 00000000000..9a637aa7833 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-linkname.stderr @@ -0,0 +1,9 @@ +error[E0454]: #[link(name = "")] given with empty name + --> $DIR/empty-linkname.rs:11:1 + | +LL | #[link(name = "")] //~ ERROR: given with empty name + | ^^^^^^^^^^^^^^^^^^ empty name given + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0454`. diff --git a/src/test/ui/compile-fail-migration/empty-macro-use.rs b/src/test/ui/compile-fail-migration/empty-macro-use.rs new file mode 100644 index 00000000000..823a7426079 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-macro-use.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:two_macros.rs + +#[macro_use()] +extern crate two_macros; + +pub fn main() { + macro_two!(); + //~^ ERROR cannot find macro +} diff --git a/src/test/ui/compile-fail-migration/empty-macro-use.stderr b/src/test/ui/compile-fail-migration/empty-macro-use.stderr new file mode 100644 index 00000000000..8feb0930718 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-macro-use.stderr @@ -0,0 +1,8 @@ +error: cannot find macro `macro_two!` in this scope + --> $DIR/empty-macro-use.rs:17:5 + | +LL | macro_two!(); + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/empty-never-array.rs b/src/test/ui/compile-fail-migration/empty-never-array.rs new file mode 100644 index 00000000000..53b24e17319 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-never-array.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] + +enum Helper { + T(T, [!; 0]), + #[allow(dead_code)] + U(U), +} + +fn transmute(t: T) -> U { + let Helper::U(u) = Helper::T(t, []); + //~^ ERROR refutable pattern in local binding: `T(_, _)` not covered + u +} + +fn main() { + println!("{:?}", transmute::<&str, (*const u8, u64)>("type safety")); +} diff --git a/src/test/ui/compile-fail-migration/empty-never-array.stderr b/src/test/ui/compile-fail-migration/empty-never-array.stderr new file mode 100644 index 00000000000..d9ef2f30aab --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-never-array.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in local binding: `T(_, _)` not covered + --> $DIR/empty-never-array.rs:20:9 + | +LL | let Helper::U(u) = Helper::T(t, []); + | ^^^^^^^^^^^^ pattern `T(_, _)` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-expr.rs b/src/test/ui/compile-fail-migration/empty-struct-braces-expr.rs new file mode 100644 index 00000000000..3096e8f8313 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-expr.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Can't use empty braced struct as constant or constructor function + +// aux-build:empty-struct.rs + +extern crate empty_struct; +use empty_struct::*; + +struct Empty1 {} + +enum E { + Empty3 {} +} + +fn main() { + let e1 = Empty1; //~ ERROR expected value, found struct `Empty1` + let e1 = Empty1(); //~ ERROR expected function, found struct `Empty1` + let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3` + let e3 = E::Empty3(); //~ ERROR expected function, found struct variant `E::Empty3` + + let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1` + let xe1 = XEmpty1(); //~ ERROR expected function, found struct `XEmpty1` + let xe3 = XE::Empty3; //~ ERROR no variant named `Empty3` found for type + let xe3 = XE::Empty3(); //~ ERROR no variant named `Empty3` found for type +} diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-expr.stderr b/src/test/ui/compile-fail-migration/empty-struct-braces-expr.stderr new file mode 100644 index 00000000000..9b6114875e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-expr.stderr @@ -0,0 +1,68 @@ +error[E0423]: expected value, found struct `Empty1` + --> $DIR/empty-struct-braces-expr.rs:25:14 + | +LL | let e1 = Empty1; //~ ERROR expected value, found struct `Empty1` + | ^^^^^^ + | | + | did you mean `XEmpty2`? + | did you mean `Empty1 { /* fields */ }`? + +error[E0423]: expected function, found struct `Empty1` + --> $DIR/empty-struct-braces-expr.rs:26:14 + | +LL | let e1 = Empty1(); //~ ERROR expected function, found struct `Empty1` + | ^^^^^^ + | | + | did you mean `XEmpty2`? + | did you mean `Empty1 { /* fields */ }`? + +error[E0423]: expected value, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-expr.rs:27:14 + | +LL | let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3` + | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? + +error[E0423]: expected function, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-expr.rs:28:14 + | +LL | let e3 = E::Empty3(); //~ ERROR expected function, found struct variant `E::Empty3` + | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? + +error[E0423]: expected value, found struct `XEmpty1` + --> $DIR/empty-struct-braces-expr.rs:30:15 + | +LL | let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1` + | ^^^^^^^ + | | + | did you mean `XEmpty2`? + | did you mean `XEmpty1 { /* fields */ }`? + +error[E0423]: expected function, found struct `XEmpty1` + --> $DIR/empty-struct-braces-expr.rs:31:15 + | +LL | let xe1 = XEmpty1(); //~ ERROR expected function, found struct `XEmpty1` + | ^^^^^^^ + | | + | did you mean `XEmpty2`? + | did you mean `XEmpty1 { /* fields */ }`? + +error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the current scope + --> $DIR/empty-struct-braces-expr.rs:32:15 + | +LL | let xe3 = XE::Empty3; //~ ERROR no variant named `Empty3` found for type + | ^^^^^^^^^^ variant not found in `empty_struct::XE` + | + = note: did you mean `empty_struct::XE::XEmpty3`? + +error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the current scope + --> $DIR/empty-struct-braces-expr.rs:33:15 + | +LL | let xe3 = XE::Empty3(); //~ ERROR no variant named `Empty3` found for type + | ^^^^^^^^^^ variant not found in `empty_struct::XE` + | + = note: did you mean `empty_struct::XE::XEmpty3`? + +error: aborting due to 8 previous errors + +Some errors occurred: E0423, E0599. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.rs b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.rs new file mode 100644 index 00000000000..e527170e9f9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.rs @@ -0,0 +1,44 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Can't use empty braced struct as constant pattern + +// aux-build:empty-struct.rs + +extern crate empty_struct; +use empty_struct::*; + +struct Empty1 {} + +enum E { + Empty3 {} +} + +fn main() { + let e1 = Empty1 {}; + let e3 = E::Empty3 {}; + let xe1 = XEmpty1 {}; + let xe3 = XE::XEmpty3 {}; + + match e1 { + Empty1 => () // Not an error, `Empty1` is interpreted as a new binding + } + match e3 { + E::Empty3 => () + //~^ ERROR expected unit struct/variant or constant, found struct variant `E::Empty3` + } + match xe1 { + XEmpty1 => () // Not an error, `XEmpty1` is interpreted as a new binding + } + match xe3 { + XE::XEmpty3 => () + //~^ ERROR expected unit struct/variant or constant, found struct variant `XE::XEmpty3` + } +} diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.stderr b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.stderr new file mode 100644 index 00000000000..aad47f4d954 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-1.stderr @@ -0,0 +1,18 @@ +error[E0532]: expected unit struct/variant or constant, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-pat-1.rs:34:9 + | +LL | E::Empty3 => () + | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? + +error[E0532]: expected unit struct/variant or constant, found struct variant `XE::XEmpty3` + --> $DIR/empty-struct-braces-pat-1.rs:41:9 + | +LL | XE::XEmpty3 => () + | ^^^^------- + | | | + | | did you mean `XEmpty4`? + | did you mean `XE::XEmpty3 { /* fields */ }`? + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0532`. diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.rs b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.rs new file mode 100644 index 00000000000..d3b13457dc6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.rs @@ -0,0 +1,36 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Can't use empty braced struct as enum pattern + +// aux-build:empty-struct.rs + +extern crate empty_struct; +use empty_struct::*; + +struct Empty1 {} + +fn main() { + let e1 = Empty1 {}; + let xe1 = XEmpty1 {}; + + match e1 { + Empty1() => () //~ ERROR expected tuple struct/variant, found struct `Empty1` + } + match xe1 { + XEmpty1() => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` + } + match e1 { + Empty1(..) => () //~ ERROR expected tuple struct/variant, found struct `Empty1` + } + match xe1 { + XEmpty1(..) => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` + } +} diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.stderr b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.stderr new file mode 100644 index 00000000000..26fb42c4e94 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-2.stderr @@ -0,0 +1,39 @@ +error[E0532]: expected tuple struct/variant, found struct `Empty1` + --> $DIR/empty-struct-braces-pat-2.rs:25:9 + | +LL | Empty1() => () //~ ERROR expected tuple struct/variant, found struct `Empty1` + | ^^^^^^ + | | + | did you mean `XEmpty6`? + | did you mean `Empty1 { /* fields */ }`? + +error[E0532]: expected tuple struct/variant, found struct `XEmpty1` + --> $DIR/empty-struct-braces-pat-2.rs:28:9 + | +LL | XEmpty1() => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` + | ^^^^^^^ + | | + | did you mean `XEmpty6`? + | did you mean `XEmpty1 { /* fields */ }`? + +error[E0532]: expected tuple struct/variant, found struct `Empty1` + --> $DIR/empty-struct-braces-pat-2.rs:31:9 + | +LL | Empty1(..) => () //~ ERROR expected tuple struct/variant, found struct `Empty1` + | ^^^^^^ + | | + | did you mean `XEmpty6`? + | did you mean `Empty1 { /* fields */ }`? + +error[E0532]: expected tuple struct/variant, found struct `XEmpty1` + --> $DIR/empty-struct-braces-pat-2.rs:34:9 + | +LL | XEmpty1(..) => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` + | ^^^^^^^ + | | + | did you mean `XEmpty6`? + | did you mean `XEmpty1 { /* fields */ }`? + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0532`. diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.rs b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.rs new file mode 100644 index 00000000000..d6c5b953492 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.rs @@ -0,0 +1,42 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Can't use empty braced struct as enum pattern + +// aux-build:empty-struct.rs + +extern crate empty_struct; +use empty_struct::*; + +enum E { + Empty3 {} +} + +fn main() { + let e3 = E::Empty3 {}; + let xe3 = XE::XEmpty3 {}; + + match e3 { + E::Empty3() => () + //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3` + } + match xe3 { + XE::XEmpty3() => () + //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3` + } + match e3 { + E::Empty3(..) => () + //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3` + } + match xe3 { + XE::XEmpty3(..) => () + //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3 + } +} diff --git a/src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.stderr b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.stderr new file mode 100644 index 00000000000..389bf0a65c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-braces-pat-3.stderr @@ -0,0 +1,33 @@ +error[E0532]: expected tuple struct/variant, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-pat-3.rs:27:9 + | +LL | E::Empty3() => () + | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? + +error[E0532]: expected tuple struct/variant, found struct variant `XE::XEmpty3` + --> $DIR/empty-struct-braces-pat-3.rs:31:9 + | +LL | XE::XEmpty3() => () + | ^^^^------- + | | | + | | did you mean `XEmpty5`? + | did you mean `XE::XEmpty3 { /* fields */ }`? + +error[E0532]: expected tuple struct/variant, found struct variant `E::Empty3` + --> $DIR/empty-struct-braces-pat-3.rs:35:9 + | +LL | E::Empty3(..) => () + | ^^^^^^^^^ did you mean `E::Empty3 { /* fields */ }`? + +error[E0532]: expected tuple struct/variant, found struct variant `XE::XEmpty3` + --> $DIR/empty-struct-braces-pat-3.rs:39:9 + | +LL | XE::XEmpty3(..) => () + | ^^^^------- + | | | + | | did you mean `XEmpty5`? + | did you mean `XE::XEmpty3 { /* fields */ }`? + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0532`. diff --git a/src/test/ui/compile-fail-migration/empty-struct-tuple-pat.rs b/src/test/ui/compile-fail-migration/empty-struct-tuple-pat.rs new file mode 100644 index 00000000000..5e683eafade --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-tuple-pat.rs @@ -0,0 +1,47 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Can't use unit struct as enum pattern + +// aux-build:empty-struct.rs + +extern crate empty_struct; +use empty_struct::*; + +struct Empty2(); + +enum E { + Empty4() +} + +// remove attribute after warning cycle and promoting warnings to errors +fn main() { + let e2 = Empty2(); + let e4 = E::Empty4(); + let xe6 = XEmpty6(); + let xe5 = XE::XEmpty5(); + + match e2 { + Empty2 => () //~ ERROR match bindings cannot shadow tuple structs + } + match xe6 { + XEmpty6 => () //~ ERROR match bindings cannot shadow tuple structs + } + + match e4 { + E::Empty4 => () + //~^ ERROR expected unit struct/variant or constant, found tuple variant `E::Empty4` + } + match xe5 { + XE::XEmpty5 => (), + //~^ ERROR expected unit struct/variant or constant, found tuple variant `XE::XEmpty5` + _ => {}, + } +} diff --git a/src/test/ui/compile-fail-migration/empty-struct-tuple-pat.stderr b/src/test/ui/compile-fail-migration/empty-struct-tuple-pat.stderr new file mode 100644 index 00000000000..3d219b1752f --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-tuple-pat.stderr @@ -0,0 +1,36 @@ +error[E0530]: match bindings cannot shadow tuple structs + --> $DIR/empty-struct-tuple-pat.rs:32:9 + | +LL | struct Empty2(); + | ---------------- a tuple struct `Empty2` is defined here +... +LL | Empty2 => () //~ ERROR match bindings cannot shadow tuple structs + | ^^^^^^ cannot be named the same as a tuple struct + +error[E0530]: match bindings cannot shadow tuple structs + --> $DIR/empty-struct-tuple-pat.rs:35:9 + | +LL | use empty_struct::*; + | --------------- a tuple struct `XEmpty6` is imported here +... +LL | XEmpty6 => () //~ ERROR match bindings cannot shadow tuple structs + | ^^^^^^^ cannot be named the same as a tuple struct + +error[E0532]: expected unit struct/variant or constant, found tuple variant `E::Empty4` + --> $DIR/empty-struct-tuple-pat.rs:39:9 + | +LL | E::Empty4 => () + | ^^^^^^^^^ not a unit struct/variant or constant + +error[E0532]: expected unit struct/variant or constant, found tuple variant `XE::XEmpty5` + --> $DIR/empty-struct-tuple-pat.rs:43:9 + | +LL | XE::XEmpty5 => (), + | ^^^^------- + | | + | did you mean `XEmpty4`? + +error: aborting due to 4 previous errors + +Some errors occurred: E0530, E0532. +For more information about an error, try `rustc --explain E0530`. diff --git a/src/test/ui/compile-fail-migration/empty-struct-unit-pat.rs b/src/test/ui/compile-fail-migration/empty-struct-unit-pat.rs new file mode 100644 index 00000000000..532c2d85053 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-unit-pat.rs @@ -0,0 +1,59 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Can't use unit struct as tuple struct pattern + +// aux-build:empty-struct.rs + +extern crate empty_struct; +use empty_struct::*; + +struct Empty2; + +enum E { + Empty4 +} + +fn main() { + let e2 = Empty2; + let e4 = E::Empty4; + let xe2 = XEmpty2; + let xe4 = XE::XEmpty4; + + match e2 { + Empty2() => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` + } + match xe2 { + XEmpty2() => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` + } + match e2 { + Empty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` + } + match xe2 { + XEmpty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` + } + + match e4 { + E::Empty4() => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` + } + match xe4 { + XE::XEmpty4() => (), + //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4` + _ => {}, + } + match e4 { + E::Empty4(..) => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` + } + match xe4 { + XE::XEmpty4(..) => (), + //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4` + _ => {}, + } +} diff --git a/src/test/ui/compile-fail-migration/empty-struct-unit-pat.stderr b/src/test/ui/compile-fail-migration/empty-struct-unit-pat.stderr new file mode 100644 index 00000000000..042b53521c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/empty-struct-unit-pat.stderr @@ -0,0 +1,55 @@ +error[E0532]: expected tuple struct/variant, found unit struct `Empty2` + --> $DIR/empty-struct-unit-pat.rs:31:9 + | +LL | Empty2() => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` + | ^^^^^^ did you mean `XEmpty6`? + +error[E0532]: expected tuple struct/variant, found unit struct `XEmpty2` + --> $DIR/empty-struct-unit-pat.rs:34:9 + | +LL | XEmpty2() => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` + | ^^^^^^^ did you mean `XEmpty6`? + +error[E0532]: expected tuple struct/variant, found unit struct `Empty2` + --> $DIR/empty-struct-unit-pat.rs:37:9 + | +LL | Empty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` + | ^^^^^^ did you mean `XEmpty6`? + +error[E0532]: expected tuple struct/variant, found unit struct `XEmpty2` + --> $DIR/empty-struct-unit-pat.rs:40:9 + | +LL | XEmpty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` + | ^^^^^^^ did you mean `XEmpty6`? + +error[E0532]: expected tuple struct/variant, found unit variant `E::Empty4` + --> $DIR/empty-struct-unit-pat.rs:44:9 + | +LL | E::Empty4() => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` + | ^^^^^^^^^ not a tuple struct/variant + +error[E0532]: expected tuple struct/variant, found unit variant `XE::XEmpty4` + --> $DIR/empty-struct-unit-pat.rs:47:9 + | +LL | XE::XEmpty4() => (), + | ^^^^------- + | | + | did you mean `XEmpty5`? + +error[E0532]: expected tuple struct/variant, found unit variant `E::Empty4` + --> $DIR/empty-struct-unit-pat.rs:52:9 + | +LL | E::Empty4(..) => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` + | ^^^^^^^^^ not a tuple struct/variant + +error[E0532]: expected tuple struct/variant, found unit variant `XE::XEmpty4` + --> $DIR/empty-struct-unit-pat.rs:55:9 + | +LL | XE::XEmpty4(..) => (), + | ^^^^------- + | | + | did you mean `XEmpty5`? + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0532`. diff --git a/src/test/ui/compile-fail-migration/enable-unstable-lib-feature.rs b/src/test/ui/compile-fail-migration/enable-unstable-lib-feature.rs new file mode 100644 index 00000000000..b10a0a60f14 --- /dev/null +++ b/src/test/ui/compile-fail-migration/enable-unstable-lib-feature.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that enabling an unstable feature disables warnings + +// aux-build:stability_cfg2.rs + +#![feature(unstable_test_feature)] +#![deny(non_snake_case)] // To trigger a hard error + +// Shouldn't generate a warning about unstable features +#[allow(unused_extern_crates)] +extern crate stability_cfg2; + +pub fn BOGUS() { } //~ ERROR + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/enable-unstable-lib-feature.stderr b/src/test/ui/compile-fail-migration/enable-unstable-lib-feature.stderr new file mode 100644 index 00000000000..20b2eb51fcb --- /dev/null +++ b/src/test/ui/compile-fail-migration/enable-unstable-lib-feature.stderr @@ -0,0 +1,14 @@ +error: function `BOGUS` should have a snake case name such as `bogus` + --> $DIR/enable-unstable-lib-feature.rs:22:1 + | +LL | pub fn BOGUS() { } //~ ERROR + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/enable-unstable-lib-feature.rs:16:9 + | +LL | #![deny(non_snake_case)] // To trigger a hard error + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/enum-discrim-autosizing.rs b/src/test/ui/compile-fail-migration/enum-discrim-autosizing.rs new file mode 100644 index 00000000000..3a243330ad9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-discrim-autosizing.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// With no repr attribute the discriminant will default to isize. +// On 32-bit architectures this is equivalent to i32 so the variants +// collide. On other architectures we need compilation to fail anyway, +// so force the repr. +#[cfg_attr(not(target_pointer_width = "32"), repr(i32))] +enum Eu64 { + Au64 = 0, + Bu64 = 0x8000_0000_0000_0000 //~ERROR already exists +} + diff --git a/src/test/ui/compile-fail-migration/enum-discrim-autosizing.stderr b/src/test/ui/compile-fail-migration/enum-discrim-autosizing.stderr new file mode 100644 index 00000000000..3b4ac436898 --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-discrim-autosizing.stderr @@ -0,0 +1,16 @@ +error[E0601]: `main` function not found in crate `enum_discrim_autosizing` + | + = note: consider adding a `main` function to `$DIR/enum-discrim-autosizing.rs` + +error[E0081]: discriminant value `0` already exists + --> $DIR/enum-discrim-autosizing.rs:18:12 + | +LL | Au64 = 0, + | - first use of `0` +LL | Bu64 = 0x8000_0000_0000_0000 //~ERROR already exists + | ^^^^^^^^^^^^^^^^^^^^^ enum already has `0` + +error: aborting due to 2 previous errors + +Some errors occurred: E0081, E0601. +For more information about an error, try `rustc --explain E0081`. diff --git a/src/test/ui/compile-fail-migration/enum-discrim-too-small.rs b/src/test/ui/compile-fail-migration/enum-discrim-too-small.rs new file mode 100644 index 00000000000..393a67be57f --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-discrim-too-small.rs @@ -0,0 +1,49 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#[repr(u8)] +enum Eu8 { + Au8 = 23, + Bu8 = 223, + Cu8 = -23, + //~^ ERROR cannot apply unary operator `-` to type `u8` +} + +#[repr(u16)] +enum Eu16 { + Au16 = 23, + Bu16 = 55555, + Cu16 = -22333, + //~^ ERROR cannot apply unary operator `-` to type `u16` +} + +#[repr(u32)] +enum Eu32 { + Au32 = 23, + Bu32 = 3_000_000_000, + Cu32 = -2_000_000_000, + //~^ ERROR cannot apply unary operator `-` to type `u32` +} + +#[repr(u64)] +enum Eu64 { + Au32 = 23, + Bu32 = 3_000_000_000, + Cu32 = -2_000_000_000, + //~^ ERROR cannot apply unary operator `-` to type `u64` +} + +// u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`. This is a +// little counterintuitive, but since the discriminant can store all the bits, and extracting it +// with a cast requires specifying the signedness, there is no loss of information in those cases. +// This also applies to isize and usize on 64-bit targets. + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/enum-discrim-too-small.stderr b/src/test/ui/compile-fail-migration/enum-discrim-too-small.stderr new file mode 100644 index 00000000000..4c8ff52c12b --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-discrim-too-small.stderr @@ -0,0 +1,35 @@ +error[E0600]: cannot apply unary operator `-` to type `u8` + --> $DIR/enum-discrim-too-small.rs:16:11 + | +LL | Cu8 = -23, + | ^^^ cannot apply unary operator `-` + | + = note: unsigned values cannot be negated + +error[E0600]: cannot apply unary operator `-` to type `u16` + --> $DIR/enum-discrim-too-small.rs:24:12 + | +LL | Cu16 = -22333, + | ^^^^^^ cannot apply unary operator `-` + | + = note: unsigned values cannot be negated + +error[E0600]: cannot apply unary operator `-` to type `u32` + --> $DIR/enum-discrim-too-small.rs:32:12 + | +LL | Cu32 = -2_000_000_000, + | ^^^^^^^^^^^^^^ cannot apply unary operator `-` + | + = note: unsigned values cannot be negated + +error[E0600]: cannot apply unary operator `-` to type `u64` + --> $DIR/enum-discrim-too-small.rs:40:12 + | +LL | Cu32 = -2_000_000_000, + | ^^^^^^^^^^^^^^ cannot apply unary operator `-` + | + = note: unsigned values cannot be negated + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0600`. diff --git a/src/test/ui/compile-fail-migration/enum-discrim-too-small2.rs b/src/test/ui/compile-fail-migration/enum-discrim-too-small2.rs new file mode 100644 index 00000000000..d66716c14c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-discrim-too-small2.rs @@ -0,0 +1,47 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(overflowing_literals)] +#![allow(dead_code)] + +#[repr(i8)] +enum Ei8 { + Ai8 = 23, + Bi8 = -23, + Ci8 = 223, //~ ERROR literal out of range for i8 +} + +#[repr(i16)] +enum Ei16 { + Ai16 = 23, + Bi16 = -22333, + Ci16 = 55555, //~ ERROR literal out of range for i16 +} + +#[repr(i32)] +enum Ei32 { + Ai32 = 23, + Bi32 = -2_000_000_000, + Ci32 = 3_000_000_000, //~ ERROR literal out of range for i32 +} + +#[repr(i64)] +enum Ei64 { + Ai64 = 23, + Bi64 = -9223372036854775808, + Ci64 = 9223372036854775809, //~ ERROR literal out of range for i64 +} + +// u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`. This is a +// little counterintuitive, but since the discriminant can store all the bits, and extracting it +// with a cast requires specifying the signedness, there is no loss of information in those cases. +// This also applies to isize and usize on 64-bit targets. + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/enum-discrim-too-small2.stderr b/src/test/ui/compile-fail-migration/enum-discrim-too-small2.stderr new file mode 100644 index 00000000000..536dbf64a9d --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-discrim-too-small2.stderr @@ -0,0 +1,32 @@ +error: literal out of range for i8 + --> $DIR/enum-discrim-too-small2.rs:18:11 + | +LL | Ci8 = 223, //~ ERROR literal out of range for i8 + | ^^^ + | +note: lint level defined here + --> $DIR/enum-discrim-too-small2.rs:11:9 + | +LL | #![deny(overflowing_literals)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: literal out of range for i16 + --> $DIR/enum-discrim-too-small2.rs:25:12 + | +LL | Ci16 = 55555, //~ ERROR literal out of range for i16 + | ^^^^^ + +error: literal out of range for i32 + --> $DIR/enum-discrim-too-small2.rs:32:12 + | +LL | Ci32 = 3_000_000_000, //~ ERROR literal out of range for i32 + | ^^^^^^^^^^^^^ + +error: literal out of range for i64 + --> $DIR/enum-discrim-too-small2.rs:39:12 + | +LL | Ci64 = 9223372036854775809, //~ ERROR literal out of range for i64 + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/enum-in-scope.rs b/src/test/ui/compile-fail-migration/enum-in-scope.rs new file mode 100644 index 00000000000..bc1bd03f2d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-in-scope.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct hello(isize); + +fn main() { + let hello = 0; //~ERROR let bindings cannot shadow tuple structs +} diff --git a/src/test/ui/compile-fail-migration/enum-in-scope.stderr b/src/test/ui/compile-fail-migration/enum-in-scope.stderr new file mode 100644 index 00000000000..1e8d5940495 --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-in-scope.stderr @@ -0,0 +1,12 @@ +error[E0530]: let bindings cannot shadow tuple structs + --> $DIR/enum-in-scope.rs:14:9 + | +LL | struct hello(isize); + | -------------------- a tuple struct `hello` is defined here +... +LL | let hello = 0; //~ERROR let bindings cannot shadow tuple structs + | ^^^^^ cannot be named the same as a tuple struct + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0530`. diff --git a/src/test/ui/compile-fail-migration/enum-to-float-cast-2.rs b/src/test/ui/compile-fail-migration/enum-to-float-cast-2.rs new file mode 100644 index 00000000000..e6f473c8aac --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-to-float-cast-2.rs @@ -0,0 +1,28 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that enum-to-float casts are disallowed. + +enum E { + L0 = -1, + H0 = 1 +} + +enum F { + L1 = 1, + H1 = 0xFFFFFFFFFFFFFFFF +} + +pub fn main() { + let a = E::L0 as f32; //~ ERROR casting + let c = F::H1 as f32; //~ ERROR casting + assert_eq!(a, -1.0f32); + assert_eq!(c, -1.0f32); +} diff --git a/src/test/ui/compile-fail-migration/enum-to-float-cast-2.stderr b/src/test/ui/compile-fail-migration/enum-to-float-cast-2.stderr new file mode 100644 index 00000000000..e8e6d8fbcfb --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-to-float-cast-2.stderr @@ -0,0 +1,19 @@ +error[E0606]: casting `E` as `f32` is invalid + --> $DIR/enum-to-float-cast-2.rs:24:13 + | +LL | let a = E::L0 as f32; //~ ERROR casting + | ^^^^^^^^^^^^ + | + = help: cast through an integer first + +error[E0606]: casting `F` as `f32` is invalid + --> $DIR/enum-to-float-cast-2.rs:25:13 + | +LL | let c = F::H1 as f32; //~ ERROR casting + | ^^^^^^^^^^^^ + | + = help: cast through an integer first + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/compile-fail-migration/enum-to-float-cast.rs b/src/test/ui/compile-fail-migration/enum-to-float-cast.rs new file mode 100644 index 00000000000..b562ba0e41a --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-to-float-cast.rs @@ -0,0 +1,31 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that enum-to-float casts are disallowed. + +enum E { + L0 = -1, + H0 = 1 +} + +enum F { + L1 = 1, + H1 = 0xFFFFFFFFFFFFFFFF +} + +static C0: f32 = E::L0 as f32; //~ ERROR casting +static C1: f32 = F::H1 as f32; //~ ERROR casting + +pub fn main() { + let b = C0; + let d = C1; + assert_eq!(b, -1.0f32); + assert_eq!(d, -1.0f32); +} diff --git a/src/test/ui/compile-fail-migration/enum-to-float-cast.stderr b/src/test/ui/compile-fail-migration/enum-to-float-cast.stderr new file mode 100644 index 00000000000..adc2015909c --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-to-float-cast.stderr @@ -0,0 +1,19 @@ +error[E0606]: casting `E` as `f32` is invalid + --> $DIR/enum-to-float-cast.rs:23:18 + | +LL | static C0: f32 = E::L0 as f32; //~ ERROR casting + | ^^^^^^^^^^^^ + | + = help: cast through an integer first + +error[E0606]: casting `F` as `f32` is invalid + --> $DIR/enum-to-float-cast.rs:24:18 + | +LL | static C1: f32 = F::H1 as f32; //~ ERROR casting + | ^^^^^^^^^^^^ + | + = help: cast through an integer first + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/compile-fail-migration/enum-variant-type-2.rs b/src/test/ui/compile-fail-migration/enum-variant-type-2.rs new file mode 100644 index 00000000000..258bfd1e3ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-variant-type-2.rs @@ -0,0 +1,19 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that enum variants are not actually types. + +enum Foo { + Bar +} + +fn foo(x: Foo::Bar) {} //~ ERROR expected type, found variant `Foo::Bar` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/enum-variant-type-2.stderr b/src/test/ui/compile-fail-migration/enum-variant-type-2.stderr new file mode 100644 index 00000000000..7a786af71bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/enum-variant-type-2.stderr @@ -0,0 +1,12 @@ +error[E0573]: expected type, found variant `Foo::Bar` + --> $DIR/enum-variant-type-2.rs:17:11 + | +LL | fn foo(x: Foo::Bar) {} //~ ERROR expected type, found variant `Foo::Bar` + | ^^^^^^^^ + | | + | not a type + | help: you can try using the variant's enum: `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/compile-fail-migration/enums-pats-not-idents.rs b/src/test/ui/compile-fail-migration/enums-pats-not-idents.rs new file mode 100644 index 00000000000..36bd54f599b --- /dev/null +++ b/src/test/ui/compile-fail-migration/enums-pats-not-idents.rs @@ -0,0 +1,13 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let a(1) = 13; //~ ERROR cannot find tuple struct/variant `a` in this scope +} diff --git a/src/test/ui/compile-fail-migration/enums-pats-not-idents.stderr b/src/test/ui/compile-fail-migration/enums-pats-not-idents.stderr new file mode 100644 index 00000000000..5bd119622e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/enums-pats-not-idents.stderr @@ -0,0 +1,9 @@ +error[E0531]: cannot find tuple struct/variant `a` in this scope + --> $DIR/enums-pats-not-idents.rs:12:9 + | +LL | let a(1) = 13; //~ ERROR cannot find tuple struct/variant `a` in this scope + | ^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0531`. diff --git a/src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.rs b/src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.rs new file mode 100644 index 00000000000..8b1e2fc1966 --- /dev/null +++ b/src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.rs @@ -0,0 +1,17 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that the error message uses the word Copy, not Pod. + +fn check_bound(_: T) {} + +fn main() { + check_bound("nocopy".to_string()); //~ ERROR : std::marker::Copy` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.stderr b/src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.stderr new file mode 100644 index 00000000000..704cd4f4838 --- /dev/null +++ b/src/test/ui/compile-fail-migration/error-should-say-copy-not-pod.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied + --> $DIR/error-should-say-copy-not-pod.rs:16:5 + | +LL | check_bound("nocopy".to_string()); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` + | +note: required by `check_bound` + --> $DIR/error-should-say-copy-not-pod.rs:13:1 + | +LL | fn check_bound(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/estr-subtyping.rs b/src/test/ui/compile-fail-migration/estr-subtyping.rs new file mode 100644 index 00000000000..b5c6db0cea9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/estr-subtyping.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn wants_uniq(x: String) { } +fn wants_slice(x: &str) { } + +fn has_uniq(x: String) { + wants_uniq(x); + wants_slice(&*x); +} + +fn has_slice(x: &str) { + wants_uniq(x); //~ ERROR mismatched types + wants_slice(x); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/estr-subtyping.stderr b/src/test/ui/compile-fail-migration/estr-subtyping.stderr new file mode 100644 index 00000000000..fcff9d0380e --- /dev/null +++ b/src/test/ui/compile-fail-migration/estr-subtyping.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/estr-subtyping.rs:20:15 + | +LL | wants_uniq(x); //~ ERROR mismatched types + | ^ + | | + | expected struct `std::string::String`, found &str + | help: try using a conversion method: `x.to_string()` + | + = note: expected type `std::string::String` + found type `&str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/eval-enum.rs b/src/test/ui/compile-fail-migration/eval-enum.rs new file mode 100644 index 00000000000..ada038114d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/eval-enum.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Test { + DivZero = 1/0, + //~^ attempt to divide by zero + //~| ERROR could not evaluate enum discriminant + //~| ERROR this expression will panic at runtime + RemZero = 1%0, + //~^ attempt to calculate the remainder with a divisor of zero + //~| ERROR could not evaluate enum discriminant + //~| ERROR this expression will panic at runtime +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/eval-enum.stderr b/src/test/ui/compile-fail-migration/eval-enum.stderr new file mode 100644 index 00000000000..f26c48f1a72 --- /dev/null +++ b/src/test/ui/compile-fail-migration/eval-enum.stderr @@ -0,0 +1,41 @@ +error: attempt to divide by zero + --> $DIR/eval-enum.rs:12:15 + | +LL | DivZero = 1/0, + | ^^^ + | + = note: #[deny(const_err)] on by default + +error: this expression will panic at runtime + --> $DIR/eval-enum.rs:12:15 + | +LL | DivZero = 1/0, + | ^^^ attempt to divide by zero + +error[E0080]: could not evaluate enum discriminant + --> $DIR/eval-enum.rs:12:15 + | +LL | DivZero = 1/0, + | ^^^ attempt to divide by zero + +error: attempt to calculate the remainder with a divisor of zero + --> $DIR/eval-enum.rs:16:15 + | +LL | RemZero = 1%0, + | ^^^ + +error: this expression will panic at runtime + --> $DIR/eval-enum.rs:16:15 + | +LL | RemZero = 1%0, + | ^^^ attempt to calculate the remainder with a divisor of zero + +error[E0080]: could not evaluate enum discriminant + --> $DIR/eval-enum.rs:16:15 + | +LL | RemZero = 1%0, + | ^^^ attempt to calculate the remainder with a divisor of zero + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/exclusive-drop-and-copy.rs b/src/test/ui/compile-fail-migration/exclusive-drop-and-copy.rs new file mode 100644 index 00000000000..b4cb2469659 --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive-drop-and-copy.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// issue #20126 + +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) {} +} + +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented +struct Bar(::std::marker::PhantomData); + +impl Drop for Bar { + fn drop(&mut self) {} +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/exclusive-drop-and-copy.stderr b/src/test/ui/compile-fail-migration/exclusive-drop-and-copy.stderr new file mode 100644 index 00000000000..1c5e62e21a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive-drop-and-copy.stderr @@ -0,0 +1,15 @@ +error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor + --> $DIR/exclusive-drop-and-copy.rs:13:10 + | +LL | #[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented + | ^^^^ Copy not allowed on types with destructors + +error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor + --> $DIR/exclusive-drop-and-copy.rs:20:10 + | +LL | #[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented + | ^^^^ Copy not allowed on types with destructors + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0184`. diff --git a/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.rs b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.rs new file mode 100644 index 00000000000..69e5898ed4d --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(exclusive_range_pattern)] + +fn main() { + match [5..4, 99..105, 43..44] { + [_, 99.., _] => {}, //~ ERROR unexpected token: `,` + _ => {}, + } +} diff --git a/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.stderr b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.stderr new file mode 100644 index 00000000000..6ccf7efbb88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision.stderr @@ -0,0 +1,8 @@ +error: unexpected token: `,` + --> $DIR/exclusive_range_pattern_syntax_collision.rs:15:15 + | +LL | [_, 99.., _] => {}, //~ ERROR unexpected token: `,` + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.rs b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.rs new file mode 100644 index 00000000000..9212ea86118 --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(exclusive_range_pattern)] + +fn main() { + match [5..4, 99..105, 43..44] { + [_, 99..] => {}, //~ ERROR unexpected token: `]` + _ => {}, + } +} diff --git a/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.stderr b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.stderr new file mode 100644 index 00000000000..d1863cbfb6f --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision2.stderr @@ -0,0 +1,8 @@ +error: unexpected token: `]` + --> $DIR/exclusive_range_pattern_syntax_collision2.rs:15:15 + | +LL | [_, 99..] => {}, //~ ERROR unexpected token: `]` + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.rs b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.rs new file mode 100644 index 00000000000..d83305857ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(exclusive_range_pattern)] + +fn main() { + match [5..4, 99..105, 43..44] { + [..9, 99..100, _] => {}, //~ ERROR expected one of `,` or `]`, found `9` + _ => {}, + } +} diff --git a/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.stderr b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.stderr new file mode 100644 index 00000000000..21b2d0c5c57 --- /dev/null +++ b/src/test/ui/compile-fail-migration/exclusive_range_pattern_syntax_collision3.stderr @@ -0,0 +1,8 @@ +error: expected one of `,` or `]`, found `9` + --> $DIR/exclusive_range_pattern_syntax_collision3.rs:15:12 + | +LL | [..9, 99..100, _] => {}, //~ ERROR expected one of `,` or `]`, found `9` + | ^ expected one of `,` or `]` here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/expanded-cfg.rs b/src/test/ui/compile-fail-migration/expanded-cfg.rs new file mode 100644 index 00000000000..77351f6e4f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/expanded-cfg.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(custom_attribute, rustc_attrs)] + +macro_rules! mac { + {} => { + #[cfg(attr)] + mod m { + #[lang_item] + fn f() {} + + #[cfg_attr(target_thread_local, custom)] + fn g() {} + } + + #[cfg(attr)] + unconfigured_invocation!(); + } +} + +mac! {} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/expanded-cfg.stderr b/src/test/ui/compile-fail-migration/expanded-cfg.stderr new file mode 100644 index 00000000000..d7bc47fad27 --- /dev/null +++ b/src/test/ui/compile-fail-migration/expanded-cfg.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/expanded-cfg.rs:32:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/explicit-call-to-dtor.rs b/src/test/ui/compile-fail-migration/explicit-call-to-dtor.rs new file mode 100644 index 00000000000..90030488dd6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/explicit-call-to-dtor.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + x: isize +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("kaboom"); + } +} + +fn main() { + let x = Foo { x: 3 }; + x.drop(); //~ ERROR explicit use of destructor method +} diff --git a/src/test/ui/compile-fail-migration/explicit-call-to-dtor.stderr b/src/test/ui/compile-fail-migration/explicit-call-to-dtor.stderr new file mode 100644 index 00000000000..264d820042b --- /dev/null +++ b/src/test/ui/compile-fail-migration/explicit-call-to-dtor.stderr @@ -0,0 +1,9 @@ +error[E0040]: explicit use of destructor method + --> $DIR/explicit-call-to-dtor.rs:23:7 + | +LL | x.drop(); //~ ERROR explicit use of destructor method + | ^^^^ explicit destructor calls not allowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0040`. diff --git a/src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.rs b/src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.rs new file mode 100644 index 00000000000..63ed74dfa49 --- /dev/null +++ b/src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + x: isize +} + +trait Bar : Drop { + fn blah(&self); +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("kaboom"); + } +} + +impl Bar for Foo { + fn blah(&self) { + self.drop(); //~ ERROR explicit use of destructor method + } +} + +fn main() { + let x = Foo { x: 3 }; +} diff --git a/src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.stderr b/src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.stderr new file mode 100644 index 00000000000..0d0ae629def --- /dev/null +++ b/src/test/ui/compile-fail-migration/explicit-call-to-supertrait-dtor.stderr @@ -0,0 +1,9 @@ +error[E0040]: explicit use of destructor method + --> $DIR/explicit-call-to-supertrait-dtor.rs:27:14 + | +LL | self.drop(); //~ ERROR explicit use of destructor method + | ^^^^ explicit destructor calls not allowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0040`. diff --git a/src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.rs b/src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.rs new file mode 100644 index 00000000000..eac134ff3cc --- /dev/null +++ b/src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<'a,'b> { + x: &'a isize, + y: &'b isize, +} + +impl<'a,'b> Foo<'a,'b> { + fn bar(self: + Foo<'b,'a> + //~^ ERROR mismatched method receiver + //~| expected type `Foo<'a, 'b>` + //~| found type `Foo<'b, 'a>` + //~| lifetime mismatch + //~| ERROR mismatched method receiver + //~| expected type `Foo<'a, 'b>` + //~| found type `Foo<'b, 'a>` + //~| lifetime mismatch + ) {} +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.stderr b/src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.stderr new file mode 100644 index 00000000000..6a22d20467b --- /dev/null +++ b/src/test/ui/compile-fail-migration/explicit-self-lifetime-mismatch.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched method receiver + --> $DIR/explicit-self-lifetime-mismatch.rs:18:12 + | +LL | Foo<'b,'a> + | ^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Foo<'a, 'b>` + found type `Foo<'b, 'a>` +note: the lifetime 'b as defined on the impl at 16:9... + --> $DIR/explicit-self-lifetime-mismatch.rs:16:9 + | +LL | impl<'a,'b> Foo<'a,'b> { + | ^^ +note: ...does not necessarily outlive the lifetime 'a as defined on the impl at 16:6 + --> $DIR/explicit-self-lifetime-mismatch.rs:16:6 + | +LL | impl<'a,'b> Foo<'a,'b> { + | ^^ + +error[E0308]: mismatched method receiver + --> $DIR/explicit-self-lifetime-mismatch.rs:18:12 + | +LL | Foo<'b,'a> + | ^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Foo<'a, 'b>` + found type `Foo<'b, 'a>` +note: the lifetime 'a as defined on the impl at 16:6... + --> $DIR/explicit-self-lifetime-mismatch.rs:16:6 + | +LL | impl<'a,'b> Foo<'a,'b> { + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 16:9 + --> $DIR/explicit-self-lifetime-mismatch.rs:16:9 + | +LL | impl<'a,'b> 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/compile-fail-migration/export-fully-qualified.rs b/src/test/ui/compile-fail-migration/export-fully-qualified.rs new file mode 100644 index 00000000000..19fa13f8377 --- /dev/null +++ b/src/test/ui/compile-fail-migration/export-fully-qualified.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// In this test baz isn't resolved when called as foo.baz even though +// it's called from inside foo. This is somewhat surprising and may +// want to change eventually. + +mod foo { + pub fn bar() { foo::baz(); } //~ ERROR failed to resolve. Use of undeclared type or module `foo` + + fn baz() { } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/export-fully-qualified.stderr b/src/test/ui/compile-fail-migration/export-fully-qualified.stderr new file mode 100644 index 00000000000..b8409929763 --- /dev/null +++ b/src/test/ui/compile-fail-migration/export-fully-qualified.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `foo` + --> $DIR/export-fully-qualified.rs:16:20 + | +LL | pub fn bar() { foo::baz(); } //~ ERROR failed to resolve. Use of undeclared type or module `foo` + | ^^^ Use of undeclared type or module `foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/export-import.rs b/src/test/ui/compile-fail-migration/export-import.rs new file mode 100644 index 00000000000..3877250126d --- /dev/null +++ b/src/test/ui/compile-fail-migration/export-import.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use m::unexported; +//~^ ERROR: is private + +mod m { + pub fn exported() { } + + fn unexported() { } +} + + +fn main() { unexported(); } diff --git a/src/test/ui/compile-fail-migration/export-import.stderr b/src/test/ui/compile-fail-migration/export-import.stderr new file mode 100644 index 00000000000..2f12485f123 --- /dev/null +++ b/src/test/ui/compile-fail-migration/export-import.stderr @@ -0,0 +1,9 @@ +error[E0603]: function `unexported` is private + --> $DIR/export-import.rs:11:5 + | +LL | use m::unexported; + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/export-tag-variant.rs b/src/test/ui/compile-fail-migration/export-tag-variant.rs new file mode 100644 index 00000000000..b6e8cf71ddd --- /dev/null +++ b/src/test/ui/compile-fail-migration/export-tag-variant.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub fn x() { } + + enum y { y1, } +} + +fn main() { let z = foo::y::y1; } //~ ERROR: enum `y` is private diff --git a/src/test/ui/compile-fail-migration/export-tag-variant.stderr b/src/test/ui/compile-fail-migration/export-tag-variant.stderr new file mode 100644 index 00000000000..da67e2c4199 --- /dev/null +++ b/src/test/ui/compile-fail-migration/export-tag-variant.stderr @@ -0,0 +1,9 @@ +error[E0603]: enum `y` is private + --> $DIR/export-tag-variant.rs:17:21 + | +LL | fn main() { let z = foo::y::y1; } //~ ERROR: enum `y` is private + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/export.rs b/src/test/ui/compile-fail-migration/export.rs new file mode 100644 index 00000000000..c28ea70c752 --- /dev/null +++ b/src/test/ui/compile-fail-migration/export.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub fn x(y: isize) { log(debug, y); } + //~^ ERROR cannot find function `log` in this scope + //~| ERROR cannot find value `debug` in this scope + fn z(y: isize) { log(debug, y); } + //~^ ERROR cannot find function `log` in this scope + //~| ERROR cannot find value `debug` in this scope +} + +fn main() { foo::z(10); } //~ ERROR function `z` is private diff --git a/src/test/ui/compile-fail-migration/export.stderr b/src/test/ui/compile-fail-migration/export.stderr new file mode 100644 index 00000000000..dd19e83750b --- /dev/null +++ b/src/test/ui/compile-fail-migration/export.stderr @@ -0,0 +1,34 @@ +error[E0425]: cannot find function `log` in this scope + --> $DIR/export.rs:12:26 + | +LL | pub fn x(y: isize) { log(debug, y); } + | ^^^ not found in this scope + +error[E0425]: cannot find value `debug` in this scope + --> $DIR/export.rs:12:30 + | +LL | pub fn x(y: isize) { log(debug, y); } + | ^^^^^ not found in this scope + +error[E0425]: cannot find function `log` in this scope + --> $DIR/export.rs:15:22 + | +LL | fn z(y: isize) { log(debug, y); } + | ^^^ not found in this scope + +error[E0425]: cannot find value `debug` in this scope + --> $DIR/export.rs:15:26 + | +LL | fn z(y: isize) { log(debug, y); } + | ^^^^^ not found in this scope + +error[E0603]: function `z` is private + --> $DIR/export.rs:20:13 + | +LL | fn main() { foo::z(10); } //~ ERROR function `z` is private + | ^^^^^^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0425, E0603. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/export2.rs b/src/test/ui/compile-fail-migration/export2.rs new file mode 100644 index 00000000000..dc96ce7f504 --- /dev/null +++ b/src/test/ui/compile-fail-migration/export2.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub fn x() { bar::x(); } //~ ERROR failed to resolve. Use of undeclared type or module `bar` +} + +mod bar { + fn x() { println!("x"); } + + pub fn y() { } +} + +fn main() { foo::x(); } diff --git a/src/test/ui/compile-fail-migration/export2.stderr b/src/test/ui/compile-fail-migration/export2.stderr new file mode 100644 index 00000000000..c76afb8a1e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/export2.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `bar` + --> $DIR/export2.rs:12:18 + | +LL | pub fn x() { bar::x(); } //~ ERROR failed to resolve. Use of undeclared type or module `bar` + | ^^^ Use of undeclared type or module `bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/expr_attr_paren_order.rs b/src/test/ui/compile-fail-migration/expr_attr_paren_order.rs new file mode 100644 index 00000000000..49b2fa0e350 --- /dev/null +++ b/src/test/ui/compile-fail-migration/expr_attr_paren_order.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(stmt_expr_attributes)] + +fn main() { + + // Test that attributes on parens get concatenated + // in the expected order in the hir folder. + + #[deny(non_snake_case)] ( + #![allow(non_snake_case)] + { + let X = 0; + let _ = X; + } + ); + + #[allow(non_snake_case)] ( + #![deny(non_snake_case)] + { + let X = 0; //~ ERROR snake case name + let _ = X; + } + ); + +} diff --git a/src/test/ui/compile-fail-migration/expr_attr_paren_order.stderr b/src/test/ui/compile-fail-migration/expr_attr_paren_order.stderr new file mode 100644 index 00000000000..938ff51b37d --- /dev/null +++ b/src/test/ui/compile-fail-migration/expr_attr_paren_order.stderr @@ -0,0 +1,14 @@ +error: variable `X` should have a snake case name such as `x` + --> $DIR/expr_attr_paren_order.rs:29:17 + | +LL | let X = 0; //~ ERROR snake case name + | ^ + | +note: lint level defined here + --> $DIR/expr_attr_paren_order.rs:27:17 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/ext-nonexistent.rs b/src/test/ui/compile-fail-migration/ext-nonexistent.rs new file mode 100644 index 00000000000..a5bf7960624 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ext-nonexistent.rs @@ -0,0 +1,12 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:cannot find macro +fn main() { iamnotanextensionthatexists!(""); } diff --git a/src/test/ui/compile-fail-migration/ext-nonexistent.stderr b/src/test/ui/compile-fail-migration/ext-nonexistent.stderr new file mode 100644 index 00000000000..ff027f18476 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ext-nonexistent.stderr @@ -0,0 +1,8 @@ +error: cannot find macro `iamnotanextensionthatexists!` in this scope + --> $DIR/ext-nonexistent.rs:12:13 + | +LL | fn main() { iamnotanextensionthatexists!(""); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.rs b/src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.rs new file mode 100644 index 00000000000..c2362689721 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.rs @@ -0,0 +1,11 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { env!("one", 10); } //~ ERROR: expected string literal diff --git a/src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.stderr b/src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.stderr new file mode 100644 index 00000000000..4a10deb4bdd --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-arg-2-not-string-literal.stderr @@ -0,0 +1,8 @@ +error: expected string literal + --> $DIR/extenv-arg-2-not-string-literal.rs:11:25 + | +LL | fn main() { env!("one", 10); } //~ ERROR: expected string literal + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extenv-no-args.rs b/src/test/ui/compile-fail-migration/extenv-no-args.rs new file mode 100644 index 00000000000..afa47dbe744 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-no-args.rs @@ -0,0 +1,11 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { env!(); } //~ ERROR: env! takes 1 or 2 arguments diff --git a/src/test/ui/compile-fail-migration/extenv-no-args.stderr b/src/test/ui/compile-fail-migration/extenv-no-args.stderr new file mode 100644 index 00000000000..ebd97c014f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-no-args.stderr @@ -0,0 +1,8 @@ +error: env! takes 1 or 2 arguments + --> $DIR/extenv-no-args.rs:11:13 + | +LL | fn main() { env!(); } //~ ERROR: env! takes 1 or 2 arguments + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extenv-not-defined-custom.rs b/src/test/ui/compile-fail-migration/extenv-not-defined-custom.rs new file mode 100644 index 00000000000..485b6c09f0a --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-not-defined-custom.rs @@ -0,0 +1,11 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); } //~ ERROR: my error message diff --git a/src/test/ui/compile-fail-migration/extenv-not-defined-custom.stderr b/src/test/ui/compile-fail-migration/extenv-not-defined-custom.stderr new file mode 100644 index 00000000000..845f87df916 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-not-defined-custom.stderr @@ -0,0 +1,8 @@ +error: my error message + --> $DIR/extenv-not-defined-custom.rs:11:13 + | +LL | fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); } //~ ERROR: my error message + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extenv-not-defined-default.rs b/src/test/ui/compile-fail-migration/extenv-not-defined-default.rs new file mode 100644 index 00000000000..d99d4dc33a2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-not-defined-default.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + env!("__HOPEFULLY_NOT_DEFINED__"); + //~^ ERROR: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined +} diff --git a/src/test/ui/compile-fail-migration/extenv-not-defined-default.stderr b/src/test/ui/compile-fail-migration/extenv-not-defined-default.stderr new file mode 100644 index 00000000000..0db6f536edb --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-not-defined-default.stderr @@ -0,0 +1,8 @@ +error: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined + --> $DIR/extenv-not-defined-default.rs:12:5 + | +LL | env!("__HOPEFULLY_NOT_DEFINED__"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extenv-not-string-literal.rs b/src/test/ui/compile-fail-migration/extenv-not-string-literal.rs new file mode 100644 index 00000000000..07ce47a14d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-not-string-literal.rs @@ -0,0 +1,11 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { env!(10, "two"); } //~ ERROR: expected string literal diff --git a/src/test/ui/compile-fail-migration/extenv-not-string-literal.stderr b/src/test/ui/compile-fail-migration/extenv-not-string-literal.stderr new file mode 100644 index 00000000000..1660d8665dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-not-string-literal.stderr @@ -0,0 +1,8 @@ +error: expected string literal + --> $DIR/extenv-not-string-literal.rs:11:18 + | +LL | fn main() { env!(10, "two"); } //~ ERROR: expected string literal + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extenv-too-many-args.rs b/src/test/ui/compile-fail-migration/extenv-too-many-args.rs new file mode 100644 index 00000000000..c6c4f0ec6b8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-too-many-args.rs @@ -0,0 +1,11 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { env!("one", "two", "three"); } //~ ERROR: env! takes 1 or 2 arguments diff --git a/src/test/ui/compile-fail-migration/extenv-too-many-args.stderr b/src/test/ui/compile-fail-migration/extenv-too-many-args.stderr new file mode 100644 index 00000000000..e4eda9e9e9a --- /dev/null +++ b/src/test/ui/compile-fail-migration/extenv-too-many-args.stderr @@ -0,0 +1,8 @@ +error: env! takes 1 or 2 arguments + --> $DIR/extenv-too-many-args.rs:11:13 + | +LL | fn main() { env!("one", "two", "three"); } //~ ERROR: env! takes 1 or 2 arguments + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extern-crate-visibility.rs b/src/test/ui/compile-fail-migration/extern-crate-visibility.rs new file mode 100644 index 00000000000..6bb88e40910 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-crate-visibility.rs @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + extern crate core; +} + +// Check that private crates can be used from outside their modules, albeit with warnings +use foo::core::cell; //~ ERROR extern crate `core` is private + +fn f() { + foo::core::cell::Cell::new(0); //~ ERROR extern crate `core` is private + + use foo::*; + mod core {} // Check that private crates are not glob imported +} + +mod bar { + pub extern crate core; +} + +mod baz { + pub use bar::*; + use self::core::cell; // Check that public extern crates are glob imported +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/extern-crate-visibility.stderr b/src/test/ui/compile-fail-migration/extern-crate-visibility.stderr new file mode 100644 index 00000000000..cadb636bf0d --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-crate-visibility.stderr @@ -0,0 +1,15 @@ +error[E0603]: extern crate `core` is private + --> $DIR/extern-crate-visibility.rs:16:5 + | +LL | use foo::core::cell; //~ ERROR extern crate `core` is private + | ^^^^^^^^^^^^^^^ + +error[E0603]: extern crate `core` is private + --> $DIR/extern-crate-visibility.rs:19:5 + | +LL | foo::core::cell::Cell::new(0); //~ ERROR extern crate `core` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/extern-macro.rs b/src/test/ui/compile-fail-migration/extern-macro.rs new file mode 100644 index 00000000000..4267103ab9a --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-macro.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #41719 + +#![feature(use_extern_macros)] + +fn main() { + enum Foo {} + let _ = Foo::bar!(); //~ ERROR fail to resolve non-ident macro path +} diff --git a/src/test/ui/compile-fail-migration/extern-macro.stderr b/src/test/ui/compile-fail-migration/extern-macro.stderr new file mode 100644 index 00000000000..8918ac3143b --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-macro.stderr @@ -0,0 +1,8 @@ +error: fail to resolve non-ident macro path + --> $DIR/extern-macro.rs:17:13 + | +LL | let _ = Foo::bar!(); //~ ERROR fail to resolve non-ident macro path + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extern-main-fn.rs b/src/test/ui/compile-fail-migration/extern-main-fn.rs new file mode 100644 index 00000000000..d9bdb4ecd04 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-main-fn.rs @@ -0,0 +1,11 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern fn main() {} //~ ERROR: main function has wrong type [E0580] diff --git a/src/test/ui/compile-fail-migration/extern-main-fn.stderr b/src/test/ui/compile-fail-migration/extern-main-fn.stderr new file mode 100644 index 00000000000..24e9d138693 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-main-fn.stderr @@ -0,0 +1,12 @@ +error[E0580]: main function has wrong type + --> $DIR/extern-main-fn.rs:11:1 + | +LL | extern fn main() {} //~ ERROR: main function has wrong type [E0580] + | ^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn + | + = note: expected type `fn()` + found type `extern "C" fn()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0580`. diff --git a/src/test/ui/compile-fail-migration/extern-types-distinct-types.rs b/src/test/ui/compile-fail-migration/extern-types-distinct-types.rs new file mode 100644 index 00000000000..8b434bbfc6d --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-types-distinct-types.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_types)] + +extern { + type A; + type B; +} + +fn foo(r: &A) -> &B { + r //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/extern-types-distinct-types.stderr b/src/test/ui/compile-fail-migration/extern-types-distinct-types.stderr new file mode 100644 index 00000000000..6c74f63744f --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-types-distinct-types.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/extern-types-distinct-types.rs:19:5 + | +LL | r //~ ERROR mismatched types + | ^ expected extern type `B`, found extern type `A` + | + = note: expected type `&B` + found type `&A` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/extern-types-not-sync-send.rs b/src/test/ui/compile-fail-migration/extern-types-not-sync-send.rs new file mode 100644 index 00000000000..10abb80a2f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-types-not-sync-send.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure extern types are !Sync and !Send. + +#![feature(extern_types)] + +extern { + type A; +} + +fn assert_sync() { } +fn assert_send() { } + +fn main() { + assert_sync::(); + //~^ ERROR `A` cannot be shared between threads safely [E0277] + + assert_send::(); + //~^ ERROR `A` cannot be sent between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/extern-types-not-sync-send.stderr b/src/test/ui/compile-fail-migration/extern-types-not-sync-send.stderr new file mode 100644 index 00000000000..f076aa0fd68 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-types-not-sync-send.stderr @@ -0,0 +1,29 @@ +error[E0277]: `A` cannot be shared between threads safely + --> $DIR/extern-types-not-sync-send.rs:23:5 + | +LL | assert_sync::(); + | ^^^^^^^^^^^^^^^^ `A` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `A` +note: required by `assert_sync` + --> $DIR/extern-types-not-sync-send.rs:19:1 + | +LL | fn assert_sync() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `A` cannot be sent between threads safely + --> $DIR/extern-types-not-sync-send.rs:26:5 + | +LL | assert_send::(); + | ^^^^^^^^^^^^^^^^ `A` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `A` +note: required by `assert_send` + --> $DIR/extern-types-not-sync-send.rs:20:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/extern-types-unsized.rs b/src/test/ui/compile-fail-migration/extern-types-unsized.rs new file mode 100644 index 00000000000..f2db4553868 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-types-unsized.rs @@ -0,0 +1,43 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure extern types are !Sized. + +#![feature(extern_types)] + +extern { + type A; +} + +struct Foo { + x: u8, + tail: A, +} + +struct Bar { + x: u8, + tail: T, +} + +fn assert_sized() { } + +fn main() { + assert_sized::(); + //~^ ERROR the size for values of type + + assert_sized::(); + //~^ ERROR the size for values of type + + assert_sized::>(); + //~^ ERROR the size for values of type + + assert_sized::>>(); + //~^ ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/extern-types-unsized.stderr b/src/test/ui/compile-fail-migration/extern-types-unsized.stderr new file mode 100644 index 00000000000..b86602a687b --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-types-unsized.stderr @@ -0,0 +1,63 @@ +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/extern-types-unsized.rs:32:5 + | +LL | assert_sized::(); + | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `A` + = note: to learn more, visit +note: required by `assert_sized` + --> $DIR/extern-types-unsized.rs:29:1 + | +LL | fn assert_sized() { } + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/extern-types-unsized.rs:35:5 + | +LL | assert_sized::(); + | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `Foo`, the trait `std::marker::Sized` is not implemented for `A` + = note: to learn more, visit + = note: required because it appears within the type `Foo` +note: required by `assert_sized` + --> $DIR/extern-types-unsized.rs:29:1 + | +LL | fn assert_sized() { } + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/extern-types-unsized.rs:38:5 + | +LL | assert_sized::>(); + | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `Bar`, the trait `std::marker::Sized` is not implemented for `A` + = note: to learn more, visit + = note: required because it appears within the type `Bar` +note: required by `assert_sized` + --> $DIR/extern-types-unsized.rs:29:1 + | +LL | fn assert_sized() { } + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `A` cannot be known at compilation time + --> $DIR/extern-types-unsized.rs:41:5 + | +LL | assert_sized::>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `Bar>`, the trait `std::marker::Sized` is not implemented for `A` + = note: to learn more, visit + = note: required because it appears within the type `Bar` + = note: required because it appears within the type `Bar>` +note: required by `assert_sized` + --> $DIR/extern-types-unsized.rs:29:1 + | +LL | fn assert_sized() { } + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/extern-with-type-bounds.rs b/src/test/ui/compile-fail-migration/extern-with-type-bounds.rs new file mode 100644 index 00000000000..9493a1ae892 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-with-type-bounds.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(intrinsics)] + +extern "rust-intrinsic" { + // Real example from libcore + fn type_id() -> u64; + + // Silent bounds made explicit to make sure they are actually + // resolved. + fn transmute(val: T) -> U; + + // Bounds aren't checked right now, so this should work + // even though it's incorrect. + fn size_of() -> usize; + + // Unresolved bounds should still error. + fn align_of() -> usize; + //~^ ERROR cannot find trait `NoSuchTrait` in this scope +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/extern-with-type-bounds.stderr b/src/test/ui/compile-fail-migration/extern-with-type-bounds.stderr new file mode 100644 index 00000000000..4b62a12d36b --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-with-type-bounds.stderr @@ -0,0 +1,9 @@ +error[E0405]: cannot find trait `NoSuchTrait` in this scope + --> $DIR/extern-with-type-bounds.rs:26:20 + | +LL | fn align_of() -> usize; + | ^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0405`. diff --git a/src/test/ui/compile-fail-migration/extern-wrong-value-type.rs b/src/test/ui/compile-fail-migration/extern-wrong-value-type.rs new file mode 100644 index 00000000000..66b06c505e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-wrong-value-type.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern fn f() { +} + +fn is_fn(_: F) where F: Fn() {} + +fn main() { + // extern functions are extern "C" fn + let _x: extern "C" fn() = f; // OK + is_fn(f); + //~^ ERROR `extern "C" fn() {f}: std::ops::Fn<()>` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/extern-wrong-value-type.stderr b/src/test/ui/compile-fail-migration/extern-wrong-value-type.stderr new file mode 100644 index 00000000000..35e0d68e46a --- /dev/null +++ b/src/test/ui/compile-fail-migration/extern-wrong-value-type.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `extern "C" fn() {f}: std::ops::Fn<()>` is not satisfied + --> $DIR/extern-wrong-value-type.rs:19:5 + | +LL | is_fn(f); + | ^^^^^ the trait `std::ops::Fn<()>` is not implemented for `extern "C" fn() {f}` + | +note: required by `is_fn` + --> $DIR/extern-wrong-value-type.rs:14:1 + | +LL | fn is_fn(_: F) where F: Fn() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/external-doc-error.rs b/src/test/ui/compile-fail-migration/external-doc-error.rs new file mode 100644 index 00000000000..1ae0d0bd276 --- /dev/null +++ b/src/test/ui/compile-fail-migration/external-doc-error.rs @@ -0,0 +1,16 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(external_doc)] + +#[doc(include = "not-a-file.md")] //~ ERROR: couldn't read +pub struct SomeStruct; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/external-doc-error.stderr b/src/test/ui/compile-fail-migration/external-doc-error.stderr new file mode 100644 index 00000000000..0af15be39ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/external-doc-error.stderr @@ -0,0 +1,8 @@ +error: couldn't read $DIR/not-a-file.md: No such file or directory (os error 2) + --> $DIR/external-doc-error.rs:13:1 + | +LL | #[doc(include = "not-a-file.md")] //~ ERROR: couldn't read + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extoption_env-no-args.rs b/src/test/ui/compile-fail-migration/extoption_env-no-args.rs new file mode 100644 index 00000000000..fd56756584a --- /dev/null +++ b/src/test/ui/compile-fail-migration/extoption_env-no-args.rs @@ -0,0 +1,11 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { option_env!(); } //~ ERROR: option_env! takes 1 argument diff --git a/src/test/ui/compile-fail-migration/extoption_env-no-args.stderr b/src/test/ui/compile-fail-migration/extoption_env-no-args.stderr new file mode 100644 index 00000000000..d01aefe46b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extoption_env-no-args.stderr @@ -0,0 +1,8 @@ +error: option_env! takes 1 argument + --> $DIR/extoption_env-no-args.rs:11:13 + | +LL | fn main() { option_env!(); } //~ ERROR: option_env! takes 1 argument + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extoption_env-not-string-literal.rs b/src/test/ui/compile-fail-migration/extoption_env-not-string-literal.rs new file mode 100644 index 00000000000..6371a5c711d --- /dev/null +++ b/src/test/ui/compile-fail-migration/extoption_env-not-string-literal.rs @@ -0,0 +1,11 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { option_env!(10); } //~ ERROR: argument must be a string literal diff --git a/src/test/ui/compile-fail-migration/extoption_env-not-string-literal.stderr b/src/test/ui/compile-fail-migration/extoption_env-not-string-literal.stderr new file mode 100644 index 00000000000..af4163259ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/extoption_env-not-string-literal.stderr @@ -0,0 +1,8 @@ +error: argument must be a string literal + --> $DIR/extoption_env-not-string-literal.rs:11:25 + | +LL | fn main() { option_env!(10); } //~ ERROR: argument must be a string literal + | ^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/extoption_env-too-many-args.rs b/src/test/ui/compile-fail-migration/extoption_env-too-many-args.rs new file mode 100644 index 00000000000..b31e857c14e --- /dev/null +++ b/src/test/ui/compile-fail-migration/extoption_env-too-many-args.rs @@ -0,0 +1,11 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { option_env!("one", "two"); } //~ ERROR: option_env! takes 1 argument diff --git a/src/test/ui/compile-fail-migration/extoption_env-too-many-args.stderr b/src/test/ui/compile-fail-migration/extoption_env-too-many-args.stderr new file mode 100644 index 00000000000..0e4569d7a01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/extoption_env-too-many-args.stderr @@ -0,0 +1,8 @@ +error: option_env! takes 1 argument + --> $DIR/extoption_env-too-many-args.rs:11:13 + | +LL | fn main() { option_env!("one", "two"); } //~ ERROR: option_env! takes 1 argument + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/fail-no-dead-code-core.rs b/src/test/ui/compile-fail-migration/fail-no-dead-code-core.rs new file mode 100644 index 00000000000..aed76e36fca --- /dev/null +++ b/src/test/ui/compile-fail-migration/fail-no-dead-code-core.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(dead_code)] +#![allow(unreachable_code)] + +#[macro_use] +extern crate core; + +fn foo() { //~ ERROR function is never used + + // none of these should have any dead_code exposed to the user + panic!(); + + panic!("foo"); + + panic!("bar {}", "baz") +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/fail-no-dead-code-core.stderr b/src/test/ui/compile-fail-migration/fail-no-dead-code-core.stderr new file mode 100644 index 00000000000..d2af77a28d3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fail-no-dead-code-core.stderr @@ -0,0 +1,14 @@ +error: function is never used: `foo` + --> $DIR/fail-no-dead-code-core.rs:17:1 + | +LL | fn foo() { //~ ERROR function is never used + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/fail-no-dead-code-core.rs:11:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/fail-no-dead-code.rs b/src/test/ui/compile-fail-migration/fail-no-dead-code.rs new file mode 100644 index 00000000000..6e5d3a31355 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fail-no-dead-code.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(dead_code)] +#![allow(unreachable_code)] + +fn foo() { //~ ERROR function is never used + + // none of these should have any dead_code exposed to the user + panic!(); + + panic!("foo"); + + panic!("bar {}", "baz") +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/fail-no-dead-code.stderr b/src/test/ui/compile-fail-migration/fail-no-dead-code.stderr new file mode 100644 index 00000000000..f355c7dd731 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fail-no-dead-code.stderr @@ -0,0 +1,14 @@ +error: function is never used: `foo` + --> $DIR/fail-no-dead-code.rs:14:1 + | +LL | fn foo() { //~ ERROR function is never used + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/fail-no-dead-code.rs:11:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/fail-simple.rs b/src/test/ui/compile-fail-migration/fail-simple.rs new file mode 100644 index 00000000000..a20ff864705 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fail-simple.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + panic!(@); //~ ERROR no rules expected the token `@` +} diff --git a/src/test/ui/compile-fail-migration/fail-simple.stderr b/src/test/ui/compile-fail-migration/fail-simple.stderr new file mode 100644 index 00000000000..764f2c464bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/fail-simple.stderr @@ -0,0 +1,8 @@ +error: no rules expected the token `@` + --> $DIR/fail-simple.rs:12:12 + | +LL | panic!(@); //~ ERROR no rules expected the token `@` + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.rs b/src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.rs new file mode 100644 index 00000000000..66691af2d03 --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![no_std] +#![no_main] + +use core::alloc::Layout; + +#[alloc_error_handler] //~ ERROR #[alloc_error_handler] is an unstable feature (see issue #51540) +fn oom(info: Layout) -> ! { + loop {} +} diff --git a/src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.stderr b/src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.stderr new file mode 100644 index 00000000000..255d5b06c17 --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-alloc-error-handler.stderr @@ -0,0 +1,11 @@ +error[E0658]: #[alloc_error_handler] is an unstable feature (see issue #51540) + --> $DIR/feature-gate-alloc-error-handler.rs:18:1 + | +LL | #[alloc_error_handler] //~ ERROR #[alloc_error_handler] is an unstable feature (see issue #51540) + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(alloc_error_handler)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/feature-gate-panic-implementation.rs b/src/test/ui/compile-fail-migration/feature-gate-panic-implementation.rs new file mode 100644 index 00000000000..ae9fbc7b13b --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-panic-implementation.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_implementation] //~ ERROR #[panic_implementation] is an unstable feature (see issue #44489) +fn panic(info: &PanicInfo) -> ! { + loop {} +} diff --git a/src/test/ui/compile-fail-migration/feature-gate-panic-implementation.stderr b/src/test/ui/compile-fail-migration/feature-gate-panic-implementation.stderr new file mode 100644 index 00000000000..f99228bef1d --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-panic-implementation.stderr @@ -0,0 +1,11 @@ +error[E0658]: #[panic_implementation] is an unstable feature (see issue #44489) + --> $DIR/feature-gate-panic-implementation.rs:18:1 + | +LL | #[panic_implementation] //~ ERROR #[panic_implementation] is an unstable feature (see issue #44489) + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(panic_implementation)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/feature-gate-tool_lints.rs b/src/test/ui/compile-fail-migration/feature-gate-tool_lints.rs new file mode 100644 index 00000000000..c311eb7ed7a --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-tool_lints.rs @@ -0,0 +1,12 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[warn(clippy::assign_ops)] //~ ERROR scoped lint `clippy::assign_ops` is experimental +fn main() {} diff --git a/src/test/ui/compile-fail-migration/feature-gate-tool_lints.stderr b/src/test/ui/compile-fail-migration/feature-gate-tool_lints.stderr new file mode 100644 index 00000000000..8840b3906dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-tool_lints.stderr @@ -0,0 +1,11 @@ +error[E0658]: scoped lint `clippy::assign_ops` is experimental (see issue #44690) + --> $DIR/feature-gate-tool_lints.rs:11:8 + | +LL | #[warn(clippy::assign_ops)] //~ ERROR scoped lint `clippy::assign_ops` is experimental + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(tool_lints)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.rs b/src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.rs new file mode 100644 index 00000000000..7bcddbb6a2f --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.rs @@ -0,0 +1,17 @@ +// gate-test-irrefutable_let_patterns + +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[allow(irrefutable_let_patterns)] +fn main() { + if let _ = 5 {} + //~^ ERROR 15:12: 15:13: irrefutable if-let pattern [E0162] +} diff --git a/src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.stderr b/src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.stderr new file mode 100644 index 00000000000..2b23962a304 --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gate-without_gate_irrefutable_pattern.stderr @@ -0,0 +1,9 @@ +error[E0162]: irrefutable if-let pattern + --> $DIR/feature-gate-without_gate_irrefutable_pattern.rs:15:12 + | +LL | if let _ = 5 {} + | ^ irrefutable pattern + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0162`. diff --git a/src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.rs b/src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.rs new file mode 100644 index 00000000000..ae342af4a52 --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// tests that input to a macro is checked for use of gated features. If this +// test succeeds due to the acceptance of a feature, pick a new feature to +// test. Not ideal, but oh well :( + +fn main() { + let a = &[1, 2, 3]; + println!("{}", { + extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change + fn atomic_fence(); + } + atomic_fence(); + 42 + }); +} diff --git a/src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.stderr b/src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.stderr new file mode 100644 index 00000000000..41b3e3eaf10 --- /dev/null +++ b/src/test/ui/compile-fail-migration/feature-gated-feature-in-macro-arg.stderr @@ -0,0 +1,13 @@ +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gated-feature-in-macro-arg.rs:18:9 + | +LL | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change +LL | | fn atomic_fence(); +LL | | } + | |_________^ + | + = help: add #![feature(intrinsics)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/float-literal-inference-restrictions.rs b/src/test/ui/compile-fail-migration/float-literal-inference-restrictions.rs new file mode 100644 index 00000000000..1e58df69f16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/float-literal-inference-restrictions.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x: f32 = 1; //~ ERROR mismatched types + let y: f32 = 1f64; //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/float-literal-inference-restrictions.stderr b/src/test/ui/compile-fail-migration/float-literal-inference-restrictions.stderr new file mode 100644 index 00000000000..80ca6d073dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/float-literal-inference-restrictions.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/float-literal-inference-restrictions.rs:12:18 + | +LL | let x: f32 = 1; //~ ERROR mismatched types + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/float-literal-inference-restrictions.rs:13:18 + | +LL | let y: f32 = 1f64; //~ ERROR mismatched types + | ^^^^ expected f32, found f64 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/fn-bad-block-type.rs b/src/test/ui/compile-fail-migration/fn-bad-block-type.rs new file mode 100644 index 00000000000..c5c355cfbce --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-bad-block-type.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:mismatched types + +fn f() -> isize { true } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/fn-bad-block-type.stderr b/src/test/ui/compile-fail-migration/fn-bad-block-type.stderr new file mode 100644 index 00000000000..23d76e54531 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-bad-block-type.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/fn-bad-block-type.rs:13:19 + | +LL | fn f() -> isize { true } + | ----- ^^^^ expected isize, found bool + | | + | expected `isize` because of return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/fn-compare-mismatch.rs b/src/test/ui/compile-fail-migration/fn-compare-mismatch.rs new file mode 100644 index 00000000000..27be1ada445 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-compare-mismatch.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + fn f() { } + fn g() { } + let x = f == g; + //~^ ERROR binary operation `==` cannot be applied + //~| ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/fn-compare-mismatch.stderr b/src/test/ui/compile-fail-migration/fn-compare-mismatch.stderr new file mode 100644 index 00000000000..995a17e01bf --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-compare-mismatch.stderr @@ -0,0 +1,21 @@ +error[E0369]: binary operation `==` cannot be applied to type `fn() {main::f}` + --> $DIR/fn-compare-mismatch.rs:14:13 + | +LL | let x = f == g; + | ^^^^^^ + | + = note: an implementation of `std::cmp::PartialEq` might be missing for `fn() {main::f}` + +error[E0308]: mismatched types + --> $DIR/fn-compare-mismatch.rs:14:18 + | +LL | let x = f == g; + | ^ expected fn item, found a different fn item + | + = note: expected type `fn() {main::f}` + found type `fn() {main::g}` + +error: aborting due to 2 previous errors + +Some errors occurred: E0308, E0369. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/fn-item-type.rs b/src/test/ui/compile-fail-migration/fn-item-type.rs new file mode 100644 index 00000000000..6217a9f16b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-item-type.rs @@ -0,0 +1,43 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the types of distinct fn items are not compatible by +// default. See also `run-pass/fn-item-type-*.rs`. + +fn foo(x: isize) -> isize { x * 2 } +fn bar(x: isize) -> isize { x * 4 } + +fn eq(x: T, y: T) { } + +trait Foo { fn foo() { /* this is a default fn */ } } +impl Foo for T { /* `foo` is still default here */ } + +fn main() { + eq(foo::, bar::); + //~^ ERROR mismatched types + //~| expected type `fn(isize) -> isize {foo::}` + //~| found type `fn(isize) -> isize {bar::}` + //~| expected fn item, found a different fn item + + eq(foo::, foo::); + //~^ ERROR mismatched types + //~| expected u8, found i8 + + eq(bar::, bar::>); + //~^ ERROR mismatched types + //~| expected type `fn(isize) -> isize {bar::}` + //~| found type `fn(isize) -> isize {bar::>}` + //~| expected struct `std::string::String`, found struct `std::vec::Vec` + + // Make sure we distinguish between trait methods correctly. + eq(::foo, ::foo); + //~^ ERROR mismatched types + //~| expected u8, found u16 +} diff --git a/src/test/ui/compile-fail-migration/fn-item-type.stderr b/src/test/ui/compile-fail-migration/fn-item-type.stderr new file mode 100644 index 00000000000..59dd4b294aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-item-type.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/fn-item-type.rs:23:19 + | +LL | eq(foo::, bar::); + | ^^^^^^^^^ expected fn item, found a different fn item + | + = note: expected type `fn(isize) -> isize {foo::}` + found type `fn(isize) -> isize {bar::}` + +error[E0308]: mismatched types + --> $DIR/fn-item-type.rs:29:19 + | +LL | eq(foo::, foo::); + | ^^^^^^^^^ expected u8, found i8 + | + = note: expected type `fn(isize) -> isize {foo::}` + found type `fn(isize) -> isize {foo::}` + +error[E0308]: mismatched types + --> $DIR/fn-item-type.rs:33:23 + | +LL | eq(bar::, bar::>); + | ^^^^^^^^^^^^^^ expected struct `std::string::String`, found struct `std::vec::Vec` + | + = note: expected type `fn(isize) -> isize {bar::}` + found type `fn(isize) -> isize {bar::>}` + +error[E0308]: mismatched types + --> $DIR/fn-item-type.rs:40:26 + | +LL | eq(::foo, ::foo); + | ^^^^^^^^^^^^^^^^^ expected u8, found u16 + | + = note: expected type `fn() {::foo}` + found type `fn() {::foo}` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/fn-trait-formatting.rs b/src/test/ui/compile-fail-migration/fn-trait-formatting.rs new file mode 100644 index 00000000000..56d64d77ee2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-trait-formatting.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn needs_fn(x: F) where F: Fn(isize) -> isize {} + +fn main() { + let _: () = (box |_: isize| {}) as Box; + //~^ ERROR mismatched types + //~| expected type `()` + //~| found type `std::boxed::Box` + let _: () = (box |_: isize, isize| {}) as Box; + //~^ ERROR mismatched types + //~| expected type `()` + //~| found type `std::boxed::Box` + let _: () = (box || -> isize { unimplemented!() }) as Box isize>; + //~^ ERROR mismatched types + //~| expected type `()` + //~| found type `std::boxed::Box isize>` + + needs_fn(1); + //~^ ERROR : std::ops::Fn<(isize,)>` +} diff --git a/src/test/ui/compile-fail-migration/fn-trait-formatting.stderr b/src/test/ui/compile-fail-migration/fn-trait-formatting.stderr new file mode 100644 index 00000000000..5bf1ed76d5f --- /dev/null +++ b/src/test/ui/compile-fail-migration/fn-trait-formatting.stderr @@ -0,0 +1,46 @@ +error[E0308]: mismatched types + --> $DIR/fn-trait-formatting.rs:16:17 + | +LL | let _: () = (box |_: isize| {}) as Box; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | + = note: expected type `()` + found type `std::boxed::Box` + +error[E0308]: mismatched types + --> $DIR/fn-trait-formatting.rs:20:17 + | +LL | let _: () = (box |_: isize, isize| {}) as Box; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | + = note: expected type `()` + found type `std::boxed::Box` + +error[E0308]: mismatched types + --> $DIR/fn-trait-formatting.rs:24:17 + | +LL | let _: () = (box || -> isize { unimplemented!() }) as Box isize>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` + | + = note: expected type `()` + found type `std::boxed::Box isize>` + +error[E0277]: the trait bound `{integer}: std::ops::Fn<(isize,)>` is not satisfied + --> $DIR/fn-trait-formatting.rs:29:5 + | +LL | needs_fn(1); + | ^^^^^^^^ the trait `std::ops::Fn<(isize,)>` is not implemented for `{integer}` + | + = help: the following implementations were found: + <&'a F as std::ops::Fn> + > +note: required by `needs_fn` + --> $DIR/fn-trait-formatting.rs:13:1 + | +LL | fn needs_fn(x: F) where F: Fn(isize) -> isize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/for-expn.rs b/src/test/ui/compile-fail-migration/for-expn.rs new file mode 100644 index 00000000000..7e9d4df005d --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-expn.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an error on a sub-expresson in a for loop has the correct span. + +fn main() { + // Odd formatting to make sure we get the right span. + for t in & + foo //~ ERROR cannot find value `foo` in this scope + { + } +} diff --git a/src/test/ui/compile-fail-migration/for-expn.stderr b/src/test/ui/compile-fail-migration/for-expn.stderr new file mode 100644 index 00000000000..14c2c1a6d3d --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-expn.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `foo` in this scope + --> $DIR/for-expn.rs:16:7 + | +LL | foo //~ ERROR cannot find value `foo` in this scope + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/for-loop-bogosity.rs b/src/test/ui/compile-fail-migration/for-loop-bogosity.rs new file mode 100644 index 00000000000..96ad184fd35 --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-bogosity.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct MyStruct { + x: isize, + y: isize, +} + +impl MyStruct { + fn next(&mut self) -> Option { + Some(self.x) + } +} + +pub fn main() { + let mut bogus = MyStruct { + x: 1, + y: 2, + }; + for x in bogus { //~ ERROR `MyStruct: std::iter::Iterator` is not satisfied + drop(x); + } +} diff --git a/src/test/ui/compile-fail-migration/for-loop-bogosity.stderr b/src/test/ui/compile-fail-migration/for-loop-bogosity.stderr new file mode 100644 index 00000000000..0476ec06c70 --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-bogosity.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `MyStruct: std::iter::Iterator` is not satisfied + --> $DIR/for-loop-bogosity.rs:27:14 + | +LL | for x in bogus { //~ ERROR `MyStruct: std::iter::Iterator` is not satisfied + | ^^^^^ `MyStruct` is not an iterator; maybe try calling `.iter()` or a similar method + | + = help: the trait `std::iter::Iterator` is not implemented for `MyStruct` + = note: required by `std::iter::IntoIterator::into_iter` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.rs b/src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.rs new file mode 100644 index 00000000000..81c4db68628 --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + for &1 in [1].iter() {} //~ ERROR refutable pattern in `for` loop binding +} diff --git a/src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.stderr b/src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.stderr new file mode 100644 index 00000000000..b76c2ffc240 --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-refutable-pattern-error-message.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in `for` loop binding: `&_` not covered + --> $DIR/for-loop-refutable-pattern-error-message.rs:12:9 + | +LL | for &1 in [1].iter() {} //~ ERROR refutable pattern in `for` loop binding + | ^^ pattern `&_` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/for-loop-type-error.rs b/src/test/ui/compile-fail-migration/for-loop-type-error.rs new file mode 100644 index 00000000000..7f0e40128f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-type-error.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + let x = () + (); //~ ERROR binary operation + + // this shouldn't have a flow-on error: + for _ in x {} +} diff --git a/src/test/ui/compile-fail-migration/for-loop-type-error.stderr b/src/test/ui/compile-fail-migration/for-loop-type-error.stderr new file mode 100644 index 00000000000..f80a457dce3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-type-error.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `+` cannot be applied to type `()` + --> $DIR/for-loop-type-error.rs:12:13 + | +LL | let x = () + (); //~ ERROR binary operation + | ^^^^^^^ + | + = note: an implementation of `std::ops::Add` might be missing for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.rs b/src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.rs new file mode 100644 index 00000000000..fb5553166ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that `for` loops don't introduce artificial +// constraints on the type of the binding (`i`). +// Subtle changes in the desugaring can cause the +// type of elements in the vector to (incorrectly) +// fallback to `!` or `()`. + +fn main() { + for i in Vec::new() { } //~ ERROR type annotations needed +} diff --git a/src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.stderr b/src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.stderr new file mode 100644 index 00000000000..c3723c52fda --- /dev/null +++ b/src/test/ui/compile-fail-migration/for-loop-unconstrained-element-type.stderr @@ -0,0 +1,12 @@ +error[E0282]: type annotations needed + --> $DIR/for-loop-unconstrained-element-type.rs:18:14 + | +LL | for i in Vec::new() { } //~ ERROR type annotations needed + | ^^^^^^^^^^ + | | + | cannot infer type + | the element type for this iterator is not specified + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.rs b/src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.rs new file mode 100644 index 00000000000..da77066150c --- /dev/null +++ b/src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern "C" { + fn g(_: &u8) -> &u8; // OK + fn f() -> &u8; //~ ERROR missing lifetime specifier +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.stderr b/src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.stderr new file mode 100644 index 00000000000..ea15897b3d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/foreign-fn-return-lifetime.stderr @@ -0,0 +1,12 @@ +error[E0106]: missing lifetime specifier + --> $DIR/foreign-fn-return-lifetime.rs:13:15 + | +LL | fn f() -> &u8; //~ ERROR missing lifetime specifier + | ^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from + = help: consider giving it a 'static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.rs b/src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.rs new file mode 100644 index 00000000000..5fad4c3677c --- /dev/null +++ b/src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +mod test { + extern { + pub fn free(); + } +} + +fn main() { + test::free(); + //~^ ERROR call to unsafe function is unsafe +} diff --git a/src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.stderr b/src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.stderr new file mode 100644 index 00000000000..498dd04e08f --- /dev/null +++ b/src/test/ui/compile-fail-migration/foreign-unsafe-fn-called.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/foreign-unsafe-fn-called.rs:19:5 + | +LL | test::free(); + | ^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/fully-qualified-type-name1.rs b/src/test/ui/compile-fail-migration/fully-qualified-type-name1.rs new file mode 100644 index 00000000000..1a7ceb2e763 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fully-qualified-type-name1.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we use fully-qualified type names in error messages. + +fn main() { + let x: Option; + x = 5; + //~^ ERROR mismatched types + //~| expected type `std::option::Option` + //~| found type `{integer}` + //~| expected enum `std::option::Option`, found integral variable +} diff --git a/src/test/ui/compile-fail-migration/fully-qualified-type-name1.stderr b/src/test/ui/compile-fail-migration/fully-qualified-type-name1.stderr new file mode 100644 index 00000000000..55553c084c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fully-qualified-type-name1.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/fully-qualified-type-name1.rs:15:9 + | +LL | x = 5; + | ^ + | | + | expected enum `std::option::Option`, found integral variable + | help: try using a variant of the expected type: `Some(5)` + | + = note: expected type `std::option::Option` + found type `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/fully-qualified-type-name2.rs b/src/test/ui/compile-fail-migration/fully-qualified-type-name2.rs new file mode 100644 index 00000000000..9ba8a11d536 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fully-qualified-type-name2.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we use fully-qualified type names in error messages. + +mod x { + pub enum foo { } +} + +mod y { + pub enum foo { } +} + +fn bar(x: x::foo) -> y::foo { + return x; + //~^ ERROR mismatched types + //~| expected type `y::foo` + //~| found type `x::foo` + //~| expected enum `y::foo`, found enum `x::foo` +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/fully-qualified-type-name2.stderr b/src/test/ui/compile-fail-migration/fully-qualified-type-name2.stderr new file mode 100644 index 00000000000..f2881894b0a --- /dev/null +++ b/src/test/ui/compile-fail-migration/fully-qualified-type-name2.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/fully-qualified-type-name2.rs:22:12 + | +LL | return x; + | ^ expected enum `y::foo`, found enum `x::foo` + | + = note: expected type `y::foo` + found type `x::foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/fully-qualified-type-name3.rs b/src/test/ui/compile-fail-migration/fully-qualified-type-name3.rs new file mode 100644 index 00000000000..dc0c9a093ff --- /dev/null +++ b/src/test/ui/compile-fail-migration/fully-qualified-type-name3.rs @@ -0,0 +1,24 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we use fully-qualified type names in error messages. + +// ignore-test + +type T1 = usize; +type T2 = isize; + +fn bar(x: T1) -> T2 { + return x; + //~^ ERROR mismatched types: expected `T2`, found `T1` +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/fully-qualified-type-name4.rs b/src/test/ui/compile-fail-migration/fully-qualified-type-name4.rs new file mode 100644 index 00000000000..3c8fde751f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fully-qualified-type-name4.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we use fully-qualified type names in error messages. + +use std::option::Option; + +fn bar(x: usize) -> Option { + return x; + //~^ ERROR mismatched types + //~| expected type `std::option::Option` + //~| found type `usize` + //~| expected enum `std::option::Option`, found usize +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/fully-qualified-type-name4.stderr b/src/test/ui/compile-fail-migration/fully-qualified-type-name4.stderr new file mode 100644 index 00000000000..eb855484468 --- /dev/null +++ b/src/test/ui/compile-fail-migration/fully-qualified-type-name4.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/fully-qualified-type-name4.rs:16:12 + | +LL | return x; + | ^ expected enum `std::option::Option`, found usize + | + = note: expected type `std::option::Option` + found type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.nll.stderr b/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.nll.stderr new file mode 100644 index 00000000000..832b570512a --- /dev/null +++ b/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.nll.stderr @@ -0,0 +1,9 @@ +error[E0509]: cannot move out of type `A`, which implements the `Drop` trait + --> $DIR/functional-struct-update-noncopyable.rs:22:14 + | +LL | let _b = A { y: Arc::new(3), ..a }; //~ ERROR cannot move out of type `A` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.rs b/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.rs new file mode 100644 index 00000000000..7ce32bbc975 --- /dev/null +++ b/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.rs @@ -0,0 +1,24 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// issue 7327 + +use std::sync::Arc; + +struct A { y: Arc, x: Arc } + +impl Drop for A { + fn drop(&mut self) { println!("x={}", *self.x); } +} +fn main() { + let a = A { y: Arc::new(1), x: Arc::new(2) }; + let _b = A { y: Arc::new(3), ..a }; //~ ERROR cannot move out of type `A` + let _c = a; +} diff --git a/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.stderr b/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.stderr new file mode 100644 index 00000000000..ad4fb97ae09 --- /dev/null +++ b/src/test/ui/compile-fail-migration/functional-struct-update-noncopyable.stderr @@ -0,0 +1,9 @@ +error[E0509]: cannot move out of type `A`, which implements the `Drop` trait + --> $DIR/functional-struct-update-noncopyable.rs:22:36 + | +LL | let _b = A { y: Arc::new(3), ..a }; //~ ERROR cannot move out of type `A` + | ^ cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.rs b/src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.rs new file mode 100644 index 00000000000..3f41401eb69 --- /dev/null +++ b/src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.rs @@ -0,0 +1,42 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// RFC 736 (and Issue 21407): functional struct update should respect privacy. + +// The `foo` module attempts to maintains an invariant that each `S` +// has a unique `u64` id. +use self::foo::S; +mod foo { + use std::cell::{UnsafeCell}; + + static mut count : UnsafeCell = UnsafeCell::new(1); + + pub struct S { pub a: u8, pub b: String, secret_uid: u64 } + + pub fn make_secrets(a: u8, b: String) -> S { + let val = unsafe { let p = count.get(); let val = *p; *p = val + 1; val }; + println!("creating {}, uid {}", b, val); + S { a: a, b: b, secret_uid: val } + } + + impl Drop for S { + fn drop(&mut self) { + println!("dropping {}, uid {}", self.b, self.secret_uid); + } + } +} + +fn main() { + let s_1 = foo::make_secrets(3, format!("ess one")); + let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ... + //~^ ERROR field `secret_uid` of struct `foo::S` is private + println!("main forged an S named: {}", s_2.b); + // at end of scope, ... both s_1 *and* s_2 get dropped. Boom! +} diff --git a/src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.stderr b/src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.stderr new file mode 100644 index 00000000000..35a2f8460b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/functional-struct-update-respects-privacy.stderr @@ -0,0 +1,9 @@ +error[E0451]: field `secret_uid` of struct `foo::S` is private + --> $DIR/functional-struct-update-respects-privacy.rs:38:49 + | +LL | let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ... + | ^^^ field `secret_uid` is private + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/compile-fail-migration/future-incompatible-lint-group.rs b/src/test/ui/compile-fail-migration/future-incompatible-lint-group.rs new file mode 100644 index 00000000000..5f320135edf --- /dev/null +++ b/src/test/ui/compile-fail-migration/future-incompatible-lint-group.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(future_incompatible)] + +trait Tr { + fn f(u8) {} //~ ERROR anonymous parameters are deprecated + //~^ WARN this was previously accepted +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/future-incompatible-lint-group.stderr b/src/test/ui/compile-fail-migration/future-incompatible-lint-group.stderr new file mode 100644 index 00000000000..56f4ff33eb2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/future-incompatible-lint-group.stderr @@ -0,0 +1,17 @@ +error: anonymous parameters are deprecated and will be removed in the next edition. + --> $DIR/future-incompatible-lint-group.rs:14:10 + | +LL | fn f(u8) {} //~ ERROR anonymous parameters are deprecated + | ^^ help: Try naming the parameter or explicitly ignoring it: `_: u8` + | +note: lint level defined here + --> $DIR/future-incompatible-lint-group.rs:11:9 + | +LL | #![deny(future_incompatible)] + | ^^^^^^^^^^^^^^^^^^^ + = note: #[deny(anonymous_parameters)] implied by #[deny(future_incompatible)] + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41686 + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/gated-attr-literals.rs b/src/test/ui/compile-fail-migration/gated-attr-literals.rs new file mode 100644 index 00000000000..8d36745116b --- /dev/null +++ b/src/test/ui/compile-fail-migration/gated-attr-literals.rs @@ -0,0 +1,43 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that literals in attributes don't parse without the feature gate. + +// gate-test-attr_literals + +#![feature(custom_attribute)] + +#[fake_attr] // OK +#[fake_attr(100)] + //~^ ERROR non-string literals in attributes +#[fake_attr(1, 2, 3)] + //~^ ERROR non-string literals in attributes +#[fake_attr("hello")] + //~^ ERROR string literals in top-level positions, are experimental +#[fake_attr(name = "hello")] // OK +#[fake_attr(1, "hi", key = 12, true, false)] + //~^ ERROR non-string literals in attributes, or string literals in top-level positions +#[fake_attr(key = "hello", val = 10)] + //~^ ERROR non-string literals in attributes +#[fake_attr(key("hello"), val(10))] + //~^ ERROR non-string literals in attributes, or string literals in top-level positions +#[fake_attr(enabled = true, disabled = false)] + //~^ ERROR non-string literals in attributes +#[fake_attr(true)] + //~^ ERROR non-string literals in attributes +#[fake_attr(pi = 3.14159)] + //~^ ERROR non-string literals in attributes +#[fake_attr(b"hi")] + //~^ ERROR string literals in top-level positions, are experimental +#[fake_doc(r"doc")] + //~^ ERROR string literals in top-level positions, are experimental +struct Q { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/gated-attr-literals.stderr b/src/test/ui/compile-fail-migration/gated-attr-literals.stderr new file mode 100644 index 00000000000..e123c7cfa1a --- /dev/null +++ b/src/test/ui/compile-fail-migration/gated-attr-literals.stderr @@ -0,0 +1,195 @@ +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:20:1 + | +LL | #[fake_attr] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:21:1 + | +LL | #[fake_attr(100)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:21:1 + | +LL | #[fake_attr(100)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:23:1 + | +LL | #[fake_attr(1, 2, 3)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:23:1 + | +LL | #[fake_attr(1, 2, 3)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:25:1 + | +LL | #[fake_attr("hello")] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:25:1 + | +LL | #[fake_attr("hello")] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:27:1 + | +LL | #[fake_attr(name = "hello")] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:28:1 + | +LL | #[fake_attr(1, "hi", key = 12, true, false)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:28:1 + | +LL | #[fake_attr(1, "hi", key = 12, true, false)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:30:1 + | +LL | #[fake_attr(key = "hello", val = 10)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:30:1 + | +LL | #[fake_attr(key = "hello", val = 10)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:32:1 + | +LL | #[fake_attr(key("hello"), val(10))] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:32:1 + | +LL | #[fake_attr(key("hello"), val(10))] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:34:1 + | +LL | #[fake_attr(enabled = true, disabled = false)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:34:1 + | +LL | #[fake_attr(enabled = true, disabled = false)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:36:1 + | +LL | #[fake_attr(true)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:36:1 + | +LL | #[fake_attr(true)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:38:1 + | +LL | #[fake_attr(pi = 3.14159)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:38:1 + | +LL | #[fake_attr(pi = 3.14159)] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:40:1 + | +LL | #[fake_attr(b"hi")] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:40:1 + | +LL | #[fake_attr(b"hi")] //~ ERROR attribute `fake_attr` is currently unknown + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error[E0658]: The attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/gated-attr-literals.rs:42:1 + | +LL | #[fake_doc(r"doc")] //~ ERROR attribute `fake_doc` is currently unknown + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981) + --> $DIR/gated-attr-literals.rs:42:1 + | +LL | #[fake_doc(r"doc")] //~ ERROR attribute `fake_doc` is currently unknown + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(attr_literals)] to the crate attributes to enable + +error: aborting due to 24 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/gated-bad-feature.rs b/src/test/ui/compile-fail-migration/gated-bad-feature.rs new file mode 100644 index 00000000000..5baafd41531 --- /dev/null +++ b/src/test/ui/compile-fail-migration/gated-bad-feature.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature( + foo_bar_baz, + foo(bar), + foo = "baz" +)] +//~^^^ ERROR: malformed feature +//~^^^ ERROR: malformed feature + +#![feature] //~ ERROR: malformed feature +#![feature = "foo"] //~ ERROR: malformed feature + +#![feature(test_removed_feature)] //~ ERROR: feature has been removed diff --git a/src/test/ui/compile-fail-migration/gated-bad-feature.stderr b/src/test/ui/compile-fail-migration/gated-bad-feature.stderr new file mode 100644 index 00000000000..2bed241d68c --- /dev/null +++ b/src/test/ui/compile-fail-migration/gated-bad-feature.stderr @@ -0,0 +1,38 @@ +error[E0556]: malformed feature, expected just one word + --> $DIR/gated-bad-feature.rs:13:5 + | +LL | foo(bar), + | ^^^^^^^^ + +error[E0556]: malformed feature, expected just one word + --> $DIR/gated-bad-feature.rs:14:5 + | +LL | foo = "baz" + | ^^^^^^^^^^^ + +error[E0555]: malformed feature attribute, expected #![feature(...)] + --> $DIR/gated-bad-feature.rs:19:1 + | +LL | #![feature] //~ ERROR: malformed feature + | ^^^^^^^^^^^ + +error[E0555]: malformed feature attribute, expected #![feature(...)] + --> $DIR/gated-bad-feature.rs:20:1 + | +LL | #![feature = "foo"] //~ ERROR: malformed feature + | ^^^^^^^^^^^^^^^^^^^ + +error[E0557]: feature has been removed + --> $DIR/gated-bad-feature.rs:22:12 + | +LL | #![feature(test_removed_feature)] //~ ERROR: feature has been removed + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0601]: `main` function not found in crate `gated_bad_feature` + | + = note: consider adding a `main` function to `$DIR/gated-bad-feature.rs` + +error: aborting due to 6 previous errors + +Some errors occurred: E0555, E0556, E0557, E0601. +For more information about an error, try `rustc --explain E0555`. diff --git a/src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.rs b/src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.rs new file mode 100644 index 00000000000..13abdf616b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.rs @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generator_trait)] +#![feature(generators)] + +// Test that we cannot create a generator that returns a value of its +// own type. + +use std::ops::Generator; + +pub fn want_cyclic_generator_return(_: T) + where T: Generator +{ +} + +fn supply_cyclic_generator_return() { + want_cyclic_generator_return(|| { + //~^ ERROR type mismatch + if false { yield None.unwrap(); } + None.unwrap() + }) +} + +pub fn want_cyclic_generator_yield(_: T) + where T: Generator +{ +} + +fn supply_cyclic_generator_yield() { + want_cyclic_generator_yield(|| { + //~^ ERROR type mismatch + if false { yield None.unwrap(); } + None.unwrap() + }) +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.stderr b/src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.stderr new file mode 100644 index 00000000000..a52e717ebae --- /dev/null +++ b/src/test/ui/compile-fail-migration/generator-yielding-or-returning-itself.stderr @@ -0,0 +1,39 @@ +error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:25:34: 29:6 _] as std::ops::Generator>::Return == [generator@$DIR/generator-yielding-or-returning-itself.rs:25:34: 29:6 _]` + --> $DIR/generator-yielding-or-returning-itself.rs:25:5 + | +LL | want_cyclic_generator_return(|| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size + | + = note: closures cannot capture themselves or take themselves as argument; + this error may be the result of a recent compiler bug-fix, + see https://github.com/rust-lang/rust/issues/46062 for more details +note: required by `want_cyclic_generator_return` + --> $DIR/generator-yielding-or-returning-itself.rs:19:1 + | +LL | / pub fn want_cyclic_generator_return(_: T) +LL | | where T: Generator +LL | | { +LL | | } + | |_^ + +error[E0271]: type mismatch resolving `<[generator@$DIR/generator-yielding-or-returning-itself.rs:38:33: 42:6 _] as std::ops::Generator>::Yield == [generator@$DIR/generator-yielding-or-returning-itself.rs:38:33: 42:6 _]` + --> $DIR/generator-yielding-or-returning-itself.rs:38:5 + | +LL | want_cyclic_generator_yield(|| { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic type of infinite size + | + = note: closures cannot capture themselves or take themselves as argument; + this error may be the result of a recent compiler bug-fix, + see https://github.com/rust-lang/rust/issues/46062 for more details +note: required by `want_cyclic_generator_yield` + --> $DIR/generator-yielding-or-returning-itself.rs:32:1 + | +LL | / pub fn want_cyclic_generator_yield(_: T) +LL | | where T: Generator +LL | | { +LL | | } + | |_^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/generic-extern-lifetime.rs b/src/test/ui/compile-fail-migration/generic-extern-lifetime.rs new file mode 100644 index 00000000000..fa2d4743937 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-extern-lifetime.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test to make sure the names of the lifetimes are correctly resolved +// in extern blocks. + +extern { + pub fn life<'a>(x:&'a i32); + pub fn life2<'b>(x:&'a i32, y:&'b i32); //~ ERROR use of undeclared lifetime name `'a` + pub fn life3<'a>(x:&'a i32, y:&i32) -> &'a i32; + pub fn life4<'b>(x: for<'c> fn(&'a i32)); //~ ERROR use of undeclared lifetime name `'a` + pub fn life5<'b>(x: for<'c> fn(&'b i32)); + pub fn life6<'b>(x: for<'c> fn(&'c i32)); + pub fn life7<'b>() -> for<'c> fn(&'a i32); //~ ERROR use of undeclared lifetime name `'a` + pub fn life8<'b>() -> for<'c> fn(&'b i32); + pub fn life9<'b>() -> for<'c> fn(&'c i32); +} +fn main() {} diff --git a/src/test/ui/compile-fail-migration/generic-extern-lifetime.stderr b/src/test/ui/compile-fail-migration/generic-extern-lifetime.stderr new file mode 100644 index 00000000000..9276ae0d412 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-extern-lifetime.stderr @@ -0,0 +1,21 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/generic-extern-lifetime.rs:16:24 + | +LL | pub fn life2<'b>(x:&'a i32, y:&'b i32); //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/generic-extern-lifetime.rs:18:36 + | +LL | pub fn life4<'b>(x: for<'c> fn(&'a i32)); //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/generic-extern-lifetime.rs:21:38 + | +LL | pub fn life7<'b>() -> for<'c> fn(&'a i32); //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/compile-fail-migration/generic-extern.rs b/src/test/ui/compile-fail-migration/generic-extern.rs new file mode 100644 index 00000000000..a7140d1be87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-extern.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn foo(); //~ ERROR foreign items may not have type parameters +} + +fn main() { + foo::(); +} diff --git a/src/test/ui/compile-fail-migration/generic-extern.stderr b/src/test/ui/compile-fail-migration/generic-extern.stderr new file mode 100644 index 00000000000..c1ba2cced54 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-extern.stderr @@ -0,0 +1,11 @@ +error[E0044]: foreign items may not have type parameters + --> $DIR/generic-extern.rs:12:5 + | +LL | fn foo(); //~ ERROR foreign items may not have type parameters + | ^^^^^^^^^^^^ can't have type parameters + | + = help: use specialization instead of type parameters by replacing them with concrete types like `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0044`. diff --git a/src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.rs b/src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.rs new file mode 100644 index 00000000000..3f5f7bb3a53 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker; + +struct Foo( + marker::PhantomData<(A,B,C)>); + +impl Foo { + fn new() -> Foo {Foo(marker::PhantomData)} +} + +fn main() { + Foo::::new(); + //~^ ERROR wrong number of type arguments +} diff --git a/src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.stderr b/src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.stderr new file mode 100644 index 00000000000..a10b500f9f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-impl-less-params-with-defaults.stderr @@ -0,0 +1,9 @@ +error[E0243]: wrong number of type arguments: expected at least 2, found 1 + --> $DIR/generic-impl-less-params-with-defaults.rs:21:5 + | +LL | Foo::::new(); + | ^^^^^^^^^^^^^^^^^ expected at least 2 type arguments + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0243`. diff --git a/src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.rs b/src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.rs new file mode 100644 index 00000000000..31411992089 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker; + +struct Heap; + +struct Vec( + marker::PhantomData<(T,A)>); + +impl Vec { + fn new() -> Vec {Vec(marker::PhantomData)} +} + +fn main() { + Vec::::new(); + //~^ ERROR wrong number of type arguments +} diff --git a/src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.stderr b/src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.stderr new file mode 100644 index 00000000000..6b54baefb1d --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-impl-more-params-with-defaults.stderr @@ -0,0 +1,9 @@ +error[E0244]: wrong number of type arguments: expected at most 2, found 3 + --> $DIR/generic-impl-more-params-with-defaults.rs:23:5 + | +LL | Vec::::new(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected at most 2 type arguments + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0244`. diff --git a/src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.rs b/src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.rs new file mode 100644 index 00000000000..9b9f09f4777 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This code used to produce an ICE on the definition of trait Bar +// with the following message: +// +// Type parameter out of range when substituting in region 'a (root +// type=fn(Self) -> 'astr) (space=FnSpace, index=0) +// +// Regression test for issue #16218. + +trait Bar<'a> { + fn dummy(&'a self); +} + +trait Foo<'a> { + fn dummy(&'a self) { } + fn bar<'b, T: Bar<'b>>(self) -> &'b str; +} + +impl<'a> Foo<'a> for &'a str { + fn bar>(self) -> &'a str { panic!() } //~ ERROR lifetime +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.stderr b/src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.stderr new file mode 100644 index 00000000000..182eab0a69b --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-lifetime-trait-impl.stderr @@ -0,0 +1,12 @@ +error[E0195]: lifetime parameters or bounds on method `bar` do not match the trait declaration + --> $DIR/generic-lifetime-trait-impl.rs:29:11 + | +LL | fn bar<'b, T: Bar<'b>>(self) -> &'b str; + | ---------------- lifetimes in impl do not match this method in trait +... +LL | fn bar>(self) -> &'a str { panic!() } //~ ERROR lifetime + | ^^^^^^^^^^^^ lifetimes do not match method in trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0195`. diff --git a/src/test/ui/compile-fail-migration/generic-no-mangle.rs b/src/test/ui/compile-fail-migration/generic-no-mangle.rs new file mode 100644 index 00000000000..2b4c94d281f --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-no-mangle.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(no_mangle_generic_items)] + +#[no_mangle] +pub fn foo() {} //~ ERROR functions generic over types must be mangled + +#[no_mangle] +pub extern fn bar() {} //~ ERROR functions generic over types must be mangled + +#[no_mangle] +pub fn baz(x: &i32) -> &i32 { x } + +#[no_mangle] +pub fn qux<'a>(x: &'a i32) -> &i32 { x } + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/generic-no-mangle.stderr b/src/test/ui/compile-fail-migration/generic-no-mangle.stderr new file mode 100644 index 00000000000..4eaa3973329 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-no-mangle.stderr @@ -0,0 +1,24 @@ +error: functions generic over types must be mangled + --> $DIR/generic-no-mangle.rs:14:1 + | +LL | #[no_mangle] + | ------------ help: remove this attribute +LL | pub fn foo() {} //~ ERROR functions generic over types must be mangled + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/generic-no-mangle.rs:11:9 + | +LL | #![deny(no_mangle_generic_items)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: functions generic over types must be mangled + --> $DIR/generic-no-mangle.rs:17:1 + | +LL | #[no_mangle] + | ------------ help: remove this attribute +LL | pub extern fn bar() {} //~ ERROR functions generic over types must be mangled + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/generic-non-trailing-defaults.rs b/src/test/ui/compile-fail-migration/generic-non-trailing-defaults.rs new file mode 100644 index 00000000000..13b7753082c --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-non-trailing-defaults.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Heap; + +struct Vec(A, T); +//~^ ERROR type parameters with a default must be trailing + +struct Foo, C>(A, B, C); +//~^ ERROR type parameters with a default must be trailing +//~| ERROR type parameters with a default cannot use forward declared identifiers + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/generic-non-trailing-defaults.stderr b/src/test/ui/compile-fail-migration/generic-non-trailing-defaults.stderr new file mode 100644 index 00000000000..ce8badf6d30 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-non-trailing-defaults.stderr @@ -0,0 +1,21 @@ +error: type parameters with a default must be trailing + --> $DIR/generic-non-trailing-defaults.rs:13:12 + | +LL | struct Vec(A, T); + | ^ + +error: type parameters with a default must be trailing + --> $DIR/generic-non-trailing-defaults.rs:16:15 + | +LL | struct Foo, C>(A, B, C); + | ^ + +error[E0128]: type parameters with a default cannot use forward declared identifiers + --> $DIR/generic-non-trailing-defaults.rs:16:23 + | +LL | struct Foo, C>(A, B, C); + | ^ defaulted type parameters cannot be forward declared + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0128`. diff --git a/src/test/ui/compile-fail-migration/generic-type-params-forward-mention.rs b/src/test/ui/compile-fail-migration/generic-type-params-forward-mention.rs new file mode 100644 index 00000000000..bfa6af0da43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-type-params-forward-mention.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that we get an error and not an ICE for this problematic case. +struct Foo, U = bool>(T, U); +//~^ ERROR type parameters with a default cannot use forward declared identifiers +fn main() { + let x: Foo; +} diff --git a/src/test/ui/compile-fail-migration/generic-type-params-forward-mention.stderr b/src/test/ui/compile-fail-migration/generic-type-params-forward-mention.stderr new file mode 100644 index 00000000000..542716326f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-type-params-forward-mention.stderr @@ -0,0 +1,9 @@ +error[E0128]: type parameters with a default cannot use forward declared identifiers + --> $DIR/generic-type-params-forward-mention.rs:12:23 + | +LL | struct Foo, U = bool>(T, U); + | ^ defaulted type parameters cannot be forward declared + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0128`. diff --git a/src/test/ui/compile-fail-migration/generic-type-params-name-repr.rs b/src/test/ui/compile-fail-migration/generic-type-params-name-repr.rs new file mode 100644 index 00000000000..71d7cf792e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-type-params-name-repr.rs @@ -0,0 +1,61 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker; + +struct A; +struct B; +struct C; +struct Foo(marker::PhantomData<(T,U,V)>); + +struct Hash(marker::PhantomData); +struct HashMap>(marker::PhantomData<(K,V,H)>); + +fn main() { + // Ensure that the printed type doesn't include the default type params... + let _: Foo = (); + //~^ ERROR mismatched types + //~| expected type `Foo` + //~| found type `()` + //~| expected struct `Foo`, found () + + // ...even when they're present, but the same types as the defaults. + let _: Foo = (); + //~^ ERROR mismatched types + //~| expected type `Foo` + //~| found type `()` + //~| expected struct `Foo`, found () + + // Including cases where the default is using previous type params. + let _: HashMap = (); + //~^ ERROR mismatched types + //~| expected type `HashMap` + //~| found type `()` + //~| expected struct `HashMap`, found () + let _: HashMap> = (); + //~^ ERROR mismatched types + //~| expected type `HashMap` + //~| found type `()` + //~| expected struct `HashMap`, found () + + // But not when there's a different type in between. + let _: Foo = (); + //~^ ERROR mismatched types + //~| expected type `Foo` + //~| found type `()` + //~| expected struct `Foo`, found () + + // And don't print <> at all when there's just defaults. + let _: Foo = (); + //~^ ERROR mismatched types + //~| expected type `Foo` + //~| found type `()` + //~| expected struct `Foo`, found () +} diff --git a/src/test/ui/compile-fail-migration/generic-type-params-name-repr.stderr b/src/test/ui/compile-fail-migration/generic-type-params-name-repr.stderr new file mode 100644 index 00000000000..1c65aeadae6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/generic-type-params-name-repr.stderr @@ -0,0 +1,57 @@ +error[E0308]: mismatched types + --> $DIR/generic-type-params-name-repr.rs:23:25 + | +LL | let _: Foo = (); + | ^^ expected struct `Foo`, found () + | + = note: expected type `Foo` + found type `()` + +error[E0308]: mismatched types + --> $DIR/generic-type-params-name-repr.rs:30:31 + | +LL | let _: Foo = (); + | ^^ expected struct `Foo`, found () + | + = note: expected type `Foo` + found type `()` + +error[E0308]: mismatched types + --> $DIR/generic-type-params-name-repr.rs:37:37 + | +LL | let _: HashMap = (); + | ^^ expected struct `HashMap`, found () + | + = note: expected type `HashMap` + found type `()` + +error[E0308]: mismatched types + --> $DIR/generic-type-params-name-repr.rs:42:51 + | +LL | let _: HashMap> = (); + | ^^ expected struct `HashMap`, found () + | + = note: expected type `HashMap` + found type `()` + +error[E0308]: mismatched types + --> $DIR/generic-type-params-name-repr.rs:49:31 + | +LL | let _: Foo = (); + | ^^ expected struct `Foo`, found () + | + = note: expected type `Foo` + found type `()` + +error[E0308]: mismatched types + --> $DIR/generic-type-params-name-repr.rs:56:27 + | +LL | let _: Foo = (); + | ^^ expected struct `Foo`, found () + | + = note: expected type `Foo` + found type `()` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/glob-cycles.rs b/src/test/ui/compile-fail-migration/glob-cycles.rs new file mode 100644 index 00000000000..8f1b8ec91db --- /dev/null +++ b/src/test/ui/compile-fail-migration/glob-cycles.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +mod foo { + pub use bar::*; + pub use main as f; +} + +mod bar { + pub use foo::*; +} + +pub use foo::*; +pub use baz::*; +mod baz { + pub use super::*; +} + +#[rustc_error] +pub fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/glob-cycles.stderr b/src/test/ui/compile-fail-migration/glob-cycles.stderr new file mode 100644 index 00000000000..a9fd9306e21 --- /dev/null +++ b/src/test/ui/compile-fail-migration/glob-cycles.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/glob-cycles.rs:29:1 + | +LL | pub fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/glob-resolve1.rs b/src/test/ui/compile-fail-migration/glob-resolve1.rs new file mode 100644 index 00000000000..2723b4ce256 --- /dev/null +++ b/src/test/ui/compile-fail-migration/glob-resolve1.rs @@ -0,0 +1,41 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure that globs only bring in public things. + +use bar::*; + +mod bar { + use self::fpriv as import; + fn fpriv() {} + extern { + fn epriv(); + } + enum A { A1 } + pub enum B { B1 } + + struct C; + + type D = isize; +} + +fn foo() {} + +fn main() { + fpriv(); //~ ERROR cannot find function `fpriv` in this scope + epriv(); //~ ERROR cannot find function `epriv` in this scope + B; //~ ERROR expected value, found enum `B` + C; //~ ERROR cannot find value `C` in this scope + import(); //~ ERROR: cannot find function `import` in this scope + + foo::(); //~ ERROR: cannot find type `A` in this scope + foo::(); //~ ERROR: cannot find type `C` in this scope + foo::(); //~ ERROR: cannot find type `D` in this scope +} diff --git a/src/test/ui/compile-fail-migration/glob-resolve1.stderr b/src/test/ui/compile-fail-migration/glob-resolve1.stderr new file mode 100644 index 00000000000..650dd2c3b19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/glob-resolve1.stderr @@ -0,0 +1,79 @@ +error[E0425]: cannot find function `fpriv` in this scope + --> $DIR/glob-resolve1.rs:32:5 + | +LL | fpriv(); //~ ERROR cannot find function `fpriv` in this scope + | ^^^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use bar::fpriv; + | + +error[E0425]: cannot find function `epriv` in this scope + --> $DIR/glob-resolve1.rs:33:5 + | +LL | epriv(); //~ ERROR cannot find function `epriv` in this scope + | ^^^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use bar::epriv; + | + +error[E0423]: expected value, found enum `B` + --> $DIR/glob-resolve1.rs:34:5 + | +LL | B; //~ ERROR expected value, found enum `B` + | ^ + | + = note: did you mean to use one of the following variants? + - `B::B1` + +error[E0425]: cannot find value `C` in this scope + --> $DIR/glob-resolve1.rs:35:5 + | +LL | C; //~ ERROR cannot find value `C` in this scope + | ^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use bar::C; + | + +error[E0425]: cannot find function `import` in this scope + --> $DIR/glob-resolve1.rs:36:5 + | +LL | import(); //~ ERROR: cannot find function `import` in this scope + | ^^^^^^ not found in this scope + +error[E0412]: cannot find type `A` in this scope + --> $DIR/glob-resolve1.rs:38:11 + | +LL | foo::(); //~ ERROR: cannot find type `A` in this scope + | ^ did you mean `B`? +help: possible candidate is found in another module, you can import it into scope + | +LL | use bar::A; + | + +error[E0412]: cannot find type `C` in this scope + --> $DIR/glob-resolve1.rs:39:11 + | +LL | foo::(); //~ ERROR: cannot find type `C` in this scope + | ^ did you mean `B`? +help: possible candidate is found in another module, you can import it into scope + | +LL | use bar::C; + | + +error[E0412]: cannot find type `D` in this scope + --> $DIR/glob-resolve1.rs:40:11 + | +LL | foo::(); //~ ERROR: cannot find type `D` in this scope + | ^ did you mean `B`? +help: possible candidate is found in another module, you can import it into scope + | +LL | use bar::D; + | + +error: aborting due to 8 previous errors + +Some errors occurred: E0412, E0423, E0425. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.nll.stderr b/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.nll.stderr new file mode 100644 index 00000000000..ec52d19cd1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.nll.stderr @@ -0,0 +1,15 @@ +error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable + --> $DIR/hashmap-iter-value-lifetime.rs:17:5 + | +LL | let (_, thing) = my_stuff.iter().next().unwrap(); + | -------- immutable borrow occurs here +LL | +LL | my_stuff.clear(); //~ ERROR cannot borrow + | ^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | println!("{}", *thing); + | ------ borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.rs b/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.rs new file mode 100644 index 00000000000..9cf145a1ff3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let mut my_stuff = std::collections::HashMap::new(); + my_stuff.insert(0, 42); + + let (_, thing) = my_stuff.iter().next().unwrap(); + + my_stuff.clear(); //~ ERROR cannot borrow + + println!("{}", *thing); +} diff --git a/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.stderr b/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.stderr new file mode 100644 index 00000000000..16e9c527391 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hashmap-iter-value-lifetime.stderr @@ -0,0 +1,15 @@ +error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable + --> $DIR/hashmap-iter-value-lifetime.rs:17:5 + | +LL | let (_, thing) = my_stuff.iter().next().unwrap(); + | -------- immutable borrow occurs here +LL | +LL | my_stuff.clear(); //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/hashmap-lifetimes.rs b/src/test/ui/compile-fail-migration/hashmap-lifetimes.rs new file mode 100644 index 00000000000..6858599f63a --- /dev/null +++ b/src/test/ui/compile-fail-migration/hashmap-lifetimes.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let mut my_stuff = std::collections::HashMap::new(); + my_stuff.insert(0, 42); + + let mut it = my_stuff.iter(); + my_stuff.insert(1, 43); //~ ERROR cannot borrow +} diff --git a/src/test/ui/compile-fail-migration/hashmap-lifetimes.stderr b/src/test/ui/compile-fail-migration/hashmap-lifetimes.stderr new file mode 100644 index 00000000000..fa3e6452325 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hashmap-lifetimes.stderr @@ -0,0 +1,13 @@ +error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable + --> $DIR/hashmap-lifetimes.rs:16:5 + | +LL | let mut it = my_stuff.iter(); + | -------- immutable borrow occurs here +LL | my_stuff.insert(1, 43); //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/hidden-rt-injection.rs b/src/test/ui/compile-fail-migration/hidden-rt-injection.rs new file mode 100644 index 00000000000..a27a8464707 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hidden-rt-injection.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This is testing that users can't access the runtime crate. + +mod m { + // The rt has been called both 'native' and 'rt' + use native; //~ ERROR unresolved import +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/hidden-rt-injection.stderr b/src/test/ui/compile-fail-migration/hidden-rt-injection.stderr new file mode 100644 index 00000000000..103cdf05485 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hidden-rt-injection.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `native` + --> $DIR/hidden-rt-injection.rs:15:9 + | +LL | use native; //~ ERROR unresolved import + | ^^^^^^ no `native` in the root + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/hidden-rt-injection2.rs b/src/test/ui/compile-fail-migration/hidden-rt-injection2.rs new file mode 100644 index 00000000000..fa6584ddd98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hidden-rt-injection2.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This is testing that users can't access the runtime crate. + +mod m { + // The rt has been called both 'native' and 'rt' + use rt; //~ ERROR unresolved import +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/hidden-rt-injection2.stderr b/src/test/ui/compile-fail-migration/hidden-rt-injection2.stderr new file mode 100644 index 00000000000..df0527f307a --- /dev/null +++ b/src/test/ui/compile-fail-migration/hidden-rt-injection2.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `rt` + --> $DIR/hidden-rt-injection2.rs:15:9 + | +LL | use rt; //~ ERROR unresolved import + | ^^ no `rt` in the root + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr new file mode 100644 index 00000000000..d668a931459 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, +LL | | for<'a> fn(&'a u32, &'a u32) -> &'a u32) } + | |_________________________________________________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option fn(&'a u32, &'b u32) -> &'a u32>` + found type `std::option::Option fn(&'a u32, &'a u32) -> &'a u32>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_vs_bound_a.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_vs_bound_a.stderr new file mode 100644 index 00000000000..23854f9c147 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_b_vs_bound_a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), +LL | | for<'a> fn(&'a u32, &'a u32)) } + | |__________________________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option fn(&'a u32, &'b u32)>` + found type `std::option::Option fn(&'a u32, &'a u32)>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_a.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_a.stderr new file mode 100644 index 00000000000..01a9f578fbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_a.stderr @@ -0,0 +1,14 @@ +error: compilation successful + --> $DIR/hr-subtype.rs:110:1 + | +LL | / fn main() { +LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful +LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful +LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_b.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_b.stderr new file mode 100644 index 00000000000..01a9f578fbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_bound_b.stderr @@ -0,0 +1,14 @@ +error: compilation successful + --> $DIR/hr-subtype.rs:110:1 + | +LL | / fn main() { +LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful +LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful +LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_free_x.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_free_x.stderr new file mode 100644 index 00000000000..14e498593f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_a_vs_free_x.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), +LL | | fn(&'x u32)) } + | |___________________________________________- in this macro invocation + | + = note: expected type `std::option::Option fn(&'a u32)>` + found type `std::option::Option` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr new file mode 100644 index 00000000000..a66a4ace910 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), +LL | | for<'a> fn(Co<'a>, Co<'a>)) } + | |______________________________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option fn(Co<'a>, Co<'b>)>` + found type `std::option::Option fn(Co<'a>, Co<'a>)>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr new file mode 100644 index 00000000000..9f94b45140c --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, +LL | | for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } + | |______________________________________________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option fn(Co<'a>, Co<'b>) -> Contra<'a>>` + found type `std::option::Option fn(Co<'a>, Co<'a>) -> Contra<'a>>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_vs_bound_co_b.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_vs_bound_co_b.stderr new file mode 100644 index 00000000000..01a9f578fbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_co_a_vs_bound_co_b.stderr @@ -0,0 +1,14 @@ +error: compilation successful + --> $DIR/hr-subtype.rs:110:1 + | +LL | / fn main() { +LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful +LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful +LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr new file mode 100644 index 00000000000..511369703ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, +LL | | for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } + | |______________________________________________________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option fn(Contra<'a>, Contra<'b>) -> Co<'a>>` + found type `std::option::Option fn(Contra<'a>, Contra<'a>) -> Co<'a>>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr new file mode 100644 index 00000000000..d39d5f76a6e --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), +LL | | for<'a> fn(Inv<'a>, Inv<'a>)) } + | |__________________________________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option fn(Inv<'a>, Inv<'b>)>` + found type `std::option::Option fn(Inv<'a>, Inv<'a>)>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr b/src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr new file mode 100644 index 00000000000..01a9f578fbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr @@ -0,0 +1,14 @@ +error: compilation successful + --> $DIR/hr-subtype.rs:110:1 + | +LL | / fn main() { +LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful +LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful +LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr b/src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr new file mode 100644 index 00000000000..1999df909ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr @@ -0,0 +1,34 @@ +warning: not reporting region error due to nll + --> $DIR/hr-subtype.rs:43:26 + | +LL | gimme::<$t2>(None::<$t1>); + | ^^^^^^^^^^^ +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation + +warning: not reporting region error due to nll + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation + +error: compilation successful + --> $DIR/hr-subtype.rs:110:1 + | +LL | / fn main() { +LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful +LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful +LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.stderr b/src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.stderr new file mode 100644 index 00000000000..bf562700bb4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.free_inv_x_vs_free_inv_y.stderr @@ -0,0 +1,65 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:43:26 + | +LL | gimme::<$t2>(None::<$t1>); + | ^^^^^^^^^^^ lifetime mismatch +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option)>` + found type `std::option::Option)>` +note: the lifetime 'x as defined on the function body at 42:20... + --> $DIR/hr-subtype.rs:42:20 + | +LL | fn subtype<'x,'y:'x,'z:'y>() { + | ^^ +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation +note: ...does not necessarily outlive the lifetime 'y as defined on the function body at 42:23 + --> $DIR/hr-subtype.rs:42:23 + | +LL | fn subtype<'x,'y:'x,'z:'y>() { + | ^^ +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation + +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ lifetime mismatch +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation + | + = note: expected type `std::option::Option)>` + found type `std::option::Option)>` +note: the lifetime 'x as defined on the function body at 48:22... + --> $DIR/hr-subtype.rs:48:22 + | +LL | fn supertype<'x,'y:'x,'z:'y>() { + | ^^ +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation +note: ...does not necessarily outlive the lifetime 'y as defined on the function body at 48:25 + --> $DIR/hr-subtype.rs:48:25 + | +LL | fn supertype<'x,'y:'x,'z:'y>() { + | ^^ +... +LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), +LL | | fn(Inv<'y>)) } + | |__________________________________________________- in this macro invocation + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_x.stderr b/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_x.stderr new file mode 100644 index 00000000000..01a9f578fbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_x.stderr @@ -0,0 +1,14 @@ +error: compilation successful + --> $DIR/hr-subtype.rs:110:1 + | +LL | / fn main() { +LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful +LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful +LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.nll.stderr b/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.nll.stderr new file mode 100644 index 00000000000..f76b26b5191 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.nll.stderr @@ -0,0 +1,24 @@ +warning: not reporting region error due to nll + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ +... +LL | / check! { free_x_vs_free_y: (fn(&'x u32), +LL | | fn(&'y u32)) } + | |__________________________________________- in this macro invocation + +error: compilation successful + --> $DIR/hr-subtype.rs:110:1 + | +LL | / fn main() { +LL | | //[bound_a_vs_bound_a]~^ ERROR compilation successful +LL | | //[bound_a_vs_bound_b]~^^ ERROR compilation successful +LL | | //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +LL | | //[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +LL | | //[free_x_vs_free_x]~^^^^^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.stderr b/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.stderr new file mode 100644 index 00000000000..228f6db38fb --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.free_x_vs_free_y.stderr @@ -0,0 +1,34 @@ +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:49:26 + | +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ lifetime mismatch +... +LL | / check! { free_x_vs_free_y: (fn(&'x u32), +LL | | fn(&'y u32)) } + | |__________________________________________- in this macro invocation + | + = note: expected type `std::option::Option` + found type `std::option::Option` +note: the lifetime 'x as defined on the function body at 48:22... + --> $DIR/hr-subtype.rs:48:22 + | +LL | fn supertype<'x,'y:'x,'z:'y>() { + | ^^ +... +LL | / check! { free_x_vs_free_y: (fn(&'x u32), +LL | | fn(&'y u32)) } + | |__________________________________________- in this macro invocation +note: ...does not necessarily outlive the lifetime 'y as defined on the function body at 48:25 + --> $DIR/hr-subtype.rs:48:25 + | +LL | fn supertype<'x,'y:'x,'z:'y>() { + | ^^ +... +LL | / check! { free_x_vs_free_y: (fn(&'x u32), +LL | | fn(&'y u32)) } + | |__________________________________________- in this macro invocation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/hr-subtype.rs b/src/test/ui/compile-fail-migration/hr-subtype.rs new file mode 100644 index 00000000000..86df2382732 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hr-subtype.rs @@ -0,0 +1,116 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Targeted tests for the higher-ranked subtyping code. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +// revisions: bound_a_vs_bound_a +// revisions: bound_a_vs_bound_b +// revisions: bound_inv_a_vs_bound_inv_b +// revisions: bound_co_a_vs_bound_co_b +// revisions: bound_a_vs_free_x +// revisions: free_x_vs_free_x +// revisions: free_x_vs_free_y +// revisions: free_inv_x_vs_free_inv_y +// revisions: bound_a_b_vs_bound_a +// revisions: bound_co_a_b_vs_bound_co_a +// revisions: bound_contra_a_contra_b_ret_co_a +// revisions: bound_co_a_co_b_ret_contra_a +// revisions: bound_inv_a_b_vs_bound_inv_a +// revisions: bound_a_b_ret_a_vs_bound_a_ret_a + +fn gimme(_: Option) { } + +struct Inv<'a> { x: *mut &'a u32 } + +struct Co<'a> { x: fn(&'a u32) } + +struct Contra<'a> { x: &'a u32 } + +macro_rules! check { + ($rev:ident: ($t1:ty, $t2:ty)) => { + #[cfg($rev)] + fn subtype<'x,'y:'x,'z:'y>() { + gimme::<$t2>(None::<$t1>); + //[free_inv_x_vs_free_inv_y]~^ ERROR mismatched types + } + + #[cfg($rev)] + fn supertype<'x,'y:'x,'z:'y>() { + gimme::<$t1>(None::<$t2>); + //[bound_a_vs_free_x]~^ ERROR mismatched types + //[free_x_vs_free_y]~^^ ERROR mismatched types + //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR mismatched types + //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR mismatched types + //[free_inv_x_vs_free_inv_y]~^^^^^ ERROR mismatched types + //[bound_a_b_vs_bound_a]~^^^^^^ ERROR mismatched types + //[bound_co_a_b_vs_bound_co_a]~^^^^^^^ ERROR mismatched types + //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^ ERROR mismatched types + //[bound_co_a_co_b_ret_contra_a]~^^^^^^^^^ ERROR mismatched types + } + } +} + +// If both have bound regions, they are equivalent, regardless of +// variant. +check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32), + for<'a> fn(&'a u32)) } +check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32), + for<'b> fn(&'b u32)) } +check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>), + for<'b> fn(Inv<'b>)) } +check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>), + for<'b> fn(Co<'b>)) } + +// Bound is a subtype of free. +check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), + fn(&'x u32)) } + +// Two free regions are relatable if subtyping holds. +check! { free_x_vs_free_x: (fn(&'x u32), + fn(&'x u32)) } +check! { free_x_vs_free_y: (fn(&'x u32), + fn(&'y u32)) } +check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), + fn(Inv<'y>)) } + +// Somewhat surprisingly, a fn taking two distinct bound lifetimes and +// a fn taking one bound lifetime can be interchangeable, but only if +// we are co- or contra-variant with respect to both lifetimes. +// +// The reason is: +// - if we are covariant, then 'a and 'b can be set to the call-site +// intersection; +// - if we are contravariant, then 'a can be inferred to 'static. +check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), + for<'a> fn(&'a u32, &'a u32)) } +check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), + for<'a> fn(Co<'a>, Co<'a>)) } +check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, + for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } +check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, + for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } + +// If we make those lifetimes invariant, then the two types are not interchangeable. +check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), + for<'a> fn(Inv<'a>, Inv<'a>)) } +check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, + for<'a> fn(&'a u32, &'a u32) -> &'a u32) } + +#[rustc_error] +fn main() { +//[bound_a_vs_bound_a]~^ ERROR compilation successful +//[bound_a_vs_bound_b]~^^ ERROR compilation successful +//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful +//[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful +//[free_x_vs_free_x]~^^^^^ ERROR compilation successful +} diff --git a/src/test/ui/compile-fail-migration/hrtb-conflate-regions.rs b/src/test/ui/compile-fail-migration/hrtb-conflate-regions.rs new file mode 100644 index 00000000000..845429d4b0c --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-conflate-regions.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an impl with only one bound region `'a` cannot be used to +// satisfy a constraint where there are two bound regions. + +trait Foo { + fn foo(&self, x: X) { } +} + +fn want_foo2() + where T : for<'a,'b> Foo<(&'a isize, &'b isize)> +{ +} + +fn want_foo1() + where T : for<'z> Foo<(&'z isize, &'z isize)> +{ +} + +/////////////////////////////////////////////////////////////////////////// +// Expressed as a where clause + +struct SomeStruct; + +impl<'a> Foo<(&'a isize, &'a isize)> for SomeStruct +{ +} + +fn a() { want_foo1::(); } // OK -- foo wants just one region +fn b() { want_foo2::(); } //~ ERROR E0277 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/hrtb-conflate-regions.stderr b/src/test/ui/compile-fail-migration/hrtb-conflate-regions.stderr new file mode 100644 index 00000000000..42778c12960 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-conflate-regions.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `for<'a, 'b> SomeStruct: Foo<(&'a isize, &'b isize)>` is not satisfied + --> $DIR/hrtb-conflate-regions.rs:38:10 + | +LL | fn b() { want_foo2::(); } //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a, 'b> Foo<(&'a isize, &'b isize)>` is not implemented for `SomeStruct` + | + = help: the following implementations were found: + > +note: required by `want_foo2` + --> $DIR/hrtb-conflate-regions.rs:18:1 + | +LL | / fn want_foo2() +LL | | where T : for<'a,'b> Foo<(&'a isize, &'b isize)> +LL | | { +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.nll.stderr b/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.nll.stderr new file mode 100644 index 00000000000..06970229325 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.nll.stderr @@ -0,0 +1,14 @@ +error[E0499]: cannot borrow `foo` as mutable more than once at a time + --> $DIR/hrtb-debruijn-in-receiver.rs:27:5 + | +LL | foo.insert(); + | --- first mutable borrow occurs here +LL | foo.insert(); //~ ERROR cannot borrow + | ^^^ + | | + | second mutable borrow occurs here + | borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.rs b/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.rs new file mode 100644 index 00000000000..2365f494075 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test the case where the `Self` type has a bound lifetime that must +// be adjusted in the fn signature. Issue #19537. + +use std::collections::HashMap; + +struct Foo<'a> { + map: HashMap +} + +impl<'a> Foo<'a> { + fn new() -> Foo<'a> { panic!() } + fn insert(&'a mut self) { } +} +fn main() { + let mut foo = Foo::new(); + foo.insert(); + foo.insert(); //~ ERROR cannot borrow +} diff --git a/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.stderr b/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.stderr new file mode 100644 index 00000000000..9a560caf5e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-debruijn-in-receiver.stderr @@ -0,0 +1,13 @@ +error[E0499]: cannot borrow `foo` as mutable more than once at a time + --> $DIR/hrtb-debruijn-in-receiver.rs:27:5 + | +LL | foo.insert(); + | --- first mutable borrow occurs here +LL | foo.insert(); //~ ERROR cannot borrow + | ^^^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.rs b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.rs new file mode 100644 index 00000000000..b55dccec2d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.rs @@ -0,0 +1,60 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test HRTB supertraits with several levels of expansion required. + +trait Foo<'tcx> +{ + fn foo(&'tcx self) -> &'tcx isize; +} + +trait Bar<'ccx> + : for<'tcx> Foo<'tcx> +{ + fn bar(&'ccx self) -> &'ccx isize; +} + +trait Baz + : for<'ccx> Bar<'ccx> +{ + fn dummy(&self); +} + +trait Qux + : Bar<'static> +{ + fn dummy(&self); +} + +fn want_foo_for_any_tcx(f: &F) + where F : for<'tcx> Foo<'tcx> +{ +} + +fn want_bar_for_any_ccx(b: &B) + where B : for<'ccx> Bar<'ccx> +{ +} + +fn want_baz(b: &B) + where B : Baz +{ + want_foo_for_any_tcx(b); + want_bar_for_any_ccx(b); +} + +fn want_qux(b: &B) + where B : Qux +{ + want_foo_for_any_tcx(b); + want_bar_for_any_ccx(b); //~ ERROR E0277 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.stderr b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.stderr new file mode 100644 index 00000000000..dca9feab201 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits-transitive.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied + --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:57:5 + | +LL | want_bar_for_any_ccx(b); //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` + | + = help: consider adding a `where for<'ccx> B: Bar<'ccx>` bound +note: required by `want_bar_for_any_ccx` + --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:41:1 + | +LL | / fn want_bar_for_any_ccx(b: &B) +LL | | where B : for<'ccx> Bar<'ccx> +LL | | { +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.rs b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.rs new file mode 100644 index 00000000000..4c5add4acea --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.rs @@ -0,0 +1,58 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a trait (`Bar`) with a higher-ranked supertrait. + +trait Foo<'tcx> +{ + fn foo(&'tcx self) -> &'tcx isize; +} + +trait Bar<'ccx> + : for<'tcx> Foo<'tcx> +{ + fn bar(&'ccx self) -> &'ccx isize; +} + +fn want_foo_for_some_tcx<'x,F>(f: &'x F) + where F : Foo<'x> +{ + want_foo_for_some_tcx(f); + want_foo_for_any_tcx(f); //~ ERROR E0277 +} + +fn want_foo_for_any_tcx(f: &F) + where F : for<'tcx> Foo<'tcx> +{ + want_foo_for_some_tcx(f); + want_foo_for_any_tcx(f); +} + +fn want_bar_for_some_ccx<'x,B>(b: &B) + where B : Bar<'x> +{ + want_foo_for_some_tcx(b); + want_foo_for_any_tcx(b); + + want_bar_for_some_ccx(b); + want_bar_for_any_ccx(b); //~ ERROR E0277 +} + +fn want_bar_for_any_ccx(b: &B) + where B : for<'ccx> Bar<'ccx> +{ + want_foo_for_some_tcx(b); + want_foo_for_any_tcx(b); + + want_bar_for_some_ccx(b); + want_bar_for_any_ccx(b); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.stderr b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.stderr new file mode 100644 index 00000000000..ad069e10182 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-higher-ranker-supertraits.stderr @@ -0,0 +1,40 @@ +error[E0277]: the trait bound `for<'tcx> F: Foo<'tcx>` is not satisfied + --> $DIR/hrtb-higher-ranker-supertraits.rs:28:5 + | +LL | want_foo_for_any_tcx(f); //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'tcx> Foo<'tcx>` is not implemented for `F` + | + = help: consider adding a `where for<'tcx> F: Foo<'tcx>` bound +note: required by `want_foo_for_any_tcx` + --> $DIR/hrtb-higher-ranker-supertraits.rs:31:1 + | +LL | / fn want_foo_for_any_tcx(f: &F) +LL | | where F : for<'tcx> Foo<'tcx> +LL | | { +LL | | want_foo_for_some_tcx(f); +LL | | want_foo_for_any_tcx(f); +LL | | } + | |_^ + +error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied + --> $DIR/hrtb-higher-ranker-supertraits.rs:45:5 + | +LL | want_bar_for_any_ccx(b); //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` + | + = help: consider adding a `where for<'ccx> B: Bar<'ccx>` bound +note: required by `want_bar_for_any_ccx` + --> $DIR/hrtb-higher-ranker-supertraits.rs:48:1 + | +LL | / fn want_bar_for_any_ccx(b: &B) +LL | | where B : for<'ccx> Bar<'ccx> +LL | | { +LL | | want_foo_for_some_tcx(b); +... | +LL | | want_bar_for_any_ccx(b); +LL | | } + | |_^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.nll.stderr b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.nll.stderr new file mode 100644 index 00000000000..e533ecc6eb0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/hrtb-identity-fn-borrows.rs:27:5 + | +LL | let y = f.call(&x); + | -- borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here +... +LL | drop(y); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.stderr b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.stderr new file mode 100644 index 00000000000..6888ec9bddb --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.ast.stderr @@ -0,0 +1,11 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/hrtb-identity-fn-borrows.rs:27:5 + | +LL | let y = f.call(&x); + | - borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.mir.stderr b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.mir.stderr new file mode 100644 index 00000000000..e533ecc6eb0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.mir.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/hrtb-identity-fn-borrows.rs:27:5 + | +LL | let y = f.call(&x); + | -- borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here +... +LL | drop(y); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.rs b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.rs new file mode 100644 index 00000000000..e98cf4eb2ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-identity-fn-borrows.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the `'a` in the where clause correctly links the region +// of the output to the region of the input. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +fn call_repeatedly(f: F) + where F : for<'a> FnLike<&'a isize, &'a isize> +{ + // Result is stored: cannot re-assign `x` + let mut x = 3; + let y = f.call(&x); + x = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed + + // Result is not stored: can re-assign `x` + let mut x = 3; + f.call(&x); + f.call(&x); + f.call(&x); + x = 5; + drop(y); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/hrtb-just-for-static.rs b/src/test/ui/compile-fail-migration/hrtb-just-for-static.rs new file mode 100644 index 00000000000..aec950f992c --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-just-for-static.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a case where you have an impl of `Foo` for all `X` that +// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. + +trait Foo { + fn foo(&self, x: X) { } +} + +fn want_hrtb() + where T : for<'a> Foo<&'a isize> +{ +} + +// AnyInt implements Foo<&'a isize> for any 'a, so it is a match. +struct AnyInt; +impl<'a> Foo<&'a isize> for AnyInt { } +fn give_any() { + want_hrtb::() +} + +// StaticInt only implements Foo<&'static isize>, so it is an error. +struct StaticInt; +impl Foo<&'static isize> for StaticInt { } +fn give_static() { + want_hrtb::() //~ ERROR `for<'a> StaticInt: Foo<&'a isize>` is not satisfied +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/hrtb-just-for-static.stderr b/src/test/ui/compile-fail-migration/hrtb-just-for-static.stderr new file mode 100644 index 00000000000..615a8b3bde5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-just-for-static.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `for<'a> StaticInt: Foo<&'a isize>` is not satisfied + --> $DIR/hrtb-just-for-static.rs:34:5 + | +LL | want_hrtb::() //~ ERROR `for<'a> StaticInt: Foo<&'a isize>` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `StaticInt` + | + = help: the following implementations were found: + > +note: required by `want_hrtb` + --> $DIR/hrtb-just-for-static.rs:18:1 + | +LL | / fn want_hrtb() +LL | | where T : for<'a> Foo<&'a isize> +LL | | { +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.rs b/src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.rs new file mode 100644 index 00000000000..fcfbeefced0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.rs @@ -0,0 +1,66 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a case where you have an impl of `Foo` for all `X` that +// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. + +trait Foo { + fn foo(&mut self, x: X) { } +} + +trait Bar { + fn bar(&mut self, x: X) { } +} + +impl<'a,X,F> Foo for &'a mut F + where F : Foo + Bar +{ +} + +impl<'a,X,F> Bar for &'a mut F + where F : Bar +{ +} + +fn no_hrtb<'b,T>(mut t: T) + where T : Bar<&'b isize> +{ + // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that + // `&mut T : Bar<&'b isize>`. + no_hrtb(&mut t); +} + +fn bar_hrtb(mut t: T) + where T : for<'b> Bar<&'b isize> +{ + // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above + // ensures that `&mut T : for<'b> Bar<&'b isize>`. This is an + // example of a "perfect forwarding" impl. + bar_hrtb(&mut t); +} + +fn foo_hrtb_bar_not<'b,T>(mut t: T) + where T : for<'a> Foo<&'a isize> + Bar<&'b isize> +{ + // Not OK -- The forwarding impl for `Foo` requires that `Bar` also + // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a + // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where + // clause only specifies `T : Bar<&'b isize>`. + foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> T: Bar<&'a isize>` is not satisfied +} + +fn foo_hrtb_bar_hrtb(mut t: T) + where T : for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize> +{ + // OK -- now we have `T : for<'b> Bar&'b isize>`. + foo_hrtb_bar_hrtb(&mut t); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.stderr b/src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.stderr new file mode 100644 index 00000000000..5e8674df053 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hrtb-perfect-forwarding.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `for<'a> T: Bar<&'a isize>` is not satisfied + --> $DIR/hrtb-perfect-forwarding.rs:56:5 + | +LL | foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> T: Bar<&'a isize>` is not satisfied + | ^^^^^^^^^^^^^^^^ the trait `for<'a> Bar<&'a isize>` is not implemented for `T` + | + = help: consider adding a `where for<'a> T: Bar<&'a isize>` bound + = note: required because of the requirements on the impl of `for<'a> Foo<&'a isize>` for `&mut T` +note: required by `foo_hrtb_bar_not` + --> $DIR/hrtb-perfect-forwarding.rs:49:1 + | +LL | / fn foo_hrtb_bar_not<'b,T>(mut t: T) +LL | | where T : for<'a> Foo<&'a isize> + Bar<&'b isize> +LL | | { +LL | | // Not OK -- The forwarding impl for `Foo` requires that `Bar` also +... | +LL | | foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> T: Bar<&'a isize>` is not satisfied +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/huge-array-simple.rs b/src/test/ui/compile-fail-migration/huge-array-simple.rs new file mode 100644 index 00000000000..54340cf7ac4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/huge-array-simple.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// FIXME (#23926): the error output is not consistent between a +// self-hosted and a cross-compiled setup. Skipping for now. + +// ignore-test FIXME(#23926) + +#![allow(exceeding_bitshifts)] + +fn main() { + let _fat : [u8; (1<<61)+(1<<31)] = + [0; (1u64<<61) as usize +(1u64<<31) as usize]; +} diff --git a/src/test/ui/compile-fail-migration/huge-array.rs b/src/test/ui/compile-fail-migration/huge-array.rs new file mode 100644 index 00000000000..7de84802e1d --- /dev/null +++ b/src/test/ui/compile-fail-migration/huge-array.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:; 1518600000 + +fn generic(t: T) { + let s: [T; 1518600000] = [t; 1518600000]; +} + +fn main() { + let x: [u8; 1518599999] = [0; 1518599999]; + generic::<[u8; 1518599999]>(x); +} diff --git a/src/test/ui/compile-fail-migration/huge-array.stderr b/src/test/ui/compile-fail-migration/huge-array.stderr new file mode 100644 index 00000000000..38d9effcfb5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/huge-array.stderr @@ -0,0 +1,4 @@ +error: the type `[[u8; 1518599999]; 1518600000]` is too big for the current architecture + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/huge-enum.rs b/src/test/ui/compile-fail-migration/huge-enum.rs new file mode 100644 index 00000000000..6e7c05370b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/huge-enum.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: Option + +// FIXME: work properly with higher limits + +#[cfg(target_pointer_width = "32")] +fn main() { + let big: Option<[u32; (1<<29)-1]> = None; +} + +#[cfg(target_pointer_width = "64")] +fn main() { + let big: Option<[u32; (1<<45)-1]> = None; +} diff --git a/src/test/ui/compile-fail-migration/huge-enum.stderr b/src/test/ui/compile-fail-migration/huge-enum.stderr new file mode 100644 index 00000000000..239428badc2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/huge-enum.stderr @@ -0,0 +1,4 @@ +error: the type `std::option::Option<[u32; 35184372088831]>` is too big for the current architecture + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/huge-struct.rs b/src/test/ui/compile-fail-migration/huge-struct.rs new file mode 100644 index 00000000000..a10c61d6606 --- /dev/null +++ b/src/test/ui/compile-fail-migration/huge-struct.rs @@ -0,0 +1,54 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: too big for the current + +struct S32 { + v0: T, + v1: T, + v2: T, + v3: T, + v4: T, + v5: T, + v6: T, + v7: T, + v8: T, + u9: T, + v10: T, + v11: T, + v12: T, + v13: T, + v14: T, + v15: T, + v16: T, + v17: T, + v18: T, + v19: T, + v20: T, + v21: T, + v22: T, + v23: T, + v24: T, + u25: T, + v26: T, + v27: T, + v28: T, + v29: T, + v30: T, + v31: T, +} + +struct S1k { val: S32> } + +struct S1M { val: S1k> } + +fn main() { + let fat: Option>>> = None; +} diff --git a/src/test/ui/compile-fail-migration/huge-struct.stderr b/src/test/ui/compile-fail-migration/huge-struct.stderr new file mode 100644 index 00000000000..15807309d48 --- /dev/null +++ b/src/test/ui/compile-fail-migration/huge-struct.stderr @@ -0,0 +1,4 @@ +error: the type `S32>>` is too big for the current architecture + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/hygienic-label-1.rs b/src/test/ui/compile-fail-migration/hygienic-label-1.rs new file mode 100644 index 00000000000..305b43402da --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-1.rs @@ -0,0 +1,17 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + () => { break 'x; } //~ ERROR use of undeclared label `'x` +} + +pub fn main() { + 'x: loop { foo!() } +} diff --git a/src/test/ui/compile-fail-migration/hygienic-label-1.stderr b/src/test/ui/compile-fail-migration/hygienic-label-1.stderr new file mode 100644 index 00000000000..051466b183d --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-1.stderr @@ -0,0 +1,12 @@ +error[E0426]: use of undeclared label `'x` + --> $DIR/hygienic-label-1.rs:12:19 + | +LL | () => { break 'x; } //~ ERROR use of undeclared label `'x` + | ^^ did you mean `'x`? +... +LL | 'x: loop { foo!() } + | ------ in this macro invocation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0426`. diff --git a/src/test/ui/compile-fail-migration/hygienic-label-2.rs b/src/test/ui/compile-fail-migration/hygienic-label-2.rs new file mode 100644 index 00000000000..24194d7bbe9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-2.rs @@ -0,0 +1,17 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($e: expr) => { 'x: loop { $e } } +} + +pub fn main() { + foo!(break 'x); //~ ERROR use of undeclared label `'x` +} diff --git a/src/test/ui/compile-fail-migration/hygienic-label-2.stderr b/src/test/ui/compile-fail-migration/hygienic-label-2.stderr new file mode 100644 index 00000000000..081c1c7e69e --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-2.stderr @@ -0,0 +1,9 @@ +error[E0426]: use of undeclared label `'x` + --> $DIR/hygienic-label-2.rs:16:16 + | +LL | foo!(break 'x); //~ ERROR use of undeclared label `'x` + | ^^ did you mean `'x`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0426`. diff --git a/src/test/ui/compile-fail-migration/hygienic-label-3.rs b/src/test/ui/compile-fail-migration/hygienic-label-3.rs new file mode 100644 index 00000000000..b107b71024d --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-3.rs @@ -0,0 +1,19 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + () => { break 'x; } //~ ERROR use of undeclared label `'x` +} + +pub fn main() { + 'x: for _ in 0..1 { + foo!() + }; +} diff --git a/src/test/ui/compile-fail-migration/hygienic-label-3.stderr b/src/test/ui/compile-fail-migration/hygienic-label-3.stderr new file mode 100644 index 00000000000..e5593df49f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-3.stderr @@ -0,0 +1,12 @@ +error[E0426]: use of undeclared label `'x` + --> $DIR/hygienic-label-3.rs:12:19 + | +LL | () => { break 'x; } //~ ERROR use of undeclared label `'x` + | ^^ did you mean `'x`? +... +LL | foo!() + | ------ in this macro invocation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0426`. diff --git a/src/test/ui/compile-fail-migration/hygienic-label-4.rs b/src/test/ui/compile-fail-migration/hygienic-label-4.rs new file mode 100644 index 00000000000..5bfcb6360e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-4.rs @@ -0,0 +1,17 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($e: expr) => { 'x: for _ in 0..1 { $e } } +} + +pub fn main() { + foo!(break 'x); //~ ERROR use of undeclared label `'x` +} diff --git a/src/test/ui/compile-fail-migration/hygienic-label-4.stderr b/src/test/ui/compile-fail-migration/hygienic-label-4.stderr new file mode 100644 index 00000000000..60351386a0b --- /dev/null +++ b/src/test/ui/compile-fail-migration/hygienic-label-4.stderr @@ -0,0 +1,9 @@ +error[E0426]: use of undeclared label `'x` + --> $DIR/hygienic-label-4.rs:16:16 + | +LL | foo!(break 'x); //~ ERROR use of undeclared label `'x` + | ^^ did you mean `'x`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0426`. diff --git a/src/test/ui/compile-fail-migration/if-branch-types.rs b/src/test/ui/compile-fail-migration/if-branch-types.rs new file mode 100644 index 00000000000..ca9803f66b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-branch-types.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = if true { 10i32 } else { 10u32 }; + //~^ ERROR if and else have incompatible types + //~| expected i32, found u32 +} diff --git a/src/test/ui/compile-fail-migration/if-branch-types.stderr b/src/test/ui/compile-fail-migration/if-branch-types.stderr new file mode 100644 index 00000000000..cefd94dc99b --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-branch-types.stderr @@ -0,0 +1,12 @@ +error[E0308]: if and else have incompatible types + --> $DIR/if-branch-types.rs:12:13 + | +LL | let x = if true { 10i32 } else { 10u32 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32 + | + = note: expected type `i32` + found type `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/if-let.rs b/src/test/ui/compile-fail-migration/if-let.rs new file mode 100644 index 00000000000..1e9144910b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-let.rs @@ -0,0 +1,55 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn macros() { + macro_rules! foo{ + ($p:pat, $e:expr, $b:block) => {{ + if let $p = $e $b + }} + } + macro_rules! bar{ + ($p:pat, $e:expr, $b:block) => {{ + foo!($p, $e, $b) + }} + } + + foo!(a, 1, { //~ ERROR irrefutable if-let + println!("irrefutable pattern"); + }); + bar!(a, 1, { //~ ERROR irrefutable if-let + println!("irrefutable pattern"); + }); +} + +pub fn main() { + if let a = 1 { //~ ERROR irrefutable if-let + println!("irrefutable pattern"); + } + + if let a = 1 { //~ ERROR irrefutable if-let + println!("irrefutable pattern"); + } else if true { + println!("else-if in irrefutable if-let"); + } else { + println!("else in irrefutable if-let"); + } + + if let 1 = 2 { + println!("refutable pattern"); + } else if let a = 1 { //~ ERROR irrefutable if-let + println!("irrefutable pattern"); + } + + if true { + println!("if"); + } else if let a = 1 { //~ ERROR irrefutable if-let + println!("irrefutable pattern"); + } +} diff --git a/src/test/ui/compile-fail-migration/if-let.stderr b/src/test/ui/compile-fail-migration/if-let.stderr new file mode 100644 index 00000000000..de8d6feb3c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-let.stderr @@ -0,0 +1,39 @@ +error[E0162]: irrefutable if-let pattern + --> $DIR/if-let.rs:23:10 + | +LL | foo!(a, 1, { //~ ERROR irrefutable if-let + | ^ irrefutable pattern + +error[E0162]: irrefutable if-let pattern + --> $DIR/if-let.rs:26:10 + | +LL | bar!(a, 1, { //~ ERROR irrefutable if-let + | ^ irrefutable pattern + +error[E0162]: irrefutable if-let pattern + --> $DIR/if-let.rs:32:12 + | +LL | if let a = 1 { //~ ERROR irrefutable if-let + | ^ irrefutable pattern + +error[E0162]: irrefutable if-let pattern + --> $DIR/if-let.rs:36:12 + | +LL | if let a = 1 { //~ ERROR irrefutable if-let + | ^ irrefutable pattern + +error[E0162]: irrefutable if-let pattern + --> $DIR/if-let.rs:46:19 + | +LL | } else if let a = 1 { //~ ERROR irrefutable if-let + | ^ irrefutable pattern + +error[E0162]: irrefutable if-let pattern + --> $DIR/if-let.rs:52:19 + | +LL | } else if let a = 1 { //~ ERROR irrefutable if-let + | ^ irrefutable pattern + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0162`. diff --git a/src/test/ui/compile-fail-migration/if-loop.rs b/src/test/ui/compile-fail-migration/if-loop.rs new file mode 100644 index 00000000000..15f04df6939 --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-loop.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(warnings)] + +// This used to ICE because the "if" being unreachable was not handled correctly +fn err() { + if loop {} {} +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/if-loop.stderr b/src/test/ui/compile-fail-migration/if-loop.stderr new file mode 100644 index 00000000000..6862560570d --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-loop.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/if-loop.rs:20:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/if-typeck.rs b/src/test/ui/compile-fail-migration/if-typeck.rs new file mode 100644 index 00000000000..d5d7d2005be --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-typeck.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:mismatched types +// issue #513 + +fn f() { } + +fn main() { + + // f is not a bool + if f { } +} diff --git a/src/test/ui/compile-fail-migration/if-typeck.stderr b/src/test/ui/compile-fail-migration/if-typeck.stderr new file mode 100644 index 00000000000..6d96f8bf223 --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-typeck.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/if-typeck.rs:19:8 + | +LL | if f { } + | ^ expected bool, found fn item + | + = note: expected type `bool` + found type `fn() {f}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/if-without-else-result.rs b/src/test/ui/compile-fail-migration/if-without-else-result.rs new file mode 100644 index 00000000000..95bcce5a847 --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-without-else-result.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let a = if true { true }; + //~^ ERROR if may be missing an else clause [E0317] + //~| expected type `()` + //~| found type `bool` + //~| expected (), found bool + println!("{}", a); +} diff --git a/src/test/ui/compile-fail-migration/if-without-else-result.stderr b/src/test/ui/compile-fail-migration/if-without-else-result.stderr new file mode 100644 index 00000000000..ab97f6c81f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/if-without-else-result.stderr @@ -0,0 +1,12 @@ +error[E0317]: if may be missing an else clause + --> $DIR/if-without-else-result.rs:12:13 + | +LL | let a = if true { true }; + | ^^^^^^^^^^^^^^^^ expected (), found bool + | + = note: expected type `()` + found type `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0317`. diff --git a/src/test/ui/compile-fail-migration/ifmt-bad-format-args.rs b/src/test/ui/compile-fail-migration/ifmt-bad-format-args.rs new file mode 100644 index 00000000000..8bd3cb0f60b --- /dev/null +++ b/src/test/ui/compile-fail-migration/ifmt-bad-format-args.rs @@ -0,0 +1,14 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + format_args!(); //~ ERROR: requires at least a format string argument + format_args!(|| {}); //~ ERROR: must be a string literal +} diff --git a/src/test/ui/compile-fail-migration/ifmt-bad-format-args.stderr b/src/test/ui/compile-fail-migration/ifmt-bad-format-args.stderr new file mode 100644 index 00000000000..d2fe12925d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ifmt-bad-format-args.stderr @@ -0,0 +1,18 @@ +error: requires at least a format string argument + --> $DIR/ifmt-bad-format-args.rs:12:5 + | +LL | format_args!(); //~ ERROR: requires at least a format string argument + | ^^^^^^^^^^^^^^^ + +error: format argument must be a string literal + --> $DIR/ifmt-bad-format-args.rs:13:18 + | +LL | format_args!(|| {}); //~ ERROR: must be a string literal + | ^^^^^ +help: you might be missing a string literal to format with + | +LL | format_args!("{}", || {}); //~ ERROR: must be a string literal + | ^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/ifmt-unimpl.rs b/src/test/ui/compile-fail-migration/ifmt-unimpl.rs new file mode 100644 index 00000000000..9b9bae92c33 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ifmt-unimpl.rs @@ -0,0 +1,14 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + format!("{:X}", "3"); + //~^ ERROR: `str: std::fmt::UpperHex` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/ifmt-unimpl.stderr b/src/test/ui/compile-fail-migration/ifmt-unimpl.stderr new file mode 100644 index 00000000000..fbb3136693a --- /dev/null +++ b/src/test/ui/compile-fail-migration/ifmt-unimpl.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `str: std::fmt::UpperHex` is not satisfied + --> $DIR/ifmt-unimpl.rs:12:21 + | +LL | format!("{:X}", "3"); + | ^^^ the trait `std::fmt::UpperHex` is not implemented for `str` + | + = note: required because of the requirements on the impl of `std::fmt::UpperHex` for `&str` + = note: required by `std::fmt::UpperHex::fmt` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/ifmt-unknown-trait.rs b/src/test/ui/compile-fail-migration/ifmt-unknown-trait.rs new file mode 100644 index 00000000000..d90b3d3cf81 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ifmt-unknown-trait.rs @@ -0,0 +1,14 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + format!("{:notimplemented}", "3"); + //~^ ERROR: unknown format trait `notimplemented` +} diff --git a/src/test/ui/compile-fail-migration/ifmt-unknown-trait.stderr b/src/test/ui/compile-fail-migration/ifmt-unknown-trait.stderr new file mode 100644 index 00000000000..3c746e4c53b --- /dev/null +++ b/src/test/ui/compile-fail-migration/ifmt-unknown-trait.stderr @@ -0,0 +1,8 @@ +error: unknown format trait `notimplemented` + --> $DIR/ifmt-unknown-trait.rs:12:34 + | +LL | format!("{:notimplemented}", "3"); + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/illegal-ufcs-drop.rs b/src/test/ui/compile-fail-migration/illegal-ufcs-drop.rs new file mode 100644 index 00000000000..f4c653bd573 --- /dev/null +++ b/src/test/ui/compile-fail-migration/illegal-ufcs-drop.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) {} +} + +fn main() { + Drop::drop(&mut Foo) //~ ERROR explicit use of destructor method +} diff --git a/src/test/ui/compile-fail-migration/illegal-ufcs-drop.stderr b/src/test/ui/compile-fail-migration/illegal-ufcs-drop.stderr new file mode 100644 index 00000000000..f82c54664a9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/illegal-ufcs-drop.stderr @@ -0,0 +1,9 @@ +error[E0040]: explicit use of destructor method + --> $DIR/illegal-ufcs-drop.rs:19:5 + | +LL | Drop::drop(&mut Foo) //~ ERROR explicit use of destructor method + | ^^^^^^^^^^ explicit destructor calls not allowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0040`. diff --git a/src/test/ui/compile-fail-migration/immut-function-arguments.ast.nll.stderr b/src/test/ui/compile-fail-migration/immut-function-arguments.ast.nll.stderr new file mode 100644 index 00000000000..c8236340627 --- /dev/null +++ b/src/test/ui/compile-fail-migration/immut-function-arguments.ast.nll.stderr @@ -0,0 +1,19 @@ +error[E0384]: cannot assign to immutable argument `y` + --> $DIR/immut-function-arguments.rs:15:5 + | +LL | fn f(y: Box) { + | - consider changing this to `mut y` +LL | *y = 5; //[ast]~ ERROR cannot assign + | ^^^^^^ cannot assign to immutable argument + +error[E0384]: cannot assign to immutable argument `q` + --> $DIR/immut-function-arguments.rs:20:35 + | +LL | let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign + | - ^^^^^^ cannot assign to immutable argument + | | + | consider changing this to `mut q` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/immut-function-arguments.ast.stderr b/src/test/ui/compile-fail-migration/immut-function-arguments.ast.stderr new file mode 100644 index 00000000000..54125b955cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/immut-function-arguments.ast.stderr @@ -0,0 +1,19 @@ +error[E0594]: cannot assign to immutable `Box` content `*y` + --> $DIR/immut-function-arguments.rs:15:5 + | +LL | fn f(y: Box) { + | - consider changing this to `mut y` +LL | *y = 5; //[ast]~ ERROR cannot assign + | ^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to immutable `Box` content `*q` + --> $DIR/immut-function-arguments.rs:20:35 + | +LL | let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign + | - ^^^^^^ cannot borrow as mutable + | | + | consider changing this to `mut q` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/immut-function-arguments.mir.stderr b/src/test/ui/compile-fail-migration/immut-function-arguments.mir.stderr new file mode 100644 index 00000000000..c8236340627 --- /dev/null +++ b/src/test/ui/compile-fail-migration/immut-function-arguments.mir.stderr @@ -0,0 +1,19 @@ +error[E0384]: cannot assign to immutable argument `y` + --> $DIR/immut-function-arguments.rs:15:5 + | +LL | fn f(y: Box) { + | - consider changing this to `mut y` +LL | *y = 5; //[ast]~ ERROR cannot assign + | ^^^^^^ cannot assign to immutable argument + +error[E0384]: cannot assign to immutable argument `q` + --> $DIR/immut-function-arguments.rs:20:35 + | +LL | let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign + | - ^^^^^^ cannot assign to immutable argument + | | + | consider changing this to `mut q` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/immut-function-arguments.rs b/src/test/ui/compile-fail-migration/immut-function-arguments.rs new file mode 100644 index 00000000000..61a074952ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/immut-function-arguments.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn f(y: Box) { + *y = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign +} + +fn g() { + let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/impl-bounds-checking.rs b/src/test/ui/compile-fail-migration/impl-bounds-checking.rs new file mode 100644 index 00000000000..f90365b71ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-bounds-checking.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Clone2 { + fn clone(&self) -> Self; +} + + +trait Getter { + fn get(&self) -> T; +} + +impl Getter for isize { //~ ERROR `isize: Clone2` is not satisfied + fn get(&self) -> isize { *self } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/impl-bounds-checking.stderr b/src/test/ui/compile-fail-migration/impl-bounds-checking.stderr new file mode 100644 index 00000000000..80666131b2c --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-bounds-checking.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `isize: Clone2` is not satisfied + --> $DIR/impl-bounds-checking.rs:20:6 + | +LL | impl Getter for isize { //~ ERROR `isize: Clone2` is not satisfied + | ^^^^^^^^^^^^^ the trait `Clone2` is not implemented for `isize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.rs b/src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.rs new file mode 100644 index 00000000000..23549918ff1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; + +trait Foo { + fn foo(&self, a: &A, b: &impl Debug); +} + +impl Foo for () { + fn foo(&self, a: &impl Debug, b: &B) { } + //~^ ERROR method `foo` has an incompatible type for trait +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.stderr b/src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.stderr new file mode 100644 index 00000000000..77ecdf2f5ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/impl-generic-mismatch-ab.stderr @@ -0,0 +1,15 @@ +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/impl-generic-mismatch-ab.rs:18:32 + | +LL | fn foo(&self, a: &A, b: &impl Debug); + | -- type in trait +... +LL | fn foo(&self, a: &impl Debug, b: &B) { } + | ^^^^^^^^^^^ expected type parameter, found a different type parameter + | + = note: expected type `fn(&(), &B, &impl Debug)` + found type `fn(&(), &impl Debug, &B)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.rs b/src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.rs new file mode 100644 index 00000000000..653ef1723e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.rs @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that attempts to construct infinite types via impl trait fail +// in a graceful way. +// +// Regression test for #38064. + +// error-pattern:overflow evaluating the requirement `impl Quux` + +trait Quux {} + +fn foo() -> impl Quux { + struct Foo(T); + impl Quux for Foo {} + Foo(bar()) +} + +fn bar() -> impl Quux { + struct Bar(T); + impl Quux for Bar {} + Bar(foo()) +} + +// effectively: +// struct Foo(Bar); +// struct Bar(Foo); +// should produce an error about infinite size + +fn main() { foo(); } diff --git a/src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.stderr b/src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.stderr new file mode 100644 index 00000000000..f260cce647b --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/infinite-impl-trait-issue-38064.stderr @@ -0,0 +1,7 @@ +error[E0275]: overflow evaluating the requirement `impl Quux` + | + = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.nll.stderr new file mode 100644 index 00000000000..6d581952ac9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -0,0 +1,73 @@ +warning: not reporting region error due to nll + --> $DIR/must_outlive_least_region_or_bound.rs:13:35 + | +LL | fn elided(x: &i32) -> impl Copy { x } + | ^ + +warning: not reporting region error due to nll + --> $DIR/must_outlive_least_region_or_bound.rs:16:44 + | +LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } + | ^ + +warning: not reporting region error due to nll + --> $DIR/must_outlive_least_region_or_bound.rs:22:69 + | +LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } + | ^ + +warning: not reporting region error due to nll + --> $DIR/must_outlive_least_region_or_bound.rs:29:5 + | +LL | move |_| println!("{}", y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/must_outlive_least_region_or_bound.rs:32:51 + | +LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/must_outlive_least_region_or_bound.rs:13:35 + | +LL | fn elided(x: &i32) -> impl Copy { x } + | ---- ^ lifetime `'static` required + | | + | help: add explicit lifetime `'static` to the type of `x`: `&'static i32` + +error: unsatisfied lifetime constraints + --> $DIR/must_outlive_least_region_or_bound.rs:16:44 + | +LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } + | -- lifetime `'a` defined here ^ return requires that `'a` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/must_outlive_least_region_or_bound.rs:22:69 + | +LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } + | -- lifetime `'a` defined here ^ return requires that `'a` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/must_outlive_least_region_or_bound.rs:29:5 + | +LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | //~^ ERROR lifetime mismatch +LL | move |_| println!("{}", y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/must_outlive_least_region_or_bound.rs:34:5 + | +LL | x + | ^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error: aborting due to 5 previous errors + +Some errors occurred: E0310, E0621. +For more information about an error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.rs new file mode 100644 index 00000000000..537fc975bcf --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.rs @@ -0,0 +1,37 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; + +fn elided(x: &i32) -> impl Copy { x } +//~^ ERROR explicit lifetime required in the type of `x` [E0621] + +fn explicit<'a>(x: &'a i32) -> impl Copy { x } +//~^ ERROR cannot infer an appropriate lifetime + +trait LifetimeTrait<'a> {} +impl<'a> LifetimeTrait<'a> for &'a i32 {} + +fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } +//~^ ERROR cannot infer an appropriate lifetime + +// Tests that a closure type contianing 'b cannot be returned from a type where +// only 'a was expected. +fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { + //~^ ERROR lifetime mismatch + move |_| println!("{}", y) +} + +fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { + //~^ ERROR the parameter type `T` may not live long enough + x +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.stderr new file mode 100644 index 00000000000..48686cbcaf2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/must_outlive_least_region_or_bound.stderr @@ -0,0 +1,71 @@ +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/must_outlive_least_region_or_bound.rs:13:23 + | +LL | fn elided(x: &i32) -> impl Copy { x } + | ---- ^^^^^^^^^ lifetime `'static` required + | | + | help: add explicit lifetime `'static` to the type of `x`: `&'static i32` + +error: cannot infer an appropriate lifetime + --> $DIR/must_outlive_least_region_or_bound.rs:16:44 + | +LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } + | --------- ^ ...but this borrow... + | | + | this return type evaluates to the `'static` lifetime... + | +note: ...can't outlive the lifetime 'a as defined on the function body at 16:13 + --> $DIR/must_outlive_least_region_or_bound.rs:16:13 + | +LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } + | ^^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime 'a as defined on the function body at 16:13 + | +LL | fn explicit<'a>(x: &'a i32) -> impl Copy + 'a { x } + | ^^^^^^^^^^^^^^ + +error: cannot infer an appropriate lifetime + --> $DIR/must_outlive_least_region_or_bound.rs:22:69 + | +LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } + | -------------------------------- ^ ...but this borrow... + | | + | this return type evaluates to the `'static` lifetime... + | +note: ...can't outlive the lifetime 'a as defined on the function body at 22:15 + --> $DIR/must_outlive_least_region_or_bound.rs:22:15 + | +LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } + | ^^ +help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime 'a as defined on the function body at 22:15 + | +LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static + 'a { x } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0623]: lifetime mismatch + --> $DIR/must_outlive_least_region_or_bound.rs:27:61 + | +LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { + | ------- ^^^^^^^^^^^^^^^^ + | | | + | | ...but data from `y` is returned here + | this parameter and the return type are declared with different lifetimes... + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/must_outlive_least_region_or_bound.rs:32:51 + | +LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { + | -- ^^^^^^^^^^^^^^^^^^^^ + | | + | help: consider adding an explicit lifetime bound `T: 'static`... + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/must_outlive_least_region_or_bound.rs:32:51 + | +LL | fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0310, E0621, E0623. +For more information about an error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.rs b/src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.rs new file mode 100644 index 00000000000..6c0a0b800ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; + +trait MultiRegionTrait<'a, 'b> {} +impl<'a, 'b> MultiRegionTrait<'a, 'b> for (&'a u32, &'b u32) {} + +fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> { +//~^ ERROR ambiguous lifetime bound + (x, y) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.stderr b/src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.stderr new file mode 100644 index 00000000000..fd2665dc762 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/needs_least_region_or_bound.stderr @@ -0,0 +1,8 @@ +error: ambiguous lifetime bound in `impl Trait` + --> $DIR/needs_least_region_or_bound.rs:16:55 + | +LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ neither `'a` nor `'b` outlives the other + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/impl-trait/no-trait.rs b/src/test/ui/compile-fail-migration/impl-trait/no-trait.rs new file mode 100644 index 00000000000..5299ba297d0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/no-trait.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> impl 'static {} //~ ERROR at least one trait must be specified + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/impl-trait/no-trait.stderr b/src/test/ui/compile-fail-migration/impl-trait/no-trait.stderr new file mode 100644 index 00000000000..fdd01c87d1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/no-trait.stderr @@ -0,0 +1,8 @@ +error: at least one trait must be specified + --> $DIR/no-trait.rs:11:11 + | +LL | fn f() -> impl 'static {} //~ ERROR at least one trait must be specified + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.nll.stderr b/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.nll.stderr new file mode 100644 index 00000000000..823ee446729 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/type_parameters_captured.rs:17:20 + | +LL | fn foo(x: T) -> impl Any + 'static { + | ^^^^^^^^^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/type_parameters_captured.rs:19:5 + | +LL | x + | ^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.rs b/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.rs new file mode 100644 index 00000000000..7c3430ab90e --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; + +trait Any {} +impl Any for T {} + +// Check that type parameters are captured and not considered 'static +fn foo(x: T) -> impl Any + 'static { + //~^ ERROR the parameter type `T` may not live long enough + x +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.stderr b/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.stderr new file mode 100644 index 00000000000..3b9b0e08a45 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/type_parameters_captured.stderr @@ -0,0 +1,17 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/type_parameters_captured.rs:17:20 + | +LL | fn foo(x: T) -> impl Any + 'static { + | - ^^^^^^^^^^^^^^^^^^ + | | + | help: consider adding an explicit lifetime bound `T: 'static`... + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/type_parameters_captured.rs:17:20 + | +LL | fn foo(x: T) -> impl Any + 'static { + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/impl-trait/where-allowed.rs b/src/test/ui/compile-fail-migration/impl-trait/where-allowed.rs new file mode 100644 index 00000000000..2891cd59e3e --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/where-allowed.rs @@ -0,0 +1,235 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A simple test for testing many permutations of allowedness of +//! impl Trait +use std::fmt::Debug; + +// Allowed +fn in_parameters(_: impl Debug) { panic!() } + +// Allowed +fn in_return() -> impl Debug { panic!() } + +// Allowed +fn in_adt_in_parameters(_: Vec) { panic!() } + +// Allowed +fn in_adt_in_return() -> Vec { panic!() } + +// Disallowed +fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +//~^^ ERROR nested `impl Trait` is not allowed + +// Disallowed +fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +//~^^ ERROR nested `impl Trait` is not allowed + +// Disallowed +fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_Fn_parameter_in_generics (_: F) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + + +// Allowed +fn in_impl_Trait_in_parameters(_: impl Iterator) { panic!() } + +// Allowed +fn in_impl_Trait_in_return() -> impl IntoIterator { + vec![vec![0; 10], vec![12; 7], vec![8; 3]] +} + +// Disallowed +struct InBraceStructField { x: impl Debug } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +struct InAdtInBraceStructField { x: Vec } +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +struct InTupleStructField(impl Debug); +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed +enum InEnum { + InBraceVariant { x: impl Debug }, + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + InTupleVariant(impl Debug), + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Allowed +trait InTraitDefnParameters { + fn in_parameters(_: impl Debug); +} + +// Disallowed +trait InTraitDefnReturn { + fn in_return() -> impl Debug; + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Allowed and disallowed in trait impls +trait DummyTrait { + type Out; + fn in_trait_impl_parameter(impl Debug); + fn in_trait_impl_return() -> Self::Out; +} +impl DummyTrait for () { + type Out = impl Debug; + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + + fn in_trait_impl_parameter(_: impl Debug) { } + // Allowed + + fn in_trait_impl_return() -> impl Debug { () } + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Allowed +struct DummyType; +impl DummyType { + fn in_inherent_impl_parameters(_: impl Debug) { } + fn in_inherent_impl_return() -> impl Debug { () } +} + +// Disallowed +extern "C" { + fn in_foreign_parameters(_: impl Debug); + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + + fn in_foreign_return() -> impl Debug; + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Allowed +extern "C" fn in_extern_fn_parameters(_: impl Debug) { +} + +// Allowed +extern "C" fn in_extern_fn_return() -> impl Debug { + 22 +} + +type InTypeAlias = impl Debug; +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +type InReturnInTypeAlias = fn() -> impl Debug; +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + +// Disallowed in impl headers +impl PartialEq for () { + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Disallowed in impl headers +impl PartialEq<()> for impl Debug { + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Disallowed in inherent impls +impl impl Debug { + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Disallowed in inherent impls +struct InInherentImplAdt { t: T } +impl InInherentImplAdt { + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + +// Disallowed in where clauses +fn in_fn_where_clause() + where impl Debug: Debug +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +{ +} + +// Disallowed in where clauses +fn in_adt_in_fn_where_clause() + where Vec: Debug +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +{ +} + +// Disallowed +fn in_trait_parameter_in_fn_where_clause() + where T: PartialEq +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +{ +} + +// Disallowed +fn in_Fn_parameter_in_fn_where_clause() + where T: Fn(impl Debug) +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +{ +} + +// Disallowed +fn in_Fn_return_in_fn_where_clause() + where T: Fn() -> impl Debug +//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +{ +} + +fn main() { + let _in_local_variable: impl Fn() = || {}; + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types + let _in_return_in_local_variable = || -> impl Fn() { || {} }; + //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types +} + diff --git a/src/test/ui/compile-fail-migration/impl-trait/where-allowed.stderr b/src/test/ui/compile-fail-migration/impl-trait/where-allowed.stderr new file mode 100644 index 00000000000..b15893e7c28 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-trait/where-allowed.stderr @@ -0,0 +1,244 @@ +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/where-allowed.rs:60:51 + | +LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } + | --------^^^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error[E0666]: nested `impl Trait` is not allowed + --> $DIR/where-allowed.rs:69:57 + | +LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } + | --------^^^^^^^^^^- + | | | + | | nested `impl Trait` here + | outer `impl Trait` + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:28:40 + | +LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:32:42 + | +LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:36:38 + | +LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:40:40 + | +LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:44:49 + | +LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:48:51 + | +LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:52:55 + | +LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:56:57 + | +LL | fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:60:51 + | +LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:65:53 + | +LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:69:57 + | +LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:74:59 + | +LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:78:38 + | +LL | fn in_Fn_parameter_in_generics (_: F) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:82:40 + | +LL | fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:95:32 + | +LL | struct InBraceStructField { x: impl Debug } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:99:41 + | +LL | struct InAdtInBraceStructField { x: Vec } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:103:27 + | +LL | struct InTupleStructField(impl Debug); + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:108:25 + | +LL | InBraceVariant { x: impl Debug }, + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:110:20 + | +LL | InTupleVariant(impl Debug), + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:121:23 + | +LL | fn in_return() -> impl Debug; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:132:16 + | +LL | type Out = impl Debug; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:138:34 + | +LL | fn in_trait_impl_return() -> impl Debug { () } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:151:33 + | +LL | fn in_foreign_parameters(_: impl Debug); + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:154:31 + | +LL | fn in_foreign_return() -> impl Debug; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:167:23 + | +LL | type InTypeAlias = impl Debug; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:170:39 + | +LL | type InReturnInTypeAlias = fn() -> impl Debug; + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:174:16 + | +LL | impl PartialEq for () { + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:179:24 + | +LL | impl PartialEq<()> for impl Debug { + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:184:6 + | +LL | impl impl Debug { + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:190:24 + | +LL | impl InInherentImplAdt { + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:196:11 + | +LL | where impl Debug: Debug + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:203:15 + | +LL | where Vec: Debug + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:210:24 + | +LL | where T: PartialEq + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:217:17 + | +LL | where T: Fn(impl Debug) + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:224:22 + | +LL | where T: Fn() -> impl Debug + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:230:29 + | +LL | let _in_local_variable: impl Fn() = || {}; + | ^^^^^^^^^ + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/where-allowed.rs:232:46 + | +LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; + | ^^^^^^^^^ + +error: aborting due to 39 previous errors + +Some errors occurred: E0562, E0666. +For more information about an error, try `rustc --explain E0562`. diff --git a/src/test/ui/compile-fail-migration/impl-unused-tps-inherent.rs b/src/test/ui/compile-fail-migration/impl-unused-tps-inherent.rs new file mode 100644 index 00000000000..3803bb9b045 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-unused-tps-inherent.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct MyType; + +struct MyType1(T); + +trait Bar { + type Out; +} + +impl MyType { + //~^ ERROR the type parameter `T` is not constrained +} + +impl MyType1 { + // OK, T is used in `Foo`. +} + +impl MyType1 { + //~^ ERROR the type parameter `U` is not constrained +} + +impl MyType1 where T: Bar { + // OK, T is used in `Foo`. +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/impl-unused-tps-inherent.stderr b/src/test/ui/compile-fail-migration/impl-unused-tps-inherent.stderr new file mode 100644 index 00000000000..c1f31deb858 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-unused-tps-inherent.stderr @@ -0,0 +1,15 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps-inherent.rs:19:6 + | +LL | impl MyType { + | ^ unconstrained type parameter + +error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps-inherent.rs:27:8 + | +LL | impl MyType1 { + | ^ unconstrained type parameter + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0207`. diff --git a/src/test/ui/compile-fail-migration/impl-unused-tps.rs b/src/test/ui/compile-fail-migration/impl-unused-tps.rs new file mode 100644 index 00000000000..c9399afbb93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-unused-tps.rs @@ -0,0 +1,72 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + fn get(&self, A: &A) { } +} + +trait Bar { + type Out; +} + +impl Foo for [isize;0] { + // OK, T is used in `Foo`. +} + +impl Foo for [isize;1] { + //~^ ERROR the type parameter `U` is not constrained +} + +impl Foo for [isize;2] where T : Bar { + // OK, `U` is now constrained by the output type parameter. +} + +impl,U> Foo for [isize;3] { + // OK, same as above but written differently. +} + +impl Foo for U { + // OK, T, U are used everywhere. Note that the coherence check + // hasn't executed yet, so no errors about overlap. +} + +impl Bar for T { + //~^ ERROR the type parameter `U` is not constrained + + type Out = U; + + // Using `U` in an associated type within the impl is not good enough! +} + +impl Bar for T + where T : Bar +{ + //~^^^ ERROR the type parameter `U` is not constrained + + // This crafty self-referential attempt is still no good. +} + +impl Foo for T + where (T,U): Bar +{ + //~^^^ ERROR the type parameter `U` is not constrained + //~| ERROR the type parameter `V` is not constrained + + // Here, `V` is bound by an output type parameter, but the inputs + // are not themselves constrained. +} + +impl Foo<(T,U)> for T + where (T,U): Bar +{ + // As above, but both T and U ARE constrained. +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/impl-unused-tps.stderr b/src/test/ui/compile-fail-migration/impl-unused-tps.stderr new file mode 100644 index 00000000000..f50cc00b2f6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/impl-unused-tps.stderr @@ -0,0 +1,33 @@ +error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps.rs:23:8 + | +LL | impl Foo for [isize;1] { + | ^ unconstrained type parameter + +error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps.rs:40:8 + | +LL | impl Bar for T { + | ^ unconstrained type parameter + +error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps.rs:48:8 + | +LL | impl Bar for T + | ^ unconstrained type parameter + +error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps.rs:56:8 + | +LL | impl Foo for T + | ^ unconstrained type parameter + +error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps.rs:56:10 + | +LL | impl Foo for T + | ^ unconstrained type parameter + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0207`. diff --git a/src/test/ui/compile-fail-migration/implicit-method-bind.rs b/src/test/ui/compile-fail-migration/implicit-method-bind.rs new file mode 100644 index 00000000000..e116966670d --- /dev/null +++ b/src/test/ui/compile-fail-migration/implicit-method-bind.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let _f = 10i32.abs; //~ ERROR attempted to take value of method +} diff --git a/src/test/ui/compile-fail-migration/implicit-method-bind.stderr b/src/test/ui/compile-fail-migration/implicit-method-bind.stderr new file mode 100644 index 00000000000..5de9e58807c --- /dev/null +++ b/src/test/ui/compile-fail-migration/implicit-method-bind.stderr @@ -0,0 +1,11 @@ +error[E0615]: attempted to take value of method `abs` on type `i32` + --> $DIR/implicit-method-bind.rs:12:20 + | +LL | let _f = 10i32.abs; //~ ERROR attempted to take value of method + | ^^^ + | + = help: maybe a `()` to call it is missing? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0615`. diff --git a/src/test/ui/compile-fail-migration/import-crate-var.rs b/src/test/ui/compile-fail-migration/import-crate-var.rs new file mode 100644 index 00000000000..b09883d9ade --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-crate-var.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:import_crate_var.rs + +#![feature(rustc_attrs)] + +#[macro_use] extern crate import_crate_var; + +#[rustc_error] +fn main() { //~ ERROR compilation successful + m!(); + //~^ WARN `$crate` may not be imported + //~| NOTE `use $crate;` was erroneously allowed and will become a hard error +} diff --git a/src/test/ui/compile-fail-migration/import-crate-var.stderr b/src/test/ui/compile-fail-migration/import-crate-var.stderr new file mode 100644 index 00000000000..d2e22391406 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-crate-var.stderr @@ -0,0 +1,19 @@ +warning: `$crate` may not be imported + --> $DIR/import-crate-var.rs:22:5 + | +LL | m!(); + | ^^^^^ + | + = note: `use $crate;` was erroneously allowed and will become a hard error in a future release + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: compilation successful + --> $DIR/import-crate-var.rs:21:1 + | +LL | / fn main() { +LL | | m!(); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/import-from-missing.rs b/src/test/ui/compile-fail-migration/import-from-missing.rs new file mode 100644 index 00000000000..220b255bde4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-from-missing.rs @@ -0,0 +1,22 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use spam::{ham, eggs}; //~ ERROR unresolved import `spam::eggs` [E0432] + //~^ no `eggs` in `spam` + +mod spam { + pub fn ham() { } +} + +fn main() { + ham(); + // Expect eggs to pass because the compiler inserts a fake name for it + eggs(); +} diff --git a/src/test/ui/compile-fail-migration/import-from-missing.stderr b/src/test/ui/compile-fail-migration/import-from-missing.stderr new file mode 100644 index 00000000000..1b40fe45c7f --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-from-missing.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `spam::eggs` + --> $DIR/import-from-missing.rs:11:17 + | +LL | use spam::{ham, eggs}; //~ ERROR unresolved import `spam::eggs` [E0432] + | ^^^^ no `eggs` in `spam` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/import-glob-0.rs b/src/test/ui/compile-fail-migration/import-glob-0.rs new file mode 100644 index 00000000000..774eaf174d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-glob-0.rs @@ -0,0 +1,26 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use module_of_many_things::*; + +mod module_of_many_things { + pub fn f1() { println!("f1"); } + pub fn f2() { println!("f2"); } + fn f3() { println!("f3"); } + pub fn f4() { println!("f4"); } +} + + +fn main() { + f1(); + f2(); + f999(); //~ ERROR cannot find function `f999` in this scope + f4(); +} diff --git a/src/test/ui/compile-fail-migration/import-glob-0.stderr b/src/test/ui/compile-fail-migration/import-glob-0.stderr new file mode 100644 index 00000000000..91cae30776d --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-glob-0.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `f999` in this scope + --> $DIR/import-glob-0.rs:24:5 + | +LL | f999(); //~ ERROR cannot find function `f999` in this scope + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/import-glob-circular.rs b/src/test/ui/compile-fail-migration/import-glob-circular.rs new file mode 100644 index 00000000000..d9cc17791ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-glob-circular.rs @@ -0,0 +1,27 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod circ1 { + pub use circ2::f2; + pub fn f1() { println!("f1"); } + pub fn common() -> usize { return 0; } +} + +mod circ2 { + pub use circ1::f1; + pub fn f2() { println!("f2"); } + pub fn common() -> usize { return 1; } +} + +mod test { + use circ1::*; + + fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope +} diff --git a/src/test/ui/compile-fail-migration/import-glob-circular.stderr b/src/test/ui/compile-fail-migration/import-glob-circular.stderr new file mode 100644 index 00000000000..078a6a3937a --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-glob-circular.stderr @@ -0,0 +1,14 @@ +error[E0425]: cannot find function `f1066` in this scope + --> $DIR/import-glob-circular.rs:26:17 + | +LL | fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope + | ^^^^^ not found in this scope + +error[E0601]: `main` function not found in crate `import_glob_circular` + | + = note: consider adding a `main` function to `$DIR/import-glob-circular.rs` + +error: aborting due to 2 previous errors + +Some errors occurred: E0425, E0601. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/import-loop-2.rs b/src/test/ui/compile-fail-migration/import-loop-2.rs new file mode 100644 index 00000000000..b7bbe11a4dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-loop-2.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:import + +mod a { + pub use b::x; +} + +mod b { + pub use a::x; + + fn main() { let y = x; } +} diff --git a/src/test/ui/compile-fail-migration/import-loop-2.stderr b/src/test/ui/compile-fail-migration/import-loop-2.stderr new file mode 100644 index 00000000000..717f74643eb --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-loop-2.stderr @@ -0,0 +1,19 @@ +error[E0432]: unresolved import `a::x` + --> $DIR/import-loop-2.rs:18:13 + | +LL | pub use a::x; + | ^^^^ no `x` in `a` + +error[E0601]: `main` function not found in crate `import_loop_2` + | + = note: the main function must be defined at the crate level but you have one or more functions named 'main' that are not defined at the crate level. Either move the definition or attach the `#[main]` attribute to override this behavior. +note: here is a function named 'main' + --> $DIR/import-loop-2.rs:20:5 + | +LL | fn main() { let y = x; } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0432, E0601. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/import-loop.rs b/src/test/ui/compile-fail-migration/import-loop.rs new file mode 100644 index 00000000000..f9b57f00776 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-loop.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:import + +use y::x; + +mod y { + pub use y::x; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/import-loop.stderr b/src/test/ui/compile-fail-migration/import-loop.stderr new file mode 100644 index 00000000000..b9a1204bb73 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-loop.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `y::x` + --> $DIR/import-loop.rs:16:13 + | +LL | pub use y::x; + | ^^^^ no `x` in `y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/import-prefix-macro-1.rs b/src/test/ui/compile-fail-migration/import-prefix-macro-1.rs new file mode 100644 index 00000000000..beb15a11a96 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-prefix-macro-1.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + pub mod b { + pub mod c { + pub struct S; + pub struct Z; + } + } +} + +macro_rules! import { + ($p: path) => (use $p {S, Z}); //~ERROR expected one of `::`, `;`, or `as`, found `{` +} + +import! { a::b::c } + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/import-prefix-macro-1.stderr b/src/test/ui/compile-fail-migration/import-prefix-macro-1.stderr new file mode 100644 index 00000000000..e3f436e4ea8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-prefix-macro-1.stderr @@ -0,0 +1,11 @@ +error: expected one of `::`, `;`, or `as`, found `{` + --> $DIR/import-prefix-macro-1.rs:21:27 + | +LL | ($p: path) => (use $p {S, Z}); //~ERROR expected one of `::`, `;`, or `as`, found `{` + | ^ expected one of `::`, `;`, or `as` here +... +LL | import! { a::b::c } + | ------------------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/import-prefix-macro-2.rs b/src/test/ui/compile-fail-migration/import-prefix-macro-2.rs new file mode 100644 index 00000000000..56c6273aa9a --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-prefix-macro-2.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + pub mod b { + pub mod c { + pub struct S; + pub struct Z; + } + } +} + +macro_rules! import { + ($p: path) => (use ::$p {S, Z}); //~ERROR expected identifier, found `a::b::c` +} + +import! { a::b::c } + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/import-prefix-macro-2.stderr b/src/test/ui/compile-fail-migration/import-prefix-macro-2.stderr new file mode 100644 index 00000000000..ab9e32afdf0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-prefix-macro-2.stderr @@ -0,0 +1,11 @@ +error: expected identifier, found `a::b::c` + --> $DIR/import-prefix-macro-2.rs:21:26 + | +LL | ($p: path) => (use ::$p {S, Z}); //~ERROR expected identifier, found `a::b::c` + | ^^ expected identifier +... +LL | import! { a::b::c } + | ------------------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/import-trait-method.rs b/src/test/ui/compile-fail-migration/import-trait-method.rs new file mode 100644 index 00000000000..75081b10d86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-trait-method.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + fn foo(); +} + +use Foo::foo; //~ ERROR not directly importable + +fn main() { foo(); } diff --git a/src/test/ui/compile-fail-migration/import-trait-method.stderr b/src/test/ui/compile-fail-migration/import-trait-method.stderr new file mode 100644 index 00000000000..917a68a7c8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/import-trait-method.stderr @@ -0,0 +1,9 @@ +error[E0253]: `foo` is not directly importable + --> $DIR/import-trait-method.rs:15:5 + | +LL | use Foo::foo; //~ ERROR not directly importable + | ^^^^^^^^ cannot be imported directly + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0253`. diff --git a/src/test/ui/compile-fail-migration/import.rs b/src/test/ui/compile-fail-migration/import.rs new file mode 100644 index 00000000000..81a5334ed7a --- /dev/null +++ b/src/test/ui/compile-fail-migration/import.rs @@ -0,0 +1,25 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use zed::bar; +use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] + //~^ no `baz` in `zed`. Did you mean to use `bar`? + + +mod zed { + pub fn bar() { println!("bar"); } + use foo; //~ ERROR unresolved import `foo` [E0432] + //~^ no `foo` in the root +} + +fn main() { + zed::foo(); //~ ERROR `foo` is private + bar(); +} diff --git a/src/test/ui/compile-fail-migration/import.stderr b/src/test/ui/compile-fail-migration/import.stderr new file mode 100644 index 00000000000..89665586844 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import.stderr @@ -0,0 +1,22 @@ +error[E0432]: unresolved import `zed::baz` + --> $DIR/import.rs:12:5 + | +LL | use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] + | ^^^^^^^^ no `baz` in `zed`. Did you mean to use `bar`? + +error[E0432]: unresolved import `foo` + --> $DIR/import.rs:18:9 + | +LL | use foo; //~ ERROR unresolved import `foo` [E0432] + | ^^^ no `foo` in the root + +error[E0603]: unresolved item `foo` is private + --> $DIR/import.rs:23:5 + | +LL | zed::foo(); //~ ERROR `foo` is private + | ^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0432, E0603. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/import2.rs b/src/test/ui/compile-fail-migration/import2.rs new file mode 100644 index 00000000000..c4bd9ff1e2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/import2.rs @@ -0,0 +1,20 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use baz::zed::bar; //~ ERROR unresolved import `baz::zed` [E0432] + //~^ Could not find `zed` in `baz` + +mod baz {} +mod zed { + pub fn bar() { println!("bar3"); } +} +fn main() { + bar(); +} diff --git a/src/test/ui/compile-fail-migration/import2.stderr b/src/test/ui/compile-fail-migration/import2.stderr new file mode 100644 index 00000000000..c07506845c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import2.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `baz::zed` + --> $DIR/import2.rs:11:10 + | +LL | use baz::zed::bar; //~ ERROR unresolved import `baz::zed` [E0432] + | ^^^ Could not find `zed` in `baz` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/import3.rs b/src/test/ui/compile-fail-migration/import3.rs new file mode 100644 index 00000000000..0a7827587a6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import3.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: unresolved +use main::bar; + +fn main() { println!("foo"); } diff --git a/src/test/ui/compile-fail-migration/import3.stderr b/src/test/ui/compile-fail-migration/import3.stderr new file mode 100644 index 00000000000..5211b862b3d --- /dev/null +++ b/src/test/ui/compile-fail-migration/import3.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `main` + --> $DIR/import3.rs:12:5 + | +LL | use main::bar; + | ^^^^ Maybe a missing `extern crate main;`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/import4.rs b/src/test/ui/compile-fail-migration/import4.rs new file mode 100644 index 00000000000..5f3163e9390 --- /dev/null +++ b/src/test/ui/compile-fail-migration/import4.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: import + + +mod a { pub use b::foo; } +mod b { pub use a::foo; } + +fn main() { println!("loop"); } diff --git a/src/test/ui/compile-fail-migration/import4.stderr b/src/test/ui/compile-fail-migration/import4.stderr new file mode 100644 index 00000000000..d74e781ad4a --- /dev/null +++ b/src/test/ui/compile-fail-migration/import4.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `a::foo` + --> $DIR/import4.rs:15:17 + | +LL | mod b { pub use a::foo; } + | ^^^^^^ no `foo` in `a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/imports/reexports.rs b/src/test/ui/compile-fail-migration/imports/reexports.rs new file mode 100644 index 00000000000..f50b5b0e849 --- /dev/null +++ b/src/test/ui/compile-fail-migration/imports/reexports.rs @@ -0,0 +1,42 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + fn foo() {} + mod foo {} + + mod a { + pub use super::foo; //~ ERROR cannot be re-exported + pub use super::*; //~ ERROR must import something with the glob's visibility + } +} + +mod b { + pub fn foo() {} + mod foo { pub struct S; } + + pub mod a { + pub use super::foo; // This is OK since the value `foo` is visible enough. + fn f(_: foo::S) {} // `foo` is imported in the type namespace (but not `pub` re-exported). + } + + pub mod b { + pub use super::*; // This is also OK since the value `foo` is visible enough. + fn f(_: foo::S) {} // Again, the module `foo` is imported (but not `pub` re-exported). + } +} + +mod c { + // Test that `foo` is not re-exported. + use b::a::foo::S; //~ ERROR `foo` + use b::b::foo::S as T; //~ ERROR `foo` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/imports/reexports.stderr b/src/test/ui/compile-fail-migration/imports/reexports.stderr new file mode 100644 index 00000000000..a166344314b --- /dev/null +++ b/src/test/ui/compile-fail-migration/imports/reexports.stderr @@ -0,0 +1,34 @@ +error[E0364]: `foo` is private, and cannot be re-exported + --> $DIR/reexports.rs:16:17 + | +LL | pub use super::foo; //~ ERROR cannot be re-exported + | ^^^^^^^^^^ + | +note: consider marking `foo` as `pub` in the imported module + --> $DIR/reexports.rs:16:17 + | +LL | pub use super::foo; //~ ERROR cannot be re-exported + | ^^^^^^^^^^ + +error: A non-empty glob must import something with the glob's visibility + --> $DIR/reexports.rs:17:17 + | +LL | pub use super::*; //~ ERROR must import something with the glob's visibility + | ^^^^^^^^ + +error[E0603]: module `foo` is private + --> $DIR/reexports.rs:38:9 + | +LL | use b::a::foo::S; //~ ERROR `foo` + | ^^^^^^^^^^^^ + +error[E0603]: module `foo` is private + --> $DIR/reexports.rs:39:9 + | +LL | use b::b::foo::S as T; //~ ERROR `foo` + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0364, E0603. +For more information about an error, try `rustc --explain E0364`. diff --git a/src/test/ui/compile-fail-migration/imports/unused-macro-use.rs b/src/test/ui/compile-fail-migration/imports/unused-macro-use.rs new file mode 100644 index 00000000000..365521970cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/imports/unused-macro-use.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused)] + +#[macro_use] //~ ERROR unused `#[macro_use]` import +extern crate core; + +#[macro_use( + panic //~ ERROR unused `#[macro_use]` import +)] +extern crate core as core_2; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/imports/unused-macro-use.stderr b/src/test/ui/compile-fail-migration/imports/unused-macro-use.stderr new file mode 100644 index 00000000000..0920b5c6d1e --- /dev/null +++ b/src/test/ui/compile-fail-migration/imports/unused-macro-use.stderr @@ -0,0 +1,21 @@ +error: unused `#[macro_use]` import + --> $DIR/unused-macro-use.rs:13:1 + | +LL | #[macro_use] //~ ERROR unused `#[macro_use]` import + | ^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/unused-macro-use.rs:11:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: #[deny(unused_imports)] implied by #[deny(unused)] + +error: unused `#[macro_use]` import + --> $DIR/unused-macro-use.rs:17:5 + | +LL | panic //~ ERROR unused `#[macro_use]` import + | ^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/imports/unused.rs b/src/test/ui/compile-fail-migration/imports/unused.rs new file mode 100644 index 00000000000..1eb756fe9e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/imports/unused.rs @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused)] + +mod foo { + fn f() {} + + mod m1 { + pub(super) use super::f; //~ ERROR unused + } + + mod m2 { + #[allow(unused)] + use super::m1::*; // (despite this glob import) + } + + mod m3 { + pub(super) use super::f; // Check that this is counted as used (c.f. #36249). + } + + pub mod m4 { + use super::m3::*; + pub fn g() { f(); } + } +} + +fn main() { + foo::m4::g(); +} diff --git a/src/test/ui/compile-fail-migration/imports/unused.stderr b/src/test/ui/compile-fail-migration/imports/unused.stderr new file mode 100644 index 00000000000..ff5c937aa83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/imports/unused.stderr @@ -0,0 +1,15 @@ +error: unused import: `super::f` + --> $DIR/unused.rs:17:24 + | +LL | pub(super) use super::f; //~ ERROR unused + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/unused.rs:11:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: #[deny(unused_imports)] implied by #[deny(unused)] + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/inaccessible-test-modules.rs b/src/test/ui/compile-fail-migration/inaccessible-test-modules.rs new file mode 100644 index 00000000000..bfc1ac2daef --- /dev/null +++ b/src/test/ui/compile-fail-migration/inaccessible-test-modules.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:--test + +// the `--test` harness creates modules with these textual names, but +// they should be inaccessible from normal code. +use __test as x; //~ ERROR unresolved import `__test` +use __test_reexports as y; //~ ERROR unresolved import `__test_reexports` + +#[test] +fn baz() {} diff --git a/src/test/ui/compile-fail-migration/inaccessible-test-modules.stderr b/src/test/ui/compile-fail-migration/inaccessible-test-modules.stderr new file mode 100644 index 00000000000..ce8eaf59027 --- /dev/null +++ b/src/test/ui/compile-fail-migration/inaccessible-test-modules.stderr @@ -0,0 +1,15 @@ +error[E0432]: unresolved import `__test` + --> $DIR/inaccessible-test-modules.rs:15:5 + | +LL | use __test as x; //~ ERROR unresolved import `__test` + | ^^^^^^^^^^^ no `__test` in the root. Did you mean to use `__test`? + +error[E0432]: unresolved import `__test_reexports` + --> $DIR/inaccessible-test-modules.rs:16:5 + | +LL | use __test_reexports as y; //~ ERROR unresolved import `__test_reexports` + | ^^^^^^^^^^^^^^^^^^^^^ no `__test_reexports` in the root. Did you mean to use `__test_reexports`? + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/index-bot.rs b/src/test/ui/compile-fail-migration/index-bot.rs new file mode 100644 index 00000000000..fc88ff6f47b --- /dev/null +++ b/src/test/ui/compile-fail-migration/index-bot.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + (return)[0]; //~ ERROR cannot index into a value of type `!` +} diff --git a/src/test/ui/compile-fail-migration/index-bot.stderr b/src/test/ui/compile-fail-migration/index-bot.stderr new file mode 100644 index 00000000000..1086196d6ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/index-bot.stderr @@ -0,0 +1,9 @@ +error[E0608]: cannot index into a value of type `!` + --> $DIR/index-bot.rs:12:5 + | +LL | (return)[0]; //~ ERROR cannot index into a value of type `!` + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0608`. diff --git a/src/test/ui/compile-fail-migration/index_message.rs b/src/test/ui/compile-fail-migration/index_message.rs new file mode 100644 index 00000000000..b9daad936c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/index_message.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let z = (); + let _ = z[0]; //~ ERROR cannot index into a value of type `()` +} diff --git a/src/test/ui/compile-fail-migration/index_message.stderr b/src/test/ui/compile-fail-migration/index_message.stderr new file mode 100644 index 00000000000..208d33e9cd5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/index_message.stderr @@ -0,0 +1,9 @@ +error[E0608]: cannot index into a value of type `()` + --> $DIR/index_message.rs:13:13 + | +LL | let _ = z[0]; //~ ERROR cannot index into a value of type `()` + | ^^^^ help: to access tuple elements, use: `z.0` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0608`. diff --git a/src/test/ui/compile-fail-migration/indexing-requires-a-uint.rs b/src/test/ui/compile-fail-migration/indexing-requires-a-uint.rs new file mode 100644 index 00000000000..624944f7344 --- /dev/null +++ b/src/test/ui/compile-fail-migration/indexing-requires-a-uint.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure that indexing an array is only valid with a `usize`, not any other +// integral type. + +fn main() { + fn bar(_: T) {} + [0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied + + [0][0]; // should infer to be a usize + + let i = 0; // i is an IntVar + [0][i]; // i should be locked to usize + bar::(i); // i should not be re-coerced back to an isize + //~^ ERROR: mismatched types +} diff --git a/src/test/ui/compile-fail-migration/indexing-requires-a-uint.stderr b/src/test/ui/compile-fail-migration/indexing-requires-a-uint.stderr new file mode 100644 index 00000000000..e9608e0b235 --- /dev/null +++ b/src/test/ui/compile-fail-migration/indexing-requires-a-uint.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied + --> $DIR/indexing-requires-a-uint.rs:16:5 + | +LL | [0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied + | ^^^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[{integer}]>` is not implemented for `u8` + = note: required because of the requirements on the impl of `std::ops::Index` for `[{integer}]` + +error[E0308]: mismatched types + --> $DIR/indexing-requires-a-uint.rs:22:18 + | +LL | bar::(i); // i should not be re-coerced back to an isize + | ^ expected isize, found usize + +error: aborting due to 2 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/infinite-autoderef.rs b/src/test/ui/compile-fail-migration/infinite-autoderef.rs new file mode 100644 index 00000000000..3635c4dbb02 --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-autoderef.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: reached the recursion limit while auto-dereferencing + +#![feature(box_syntax)] + +use std::ops::Deref; + +struct Foo; + +impl Deref for Foo { + type Target = Foo; + + fn deref(&self) -> &Foo { + self + } +} + +pub fn main() { + let mut x; + loop { + x = box x; + x.foo; + x.bar(); + } + + Foo.foo; + Foo.bar(); +} diff --git a/src/test/ui/compile-fail-migration/infinite-autoderef.stderr b/src/test/ui/compile-fail-migration/infinite-autoderef.stderr new file mode 100644 index 00000000000..b5e20ea5cbf --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-autoderef.stderr @@ -0,0 +1,52 @@ +error[E0308]: mismatched types + --> $DIR/infinite-autoderef.rs:30:13 + | +LL | x = box x; + | ^^^^^ + | | + | cyclic type of infinite size + | help: try using a conversion method: `box x.to_string()` + +error[E0055]: reached the recursion limit while auto-dereferencing Foo + --> $DIR/infinite-autoderef.rs:35:5 + | +LL | Foo.foo; + | ^^^^^^^ deref recursion limit reached + | + = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + +error[E0055]: reached the recursion limit while auto-dereferencing Foo + --> $DIR/infinite-autoderef.rs:35:9 + | +LL | Foo.foo; + | ^^^ deref recursion limit reached + | + = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + +error[E0609]: no field `foo` on type `Foo` + --> $DIR/infinite-autoderef.rs:35:9 + | +LL | Foo.foo; + | ^^^ unknown field + +error[E0055]: reached the recursion limit while auto-dereferencing Foo + --> $DIR/infinite-autoderef.rs:36:9 + | +LL | Foo.bar(); + | ^^^ deref recursion limit reached + | + = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + +error[E0599]: no method named `bar` found for type `Foo` in the current scope + --> $DIR/infinite-autoderef.rs:36:9 + | +LL | struct Foo; + | ----------- method `bar` not found for this +... +LL | Foo.bar(); + | ^^^ + +error: aborting due to 6 previous errors + +Some errors occurred: E0055, E0308, E0599, E0609. +For more information about an error, try `rustc --explain E0055`. diff --git a/src/test/ui/compile-fail-migration/infinite-instantiation.rs b/src/test/ui/compile-fail-migration/infinite-instantiation.rs new file mode 100644 index 00000000000..08e6bf24691 --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-instantiation.rs @@ -0,0 +1,44 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// +// We get an error message at the top of file (dummy span). +// This is not helpful, but also kind of annoying to prevent, +// so for now just live with it. +// This test case was originally for issue #2258. + +trait ToOpt: Sized { + fn to_option(&self) -> Option; +} + +impl ToOpt for usize { + fn to_option(&self) -> Option { + Some(*self) + } +} + +impl ToOpt for Option { + fn to_option(&self) -> Option> { + Some((*self).clone()) + } +} + +fn function(counter: usize, t: T) { +//~^ ERROR reached the recursion limit while instantiating `function:: 0 { + function(counter - 1, t.to_option()); + // FIXME(#4287) Error message should be here. It should be + // a type error to instantiate `test` at a type other than T. + } +} + +fn main() { + function(22, 22); +} diff --git a/src/test/ui/compile-fail-migration/infinite-instantiation.stderr b/src/test/ui/compile-fail-migration/infinite-instantiation.stderr new file mode 100644 index 00000000000..483605fc389 --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-instantiation.stderr @@ -0,0 +1,14 @@ +error: reached the recursion limit while instantiating `function::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/infinite-instantiation.rs:33:1 + | +LL | / fn function(counter: usize, t: T) { +LL | | //~^ ERROR reached the recursion limit while instantiating `function:: 0 { +LL | | function(counter - 1, t.to_option()); +... | +LL | | } +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/infinite-macro-expansion.rs b/src/test/ui/compile-fail-migration/infinite-macro-expansion.rs new file mode 100644 index 00000000000..14d22702db7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-macro-expansion.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! recursive { + () => (recursive!()) //~ ERROR recursion limit reached while expanding the macro `recursive` +} + +fn main() { + recursive!() +} diff --git a/src/test/ui/compile-fail-migration/infinite-macro-expansion.stderr b/src/test/ui/compile-fail-migration/infinite-macro-expansion.stderr new file mode 100644 index 00000000000..79216693475 --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-macro-expansion.stderr @@ -0,0 +1,13 @@ +error: recursion limit reached while expanding the macro `recursive` + --> $DIR/infinite-macro-expansion.rs:12:12 + | +LL | () => (recursive!()) //~ ERROR recursion limit reached while expanding the macro `recursive` + | ^^^^^^^^^^^^ +... +LL | recursive!() + | ------------ in this macro invocation + | + = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/infinite-tag-type-recursion.rs b/src/test/ui/compile-fail-migration/infinite-tag-type-recursion.rs new file mode 100644 index 00000000000..c9a7f731aea --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-tag-type-recursion.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum mlist { cons(isize, mlist), nil, } +//~^ ERROR recursive type `mlist` has infinite size + +fn main() { let a = mlist::cons(10, mlist::cons(11, mlist::nil)); } diff --git a/src/test/ui/compile-fail-migration/infinite-tag-type-recursion.stderr b/src/test/ui/compile-fail-migration/infinite-tag-type-recursion.stderr new file mode 100644 index 00000000000..e1fa3dec64c --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-tag-type-recursion.stderr @@ -0,0 +1,13 @@ +error[E0072]: recursive type `mlist` has infinite size + --> $DIR/infinite-tag-type-recursion.rs:11:1 + | +LL | enum mlist { cons(isize, mlist), nil, } + | ^^^^^^^^^^ ----- recursive without indirection + | | + | recursive type has infinite size + | + = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `mlist` representable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/compile-fail-migration/infinite-vec-type-recursion.rs b/src/test/ui/compile-fail-migration/infinite-vec-type-recursion.rs new file mode 100644 index 00000000000..42c80b54313 --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-vec-type-recursion.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +type x = Vec; +//~^ ERROR cycle detected + +fn main() { let b: x = Vec::new(); } diff --git a/src/test/ui/compile-fail-migration/infinite-vec-type-recursion.stderr b/src/test/ui/compile-fail-migration/infinite-vec-type-recursion.stderr new file mode 100644 index 00000000000..3e2d3d6d726 --- /dev/null +++ b/src/test/ui/compile-fail-migration/infinite-vec-type-recursion.stderr @@ -0,0 +1,11 @@ +error[E0391]: cycle detected when processing `x` + --> $DIR/infinite-vec-type-recursion.rs:11:14 + | +LL | type x = Vec; + | ^ + | + = note: ...which again requires processing `x`, completing the cycle + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.rs b/src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.rs new file mode 100644 index 00000000000..d11aacec196 --- /dev/null +++ b/src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.rs @@ -0,0 +1,26 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:reached recursion limit + +#![feature(never_type)] +#![feature(exhaustive_patterns)] + +struct Foo<'a, T: 'a> { + ph: std::marker::PhantomData, + foo: &'a Foo<'a, (T, T)>, +} + +fn wub(f: Foo) { + match f {} +} + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.stderr b/src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.stderr new file mode 100644 index 00000000000..24237f3a1b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/inhabitedness-infinite-loop.stderr @@ -0,0 +1,4 @@ +error: reached recursion limit while checking inhabitedness of `Foo<'_, (((((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))))), ((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))))), (((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))))), ((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))))))), ((((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))))), ((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))))), (((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))))), ((((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))))), (((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))), ((((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))))), (((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))), ((((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))))), (((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))), ((((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !))))), (((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))), ((((!, !), (!, !)), ((!, !), (!, !))), (((!, !), (!, !)), ((!, !), (!, !)))))))))))))))>` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/init-unsafe.rs b/src/test/ui/compile-fail-migration/init-unsafe.rs new file mode 100644 index 00000000000..9e599cebd7a --- /dev/null +++ b/src/test/ui/compile-fail-migration/init-unsafe.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(core_intrinsics)] + +use std::intrinsics::{init}; + +// Test that the `init` intrinsic is really unsafe +pub fn main() { + let stuff = init::(); //~ ERROR call to unsafe function is unsafe +} diff --git a/src/test/ui/compile-fail-migration/init-unsafe.stderr b/src/test/ui/compile-fail-migration/init-unsafe.stderr new file mode 100644 index 00000000000..f3d041fde01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/init-unsafe.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/init-unsafe.rs:17:17 + | +LL | let stuff = init::(); //~ ERROR call to unsafe function is unsafe + | ^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/inner-static-type-parameter.rs b/src/test/ui/compile-fail-migration/inner-static-type-parameter.rs new file mode 100644 index 00000000000..4d763017c0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/inner-static-type-parameter.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// see #9186 + +enum Bar { What } //~ ERROR parameter `T` is never used + +fn foo() { + static a: Bar = Bar::What; +//~^ ERROR can't use type parameters from outer function +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/inner-static-type-parameter.stderr b/src/test/ui/compile-fail-migration/inner-static-type-parameter.stderr new file mode 100644 index 00000000000..1820e5c57dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/inner-static-type-parameter.stderr @@ -0,0 +1,22 @@ +error[E0401]: can't use type parameters from outer function + --> $DIR/inner-static-type-parameter.rs:16:19 + | +LL | fn foo() { + | --- - type variable from outer function + | | + | try adding a local type parameter in this method instead +LL | static a: Bar = Bar::What; + | ^ use of type variable from outer function + +error[E0392]: parameter `T` is never used + --> $DIR/inner-static-type-parameter.rs:13:10 + | +LL | enum Bar { What } //~ ERROR parameter `T` is never used + | ^ unused type parameter + | + = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 2 previous errors + +Some errors occurred: E0392, E0401. +For more information about an error, try `rustc --explain E0392`. diff --git a/src/test/ui/compile-fail-migration/integer-literal-suffix-inference.rs b/src/test/ui/compile-fail-migration/integer-literal-suffix-inference.rs new file mode 100644 index 00000000000..7a850d90a87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/integer-literal-suffix-inference.rs @@ -0,0 +1,172 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + + // the smallest positive values that need these types + let a8: i8 = 8; + let a16: i16 = 128; + let a32: i32 = 32_768; + let a64: i64 = 2_147_483_648; + + // the smallest negative values that need these types + let c8: i8 = -9; + let c16: i16 = -129; + let c32: i32 = -32_769; + let c64: i64 = -2_147_483_649; + + fn id_i8(n: i8) -> i8 { n } + fn id_i16(n: i16) -> i16 { n } + fn id_i32(n: i32) -> i32 { n } + fn id_i64(n: i64) -> i64 { n } + + // the smallest values that need these types + let b8: u8 = 16; + let b16: u16 = 256; + let b32: u32 = 65_536; + let b64: u64 = 4_294_967_296; + + fn id_u8(n: u8) -> u8 { n } + fn id_u16(n: u16) -> u16 { n } + fn id_u32(n: u32) -> u32 { n } + fn id_u64(n: u64) -> u64 { n } + + id_i8(a8); // ok + id_i8(a16); + //~^ ERROR mismatched types + //~| expected i8, found i16 + id_i8(a32); + //~^ ERROR mismatched types + //~| expected i8, found i32 + id_i8(a64); + //~^ ERROR mismatched types + //~| expected i8, found i64 + + id_i16(a8); + //~^ ERROR mismatched types + //~| expected i16, found i8 + id_i16(a16); // ok + id_i16(a32); + //~^ ERROR mismatched types + //~| expected i16, found i32 + id_i16(a64); + //~^ ERROR mismatched types + //~| expected i16, found i64 + + id_i32(a8); + //~^ ERROR mismatched types + //~| expected i32, found i8 + id_i32(a16); + //~^ ERROR mismatched types + //~| expected i32, found i16 + id_i32(a32); // ok + id_i32(a64); + //~^ ERROR mismatched types + //~| expected i32, found i64 + + id_i64(a8); + //~^ ERROR mismatched types + //~| expected i64, found i8 + id_i64(a16); + //~^ ERROR mismatched types + //~| expected i64, found i16 + id_i64(a32); + //~^ ERROR mismatched types + //~| expected i64, found i32 + id_i64(a64); // ok + + id_i8(c8); // ok + id_i8(c16); + //~^ ERROR mismatched types + //~| expected i8, found i16 + id_i8(c32); + //~^ ERROR mismatched types + //~| expected i8, found i32 + id_i8(c64); + //~^ ERROR mismatched types + //~| expected i8, found i64 + + id_i16(c8); + //~^ ERROR mismatched types + //~| expected i16, found i8 + id_i16(c16); // ok + id_i16(c32); + //~^ ERROR mismatched types + //~| expected i16, found i32 + id_i16(c64); + //~^ ERROR mismatched types + //~| expected i16, found i64 + + id_i32(c8); + //~^ ERROR mismatched types + //~| expected i32, found i8 + id_i32(c16); + //~^ ERROR mismatched types + //~| expected i32, found i16 + id_i32(c32); // ok + id_i32(c64); + //~^ ERROR mismatched types + //~| expected i32, found i64 + + id_i64(a8); + //~^ ERROR mismatched types + //~| expected i64, found i8 + id_i64(a16); + //~^ ERROR mismatched types + //~| expected i64, found i16 + id_i64(a32); + //~^ ERROR mismatched types + //~| expected i64, found i32 + id_i64(a64); // ok + + id_u8(b8); // ok + id_u8(b16); + //~^ ERROR mismatched types + //~| expected u8, found u16 + id_u8(b32); + //~^ ERROR mismatched types + //~| expected u8, found u32 + id_u8(b64); + //~^ ERROR mismatched types + //~| expected u8, found u64 + + id_u16(b8); + //~^ ERROR mismatched types + //~| expected u16, found u8 + id_u16(b16); // ok + id_u16(b32); + //~^ ERROR mismatched types + //~| expected u16, found u32 + id_u16(b64); + //~^ ERROR mismatched types + //~| expected u16, found u64 + + id_u32(b8); + //~^ ERROR mismatched types + //~| expected u32, found u8 + id_u32(b16); + //~^ ERROR mismatched types + //~| expected u32, found u16 + id_u32(b32); // ok + id_u32(b64); + //~^ ERROR mismatched types + //~| expected u32, found u64 + + id_u64(b8); + //~^ ERROR mismatched types + //~| expected u64, found u8 + id_u64(b16); + //~^ ERROR mismatched types + //~| expected u64, found u16 + id_u64(b32); + //~^ ERROR mismatched types + //~| expected u64, found u32 + id_u64(b64); // ok +} diff --git a/src/test/ui/compile-fail-migration/integer-literal-suffix-inference.stderr b/src/test/ui/compile-fail-migration/integer-literal-suffix-inference.stderr new file mode 100644 index 00000000000..1c5d656020c --- /dev/null +++ b/src/test/ui/compile-fail-migration/integer-literal-suffix-inference.stderr @@ -0,0 +1,291 @@ +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:42:11 + | +LL | id_i8(a16); + | ^^^ expected i8, found i16 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:45:11 + | +LL | id_i8(a32); + | ^^^ expected i8, found i32 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:48:11 + | +LL | id_i8(a64); + | ^^^ expected i8, found i64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:52:12 + | +LL | id_i16(a8); + | ^^ expected i16, found i8 +help: you can cast an `i8` to `i16`, which will sign-extend the source value + | +LL | id_i16(a8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:56:12 + | +LL | id_i16(a32); + | ^^^ expected i16, found i32 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:59:12 + | +LL | id_i16(a64); + | ^^^ expected i16, found i64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:63:12 + | +LL | id_i32(a8); + | ^^ expected i32, found i8 +help: you can cast an `i8` to `i32`, which will sign-extend the source value + | +LL | id_i32(a8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:66:12 + | +LL | id_i32(a16); + | ^^^ expected i32, found i16 +help: you can cast an `i16` to `i32`, which will sign-extend the source value + | +LL | id_i32(a16.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:70:12 + | +LL | id_i32(a64); + | ^^^ expected i32, found i64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:74:12 + | +LL | id_i64(a8); + | ^^ expected i64, found i8 +help: you can cast an `i8` to `i64`, which will sign-extend the source value + | +LL | id_i64(a8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:77:12 + | +LL | id_i64(a16); + | ^^^ expected i64, found i16 +help: you can cast an `i16` to `i64`, which will sign-extend the source value + | +LL | id_i64(a16.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:80:12 + | +LL | id_i64(a32); + | ^^^ expected i64, found i32 +help: you can cast an `i32` to `i64`, which will sign-extend the source value + | +LL | id_i64(a32.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:86:11 + | +LL | id_i8(c16); + | ^^^ expected i8, found i16 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:89:11 + | +LL | id_i8(c32); + | ^^^ expected i8, found i32 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:92:11 + | +LL | id_i8(c64); + | ^^^ expected i8, found i64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:96:12 + | +LL | id_i16(c8); + | ^^ expected i16, found i8 +help: you can cast an `i8` to `i16`, which will sign-extend the source value + | +LL | id_i16(c8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:100:12 + | +LL | id_i16(c32); + | ^^^ expected i16, found i32 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:103:12 + | +LL | id_i16(c64); + | ^^^ expected i16, found i64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:107:12 + | +LL | id_i32(c8); + | ^^ expected i32, found i8 +help: you can cast an `i8` to `i32`, which will sign-extend the source value + | +LL | id_i32(c8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:110:12 + | +LL | id_i32(c16); + | ^^^ expected i32, found i16 +help: you can cast an `i16` to `i32`, which will sign-extend the source value + | +LL | id_i32(c16.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:114:12 + | +LL | id_i32(c64); + | ^^^ expected i32, found i64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:118:12 + | +LL | id_i64(a8); + | ^^ expected i64, found i8 +help: you can cast an `i8` to `i64`, which will sign-extend the source value + | +LL | id_i64(a8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:121:12 + | +LL | id_i64(a16); + | ^^^ expected i64, found i16 +help: you can cast an `i16` to `i64`, which will sign-extend the source value + | +LL | id_i64(a16.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:124:12 + | +LL | id_i64(a32); + | ^^^ expected i64, found i32 +help: you can cast an `i32` to `i64`, which will sign-extend the source value + | +LL | id_i64(a32.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:130:11 + | +LL | id_u8(b16); + | ^^^ expected u8, found u16 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:133:11 + | +LL | id_u8(b32); + | ^^^ expected u8, found u32 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:136:11 + | +LL | id_u8(b64); + | ^^^ expected u8, found u64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:140:12 + | +LL | id_u16(b8); + | ^^ expected u16, found u8 +help: you can cast an `u8` to `u16`, which will zero-extend the source value + | +LL | id_u16(b8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:144:12 + | +LL | id_u16(b32); + | ^^^ expected u16, found u32 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:147:12 + | +LL | id_u16(b64); + | ^^^ expected u16, found u64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:151:12 + | +LL | id_u32(b8); + | ^^ expected u32, found u8 +help: you can cast an `u8` to `u32`, which will zero-extend the source value + | +LL | id_u32(b8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:154:12 + | +LL | id_u32(b16); + | ^^^ expected u32, found u16 +help: you can cast an `u16` to `u32`, which will zero-extend the source value + | +LL | id_u32(b16.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:158:12 + | +LL | id_u32(b64); + | ^^^ expected u32, found u64 + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:162:12 + | +LL | id_u64(b8); + | ^^ expected u64, found u8 +help: you can cast an `u8` to `u64`, which will zero-extend the source value + | +LL | id_u64(b8.into()); + | ^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:165:12 + | +LL | id_u64(b16); + | ^^^ expected u64, found u16 +help: you can cast an `u16` to `u64`, which will zero-extend the source value + | +LL | id_u64(b16.into()); + | ^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/integer-literal-suffix-inference.rs:168:12 + | +LL | id_u64(b32); + | ^^^ expected u64, found u32 +help: you can cast an `u32` to `u64`, which will zero-extend the source value + | +LL | id_u64(b32.into()); + | ^^^^^^^^^^ + +error: aborting due to 36 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/integral-indexing.rs b/src/test/ui/compile-fail-migration/integral-indexing.rs new file mode 100644 index 00000000000..4b01afb8131 --- /dev/null +++ b/src/test/ui/compile-fail-migration/integral-indexing.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + let v: Vec = vec![0, 1, 2, 3, 4, 5]; + let s: String = "abcdef".to_string(); + v[3_usize]; + v[3]; + v[3u8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + v[3i8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + v[3u32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + v[3i32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + s.as_bytes()[3_usize]; + s.as_bytes()[3]; + s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/integral-indexing.stderr b/src/test/ui/compile-fail-migration/integral-indexing.stderr new file mode 100644 index 00000000000..d86421a7985 --- /dev/null +++ b/src/test/ui/compile-fail-migration/integral-indexing.stderr @@ -0,0 +1,75 @@ +error[E0277]: the trait bound `u8: std::slice::SliceIndex<[isize]>` is not satisfied + --> $DIR/integral-indexing.rs:16:5 + | +LL | v[3u8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + | ^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `u8` + = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` + +error[E0277]: the trait bound `i8: std::slice::SliceIndex<[isize]>` is not satisfied + --> $DIR/integral-indexing.rs:17:5 + | +LL | v[3i8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + | ^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `i8` + = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` + +error[E0277]: the trait bound `u32: std::slice::SliceIndex<[isize]>` is not satisfied + --> $DIR/integral-indexing.rs:18:5 + | +LL | v[3u32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `u32` + = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` + +error[E0277]: the trait bound `i32: std::slice::SliceIndex<[isize]>` is not satisfied + --> $DIR/integral-indexing.rs:19:5 + | +LL | v[3i32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied + | ^^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[isize]>` is not implemented for `i32` + = note: required because of the requirements on the impl of `std::ops::Index` for `std::vec::Vec` + +error[E0277]: the trait bound `u8: std::slice::SliceIndex<[u8]>` is not satisfied + --> $DIR/integral-indexing.rs:22:5 + | +LL | s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + | ^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `u8` + = note: required because of the requirements on the impl of `std::ops::Index` for `[u8]` + +error[E0277]: the trait bound `i8: std::slice::SliceIndex<[u8]>` is not satisfied + --> $DIR/integral-indexing.rs:23:5 + | +LL | s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + | ^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `i8` + = note: required because of the requirements on the impl of `std::ops::Index` for `[u8]` + +error[E0277]: the trait bound `u32: std::slice::SliceIndex<[u8]>` is not satisfied + --> $DIR/integral-indexing.rs:24:5 + | +LL | s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + | ^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `u32` + = note: required because of the requirements on the impl of `std::ops::Index` for `[u8]` + +error[E0277]: the trait bound `i32: std::slice::SliceIndex<[u8]>` is not satisfied + --> $DIR/integral-indexing.rs:25:5 + | +LL | s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied + | ^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize` + | + = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `i32` + = note: required because of the requirements on the impl of `std::ops::Index` for `[u8]` + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/integral-variable-unification-error.rs b/src/test/ui/compile-fail-migration/integral-variable-unification-error.rs new file mode 100644 index 00000000000..f2686ae4d19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/integral-variable-unification-error.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let mut x = 2; + x = 5.0; + //~^ ERROR mismatched types + //~| expected type `{integer}` + //~| found type `{float}` + //~| expected integral variable, found floating-point variable +} diff --git a/src/test/ui/compile-fail-migration/integral-variable-unification-error.stderr b/src/test/ui/compile-fail-migration/integral-variable-unification-error.stderr new file mode 100644 index 00000000000..bbaa6030866 --- /dev/null +++ b/src/test/ui/compile-fail-migration/integral-variable-unification-error.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/integral-variable-unification-error.rs:13:9 + | +LL | x = 5.0; + | ^^^ expected integral variable, found floating-point variable + | + = note: expected type `{integer}` + found type `{float}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/internal-unstable-noallow.rs b/src/test/ui/compile-fail-migration/internal-unstable-noallow.rs new file mode 100644 index 00000000000..2e42e9d3b01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/internal-unstable-noallow.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// this has to be separate to internal-unstable.rs because these tests +// have error messages pointing deep into the internals of the +// cross-crate macros, and hence need to use error-pattern instead of +// the // ~ form. + +// aux-build:internal_unstable.rs +// error-pattern:use of unstable library feature 'function' +// error-pattern:use of unstable library feature 'struct_field' +// error-pattern:use of unstable library feature 'method' +// error-pattern:use of unstable library feature 'struct2_field' + +#[macro_use] +extern crate internal_unstable; + +fn main() { + call_unstable_noallow!(); + + construct_unstable_noallow!(0); + + |x: internal_unstable::Foo| { call_method_noallow!(x) }; + + |x: internal_unstable::Bar| { access_field_noallow!(x) }; +} diff --git a/src/test/ui/compile-fail-migration/internal-unstable-noallow.stderr b/src/test/ui/compile-fail-migration/internal-unstable-noallow.stderr new file mode 100644 index 00000000000..fc8100525e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/internal-unstable-noallow.stderr @@ -0,0 +1,39 @@ +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable-noallow.rs:26:5 + | +LL | call_unstable_noallow!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'struct_field' + --> $DIR/internal-unstable-noallow.rs:28:5 + | +LL | construct_unstable_noallow!(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(struct_field)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'method' + --> $DIR/internal-unstable-noallow.rs:30:35 + | +LL | |x: internal_unstable::Foo| { call_method_noallow!(x) }; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(method)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0658]: use of unstable library feature 'struct2_field' + --> $DIR/internal-unstable-noallow.rs:32:35 + | +LL | |x: internal_unstable::Bar| { access_field_noallow!(x) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(struct2_field)] to the crate attributes to enable + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/internal-unstable-thread-local.rs b/src/test/ui/compile-fail-migration/internal-unstable-thread-local.rs new file mode 100644 index 00000000000..74526fb3d83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/internal-unstable-thread-local.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:internal_unstable.rs + +#![allow(dead_code)] + +extern crate internal_unstable; + + +thread_local!(static FOO: () = ()); +thread_local!(static BAR: () = internal_unstable::unstable()); //~ ERROR use of unstable + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/internal-unstable-thread-local.stderr b/src/test/ui/compile-fail-migration/internal-unstable-thread-local.stderr new file mode 100644 index 00000000000..b77b94663ff --- /dev/null +++ b/src/test/ui/compile-fail-migration/internal-unstable-thread-local.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable-thread-local.rs:19:32 + | +LL | thread_local!(static BAR: () = internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/internal-unstable.rs b/src/test/ui/compile-fail-migration/internal-unstable.rs new file mode 100644 index 00000000000..e01259f0deb --- /dev/null +++ b/src/test/ui/compile-fail-migration/internal-unstable.rs @@ -0,0 +1,52 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:internal_unstable.rs + +#![feature(allow_internal_unstable)] + +#[macro_use] +extern crate internal_unstable; + +macro_rules! foo { + ($e: expr, $f: expr) => {{ + $e; + $f; + internal_unstable::unstable(); //~ ERROR use of unstable + }} +} + +#[allow_internal_unstable] +macro_rules! bar { + ($e: expr) => {{ + foo!($e, + internal_unstable::unstable()); + internal_unstable::unstable(); + }} +} + +fn main() { + // ok, the instability is contained. + call_unstable_allow!(); + construct_unstable_allow!(0); + |x: internal_unstable::Foo| { call_method_allow!(x) }; + |x: internal_unstable::Bar| { access_field_allow!(x) }; + + // bad. + pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable + + pass_through_noallow!(internal_unstable::unstable()); //~ ERROR use of unstable + + + + println!("{:?}", internal_unstable::unstable()); //~ ERROR use of unstable + + bar!(internal_unstable::unstable()); //~ ERROR use of unstable +} diff --git a/src/test/ui/compile-fail-migration/internal-unstable.stderr b/src/test/ui/compile-fail-migration/internal-unstable.stderr new file mode 100644 index 00000000000..ec4f0725c34 --- /dev/null +++ b/src/test/ui/compile-fail-migration/internal-unstable.stderr @@ -0,0 +1,46 @@ +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:43:25 + | +LL | pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:45:27 + | +LL | pass_through_noallow!(internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:49:22 + | +LL | println!("{:?}", internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:51:10 + | +LL | bar!(internal_unstable::unstable()); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(function)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'function' + --> $DIR/internal-unstable.rs:22:9 + | +LL | internal_unstable::unstable(); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | bar!(internal_unstable::unstable()); //~ ERROR use of unstable + | ------------------------------------ in this macro invocation + | + = help: add #![feature(function)] to the crate attributes to enable + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.rs b/src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.rs new file mode 100644 index 00000000000..a224690af76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test number of arguments in platform-specific intrinsic function +// This is the error E0444 + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +struct f64x2(f64, f64); + +extern "platform-intrinsic" { + fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ platform-specific intrinsic +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.stderr b/src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.stderr new file mode 100644 index 00000000000..af852b669c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/intrinsic-invalid-number-of-arguments.stderr @@ -0,0 +1,9 @@ +error[E0444]: platform-specific intrinsic has invalid number of arguments: found 3, expected 1 + --> $DIR/intrinsic-invalid-number-of-arguments.rs:20:5 + | +LL | fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ platform-specific intrinsic + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0444`. diff --git a/src/test/ui/compile-fail-migration/invalid-crate-type.rs b/src/test/ui/compile-fail-migration/invalid-crate-type.rs new file mode 100644 index 00000000000..4b6b6c2fe76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-crate-type.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// regression test for issue 11256 +#![crate_type="foo"] //~ ERROR invalid `crate_type` value + +fn main() { + return +} diff --git a/src/test/ui/compile-fail-migration/invalid-crate-type.stderr b/src/test/ui/compile-fail-migration/invalid-crate-type.stderr new file mode 100644 index 00000000000..6dc8a0f2bbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-crate-type.stderr @@ -0,0 +1,10 @@ +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:12:1 + | +LL | #![crate_type="foo"] //~ ERROR invalid `crate_type` value + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: #[deny(unknown_crate_types)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/invalid-inline.rs b/src/test/ui/compile-fail-migration/invalid-inline.rs new file mode 100644 index 00000000000..93b985b4fb0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-inline.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![allow(dead_code)] + +#[inline(please_no)] //~ ERROR invalid argument +fn a() { +} + +#[inline(please,no)] //~ ERROR expected one argument +fn b() { +} + +#[inline()] //~ ERROR expected one argument +fn c() { +} + +fn main() { + a(); + b(); + c(); +} diff --git a/src/test/ui/compile-fail-migration/invalid-inline.stderr b/src/test/ui/compile-fail-migration/invalid-inline.stderr new file mode 100644 index 00000000000..d4861c23aee --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-inline.stderr @@ -0,0 +1,22 @@ +error[E0535]: invalid argument + --> $DIR/invalid-inline.rs:12:10 + | +LL | #[inline(please_no)] //~ ERROR invalid argument + | ^^^^^^^^^ + +error[E0534]: expected one argument + --> $DIR/invalid-inline.rs:16:1 + | +LL | #[inline(please,no)] //~ ERROR expected one argument + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0534]: expected one argument + --> $DIR/invalid-inline.rs:20:1 + | +LL | #[inline()] //~ ERROR expected one argument + | ^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0534, E0535. +For more information about an error, try `rustc --explain E0534`. diff --git a/src/test/ui/compile-fail-migration/invalid-macro-matcher.rs b/src/test/ui/compile-fail-migration/invalid-macro-matcher.rs new file mode 100644 index 00000000000..d710f5647dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-macro-matcher.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_macros)] + +macro_rules! invalid { + _ => (); //~ ERROR invalid macro matcher +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/invalid-macro-matcher.stderr b/src/test/ui/compile-fail-migration/invalid-macro-matcher.stderr new file mode 100644 index 00000000000..d3ddb613f94 --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-macro-matcher.stderr @@ -0,0 +1,8 @@ +error: invalid macro matcher; matchers must be contained in balanced delimiters + --> $DIR/invalid-macro-matcher.rs:14:5 + | +LL | _ => (); //~ ERROR invalid macro matcher + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/invalid-plugin-attr.rs b/src/test/ui/compile-fail-migration/invalid-plugin-attr.rs new file mode 100644 index 00000000000..3bf09e10ae8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-plugin-attr.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_attributes)] +#![feature(plugin)] + +#[plugin(bla)] //~ ERROR unused attribute + //~^ ERROR should be an inner attribute + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/invalid-plugin-attr.stderr b/src/test/ui/compile-fail-migration/invalid-plugin-attr.stderr new file mode 100644 index 00000000000..a5d321ea9bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid-plugin-attr.stderr @@ -0,0 +1,20 @@ +error: unused attribute + --> $DIR/invalid-plugin-attr.rs:14:1 + | +LL | #[plugin(bla)] //~ ERROR unused attribute + | ^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/invalid-plugin-attr.rs:11:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] + --> $DIR/invalid-plugin-attr.rs:14:1 + | +LL | #[plugin(bla)] //~ ERROR unused attribute + | ^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/invalid_crate_type_syntax.rs b/src/test/ui/compile-fail-migration/invalid_crate_type_syntax.rs new file mode 100644 index 00000000000..6d42515704e --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid_crate_type_syntax.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// regression test for issue 16974 +#![crate_type(lib)] //~ ERROR `crate_type` requires a value + +fn my_lib_fn() {} diff --git a/src/test/ui/compile-fail-migration/invalid_crate_type_syntax.stderr b/src/test/ui/compile-fail-migration/invalid_crate_type_syntax.stderr new file mode 100644 index 00000000000..b609695b86e --- /dev/null +++ b/src/test/ui/compile-fail-migration/invalid_crate_type_syntax.stderr @@ -0,0 +1,15 @@ +error: `crate_type` requires a value + --> $DIR/invalid_crate_type_syntax.rs:12:1 + | +LL | #![crate_type(lib)] //~ ERROR `crate_type` requires a value + | ^^^^^^^^^^^^^^^^^^^ + | + = note: for example: `#![crate_type="lib"]` + +error[E0601]: `main` function not found in crate `invalid_crate_type_syntax` + | + = note: consider adding a `main` function to `$DIR/invalid_crate_type_syntax.rs` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/isssue-38821.rs b/src/test/ui/compile-fail-migration/isssue-38821.rs new file mode 100644 index 00000000000..63de780e109 --- /dev/null +++ b/src/test/ui/compile-fail-migration/isssue-38821.rs @@ -0,0 +1,43 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Nullable(T); + +pub trait NotNull {} + +pub trait IntoNullable { + type Nullable; +} + +impl IntoNullable for T { + type Nullable = Nullable; +} + +impl IntoNullable for Nullable { + type Nullable = Nullable; +} + +pub trait Expression { + type SqlType; +} + +pub trait Column: Expression {} + +#[derive(Debug, Copy, Clone)] +//~^ ERROR the trait bound `::SqlType: NotNull` is not satisfied +pub enum ColumnInsertValue where + Col: Column, + Expr: Expression::Nullable>, +{ + Expression(Col, Expr), + Default(Col), +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/isssue-38821.stderr b/src/test/ui/compile-fail-migration/isssue-38821.stderr new file mode 100644 index 00000000000..a9e12e40d5d --- /dev/null +++ b/src/test/ui/compile-fail-migration/isssue-38821.stderr @@ -0,0 +1,12 @@ +error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied + --> $DIR/isssue-38821.rs:33:17 + | +LL | #[derive(Debug, Copy, Clone)] + | ^^^^ the trait `NotNull` is not implemented for `::SqlType` + | + = help: consider adding a `where ::SqlType: NotNull` bound + = note: required because of the requirements on the impl of `IntoNullable` for `::SqlType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/issue-10755.rs b/src/test/ui/compile-fail-migration/issue-10755.rs new file mode 100644 index 00000000000..57915bce456 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-10755.rs @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -C linker=llllll -Z linker-flavor=ld +// error-pattern: linker `llllll` not found + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/issue-10755.stderr b/src/test/ui/compile-fail-migration/issue-10755.stderr new file mode 100644 index 00000000000..db64944d44f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-10755.stderr @@ -0,0 +1,6 @@ +error: linker `llllll` not found + | + = note: No such file or directory (os error 2) + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/issue-11593.rs b/src/test/ui/compile-fail-migration/issue-11593.rs new file mode 100644 index 00000000000..2749438433d --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-11593.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:private_trait_xc.rs + +extern crate private_trait_xc; + +struct Bar; + +impl private_trait_xc::Foo for Bar {} +//~^ ERROR: trait `Foo` is private + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-11593.stderr b/src/test/ui/compile-fail-migration/issue-11593.stderr new file mode 100644 index 00000000000..24e1a5eb6f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-11593.stderr @@ -0,0 +1,9 @@ +error[E0603]: trait `Foo` is private + --> $DIR/issue-11593.rs:17:6 + | +LL | impl private_trait_xc::Foo for Bar {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/issue-11680.rs b/src/test/ui/compile-fail-migration/issue-11680.rs new file mode 100644 index 00000000000..7dccd781106 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-11680.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_11680.rs + +extern crate issue_11680 as other; + +fn main() { + let _b = other::Foo::Bar(1); + //~^ ERROR: enum `Foo` is private + + let _b = other::test::Foo::Bar(1); + //~^ ERROR: enum `Foo` is private +} diff --git a/src/test/ui/compile-fail-migration/issue-11680.stderr b/src/test/ui/compile-fail-migration/issue-11680.stderr new file mode 100644 index 00000000000..37cfe960600 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-11680.stderr @@ -0,0 +1,15 @@ +error[E0603]: enum `Foo` is private + --> $DIR/issue-11680.rs:16:14 + | +LL | let _b = other::Foo::Bar(1); + | ^^^^^^^^^^^^^^^ + +error[E0603]: enum `Foo` is private + --> $DIR/issue-11680.rs:19:14 + | +LL | let _b = other::test::Foo::Bar(1); + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/issue-15919.rs b/src/test/ui/compile-fail-migration/issue-15919.rs new file mode 100644 index 00000000000..df7e7c102b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-15919.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: too big for the current architecture + +#[cfg(target_pointer_width = "32")] +fn main() { + let x = [0usize; 0xffff_ffff]; +} + +#[cfg(target_pointer_width = "64")] +fn main() { + let x = [0usize; 0xffff_ffff_ffff_ffff]; +} diff --git a/src/test/ui/compile-fail-migration/issue-15919.stderr b/src/test/ui/compile-fail-migration/issue-15919.stderr new file mode 100644 index 00000000000..a69e7b43e25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-15919.stderr @@ -0,0 +1,4 @@ +error: the type `[usize; 18446744073709551615]` is too big for the current architecture + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/issue-16725.rs b/src/test/ui/compile-fail-migration/issue-16725.rs new file mode 100644 index 00000000000..cadf602a4cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-16725.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_16725.rs + +extern crate issue_16725 as foo; + +fn main() { + unsafe { foo::bar(); } + //~^ ERROR: function `bar` is private +} diff --git a/src/test/ui/compile-fail-migration/issue-16725.stderr b/src/test/ui/compile-fail-migration/issue-16725.stderr new file mode 100644 index 00000000000..709f3cf50b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-16725.stderr @@ -0,0 +1,9 @@ +error[E0603]: function `bar` is private + --> $DIR/issue-16725.rs:16:14 + | +LL | unsafe { foo::bar(); } + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/issue-17718-const-privacy.rs b/src/test/ui/compile-fail-migration/issue-17718-const-privacy.rs new file mode 100644 index 00000000000..523a387956a --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-17718-const-privacy.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_17718_const_privacy.rs + +extern crate issue_17718_const_privacy as other; + +use a::B; //~ ERROR: constant `B` is private +use other::{ + FOO, + BAR, //~ ERROR: constant `BAR` is private + FOO2, +}; + +mod a { + const B: usize = 3; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-17718-const-privacy.stderr b/src/test/ui/compile-fail-migration/issue-17718-const-privacy.stderr new file mode 100644 index 00000000000..a453e599c8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-17718-const-privacy.stderr @@ -0,0 +1,15 @@ +error[E0603]: constant `B` is private + --> $DIR/issue-17718-const-privacy.rs:15:5 + | +LL | use a::B; //~ ERROR: constant `B` is private + | ^^^^ + +error[E0603]: constant `BAR` is private + --> $DIR/issue-17718-const-privacy.rs:18:5 + | +LL | BAR, //~ ERROR: constant `BAR` is private + | ^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/issue-17913.rs b/src/test/ui/compile-fail-migration/issue-17913.rs new file mode 100644 index 00000000000..80e5f2b6e21 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-17913.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// error-pattern: too big for the current architecture + +#![feature(box_syntax)] + +#[cfg(target_pointer_width = "64")] +fn main() { + let n = 0_usize; + let a: Box<_> = box [&n; 0xF000000000000000_usize]; + println!("{}", a[0xFFFFFF_usize]); +} + +#[cfg(target_pointer_width = "32")] +fn main() { + let n = 0_usize; + let a: Box<_> = box [&n; 0xFFFFFFFF_usize]; + println!("{}", a[0xFFFFFF_usize]); +} diff --git a/src/test/ui/compile-fail-migration/issue-17913.stderr b/src/test/ui/compile-fail-migration/issue-17913.stderr new file mode 100644 index 00000000000..ca8a28c0fd7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-17913.stderr @@ -0,0 +1,4 @@ +error: the type `[&usize; 17293822569102704640]` is too big for the current architecture + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/issue-19163.nll.stderr b/src/test/ui/compile-fail-migration/issue-19163.nll.stderr new file mode 100644 index 00000000000..32059bf0af1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-19163.nll.stderr @@ -0,0 +1,9 @@ +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/issue-19163.rs:19:14 + | +LL | mywrite!(&v, "Hello world"); + | ^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/issue-19163.rs b/src/test/ui/compile-fail-migration/issue-19163.rs new file mode 100644 index 00000000000..cd6f7c4fd8f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-19163.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-19163.rs + +#[macro_use] extern crate issue_19163; + +use std::io::Write; + +fn main() { + let mut v = vec![]; + mywrite!(&v, "Hello world"); + //~^ error: cannot borrow immutable borrowed content as mutable +} diff --git a/src/test/ui/compile-fail-migration/issue-19163.stderr b/src/test/ui/compile-fail-migration/issue-19163.stderr new file mode 100644 index 00000000000..f7e65e18326 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-19163.stderr @@ -0,0 +1,9 @@ +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/issue-19163.rs:19:14 + | +LL | mywrite!(&v, "Hello world"); + | ^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/issue-1920-1.rs b/src/test/ui/compile-fail-migration/issue-1920-1.rs new file mode 100644 index 00000000000..97dd290a45b --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-1920-1.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Test that absolute path names are correct when a crate is not linked into the root namespace + +// aux-build:issue_1920.rs + +mod foo { + pub extern crate issue_1920; +} + +fn assert_clone() where T : Clone { } + +fn main() { + assert_clone::(); + //~^ ERROR `foo::issue_1920::S: std::clone::Clone` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/issue-1920-1.stderr b/src/test/ui/compile-fail-migration/issue-1920-1.stderr new file mode 100644 index 00000000000..bd823ad6fb6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-1920-1.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `foo::issue_1920::S: std::clone::Clone` is not satisfied + --> $DIR/issue-1920-1.rs:22:5 + | +LL | assert_clone::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `foo::issue_1920::S` + | +note: required by `assert_clone` + --> $DIR/issue-1920-1.rs:19:1 + | +LL | fn assert_clone() where T : Clone { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/issue-1920-2.rs b/src/test/ui/compile-fail-migration/issue-1920-2.rs new file mode 100644 index 00000000000..2af6e2cc991 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-1920-2.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Test that when a crate is linked under another name that name is used in global paths + +// aux-build:issue_1920.rs + +extern crate issue_1920 as bar; + +fn assert_clone() where T : Clone { } + +fn main() { + assert_clone::(); + //~^ ERROR `bar::S: std::clone::Clone` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/issue-1920-2.stderr b/src/test/ui/compile-fail-migration/issue-1920-2.stderr new file mode 100644 index 00000000000..cf98a893a18 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-1920-2.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `bar::S: std::clone::Clone` is not satisfied + --> $DIR/issue-1920-2.rs:20:5 + | +LL | assert_clone::(); + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `bar::S` + | +note: required by `assert_clone` + --> $DIR/issue-1920-2.rs:17:1 + | +LL | fn assert_clone() where T : Clone { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/issue-1920-3.rs b/src/test/ui/compile-fail-migration/issue-1920-3.rs new file mode 100644 index 00000000000..fa6efea845f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-1920-3.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Test that when a crate is linked multiple times that the shortest absolute path name is used + +// aux-build:issue_1920.rs + +mod foo { + pub extern crate issue_1920; +} + +extern crate issue_1920; + +fn assert_clone() where T : Clone { } + +fn main() { + assert_clone::(); + //~^ ERROR `issue_1920::S: std::clone::Clone` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/issue-1920-3.stderr b/src/test/ui/compile-fail-migration/issue-1920-3.stderr new file mode 100644 index 00000000000..6f5efd0dc4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-1920-3.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `issue_1920::S: std::clone::Clone` is not satisfied + --> $DIR/issue-1920-3.rs:24:5 + | +LL | assert_clone::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `issue_1920::S` + | +note: required by `assert_clone` + --> $DIR/issue-1920-3.rs:21:1 + | +LL | fn assert_clone() where T : Clone { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/issue-21146.rs b/src/test/ui/compile-fail-migration/issue-21146.rs new file mode 100644 index 00000000000..457d40e62b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-21146.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: expected one of `!` or `::`, found `` +include!("auxiliary/issue-21146-inc.rs"); +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-21146.stderr b/src/test/ui/compile-fail-migration/issue-21146.stderr new file mode 100644 index 00000000000..fab38123ea8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-21146.stderr @@ -0,0 +1,8 @@ +error: expected one of `!` or `::`, found `` + --> $DIR/auxiliary/issue-21146-inc.rs:13:1 + | +LL | parse_error + | ^^^^^^^^^^^ expected one of `!` or `::` here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/issue-21202.rs b/src/test/ui/compile-fail-migration/issue-21202.rs new file mode 100644 index 00000000000..2bce838c1cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-21202.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_21202.rs + +extern crate issue_21202 as crate1; + +use crate1::A; + +mod B { + use crate1::A::Foo; + fn bar(f: Foo) { + Foo::foo(&f); + //~^ ERROR: method `foo` is private + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/issue-21202.stderr b/src/test/ui/compile-fail-migration/issue-21202.stderr new file mode 100644 index 00000000000..9d17ff64769 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-21202.stderr @@ -0,0 +1,9 @@ +error[E0624]: method `foo` is private + --> $DIR/issue-21202.rs:20:9 + | +LL | Foo::foo(&f); + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/issue-22638.rs b/src/test/ui/compile-fail-migration/issue-22638.rs new file mode 100644 index 00000000000..1c534ebbd43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-22638.rs @@ -0,0 +1,69 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +#![recursion_limit = "20"] +#![type_length_limit = "20000000"] +#![crate_type = "rlib"] + +#[derive(Clone)] +struct A (B); + +impl A { + pub fn matches(&self, f: &F) { + let &A(ref term) = self; + term.matches(f); + } +} + +#[derive(Clone)] +enum B { + Variant1, + Variant2(C), +} + +impl B { + pub fn matches(&self, f: &F) { + match self { + &B::Variant2(ref factor) => { + factor.matches(&|| ()) + } + _ => unreachable!("") + } + } +} + +#[derive(Clone)] +struct C (D); + +impl C { + pub fn matches(&self, f: &F) { + let &C(ref base) = self; + base.matches(&|| { + C(base.clone()).matches(f) + }) + } +} + +#[derive(Clone)] +struct D (Box); + +impl D { + pub fn matches(&self, f: &F) { + //~^ ERROR reached the type-length limit while instantiating `D::matches::<[closure + let &D(ref a) = self; + a.matches(f) + } +} + +pub fn matches() { + A(B::Variant1).matches(&(|| ())) +} diff --git a/src/test/ui/compile-fail-migration/issue-22638.stderr b/src/test/ui/compile-fail-migration/issue-22638.stderr new file mode 100644 index 00000000000..a549c00a341 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-22638.stderr @@ -0,0 +1,14 @@ +error: reached the type-length limit while instantiating `D::matches::<[closure@/home/david/projects/rust/workdirs/rust1/s...` + --> $DIR/issue-22638.rs:60:5 + | +LL | / pub fn matches(&self, f: &F) { +LL | | //~^ ERROR reached the type-length limit while instantiating `D::matches::<[closure +LL | | let &D(ref a) = self; +LL | | a.matches(f) +LL | | } + | |_____^ + | + = note: consider adding a `#![type_length_limit="40000000"]` attribute to your crate + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/issue-23595-1.rs b/src/test/ui/compile-fail-migration/issue-23595-1.rs new file mode 100644 index 00000000000..a3422d859c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-23595-1.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_type_defaults)] + +use std::ops::{Index}; + +trait Hierarchy { + type Value; + type ChildKey; + type Children = Index; + //~^ ERROR: the value of the associated type `ChildKey` + //~^^ ERROR: the value of the associated type `Children` + //~^^^ ERROR: the value of the associated type `Value` + + fn data(&self) -> Option<(Self::Value, Self::Children)>; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-23595-1.stderr b/src/test/ui/compile-fail-migration/issue-23595-1.stderr new file mode 100644 index 00000000000..624534eb8d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-23595-1.stderr @@ -0,0 +1,21 @@ +error[E0191]: the value of the associated type `ChildKey` (from the trait `Hierarchy`) must be specified + --> $DIR/issue-23595-1.rs:18:50 + | +LL | type Children = Index; + | ^^^^^^^^^ missing associated type `ChildKey` value + +error[E0191]: the value of the associated type `Children` (from the trait `Hierarchy`) must be specified + --> $DIR/issue-23595-1.rs:18:50 + | +LL | type Children = Index; + | ^^^^^^^^^ missing associated type `Children` value + +error[E0191]: the value of the associated type `Value` (from the trait `Hierarchy`) must be specified + --> $DIR/issue-23595-1.rs:18:50 + | +LL | type Children = Index; + | ^^^^^^^^^ missing associated type `Value` value + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0191`. diff --git a/src/test/ui/compile-fail-migration/issue-26548.rs b/src/test/ui/compile-fail-migration/issue-26548.rs new file mode 100644 index 00000000000..85ddf8d9493 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-26548.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//~^^^^^^^^^^ ERROR cycle detected when computing layout of +//~| NOTE ...which requires computing layout of +//~| NOTE ...which again requires computing layout of + +trait Mirror { type It: ?Sized; } +impl Mirror for T { type It = Self; } +struct S(Option<::It>); + +fn main() { //~ NOTE cycle used when processing `main` + let _s = S(None); +} diff --git a/src/test/ui/compile-fail-migration/issue-26548.stderr b/src/test/ui/compile-fail-migration/issue-26548.stderr new file mode 100644 index 00000000000..7ebeb76b657 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-26548.stderr @@ -0,0 +1,13 @@ +error[E0391]: cycle detected when computing layout of `std::option::Option` + | +note: ...which requires computing layout of `S`... + = note: ...which again requires computing layout of `std::option::Option`, completing the cycle +note: cycle used when processing `main` + --> $DIR/issue-26548.rs:19:1 + | +LL | fn main() { //~ NOTE cycle used when processing `main` + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/issue-28075.rs b/src/test/ui/compile-fail-migration/issue-28075.rs new file mode 100644 index 00000000000..0f6b9d1b5dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28075.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Unstable entities should be caught in import lists + +// aux-build:lint_stability.rs + +#![allow(warnings)] + +extern crate lint_stability; + +use lint_stability::{unstable, deprecated}; +//~^ ERROR use of unstable library feature 'unstable_test_feature' + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/issue-28075.stderr b/src/test/ui/compile-fail-migration/issue-28075.stderr new file mode 100644 index 00000000000..b42a322cbb4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28075.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/issue-28075.rs:19:22 + | +LL | use lint_stability::{unstable, deprecated}; + | ^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/issue-28388-1.rs b/src/test/ui/compile-fail-migration/issue-28388-1.rs new file mode 100644 index 00000000000..187d91731d0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28388-1.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. + +use foo::{}; //~ ERROR cannot find module or enum `foo` in the crate root + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-28388-1.stderr b/src/test/ui/compile-fail-migration/issue-28388-1.stderr new file mode 100644 index 00000000000..9f4b6cb56e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28388-1.stderr @@ -0,0 +1,9 @@ +error[E0578]: cannot find module or enum `foo` in the crate root + --> $DIR/issue-28388-1.rs:13:5 + | +LL | use foo::{}; //~ ERROR cannot find module or enum `foo` in the crate root + | ^^^ not found in the crate root + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0578`. diff --git a/src/test/ui/compile-fail-migration/issue-28388-2.rs b/src/test/ui/compile-fail-migration/issue-28388-2.rs new file mode 100644 index 00000000000..4ed5bfab06f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28388-2.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. + +mod m { + mod n {} +} + +use m::n::{}; +//~^ ERROR module `n` is private + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-28388-2.stderr b/src/test/ui/compile-fail-migration/issue-28388-2.stderr new file mode 100644 index 00000000000..7809934942c --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28388-2.stderr @@ -0,0 +1,9 @@ +error[E0603]: module `n` is private + --> $DIR/issue-28388-2.rs:17:5 + | +LL | use m::n::{}; + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/issue-28388-3.rs b/src/test/ui/compile-fail-migration/issue-28388-3.rs new file mode 100644 index 00000000000..12e3457ef9e --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28388-3.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. + +// aux-build:lint_stability.rs + +extern crate lint_stability; + +use lint_stability::UnstableEnum::{}; +//~^ ERROR use of unstable library feature 'unstable_test_feature' +use lint_stability::StableEnum::{}; // OK + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-28388-3.stderr b/src/test/ui/compile-fail-migration/issue-28388-3.stderr new file mode 100644 index 00000000000..653fdb5a4d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28388-3.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/issue-28388-3.rs:17:5 + | +LL | use lint_stability::UnstableEnum::{}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/issue-28625.rs b/src/test/ui/compile-fail-migration/issue-28625.rs new file mode 100644 index 00000000000..dc9155ed66c --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28625.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Bar { + type Bar; +} + +struct ArrayPeano { + data: T::Bar, +} + +fn foo(a: &ArrayPeano) -> &[T] where T: Bar { + unsafe { std::mem::transmute(a) } //~ ERROR transmute called with types of different sizes +} + +impl Bar for () { + type Bar = (); +} + +fn main() { + let x: ArrayPeano<()> = ArrayPeano { data: () }; + foo(&x); +} diff --git a/src/test/ui/compile-fail-migration/issue-28625.stderr b/src/test/ui/compile-fail-migration/issue-28625.stderr new file mode 100644 index 00000000000..90b50f193fb --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28625.stderr @@ -0,0 +1,12 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/issue-28625.rs:20:14 + | +LL | unsafe { std::mem::transmute(a) } //~ ERROR transmute called with types of different sizes + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: &ArrayPeano (64 bits) + = note: target type: &[T] (128 bits) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/compile-fail-migration/issue-28848.rs b/src/test/ui/compile-fail-migration/issue-28848.rs new file mode 100644 index 00000000000..1a06d59f0b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28848.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<'a, 'b: 'a>(&'a &'b ()); + +impl<'a, 'b> Foo<'a, 'b> { + fn xmute(a: &'b ()) -> &'a () { + unreachable!() + } +} + +pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { + Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-28848.stderr b/src/test/ui/compile-fail-migration/issue-28848.stderr new file mode 100644 index 00000000000..738a1c0c6f6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-28848.stderr @@ -0,0 +1,20 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/issue-28848.rs:20:5 + | +LL | Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied + | ^^^^^^^^^^^^^^^^^^^^ + | +note: lifetime parameter instantiated with the lifetime 'b as defined on the function body at 19:16 + --> $DIR/issue-28848.rs:19:16 + | +LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { + | ^^ +note: but lifetime parameter must outlive the lifetime 'a as defined on the function body at 19:12 + --> $DIR/issue-28848.rs:19:12 + | +LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/compile-fail-migration/issue-29181.rs b/src/test/ui/compile-fail-migration/issue-29181.rs new file mode 100644 index 00000000000..2fcec51912e --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-29181.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-29181.rs + +extern crate issue_29181 as foo; + +fn main() { + 0.homura(); //~ ERROR no method named `homura` found +} diff --git a/src/test/ui/compile-fail-migration/issue-29181.stderr b/src/test/ui/compile-fail-migration/issue-29181.stderr new file mode 100644 index 00000000000..5dda7848926 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-29181.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `homura` found for type `{integer}` in the current scope + --> $DIR/issue-29181.rs:16:7 + | +LL | 0.homura(); //~ ERROR no method named `homura` found + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/issue-30123.rs b/src/test/ui/compile-fail-migration/issue-30123.rs new file mode 100644 index 00000000000..653097ad69f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-30123.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_30123_aux.rs + +extern crate issue_30123_aux; +use issue_30123_aux::*; + +fn main() { + let ug = Graph::::new_undirected(); + //~^ ERROR no function or associated item named `new_undirected` found for type +} diff --git a/src/test/ui/compile-fail-migration/issue-30123.stderr b/src/test/ui/compile-fail-migration/issue-30123.stderr new file mode 100644 index 00000000000..094c962de29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-30123.stderr @@ -0,0 +1,9 @@ +error[E0599]: no function or associated item named `new_undirected` found for type `issue_30123_aux::Graph` in the current scope + --> $DIR/issue-30123.rs:17:14 + | +LL | let ug = Graph::::new_undirected(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `issue_30123_aux::Graph` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/issue-30535.rs b/src/test/ui/compile-fail-migration/issue-30535.rs new file mode 100644 index 00000000000..90f5220a623 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-30535.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-30535.rs + +extern crate issue_30535 as foo; + +fn bar( + _: foo::Foo::FooV //~ ERROR expected type, found variant `foo::Foo::FooV` +) {} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-30535.stderr b/src/test/ui/compile-fail-migration/issue-30535.stderr new file mode 100644 index 00000000000..c3838fdb9cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-30535.stderr @@ -0,0 +1,11 @@ +error[E0573]: expected type, found variant `foo::Foo::FooV` + --> $DIR/issue-30535.rs:16:8 + | +LL | _: foo::Foo::FooV //~ ERROR expected type, found variant `foo::Foo::FooV` + | ^^^^^^^^^^^^^^ not a type + | + = help: there is an enum variant `foo::Foo::FooV`, try using `foo::Foo`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/compile-fail-migration/issue-32377.rs b/src/test/ui/compile-fail-migration/issue-32377.rs new file mode 100644 index 00000000000..5091ba4ee1a --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-32377.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; +use std::marker::PhantomData; + +trait Foo { + type Error; +} + +struct Bar { + stream: PhantomData, +} + +fn foo(x: [usize; 2]) -> Bar { + unsafe { mem::transmute(x) } + //~^ ERROR transmute called with types of different sizes +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-32377.stderr b/src/test/ui/compile-fail-migration/issue-32377.stderr new file mode 100644 index 00000000000..a0698885caa --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-32377.stderr @@ -0,0 +1,12 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/issue-32377.rs:23:14 + | +LL | unsafe { mem::transmute(x) } + | ^^^^^^^^^^^^^^ + | + = note: source type: [usize; 2] (128 bits) + = note: target type: Bar (0 bits) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/compile-fail-migration/issue-36881.rs b/src/test/ui/compile-fail-migration/issue-36881.rs new file mode 100644 index 00000000000..0f5aa24926b --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-36881.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-36881-aux.rs + +fn main() { + #[allow(unused_extern_crates)] + extern crate issue_36881_aux; + use issue_36881_aux::Foo; //~ ERROR unresolved import +} diff --git a/src/test/ui/compile-fail-migration/issue-36881.stderr b/src/test/ui/compile-fail-migration/issue-36881.stderr new file mode 100644 index 00000000000..39132fde762 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-36881.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `issue_36881_aux` + --> $DIR/issue-36881.rs:16:9 + | +LL | use issue_36881_aux::Foo; //~ ERROR unresolved import + | ^^^^^^^^^^^^^^^ Maybe a missing `extern crate issue_36881_aux;`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/issue-37131.rs b/src/test/ui/compile-fail-migration/issue-37131.rs new file mode 100644 index 00000000000..efb0b249a8a --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-37131.rs @@ -0,0 +1,18 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that compiling for a target which is not installed will result in a helpful +// error message. + +// compile-flags: --target=thumbv6m-none-eabi +// ignore-arm + +// error-pattern:target may not be installed +fn main() { } diff --git a/src/test/ui/compile-fail-migration/issue-37131.stderr b/src/test/ui/compile-fail-migration/issue-37131.stderr new file mode 100644 index 00000000000..660a6935f36 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-37131.stderr @@ -0,0 +1,7 @@ +error[E0463]: can't find crate for `std` + | + = note: the `thumbv6m-none-eabi` target may not be installed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/issue-41549.rs b/src/test/ui/compile-fail-migration/issue-41549.rs new file mode 100644 index 00000000000..67be194c8ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-41549.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_41549.rs + + +extern crate issue_41549; + +struct S; + +impl issue_41549::Trait for S { + const CONST: () = (); //~ ERROR incompatible type for trait +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-41549.stderr b/src/test/ui/compile-fail-migration/issue-41549.stderr new file mode 100644 index 00000000000..e5362727d94 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-41549.stderr @@ -0,0 +1,12 @@ +error[E0326]: implemented const `CONST` has an incompatible type for trait + --> $DIR/issue-41549.rs:19:18 + | +LL | const CONST: () = (); //~ ERROR incompatible type for trait + | ^^ expected u32, found () + | + = note: expected type `u32` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0326`. diff --git a/src/test/ui/compile-fail-migration/issue-43733-2.rs b/src/test/ui/compile-fail-migration/issue-43733-2.rs new file mode 100644 index 00000000000..a5ba9ef9bd3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-43733-2.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_fn)] +#![feature(cfg_target_thread_local, thread_local_internals)] + +// On platforms *without* `#[thread_local]`, use +// a custom non-`Sync` type to fake the same error. +#[cfg(not(target_thread_local))] +struct Key { + _data: std::cell::UnsafeCell>, + _flag: std::cell::Cell, +} + +#[cfg(not(target_thread_local))] +impl Key { + const fn new() -> Self { + Key { + _data: std::cell::UnsafeCell::new(None), + _flag: std::cell::Cell::new(false), + } + } +} + +#[cfg(target_thread_local)] +use std::thread::__FastLocalKeyInner as Key; + +static __KEY: Key<()> = Key::new(); +//~^ ERROR `std::cell::UnsafeCell>` cannot be shared between threads +//~| ERROR `std::cell::Cell` cannot be shared between threads safely [E0277] + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-43733-2.stderr b/src/test/ui/compile-fail-migration/issue-43733-2.stderr new file mode 100644 index 00000000000..8eb150ff833 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-43733-2.stderr @@ -0,0 +1,23 @@ +error[E0277]: `std::cell::UnsafeCell>` cannot be shared between threads safely + --> $DIR/issue-43733-2.rs:35:1 + | +LL | static __KEY: Key<()> = Key::new(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell>` cannot be shared between threads safely + | + = help: within `std::thread::Key<()>`, the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell>` + = note: required because it appears within the type `std::thread::Key<()>` + = note: shared static variables must have a type that implements `Sync` + +error[E0277]: `std::cell::Cell` cannot be shared between threads safely + --> $DIR/issue-43733-2.rs:35:1 + | +LL | static __KEY: Key<()> = Key::new(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely + | + = help: within `std::thread::Key<()>`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell` + = note: required because it appears within the type `std::thread::Key<()>` + = note: shared static variables must have a type that implements `Sync` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.rs b/src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.rs new file mode 100644 index 00000000000..f5a20dd96dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.rs @@ -0,0 +1,51 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(crate_visibility_modifier)] + +mod rank { + pub use self::Professor::*; + //~^ ERROR enum is private and its variants cannot be re-exported + pub use self::Lieutenant::{JuniorGrade, Full}; + //~^ ERROR variant `JuniorGrade` is private and cannot be re-exported + //~| ERROR variant `Full` is private and cannot be re-exported + pub use self::PettyOfficer::*; + //~^ ERROR enum is private and its variants cannot be re-exported + pub use self::Crewman::*; + //~^ ERROR enum is private and its variants cannot be re-exported + + enum Professor { + Adjunct, + Assistant, + Associate, + Full + } + + enum Lieutenant { + JuniorGrade, + Full, + } + + pub(in rank) enum PettyOfficer { + SecondClass, + FirstClass, + Chief, + MasterChief + } + + crate enum Crewman { + Recruit, + Apprentice, + Full + } + +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.stderr b/src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.stderr new file mode 100644 index 00000000000..9e5abdeaa43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-46209-private-enum-variant-reexport.stderr @@ -0,0 +1,44 @@ +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:19:13 + | +LL | pub use self::PettyOfficer::*; + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | pub(in rank) enum PettyOfficer { + | ------------------------------ help: consider making the enum public: `pub enum PettyOfficer` + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:21:13 + | +LL | pub use self::Crewman::*; + | ^^^^^^^^^^^^^^^^ +... +LL | crate enum Crewman { + | ------------------ help: consider making the enum public: `pub enum Crewman` + +error: enum is private and its variants cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:14:13 + | +LL | pub use self::Professor::*; + | ^^^^^^^^^^^^^^^^^^ +... +LL | enum Professor { + | -------------- help: consider making the enum public: `pub enum Professor` + +error: variant `JuniorGrade` is private and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:16:32 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^^^^^^^^ +... +LL | enum Lieutenant { + | --------------- help: consider making the enum public: `pub enum Lieutenant` + +error: variant `Full` is private and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:16:45 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.rs b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.rs new file mode 100644 index 00000000000..4c67fb3bef1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(inner_deref)] + +fn main() { + let _result = &Some(42).deref(); +//~^ ERROR no method named `deref` found for type `std::option::Option<{integer}>` +} diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.stderr b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.stderr new file mode 100644 index 00000000000..a56cd6e8d2f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/option_deref.stderr @@ -0,0 +1,12 @@ +error[E0599]: no method named `deref` found for type `std::option::Option<{integer}>` in the current scope + --> $DIR/option_deref.rs:14:29 + | +LL | let _result = &Some(42).deref(); + | ^^^^^ + | + = note: the method `deref` exists but the following trait bounds were not satisfied: + `{integer} : std::ops::Deref` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.rs b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.rs new file mode 100644 index 00000000000..73bdf0b9209 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(inner_deref)] + +fn main() { + let _result = &Ok(42).deref(); +//~^ ERROR no method named `deref` found +} diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.stderr b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.stderr new file mode 100644 index 00000000000..d3d7c1993ca --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref.stderr @@ -0,0 +1,12 @@ +error[E0599]: no method named `deref` found for type `std::result::Result<{integer}, _>` in the current scope + --> $DIR/result_deref.rs:14:27 + | +LL | let _result = &Ok(42).deref(); + | ^^^^^ + | + = note: the method `deref` exists but the following trait bounds were not satisfied: + `{integer} : std::ops::Deref` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.rs b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.rs new file mode 100644 index 00000000000..5d1e7472d8f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(inner_deref)] + +fn main() { + let _result = &Err(41).deref_err(); +//~^ ERROR no method named `deref_err` found +} diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.stderr b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.stderr new file mode 100644 index 00000000000..bf75687b21f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_err.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `deref_err` found for type `std::result::Result<_, {integer}>` in the current scope + --> $DIR/result_deref_err.rs:14:28 + | +LL | let _result = &Err(41).deref_err(); + | ^^^^^^^^^ + | + = note: the method `deref_err` exists but the following trait bounds were not satisfied: + `{integer} : std::ops::Deref` + = help: did you mean `deref_ok`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.rs b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.rs new file mode 100644 index 00000000000..bee8e0c062b --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(inner_deref)] + +fn main() { + let _result = &Ok(42).deref_ok(); +//~^ ERROR no method named `deref_ok` found +} diff --git a/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.stderr b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.stderr new file mode 100644 index 00000000000..a77333a7568 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-50264-inner-deref-trait/result_deref_ok.stderr @@ -0,0 +1,12 @@ +error[E0599]: no method named `deref_ok` found for type `std::result::Result<{integer}, _>` in the current scope + --> $DIR/result_deref_ok.rs:14:27 + | +LL | let _result = &Ok(42).deref_ok(); + | ^^^^^^^^ + | + = note: the method `deref_ok` exists but the following trait bounds were not satisfied: + `{integer} : std::ops::Deref` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/issue-52489.rs b/src/test/ui/compile-fail-migration/issue-52489.rs new file mode 100644 index 00000000000..c43cc12ca02 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-52489.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 +// aux-build:issue-52489.rs + +use issue_52489; +//~^ ERROR use of unstable library feature 'issue_52489_unstable' + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue-52489.stderr b/src/test/ui/compile-fail-migration/issue-52489.stderr new file mode 100644 index 00000000000..5b38a0789ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-52489.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'issue_52489_unstable' + --> $DIR/issue-52489.rs:14:5 + | +LL | use issue_52489; + | ^^^^^^^^^^^ + | + = help: add #![feature(issue_52489_unstable)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/issue-5500-1.ast.stderr b/src/test/ui/compile-fail-migration/issue-5500-1.ast.stderr new file mode 100644 index 00000000000..611eea533b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-5500-1.ast.stderr @@ -0,0 +1,15 @@ +error[E0594]: cannot assign to field `_iter.node` of immutable binding + --> $DIR/issue-5500-1.rs:22:5 + | +LL | let _iter = TrieMapIterator{node: &a}; + | ----- consider changing this to `mut _iter` +LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding +LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) +LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK +LL | | // because the test is here to check that the compiler doesn't ICE (cf. #5500). +LL | | panic!() + | |____________^ cannot mutably borrow field of immutable binding + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/issue-5500-1.mir.stderr b/src/test/ui/compile-fail-migration/issue-5500-1.mir.stderr new file mode 100644 index 00000000000..465485e5e29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-5500-1.mir.stderr @@ -0,0 +1,15 @@ +error[E0594]: cannot assign to field `_iter.node` of immutable binding (Ast) + --> $DIR/issue-5500-1.rs:22:5 + | +LL | let _iter = TrieMapIterator{node: &a}; + | ----- consider changing this to `mut _iter` +LL | / _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding +LL | | //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) +LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK +LL | | // because the test is here to check that the compiler doesn't ICE (cf. #5500). +LL | | panic!() + | |____________^ cannot mutably borrow field of immutable binding + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/issue-5500-1.rs b/src/test/ui/compile-fail-migration/issue-5500-1.rs new file mode 100644 index 00000000000..8d6efa774a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-5500-1.rs @@ -0,0 +1,27 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-compare-mode-nll +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=compare + +struct TrieMapIterator<'a> { + node: &'a usize +} + +fn main() { + let a = 5; + let _iter = TrieMapIterator{node: &a}; + _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding + //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) + // MIR doesn't generate an error because the code isn't reachable. This is OK + // because the test is here to check that the compiler doesn't ICE (cf. #5500). + panic!() +} diff --git a/src/test/ui/compile-fail-migration/issue-5844.rs b/src/test/ui/compile-fail-migration/issue-5844.rs new file mode 100644 index 00000000000..02e5b9b0921 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-5844.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//aux-build:issue_5844_aux.rs + +extern crate issue_5844_aux; + +fn main () { + issue_5844_aux::rand(); //~ ERROR: requires unsafe +} diff --git a/src/test/ui/compile-fail-migration/issue-5844.stderr b/src/test/ui/compile-fail-migration/issue-5844.stderr new file mode 100644 index 00000000000..05b0b63439f --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue-5844.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/issue-5844.rs:16:5 + | +LL | issue_5844_aux::rand(); //~ ERROR: requires unsafe + | ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/issue32829.rs b/src/test/ui/compile-fail-migration/issue32829.rs new file mode 100644 index 00000000000..2b223bac8e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue32829.rs @@ -0,0 +1,94 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +#![feature(const_fn)] + +const bad : u32 = { + { + 5; + //~^ ERROR statements in constants are unstable + 0 + } +}; + +const bad_two : u32 = { + { + invalid(); + //~^ ERROR statements in constants are unstable + //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants + 0 + } +}; + +const bad_three : u32 = { + { + valid(); + //~^ ERROR statements in constants are unstable + 0 + } +}; + +static bad_four : u32 = { + { + 5; + //~^ ERROR statements in statics are unstable + 0 + } +}; + +static bad_five : u32 = { + { + invalid(); + //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants + //~| ERROR statements in statics are unstable + 0 + } +}; + +static bad_six : u32 = { + { + valid(); + //~^ ERROR statements in statics are unstable + 0 + } +}; + +static mut bad_seven : u32 = { + { + 5; + //~^ ERROR statements in statics are unstable + 0 + } +}; + +static mut bad_eight : u32 = { + { + invalid(); + //~^ ERROR statements in statics are unstable + //~| ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants + 0 + } +}; + +static mut bad_nine : u32 = { + { + valid(); + //~^ ERROR statements in statics are unstable + 0 + } +}; + + +fn invalid() {} +const fn valid() {} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/issue32829.stderr b/src/test/ui/compile-fail-migration/issue32829.stderr new file mode 100644 index 00000000000..dad0880dbdf --- /dev/null +++ b/src/test/ui/compile-fail-migration/issue32829.stderr @@ -0,0 +1,94 @@ +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/issue32829.rs:17:9 + | +LL | 5; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue32829.rs:25:9 + | +LL | invalid(); + | ^^^^^^^^^ + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/issue32829.rs:25:9 + | +LL | invalid(); + | ^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in constants are unstable (see issue #48821) + --> $DIR/issue32829.rs:34:9 + | +LL | valid(); + | ^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/issue32829.rs:42:9 + | +LL | 5; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue32829.rs:50:9 + | +LL | invalid(); + | ^^^^^^^^^ + +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/issue32829.rs:50:9 + | +LL | invalid(); + | ^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/issue32829.rs:59:9 + | +LL | valid(); + | ^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/issue32829.rs:67:9 + | +LL | 5; + | ^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants + --> $DIR/issue32829.rs:75:9 + | +LL | invalid(); + | ^^^^^^^^^ + +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/issue32829.rs:75:9 + | +LL | invalid(); + | ^^^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/issue32829.rs:84:9 + | +LL | valid(); + | ^^^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error: aborting due to 12 previous errors + +Some errors occurred: E0015, E0658. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/compile-fail-migration/keyword-extern-as-identifier.rs b/src/test/ui/compile-fail-migration/keyword-extern-as-identifier.rs new file mode 100644 index 00000000000..3e445853957 --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-extern-as-identifier.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_in_paths)] + +fn main() { + let extern = 0; //~ ERROR cannot find unit struct/variant or constant `extern` in this scope +} diff --git a/src/test/ui/compile-fail-migration/keyword-extern-as-identifier.stderr b/src/test/ui/compile-fail-migration/keyword-extern-as-identifier.stderr new file mode 100644 index 00000000000..0aa5fc08d6f --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-extern-as-identifier.stderr @@ -0,0 +1,9 @@ +error[E0532]: expected unit struct/variant or constant, found module `extern` + --> $DIR/keyword-extern-as-identifier.rs:14:9 + | +LL | let extern = 0; //~ ERROR expected unit struct/variant or constant, found module `extern` + | ^^^^^^ not a unit struct/variant or constant + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0532`. diff --git a/src/test/ui/compile-fail-migration/keyword-false-as-identifier.rs b/src/test/ui/compile-fail-migration/keyword-false-as-identifier.rs new file mode 100644 index 00000000000..f246d6e75df --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-false-as-identifier.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let false = 22; //~ error: mismatched types +} diff --git a/src/test/ui/compile-fail-migration/keyword-false-as-identifier.stderr b/src/test/ui/compile-fail-migration/keyword-false-as-identifier.stderr new file mode 100644 index 00000000000..13f675404f6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-false-as-identifier.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/keyword-false-as-identifier.rs:12:9 + | +LL | let false = 22; //~ error: mismatched types + | ^^^^^ expected integral variable, found bool + | + = note: expected type `{integer}` + found type `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/keyword-self-as-identifier.rs b/src/test/ui/compile-fail-migration/keyword-self-as-identifier.rs new file mode 100644 index 00000000000..b50fc68bed6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-self-as-identifier.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let Self = 22; //~ ERROR cannot find unit struct/variant or constant `Self` in this scope +} diff --git a/src/test/ui/compile-fail-migration/keyword-self-as-identifier.stderr b/src/test/ui/compile-fail-migration/keyword-self-as-identifier.stderr new file mode 100644 index 00000000000..c47f4aeabef --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-self-as-identifier.stderr @@ -0,0 +1,9 @@ +error[E0531]: cannot find unit struct/variant or constant `Self` in this scope + --> $DIR/keyword-self-as-identifier.rs:12:9 + | +LL | let Self = 22; //~ ERROR cannot find unit struct/variant or constant `Self` in this scope + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0531`. diff --git a/src/test/ui/compile-fail-migration/keyword-super-as-identifier.rs b/src/test/ui/compile-fail-migration/keyword-super-as-identifier.rs new file mode 100644 index 00000000000..54dac771f01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-super-as-identifier.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let super = 22; //~ ERROR failed to resolve. There are too many initial `super`s +} diff --git a/src/test/ui/compile-fail-migration/keyword-super-as-identifier.stderr b/src/test/ui/compile-fail-migration/keyword-super-as-identifier.stderr new file mode 100644 index 00000000000..649be45c224 --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-super-as-identifier.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. There are too many initial `super`s. + --> $DIR/keyword-super-as-identifier.rs:12:9 + | +LL | let super = 22; //~ ERROR failed to resolve. There are too many initial `super`s + | ^^^^^ There are too many initial `super`s. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/keyword-super.rs b/src/test/ui/compile-fail-migration/keyword-super.rs new file mode 100644 index 00000000000..02047bd639f --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-super.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let super: isize; //~ ERROR failed to resolve. There are too many initial `super`s +} diff --git a/src/test/ui/compile-fail-migration/keyword-super.stderr b/src/test/ui/compile-fail-migration/keyword-super.stderr new file mode 100644 index 00000000000..ac692ad45d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-super.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. There are too many initial `super`s. + --> $DIR/keyword-super.rs:12:9 + | +LL | let super: isize; //~ ERROR failed to resolve. There are too many initial `super`s + | ^^^^^ There are too many initial `super`s. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/keyword-true-as-identifier.rs b/src/test/ui/compile-fail-migration/keyword-true-as-identifier.rs new file mode 100644 index 00000000000..b09d09db560 --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-true-as-identifier.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let true = 22; //~ error: mismatched types +} diff --git a/src/test/ui/compile-fail-migration/keyword-true-as-identifier.stderr b/src/test/ui/compile-fail-migration/keyword-true-as-identifier.stderr new file mode 100644 index 00000000000..776470ba77c --- /dev/null +++ b/src/test/ui/compile-fail-migration/keyword-true-as-identifier.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/keyword-true-as-identifier.rs:12:9 + | +LL | let true = 22; //~ error: mismatched types + | ^^^^ expected integral variable, found bool + | + = note: expected type `{integer}` + found type `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/kindck-copy.rs b/src/test/ui/compile-fail-migration/kindck-copy.rs new file mode 100644 index 00000000000..747fe2d2046 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-copy.rs @@ -0,0 +1,81 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which of the builtin types are considered POD. + +use std::rc::Rc; + +fn assert_copy() { } + +trait Dummy { } + +#[derive(Copy, Clone)] +struct MyStruct { + x: isize, + y: isize, +} + +struct MyNoncopyStruct { + x: Box, +} + +fn test<'a,T,U:Copy>(_: &'a isize) { + // lifetime pointers are ok... + assert_copy::<&'static isize>(); + assert_copy::<&'a isize>(); + assert_copy::<&'a str>(); + assert_copy::<&'a [isize]>(); + + // ...unless they are mutable + assert_copy::<&'static mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::<&'a mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied + + // boxes are not ok + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy:: >(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + + // borrowed object types are generally ok + assert_copy::<&'a Dummy>(); + assert_copy::<&'a (Dummy+Send)>(); + assert_copy::<&'static (Dummy+Send)>(); + + // owned object types are not ok + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + + // mutable object types are not ok + assert_copy::<&'a mut (Dummy+Send)>(); //~ ERROR : std::marker::Copy` is not satisfied + + // unsafe ptrs are ok + assert_copy::<*const isize>(); + assert_copy::<*const &'a mut isize>(); + + // regular old ints and such are ok + assert_copy::(); + assert_copy::(); + assert_copy::<()>(); + + // tuples are ok + assert_copy::<(isize,isize)>(); + + // structs of POD are ok + assert_copy::(); + + // structs containing non-POD are not ok + assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied + + // ref counted types are not ok + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/kindck-copy.stderr b/src/test/ui/compile-fail-migration/kindck-copy.stderr new file mode 100644 index 00000000000..8d72d912689 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-copy.stderr @@ -0,0 +1,139 @@ +error[E0277]: the trait bound `&'static mut isize: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:37:5 + | +LL | assert_copy::<&'static mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'static mut isize` + | + = help: the following implementations were found: + +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `&'a mut isize: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:38:5 + | +LL | assert_copy::<&'a mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut isize` + | + = help: the following implementations were found: + +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:41:5 + | +LL | assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:42:5 + | +LL | assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::vec::Vec: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:43:5 + | +LL | assert_copy:: >(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::vec::Vec` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::boxed::Box<&'a mut isize>: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:44:5 + | +LL | assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<&'a mut isize>` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:52:5 + | +LL | assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::boxed::Box: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:53:5 + | +LL | assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `&'a mut (dyn Dummy + std::marker::Send + 'a): std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:56:5 + | +LL | assert_copy::<&'a mut (Dummy+Send)>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `MyNoncopyStruct: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:74:5 + | +LL | assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `MyNoncopyStruct` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied + --> $DIR/kindck-copy.rs:77:5 + | +LL | assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::rc::Rc` + | +note: required by `assert_copy` + --> $DIR/kindck-copy.rs:15:1 + | +LL | fn assert_copy() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 11 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-impl-type-params-2.rs b/src/test/ui/compile-fail-migration/kindck-impl-type-params-2.rs new file mode 100644 index 00000000000..21aefc4f9c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-impl-type-params-2.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +trait Foo { +} + +impl Foo for T { +} + +fn take_param(foo: &T) { } + +fn main() { + let x: Box<_> = box 3; + take_param(&x); + //~^ ERROR `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/kindck-impl-type-params-2.stderr b/src/test/ui/compile-fail-migration/kindck-impl-type-params-2.stderr new file mode 100644 index 00000000000..e4c02085ddb --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-impl-type-params-2.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params-2.rs:23:5 + | +LL | take_param(&x); + | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` + | + = note: required because of the requirements on the impl of `Foo` for `std::boxed::Box<{integer}>` +note: required by `take_param` + --> $DIR/kindck-impl-type-params-2.rs:19:1 + | +LL | fn take_param(foo: &T) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-impl-type-params.nll.stderr b/src/test/ui/compile-fail-migration/kindck-impl-type-params.nll.stderr new file mode 100644 index 00000000000..8f24baf7fc4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-impl-type-params.nll.stderr @@ -0,0 +1,69 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/kindck-impl-type-params.rs:28:13 + | +LL | let a = &t as &Gettable; + | ^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:28:13 + | +LL | let a = &t as &Gettable; + | ^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/kindck-impl-type-params.rs:35:27 + | +LL | let a: &Gettable = &t; + | ^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:35:27 + | +LL | let a: &Gettable = &t; + | ^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +warning: not reporting region error due to nll + --> $DIR/kindck-impl-type-params.rs:42:13 + | +LL | let a = &t as &Gettable<&'a isize>; + | ^^ + +error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:48:13 + | +LL | let a = t as Box>; + | ^ the trait `std::marker::Copy` is not implemented for `std::string::String` + | + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: the trait bound `foo3::Foo: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:56:33 + | +LL | let a: Box> = t; + | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` + | + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-impl-type-params.rs b/src/test/ui/compile-fail-migration/kindck-impl-type-params.rs new file mode 100644 index 00000000000..3a0e66f58e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-impl-type-params.rs @@ -0,0 +1,60 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #14061: tests the interaction between generic implementation +// parameter bounds and trait objects. + +#![feature(box_syntax)] + +use std::marker; + +struct S(marker::PhantomData); + +trait Gettable { + fn get(&self) -> T { panic!() } +} + +impl Gettable for S {} + +fn f(val: T) { + let t: S = S(marker::PhantomData); + let a = &t as &Gettable; + //~^ ERROR `T` cannot be sent between threads safely + //~| ERROR : std::marker::Copy` is not satisfied +} + +fn g(val: T) { + let t: S = S(marker::PhantomData); + let a: &Gettable = &t; + //~^ ERROR `T` cannot be sent between threads safely + //~| ERROR : std::marker::Copy` is not satisfied +} + +fn foo<'a>() { + let t: S<&'a isize> = S(marker::PhantomData); + let a = &t as &Gettable<&'a isize>; + //~^ ERROR does not fulfill +} + +fn foo2<'a>() { + let t: Box> = box S(marker::PhantomData); + let a = t as Box>; + //~^ ERROR : std::marker::Copy` is not satisfied +} + +fn foo3<'a>() { + struct Foo; // does not impl Copy + + let t: Box> = box S(marker::PhantomData); + let a: Box> = t; + //~^ ERROR : std::marker::Copy` is not satisfied +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/kindck-impl-type-params.stderr b/src/test/ui/compile-fail-migration/kindck-impl-type-params.stderr new file mode 100644 index 00000000000..b938d40c765 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-impl-type-params.stderr @@ -0,0 +1,72 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/kindck-impl-type-params.rs:28:13 + | +LL | let a = &t as &Gettable; + | ^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:28:13 + | +LL | let a = &t as &Gettable; + | ^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/kindck-impl-type-params.rs:35:27 + | +LL | let a: &Gettable = &t; + | ^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:35:27 + | +LL | let a: &Gettable = &t; + | ^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0477]: the type `&'a isize` does not fulfill the required lifetime + --> $DIR/kindck-impl-type-params.rs:42:13 + | +LL | let a = &t as &Gettable<&'a isize>; + | ^^ + | + = note: type must satisfy the static lifetime + +error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:48:13 + | +LL | let a = t as Box>; + | ^ the trait `std::marker::Copy` is not implemented for `std::string::String` + | + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error[E0277]: the trait bound `foo3::Foo: std::marker::Copy` is not satisfied + --> $DIR/kindck-impl-type-params.rs:56:33 + | +LL | let a: Box> = t; + | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` + | + = note: required because of the requirements on the impl of `Gettable` for `S` + = note: required for the cast to the object type `dyn Gettable` + +error: aborting due to 7 previous errors + +Some errors occurred: E0277, E0477. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.rs b/src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.rs new file mode 100644 index 00000000000..0731fbaf01c --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that Copy bounds inherited by trait are checked. + +#![feature(box_syntax)] + +use std::any::Any; + +trait Foo : Copy { + fn foo(&self) {} +} + +impl Foo for T { +} + +fn take_param(foo: &T) { } + +fn a() { + let x: Box<_> = box 3; + take_param(&x); //~ ERROR E0277 +} + +fn b() { + let x: Box<_> = box 3; + let y = &x; + let z = &x as &Foo; + //~^ ERROR E0038 + //~| ERROR E0038 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.stderr b/src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.stderr new file mode 100644 index 00000000000..542ecc0c004 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-inherited-copy-bound.stderr @@ -0,0 +1,34 @@ +error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied + --> $DIR/kindck-inherited-copy-bound.rs:28:5 + | +LL | take_param(&x); //~ ERROR E0277 + | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` + | + = note: required because of the requirements on the impl of `Foo` for `std::boxed::Box<{integer}>` +note: required by `take_param` + --> $DIR/kindck-inherited-copy-bound.rs:24:1 + | +LL | fn take_param(foo: &T) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/kindck-inherited-copy-bound.rs:34:19 + | +LL | let z = &x as &Foo; + | ^^^^ the trait `Foo` cannot be made into an object + | + = note: the trait cannot require that `Self : Sized` + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/kindck-inherited-copy-bound.rs:34:13 + | +LL | let z = &x as &Foo; + | ^^ the trait `Foo` cannot be made into an object + | + = note: the trait cannot require that `Self : Sized` + = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Foo>` for `&std::boxed::Box<{integer}>` + +error: aborting due to 3 previous errors + +Some errors occurred: E0038, E0277. +For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/kindck-nonsendable-1.rs b/src/test/ui/compile-fail-migration/kindck-nonsendable-1.rs new file mode 100644 index 00000000000..43c212b2af5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-nonsendable-1.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +use std::rc::Rc; + +fn foo(_x: Rc) {} + +fn bar(_: F) { } + +fn main() { + let x = Rc::new(3); + bar(move|| foo(x)); + //~^ ERROR `std::rc::Rc` cannot be sent between threads safely +} diff --git a/src/test/ui/compile-fail-migration/kindck-nonsendable-1.stderr b/src/test/ui/compile-fail-migration/kindck-nonsendable-1.stderr new file mode 100644 index 00000000000..a8aa02e1d62 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-nonsendable-1.stderr @@ -0,0 +1,17 @@ +error[E0277]: `std::rc::Rc` cannot be sent between threads safely + --> $DIR/kindck-nonsendable-1.rs:20:5 + | +LL | bar(move|| foo(x)); + | ^^^ `std::rc::Rc` cannot be sent between threads safely + | + = help: within `[closure@$DIR/kindck-nonsendable-1.rs:20:9: 20:22 x:std::rc::Rc]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc` + = note: required because it appears within the type `[closure@$DIR/kindck-nonsendable-1.rs:20:9: 20:22 x:std::rc::Rc]` +note: required by `bar` + --> $DIR/kindck-nonsendable-1.rs:16:1 + | +LL | fn bar(_: F) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-send-object.rs b/src/test/ui/compile-fail-migration/kindck-send-object.rs new file mode 100644 index 00000000000..82b97878549 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-object.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which of the builtin types are considered sendable. The tests +// in this file all test the "kind" violates detected during kindck. +// See all `regions-bounded-by-send.rs` + +fn assert_send() { } +trait Dummy { } +trait Message : Send { } + +// careful with object types, who knows what they close over... + +fn object_ref_with_static_bound_not_ok() { + assert_send::<&'static (Dummy+'static)>(); + //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] +} + +fn box_object_with_no_bound_not_ok<'a>() { + assert_send::>(); + //~^ ERROR `dyn Dummy` cannot be sent between threads safely +} + +fn object_with_send_bound_ok() { + assert_send::<&'static (Dummy+Sync)>(); + assert_send::>(); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/kindck-send-object.stderr b/src/test/ui/compile-fail-migration/kindck-send-object.stderr new file mode 100644 index 00000000000..e342352d590 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-object.stderr @@ -0,0 +1,32 @@ +error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely + --> $DIR/kindck-send-object.rs:22:5 + | +LL | assert_send::<&'static (Dummy+'static)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'static)` + = note: required because of the requirements on the impl of `std::marker::Send` for `&'static (dyn Dummy + 'static)` +note: required by `assert_send` + --> $DIR/kindck-send-object.rs:15:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `dyn Dummy` cannot be sent between threads safely + --> $DIR/kindck-send-object.rs:27:5 + | +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `dyn Dummy` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique` + = note: required because it appears within the type `std::boxed::Box` +note: required by `assert_send` + --> $DIR/kindck-send-object.rs:15:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-send-object1.nll.stderr b/src/test/ui/compile-fail-migration/kindck-send-object1.nll.stderr new file mode 100644 index 00000000000..6613a29cd76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-object1.nll.stderr @@ -0,0 +1,38 @@ +error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely + --> $DIR/kindck-send-object1.rs:20:5 + | +LL | assert_send::<&'a Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'a)` + = note: required because of the requirements on the impl of `std::marker::Send` for `&'a (dyn Dummy + 'a)` +note: required by `assert_send` + --> $DIR/kindck-send-object1.rs:15:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/kindck-send-object1.rs:24:5 + | +LL | assert_send::<&'a (Dummy+Sync)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely + --> $DIR/kindck-send-object1.rs:39:5 + | +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `(dyn Dummy + 'a)` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn Dummy + 'a)>` + = note: required because it appears within the type `std::boxed::Box<(dyn Dummy + 'a)>` +note: required by `assert_send` + --> $DIR/kindck-send-object1.rs:15:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-send-object1.rs b/src/test/ui/compile-fail-migration/kindck-send-object1.rs new file mode 100644 index 00000000000..853630aa416 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-object1.rs @@ -0,0 +1,43 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which object types are considered sendable. This test +// is broken into two parts because some errors occur in distinct +// phases in the compiler. See kindck-send-object2.rs as well! + +fn assert_send() { } +trait Dummy { } + +// careful with object types, who knows what they close over... +fn test51<'a>() { + assert_send::<&'a Dummy>(); + //~^ ERROR `(dyn Dummy + 'a)` cannot be shared between threads safely [E0277] +} +fn test52<'a>() { + assert_send::<&'a (Dummy+Sync)>(); + //~^ ERROR does not fulfill the required lifetime +} + +// ...unless they are properly bounded +fn test60() { + assert_send::<&'static (Dummy+Sync)>(); +} +fn test61() { + assert_send::>(); +} + +// closure and object types can have lifetime bounds which make +// them not ok +fn test_71<'a>() { + assert_send::>(); + //~^ ERROR `(dyn Dummy + 'a)` cannot be sent between threads safely +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/kindck-send-object1.stderr b/src/test/ui/compile-fail-migration/kindck-send-object1.stderr new file mode 100644 index 00000000000..d906b7d9e16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-object1.stderr @@ -0,0 +1,41 @@ +error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely + --> $DIR/kindck-send-object1.rs:20:5 + | +LL | assert_send::<&'a Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'a)` + = note: required because of the requirements on the impl of `std::marker::Send` for `&'a (dyn Dummy + 'a)` +note: required by `assert_send` + --> $DIR/kindck-send-object1.rs:15:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0477]: the type `&'a (dyn Dummy + std::marker::Sync + 'a)` does not fulfill the required lifetime + --> $DIR/kindck-send-object1.rs:24:5 + | +LL | assert_send::<&'a (Dummy+Sync)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely + --> $DIR/kindck-send-object1.rs:39:5 + | +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `(dyn Dummy + 'a)` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn Dummy + 'a)>` + = note: required because it appears within the type `std::boxed::Box<(dyn Dummy + 'a)>` +note: required by `assert_send` + --> $DIR/kindck-send-object1.rs:15:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0277, E0477. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-send-object2.rs b/src/test/ui/compile-fail-migration/kindck-send-object2.rs new file mode 100644 index 00000000000..0265f888e7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-object2.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Continue kindck-send-object1.rs. + +fn assert_send() { } +trait Dummy { } + +fn test50() { + assert_send::<&'static Dummy>(); + //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] +} + +fn test53() { + assert_send::>(); + //~^ ERROR `dyn Dummy` cannot be sent between threads safely +} + +// ...unless they are properly bounded +fn test60() { + assert_send::<&'static (Dummy+Sync)>(); +} +fn test61() { + assert_send::>(); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/kindck-send-object2.stderr b/src/test/ui/compile-fail-migration/kindck-send-object2.stderr new file mode 100644 index 00000000000..475159cd400 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-object2.stderr @@ -0,0 +1,32 @@ +error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely + --> $DIR/kindck-send-object2.rs:17:5 + | +LL | assert_send::<&'static Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'static)` + = note: required because of the requirements on the impl of `std::marker::Send` for `&'static (dyn Dummy + 'static)` +note: required by `assert_send` + --> $DIR/kindck-send-object2.rs:13:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `dyn Dummy` cannot be sent between threads safely + --> $DIR/kindck-send-object2.rs:22:5 + | +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `dyn Dummy` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique` + = note: required because it appears within the type `std::boxed::Box` +note: required by `assert_send` + --> $DIR/kindck-send-object2.rs:13:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-send-owned.rs b/src/test/ui/compile-fail-migration/kindck-send-owned.rs new file mode 100644 index 00000000000..e48460a8753 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-owned.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which of the builtin types are considered sendable. + +fn assert_send() { } + +// owned content are ok +fn test30() { assert_send::>(); } +fn test31() { assert_send::(); } +fn test32() { assert_send:: >(); } + +// but not if they own a bad thing +fn test40() { + assert_send::>(); + //~^ ERROR `*mut u8` cannot be sent between threads safely +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/kindck-send-owned.stderr b/src/test/ui/compile-fail-migration/kindck-send-owned.stderr new file mode 100644 index 00000000000..f5781bd968e --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-owned.stderr @@ -0,0 +1,18 @@ +error[E0277]: `*mut u8` cannot be sent between threads safely + --> $DIR/kindck-send-owned.rs:22:5 + | +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut u8` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `*mut u8` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<*mut u8>` + = note: required because it appears within the type `std::boxed::Box<*mut u8>` +note: required by `assert_send` + --> $DIR/kindck-send-owned.rs:13:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/kindck-send-unsafe.rs b/src/test/ui/compile-fail-migration/kindck-send-unsafe.rs new file mode 100644 index 00000000000..99b995b0906 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-unsafe.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate core; + +fn assert_send() { } + +fn test71<'a>() { + assert_send::<*mut &'a isize>(); + //~^ ERROR `*mut &'a isize` cannot be sent between threads safely +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/kindck-send-unsafe.rs~rust-lang_master b/src/test/ui/compile-fail-migration/kindck-send-unsafe.rs~rust-lang_master new file mode 100644 index 00000000000..a9bbfcfa262 --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-unsafe.rs~rust-lang_master @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn assert_send() { } + +// unsafe ptrs are ok unless they point at unsendable things +fn test70() { + assert_send::<*mut int>(); +} +fn test71<'a>() { + assert_send::<*mut &'a int>(); //~ ERROR does not fulfill the required lifetime +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/kindck-send-unsafe.stderr b/src/test/ui/compile-fail-migration/kindck-send-unsafe.stderr new file mode 100644 index 00000000000..846de09ba3c --- /dev/null +++ b/src/test/ui/compile-fail-migration/kindck-send-unsafe.stderr @@ -0,0 +1,16 @@ +error[E0277]: `*mut &'a isize` cannot be sent between threads safely + --> $DIR/kindck-send-unsafe.rs:16:5 + | +LL | assert_send::<*mut &'a isize>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `*mut &'a isize` +note: required by `assert_send` + --> $DIR/kindck-send-unsafe.rs:13:1 + | +LL | fn assert_send() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/label-static.rs b/src/test/ui/compile-fail-migration/label-static.rs new file mode 100644 index 00000000000..a0fb25ea06e --- /dev/null +++ b/src/test/ui/compile-fail-migration/label-static.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + 'static: loop { //~ ERROR invalid label name `'static` + break 'static //~ ERROR invalid label name `'static` + } +} diff --git a/src/test/ui/compile-fail-migration/label-static.stderr b/src/test/ui/compile-fail-migration/label-static.stderr new file mode 100644 index 00000000000..f5b6eba0089 --- /dev/null +++ b/src/test/ui/compile-fail-migration/label-static.stderr @@ -0,0 +1,14 @@ +error: invalid label name `'static` + --> $DIR/label-static.rs:12:5 + | +LL | 'static: loop { //~ ERROR invalid label name `'static` + | ^^^^^^^ + +error: invalid label name `'static` + --> $DIR/label-static.rs:13:15 + | +LL | break 'static //~ ERROR invalid label name `'static` + | ^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/label-underscore.rs b/src/test/ui/compile-fail-migration/label-underscore.rs new file mode 100644 index 00000000000..30411bf8789 --- /dev/null +++ b/src/test/ui/compile-fail-migration/label-underscore.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + '_: loop { //~ ERROR invalid label name `'_` + break '_ //~ ERROR invalid label name `'_` + } +} diff --git a/src/test/ui/compile-fail-migration/label-underscore.stderr b/src/test/ui/compile-fail-migration/label-underscore.stderr new file mode 100644 index 00000000000..9a567094c82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/label-underscore.stderr @@ -0,0 +1,14 @@ +error: invalid label name `'_` + --> $DIR/label-underscore.rs:12:5 + | +LL | '_: loop { //~ ERROR invalid label name `'_` + | ^^ + +error: invalid label name `'_` + --> $DIR/label-underscore.rs:13:15 + | +LL | break '_ //~ ERROR invalid label name `'_` + | ^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lang-item-missing.rs b/src/test/ui/compile-fail-migration/lang-item-missing.rs new file mode 100644 index 00000000000..ce2fa2548c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lang-item-missing.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a missing lang item (in this case `sized`) does not cause an ICE, +// see #17392. + +// error-pattern: requires `sized` lang_item + +#![feature(start, no_core)] +#![no_core] + +#[start] +fn start(argc: isize, argv: *const *const u8) -> isize { + 0 +} diff --git a/src/test/ui/compile-fail-migration/lang-item-missing.stderr b/src/test/ui/compile-fail-migration/lang-item-missing.stderr new file mode 100644 index 00000000000..f7516c7d377 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lang-item-missing.stderr @@ -0,0 +1,4 @@ +error: requires `sized` lang_item + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lexical-scopes.rs b/src/test/ui/compile-fail-migration/lexical-scopes.rs new file mode 100644 index 00000000000..39da0d47a95 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lexical-scopes.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct T { i: i32 } +fn f() { + let t = T { i: 0 }; //~ ERROR expected struct, variant or union type, found type parameter `T` +} + +mod Foo { + pub fn f() {} +} +fn g() { + Foo::f(); //~ ERROR no function or associated item named `f` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lexical-scopes.stderr b/src/test/ui/compile-fail-migration/lexical-scopes.stderr new file mode 100644 index 00000000000..3a6ae52c68d --- /dev/null +++ b/src/test/ui/compile-fail-migration/lexical-scopes.stderr @@ -0,0 +1,20 @@ +error[E0574]: expected struct, variant or union type, found type parameter `T` + --> $DIR/lexical-scopes.rs:13:13 + | +LL | let t = T { i: 0 }; //~ ERROR expected struct, variant or union type, found type parameter `T` + | ^ not a struct, variant or union type +help: possible better candidate is found in another module, you can import it into scope + | +LL | use T; + | + +error[E0599]: no function or associated item named `f` found for type `Foo` in the current scope + --> $DIR/lexical-scopes.rs:20:5 + | +LL | Foo::f(); //~ ERROR no function or associated item named `f` + | ^^^^^^ function or associated item not found in `Foo` + +error: aborting due to 2 previous errors + +Some errors occurred: E0574, E0599. +For more information about an error, try `rustc --explain E0574`. diff --git a/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.nll.stderr b/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.nll.stderr new file mode 100644 index 00000000000..ab9bb195631 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.nll.stderr @@ -0,0 +1,32 @@ +warning: not reporting region error due to nll + --> $DIR/lifetime-bound-will-change-warning.rs:44:13 + | +LL | ref_obj(x) //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/lifetime-bound-will-change-warning.rs:49:18 + | +LL | lib::ref_obj(x) //~ ERROR mismatched types + | ^ + +error: borrowed data escapes outside of function + --> $DIR/lifetime-bound-will-change-warning.rs:44:5 + | +LL | fn test2<'a>(x: &'a Box) { + | - `x` is a reference that is only valid in the function body +LL | // but ref_obj will not, so warn. +LL | ref_obj(x) //~ ERROR mismatched types + | ^^^^^^^^^^ `x` escapes the function body here + +error: borrowed data escapes outside of function + --> $DIR/lifetime-bound-will-change-warning.rs:49:5 + | +LL | fn test2cc<'a>(x: &'a Box) { + | - `x` is a reference that is only valid in the function body +LL | // same as test2, but cross crate +LL | lib::ref_obj(x) //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^ `x` escapes the function body here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.rs b/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.rs new file mode 100644 index 00000000000..7e9a4f82478 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.rs @@ -0,0 +1,64 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lifetime_bound_will_change_warning_lib.rs + +// Test that various corner cases cause an error. These are tests +// that used to pass before we tweaked object defaults. + +#![allow(dead_code)] +#![allow(unused_variables)] +#![feature(rustc_attrs)] + +extern crate lifetime_bound_will_change_warning_lib as lib; + +fn just_ref(x: &Fn()) { +} + +fn ref_obj(x: &Box) { + // this will change to &Box... + + // Note: no warning is issued here, because the type of `x` will change to 'static + if false { ref_obj(x); } +} + +fn test1<'a>(x: &'a Box) { + // just_ref will stay the same. + just_ref(&**x) +} + +fn test1cc<'a>(x: &'a Box) { + // same as test1, but cross-crate + lib::just_ref(&**x) +} + +fn test2<'a>(x: &'a Box) { + // but ref_obj will not, so warn. + ref_obj(x) //~ ERROR mismatched types +} + +fn test2cc<'a>(x: &'a Box) { + // same as test2, but cross crate + lib::ref_obj(x) //~ ERROR mismatched types +} + +fn test3<'a>(x: &'a Box) { + // here, we have a 'static bound, so even when ref_obj changes, no error results + ref_obj(x) +} + +fn test3cc<'a>(x: &'a Box) { + // same as test3, but cross crate + lib::ref_obj(x) +} + +#[rustc_error] +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.stderr b/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.stderr new file mode 100644 index 00000000000..01f215c97f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lifetime-bound-will-change-warning.stderr @@ -0,0 +1,33 @@ +error[E0308]: mismatched types + --> $DIR/lifetime-bound-will-change-warning.rs:44:13 + | +LL | ref_obj(x) //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `&std::boxed::Box<(dyn std::ops::Fn() + 'static)>` + found type `&std::boxed::Box<(dyn std::ops::Fn() + 'a)>` +note: the lifetime 'a as defined on the function body at 42:10... + --> $DIR/lifetime-bound-will-change-warning.rs:42:10 + | +LL | fn test2<'a>(x: &'a Box) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/lifetime-bound-will-change-warning.rs:49:18 + | +LL | lib::ref_obj(x) //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `&std::boxed::Box<(dyn std::ops::Fn() + 'static)>` + found type `&std::boxed::Box<(dyn std::ops::Fn() + 'a)>` +note: the lifetime 'a as defined on the function body at 47:12... + --> $DIR/lifetime-bound-will-change-warning.rs:47:12 + | +LL | fn test2cc<'a>(x: &'a Box) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/lifetime-no-keyword.rs b/src/test/ui/compile-fail-migration/lifetime-no-keyword.rs new file mode 100644 index 00000000000..d583c4fc6c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lifetime-no-keyword.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo<'a>(a: &'a isize) { } +fn bar(a: &'static isize) { } +fn baz<'let>(a: &'let isize) { } //~ ERROR lifetimes cannot use keyword names +//~^ ERROR lifetimes cannot use keyword names +fn zab<'self>(a: &'self isize) { } //~ ERROR lifetimes cannot use keyword names +//~^ ERROR lifetimes cannot use keyword names +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lifetime-no-keyword.stderr b/src/test/ui/compile-fail-migration/lifetime-no-keyword.stderr new file mode 100644 index 00000000000..1dcbe336c69 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lifetime-no-keyword.stderr @@ -0,0 +1,26 @@ +error: lifetimes cannot use keyword names + --> $DIR/lifetime-no-keyword.rs:13:8 + | +LL | fn baz<'let>(a: &'let isize) { } //~ ERROR lifetimes cannot use keyword names + | ^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/lifetime-no-keyword.rs:13:18 + | +LL | fn baz<'let>(a: &'let isize) { } //~ ERROR lifetimes cannot use keyword names + | ^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/lifetime-no-keyword.rs:15:8 + | +LL | fn zab<'self>(a: &'self isize) { } //~ ERROR lifetimes cannot use keyword names + | ^^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/lifetime-no-keyword.rs:15:19 + | +LL | fn zab<'self>(a: &'self isize) { } //~ ERROR lifetimes cannot use keyword names + | ^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/linkage2.rs b/src/test/ui/compile-fail-migration/linkage2.rs new file mode 100644 index 00000000000..afae4a451d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/linkage2.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(linkage)] + +extern { + #[linkage = "extern_weak"] static foo: i32; + //~^ ERROR: must have type `*const T` or `*mut T` +} + +fn main() { + println!("{}", unsafe { foo }); +} diff --git a/src/test/ui/compile-fail-migration/linkage2.stderr b/src/test/ui/compile-fail-migration/linkage2.stderr new file mode 100644 index 00000000000..d9edac160da --- /dev/null +++ b/src/test/ui/compile-fail-migration/linkage2.stderr @@ -0,0 +1,8 @@ +error: must have type `*const T` or `*mut T` + --> $DIR/linkage2.rs:14:32 + | +LL | #[linkage = "extern_weak"] static foo: i32; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/linkage3.rs b/src/test/ui/compile-fail-migration/linkage3.rs new file mode 100644 index 00000000000..c222989ed66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/linkage3.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(linkage)] + +extern { + #[linkage = "foo"] static foo: *const i32; + //~^ ERROR: invalid linkage specified +} + +fn main() { + println!("{:?}", unsafe { foo }); +} diff --git a/src/test/ui/compile-fail-migration/linkage3.stderr b/src/test/ui/compile-fail-migration/linkage3.stderr new file mode 100644 index 00000000000..3429ced8ce4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/linkage3.stderr @@ -0,0 +1,8 @@ +error: invalid linkage specified + --> $DIR/linkage3.rs:14:24 + | +LL | #[linkage = "foo"] static foo: *const i32; + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/linkage4.rs b/src/test/ui/compile-fail-migration/linkage4.rs new file mode 100644 index 00000000000..1cf6e90d6c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/linkage4.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[linkage = "external"] +static foo: isize = 0; +//~^^ ERROR: the `linkage` attribute is experimental and not portable + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/linkage4.stderr b/src/test/ui/compile-fail-migration/linkage4.stderr new file mode 100644 index 00000000000..c04f88d37a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/linkage4.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `linkage` attribute is experimental and not portable across platforms (see issue #29603) + --> $DIR/linkage4.rs:11:1 + | +LL | #[linkage = "external"] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(linkage)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/lint-attr-non-item-node.rs b/src/test/ui/compile-fail-migration/lint-attr-non-item-node.rs new file mode 100644 index 00000000000..930f69e51e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-attr-non-item-node.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks that lint attributes work on non-item AST nodes + +fn main() { + #[deny(unreachable_code)] + loop { + break; + "unreachable"; //~ ERROR unreachable statement + } +} diff --git a/src/test/ui/compile-fail-migration/lint-attr-non-item-node.stderr b/src/test/ui/compile-fail-migration/lint-attr-non-item-node.stderr new file mode 100644 index 00000000000..33d096c5bcf --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-attr-non-item-node.stderr @@ -0,0 +1,14 @@ +error: unreachable statement + --> $DIR/lint-attr-non-item-node.rs:17:9 + | +LL | "unreachable"; //~ ERROR unreachable statement + | ^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-attr-non-item-node.rs:14:12 + | +LL | #[deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-change-warnings.rs b/src/test/ui/compile-fail-migration/lint-change-warnings.rs new file mode 100644 index 00000000000..19e253e3b8e --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-change-warnings.rs @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(warnings)] +#![allow(dead_code)] + +fn main() { + while true {} //~ ERROR: infinite +} + +#[allow(warnings)] +fn foo() { + while true {} +} + +#[warn(warnings)] +fn bar() { + while true {} //~ WARNING: infinite +} + +#[forbid(warnings)] +fn baz() { + while true {} //~ ERROR: infinite +} diff --git a/src/test/ui/compile-fail-migration/lint-change-warnings.stderr b/src/test/ui/compile-fail-migration/lint-change-warnings.stderr new file mode 100644 index 00000000000..353802f5c28 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-change-warnings.stderr @@ -0,0 +1,36 @@ +error: denote infinite loops with `loop { ... }` + --> $DIR/lint-change-warnings.rs:15:5 + | +LL | while true {} //~ ERROR: infinite + | ^^^^^^^^^^ help: use `loop` + | +note: lint level defined here + --> $DIR/lint-change-warnings.rs:11:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: #[deny(while_true)] implied by #[deny(warnings)] + +warning: denote infinite loops with `loop { ... }` + --> $DIR/lint-change-warnings.rs:25:5 + | +LL | while true {} //~ WARNING: infinite + | ^^^^^^^^^^ help: use `loop` + | + = note: #[warn(while_true)] on by default + +error: denote infinite loops with `loop { ... }` + --> $DIR/lint-change-warnings.rs:30:5 + | +LL | while true {} //~ ERROR: infinite + | ^^^^^^^^^^ help: use `loop` + | +note: lint level defined here + --> $DIR/lint-change-warnings.rs:28:10 + | +LL | #[forbid(warnings)] + | ^^^^^^^^ + = note: #[forbid(while_true)] implied by #[forbid(warnings)] + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-ctypes-enum.rs b/src/test/ui/compile-fail-migration/lint-ctypes-enum.rs new file mode 100644 index 00000000000..7b7ffd8fc10 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-ctypes-enum.rs @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(improper_ctypes)] +#![allow(dead_code)] + +enum Z { } +enum U { A } +enum B { C, D } +enum T { E, F, G } + +#[repr(C)] +enum ReprC { A, B, C } + +#[repr(u8)] +enum U8 { A, B, C } + +#[repr(isize)] +enum Isize { A, B, C } + +extern { + fn zf(x: Z); + fn uf(x: U); //~ ERROR enum has no representation hint + fn bf(x: B); //~ ERROR enum has no representation hint + fn tf(x: T); //~ ERROR enum has no representation hint + fn reprc(x: ReprC); + fn u8(x: U8); + fn isize(x: Isize); +} + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-ctypes-enum.stderr b/src/test/ui/compile-fail-migration/lint-ctypes-enum.stderr new file mode 100644 index 00000000000..9b1c04b2a1d --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-ctypes-enum.stderr @@ -0,0 +1,46 @@ +error: `extern` block uses type `U` which is not FFI-safe: enum has no representation hint + --> $DIR/lint-ctypes-enum.rs:30:13 + | +LL | fn uf(x: U); //~ ERROR enum has no representation hint + | ^ + | +note: lint level defined here + --> $DIR/lint-ctypes-enum.rs:11:9 + | +LL | #![deny(improper_ctypes)] + | ^^^^^^^^^^^^^^^ + = help: consider adding a #[repr(...)] attribute to this enum +note: type defined here + --> $DIR/lint-ctypes-enum.rs:15:1 + | +LL | enum U { A } + | ^^^^^^^^^^^^ + +error: `extern` block uses type `B` which is not FFI-safe: enum has no representation hint + --> $DIR/lint-ctypes-enum.rs:31:13 + | +LL | fn bf(x: B); //~ ERROR enum has no representation hint + | ^ + | + = help: consider adding a #[repr(...)] attribute to this enum +note: type defined here + --> $DIR/lint-ctypes-enum.rs:16:1 + | +LL | enum B { C, D } + | ^^^^^^^^^^^^^^^ + +error: `extern` block uses type `T` which is not FFI-safe: enum has no representation hint + --> $DIR/lint-ctypes-enum.rs:32:13 + | +LL | fn tf(x: T); //~ ERROR enum has no representation hint + | ^ + | + = help: consider adding a #[repr(...)] attribute to this enum +note: type defined here + --> $DIR/lint-ctypes-enum.rs:17:1 + | +LL | enum T { E, F, G } + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-1.rs b/src/test/ui/compile-fail-migration/lint-dead-code-1.rs new file mode 100644 index 00000000000..2fe72365bab --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-1.rs @@ -0,0 +1,116 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] +#![allow(unused_variables)] +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] +#![deny(dead_code)] + +#![crate_type="lib"] + +pub use foo2::Bar2; + +mod foo { + pub struct Bar; //~ ERROR: struct is never constructed +} + +mod foo2 { + pub struct Bar2; +} + +pub static pub_static: isize = 0; +static priv_static: isize = 0; //~ ERROR: static item is never used +const used_static: isize = 0; +pub static used_static2: isize = used_static; +const USED_STATIC: isize = 0; +const STATIC_USED_IN_ENUM_DISCRIMINANT: isize = 10; + +pub const pub_const: isize = 0; +const priv_const: isize = 0; //~ ERROR: constant item is never used +const used_const: isize = 0; +pub const used_const2: isize = used_const; +const USED_CONST: isize = 1; +const CONST_USED_IN_ENUM_DISCRIMINANT: isize = 11; + +pub type typ = *const UsedStruct4; +pub struct PubStruct; +struct PrivStruct; //~ ERROR: struct is never constructed +struct UsedStruct1 { + #[allow(dead_code)] + x: isize +} +struct UsedStruct2(isize); +struct UsedStruct3; +pub struct UsedStruct4; +// this struct is never used directly, but its method is, so we don't want +// to warn it +struct SemiUsedStruct; +impl SemiUsedStruct { + fn la_la_la() {} +} +struct StructUsedAsField; +pub struct StructUsedInEnum; +struct StructUsedInGeneric; +pub struct PubStruct2 { + #[allow(dead_code)] + struct_used_as_field: *const StructUsedAsField +} + +pub enum pub_enum { foo1, bar1 } +pub enum pub_enum2 { a(*const StructUsedInEnum) } +pub enum pub_enum3 { + Foo = STATIC_USED_IN_ENUM_DISCRIMINANT, + Bar = CONST_USED_IN_ENUM_DISCRIMINANT, +} + +enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used +enum used_enum { + foo3, + bar3 //~ ERROR variant is never constructed +} + +fn f() {} + +pub fn pub_fn() { + used_fn(); + let used_struct1 = UsedStruct1 { x: 1 }; + let used_struct2 = UsedStruct2(1); + let used_struct3 = UsedStruct3; + let e = used_enum::foo3; + SemiUsedStruct::la_la_la(); + + let i = 1; + match i { + USED_STATIC => (), + USED_CONST => (), + _ => () + } + f::(); +} +fn priv_fn() { //~ ERROR: function is never used + let unused_struct = PrivStruct; +} +fn used_fn() {} + +fn foo() { //~ ERROR: function is never used + bar(); + let unused_enum = priv_enum::foo2; +} + +fn bar() { //~ ERROR: function is never used + foo(); +} + +// Code with #[allow(dead_code)] should be marked live (and thus anything it +// calls is marked live) +#[allow(dead_code)] +fn g() { h(); } +fn h() {} diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-1.stderr b/src/test/ui/compile-fail-migration/lint-dead-code-1.stderr new file mode 100644 index 00000000000..9802b7e8f38 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-1.stderr @@ -0,0 +1,62 @@ +error: struct is never constructed: `Bar` + --> $DIR/lint-dead-code-1.rs:22:5 + | +LL | pub struct Bar; //~ ERROR: struct is never constructed + | ^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-dead-code-1.rs:15:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: static item is never used: `priv_static` + --> $DIR/lint-dead-code-1.rs:30:1 + | +LL | static priv_static: isize = 0; //~ ERROR: static item is never used + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: constant item is never used: `priv_const` + --> $DIR/lint-dead-code-1.rs:37:1 + | +LL | const priv_const: isize = 0; //~ ERROR: constant item is never used + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: struct is never constructed: `PrivStruct` + --> $DIR/lint-dead-code-1.rs:45:1 + | +LL | struct PrivStruct; //~ ERROR: struct is never constructed + | ^^^^^^^^^^^^^^^^^^ + +error: enum is never used: `priv_enum` + --> $DIR/lint-dead-code-1.rs:74:1 + | +LL | enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used + | ^^^^^^^^^^^^^^ + +error: variant is never constructed: `bar3` + --> $DIR/lint-dead-code-1.rs:77:5 + | +LL | bar3 //~ ERROR variant is never constructed + | ^^^^ + +error: function is never used: `priv_fn` + --> $DIR/lint-dead-code-1.rs:98:1 + | +LL | fn priv_fn() { //~ ERROR: function is never used + | ^^^^^^^^^^^^ + +error: function is never used: `foo` + --> $DIR/lint-dead-code-1.rs:103:1 + | +LL | fn foo() { //~ ERROR: function is never used + | ^^^^^^^^ + +error: function is never used: `bar` + --> $DIR/lint-dead-code-1.rs:108:1 + | +LL | fn bar() { //~ ERROR: function is never used + | ^^^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-2.rs b/src/test/ui/compile-fail-migration/lint-dead-code-2.rs new file mode 100644 index 00000000000..4a0e4f4319e --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-2.rs @@ -0,0 +1,51 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] +#![deny(dead_code)] +#![feature(main, start)] + +struct Foo; + +trait Bar { + fn bar1(&self); + fn bar2(&self) { + self.bar1(); + } +} + +impl Bar for Foo { + fn bar1(&self) { + live_fn(); + } +} + +fn live_fn() {} + +fn dead_fn() {} //~ ERROR: function is never used + +#[main] +fn dead_fn2() {} //~ ERROR: function is never used + +fn used_fn() {} + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + used_fn(); + let foo = Foo; + foo.bar2(); + 0 +} + +// this is not main +fn main() { //~ ERROR: function is never used + dead_fn(); + dead_fn2(); +} diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-2.stderr b/src/test/ui/compile-fail-migration/lint-dead-code-2.stderr new file mode 100644 index 00000000000..6e713c84f16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-2.stderr @@ -0,0 +1,26 @@ +error: function is never used: `dead_fn` + --> $DIR/lint-dead-code-2.rs:32:1 + | +LL | fn dead_fn() {} //~ ERROR: function is never used + | ^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-dead-code-2.rs:12:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: function is never used: `dead_fn2` + --> $DIR/lint-dead-code-2.rs:35:1 + | +LL | fn dead_fn2() {} //~ ERROR: function is never used + | ^^^^^^^^^^^^^ + +error: function is never used: `main` + --> $DIR/lint-dead-code-2.rs:48:1 + | +LL | fn main() { //~ ERROR: function is never used + | ^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-3.rs b/src/test/ui/compile-fail-migration/lint-dead-code-3.rs new file mode 100644 index 00000000000..112d3630952 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-3.rs @@ -0,0 +1,88 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] +#![allow(non_camel_case_types)] +#![deny(dead_code)] + +#![crate_type="lib"] + + +pub use extern_foo as x; +extern { + pub fn extern_foo(); +} + +struct Foo; //~ ERROR: struct is never constructed +impl Foo { + fn foo(&self) { //~ ERROR: method is never used + bar() + } +} + +fn bar() { //~ ERROR: function is never used + fn baz() {} + + Foo.foo(); + baz(); +} + +// no warning +struct Foo2; +impl Foo2 { fn foo2(&self) { bar2() } } +fn bar2() { + fn baz2() {} + + Foo2.foo2(); + baz2(); +} + +pub fn pub_fn() { + let foo2_struct = Foo2; + foo2_struct.foo2(); + + blah::baz(); +} + +mod blah { + // not warned because it's used in the parameter of `free` and return of + // `malloc` below, which are also used. + enum c_void {} + + extern { + fn free(p: *const c_void); + fn malloc(size: usize) -> *const c_void; + } + + pub fn baz() { + unsafe { free(malloc(4)); } + } +} + +enum c_void {} //~ ERROR: enum is never used +extern { + fn free(p: *const c_void); //~ ERROR: foreign function is never used +} + +// Check provided method +mod inner { + pub trait Trait { + fn f(&self) { f(); } + } + + impl Trait for isize {} + + fn f() {} +} + +pub fn foo() { + let a: &inner::Trait = &1_isize; + a.f(); +} diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-3.stderr b/src/test/ui/compile-fail-migration/lint-dead-code-3.stderr new file mode 100644 index 00000000000..994e93e8557 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-3.stderr @@ -0,0 +1,38 @@ +error: struct is never constructed: `Foo` + --> $DIR/lint-dead-code-3.rs:23:1 + | +LL | struct Foo; //~ ERROR: struct is never constructed + | ^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-dead-code-3.rs:13:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: method is never used: `foo` + --> $DIR/lint-dead-code-3.rs:25:5 + | +LL | fn foo(&self) { //~ ERROR: method is never used + | ^^^^^^^^^^^^^ + +error: function is never used: `bar` + --> $DIR/lint-dead-code-3.rs:30:1 + | +LL | fn bar() { //~ ERROR: function is never used + | ^^^^^^^^ + +error: enum is never used: `c_void` + --> $DIR/lint-dead-code-3.rs:69:1 + | +LL | enum c_void {} //~ ERROR: enum is never used + | ^^^^^^^^^^^ + +error: foreign function is never used: `free` + --> $DIR/lint-dead-code-3.rs:71:5 + | +LL | fn free(p: *const c_void); //~ ERROR: foreign function is never used + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-4.rs b/src/test/ui/compile-fail-migration/lint-dead-code-4.rs new file mode 100644 index 00000000000..1296cf46e6f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-4.rs @@ -0,0 +1,93 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] +#![allow(non_camel_case_types)] +#![deny(dead_code)] + +struct Foo { + x: usize, + b: bool, //~ ERROR: field is never used +} + +fn field_read(f: Foo) -> usize { + f.x.pow(2) +} + +enum XYZ { + X, //~ ERROR variant is never constructed + Y { //~ ERROR variant is never constructed + a: String, + b: i32, + c: i32, + }, + Z +} + +enum ABC { //~ ERROR enum is never used + A, + B { + a: String, + b: i32, + c: i32, + }, + C +} + +// ensure struct variants get warning for their fields +enum IJK { + I, //~ ERROR variant is never constructed + J { + a: String, + b: i32, //~ ERROR field is never used + c: i32, //~ ERROR field is never used + }, + K //~ ERROR variant is never constructed + +} + +fn struct_variant_partial_use(b: IJK) -> String { + match b { + IJK::J { a, b: _, .. } => a, + _ => "".to_string() + } +} + +fn field_match_in_patterns(b: XYZ) -> String { + match b { + XYZ::Y { a, b: _, .. } => a, + _ => "".to_string() + } +} + +struct Bar { + x: usize, //~ ERROR: field is never used + b: bool, + c: bool, //~ ERROR: field is never used + _guard: () +} + +#[repr(C)] +struct Baz { + x: u32, +} + +fn field_match_in_let(f: Bar) -> bool { + let Bar { b, c: _, .. } = f; + b +} + +fn main() { + field_read(Foo { x: 1, b: false }); + field_match_in_patterns(XYZ::Z); + struct_variant_partial_use(IJK::J { a: "".into(), b: 1, c: -1 }); + field_match_in_let(Bar { x: 42, b: true, c: false, _guard: () }); + let _ = Baz { x: 0 }; +} diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-4.stderr b/src/test/ui/compile-fail-migration/lint-dead-code-4.stderr new file mode 100644 index 00000000000..fce2cf76898 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-4.stderr @@ -0,0 +1,72 @@ +error: field is never used: `b` + --> $DIR/lint-dead-code-4.rs:17:5 + | +LL | b: bool, //~ ERROR: field is never used + | ^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-dead-code-4.rs:13:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: variant is never constructed: `X` + --> $DIR/lint-dead-code-4.rs:25:5 + | +LL | X, //~ ERROR variant is never constructed + | ^ + +error: variant is never constructed: `Y` + --> $DIR/lint-dead-code-4.rs:26:5 + | +LL | / Y { //~ ERROR variant is never constructed +LL | | a: String, +LL | | b: i32, +LL | | c: i32, +LL | | }, + | |_____^ + +error: enum is never used: `ABC` + --> $DIR/lint-dead-code-4.rs:34:1 + | +LL | enum ABC { //~ ERROR enum is never used + | ^^^^^^^^ + +error: variant is never constructed: `I` + --> $DIR/lint-dead-code-4.rs:46:5 + | +LL | I, //~ ERROR variant is never constructed + | ^ + +error: field is never used: `b` + --> $DIR/lint-dead-code-4.rs:49:9 + | +LL | b: i32, //~ ERROR field is never used + | ^^^^^^ + +error: field is never used: `c` + --> $DIR/lint-dead-code-4.rs:50:9 + | +LL | c: i32, //~ ERROR field is never used + | ^^^^^^ + +error: variant is never constructed: `K` + --> $DIR/lint-dead-code-4.rs:52:5 + | +LL | K //~ ERROR variant is never constructed + | ^ + +error: field is never used: `x` + --> $DIR/lint-dead-code-4.rs:71:5 + | +LL | x: usize, //~ ERROR: field is never used + | ^^^^^^^^ + +error: field is never used: `c` + --> $DIR/lint-dead-code-4.rs:73:5 + | +LL | c: bool, //~ ERROR: field is never used + | ^^^^^^^ + +error: aborting due to 10 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-5.rs b/src/test/ui/compile-fail-migration/lint-dead-code-5.rs new file mode 100644 index 00000000000..ee5cf24823d --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-5.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] +#![deny(dead_code)] + +enum Enum1 { + Variant1(isize), + Variant2 //~ ERROR: variant is never constructed +} + +enum Enum2 { + Variant3(bool), + #[allow(dead_code)] + Variant4(isize), + Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5` + Variant6(isize), //~ ERROR: variant is never constructed: `Variant6` + _Variant7, +} + +enum Enum3 { //~ ERROR: enum is never used + Variant8, + Variant9 +} + +fn main() { + let v = Enum1::Variant1(1); + match v { + Enum1::Variant1(_) => (), + Enum1::Variant2 => () + } + let x = Enum2::Variant3(true); +} diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-5.stderr b/src/test/ui/compile-fail-migration/lint-dead-code-5.stderr new file mode 100644 index 00000000000..37ca0f479f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-5.stderr @@ -0,0 +1,32 @@ +error: variant is never constructed: `Variant2` + --> $DIR/lint-dead-code-5.rs:16:5 + | +LL | Variant2 //~ ERROR: variant is never constructed + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-dead-code-5.rs:12:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: variant is never constructed: `Variant5` + --> $DIR/lint-dead-code-5.rs:23:5 + | +LL | Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5` + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: variant is never constructed: `Variant6` + --> $DIR/lint-dead-code-5.rs:24:5 + | +LL | Variant6(isize), //~ ERROR: variant is never constructed: `Variant6` + | ^^^^^^^^^^^^^^^ + +error: enum is never used: `Enum3` + --> $DIR/lint-dead-code-5.rs:28:1 + | +LL | enum Enum3 { //~ ERROR: enum is never used + | ^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-type-alias.rs b/src/test/ui/compile-fail-migration/lint-dead-code-type-alias.rs new file mode 100644 index 00000000000..aaa01aa6bbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-type-alias.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(dead_code)] + +type Used = u8; +type Unused = u8; //~ ERROR type alias is never used + +fn id(x: Used) -> Used { x } + +fn main() { + id(0); +} diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-type-alias.stderr b/src/test/ui/compile-fail-migration/lint-dead-code-type-alias.stderr new file mode 100644 index 00000000000..bd11e64c781 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-type-alias.stderr @@ -0,0 +1,14 @@ +error: type alias is never used: `Unused` + --> $DIR/lint-dead-code-type-alias.rs:14:1 + | +LL | type Unused = u8; //~ ERROR type alias is never used + | ^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-dead-code-type-alias.rs:11:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-variant.rs b/src/test/ui/compile-fail-migration/lint-dead-code-variant.rs new file mode 100644 index 00000000000..3301560c315 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-variant.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(dead_code)] + +#[derive(Clone)] +enum Enum { + Variant1, //~ ERROR: variant is never constructed + Variant2, +} + +fn main() { + let e = Enum::Variant2; + e.clone(); +} diff --git a/src/test/ui/compile-fail-migration/lint-dead-code-variant.stderr b/src/test/ui/compile-fail-migration/lint-dead-code-variant.stderr new file mode 100644 index 00000000000..05b7e35337a --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-dead-code-variant.stderr @@ -0,0 +1,14 @@ +error: variant is never constructed: `Variant1` + --> $DIR/lint-dead-code-variant.rs:15:5 + | +LL | Variant1, //~ ERROR: variant is never constructed + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-dead-code-variant.rs:11:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.rs b/src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.rs new file mode 100644 index 00000000000..18159aec708 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_imports)] +#![allow(non_upper_case_globals)] + +// The aim of this test is to ensure that deny/allow/warn directives +// are applied to individual "use" statements instead of silently +// ignored. + +#[allow(dead_code)] +mod a { pub static x: isize = 3; pub static y: isize = 4; } + +mod b { + use a::x; //~ ERROR: unused import + #[allow(unused_imports)] + use a::y; // no error here +} + +#[allow(unused_imports)] +mod c { + use a::x; + #[deny(unused_imports)] + use a::y; //~ ERROR: unused import +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.stderr b/src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.stderr new file mode 100644 index 00000000000..2c4602ae20b --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-directives-on-use-items-issue-10534.stderr @@ -0,0 +1,26 @@ +error: unused import: `a::x` + --> $DIR/lint-directives-on-use-items-issue-10534.rs:22:9 + | +LL | use a::x; //~ ERROR: unused import + | ^^^^ + | +note: lint level defined here + --> $DIR/lint-directives-on-use-items-issue-10534.rs:11:9 + | +LL | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: unused import: `a::y` + --> $DIR/lint-directives-on-use-items-issue-10534.rs:31:9 + | +LL | use a::y; //~ ERROR: unused import + | ^^^^ + | +note: lint level defined here + --> $DIR/lint-directives-on-use-items-issue-10534.rs:30:12 + | +LL | #[deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.rs b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.rs new file mode 100644 index 00000000000..5ebfcc4926b --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.rs @@ -0,0 +1,57 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(exceeding_bitshifts, const_err)] +#![allow(unused_variables)] +#![allow(dead_code)] + +fn main() { + let n = 1u8 << 7; + let n = 1u8 << 8; //~ ERROR: attempt to shift left with overflow + let n = 1u16 << 15; + let n = 1u16 << 16; //~ ERROR: attempt to shift left with overflow + let n = 1u32 << 31; + let n = 1u32 << 32; //~ ERROR: attempt to shift left with overflow + let n = 1u64 << 63; + let n = 1u64 << 64; //~ ERROR: attempt to shift left with overflow + let n = 1i8 << 7; + let n = 1i8 << 8; //~ ERROR: attempt to shift left with overflow + let n = 1i16 << 15; + let n = 1i16 << 16; //~ ERROR: attempt to shift left with overflow + let n = 1i32 << 31; + let n = 1i32 << 32; //~ ERROR: attempt to shift left with overflow + let n = 1i64 << 63; + let n = 1i64 << 64; //~ ERROR: attempt to shift left with overflow + + let n = 1u8 >> 7; + let n = 1u8 >> 8; //~ ERROR: attempt to shift right with overflow + let n = 1u16 >> 15; + let n = 1u16 >> 16; //~ ERROR: attempt to shift right with overflow + let n = 1u32 >> 31; + let n = 1u32 >> 32; //~ ERROR: attempt to shift right with overflow + let n = 1u64 >> 63; + let n = 1u64 >> 64; //~ ERROR: attempt to shift right with overflow + let n = 1i8 >> 7; + let n = 1i8 >> 8; //~ ERROR: attempt to shift right with overflow + let n = 1i16 >> 15; + let n = 1i16 >> 16; //~ ERROR: attempt to shift right with overflow + let n = 1i32 >> 31; + let n = 1i32 >> 32; //~ ERROR: attempt to shift right with overflow + let n = 1i64 >> 63; + let n = 1i64 >> 64; //~ ERROR: attempt to shift right with overflow + + let n = 1u8; + let n = n << 7; + let n = n << 8; //~ ERROR: attempt to shift left with overflow + + let n = 1u8 << -8; //~ ERROR: attempt to shift left with overflow + + let n = 1i8<<(1isize+-1); +} diff --git a/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.stderr b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.stderr new file mode 100644 index 00000000000..5124a69195a --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts.stderr @@ -0,0 +1,116 @@ +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:17:15 + | +LL | let n = 1u8 << 8; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-exceeding-bitshifts.rs:11:9 + | +LL | #![deny(exceeding_bitshifts, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:19:15 + | +LL | let n = 1u16 << 16; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:21:15 + | +LL | let n = 1u32 << 32; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:23:15 + | +LL | let n = 1u64 << 64; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:25:15 + | +LL | let n = 1i8 << 8; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:27:15 + | +LL | let n = 1i16 << 16; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:29:15 + | +LL | let n = 1i32 << 32; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:31:15 + | +LL | let n = 1i64 << 64; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:34:15 + | +LL | let n = 1u8 >> 8; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:36:15 + | +LL | let n = 1u16 >> 16; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:38:15 + | +LL | let n = 1u32 >> 32; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:40:15 + | +LL | let n = 1u64 >> 64; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:42:15 + | +LL | let n = 1i8 >> 8; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:44:15 + | +LL | let n = 1i16 >> 16; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:46:15 + | +LL | let n = 1i32 >> 32; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^^^ + +error: attempt to shift right with overflow + --> $DIR/lint-exceeding-bitshifts.rs:48:15 + | +LL | let n = 1i64 >> 64; //~ ERROR: attempt to shift right with overflow + | ^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:52:15 + | +LL | let n = n << 8; //~ ERROR: attempt to shift left with overflow + | ^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts.rs:54:15 + | +LL | let n = 1u8 << -8; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^ + +error: aborting due to 18 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.rs b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.rs new file mode 100644 index 00000000000..3ba300eb7c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(exceeding_bitshifts, const_err)] +#![allow(unused_variables)] +#![allow(dead_code)] + +fn main() { + let n = 1u8 << (4+3); + let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow + let n = 1i64 >> [63][0]; + let n = 1i64 >> [64][0]; // should be linting, needs to wait for const propagation + + #[cfg(target_pointer_width = "32")] + const BITS: usize = 32; + #[cfg(target_pointer_width = "64")] + const BITS: usize = 64; + let n = 1_isize << BITS; //~ ERROR: attempt to shift left with overflow + let n = 1_usize << BITS; //~ ERROR: attempt to shift left with overflow +} diff --git a/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.stderr b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.stderr new file mode 100644 index 00000000000..17b4235a73f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-exceeding-bitshifts2.stderr @@ -0,0 +1,26 @@ +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts2.rs:17:15 + | +LL | let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-exceeding-bitshifts2.rs:11:9 + | +LL | #![deny(exceeding_bitshifts, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts2.rs:25:15 + | +LL | let n = 1_isize << BITS; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^^^^^^ + +error: attempt to shift left with overflow + --> $DIR/lint-exceeding-bitshifts2.rs:26:15 + | +LL | let n = 1_usize << BITS; //~ ERROR: attempt to shift left with overflow + | ^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-forbid-cmdline.rs b/src/test/ui/compile-fail-migration/lint-forbid-cmdline.rs new file mode 100644 index 00000000000..6a4d17b33de --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-forbid-cmdline.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -F deprecated + +#[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated) +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/lint-forbid-cmdline.stderr b/src/test/ui/compile-fail-migration/lint-forbid-cmdline.stderr new file mode 100644 index 00000000000..37a2699e898 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-forbid-cmdline.stderr @@ -0,0 +1,11 @@ +error[E0453]: allow(deprecated) overruled by outer forbid(deprecated) + --> $DIR/lint-forbid-cmdline.rs:13:9 + | +LL | #[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated) + | ^^^^^^^^^^ overruled by previous forbid + | + = note: `forbid` lint level was set on command line + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/compile-fail-migration/lint-impl-fn.rs b/src/test/ui/compile-fail-migration/lint-impl-fn.rs new file mode 100644 index 00000000000..54a720d75b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-impl-fn.rs @@ -0,0 +1,43 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(while_true)] +#![allow(dead_code)] + +struct A(isize); + +impl A { + fn foo(&self) { while true {} } + + #[deny(while_true)] + fn bar(&self) { while true {} } //~ ERROR: infinite loops +} + +#[deny(while_true)] +mod foo { + struct B(isize); + + impl B { + fn foo(&self) { while true {} } //~ ERROR: infinite loops + + #[allow(while_true)] + fn bar(&self) { while true {} } + } +} + +#[deny(while_true)] +fn main() { + while true {} //~ ERROR: infinite loops +} + +#[deny(while_true)] +fn bar() { + while cfg!(unix) {} // no error +} diff --git a/src/test/ui/compile-fail-migration/lint-impl-fn.stderr b/src/test/ui/compile-fail-migration/lint-impl-fn.stderr new file mode 100644 index 00000000000..ed37e877875 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-impl-fn.stderr @@ -0,0 +1,38 @@ +error: denote infinite loops with `loop { ... }` + --> $DIR/lint-impl-fn.rs:20:21 + | +LL | fn bar(&self) { while true {} } //~ ERROR: infinite loops + | ^^^^^^^^^^ help: use `loop` + | +note: lint level defined here + --> $DIR/lint-impl-fn.rs:19:12 + | +LL | #[deny(while_true)] + | ^^^^^^^^^^ + +error: denote infinite loops with `loop { ... }` + --> $DIR/lint-impl-fn.rs:28:25 + | +LL | fn foo(&self) { while true {} } //~ ERROR: infinite loops + | ^^^^^^^^^^ help: use `loop` + | +note: lint level defined here + --> $DIR/lint-impl-fn.rs:23:8 + | +LL | #[deny(while_true)] + | ^^^^^^^^^^ + +error: denote infinite loops with `loop { ... }` + --> $DIR/lint-impl-fn.rs:37:5 + | +LL | while true {} //~ ERROR: infinite loops + | ^^^^^^^^^^ help: use `loop` + | +note: lint level defined here + --> $DIR/lint-impl-fn.rs:35:8 + | +LL | #[deny(while_true)] + | ^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-malformed.rs b/src/test/ui/compile-fail-migration/lint-malformed.rs new file mode 100644 index 00000000000..ad5e3aa3f06 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-malformed.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny = "foo"] //~ ERROR malformed lint attribute +#![allow(bar = "baz")] //~ ERROR malformed lint attribute + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-malformed.stderr b/src/test/ui/compile-fail-migration/lint-malformed.stderr new file mode 100644 index 00000000000..7b8155cb410 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-malformed.stderr @@ -0,0 +1,15 @@ +error[E0452]: malformed lint attribute + --> $DIR/lint-malformed.rs:11:1 + | +LL | #![deny = "foo"] //~ ERROR malformed lint attribute + | ^^^^^^^^^^^^^^^^ + +error[E0452]: malformed lint attribute + --> $DIR/lint-malformed.rs:12:10 + | +LL | #![allow(bar = "baz")] //~ ERROR malformed lint attribute + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0452`. diff --git a/src/test/ui/compile-fail-migration/lint-misplaced-attr.rs b/src/test/ui/compile-fail-migration/lint-misplaced-attr.rs new file mode 100644 index 00000000000..18ea5a383f6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-misplaced-attr.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// When denying at the crate level, be sure to not get random warnings from the +// injected intrinsics by the compiler. + +#![deny(unused_attributes)] + +mod a { + #![crate_type = "bin"] //~ ERROR unused attribute + //~^ ERROR should be in the root module +} + +#[crate_type = "bin"] fn main() {} //~ ERROR unused attribute + //~^ ERROR should be an inner diff --git a/src/test/ui/compile-fail-migration/lint-misplaced-attr.stderr b/src/test/ui/compile-fail-migration/lint-misplaced-attr.stderr new file mode 100644 index 00000000000..17f29a6ba79 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-misplaced-attr.stderr @@ -0,0 +1,32 @@ +error: unused attribute + --> $DIR/lint-misplaced-attr.rs:17:5 + | +LL | #![crate_type = "bin"] //~ ERROR unused attribute + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-misplaced-attr.rs:14:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: crate-level attribute should be in the root module + --> $DIR/lint-misplaced-attr.rs:17:5 + | +LL | #![crate_type = "bin"] //~ ERROR unused attribute + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: unused attribute + --> $DIR/lint-misplaced-attr.rs:21:1 + | +LL | #[crate_type = "bin"] fn main() {} //~ ERROR unused attribute + | ^^^^^^^^^^^^^^^^^^^^^ + +error: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] + --> $DIR/lint-misplaced-attr.rs:21:1 + | +LL | #[crate_type = "bin"] fn main() {} //~ ERROR unused attribute + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-missing-copy-implementations.rs b/src/test/ui/compile-fail-migration/lint-missing-copy-implementations.rs new file mode 100644 index 00000000000..94a11aac067 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-missing-copy-implementations.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// See issue 19712 + +#![deny(missing_copy_implementations)] + +mod inner { + pub struct Foo { //~ ERROR type could implement `Copy`; consider adding `impl Copy` + pub field: i32 + } +} + +pub fn foo() -> inner::Foo { + inner::Foo { field: 42 } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-missing-copy-implementations.stderr b/src/test/ui/compile-fail-migration/lint-missing-copy-implementations.stderr new file mode 100644 index 00000000000..3cb89ef794a --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-missing-copy-implementations.stderr @@ -0,0 +1,16 @@ +error: type could implement `Copy`; consider adding `impl Copy` + --> $DIR/lint-missing-copy-implementations.rs:16:5 + | +LL | / pub struct Foo { //~ ERROR type could implement `Copy`; consider adding `impl Copy` +LL | | pub field: i32 +LL | | } + | |_____^ + | +note: lint level defined here + --> $DIR/lint-missing-copy-implementations.rs:13:9 + | +LL | #![deny(missing_copy_implementations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-missing-doc.rs b/src/test/ui/compile-fail-migration/lint-missing-doc.rs new file mode 100644 index 00000000000..4add67f61e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-missing-doc.rs @@ -0,0 +1,196 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// When denying at the crate level, be sure to not get random warnings from the +// injected intrinsics by the compiler. +#![deny(missing_docs)] +#![allow(dead_code)] +#![feature(associated_type_defaults)] + +//! Some garbage docs for the crate here +#![doc="More garbage"] + +type Typedef = String; +pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias + +struct Foo { + a: isize, + b: isize, +} + +pub struct PubFoo { //~ ERROR: missing documentation for a struct + pub a: isize, //~ ERROR: missing documentation for a struct field + b: isize, +} + +#[allow(missing_docs)] +pub struct PubFoo2 { + pub a: isize, + pub c: isize, +} + +mod module_no_dox {} +pub mod pub_module_no_dox {} //~ ERROR: missing documentation for a module + +/// dox +pub fn foo() {} +pub fn foo2() {} //~ ERROR: missing documentation for a function +fn foo3() {} +#[allow(missing_docs)] pub fn foo4() {} + +/// dox +pub trait A { + /// dox + fn foo(&self); + /// dox + fn foo_with_impl(&self) {} +} + +#[allow(missing_docs)] +trait B { + fn foo(&self); + fn foo_with_impl(&self) {} +} + +pub trait C { //~ ERROR: missing documentation for a trait + fn foo(&self); //~ ERROR: missing documentation for a trait method + fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method +} + +#[allow(missing_docs)] +pub trait D { + fn dummy(&self) { } +} + +/// dox +pub trait E { + type AssociatedType; //~ ERROR: missing documentation for an associated type + type AssociatedTypeDef = Self; //~ ERROR: missing documentation for an associated type + + /// dox + type DocumentedType; + /// dox + type DocumentedTypeDef = Self; + /// dox + fn dummy(&self) {} +} + +impl Foo { + pub fn foo() {} + fn bar() {} +} + +impl PubFoo { + pub fn foo() {} //~ ERROR: missing documentation for a method + /// dox + pub fn foo1() {} + fn foo2() {} + #[allow(missing_docs)] pub fn foo3() {} +} + +#[allow(missing_docs)] +trait F { + fn a(); + fn b(&self); +} + +// should need to redefine documentation for implementations of traits +impl F for Foo { + fn a() {} + fn b(&self) {} +} + +// It sure is nice if doc(hidden) implies allow(missing_docs), and that it +// applies recursively +#[doc(hidden)] +mod a { + pub fn baz() {} + pub mod b { + pub fn baz() {} + } +} + +enum Baz { + BazA { + a: isize, + b: isize + }, + BarB +} + +pub enum PubBaz { //~ ERROR: missing documentation for an enum + PubBazA { //~ ERROR: missing documentation for a variant + a: isize, //~ ERROR: missing documentation for a struct field + }, +} + +/// dox +pub enum PubBaz2 { + /// dox + PubBaz2A { + /// dox + a: isize, + }, +} + +#[allow(missing_docs)] +pub enum PubBaz3 { + PubBaz3A { + b: isize + }, +} + +#[doc(hidden)] +pub fn baz() {} + + +const FOO: u32 = 0; +/// dox +pub const FOO1: u32 = 0; +#[allow(missing_docs)] +pub const FOO2: u32 = 0; +#[doc(hidden)] +pub const FOO3: u32 = 0; +pub const FOO4: u32 = 0; //~ ERROR: missing documentation for a const + + +static BAR: u32 = 0; +/// dox +pub static BAR1: u32 = 0; +#[allow(missing_docs)] +pub static BAR2: u32 = 0; +#[doc(hidden)] +pub static BAR3: u32 = 0; +pub static BAR4: u32 = 0; //~ ERROR: missing documentation for a static + + +mod internal_impl { + /// dox + pub fn documented() {} + pub fn undocumented1() {} //~ ERROR: missing documentation for a function + pub fn undocumented2() {} //~ ERROR: missing documentation for a function + fn undocumented3() {} + /// dox + pub mod globbed { + /// dox + pub fn also_documented() {} + pub fn also_undocumented1() {} //~ ERROR: missing documentation for a function + fn also_undocumented2() {} + } +} +/// dox +pub mod public_interface { + pub use internal_impl::documented as foo; + pub use internal_impl::undocumented1 as bar; + pub use internal_impl::{documented, undocumented2}; + pub use internal_impl::globbed::*; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-missing-doc.stderr b/src/test/ui/compile-fail-migration/lint-missing-doc.stderr new file mode 100644 index 00000000000..e61d56d8518 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-missing-doc.stderr @@ -0,0 +1,122 @@ +error: missing documentation for a type alias + --> $DIR/lint-missing-doc.rs:21:1 + | +LL | pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-missing-doc.rs:13:9 + | +LL | #![deny(missing_docs)] + | ^^^^^^^^^^^^ + +error: missing documentation for a struct + --> $DIR/lint-missing-doc.rs:28:1 + | +LL | pub struct PubFoo { //~ ERROR: missing documentation for a struct + | ^^^^^^^^^^^^^^^^^ + +error: missing documentation for a struct field + --> $DIR/lint-missing-doc.rs:29:5 + | +LL | pub a: isize, //~ ERROR: missing documentation for a struct field + | ^^^^^^^^^^^^ + +error: missing documentation for a module + --> $DIR/lint-missing-doc.rs:40:1 + | +LL | pub mod pub_module_no_dox {} //~ ERROR: missing documentation for a module + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/lint-missing-doc.rs:44:1 + | +LL | pub fn foo2() {} //~ ERROR: missing documentation for a function + | ^^^^^^^^^^^^^ + +error: missing documentation for a trait + --> $DIR/lint-missing-doc.rs:62:1 + | +LL | pub trait C { //~ ERROR: missing documentation for a trait + | ^^^^^^^^^^^ + +error: missing documentation for a trait method + --> $DIR/lint-missing-doc.rs:63:5 + | +LL | fn foo(&self); //~ ERROR: missing documentation for a trait method + | ^^^^^^^^^^^^^^ + +error: missing documentation for a trait method + --> $DIR/lint-missing-doc.rs:64:5 + | +LL | fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for an associated type + --> $DIR/lint-missing-doc.rs:74:5 + | +LL | type AssociatedType; //~ ERROR: missing documentation for an associated type + | ^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for an associated type + --> $DIR/lint-missing-doc.rs:75:5 + | +LL | type AssociatedTypeDef = Self; //~ ERROR: missing documentation for an associated type + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a method + --> $DIR/lint-missing-doc.rs:91:5 + | +LL | pub fn foo() {} //~ ERROR: missing documentation for a method + | ^^^^^^^^^^^^ + +error: missing documentation for an enum + --> $DIR/lint-missing-doc.rs:128:1 + | +LL | pub enum PubBaz { //~ ERROR: missing documentation for an enum + | ^^^^^^^^^^^^^^^ + +error: missing documentation for a variant + --> $DIR/lint-missing-doc.rs:129:5 + | +LL | PubBazA { //~ ERROR: missing documentation for a variant + | ^^^^^^^ + +error: missing documentation for a struct field + --> $DIR/lint-missing-doc.rs:130:9 + | +LL | a: isize, //~ ERROR: missing documentation for a struct field + | ^^^^^^^^ + +error: missing documentation for a constant + --> $DIR/lint-missing-doc.rs:161:1 + | +LL | pub const FOO4: u32 = 0; //~ ERROR: missing documentation for a const + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a static + --> $DIR/lint-missing-doc.rs:171:1 + | +LL | pub static BAR4: u32 = 0; //~ ERROR: missing documentation for a static + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/lint-missing-doc.rs:177:5 + | +LL | pub fn undocumented1() {} //~ ERROR: missing documentation for a function + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/lint-missing-doc.rs:178:5 + | +LL | pub fn undocumented2() {} //~ ERROR: missing documentation for a function + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: missing documentation for a function + --> $DIR/lint-missing-doc.rs:184:9 + | +LL | pub fn also_undocumented1() {} //~ ERROR: missing documentation for a function + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 19 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-non-camel-case-types.rs b/src/test/ui/compile-fail-migration/lint-non-camel-case-types.rs new file mode 100644 index 00000000000..5dcdf3a863f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-camel-case-types.rs @@ -0,0 +1,56 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![forbid(non_camel_case_types)] +#![allow(dead_code)] + +struct ONE_TWO_THREE; +//~^ ERROR type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree` + +struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo` + bar: isize, +} + +enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2` + Bar +} + +struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3` + bar: isize +} + +type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4` + +enum Foo5 { + bar //~ ERROR variant `bar` should have a camel case name such as `Bar` +} + +trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6` + fn dummy(&self) { } +} + +fn f(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty` + +#[repr(C)] +struct foo7 { + bar: isize, +} + +type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase` + +struct X86_64; + +struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` + +struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123` + +struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3` + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-non-camel-case-types.stderr b/src/test/ui/compile-fail-migration/lint-non-camel-case-types.stderr new file mode 100644 index 00000000000..85610dc7fa3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-camel-case-types.stderr @@ -0,0 +1,88 @@ +error: type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree` + --> $DIR/lint-non-camel-case-types.rs:14:1 + | +LL | struct ONE_TWO_THREE; + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-non-camel-case-types.rs:11:11 + | +LL | #![forbid(non_camel_case_types)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: type `foo` should have a camel case name such as `Foo` + --> $DIR/lint-non-camel-case-types.rs:17:1 + | +LL | / struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo` +LL | | bar: isize, +LL | | } + | |_^ + +error: type `foo2` should have a camel case name such as `Foo2` + --> $DIR/lint-non-camel-case-types.rs:21:1 + | +LL | / enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2` +LL | | Bar +LL | | } + | |_^ + +error: type `foo3` should have a camel case name such as `Foo3` + --> $DIR/lint-non-camel-case-types.rs:25:1 + | +LL | / struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3` +LL | | bar: isize +LL | | } + | |_^ + +error: type `foo4` should have a camel case name such as `Foo4` + --> $DIR/lint-non-camel-case-types.rs:29:1 + | +LL | type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4` + | ^^^^^^^^^^^^^^^^^^ + +error: variant `bar` should have a camel case name such as `Bar` + --> $DIR/lint-non-camel-case-types.rs:32:5 + | +LL | bar //~ ERROR variant `bar` should have a camel case name such as `Bar` + | ^^^ + +error: trait `foo6` should have a camel case name such as `Foo6` + --> $DIR/lint-non-camel-case-types.rs:35:1 + | +LL | / trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6` +LL | | fn dummy(&self) { } +LL | | } + | |_^ + +error: type parameter `ty` should have a camel case name such as `Ty` + --> $DIR/lint-non-camel-case-types.rs:39:6 + | +LL | fn f(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty` + | ^^ + +error: type `__` should have a camel case name such as `CamelCase` + --> $DIR/lint-non-camel-case-types.rs:46:1 + | +LL | type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase` + | ^^^^^^^^^^^^^^^^ + +error: type `X86__64` should have a camel case name such as `X86_64` + --> $DIR/lint-non-camel-case-types.rs:50:1 + | +LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` + | ^^^^^^^^^^^^^^^ + +error: type `Abc_123` should have a camel case name such as `Abc123` + --> $DIR/lint-non-camel-case-types.rs:52:1 + | +LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123` + | ^^^^^^^^^^^^^^^ + +error: type `A1_b2_c3` should have a camel case name such as `A1B2C3` + --> $DIR/lint-non-camel-case-types.rs:54:1 + | +LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3` + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.rs b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.rs new file mode 100644 index 00000000000..fe22c21df24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --crate-name NonSnakeCase +// error-pattern: crate `NonSnakeCase` should have a snake case name such as `non_snake_case` + +#![deny(non_snake_case)] + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.stderr b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.stderr new file mode 100644 index 00000000000..ce49d9a0b80 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate-2.stderr @@ -0,0 +1,10 @@ +error: crate `NonSnakeCase` should have a snake case name such as `non_snake_case` + | +note: lint level defined here + --> $DIR/lint-non-snake-case-crate-2.rs:14:9 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-crate.rs b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate.rs new file mode 100644 index 00000000000..9ca0a34e6ff --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "NonSnakeCase"] +//~^ ERROR crate `NonSnakeCase` should have a snake case name such as `non_snake_case` +#![deny(non_snake_case)] + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-crate.stderr b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate.stderr new file mode 100644 index 00000000000..4d55661daa0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-crate.stderr @@ -0,0 +1,14 @@ +error: crate `NonSnakeCase` should have a snake case name such as `non_snake_case` + --> $DIR/lint-non-snake-case-crate.rs:11:1 + | +LL | #![crate_name = "NonSnakeCase"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-non-snake-case-crate.rs:13:9 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-functions.rs b/src/test/ui/compile-fail-migration/lint-non-snake-case-functions.rs new file mode 100644 index 00000000000..6cfdc6ad90b --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-functions.rs @@ -0,0 +1,54 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(non_snake_case)] +#![allow(dead_code)] + +struct Foo; + +impl Foo { + fn Foo_Method() {} + //~^ ERROR method `Foo_Method` should have a snake case name such as `foo_method` + + // Don't allow two underscores in a row + fn foo__method(&self) {} + //~^ ERROR method `foo__method` should have a snake case name such as `foo_method` + + pub fn xyZ(&mut self) {} + //~^ ERROR method `xyZ` should have a snake case name such as `xy_z` + + fn render_HTML() {} + //~^ ERROR method `render_HTML` should have a snake case name such as `render_html` +} + +trait X { + fn ABC(); + //~^ ERROR trait method `ABC` should have a snake case name such as `abc` + + fn a_b_C(&self) {} + //~^ ERROR trait method `a_b_C` should have a snake case name such as `a_b_c` + + fn something__else(&mut self); + //~^ ERROR trait method `something__else` should have a snake case name such as `something_else` +} + +impl X for Foo { + // These errors should be caught at the trait definition not the impl + fn ABC() {} + fn something__else(&mut self) {} +} + +fn Cookie() {} +//~^ ERROR function `Cookie` should have a snake case name such as `cookie` + +pub fn bi_S_Cuit() {} +//~^ ERROR function `bi_S_Cuit` should have a snake case name such as `bi_s_cuit` + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-functions.stderr b/src/test/ui/compile-fail-migration/lint-non-snake-case-functions.stderr new file mode 100644 index 00000000000..f7ac48da901 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-functions.stderr @@ -0,0 +1,62 @@ +error: method `Foo_Method` should have a snake case name such as `foo_method` + --> $DIR/lint-non-snake-case-functions.rs:17:5 + | +LL | fn Foo_Method() {} + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-non-snake-case-functions.rs:11:9 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: method `foo__method` should have a snake case name such as `foo_method` + --> $DIR/lint-non-snake-case-functions.rs:21:5 + | +LL | fn foo__method(&self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: method `xyZ` should have a snake case name such as `xy_z` + --> $DIR/lint-non-snake-case-functions.rs:24:5 + | +LL | pub fn xyZ(&mut self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: method `render_HTML` should have a snake case name such as `render_html` + --> $DIR/lint-non-snake-case-functions.rs:27:5 + | +LL | fn render_HTML() {} + | ^^^^^^^^^^^^^^^^^^^ + +error: trait method `ABC` should have a snake case name such as `abc` + --> $DIR/lint-non-snake-case-functions.rs:32:5 + | +LL | fn ABC(); + | ^^^^^^^^^ + +error: trait method `a_b_C` should have a snake case name such as `a_b_c` + --> $DIR/lint-non-snake-case-functions.rs:35:5 + | +LL | fn a_b_C(&self) {} + | ^^^^^^^^^^^^^^^^^^ + +error: trait method `something__else` should have a snake case name such as `something_else` + --> $DIR/lint-non-snake-case-functions.rs:38:5 + | +LL | fn something__else(&mut self); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: function `Cookie` should have a snake case name such as `cookie` + --> $DIR/lint-non-snake-case-functions.rs:48:1 + | +LL | fn Cookie() {} + | ^^^^^^^^^^^^^^ + +error: function `bi_S_Cuit` should have a snake case name such as `bi_s_cuit` + --> $DIR/lint-non-snake-case-functions.rs:51:1 + | +LL | pub fn bi_S_Cuit() {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.rs b/src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.rs new file mode 100644 index 00000000000..64669d90d06 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(non_snake_case)] +#![allow(dead_code)] + +fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name such as `'foo_bar` + _: &'FooBar () +) {} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.stderr b/src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.stderr new file mode 100644 index 00000000000..dc9b5b8cd75 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-lifetimes.stderr @@ -0,0 +1,14 @@ +error: lifetime `'FooBar` should have a snake case name such as `'foo_bar` + --> $DIR/lint-non-snake-case-lifetimes.rs:14:6 + | +LL | fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name such as `'foo_bar` + | ^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-non-snake-case-lifetimes.rs:11:9 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-modules.rs b/src/test/ui/compile-fail-migration/lint-non-snake-case-modules.rs new file mode 100644 index 00000000000..5bc84698ec9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-modules.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(non_snake_case)] +#![allow(dead_code)] + +mod FooBar { //~ ERROR module `FooBar` should have a snake case name such as `foo_bar` + pub struct S; +} + +fn f(_: FooBar::S) { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-non-snake-case-modules.stderr b/src/test/ui/compile-fail-migration/lint-non-snake-case-modules.stderr new file mode 100644 index 00000000000..d55d80f31b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-snake-case-modules.stderr @@ -0,0 +1,16 @@ +error: module `FooBar` should have a snake case name such as `foo_bar` + --> $DIR/lint-non-snake-case-modules.rs:14:1 + | +LL | / mod FooBar { //~ ERROR module `FooBar` should have a snake case name such as `foo_bar` +LL | | pub struct S; +LL | | } + | |_^ + | +note: lint level defined here + --> $DIR/lint-non-snake-case-modules.rs:11:9 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-non-uppercase-statics.rs b/src/test/ui/compile-fail-migration/lint-non-uppercase-statics.rs new file mode 100644 index 00000000000..84cc24a0010 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-uppercase-statics.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![forbid(non_upper_case_globals)] +#![allow(dead_code)] + +static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name such as `FOO` + +static mut bar: isize = 1; + //~^ ERROR static variable `bar` should have an upper case name such as `BAR` + +#[no_mangle] +pub static extern_foo: isize = 1; // OK, because #[no_mangle] supersedes the warning + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-non-uppercase-statics.stderr b/src/test/ui/compile-fail-migration/lint-non-uppercase-statics.stderr new file mode 100644 index 00000000000..0d56c577734 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-non-uppercase-statics.stderr @@ -0,0 +1,20 @@ +error: static variable `foo` should have an upper case name such as `FOO` + --> $DIR/lint-non-uppercase-statics.rs:14:1 + | +LL | static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name such as `FOO` + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-non-uppercase-statics.rs:11:11 + | +LL | #![forbid(non_upper_case_globals)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: static variable `bar` should have an upper case name such as `BAR` + --> $DIR/lint-non-uppercase-statics.rs:16:1 + | +LL | static mut bar: isize = 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-obsolete-attr.rs b/src/test/ui/compile-fail-migration/lint-obsolete-attr.rs new file mode 100644 index 00000000000..b234f08d04a --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-obsolete-attr.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// When denying at the crate level, be sure to not get random warnings from the +// injected intrinsics by the compiler. + +#![deny(unused_attributes)] +#![allow(dead_code)] +#![feature(custom_attribute)] + +#[ab_isize="stdcall"] extern {} //~ ERROR unused attribute + +#[fixed_stack_segment] fn f() {} //~ ERROR unused attribute + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-obsolete-attr.stderr b/src/test/ui/compile-fail-migration/lint-obsolete-attr.stderr new file mode 100644 index 00000000000..4a8a55e260e --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-obsolete-attr.stderr @@ -0,0 +1,20 @@ +error: unused attribute + --> $DIR/lint-obsolete-attr.rs:18:1 + | +LL | #[ab_isize="stdcall"] extern {} //~ ERROR unused attribute + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-obsolete-attr.rs:14:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: unused attribute + --> $DIR/lint-obsolete-attr.rs:20:1 + | +LL | #[fixed_stack_segment] fn f() {} //~ ERROR unused attribute + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-output-format.rs b/src/test/ui/compile-fail-migration/lint-output-format.rs new file mode 100644 index 00000000000..81e0b708b87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-output-format.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -F unused_features +// aux-build:lint_output_format.rs + +#![allow(deprecated)] + +extern crate lint_output_format; //~ ERROR use of unstable library feature +use lint_output_format::{foo, bar}; //~ ERROR use of unstable library feature + +fn main() { + let _x = foo(); + let _y = bar(); //~ ERROR use of unstable library feature +} diff --git a/src/test/ui/compile-fail-migration/lint-output-format.stderr b/src/test/ui/compile-fail-migration/lint-output-format.stderr new file mode 100644 index 00000000000..bcc279929c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-output-format.stderr @@ -0,0 +1,27 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-output-format.rs:16:1 + | +LL | extern crate lint_output_format; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-output-format.rs:17:31 + | +LL | use lint_output_format::{foo, bar}; //~ ERROR use of unstable library feature + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-output-format.rs:21:14 + | +LL | let _y = bar(); //~ ERROR use of unstable library feature + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/lint-owned-heap-memory.rs b/src/test/ui/compile-fail-migration/lint-owned-heap-memory.rs new file mode 100644 index 00000000000..9c68da8beaf --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-owned-heap-memory.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![forbid(box_pointers)] +#![feature(box_syntax)] + +struct Foo { + x: Box //~ ERROR type uses owned +} + +fn main() { + let _x : Foo = Foo {x : box 10}; + //~^ ERROR type uses owned +} diff --git a/src/test/ui/compile-fail-migration/lint-owned-heap-memory.stderr b/src/test/ui/compile-fail-migration/lint-owned-heap-memory.stderr new file mode 100644 index 00000000000..5b61d30fd39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-owned-heap-memory.stderr @@ -0,0 +1,20 @@ +error: type uses owned (Box type) pointers: std::boxed::Box + --> $DIR/lint-owned-heap-memory.rs:16:5 + | +LL | x: Box //~ ERROR type uses owned + | ^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-owned-heap-memory.rs:12:11 + | +LL | #![forbid(box_pointers)] + | ^^^^^^^^^^^^ + +error: type uses owned (Box type) pointers: std::boxed::Box + --> $DIR/lint-owned-heap-memory.rs:20:29 + | +LL | let _x : Foo = Foo {x : box 10}; + | ^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-qualification.rs b/src/test/ui/compile-fail-migration/lint-qualification.rs new file mode 100644 index 00000000000..57c2166565f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-qualification.rs @@ -0,0 +1,29 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_qualifications)] + +mod foo { + pub fn bar() {} +} + +fn main() { + use foo::bar; + foo::bar(); //~ ERROR: unnecessary qualification + bar(); + + let _ = || -> Result<(), ()> { try!(Ok(())); Ok(()) }; // issue #37345 + + macro_rules! m { () => { + $crate::foo::bar(); // issue #37357 + ::foo::bar(); // issue #38682 + } } + m!(); +} diff --git a/src/test/ui/compile-fail-migration/lint-qualification.stderr b/src/test/ui/compile-fail-migration/lint-qualification.stderr new file mode 100644 index 00000000000..f4c8186caf7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-qualification.stderr @@ -0,0 +1,14 @@ +error: unnecessary qualification + --> $DIR/lint-qualification.rs:19:5 + | +LL | foo::bar(); //~ ERROR: unnecessary qualification + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-qualification.rs:11:9 + | +LL | #![deny(unused_qualifications)] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-removed-allow.rs b/src/test/ui/compile-fail-migration/lint-removed-allow.rs new file mode 100644 index 00000000000..9f84190ea18 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-removed-allow.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// No warnings about removed lint when +// allow(renamed_and_removed_lints) + +#![allow(renamed_and_removed_lints)] + +#[deny(raw_pointer_derive)] +#[deny(unused_variables)] +fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/ui/compile-fail-migration/lint-removed-allow.stderr b/src/test/ui/compile-fail-migration/lint-removed-allow.stderr new file mode 100644 index 00000000000..8f4c757e54b --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-removed-allow.stderr @@ -0,0 +1,14 @@ +error: unused variable: `unused` + --> $DIR/lint-removed-allow.rs:18:17 + | +LL | fn main() { let unused = (); } //~ ERROR unused + | ^^^^^^ help: consider using `_unused` instead + | +note: lint level defined here + --> $DIR/lint-removed-allow.rs:17:8 + | +LL | #[deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-removed-cmdline.rs b/src/test/ui/compile-fail-migration/lint-removed-cmdline.rs new file mode 100644 index 00000000000..09725b20146 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-removed-cmdline.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The raw_pointer_derived lint warns about its removal +// cc #30346 + +// compile-flags:-D raw_pointer_derive + +// error-pattern:lint `raw_pointer_derive` has been removed +// error-pattern:requested on the command line with `-D raw_pointer_derive` + +#![warn(unused)] + +#[deny(warnings)] +fn main() { let unused = (); } diff --git a/src/test/ui/compile-fail-migration/lint-removed-cmdline.stderr b/src/test/ui/compile-fail-migration/lint-removed-cmdline.stderr new file mode 100644 index 00000000000..86faeec9542 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-removed-cmdline.stderr @@ -0,0 +1,19 @@ +warning: lint `raw_pointer_derive` has been removed: `using derive with raw pointers is ok` + | + = note: requested on the command line with `-D raw_pointer_derive` + +error: unused variable: `unused` + --> $DIR/lint-removed-cmdline.rs:22:17 + | +LL | fn main() { let unused = (); } + | ^^^^^^ help: consider using `_unused` instead + | +note: lint level defined here + --> $DIR/lint-removed-cmdline.rs:21:8 + | +LL | #[deny(warnings)] + | ^^^^^^^^ + = note: #[deny(unused_variables)] implied by #[deny(warnings)] + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-removed.rs b/src/test/ui/compile-fail-migration/lint-removed.rs new file mode 100644 index 00000000000..4e53852008f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-removed.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The raw_pointer_derived lint was removed, but is now reported by +// the renamed_and_removed_lints lint, which means it's a warning by +// default, and allowed in cargo dependency builds. +// cc #30346 + +#[deny(raw_pointer_derive)] //~ WARN `raw_pointer_derive` has been removed +#[deny(unused_variables)] +fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/ui/compile-fail-migration/lint-removed.stderr b/src/test/ui/compile-fail-migration/lint-removed.stderr new file mode 100644 index 00000000000..7d66186f349 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-removed.stderr @@ -0,0 +1,22 @@ +warning: lint `raw_pointer_derive` has been removed: `using derive with raw pointers is ok` + --> $DIR/lint-removed.rs:16:8 + | +LL | #[deny(raw_pointer_derive)] //~ WARN `raw_pointer_derive` has been removed + | ^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(renamed_and_removed_lints)] on by default + +error: unused variable: `unused` + --> $DIR/lint-removed.rs:18:17 + | +LL | fn main() { let unused = (); } //~ ERROR unused + | ^^^^^^ help: consider using `_unused` instead + | +note: lint level defined here + --> $DIR/lint-removed.rs:17:8 + | +LL | #[deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-renamed-allow.rs b/src/test/ui/compile-fail-migration/lint-renamed-allow.rs new file mode 100644 index 00000000000..f6b94e89826 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-renamed-allow.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// No warnings about renamed lint when +// allow(renamed_and_removed_lints) + +#![allow(renamed_and_removed_lints)] + +#[deny(single_use_lifetime)] +#[deny(unused)] +fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/ui/compile-fail-migration/lint-renamed-allow.stderr b/src/test/ui/compile-fail-migration/lint-renamed-allow.stderr new file mode 100644 index 00000000000..6b2eb272701 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-renamed-allow.stderr @@ -0,0 +1,15 @@ +error: unused variable: `unused` + --> $DIR/lint-renamed-allow.rs:18:17 + | +LL | fn main() { let unused = (); } //~ ERROR unused + | ^^^^^^ help: consider using `_unused` instead + | +note: lint level defined here + --> $DIR/lint-renamed-allow.rs:17:8 + | +LL | #[deny(unused)] + | ^^^^^^ + = note: #[deny(unused_variables)] implied by #[deny(unused)] + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-renamed-cmdline.rs b/src/test/ui/compile-fail-migration/lint-renamed-cmdline.rs new file mode 100644 index 00000000000..f5abf2733b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-renamed-cmdline.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-D bare_trait_object + +// error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects` +// error-pattern:requested on the command line with `-D bare_trait_object` +// error-pattern:unused + +#[deny(unused)] +fn main() { let unused = (); } diff --git a/src/test/ui/compile-fail-migration/lint-renamed-cmdline.stderr b/src/test/ui/compile-fail-migration/lint-renamed-cmdline.stderr new file mode 100644 index 00000000000..5e154a0033d --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-renamed-cmdline.stderr @@ -0,0 +1,19 @@ +warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` + | + = note: requested on the command line with `-D bare_trait_object` + +error: unused variable: `unused` + --> $DIR/lint-renamed-cmdline.rs:18:17 + | +LL | fn main() { let unused = (); } + | ^^^^^^ help: consider using `_unused` instead + | +note: lint level defined here + --> $DIR/lint-renamed-cmdline.rs:17:8 + | +LL | #[deny(unused)] + | ^^^^^^ + = note: #[deny(unused_variables)] implied by #[deny(unused)] + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-renamed.rs b/src/test/ui/compile-fail-migration/lint-renamed.rs new file mode 100644 index 00000000000..c147ec5cf95 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-renamed.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[deny(bare_trait_object)] +//~^ WARN lint `bare_trait_object` has been renamed to `bare_trait_objects` +#[deny(unused)] +fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/ui/compile-fail-migration/lint-renamed.stderr b/src/test/ui/compile-fail-migration/lint-renamed.stderr new file mode 100644 index 00000000000..a87efc9e92c --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-renamed.stderr @@ -0,0 +1,23 @@ +warning: lint `bare_trait_object` has been renamed to `bare_trait_objects` + --> $DIR/lint-renamed.rs:11:8 + | +LL | #[deny(bare_trait_object)] + | ^^^^^^^^^^^^^^^^^ help: use the new name: `bare_trait_objects` + | + = note: #[warn(renamed_and_removed_lints)] on by default + +error: unused variable: `unused` + --> $DIR/lint-renamed.rs:14:17 + | +LL | fn main() { let unused = (); } //~ ERROR unused + | ^^^^^^ help: consider using `_unused` instead + | +note: lint level defined here + --> $DIR/lint-renamed.rs:13:8 + | +LL | #[deny(unused)] + | ^^^^^^ + = note: #[deny(unused_variables)] implied by #[deny(unused)] + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-shorthand-field.rs b/src/test/ui/compile-fail-migration/lint-shorthand-field.rs new file mode 100644 index 00000000000..97a976a493f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-shorthand-field.rs @@ -0,0 +1,64 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(bad_style, unused_variables)] +#![deny(non_shorthand_field_patterns)] + +struct Foo { + x: isize, + y: isize, +} + +fn main() { + { + let Foo { + x: x, //~ ERROR the `x:` in this pattern is redundant + y: ref y, //~ ERROR the `y:` in this pattern is redundant + } = Foo { x: 0, y: 0 }; + + let Foo { + x, + ref y, + } = Foo { x: 0, y: 0 }; + } + + { + const x: isize = 1; + + match (Foo { x: 1, y: 1 }) { + Foo { x: x, ..} => {}, + _ => {}, + } + } + + { + struct Bar { + x: x, + } + + struct x; + + match (Bar { x: x }) { + Bar { x: x } => {}, + } + } + + { + struct Bar { + x: Foo, + } + + enum Foo { x } + + match (Bar { x: Foo::x }) { + Bar { x: Foo::x } => {}, + } + } +} diff --git a/src/test/ui/compile-fail-migration/lint-shorthand-field.stderr b/src/test/ui/compile-fail-migration/lint-shorthand-field.stderr new file mode 100644 index 00000000000..516be532f5d --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-shorthand-field.stderr @@ -0,0 +1,24 @@ +error: the `x:` in this pattern is redundant + --> $DIR/lint-shorthand-field.rs:22:13 + | +LL | x: x, //~ ERROR the `x:` in this pattern is redundant + | --^^ + | | + | help: remove this + | +note: lint level defined here + --> $DIR/lint-shorthand-field.rs:12:9 + | +LL | #![deny(non_shorthand_field_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `y:` in this pattern is redundant + --> $DIR/lint-shorthand-field.rs:23:13 + | +LL | y: ref y, //~ ERROR the `y:` in this pattern is redundant + | --^^^^^^ + | | + | help: remove this + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-stability-2.rs b/src/test/ui/compile-fail-migration/lint-stability-2.rs new file mode 100644 index 00000000000..1f2fa077caf --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-2.rs @@ -0,0 +1,423 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_stability.rs +// aux-build:stability_cfg1.rs + +#![allow(deprecated)] +#![allow(dead_code)] +#![feature(staged_api)] + +#![stable(feature = "rust1", since = "1.0.0")] + +#[macro_use] +extern crate lint_stability; + +mod cross_crate { + extern crate stability_cfg1; + + use lint_stability::*; + + fn test() { + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); + foo.method_deprecated(); + Foo::method_deprecated(&foo); + ::method_deprecated(&foo); + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + + deprecated_text(); + foo.method_deprecated_text(); + Foo::method_deprecated_text(&foo); + ::method_deprecated_text(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + + foo.method_deprecated_unstable(); + //~^ ERROR use of unstable library feature + Foo::method_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + ::method_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + foo.trait_deprecated_unstable(); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + + foo.method_deprecated_unstable_text(); + //~^ ERROR use of unstable library feature + Foo::method_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + ::method_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + foo.trait_deprecated_unstable_text(); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + + foo.method_unstable(); //~ ERROR use of unstable library feature + Foo::method_unstable(&foo); //~ ERROR use of unstable library feature + ::method_unstable(&foo); //~ ERROR use of unstable library feature + foo.trait_unstable(); //~ ERROR use of unstable library feature + ::trait_unstable(&foo); //~ ERROR use of unstable library feature + + foo.method_unstable_text(); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + Foo::method_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + ::method_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + foo.trait_unstable_text(); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + ::trait_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + + stable(); + foo.method_stable(); + Foo::method_stable(&foo); + ::method_stable(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + + stable_text(); + foo.method_stable_text(); + Foo::method_stable_text(&foo); + ::method_stable_text(&foo); + foo.trait_stable_text(); + Trait::trait_stable_text(&foo); + ::trait_stable_text(&foo); + ::trait_stable_text(&foo); + + struct S2(T::TypeDeprecated); + + let _ = DeprecatedStruct { + i: 0 + }; + let _ = StableStruct { i: 0 }; + + let _ = DeprecatedUnitStruct; + let _ = StableUnitStruct; + + let _ = Enum::DeprecatedVariant; + let _ = Enum::StableVariant; + + let _ = DeprecatedTupleStruct (1); + let _ = StableTupleStruct (1); + + // At the moment, the lint checker only checks stability in + // in the arguments of macros. + // Eventually, we will want to lint the contents of the + // macro in the module *defining* it. Also, stability levels + // on macros themselves are not yet linted. + macro_test_arg!(deprecated_text()); + macro_test_arg!(macro_test_arg!(deprecated_text())); + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + foo.trait_deprecated_unstable(); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + foo.trait_deprecated_unstable_text(); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + foo.trait_unstable(); //~ ERROR use of unstable library feature + ::trait_unstable(&foo); //~ ERROR use of unstable library feature + foo.trait_unstable_text(); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + ::trait_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); + foo.trait_deprecated_text(); + foo.trait_deprecated_unstable(); + //~^ ERROR use of unstable library feature + foo.trait_deprecated_unstable_text(); + //~^ ERROR use of unstable library feature + foo.trait_unstable(); //~ ERROR use of unstable library feature + foo.trait_unstable_text(); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + foo.trait_stable(); + } + + struct S; + + impl DeprecatedTrait for S {} + trait LocalTrait2 : DeprecatedTrait { } +} + +mod this_crate { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn deprecated() {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn deprecated_text() {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn unstable() {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + pub fn unstable_text() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable() {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable_text() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub struct MethodTester; + + impl MethodTester { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn method_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + pub fn method_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable_text(&self) {} + } + + pub trait Trait { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + fn trait_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + fn trait_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable_text(&self) {} + } + + impl Trait for MethodTester {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedUnitStruct; + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableUnitStruct; + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableUnitStruct; + + pub enum Enum { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + DeprecatedVariant, + #[unstable(feature = "unstable_test_feature", issue = "0")] + UnstableVariant, + + #[stable(feature = "rust1", since = "1.0.0")] + StableVariant, + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedTupleStruct(isize); + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableTupleStruct(isize); + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableTupleStruct(isize); + + fn test() { + // Only the deprecated cases of the following should generate + // errors, because other stability attributes now have meaning + // only *across* crates, not within a single crate. + + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); + foo.method_deprecated(); + Foo::method_deprecated(&foo); + ::method_deprecated(&foo); + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + + deprecated_text(); + foo.method_deprecated_text(); + Foo::method_deprecated_text(&foo); + ::method_deprecated_text(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + + unstable(); + foo.method_unstable(); + Foo::method_unstable(&foo); + ::method_unstable(&foo); + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + + unstable_text(); + foo.method_unstable_text(); + Foo::method_unstable_text(&foo); + ::method_unstable_text(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + + stable(); + foo.method_stable(); + Foo::method_stable(&foo); + ::method_stable(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + + stable_text(); + foo.method_stable_text(); + Foo::method_stable_text(&foo); + ::method_stable_text(&foo); + foo.trait_stable_text(); + Trait::trait_stable_text(&foo); + ::trait_stable_text(&foo); + ::trait_stable_text(&foo); + + let _ = DeprecatedStruct { + i: 0 + }; + let _ = UnstableStruct { i: 0 }; + let _ = StableStruct { i: 0 }; + + let _ = DeprecatedUnitStruct; + let _ = UnstableUnitStruct; + let _ = StableUnitStruct; + + let _ = Enum::DeprecatedVariant; + let _ = Enum::UnstableVariant; + let _ = Enum::StableVariant; + + let _ = DeprecatedTupleStruct (1); + let _ = UnstableTupleStruct (1); + let _ = StableTupleStruct (1); + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); + foo.trait_deprecated_text(); + foo.trait_unstable(); + foo.trait_unstable_text(); + foo.trait_stable(); + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn test_fn_body() { + fn fn_in_body() {} + fn_in_body(); + } + + impl MethodTester { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn test_method_body(&self) { + fn fn_in_body() {} + fn_in_body(); + } + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub trait DeprecatedTrait { + fn dummy(&self) { } + } + + struct S; + + impl DeprecatedTrait for S { } + + trait LocalTrait : DeprecatedTrait { } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-stability-2.stderr b/src/test/ui/compile-fail-migration/lint-stability-2.stderr new file mode 100644 index 00000000000..e87e0514433 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-2.stderr @@ -0,0 +1,259 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:50:13 + | +LL | foo.method_deprecated_unstable(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:52:9 + | +LL | Foo::method_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:54:9 + | +LL | ::method_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:56:13 + | +LL | foo.trait_deprecated_unstable(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:58:9 + | +LL | ::trait_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:61:13 + | +LL | foo.method_deprecated_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:63:9 + | +LL | Foo::method_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:65:9 + | +LL | ::method_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:67:13 + | +LL | foo.trait_deprecated_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:69:9 + | +LL | ::trait_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:72:13 + | +LL | foo.method_unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:73:9 + | +LL | Foo::method_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:74:9 + | +LL | ::method_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:75:13 + | +LL | foo.trait_unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:76:9 + | +LL | ::trait_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:78:13 + | +LL | foo.method_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:80:9 + | +LL | Foo::method_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:82:9 + | +LL | ::method_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:84:13 + | +LL | foo.trait_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:86:9 + | +LL | ::trait_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:141:13 + | +LL | foo.trait_deprecated_unstable(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:143:9 + | +LL | ::trait_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:145:13 + | +LL | foo.trait_deprecated_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:147:9 + | +LL | ::trait_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:149:13 + | +LL | foo.trait_unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:150:9 + | +LL | ::trait_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:151:13 + | +LL | foo.trait_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:153:9 + | +LL | ::trait_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:164:13 + | +LL | foo.trait_deprecated_unstable(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:166:13 + | +LL | foo.trait_deprecated_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-2.rs:168:13 + | +LL | foo.trait_unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability-2.rs:169:13 + | +LL | foo.trait_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error: aborting due to 32 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/lint-stability-deprecated.rs b/src/test/ui/compile-fail-migration/lint-stability-deprecated.rs new file mode 100644 index 00000000000..de2c27bdcbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-deprecated.rs @@ -0,0 +1,473 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_stability.rs +// aux-build:inherited_stability.rs +// aux-build:stability_cfg1.rs +// aux-build:stability_cfg2.rs +// ignore-tidy-linelength + +#![warn(deprecated)] +#![allow(dead_code, unused_extern_crates)] +#![feature(staged_api, unstable_test_feature, rustc_attrs)] + +#![stable(feature = "rust1", since = "1.0.0")] + +#[macro_use] +extern crate lint_stability; + +mod cross_crate { + extern crate stability_cfg1; + extern crate stability_cfg2; + + use lint_stability::*; + + fn test() { + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); //~ WARN use of deprecated item 'lint_stability::deprecated' + foo.method_deprecated(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' + Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' + ::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' + foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + + deprecated_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text + foo.method_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + ::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + + deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable' + foo.method_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' + Foo::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' + ::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' + foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + + deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text + foo.method_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + Foo::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + ::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + + unstable(); + foo.method_unstable(); + Foo::method_unstable(&foo); + ::method_unstable(&foo); + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + + unstable_text(); + foo.method_unstable_text(); + Foo::method_unstable_text(&foo); + ::method_unstable_text(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + + stable(); + foo.method_stable(); + Foo::method_stable(&foo); + ::method_stable(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + + stable_text(); + foo.method_stable_text(); + Foo::method_stable_text(&foo); + ::method_stable_text(&foo); + foo.trait_stable_text(); + Trait::trait_stable_text(&foo); + ::trait_stable_text(&foo); + ::trait_stable_text(&foo); + + struct S1(T::TypeUnstable); + struct S2(T::TypeDeprecated); + //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated': text + type A = TraitWithAssociatedTypes< + TypeUnstable = u8, + TypeDeprecated = u16, + //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated' + >; + + let _ = DeprecatedStruct { //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct' + i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct::i' + }; + let _ = DeprecatedUnstableStruct { + //~^ WARN use of deprecated item 'lint_stability::DeprecatedUnstableStruct' + i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableStruct::i' + }; + let _ = UnstableStruct { i: 0 }; + let _ = StableStruct { i: 0 }; + + let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnitStruct' + let _ = DeprecatedUnstableUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableUnitStruct' + let _ = UnstableUnitStruct; + let _ = StableUnitStruct; + + let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedVariant' + let _ = Enum::DeprecatedUnstableVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedUnstableVariant' + let _ = Enum::UnstableVariant; + let _ = Enum::StableVariant; + + let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedTupleStruct' + let _ = DeprecatedUnstableTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableTupleStruct' + let _ = UnstableTupleStruct (1); + let _ = StableTupleStruct (1); + + // At the moment, the lint checker only checks stability in + // in the arguments of macros. + // Eventually, we will want to lint the contents of the + // macro in the module *defining* it. Also, stability levels + // on macros themselves are not yet linted. + macro_test_arg!(deprecated_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text + macro_test_arg!(deprecated_unstable_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text + macro_test_arg!(macro_test_arg!(deprecated_text())); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + foo.trait_unstable(); + foo.trait_unstable_text(); + foo.trait_stable(); + } + + struct S; + + impl UnstableTrait for S { } + impl DeprecatedTrait for S {} //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text + trait LocalTrait : UnstableTrait { } + trait LocalTrait2 : DeprecatedTrait { } //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text + + impl Trait for S { + fn trait_stable(&self) {} + fn trait_unstable(&self) {} + } +} + +mod inheritance { + extern crate inherited_stability; + use self::inherited_stability::*; + + fn test_inheritance() { + unstable(); + stable(); + + stable_mod::unstable(); + stable_mod::stable(); + + unstable_mod::deprecated(); //~ WARN use of deprecated item 'inheritance::inherited_stability::unstable_mod::deprecated': text + unstable_mod::unstable(); + + let _ = Unstable::UnstableVariant; + let _ = Unstable::StableVariant; + + let x: usize = 0; + x.unstable(); + x.stable(); + } +} + +mod this_crate { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn deprecated() {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn deprecated_text() {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn unstable() {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + pub fn unstable_text() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable() {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable_text() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub struct MethodTester; + + impl MethodTester { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn method_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + pub fn method_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable_text(&self) {} + } + + pub trait Trait { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + fn trait_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + fn trait_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable_text(&self) {} + } + + impl Trait for MethodTester {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedUnitStruct; + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableUnitStruct; + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableUnitStruct; + + pub enum Enum { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + DeprecatedVariant, + #[unstable(feature = "unstable_test_feature", issue = "0")] + UnstableVariant, + + #[stable(feature = "rust1", since = "1.0.0")] + StableVariant, + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedTupleStruct(isize); + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableTupleStruct(isize); + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableTupleStruct(isize); + + fn test() { + // Only the deprecated cases of the following should generate + // errors, because other stability attributes now have meaning + // only *across* crates, not within a single crate. + + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); //~ WARN use of deprecated item 'this_crate::deprecated' + foo.method_deprecated(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' + Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' + ::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' + foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + + deprecated_text(); //~ WARN use of deprecated item 'this_crate::deprecated_text': text + foo.method_deprecated_text(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + ::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + + unstable(); + foo.method_unstable(); + Foo::method_unstable(&foo); + ::method_unstable(&foo); + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + + unstable_text(); + foo.method_unstable_text(); + Foo::method_unstable_text(&foo); + ::method_unstable_text(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + + stable(); + foo.method_stable(); + Foo::method_stable(&foo); + ::method_stable(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + + stable_text(); + foo.method_stable_text(); + Foo::method_stable_text(&foo); + ::method_stable_text(&foo); + foo.trait_stable_text(); + Trait::trait_stable_text(&foo); + ::trait_stable_text(&foo); + ::trait_stable_text(&foo); + + let _ = DeprecatedStruct { + //~^ WARN use of deprecated item 'this_crate::DeprecatedStruct' + i: 0 //~ WARN use of deprecated item 'this_crate::DeprecatedStruct::i' + }; + let _ = UnstableStruct { i: 0 }; + let _ = StableStruct { i: 0 }; + + let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'this_crate::DeprecatedUnitStruct' + let _ = UnstableUnitStruct; + let _ = StableUnitStruct; + + let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'this_crate::Enum::DeprecatedVariant' + let _ = Enum::UnstableVariant; + let _ = Enum::StableVariant; + + let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'this_crate::DeprecatedTupleStruct' + let _ = UnstableTupleStruct (1); + let _ = StableTupleStruct (1); + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + foo.trait_unstable(); + foo.trait_unstable_text(); + foo.trait_stable(); + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn test_fn_body() { + fn fn_in_body() {} + fn_in_body(); //~ WARN use of deprecated item 'this_crate::test_fn_body::fn_in_body': text + } + + impl MethodTester { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn test_method_body(&self) { + fn fn_in_body() {} + fn_in_body(); //~ WARN use of deprecated item 'this_crate::MethodTester::test_method_body::fn_in_body': text + } + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub trait DeprecatedTrait { + fn dummy(&self) { } + } + + struct S; + + impl DeprecatedTrait for S { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait' + + trait LocalTrait : DeprecatedTrait { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait' +} + +#[rustc_error] fn main() {} //~ ERROR: compilation successful diff --git a/src/test/ui/compile-fail-migration/lint-stability-deprecated.stderr b/src/test/ui/compile-fail-migration/lint-stability-deprecated.stderr new file mode 100644 index 00000000000..afebb4f36a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-deprecated.stderr @@ -0,0 +1,644 @@ +warning: use of deprecated item 'lint_stability::deprecated': text + --> $DIR/lint-stability-deprecated.rs:36:9 + | +LL | deprecated(); //~ WARN use of deprecated item 'lint_stability::deprecated' + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-stability-deprecated.rs:17:9 + | +LL | #![warn(deprecated)] + | ^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:41:9 + | +LL | Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:43:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:45:9 + | +LL | deprecated_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:50:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:52:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:54:9 + | +LL | deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:59:9 + | +LL | Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:61:9 + | +LL | ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:63:9 + | +LL | deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:68:9 + | +LL | Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:70:9 + | +LL | ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedStruct': text + --> $DIR/lint-stability-deprecated.rs:117:17 + | +LL | let _ = DeprecatedStruct { //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct' + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedUnstableStruct': text + --> $DIR/lint-stability-deprecated.rs:120:17 + | +LL | let _ = DeprecatedUnstableStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedUnitStruct': text + --> $DIR/lint-stability-deprecated.rs:127:17 + | +LL | let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnitStruct' + | ^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedUnstableUnitStruct': text + --> $DIR/lint-stability-deprecated.rs:128:17 + | +LL | let _ = DeprecatedUnstableUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableUnitStruct' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Enum::DeprecatedVariant': text + --> $DIR/lint-stability-deprecated.rs:132:17 + | +LL | let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedVariant' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Enum::DeprecatedUnstableVariant': text + --> $DIR/lint-stability-deprecated.rs:133:17 + | +LL | let _ = Enum::DeprecatedUnstableVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedUnstableVariant' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedTupleStruct': text + --> $DIR/lint-stability-deprecated.rs:137:17 + | +LL | let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedTupleStruct' + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedUnstableTupleStruct': text + --> $DIR/lint-stability-deprecated.rs:138:17 + | +LL | let _ = DeprecatedUnstableTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableTupleStruct' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:147:25 + | +LL | macro_test_arg!(deprecated_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:148:25 + | +LL | macro_test_arg!(deprecated_unstable_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:149:41 + | +LL | macro_test_arg!(macro_test_arg!(deprecated_text())); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:154:9 + | +LL | Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:156:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:158:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:160:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:162:9 + | +LL | Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:164:9 + | +LL | ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:166:9 + | +LL | Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:168:9 + | +LL | ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedTrait': text + --> $DIR/lint-stability-deprecated.rs:196:10 + | +LL | impl DeprecatedTrait for S {} //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedTrait': text + --> $DIR/lint-stability-deprecated.rs:198:25 + | +LL | trait LocalTrait2 : DeprecatedTrait { } //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'inheritance::inherited_stability::unstable_mod::deprecated': text + --> $DIR/lint-stability-deprecated.rs:217:9 + | +LL | unstable_mod::deprecated(); //~ WARN use of deprecated item 'inheritance::inherited_stability::unstable_mod::deprecated': text + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::deprecated': text + --> $DIR/lint-stability-deprecated.rs:339:9 + | +LL | deprecated(); //~ WARN use of deprecated item 'this_crate::deprecated' + | ^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:344:9 + | +LL | Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:346:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:348:9 + | +LL | deprecated_text(); //~ WARN use of deprecated item 'this_crate::deprecated_text': text + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:353:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:355:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::DeprecatedStruct': text + --> $DIR/lint-stability-deprecated.rs:393:17 + | +LL | let _ = DeprecatedStruct { + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::DeprecatedUnitStruct': text + --> $DIR/lint-stability-deprecated.rs:400:17 + | +LL | let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'this_crate::DeprecatedUnitStruct' + | ^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Enum::DeprecatedVariant': text + --> $DIR/lint-stability-deprecated.rs:404:17 + | +LL | let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'this_crate::Enum::DeprecatedVariant' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::DeprecatedTupleStruct': text + --> $DIR/lint-stability-deprecated.rs:408:17 + | +LL | let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'this_crate::DeprecatedTupleStruct' + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:415:9 + | +LL | Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:417:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:419:9 + | +LL | Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:421:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::test_fn_body::fn_in_body': text + --> $DIR/lint-stability-deprecated.rs:448:9 + | +LL | fn_in_body(); //~ WARN use of deprecated item 'this_crate::test_fn_body::fn_in_body': text + | ^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::DeprecatedTrait': text + --> $DIR/lint-stability-deprecated.rs:468:10 + | +LL | impl DeprecatedTrait for S { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait' + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::DeprecatedTrait': text + --> $DIR/lint-stability-deprecated.rs:470:24 + | +LL | trait LocalTrait : DeprecatedTrait { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait' + | ^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::MethodTester::test_method_body::fn_in_body': text + --> $DIR/lint-stability-deprecated.rs:456:13 + | +LL | fn_in_body(); //~ WARN use of deprecated item 'this_crate::MethodTester::test_method_body::fn_in_body': text + | ^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated': text + --> $DIR/lint-stability-deprecated.rs:109:48 + | +LL | struct S2(T::TypeDeprecated); + | ^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated': text + --> $DIR/lint-stability-deprecated.rs:113:13 + | +LL | TypeDeprecated = u16, + | ^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated': text + --> $DIR/lint-stability-deprecated.rs:37:13 + | +LL | foo.method_deprecated(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated': text + --> $DIR/lint-stability-deprecated.rs:38:9 + | +LL | Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated': text + --> $DIR/lint-stability-deprecated.rs:39:9 + | +LL | ::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:40:13 + | +LL | foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:42:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:46:13 + | +LL | foo.method_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:47:9 + | +LL | Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:48:9 + | +LL | ::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:49:13 + | +LL | foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:51:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:55:13 + | +LL | foo.method_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:56:9 + | +LL | Foo::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:57:9 + | +LL | ::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:58:13 + | +LL | foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:60:9 + | +LL | ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:64:13 + | +LL | foo.method_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:65:9 + | +LL | Foo::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:66:9 + | +LL | ::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:67:13 + | +LL | foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:69:9 + | +LL | ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedStruct::i': text + --> $DIR/lint-stability-deprecated.rs:118:13 + | +LL | i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct::i' + | ^^^^ + +warning: use of deprecated item 'lint_stability::DeprecatedUnstableStruct::i': text + --> $DIR/lint-stability-deprecated.rs:122:13 + | +LL | i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableStruct::i' + | ^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:153:13 + | +LL | foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:155:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:157:13 + | +LL | foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:159:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:161:13 + | +LL | foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:163:9 + | +LL | ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:165:13 + | +LL | foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:167:9 + | +LL | ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:184:13 + | +LL | foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:185:13 + | +LL | foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable': text + --> $DIR/lint-stability-deprecated.rs:186:13 + | +LL | foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + --> $DIR/lint-stability-deprecated.rs:187:13 + | +LL | foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::MethodTester::method_deprecated': text + --> $DIR/lint-stability-deprecated.rs:340:13 + | +LL | foo.method_deprecated(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::MethodTester::method_deprecated': text + --> $DIR/lint-stability-deprecated.rs:341:9 + | +LL | Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::MethodTester::method_deprecated': text + --> $DIR/lint-stability-deprecated.rs:342:9 + | +LL | ::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:343:13 + | +LL | foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:345:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:349:13 + | +LL | foo.method_deprecated_text(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:350:9 + | +LL | Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:351:9 + | +LL | ::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:352:13 + | +LL | foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:354:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::DeprecatedStruct::i': text + --> $DIR/lint-stability-deprecated.rs:395:13 + | +LL | i: 0 //~ WARN use of deprecated item 'this_crate::DeprecatedStruct::i' + | ^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:414:13 + | +LL | foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:416:9 + | +LL | ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:418:13 + | +LL | foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:420:9 + | +LL | ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated': text + --> $DIR/lint-stability-deprecated.rs:437:13 + | +LL | foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' + | ^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + --> $DIR/lint-stability-deprecated.rs:438:13 + | +LL | foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text + | ^^^^^^^^^^^^^^^^^^^^^ + +error: compilation successful + --> $DIR/lint-stability-deprecated.rs:473:16 + | +LL | #[rustc_error] fn main() {} //~ ERROR: compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.rs b/src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.rs new file mode 100644 index 00000000000..0ad4466d0e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.rs @@ -0,0 +1,349 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_stability_fields.rs + +#![deny(deprecated)] +#![allow(dead_code)] +#![feature(staged_api, unstable_test_feature)] + +#![stable(feature = "rust1", since = "1.0.0")] + +mod cross_crate { + extern crate lint_stability_fields; + + use self::lint_stability_fields::*; + + pub fn foo() { + let x = Stable { + inherit: 1, + override1: 2, + override2: 3, + //~^ ERROR use of deprecated item + }; + + let _ = x.inherit; + let _ = x.override1; + let _ = x.override2; + //~^ ERROR use of deprecated item + + let Stable { + inherit: _, + override1: _, + override2: _ + //~^ ERROR use of deprecated item + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.0; + let _ = x.1; + let _ = x.2; + //~^ ERROR use of deprecated item + + let Stable2(_, + _, + _) + //~^ ERROR use of deprecated item + = x; + // all fine + let Stable2(..) = x; + + + let x = Unstable { + inherit: 1, + override1: 2, + override2: 3, + //~^ ERROR use of deprecated item + }; + + let _ = x.inherit; + let _ = x.override1; + let _ = x.override2; + //~^ ERROR use of deprecated item + + let Unstable { + inherit: _, + override1: _, + override2: _ + //~^ ERROR use of deprecated item + } = x; + + let Unstable + // the patterns are all fine: + { .. } = x; + + + let x = Unstable2(1, 2, 3); + + let _ = x.0; + let _ = x.1; + let _ = x.2; + //~^ ERROR use of deprecated item + + let Unstable2 + (_, + _, + _) + //~^ ERROR use of deprecated item + = x; + let Unstable2 + // the patterns are all fine: + (..) = x; + + + let x = Deprecated { + //~^ ERROR use of deprecated item + inherit: 1, + //~^ ERROR use of deprecated item + override1: 2, + //~^ ERROR use of deprecated item + override2: 3, + //~^ ERROR use of deprecated item + }; + + let _ = x.inherit; + //~^ ERROR use of deprecated item + let _ = x.override1; + //~^ ERROR use of deprecated item + let _ = x.override2; + //~^ ERROR use of deprecated item + + let Deprecated { + //~^ ERROR use of deprecated item + inherit: _, + //~^ ERROR use of deprecated item + override1: _, + //~^ ERROR use of deprecated item + override2: _ + //~^ ERROR use of deprecated item + } = x; + + let Deprecated + //~^ ERROR use of deprecated item + // the patterns are all fine: + { .. } = x; + + let x = Deprecated2(1, 2, 3); + //~^ ERROR use of deprecated item + + let _ = x.0; + //~^ ERROR use of deprecated item + let _ = x.1; + //~^ ERROR use of deprecated item + let _ = x.2; + //~^ ERROR use of deprecated item + + let Deprecated2 + //~^ ERROR use of deprecated item + (_, + //~^ ERROR use of deprecated item + _, + //~^ ERROR use of deprecated item + _) + //~^ ERROR use of deprecated item + = x; + let Deprecated2 + //~^ ERROR use of deprecated item + // the patterns are all fine: + (..) = x; + } +} + +mod this_crate { + #[stable(feature = "rust1", since = "1.0.0")] + struct Stable { + inherit: u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + override1: u8, + #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[unstable(feature = "unstable_test_feature", issue = "0")] + override2: u8, + } + + #[stable(feature = "rust1", since = "1.0.0")] + struct Stable2(u8, + #[stable(feature = "rust1", since = "1.0.0")] u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + + #[unstable(feature = "unstable_test_feature", issue = "0")] + struct Unstable { + inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + override1: u8, + #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[unstable(feature = "unstable_test_feature", issue = "0")] + override2: u8, + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + struct Unstable2(u8, + #[stable(feature = "rust1", since = "1.0.0")] u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + struct Deprecated { + inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + override1: u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + override2: u8, + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + struct Deprecated2(u8, + #[stable(feature = "rust1", since = "1.0.0")] u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] u8); + + pub fn foo() { + let x = Stable { + inherit: 1, + override1: 2, + override2: 3, + //~^ ERROR use of deprecated item + }; + + let _ = x.inherit; + let _ = x.override1; + let _ = x.override2; + //~^ ERROR use of deprecated item + + let Stable { + inherit: _, + override1: _, + override2: _ + //~^ ERROR use of deprecated item + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.0; + let _ = x.1; + let _ = x.2; + //~^ ERROR use of deprecated item + + let Stable2(_, + _, + _) + //~^ ERROR use of deprecated item + = x; + // all fine + let Stable2(..) = x; + + + let x = Unstable { + inherit: 1, + override1: 2, + override2: 3, + //~^ ERROR use of deprecated item + }; + + let _ = x.inherit; + let _ = x.override1; + let _ = x.override2; + //~^ ERROR use of deprecated item + + let Unstable { + inherit: _, + override1: _, + override2: _ + //~^ ERROR use of deprecated item + } = x; + + let Unstable + // the patterns are all fine: + { .. } = x; + + + let x = Unstable2(1, 2, 3); + + let _ = x.0; + let _ = x.1; + let _ = x.2; + //~^ ERROR use of deprecated item + + let Unstable2 + (_, + _, + _) + //~^ ERROR use of deprecated item + = x; + let Unstable2 + // the patterns are all fine: + (..) = x; + + + let x = Deprecated { + //~^ ERROR use of deprecated item + inherit: 1, + //~^ ERROR use of deprecated item + override1: 2, + //~^ ERROR use of deprecated item + override2: 3, + //~^ ERROR use of deprecated item + }; + + let _ = x.inherit; + //~^ ERROR use of deprecated item + let _ = x.override1; + //~^ ERROR use of deprecated item + let _ = x.override2; + //~^ ERROR use of deprecated item + + let Deprecated { + //~^ ERROR use of deprecated item + inherit: _, + //~^ ERROR use of deprecated item + override1: _, + //~^ ERROR use of deprecated item + override2: _ + //~^ ERROR use of deprecated item + } = x; + + let Deprecated + //~^ ERROR use of deprecated item + // the patterns are all fine: + { .. } = x; + + let x = Deprecated2(1, 2, 3); + //~^ ERROR use of deprecated item + + let _ = x.0; + //~^ ERROR use of deprecated item + let _ = x.1; + //~^ ERROR use of deprecated item + let _ = x.2; + //~^ ERROR use of deprecated item + + let Deprecated2 + //~^ ERROR use of deprecated item + (_, + //~^ ERROR use of deprecated item + _, + //~^ ERROR use of deprecated item + _) + //~^ ERROR use of deprecated item + = x; + let Deprecated2 + //~^ ERROR use of deprecated item + // the patterns are all fine: + (..) = x; + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.stderr b/src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.stderr new file mode 100644 index 00000000000..f7bc87ee9d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-fields-deprecated.stderr @@ -0,0 +1,380 @@ +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated': text + --> $DIR/lint-stability-fields-deprecated.rs:104:17 + | +LL | let x = Deprecated { + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-stability-fields-deprecated.rs:13:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated': text + --> $DIR/lint-stability-fields-deprecated.rs:121:13 + | +LL | let Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated': text + --> $DIR/lint-stability-fields-deprecated.rs:131:13 + | +LL | let Deprecated + | ^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2': text + --> $DIR/lint-stability-fields-deprecated.rs:136:17 + | +LL | let x = Deprecated2(1, 2, 3); + | ^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2': text + --> $DIR/lint-stability-fields-deprecated.rs:146:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2': text + --> $DIR/lint-stability-fields-deprecated.rs:155:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated': text + --> $DIR/lint-stability-fields-deprecated.rs:291:17 + | +LL | let x = Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated': text + --> $DIR/lint-stability-fields-deprecated.rs:308:13 + | +LL | let Deprecated { + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated': text + --> $DIR/lint-stability-fields-deprecated.rs:318:13 + | +LL | let Deprecated + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated2': text + --> $DIR/lint-stability-fields-deprecated.rs:323:17 + | +LL | let x = Deprecated2(1, 2, 3); + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated2': text + --> $DIR/lint-stability-fields-deprecated.rs:333:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated2': text + --> $DIR/lint-stability-fields-deprecated.rs:342:13 + | +LL | let Deprecated2 + | ^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Stable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:28:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Stable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:34:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Stable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:40:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Stable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:50:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Stable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:55:20 + | +LL | _) + | ^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Unstable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:65:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Unstable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:71:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Unstable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:77:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Unstable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:90:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Unstable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:96:14 + | +LL | _) + | ^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::inherit': text + --> $DIR/lint-stability-fields-deprecated.rs:106:13 + | +LL | inherit: 1, + | ^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::override1': text + --> $DIR/lint-stability-fields-deprecated.rs:108:13 + | +LL | override1: 2, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:110:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::inherit': text + --> $DIR/lint-stability-fields-deprecated.rs:114:17 + | +LL | let _ = x.inherit; + | ^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::override1': text + --> $DIR/lint-stability-fields-deprecated.rs:116:17 + | +LL | let _ = x.override1; + | ^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:118:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::inherit': text + --> $DIR/lint-stability-fields-deprecated.rs:123:13 + | +LL | inherit: _, + | ^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::override1': text + --> $DIR/lint-stability-fields-deprecated.rs:125:13 + | +LL | override1: _, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:127:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2::0': text + --> $DIR/lint-stability-fields-deprecated.rs:139:17 + | +LL | let _ = x.0; + | ^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2::1': text + --> $DIR/lint-stability-fields-deprecated.rs:141:17 + | +LL | let _ = x.1; + | ^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:143:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2::0': text + --> $DIR/lint-stability-fields-deprecated.rs:148:14 + | +LL | (_, + | ^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2::1': text + --> $DIR/lint-stability-fields-deprecated.rs:150:14 + | +LL | _, + | ^ + +error: use of deprecated item 'cross_crate::lint_stability_fields::Deprecated2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:152:14 + | +LL | _) + | ^ + +error: use of deprecated item 'this_crate::Stable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:215:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Stable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:221:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Stable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:227:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Stable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:237:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'this_crate::Stable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:242:20 + | +LL | _) + | ^ + +error: use of deprecated item 'this_crate::Unstable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:252:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Unstable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:258:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Unstable::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:264:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Unstable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:277:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'this_crate::Unstable2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:283:14 + | +LL | _) + | ^ + +error: use of deprecated item 'this_crate::Deprecated::inherit': text + --> $DIR/lint-stability-fields-deprecated.rs:293:13 + | +LL | inherit: 1, + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::override1': text + --> $DIR/lint-stability-fields-deprecated.rs:295:13 + | +LL | override1: 2, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:297:13 + | +LL | override2: 3, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::inherit': text + --> $DIR/lint-stability-fields-deprecated.rs:301:17 + | +LL | let _ = x.inherit; + | ^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::override1': text + --> $DIR/lint-stability-fields-deprecated.rs:303:17 + | +LL | let _ = x.override1; + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:305:17 + | +LL | let _ = x.override2; + | ^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::inherit': text + --> $DIR/lint-stability-fields-deprecated.rs:310:13 + | +LL | inherit: _, + | ^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::override1': text + --> $DIR/lint-stability-fields-deprecated.rs:312:13 + | +LL | override1: _, + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated::override2': text + --> $DIR/lint-stability-fields-deprecated.rs:314:13 + | +LL | override2: _ + | ^^^^^^^^^^^^ + +error: use of deprecated item 'this_crate::Deprecated2::0': text + --> $DIR/lint-stability-fields-deprecated.rs:326:17 + | +LL | let _ = x.0; + | ^^^ + +error: use of deprecated item 'this_crate::Deprecated2::1': text + --> $DIR/lint-stability-fields-deprecated.rs:328:17 + | +LL | let _ = x.1; + | ^^^ + +error: use of deprecated item 'this_crate::Deprecated2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:330:17 + | +LL | let _ = x.2; + | ^^^ + +error: use of deprecated item 'this_crate::Deprecated2::0': text + --> $DIR/lint-stability-fields-deprecated.rs:335:14 + | +LL | (_, + | ^ + +error: use of deprecated item 'this_crate::Deprecated2::1': text + --> $DIR/lint-stability-fields-deprecated.rs:337:14 + | +LL | _, + | ^ + +error: use of deprecated item 'this_crate::Deprecated2::2': text + --> $DIR/lint-stability-fields-deprecated.rs:339:14 + | +LL | _) + | ^ + +error: aborting due to 62 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-stability-fields.rs b/src/test/ui/compile-fail-migration/lint-stability-fields.rs new file mode 100644 index 00000000000..db6b64dabfe --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-fields.rs @@ -0,0 +1,293 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_stability_fields.rs +#![allow(deprecated)] +#![allow(dead_code)] +#![feature(staged_api)] + +#![stable(feature = "rust1", since = "1.0.0")] + +mod cross_crate { + extern crate lint_stability_fields; + + mod reexport { + #[stable(feature = "rust1", since = "1.0.0")] + pub use super::lint_stability_fields::*; + } + + use self::lint_stability_fields::*; + + pub fn foo() { + let x = Stable { + inherit: 1, + override1: 2, //~ ERROR use of unstable + override2: 3, //~ ERROR use of unstable + }; + + let _ = x.inherit; + let _ = x.override1; //~ ERROR use of unstable + let _ = x.override2; //~ ERROR use of unstable + + let Stable { + inherit: _, + override1: _, //~ ERROR use of unstable + override2: _ //~ ERROR use of unstable + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.0; + let _ = x.1; //~ ERROR use of unstable + let _ = x.2; //~ ERROR use of unstable + + let Stable2(_, + _, //~ ERROR use of unstable + _) //~ ERROR use of unstable + = x; + // all fine + let Stable2(..) = x; + + + let x = Unstable { //~ ERROR use of unstable + inherit: 1, //~ ERROR use of unstable + override1: 2, + override2: 3, //~ ERROR use of unstable + }; + + let _ = x.inherit; //~ ERROR use of unstable + let _ = x.override1; + let _ = x.override2; //~ ERROR use of unstable + + let Unstable { //~ ERROR use of unstable + inherit: _, //~ ERROR use of unstable + override1: _, + override2: _ //~ ERROR use of unstable + } = x; + + let Unstable //~ ERROR use of unstable + // the patterns are all fine: + { .. } = x; + + // Unstable items are still unstable even when used through a stable "pub use". + let x = reexport::Unstable2(1, 2, 3); //~ ERROR use of unstable + + let x = Unstable2(1, 2, 3); //~ ERROR use of unstable + + let _ = x.0; //~ ERROR use of unstable + let _ = x.1; + let _ = x.2; //~ ERROR use of unstable + + let Unstable2 //~ ERROR use of unstable + (_, //~ ERROR use of unstable + _, + _) //~ ERROR use of unstable + = x; + let Unstable2 //~ ERROR use of unstable + // the patterns are all fine: + (..) = x; + + + let x = Deprecated { //~ ERROR use of unstable + inherit: 1, //~ ERROR use of unstable + override1: 2, + override2: 3, //~ ERROR use of unstable + }; + + let _ = x.inherit; //~ ERROR use of unstable + let _ = x.override1; + let _ = x.override2; //~ ERROR use of unstable + + let Deprecated { //~ ERROR use of unstable + inherit: _, //~ ERROR use of unstable + override1: _, + override2: _ //~ ERROR use of unstable + } = x; + + let Deprecated //~ ERROR use of unstable + // the patterns are all fine: + { .. } = x; + + let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable + + let _ = x.0; //~ ERROR use of unstable + let _ = x.1; + let _ = x.2; //~ ERROR use of unstable + + let Deprecated2 //~ ERROR use of unstable + (_, //~ ERROR use of unstable + _, + _) //~ ERROR use of unstable + = x; + let Deprecated2 //~ ERROR use of unstable + // the patterns are all fine: + (..) = x; + } +} + +mod this_crate { + #[stable(feature = "rust1", since = "1.0.0")] + struct Stable { + inherit: u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + override1: u8, + #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[unstable(feature = "unstable_test_feature", issue = "0")] + override2: u8, + } + + #[stable(feature = "rust1", since = "1.0.0")] + struct Stable2(u8, + #[stable(feature = "rust1", since = "1.0.0")] u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + + #[unstable(feature = "unstable_test_feature", issue = "0")] + struct Unstable { + inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + override1: u8, + #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[unstable(feature = "unstable_test_feature", issue = "0")] + override2: u8, + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + struct Unstable2(u8, + #[stable(feature = "rust1", since = "1.0.0")] u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + struct Deprecated { + inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + override1: u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + override2: u8, + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + struct Deprecated2(u8, + #[stable(feature = "rust1", since = "1.0.0")] u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] u8); + + pub fn foo() { + let x = Stable { + inherit: 1, + override1: 2, + override2: 3, + }; + + let _ = x.inherit; + let _ = x.override1; + let _ = x.override2; + + let Stable { + inherit: _, + override1: _, + override2: _ + } = x; + // all fine + let Stable { .. } = x; + + let x = Stable2(1, 2, 3); + + let _ = x.0; + let _ = x.1; + let _ = x.2; + + let Stable2(_, + _, + _) + = x; + // all fine + let Stable2(..) = x; + + + let x = Unstable { + inherit: 1, + override1: 2, + override2: 3, + }; + + let _ = x.inherit; + let _ = x.override1; + let _ = x.override2; + + let Unstable { + inherit: _, + override1: _, + override2: _ + } = x; + + let Unstable + // the patterns are all fine: + { .. } = x; + + + let x = Unstable2(1, 2, 3); + + let _ = x.0; + let _ = x.1; + let _ = x.2; + + let Unstable2 + (_, + _, + _) + = x; + let Unstable2 + // the patterns are all fine: + (..) = x; + + + let x = Deprecated { + inherit: 1, + override1: 2, + override2: 3, + }; + + let _ = x.inherit; + let _ = x.override1; + let _ = x.override2; + + let Deprecated { + inherit: _, + override1: _, + override2: _ + } = x; + + let Deprecated + // the patterns are all fine: + { .. } = x; + + let x = Deprecated2(1, 2, 3); + + let _ = x.0; + let _ = x.1; + let _ = x.2; + + let Deprecated2 + (_, + _, + _) + = x; + let Deprecated2 + // the patterns are all fine: + (..) = x; + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-stability-fields.stderr b/src/test/ui/compile-fail-migration/lint-stability-fields.stderr new file mode 100644 index 00000000000..2f176062c30 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability-fields.stderr @@ -0,0 +1,347 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:61:17 + | +LL | let x = Unstable { //~ ERROR use of unstable + | ^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:71:13 + | +LL | let Unstable { //~ ERROR use of unstable + | ^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:77:13 + | +LL | let Unstable //~ ERROR use of unstable + | ^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:82:17 + | +LL | let x = reexport::Unstable2(1, 2, 3); //~ ERROR use of unstable + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:84:17 + | +LL | let x = Unstable2(1, 2, 3); //~ ERROR use of unstable + | ^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:90:13 + | +LL | let Unstable2 //~ ERROR use of unstable + | ^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:95:13 + | +LL | let Unstable2 //~ ERROR use of unstable + | ^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:100:17 + | +LL | let x = Deprecated { //~ ERROR use of unstable + | ^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:110:13 + | +LL | let Deprecated { //~ ERROR use of unstable + | ^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:116:13 + | +LL | let Deprecated //~ ERROR use of unstable + | ^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:120:17 + | +LL | let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:126:13 + | +LL | let Deprecated2 //~ ERROR use of unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:131:13 + | +LL | let Deprecated2 //~ ERROR use of unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:31:13 + | +LL | override1: 2, //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:32:13 + | +LL | override2: 3, //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:36:17 + | +LL | let _ = x.override1; //~ ERROR use of unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:37:17 + | +LL | let _ = x.override2; //~ ERROR use of unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:41:13 + | +LL | override1: _, //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:42:13 + | +LL | override2: _ //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:50:17 + | +LL | let _ = x.1; //~ ERROR use of unstable + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:51:17 + | +LL | let _ = x.2; //~ ERROR use of unstable + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:54:20 + | +LL | _, //~ ERROR use of unstable + | ^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:55:20 + | +LL | _) //~ ERROR use of unstable + | ^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:62:13 + | +LL | inherit: 1, //~ ERROR use of unstable + | ^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:64:13 + | +LL | override2: 3, //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:67:17 + | +LL | let _ = x.inherit; //~ ERROR use of unstable + | ^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:69:17 + | +LL | let _ = x.override2; //~ ERROR use of unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:72:13 + | +LL | inherit: _, //~ ERROR use of unstable + | ^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:74:13 + | +LL | override2: _ //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:86:17 + | +LL | let _ = x.0; //~ ERROR use of unstable + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:88:17 + | +LL | let _ = x.2; //~ ERROR use of unstable + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:91:14 + | +LL | (_, //~ ERROR use of unstable + | ^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:93:14 + | +LL | _) //~ ERROR use of unstable + | ^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:101:13 + | +LL | inherit: 1, //~ ERROR use of unstable + | ^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:103:13 + | +LL | override2: 3, //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:106:17 + | +LL | let _ = x.inherit; //~ ERROR use of unstable + | ^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:108:17 + | +LL | let _ = x.override2; //~ ERROR use of unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:111:13 + | +LL | inherit: _, //~ ERROR use of unstable + | ^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:113:13 + | +LL | override2: _ //~ ERROR use of unstable + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:122:17 + | +LL | let _ = x.0; //~ ERROR use of unstable + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:124:17 + | +LL | let _ = x.2; //~ ERROR use of unstable + | ^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:127:14 + | +LL | (_, //~ ERROR use of unstable + | ^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability-fields.rs:129:14 + | +LL | _) //~ ERROR use of unstable + | ^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error: aborting due to 43 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/lint-stability.rs b/src/test/ui/compile-fail-migration/lint-stability.rs new file mode 100644 index 00000000000..720b1235d47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability.rs @@ -0,0 +1,464 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_stability.rs +// aux-build:inherited_stability.rs +// aux-build:stability_cfg1.rs +// aux-build:stability_cfg2.rs + +#![allow(deprecated)] +#![allow(dead_code)] +#![feature(staged_api)] + +#![stable(feature = "rust1", since = "1.0.0")] + +#[macro_use] +extern crate lint_stability; + +mod cross_crate { + extern crate stability_cfg1; + extern crate stability_cfg2; //~ ERROR use of unstable library feature + + use lint_stability::*; + + fn test() { + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); + foo.method_deprecated(); + Foo::method_deprecated(&foo); + ::method_deprecated(&foo); + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + + deprecated_text(); + foo.method_deprecated_text(); + Foo::method_deprecated_text(&foo); + ::method_deprecated_text(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + + deprecated_future(); // Fine; no error. + + deprecated_unstable(); + //~^ ERROR use of unstable library feature + Trait::trait_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + + deprecated_unstable_text(); + //~^ ERROR use of unstable library feature + Trait::trait_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + + unstable(); //~ ERROR use of unstable library feature + Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature + ::trait_unstable(&foo); //~ ERROR use of unstable library feature + + unstable_text(); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + Trait::trait_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + ::trait_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + + stable(); + foo.method_stable(); + Foo::method_stable(&foo); + ::method_stable(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + + stable_text(); + foo.method_stable_text(); + Foo::method_stable_text(&foo); + ::method_stable_text(&foo); + foo.trait_stable_text(); + Trait::trait_stable_text(&foo); + ::trait_stable_text(&foo); + ::trait_stable_text(&foo); + + struct S1(T::TypeUnstable); + //~^ ERROR use of unstable library feature + struct S2(T::TypeDeprecated); + type A = TraitWithAssociatedTypes< + TypeUnstable = u8, //~ ERROR use of unstable library feature + TypeDeprecated = u16, + >; + + let _ = DeprecatedStruct { + i: 0 + }; + let _ = DeprecatedUnstableStruct { + //~^ ERROR use of unstable library feature + i: 0 + }; + let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable library feature + let _ = StableStruct { i: 0 }; + + let _ = DeprecatedUnitStruct; + let _ = DeprecatedUnstableUnitStruct; + //~^ ERROR use of unstable library feature + let _ = UnstableUnitStruct; //~ ERROR use of unstable library feature + let _ = StableUnitStruct; + + let _ = Enum::DeprecatedVariant; + let _ = Enum::DeprecatedUnstableVariant; + //~^ ERROR use of unstable library feature + let _ = Enum::UnstableVariant; //~ ERROR use of unstable library feature + let _ = Enum::StableVariant; + + let _ = DeprecatedTupleStruct (1); + let _ = DeprecatedUnstableTupleStruct (1); + //~^ ERROR use of unstable library feature + let _ = UnstableTupleStruct (1); //~ ERROR use of unstable library feature + let _ = StableTupleStruct (1); + + // At the moment, the lint checker only checks stability in + // in the arguments of macros. + // Eventually, we will want to lint the contents of the + // macro in the module *defining* it. Also, stability levels + // on macros themselves are not yet linted. + macro_test_arg!(deprecated_text()); + macro_test_arg!(deprecated_unstable_text()); + //~^ ERROR use of unstable library feature + macro_test_arg!(macro_test_arg!(deprecated_text())); + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + Trait::trait_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable(&foo); + //~^ ERROR use of unstable library feature + Trait::trait_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + ::trait_deprecated_unstable_text(&foo); + //~^ ERROR use of unstable library feature + Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature + ::trait_unstable(&foo); //~ ERROR use of unstable library feature + Trait::trait_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + ::trait_unstable_text(&foo); + //~^ ERROR use of unstable library feature 'unstable_test_feature': text + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); + foo.trait_deprecated_text(); + foo.trait_stable(); + } + + struct S; + + impl UnstableTrait for S { } //~ ERROR use of unstable library feature + impl DeprecatedTrait for S {} + trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable library feature + trait LocalTrait2 : DeprecatedTrait { } + + impl Trait for S { + fn trait_stable(&self) {} + fn trait_unstable(&self) {} //~ ERROR use of unstable library feature + } +} + +mod inheritance { + extern crate inherited_stability; //~ ERROR use of unstable library feature + use self::inherited_stability::*; //~ ERROR use of unstable library feature + + fn test_inheritance() { + unstable(); //~ ERROR use of unstable library feature + stable(); + + stable_mod::unstable(); //~ ERROR use of unstable library feature + stable_mod::stable(); + + unstable_mod::deprecated(); + unstable_mod::unstable(); //~ ERROR use of unstable library feature + + let _ = Unstable::UnstableVariant; //~ ERROR use of unstable library feature + let _ = Unstable::StableVariant; + + let x: usize = 0; + x.stable(); + } +} + +mod this_crate { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn deprecated() {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn deprecated_text() {} + + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_deprecated(since = "99.99.99", reason = "text")] + pub fn deprecated_future() {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn unstable() {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + pub fn unstable_text() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable() {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable_text() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub struct MethodTester; + + impl MethodTester { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn method_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + pub fn method_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable_text(&self) {} + } + + pub trait Trait { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + fn trait_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + fn trait_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable_text(&self) {} + } + + impl Trait for MethodTester {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedUnitStruct; + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableUnitStruct; + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableUnitStruct; + + pub enum Enum { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + DeprecatedVariant, + #[unstable(feature = "unstable_test_feature", issue = "0")] + UnstableVariant, + + #[stable(feature = "rust1", since = "1.0.0")] + StableVariant, + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub struct DeprecatedTupleStruct(isize); + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub struct UnstableTupleStruct(isize); + #[stable(feature = "rust1", since = "1.0.0")] + pub struct StableTupleStruct(isize); + + fn test() { + // Only the deprecated cases of the following should generate + // errors, because other stability attributes now have meaning + // only *across* crates, not within a single crate. + + type Foo = MethodTester; + let foo = MethodTester; + + deprecated(); + foo.method_deprecated(); + Foo::method_deprecated(&foo); + ::method_deprecated(&foo); + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + + deprecated_text(); + foo.method_deprecated_text(); + Foo::method_deprecated_text(&foo); + ::method_deprecated_text(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + + deprecated_future(); + + unstable(); + foo.method_unstable(); + Foo::method_unstable(&foo); + ::method_unstable(&foo); + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + + unstable_text(); + foo.method_unstable_text(); + Foo::method_unstable_text(&foo); + ::method_unstable_text(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + + stable(); + foo.method_stable(); + Foo::method_stable(&foo); + ::method_stable(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + + stable_text(); + foo.method_stable_text(); + Foo::method_stable_text(&foo); + ::method_stable_text(&foo); + foo.trait_stable_text(); + Trait::trait_stable_text(&foo); + ::trait_stable_text(&foo); + ::trait_stable_text(&foo); + + let _ = DeprecatedStruct { + i: 0 + }; + let _ = UnstableStruct { i: 0 }; + let _ = StableStruct { i: 0 }; + + let _ = DeprecatedUnitStruct; + let _ = UnstableUnitStruct; + let _ = StableUnitStruct; + + let _ = Enum::DeprecatedVariant; + let _ = Enum::UnstableVariant; + let _ = Enum::StableVariant; + + let _ = DeprecatedTupleStruct (1); + let _ = UnstableTupleStruct (1); + let _ = StableTupleStruct (1); + } + + fn test_method_param(foo: Foo) { + foo.trait_deprecated(); + Trait::trait_deprecated(&foo); + ::trait_deprecated(&foo); + ::trait_deprecated(&foo); + foo.trait_deprecated_text(); + Trait::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + ::trait_deprecated_text(&foo); + foo.trait_unstable(); + Trait::trait_unstable(&foo); + ::trait_unstable(&foo); + ::trait_unstable(&foo); + foo.trait_unstable_text(); + Trait::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + ::trait_unstable_text(&foo); + foo.trait_stable(); + Trait::trait_stable(&foo); + ::trait_stable(&foo); + ::trait_stable(&foo); + } + + fn test_method_object(foo: &Trait) { + foo.trait_deprecated(); + foo.trait_deprecated_text(); + foo.trait_unstable(); + foo.trait_unstable_text(); + foo.trait_stable(); + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn test_fn_body() { + fn fn_in_body() {} + fn_in_body(); + } + + impl MethodTester { + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn test_method_body(&self) { + fn fn_in_body() {} + fn_in_body(); + } + } + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub trait DeprecatedTrait { + fn dummy(&self) { } + } + + struct S; + + impl DeprecatedTrait for S { } + + trait LocalTrait : DeprecatedTrait { } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-stability.stderr b/src/test/ui/compile-fail-migration/lint-stability.stderr new file mode 100644 index 00000000000..893c70f85f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability.stderr @@ -0,0 +1,331 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:27:5 + | +LL | extern crate stability_cfg2; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:55:9 + | +LL | deprecated_unstable(); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:57:9 + | +LL | Trait::trait_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:59:9 + | +LL | ::trait_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:62:9 + | +LL | deprecated_unstable_text(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:64:9 + | +LL | Trait::trait_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:66:9 + | +LL | ::trait_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:69:9 + | +LL | unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:70:9 + | +LL | Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:71:9 + | +LL | ::trait_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability.rs:73:9 + | +LL | unstable_text(); + | ^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability.rs:75:9 + | +LL | Trait::trait_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability.rs:77:9 + | +LL | ::trait_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:109:17 + | +LL | let _ = DeprecatedUnstableStruct { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:113:17 + | +LL | let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:117:17 + | +LL | let _ = DeprecatedUnstableUnitStruct; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:119:17 + | +LL | let _ = UnstableUnitStruct; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:123:17 + | +LL | let _ = Enum::DeprecatedUnstableVariant; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:125:17 + | +LL | let _ = Enum::UnstableVariant; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:129:17 + | +LL | let _ = DeprecatedUnstableTupleStruct (1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:131:17 + | +LL | let _ = UnstableTupleStruct (1); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:140:25 + | +LL | macro_test_arg!(deprecated_unstable_text()); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:154:9 + | +LL | Trait::trait_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:156:9 + | +LL | ::trait_deprecated_unstable(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:158:9 + | +LL | Trait::trait_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:160:9 + | +LL | ::trait_deprecated_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:162:9 + | +LL | Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:163:9 + | +LL | ::trait_unstable(&foo); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability.rs:164:9 + | +LL | Trait::trait_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': text + --> $DIR/lint-stability.rs:166:9 + | +LL | ::trait_unstable_text(&foo); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:182:10 + | +LL | impl UnstableTrait for S { } //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:184:24 + | +LL | trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:189:9 + | +LL | fn trait_unstable(&self) {} //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:194:5 + | +LL | extern crate inherited_stability; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:195:9 + | +LL | use self::inherited_stability::*; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:198:9 + | +LL | unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:201:9 + | +LL | stable_mod::unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:205:9 + | +LL | unstable_mod::unstable(); //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:207:17 + | +LL | let _ = Unstable::UnstableVariant; //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:98:48 + | +LL | struct S1(T::TypeUnstable); + | ^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature' + --> $DIR/lint-stability.rs:102:13 + | +LL | TypeUnstable = u8, //~ ERROR use of unstable library feature + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error: aborting due to 41 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/lint-stability2.rs b/src/test/ui/compile-fail-migration/lint-stability2.rs new file mode 100644 index 00000000000..d2ec00d6495 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability2.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_stability.rs +// error-pattern: use of deprecated item + +#![deny(deprecated)] + +#[macro_use] +extern crate lint_stability; + +use lint_stability::*; + +fn main() { + macro_test!(); +} diff --git a/src/test/ui/compile-fail-migration/lint-stability2.stderr b/src/test/ui/compile-fail-migration/lint-stability2.stderr new file mode 100644 index 00000000000..5585fc9f83a --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability2.stderr @@ -0,0 +1,15 @@ +error: use of deprecated item 'lint_stability::deprecated': text + --> $DIR/lint-stability2.rs:22:5 + | +LL | macro_test!(); + | ^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-stability2.rs:14:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-stability3.rs b/src/test/ui/compile-fail-migration/lint-stability3.rs new file mode 100644 index 00000000000..44a36f215f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability3.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_stability.rs +// error-pattern: use of deprecated item + +#![deny(deprecated)] +#![allow(warnings)] + +#[macro_use] +extern crate lint_stability; + +use lint_stability::*; + +fn main() { + macro_test_arg_nested!(deprecated_text); +} diff --git a/src/test/ui/compile-fail-migration/lint-stability3.stderr b/src/test/ui/compile-fail-migration/lint-stability3.stderr new file mode 100644 index 00000000000..722223f6243 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-stability3.stderr @@ -0,0 +1,15 @@ +error: use of deprecated item 'lint_stability::deprecated_text': text + --> $DIR/lint-stability3.rs:23:5 + | +LL | macro_test_arg_nested!(deprecated_text); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-stability3.rs:14:9 + | +LL | #![deny(deprecated)] + | ^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-type-limits.rs b/src/test/ui/compile-fail-migration/lint-type-limits.rs new file mode 100644 index 00000000000..29929c120c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-limits.rs @@ -0,0 +1,37 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// compile-flags: -D unused-comparisons +fn main() { } + +fn foo() { + let mut i = 100_usize; + while i >= 0 { //~ ERROR comparison is useless due to type limits + i -= 1; + } +} + +fn bar() -> i8 { + return 123; +} + +fn bleh() { + let u = 42u8; + let _ = u > 255; //~ ERROR comparison is useless due to type limits + let _ = 255 < u; //~ ERROR comparison is useless due to type limits + let _ = u < 0; //~ ERROR comparison is useless due to type limits + let _ = 0 > u; //~ ERROR comparison is useless due to type limits + let _ = u <= 255; //~ ERROR comparison is useless due to type limits + let _ = 255 >= u; //~ ERROR comparison is useless due to type limits + let _ = u >= 0; //~ ERROR comparison is useless due to type limits + let _ = 0 <= u; //~ ERROR comparison is useless due to type limits +} diff --git a/src/test/ui/compile-fail-migration/lint-type-limits.stderr b/src/test/ui/compile-fail-migration/lint-type-limits.stderr new file mode 100644 index 00000000000..49b379a9901 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-limits.stderr @@ -0,0 +1,58 @@ +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:18:11 + | +LL | while i >= 0 { //~ ERROR comparison is useless due to type limits + | ^^^^^^ + | + = note: requested on the command line with `-D unused-comparisons` + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:29:13 + | +LL | let _ = u > 255; //~ ERROR comparison is useless due to type limits + | ^^^^^^^ + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:30:13 + | +LL | let _ = 255 < u; //~ ERROR comparison is useless due to type limits + | ^^^^^^^ + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:31:13 + | +LL | let _ = u < 0; //~ ERROR comparison is useless due to type limits + | ^^^^^ + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:32:13 + | +LL | let _ = 0 > u; //~ ERROR comparison is useless due to type limits + | ^^^^^ + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:33:13 + | +LL | let _ = u <= 255; //~ ERROR comparison is useless due to type limits + | ^^^^^^^^ + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:34:13 + | +LL | let _ = 255 >= u; //~ ERROR comparison is useless due to type limits + | ^^^^^^^^ + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:35:13 + | +LL | let _ = u >= 0; //~ ERROR comparison is useless due to type limits + | ^^^^^^ + +error: comparison is useless due to type limits + --> $DIR/lint-type-limits.rs:36:13 + | +LL | let _ = 0 <= u; //~ ERROR comparison is useless due to type limits + | ^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-type-limits2.rs b/src/test/ui/compile-fail-migration/lint-type-limits2.rs new file mode 100644 index 00000000000..8fc18d16469 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-limits2.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// compile-flags: -D unused-comparisons +fn main() { } + + +fn bar() -> i8 { + return 123; +} + +fn baz() -> bool { + 128 > bar() //~ ERROR comparison is useless due to type limits + //~| WARN literal out of range for i8 +} diff --git a/src/test/ui/compile-fail-migration/lint-type-limits2.stderr b/src/test/ui/compile-fail-migration/lint-type-limits2.stderr new file mode 100644 index 00000000000..a7abf7ad364 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-limits2.stderr @@ -0,0 +1,18 @@ +error: comparison is useless due to type limits + --> $DIR/lint-type-limits2.rs:22:5 + | +LL | 128 > bar() //~ ERROR comparison is useless due to type limits + | ^^^^^^^^^^^ + | + = note: requested on the command line with `-D unused-comparisons` + +warning: literal out of range for i8 + --> $DIR/lint-type-limits2.rs:22:5 + | +LL | 128 > bar() //~ ERROR comparison is useless due to type limits + | ^^^ + | + = note: #[warn(overflowing_literals)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-type-limits3.rs b/src/test/ui/compile-fail-migration/lint-type-limits3.rs new file mode 100644 index 00000000000..b09dc0acdbf --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-limits3.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// compile-flags: -D unused-comparisons +fn main() { } + +fn qux() { + let mut i = 1i8; + while 200 != i { //~ ERROR comparison is useless due to type limits + //~| WARN literal out of range for i8 + i += 1; + } +} diff --git a/src/test/ui/compile-fail-migration/lint-type-limits3.stderr b/src/test/ui/compile-fail-migration/lint-type-limits3.stderr new file mode 100644 index 00000000000..b6e14ac64e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-limits3.stderr @@ -0,0 +1,18 @@ +error: comparison is useless due to type limits + --> $DIR/lint-type-limits3.rs:18:11 + | +LL | while 200 != i { //~ ERROR comparison is useless due to type limits + | ^^^^^^^^ + | + = note: requested on the command line with `-D unused-comparisons` + +warning: literal out of range for i8 + --> $DIR/lint-type-limits3.rs:18:11 + | +LL | while 200 != i { //~ ERROR comparison is useless due to type limits + | ^^^ + | + = note: #[warn(overflowing_literals)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-type-overflow.rs b/src/test/ui/compile-fail-migration/lint-type-overflow.rs new file mode 100644 index 00000000000..ce336905c01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-overflow.rs @@ -0,0 +1,56 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// + +#![deny(overflowing_literals)] + +fn test(x: i8) { + println!("x {}", x); +} + +#[allow(unused_variables)] +fn main() { + let x1: u8 = 255; // should be OK + let x1: u8 = 256; //~ error: literal out of range for u8 + + let x1 = 255_u8; // should be OK + let x1 = 256_u8; //~ error: literal out of range for u8 + + let x2: i8 = -128; // should be OK + let x1: i8 = 128; //~ error: literal out of range for i8 + + let x3: i8 = -129; //~ error: literal out of range for i8 + let x3: i8 = -(129); //~ error: literal out of range for i8 + let x3: i8 = -{129}; //~ error: literal out of range for i8 + + test(1000); //~ error: literal out of range for i8 + + let x = 128_i8; //~ error: literal out of range for i8 + let x = 127_i8; + let x = -128_i8; + let x = -(128_i8); + let x = -129_i8; //~ error: literal out of range for i8 + + let x: i32 = 2147483647; // should be OK + let x = 2147483647_i32; // should be OK + let x: i32 = 2147483648; //~ error: literal out of range for i32 + let x = 2147483648_i32; //~ error: literal out of range for i32 + let x: i32 = -2147483648; // should be OK + let x = -2147483648_i32; // should be OK + let x: i32 = -2147483649; //~ error: literal out of range for i32 + let x = -2147483649_i32; //~ error: literal out of range for i32 + let x = 2147483648; //~ error: literal out of range for i32 + + let x = 9223372036854775808_i64; //~ error: literal out of range for i64 + let x = -9223372036854775808_i64; // should be OK + let x = 18446744073709551615_i64; //~ error: literal out of range for i64 + let x: i64 = -9223372036854775809; //~ error: literal out of range for i64 + let x = -9223372036854775809_i64; //~ error: literal out of range for i64 +} diff --git a/src/test/ui/compile-fail-migration/lint-type-overflow.stderr b/src/test/ui/compile-fail-migration/lint-type-overflow.stderr new file mode 100644 index 00000000000..67f4537e1e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-overflow.stderr @@ -0,0 +1,116 @@ +error: literal out of range for u8 + --> $DIR/lint-type-overflow.rs:21:18 + | +LL | let x1: u8 = 256; //~ error: literal out of range for u8 + | ^^^ + | +note: lint level defined here + --> $DIR/lint-type-overflow.rs:12:9 + | +LL | #![deny(overflowing_literals)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: literal out of range for u8 + --> $DIR/lint-type-overflow.rs:24:14 + | +LL | let x1 = 256_u8; //~ error: literal out of range for u8 + | ^^^^^^ + +error: literal out of range for i8 + --> $DIR/lint-type-overflow.rs:27:18 + | +LL | let x1: i8 = 128; //~ error: literal out of range for i8 + | ^^^ + +error: literal out of range for i8 + --> $DIR/lint-type-overflow.rs:29:19 + | +LL | let x3: i8 = -129; //~ error: literal out of range for i8 + | ^^^ + +error: literal out of range for i8 + --> $DIR/lint-type-overflow.rs:30:19 + | +LL | let x3: i8 = -(129); //~ error: literal out of range for i8 + | ^^^^^ + +error: literal out of range for i8 + --> $DIR/lint-type-overflow.rs:31:20 + | +LL | let x3: i8 = -{129}; //~ error: literal out of range for i8 + | ^^^ + +error: literal out of range for i8 + --> $DIR/lint-type-overflow.rs:33:10 + | +LL | test(1000); //~ error: literal out of range for i8 + | ^^^^ + +error: literal out of range for i8 + --> $DIR/lint-type-overflow.rs:35:13 + | +LL | let x = 128_i8; //~ error: literal out of range for i8 + | ^^^^^^ + +error: literal out of range for i8 + --> $DIR/lint-type-overflow.rs:39:14 + | +LL | let x = -129_i8; //~ error: literal out of range for i8 + | ^^^^^^ + +error: literal out of range for i32 + --> $DIR/lint-type-overflow.rs:43:18 + | +LL | let x: i32 = 2147483648; //~ error: literal out of range for i32 + | ^^^^^^^^^^ + +error: literal out of range for i32 + --> $DIR/lint-type-overflow.rs:44:13 + | +LL | let x = 2147483648_i32; //~ error: literal out of range for i32 + | ^^^^^^^^^^^^^^ + +error: literal out of range for i32 + --> $DIR/lint-type-overflow.rs:47:19 + | +LL | let x: i32 = -2147483649; //~ error: literal out of range for i32 + | ^^^^^^^^^^ + +error: literal out of range for i32 + --> $DIR/lint-type-overflow.rs:48:14 + | +LL | let x = -2147483649_i32; //~ error: literal out of range for i32 + | ^^^^^^^^^^^^^^ + +error: literal out of range for i32 + --> $DIR/lint-type-overflow.rs:49:13 + | +LL | let x = 2147483648; //~ error: literal out of range for i32 + | ^^^^^^^^^^ + +error: literal out of range for i64 + --> $DIR/lint-type-overflow.rs:51:13 + | +LL | let x = 9223372036854775808_i64; //~ error: literal out of range for i64 + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: literal out of range for i64 + --> $DIR/lint-type-overflow.rs:53:13 + | +LL | let x = 18446744073709551615_i64; //~ error: literal out of range for i64 + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: literal out of range for i64 + --> $DIR/lint-type-overflow.rs:54:19 + | +LL | let x: i64 = -9223372036854775809; //~ error: literal out of range for i64 + | ^^^^^^^^^^^^^^^^^^^ + +error: literal out of range for i64 + --> $DIR/lint-type-overflow.rs:55:14 + | +LL | let x = -9223372036854775809_i64; //~ error: literal out of range for i64 + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 18 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-type-overflow2.rs b/src/test/ui/compile-fail-migration/lint-type-overflow2.rs new file mode 100644 index 00000000000..f7cf8a68d56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-overflow2.rs @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// + +#![warn(overflowing_literals)] +#![warn(const_err)] +#![feature(rustc_attrs)] + +#[allow(unused_variables)] +#[rustc_error] +fn main() { //~ ERROR: compilation successful + let x2: i8 = --128; //~ warn: literal out of range for i8 + + let x = -3.40282357e+38_f32; //~ warn: literal out of range for f32 + let x = 3.40282357e+38_f32; //~ warn: literal out of range for f32 + let x = -1.7976931348623159e+308_f64; //~ warn: literal out of range for f64 + let x = 1.7976931348623159e+308_f64; //~ warn: literal out of range for f64 +} diff --git a/src/test/ui/compile-fail-migration/lint-type-overflow2.stderr b/src/test/ui/compile-fail-migration/lint-type-overflow2.stderr new file mode 100644 index 00000000000..ecfd2584bba --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-type-overflow2.stderr @@ -0,0 +1,50 @@ +warning: literal out of range for i8 + --> $DIR/lint-type-overflow2.rs:19:20 + | +LL | let x2: i8 = --128; //~ warn: literal out of range for i8 + | ^^^ + | +note: lint level defined here + --> $DIR/lint-type-overflow2.rs:12:9 + | +LL | #![warn(overflowing_literals)] + | ^^^^^^^^^^^^^^^^^^^^ + +warning: literal out of range for f32 + --> $DIR/lint-type-overflow2.rs:21:14 + | +LL | let x = -3.40282357e+38_f32; //~ warn: literal out of range for f32 + | ^^^^^^^^^^^^^^^^^^ + +warning: literal out of range for f32 + --> $DIR/lint-type-overflow2.rs:22:14 + | +LL | let x = 3.40282357e+38_f32; //~ warn: literal out of range for f32 + | ^^^^^^^^^^^^^^^^^^ + +warning: literal out of range for f64 + --> $DIR/lint-type-overflow2.rs:23:14 + | +LL | let x = -1.7976931348623159e+308_f64; //~ warn: literal out of range for f64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: literal out of range for f64 + --> $DIR/lint-type-overflow2.rs:24:14 + | +LL | let x = 1.7976931348623159e+308_f64; //~ warn: literal out of range for f64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: compilation successful + --> $DIR/lint-type-overflow2.rs:18:1 + | +LL | / fn main() { //~ ERROR: compilation successful +LL | | let x2: i8 = --128; //~ warn: literal out of range for i8 +LL | | +LL | | let x = -3.40282357e+38_f32; //~ warn: literal out of range for f32 +... | +LL | | let x = 1.7976931348623159e+308_f64; //~ warn: literal out of range for f64 +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-unexported-no-mangle.rs b/src/test/ui/compile-fail-migration/lint-unexported-no-mangle.rs new file mode 100644 index 00000000000..cd64dfa7a47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unexported-no-mangle.rs @@ -0,0 +1,39 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-F private_no_mangle_fns -F no_mangle_const_items -F private_no_mangle_statics + +#[no_mangle] +fn foo() { //~ ERROR function is marked #[no_mangle], but not exported +} + +#[allow(dead_code)] +#[no_mangle] +const FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] + +#[no_mangle] +pub const PUB_FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] + +#[no_mangle] +pub fn bar() { +} + +#[no_mangle] +pub static BAR: u64 = 1; + +#[allow(dead_code)] +#[no_mangle] +static PRIVATE_BAR: u64 = 1; //~ ERROR static is marked #[no_mangle], but not exported + + +fn main() { + foo(); + bar(); +} diff --git a/src/test/ui/compile-fail-migration/lint-unexported-no-mangle.stderr b/src/test/ui/compile-fail-migration/lint-unexported-no-mangle.stderr new file mode 100644 index 00000000000..e7d49f339e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unexported-no-mangle.stderr @@ -0,0 +1,43 @@ +error: function is marked #[no_mangle], but not exported + --> $DIR/lint-unexported-no-mangle.rs:14:1 + | +LL | fn foo() { //~ ERROR function is marked #[no_mangle], but not exported + | ^ + | | + | _help: try making it public: `pub` + | | +LL | | } + | |_^ + | + = note: requested on the command line with `-F private-no-mangle-fns` + +error: const items should never be #[no_mangle] + --> $DIR/lint-unexported-no-mangle.rs:19:1 + | +LL | const FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] + | -----^^^^^^^^^^^^^^ + | | + | help: try a static value: `pub static` + | + = note: requested on the command line with `-F no-mangle-const-items` + +error: const items should never be #[no_mangle] + --> $DIR/lint-unexported-no-mangle.rs:22:1 + | +LL | pub const PUB_FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] + | ---------^^^^^^^^^^^^^^^^^^ + | | + | help: try a static value: `pub static` + +error: static is marked #[no_mangle], but not exported + --> $DIR/lint-unexported-no-mangle.rs:33:1 + | +LL | static PRIVATE_BAR: u64 = 1; //~ ERROR static is marked #[no_mangle], but not exported + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: try making it public: `pub` + | + = note: requested on the command line with `-F private-no-mangle-statics` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unknown-attr.rs b/src/test/ui/compile-fail-migration/lint-unknown-attr.rs new file mode 100644 index 00000000000..af4e81be195 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-attr.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// When denying at the crate level, be sure to not get random warnings from the +// injected intrinsics by the compiler. + +#![feature(custom_attribute)] +#![deny(unused_attributes)] + +#![mutable_doc] //~ ERROR unused attribute + +#[dance] mod a {} //~ ERROR unused attribute + +#[dance] fn main() {} //~ ERROR unused attribute diff --git a/src/test/ui/compile-fail-migration/lint-unknown-attr.stderr b/src/test/ui/compile-fail-migration/lint-unknown-attr.stderr new file mode 100644 index 00000000000..5f915232c14 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-attr.stderr @@ -0,0 +1,26 @@ +error: unused attribute + --> $DIR/lint-unknown-attr.rs:19:1 + | +LL | #[dance] mod a {} //~ ERROR unused attribute + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-unknown-attr.rs:15:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: unused attribute + --> $DIR/lint-unknown-attr.rs:21:1 + | +LL | #[dance] fn main() {} //~ ERROR unused attribute + | ^^^^^^^^ + +error: unused attribute + --> $DIR/lint-unknown-attr.rs:17:1 + | +LL | #![mutable_doc] //~ ERROR unused attribute + | ^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unknown-feature-default.rs b/src/test/ui/compile-fail-migration/lint-unknown-feature-default.rs new file mode 100644 index 00000000000..5a0568f05e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-feature-default.rs @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests the default for the unused_features lint + +#![allow(stable_features)] +// FIXME(#44232) we should warn that this isn't used. +#![feature(rust1)] + +#![feature(rustc_attrs)] + +#[rustc_error] +fn main() { } //~ ERROR: compilation successful diff --git a/src/test/ui/compile-fail-migration/lint-unknown-feature-default.stderr b/src/test/ui/compile-fail-migration/lint-unknown-feature-default.stderr new file mode 100644 index 00000000000..bd4079ffd2e --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-feature-default.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/lint-unknown-feature-default.rs:20:1 + | +LL | fn main() { } //~ ERROR: compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-unknown-feature.rs b/src/test/ui/compile-fail-migration/lint-unknown-feature.rs new file mode 100644 index 00000000000..81f99f99492 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-feature.rs @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![warn(unused_features)] + +#![allow(stable_features)] +// FIXME(#44232) we should warn that this isn't used. +#![feature(rust1)] + +#![feature(rustc_attrs)] + +#[rustc_error] +fn main() {} //~ ERROR: compilation successful diff --git a/src/test/ui/compile-fail-migration/lint-unknown-feature.stderr b/src/test/ui/compile-fail-migration/lint-unknown-feature.stderr new file mode 100644 index 00000000000..e2744c03872 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-feature.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/lint-unknown-feature.rs:20:1 + | +LL | fn main() {} //~ ERROR: compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.rs b/src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.rs new file mode 100644 index 00000000000..0c41959f8a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-D bogus + +// error-pattern:unknown lint +// error-pattern:requested on the command line with `-D bogus` + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.stderr b/src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.stderr new file mode 100644 index 00000000000..86360041026 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-lint-cmdline.stderr @@ -0,0 +1,7 @@ +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0602`. diff --git a/src/test/ui/compile-fail-migration/lint-unknown-lint.rs b/src/test/ui/compile-fail-migration/lint-unknown-lint.rs new file mode 100644 index 00000000000..2de8d849d19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-lint.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(not_a_real_lint)] //~ WARN unknown lint +#![deny(unused)] +fn main() { let unused = (); } //~ ERROR unused variable diff --git a/src/test/ui/compile-fail-migration/lint-unknown-lint.stderr b/src/test/ui/compile-fail-migration/lint-unknown-lint.stderr new file mode 100644 index 00000000000..b398a2f3690 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unknown-lint.stderr @@ -0,0 +1,23 @@ +warning: unknown lint: `not_a_real_lint` + --> $DIR/lint-unknown-lint.rs:11:10 + | +LL | #![allow(not_a_real_lint)] //~ WARN unknown lint + | ^^^^^^^^^^^^^^^ + | + = note: #[warn(unknown_lints)] on by default + +error: unused variable: `unused` + --> $DIR/lint-unknown-lint.rs:13:17 + | +LL | fn main() { let unused = (); } //~ ERROR unused variable + | ^^^^^^ help: consider using `_unused` instead + | +note: lint level defined here + --> $DIR/lint-unknown-lint.rs:12:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: #[deny(unused_variables)] implied by #[deny(unused)] + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.rs b/src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.rs new file mode 100644 index 00000000000..214a03c13f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_import_braces)] + +use test::{A}; //~ ERROR braces around A is unnecessary + +mod test { + use test::{self}; // OK + use test::{self as rename}; // OK + pub struct A; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.stderr b/src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.stderr new file mode 100644 index 00000000000..a4fd474e5cc --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unnecessary-import-braces.stderr @@ -0,0 +1,14 @@ +error: braces around A is unnecessary + --> $DIR/lint-unnecessary-import-braces.rs:13:1 + | +LL | use test::{A}; //~ ERROR braces around A is unnecessary + | ^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-unnecessary-import-braces.rs:11:9 + | +LL | #![deny(unused_import_braces)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lint-unnecessary-parens.rs b/src/test/ui/compile-fail-migration/lint-unnecessary-parens.rs new file mode 100644 index 00000000000..7cd0a6bbf0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unnecessary-parens.rs @@ -0,0 +1,55 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_parens)] + +#[derive(Eq, PartialEq)] +struct X { y: bool } +impl X { + fn foo(&self, conjunct: bool) -> bool { self.y && conjunct } +} + +fn foo() -> isize { + return (1); //~ ERROR unnecessary parentheses around `return` value +} +fn bar(y: bool) -> X { + return (X { y }); //~ ERROR unnecessary parentheses around `return` value +} + +fn main() { + foo(); + bar((true)); //~ ERROR unnecessary parentheses around function argument + + if (true) {} //~ ERROR unnecessary parentheses around `if` condition + while (true) {} //~ ERROR unnecessary parentheses around `while` condition + match (true) { //~ ERROR unnecessary parentheses around `match` head expression + _ => {} + } + if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` head expression + while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` head expression + let v = X { y: false }; + // struct lits needs parens, so these shouldn't warn. + if (v == X { y: true }) {} + if (X { y: true } == v) {} + if (X { y: false }.y) {} + + while (X { y: false }.foo(true)) {} + while (true | X { y: false }.y) {} + + match (X { y: false }) { + _ => {} + } + + X { y: false }.foo((true)); //~ ERROR unnecessary parentheses around method argument + + let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value + _a = (0); //~ ERROR unnecessary parentheses around assigned value + _a += (1); //~ ERROR unnecessary parentheses around assigned value +} diff --git a/src/test/ui/compile-fail-migration/lint-unnecessary-parens.stderr b/src/test/ui/compile-fail-migration/lint-unnecessary-parens.stderr new file mode 100644 index 00000000000..8861524b185 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unnecessary-parens.stderr @@ -0,0 +1,80 @@ +error: unnecessary parentheses around `return` value + --> $DIR/lint-unnecessary-parens.rs:20:12 + | +LL | return (1); //~ ERROR unnecessary parentheses around `return` value + | ^^^ help: remove these parentheses + | +note: lint level defined here + --> $DIR/lint-unnecessary-parens.rs:11:9 + | +LL | #![deny(unused_parens)] + | ^^^^^^^^^^^^^ + +error: unnecessary parentheses around `return` value + --> $DIR/lint-unnecessary-parens.rs:23:12 + | +LL | return (X { y }); //~ ERROR unnecessary parentheses around `return` value + | ^^^^^^^^^ help: remove these parentheses + +error: unnecessary parentheses around function argument + --> $DIR/lint-unnecessary-parens.rs:28:9 + | +LL | bar((true)); //~ ERROR unnecessary parentheses around function argument + | ^^^^^^ help: remove these parentheses + +error: unnecessary parentheses around `if` condition + --> $DIR/lint-unnecessary-parens.rs:30:8 + | +LL | if (true) {} //~ ERROR unnecessary parentheses around `if` condition + | ^^^^^^ help: remove these parentheses + +error: unnecessary parentheses around `while` condition + --> $DIR/lint-unnecessary-parens.rs:31:11 + | +LL | while (true) {} //~ ERROR unnecessary parentheses around `while` condition + | ^^^^^^ help: remove these parentheses + +error: unnecessary parentheses around `match` head expression + --> $DIR/lint-unnecessary-parens.rs:32:11 + | +LL | match (true) { //~ ERROR unnecessary parentheses around `match` head expression + | ^^^^^^ help: remove these parentheses + +error: unnecessary parentheses around `if let` head expression + --> $DIR/lint-unnecessary-parens.rs:35:16 + | +LL | if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` head expression + | ^^^ help: remove these parentheses + +error: unnecessary parentheses around `while let` head expression + --> $DIR/lint-unnecessary-parens.rs:36:19 + | +LL | while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` head expression + | ^^^ help: remove these parentheses + +error: unnecessary parentheses around method argument + --> $DIR/lint-unnecessary-parens.rs:50:24 + | +LL | X { y: false }.foo((true)); //~ ERROR unnecessary parentheses around method argument + | ^^^^^^ help: remove these parentheses + +error: unnecessary parentheses around assigned value + --> $DIR/lint-unnecessary-parens.rs:52:18 + | +LL | let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value + | ^^^ help: remove these parentheses + +error: unnecessary parentheses around assigned value + --> $DIR/lint-unnecessary-parens.rs:53:10 + | +LL | _a = (0); //~ ERROR unnecessary parentheses around assigned value + | ^^^ help: remove these parentheses + +error: unnecessary parentheses around assigned value + --> $DIR/lint-unnecessary-parens.rs:54:11 + | +LL | _a += (1); //~ ERROR unnecessary parentheses around assigned value + | ^^^ help: remove these parentheses + +error: aborting due to 12 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unsafe-code.rs b/src/test/ui/compile-fail-migration/lint-unsafe-code.rs new file mode 100644 index 00000000000..10f245aaaf9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unsafe-code.rs @@ -0,0 +1,99 @@ +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_unsafe)] +#![allow(dead_code)] +#![deny(unsafe_code)] + +struct Bar; +struct Bar2; +struct Bar3; + +#[allow(unsafe_code)] +mod allowed_unsafe { + fn allowed() { unsafe {} } + unsafe fn also_allowed() {} + unsafe trait AllowedUnsafe { } + unsafe impl AllowedUnsafe for super::Bar {} +} + +macro_rules! unsafe_in_macro { + () => { + unsafe {} //~ ERROR: usage of an `unsafe` block + } +} + +unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function +unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait +unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait + +trait Baz { + unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method + unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method +} + +impl Baz for Bar { + unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method + unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method +} + + +#[allow(unsafe_code)] +trait A { + unsafe fn allowed_unsafe(&self); + unsafe fn allowed_unsafe_provided(&self) {} +} + +#[allow(unsafe_code)] +impl Baz for Bar2 { + unsafe fn baz(&self) {} + unsafe fn provided_override(&self) {} +} + +impl Baz for Bar3 { + #[allow(unsafe_code)] + unsafe fn baz(&self) {} + unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method +} + +#[allow(unsafe_code)] +unsafe trait B { + fn dummy(&self) {} +} + +trait C { + #[allow(unsafe_code)] + unsafe fn baz(&self); + unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method +} + +impl C for Bar { + #[allow(unsafe_code)] + unsafe fn baz(&self) {} + unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method +} + +impl C for Bar2 { + unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method +} + +trait D { + #[allow(unsafe_code)] + unsafe fn unsafe_provided(&self) {} +} + +impl D for Bar {} + +fn main() { + unsafe {} //~ ERROR: usage of an `unsafe` block + + unsafe_in_macro!() +} diff --git a/src/test/ui/compile-fail-migration/lint-unsafe-code.stderr b/src/test/ui/compile-fail-migration/lint-unsafe-code.stderr new file mode 100644 index 00000000000..ee2aba066ec --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unsafe-code.stderr @@ -0,0 +1,95 @@ +error: declaration of an `unsafe` function + --> $DIR/lint-unsafe-code.rs:33:1 + | +LL | unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-unsafe-code.rs:13:9 + | +LL | #![deny(unsafe_code)] + | ^^^^^^^^^^^ + +error: declaration of an `unsafe` trait + --> $DIR/lint-unsafe-code.rs:34:1 + | +LL | unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait + | ^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` trait + --> $DIR/lint-unsafe-code.rs:35:1 + | +LL | unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: declaration of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:38:5 + | +LL | unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:39:5 + | +LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:40:5 + | +LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:44:5 + | +LL | unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:45:5 + | +LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:64:5 + | +LL | unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:75:5 + | +LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:81:5 + | +LL | unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: implementation of an `unsafe` method + --> $DIR/lint-unsafe-code.rs:85:5 + | +LL | unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: usage of an `unsafe` block + --> $DIR/lint-unsafe-code.rs:96:5 + | +LL | unsafe {} //~ ERROR: usage of an `unsafe` block + | ^^^^^^^^^ + +error: usage of an `unsafe` block + --> $DIR/lint-unsafe-code.rs:29:9 + | +LL | unsafe {} //~ ERROR: usage of an `unsafe` block + | ^^^^^^^^^ +... +LL | unsafe_in_macro!() + | ------------------ in this macro invocation + +error: aborting due to 14 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unused-extern-crate.rs b/src/test/ui/compile-fail-migration/lint-unused-extern-crate.rs new file mode 100644 index 00000000000..8f0b53fd599 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-extern-crate.rs @@ -0,0 +1,45 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_unused_extern_crate.rs +// aux-build:lint_unused_extern_crate2.rs +// aux-build:lint_unused_extern_crate3.rs +// aux-build:lint_unused_extern_crate4.rs +// aux-build:lint_unused_extern_crate5.rs + +#![deny(unused_extern_crates)] +#![allow(unused_variables)] +#![allow(deprecated)] + +extern crate lint_unused_extern_crate5; //~ ERROR: unused extern crate + +pub extern crate lint_unused_extern_crate4; // no error, it is re-exported + +extern crate lint_unused_extern_crate3; // no error, it is used + +extern crate lint_unused_extern_crate2; // no error, the use marks it as used + // even if imported objects aren't used + +extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used + +#[allow(unused_imports)] +use lint_unused_extern_crate2::foo as bar; + +use other::*; + +mod foo { + // Test that this is unused even though an earler `extern crate` is used. + extern crate lint_unused_extern_crate2; //~ ERROR unused extern crate +} + +fn main() { + lint_unused_extern_crate3::foo(); + let y = foo(); +} diff --git a/src/test/ui/compile-fail-migration/lint-unused-extern-crate.stderr b/src/test/ui/compile-fail-migration/lint-unused-extern-crate.stderr new file mode 100644 index 00000000000..3a488b1e073 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-extern-crate.stderr @@ -0,0 +1,20 @@ +error: unused extern crate + --> $DIR/lint-unused-extern-crate.rs:21:1 + | +LL | extern crate lint_unused_extern_crate5; //~ ERROR: unused extern crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + | +note: lint level defined here + --> $DIR/lint-unused-extern-crate.rs:17:9 + | +LL | #![deny(unused_extern_crates)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unused extern crate + --> $DIR/lint-unused-extern-crate.rs:39:5 + | +LL | extern crate lint_unused_extern_crate2; //~ ERROR unused extern crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unused-imports.rs b/src/test/ui/compile-fail-migration/lint-unused-imports.rs new file mode 100644 index 00000000000..5bb2ab75c53 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-imports.rs @@ -0,0 +1,98 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_imports)] +#![allow(dead_code)] + +use bar::c::cc as cal; + +use std::mem::*; // shouldn't get errors for not using + // everything imported +use std::fmt::{}; +//~^ ERROR unused import: `use std::fmt::{};` + +// Should get errors for both 'Some' and 'None' +use std::option::Option::{Some, None}; +//~^ ERROR unused imports: `None`, `Some` + +use test::A; //~ ERROR unused import: `test::A` +// Be sure that if we just bring some methods into scope that they're also +// counted as being used. +use test::B; +// But only when actually used: do not get confused by the method with the same name. +use test::B2; //~ ERROR unused import: `test::B2` + +// Make sure this import is warned about when at least one of its imported names +// is unused +use test2::{foo, bar}; //~ ERROR unused import: `bar` + +mod test2 { + pub fn foo() {} + pub fn bar() {} +} + +mod test { + pub trait A { fn a(&self) {} } + pub trait B { fn b(&self) {} } + pub trait B2 { fn b(&self) {} } + pub struct C; + impl A for C {} + impl B for C {} +} + +mod foo { + pub struct Point{pub x: isize, pub y: isize} + pub struct Square{pub p: Point, pub h: usize, pub w: usize} +} + +mod bar { + // Don't ignore on 'pub use' because we're not sure if it's used or not + pub use std::cmp::PartialEq; + pub struct Square; + + pub mod c { + use foo::Point; + use foo::Square; //~ ERROR unused import: `foo::Square` + pub fn cc(_p: Point) -> super::Square { + fn f() -> super::Square { + super::Square + } + f() + } + } + + #[allow(unused_imports)] + mod foo { + use std::cmp::PartialEq; + } +} + +fn g() { + use self::g; //~ ERROR unused import: `self::g` + fn f() { + self::g(); + } +} + +// c.f. issue #35135 +#[allow(unused_variables)] +fn h() { + use test2::foo; //~ ERROR unused import: `test2::foo` + let foo = 0; +} + +fn main() { + cal(foo::Point{x:3, y:9}); + let mut a = 3; + let mut b = 4; + swap(&mut a, &mut b); + test::C.b(); + let _a = foo(); +} diff --git a/src/test/ui/compile-fail-migration/lint-unused-imports.stderr b/src/test/ui/compile-fail-migration/lint-unused-imports.stderr new file mode 100644 index 00000000000..a0292b6907e --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-imports.stderr @@ -0,0 +1,56 @@ +error: unused import: `use std::fmt::{};` + --> $DIR/lint-unused-imports.rs:18:1 + | +LL | use std::fmt::{}; + | ^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-unused-imports.rs:11:9 + | +LL | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: unused imports: `None`, `Some` + --> $DIR/lint-unused-imports.rs:22:27 + | +LL | use std::option::Option::{Some, None}; + | ^^^^ ^^^^ + +error: unused import: `test::A` + --> $DIR/lint-unused-imports.rs:25:5 + | +LL | use test::A; //~ ERROR unused import: `test::A` + | ^^^^^^^ + +error: unused import: `bar` + --> $DIR/lint-unused-imports.rs:34:18 + | +LL | use test2::{foo, bar}; //~ ERROR unused import: `bar` + | ^^^ + +error: unused import: `foo::Square` + --> $DIR/lint-unused-imports.rs:62:13 + | +LL | use foo::Square; //~ ERROR unused import: `foo::Square` + | ^^^^^^^^^^^ + +error: unused import: `self::g` + --> $DIR/lint-unused-imports.rs:78:9 + | +LL | use self::g; //~ ERROR unused import: `self::g` + | ^^^^^^^ + +error: unused import: `test2::foo` + --> $DIR/lint-unused-imports.rs:87:9 + | +LL | use test2::foo; //~ ERROR unused import: `test2::foo` + | ^^^^^^^^^^ + +error: unused import: `test::B2` + --> $DIR/lint-unused-imports.rs:30:5 + | +LL | use test::B2; //~ ERROR unused import: `test::B2` + | ^^^^^^^^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unused-mut-self.rs b/src/test/ui/compile-fail-migration/lint-unused-mut-self.rs new file mode 100644 index 00000000000..370f664e430 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-mut-self.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_assignments)] +#![allow(unused_variables)] +#![allow(dead_code)] +#![deny(unused_mut)] + +struct Foo; +impl Foo { + fn foo(mut self) {} //~ ERROR: variable does not need to be mutable + fn bar(mut self: Box) {} //~ ERROR: variable does not need to be mutable +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lint-unused-mut-self.stderr b/src/test/ui/compile-fail-migration/lint-unused-mut-self.stderr new file mode 100644 index 00000000000..af2baaa2e0a --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-mut-self.stderr @@ -0,0 +1,24 @@ +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-self.rs:18:12 + | +LL | fn foo(mut self) {} //~ ERROR: variable does not need to be mutable + | ----^^^^ + | | + | help: remove this `mut` + | +note: lint level defined here + --> $DIR/lint-unused-mut-self.rs:14:9 + | +LL | #![deny(unused_mut)] + | ^^^^^^^^^^ + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-self.rs:19:12 + | +LL | fn bar(mut self: Box) {} //~ ERROR: variable does not need to be mutable + | ----^^^^ + | | + | help: remove this `mut` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unused-mut-variables.lexical.stderr b/src/test/ui/compile-fail-migration/lint-unused-mut-variables.lexical.stderr new file mode 100644 index 00000000000..40f68c67827 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-mut-variables.lexical.stderr @@ -0,0 +1,150 @@ +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:59:14 + | +LL | let x = |mut y: isize| 10; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + | +note: lint level defined here + --> $DIR/lint-unused-mut-variables.rs:19:9 + | +LL | #![deny(unused_mut)] + | ^^^^^^^^^^ + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:24:9 + | +LL | let mut a = 3; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:26:9 + | +LL | let mut a = 2; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:28:9 + | +LL | let mut b = 3; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:30:9 + | +LL | let mut a = vec![3]; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:32:10 + | +LL | let (mut a, b) = (1, 2); //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:34:9 + | +LL | let mut a; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:38:9 + | +LL | let mut b; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:47:9 + | +LL | mut x => {} //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:51:8 + | +LL | (mut x, 1) | //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:64:9 + | +LL | let mut a = &mut 5; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:69:9 + | +LL | let mut b = (&mut a,); //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:72:9 + | +LL | let mut x = &mut 1; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:84:9 + | +LL | let mut v : &mut Vec<()> = &mut vec![]; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:61:13 + | +LL | fn what(mut foo: isize) {} //[lexical]~ ERROR: variable does not need to be mutable + | ----^^^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:79:20 + | +LL | fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { + | ----^^^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:143:9 + | +LL | let mut b = vec![2]; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + | +note: lint level defined here + --> $DIR/lint-unused-mut-variables.rs:139:8 + | +LL | #[deny(unused_mut)] + | ^^^^^^^^^^ + +error: aborting due to 17 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unused-mut-variables.nll.stderr b/src/test/ui/compile-fail-migration/lint-unused-mut-variables.nll.stderr new file mode 100644 index 00000000000..40f68c67827 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-mut-variables.nll.stderr @@ -0,0 +1,150 @@ +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:59:14 + | +LL | let x = |mut y: isize| 10; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + | +note: lint level defined here + --> $DIR/lint-unused-mut-variables.rs:19:9 + | +LL | #![deny(unused_mut)] + | ^^^^^^^^^^ + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:24:9 + | +LL | let mut a = 3; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:26:9 + | +LL | let mut a = 2; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:28:9 + | +LL | let mut b = 3; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:30:9 + | +LL | let mut a = vec![3]; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:32:10 + | +LL | let (mut a, b) = (1, 2); //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:34:9 + | +LL | let mut a; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:38:9 + | +LL | let mut b; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:47:9 + | +LL | mut x => {} //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:51:8 + | +LL | (mut x, 1) | //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:64:9 + | +LL | let mut a = &mut 5; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:69:9 + | +LL | let mut b = (&mut a,); //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:72:9 + | +LL | let mut x = &mut 1; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:84:9 + | +LL | let mut v : &mut Vec<()> = &mut vec![]; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:61:13 + | +LL | fn what(mut foo: isize) {} //[lexical]~ ERROR: variable does not need to be mutable + | ----^^^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:79:20 + | +LL | fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { + | ----^^^ + | | + | help: remove this `mut` + +error: variable does not need to be mutable + --> $DIR/lint-unused-mut-variables.rs:143:9 + | +LL | let mut b = vec![2]; //[lexical]~ ERROR: variable does not need to be mutable + | ----^ + | | + | help: remove this `mut` + | +note: lint level defined here + --> $DIR/lint-unused-mut-variables.rs:139:8 + | +LL | #[deny(unused_mut)] + | ^^^^^^^^^^ + +error: aborting due to 17 previous errors + diff --git a/src/test/ui/compile-fail-migration/lint-unused-mut-variables.rs b/src/test/ui/compile-fail-migration/lint-unused-mut-variables.rs new file mode 100644 index 00000000000..14d836074dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-unused-mut-variables.rs @@ -0,0 +1,145 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: lexical nll +#![cfg_attr(nll, feature(nll))] + +// Exercise the unused_mut attribute in some positive and negative cases + +#![allow(unused_assignments)] +#![allow(unused_variables)] +#![allow(dead_code)] +#![deny(unused_mut)] + + +fn main() { + // negative cases + let mut a = 3; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + let mut a = 2; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + let mut b = 3; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + let mut a = vec![3]; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + let (mut a, b) = (1, 2); //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + let mut a; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + a = 3; + + let mut b; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + if true { + b = 3; + } else { + b = 4; + } + + match 30 { + mut x => {} //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + } + match (30, 2) { + (mut x, 1) | //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + (mut x, 2) | + (mut x, 3) => { + } + _ => {} + } + + let x = |mut y: isize| 10; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + fn what(mut foo: isize) {} //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + + let mut a = &mut 5; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + *a = 4; + + let mut a = 5; + let mut b = (&mut a,); //[lexical]~ ERROR: variable does not need to be mutable + *b.0 = 4; //[nll]~^ ERROR: variable does not need to be mutable + + let mut x = &mut 1; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + let mut f = || { + *x += 1; + }; + f(); + + fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { + &mut arg[..] //[lexical]~^ ERROR: variable does not need to be mutable + //[nll]~^^ ERROR: variable does not need to be mutable + } + + let mut v : &mut Vec<()> = &mut vec![]; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable + v.push(()); + + // positive cases + let mut a = 2; + a = 3; + let mut a = Vec::new(); + a.push(3); + let mut a = Vec::new(); + callback(|| { + a.push(3); + }); + let mut a = Vec::new(); + callback(|| { + callback(|| { + a.push(3); + }); + }); + let (mut a, b) = (1, 2); + a = 34; + + match 30 { + mut x => { + x = 21; + } + } + + match (30, 2) { + (mut x, 1) | + (mut x, 2) | + (mut x, 3) => { + x = 21 + } + _ => {} + } + + let x = |mut y: isize| y = 32; + fn nothing(mut foo: isize) { foo = 37; } + + // leading underscore should avoid the warning, just like the + // unused variable lint. + let mut _allowed = 1; +} + +fn callback(f: F) where F: FnOnce() {} + +// make sure the lint attribute can be turned off +#[allow(unused_mut)] +fn foo(mut a: isize) { + let mut a = 3; + let mut b = vec![2]; +} + +// make sure the lint attribute can be turned off on let statements +#[deny(unused_mut)] +fn bar() { + #[allow(unused_mut)] + let mut a = 3; + let mut b = vec![2]; //[lexical]~ ERROR: variable does not need to be mutable + //[nll]~^ ERROR: variable does not need to be mutable +} diff --git a/src/test/ui/compile-fail-migration/lint-uppercase-variables.rs b/src/test/ui/compile-fail-migration/lint-uppercase-variables.rs new file mode 100644 index 00000000000..1d947684792 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-uppercase-variables.rs @@ -0,0 +1,41 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![warn(unused)] +#![allow(dead_code)] +#![deny(non_snake_case)] + +mod foo { + pub enum Foo { Foo } +} + +struct Something { + X: usize //~ ERROR structure field `X` should have a snake case name such as `x` +} + +fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name such as `xx` + println!("{}", Xx); +} + +fn main() { + let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test` + println!("{}", Test); + + match foo::Foo::Foo { + Foo => {} +//~^ ERROR variable `Foo` should have a snake case name such as `foo` +//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo` +//~^^^ WARN unused variable: `Foo` + } + + test(1); + + let _ = Something { X: 0 }; +} diff --git a/src/test/ui/compile-fail-migration/lint-uppercase-variables.stderr b/src/test/ui/compile-fail-migration/lint-uppercase-variables.stderr new file mode 100644 index 00000000000..c8381d89adc --- /dev/null +++ b/src/test/ui/compile-fail-migration/lint-uppercase-variables.stderr @@ -0,0 +1,52 @@ +warning[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` + --> $DIR/lint-uppercase-variables.rs:32:9 + | +LL | Foo => {} + | ^^^ help: to match on the variant, qualify the path: `foo::Foo::Foo` + +warning: unused variable: `Foo` + --> $DIR/lint-uppercase-variables.rs:32:9 + | +LL | Foo => {} + | ^^^ help: consider using `_Foo` instead + | +note: lint level defined here + --> $DIR/lint-uppercase-variables.rs:11:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: #[warn(unused_variables)] implied by #[warn(unused)] + +error: structure field `X` should have a snake case name such as `x` + --> $DIR/lint-uppercase-variables.rs:20:5 + | +LL | X: usize //~ ERROR structure field `X` should have a snake case name such as `x` + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint-uppercase-variables.rs:13:9 + | +LL | #![deny(non_snake_case)] + | ^^^^^^^^^^^^^^ + +error: variable `Xx` should have a snake case name such as `xx` + --> $DIR/lint-uppercase-variables.rs:23:9 + | +LL | fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name such as `xx` + | ^^ + +error: variable `Test` should have a snake case name such as `test` + --> $DIR/lint-uppercase-variables.rs:28:9 + | +LL | let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test` + | ^^^^ + +error: variable `Foo` should have a snake case name such as `foo` + --> $DIR/lint-uppercase-variables.rs:32:9 + | +LL | Foo => {} + | ^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0170`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.nll.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.nll.stderr new file mode 100644 index 00000000000..58a76bd2cf3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.nll.stderr @@ -0,0 +1,12 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-in-loop.rs:18:9 + | +LL | let v: isize; + | - consider changing this to `mut v` +... +LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.stderr new file mode 100644 index 00000000000..54419fd5b25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.ast.stderr @@ -0,0 +1,9 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-in-loop.rs:18:9 + | +LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.mir.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.mir.stderr new file mode 100644 index 00000000000..58a76bd2cf3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.mir.stderr @@ -0,0 +1,12 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-in-loop.rs:18:9 + | +LL | let v: isize; + | - consider changing this to `mut v` +... +LL | v = 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.rs b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.rs new file mode 100644 index 00000000000..7bc3680ca77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-loop.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Zborrowck=mir + +fn test() { + let v: isize; + //[mir]~^ NOTE consider changing this to `mut v` + loop { + v = 1; //[ast]~ ERROR cannot assign twice to immutable variable + //[mir]~^ ERROR cannot assign twice to immutable variable `v` + //[ast]~| NOTE cannot assign twice to immutable variable + //[mir]~| NOTE cannot assign twice to immutable variable + v.clone(); // just to prevent liveness warnings + } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.nll.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.nll.stderr new file mode 100644 index 00000000000..091547ed122 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-in-op-eq.rs:19:5 + | +LL | let v: isize; + | - consider changing this to `mut v` +LL | //[mir]~^ NOTE consider changing this to `mut v` +LL | v = 2; //[ast]~ NOTE first assignment + | ----- first assignment to `v` +LL | //[mir]~^ NOTE first assignment +LL | v += 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.stderr new file mode 100644 index 00000000000..a98c3c29bd2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.ast.stderr @@ -0,0 +1,12 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-in-op-eq.rs:19:5 + | +LL | v = 2; //[ast]~ NOTE first assignment + | ----- first assignment to `v` +LL | //[mir]~^ NOTE first assignment +LL | v += 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.mir.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.mir.stderr new file mode 100644 index 00000000000..091547ed122 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.mir.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-in-op-eq.rs:19:5 + | +LL | let v: isize; + | - consider changing this to `mut v` +LL | //[mir]~^ NOTE consider changing this to `mut v` +LL | v = 2; //[ast]~ NOTE first assignment + | ----- first assignment to `v` +LL | //[mir]~^ NOTE first assignment +LL | v += 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.rs b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.rs new file mode 100644 index 00000000000..7812cdd8684 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-in-op-eq.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Zborrowck=mir + +fn test() { + let v: isize; + //[mir]~^ NOTE consider changing this to `mut v` + v = 2; //[ast]~ NOTE first assignment + //[mir]~^ NOTE first assignment + v += 1; //[ast]~ ERROR cannot assign twice to immutable variable + //[mir]~^ ERROR cannot assign twice to immutable variable `v` + //[ast]~| NOTE cannot assign twice to immutable + //[mir]~| NOTE cannot assign twice to immutable + v.clone(); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.nll.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.nll.stderr new file mode 100644 index 00000000000..e954b1f5e0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `b` + --> $DIR/liveness-assign-imm-local-with-drop.rs:19:5 + | +LL | let b = Box::new(1); //[ast]~ NOTE first assignment + | - + | | + | first assignment to `b` + | consider changing this to `mut b` +... +LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.stderr new file mode 100644 index 00000000000..6abcf175f48 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.ast.stderr @@ -0,0 +1,12 @@ +error[E0384]: cannot assign twice to immutable variable `b` + --> $DIR/liveness-assign-imm-local-with-drop.rs:19:5 + | +LL | let b = Box::new(1); //[ast]~ NOTE first assignment + | - first assignment to `b` +... +LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.mir.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.mir.stderr new file mode 100644 index 00000000000..e954b1f5e0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.mir.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `b` + --> $DIR/liveness-assign-imm-local-with-drop.rs:19:5 + | +LL | let b = Box::new(1); //[ast]~ NOTE first assignment + | - + | | + | first assignment to `b` + | consider changing this to `mut b` +... +LL | b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.rs b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.rs new file mode 100644 index 00000000000..bb61a9037d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-drop.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Zborrowck=mir + +fn test() { + let b = Box::new(1); //[ast]~ NOTE first assignment + //[mir]~^ NOTE first assignment + //[mir]~| NOTE consider changing this to `mut b` + drop(b); + b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable + //[mir]~^ ERROR cannot assign twice to immutable variable `b` + //[ast]~| NOTE cannot assign twice to immutable + //[mir]~| NOTE cannot assign twice to immutable + drop(b); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.nll.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.nll.stderr new file mode 100644 index 00000000000..70a6ab3edf8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-with-init.rs:19:5 + | +LL | let v: isize = 1; //[ast]~ NOTE first assignment + | - + | | + | first assignment to `v` + | consider changing this to `mut v` +... +LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.stderr new file mode 100644 index 00000000000..47c780e83e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.ast.stderr @@ -0,0 +1,12 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-with-init.rs:19:5 + | +LL | let v: isize = 1; //[ast]~ NOTE first assignment + | - first assignment to `v` +... +LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.mir.stderr b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.mir.stderr new file mode 100644 index 00000000000..70a6ab3edf8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.mir.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/liveness-assign-imm-local-with-init.rs:19:5 + | +LL | let v: isize = 1; //[ast]~ NOTE first assignment + | - + | | + | first assignment to `v` + | consider changing this to `mut v` +... +LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.rs b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.rs new file mode 100644 index 00000000000..672e9fab837 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-assign-imm-local-with-init.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Zborrowck=mir + +fn test() { + let v: isize = 1; //[ast]~ NOTE first assignment + //[mir]~^ NOTE first assignment + //[mir]~| NOTE consider changing this to `mut v` + v.clone(); + v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + //[mir]~^ ERROR cannot assign twice to immutable variable `v` + //[ast]~| NOTE cannot assign twice to immutable + //[mir]~| NOTE cannot assign twice to immutable + v.clone(); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/liveness-closure-require-ret.rs b/src/test/ui/compile-fail-migration/liveness-closure-require-ret.rs new file mode 100644 index 00000000000..17cd8231222 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-closure-require-ret.rs @@ -0,0 +1,12 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn force(f: F) -> isize where F: FnOnce() -> isize { f() } +fn main() { println!("{}", force(|| {})); } //~ ERROR mismatched types diff --git a/src/test/ui/compile-fail-migration/liveness-closure-require-ret.stderr b/src/test/ui/compile-fail-migration/liveness-closure-require-ret.stderr new file mode 100644 index 00000000000..569640c9e20 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-closure-require-ret.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/liveness-closure-require-ret.rs:12:37 + | +LL | fn main() { println!("{}", force(|| {})); } //~ ERROR mismatched types + | ^^ expected isize, found () + | + = note: expected type `isize` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/liveness-dead.rs b/src/test/ui/compile-fail-migration/liveness-dead.rs new file mode 100644 index 00000000000..ddd8fc68c43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-dead.rs @@ -0,0 +1,40 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![deny(unused_assignments)] + +fn f1(x: &mut isize) { + *x = 1; // no error +} + +fn f2() { + let mut x: isize = 3; //~ ERROR: value assigned to `x` is never read + x = 4; + x.clone(); +} + +fn f3() { + let mut x: isize = 3; + x.clone(); + x = 4; //~ ERROR: value assigned to `x` is never read +} + +fn f4(mut x: i32) { //~ ERROR: value passed to `x` is never read + x = 4; + x.clone(); +} + +fn f5(mut x: i32) { + x.clone(); + x = 4; //~ ERROR: value assigned to `x` is never read +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/liveness-dead.stderr b/src/test/ui/compile-fail-migration/liveness-dead.stderr new file mode 100644 index 00000000000..6709fee0abb --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-dead.stderr @@ -0,0 +1,32 @@ +error: value assigned to `x` is never read + --> $DIR/liveness-dead.rs:19:13 + | +LL | let mut x: isize = 3; //~ ERROR: value assigned to `x` is never read + | ^ + | +note: lint level defined here + --> $DIR/liveness-dead.rs:12:9 + | +LL | #![deny(unused_assignments)] + | ^^^^^^^^^^^^^^^^^^ + +error: value assigned to `x` is never read + --> $DIR/liveness-dead.rs:27:5 + | +LL | x = 4; //~ ERROR: value assigned to `x` is never read + | ^ + +error: value passed to `x` is never read + --> $DIR/liveness-dead.rs:30:11 + | +LL | fn f4(mut x: i32) { //~ ERROR: value passed to `x` is never read + | ^ + +error: value assigned to `x` is never read + --> $DIR/liveness-dead.rs:37:5 + | +LL | x = 4; //~ ERROR: value assigned to `x` is never read + | ^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/liveness-forgot-ret.rs b/src/test/ui/compile-fail-migration/liveness-forgot-ret.rs new file mode 100644 index 00000000000..1ee4be08a1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-forgot-ret.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn god_exists(a: isize) -> bool { return god_exists(a); } + +fn f(a: isize) -> isize { if god_exists(a) { return 5; }; } +//~^ ERROR mismatched types + +fn main() { f(12); } diff --git a/src/test/ui/compile-fail-migration/liveness-forgot-ret.stderr b/src/test/ui/compile-fail-migration/liveness-forgot-ret.stderr new file mode 100644 index 00000000000..8da489bc9ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-forgot-ret.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/liveness-forgot-ret.rs:13:25 + | +LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected isize, found () + | + = note: expected type `isize` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/liveness-issue-2163.rs b/src/test/ui/compile-fail-migration/liveness-issue-2163.rs new file mode 100644 index 00000000000..69bceec8c32 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-issue-2163.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::vec::Vec; + +fn main() { + let a: Vec = Vec::new(); + a.iter().all(|_| -> bool { + //~^ ERROR mismatched types + }); +} diff --git a/src/test/ui/compile-fail-migration/liveness-issue-2163.stderr b/src/test/ui/compile-fail-migration/liveness-issue-2163.stderr new file mode 100644 index 00000000000..66cd67821be --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-issue-2163.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/liveness-issue-2163.rs:15:30 + | +LL | a.iter().all(|_| -> bool { + | ______________________________^ +LL | | //~^ ERROR mismatched types +LL | | }); + | |_____^ expected bool, found () + | + = note: expected type `bool` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/liveness-missing-ret2.rs b/src/test/ui/compile-fail-migration/liveness-missing-ret2.rs new file mode 100644 index 00000000000..a35eb1af4f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-missing-ret2.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> isize { //~ ERROR mismatched types + // Make sure typestate doesn't interpret this match expression as + // the function result + match true { true => { } _ => {} }; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/liveness-missing-ret2.stderr b/src/test/ui/compile-fail-migration/liveness-missing-ret2.stderr new file mode 100644 index 00000000000..b7bbea6225d --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-missing-ret2.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/liveness-missing-ret2.rs:11:17 + | +LL | fn f() -> isize { //~ ERROR mismatched types + | _________________^ +LL | | // Make sure typestate doesn't interpret this match expression as +LL | | // the function result +LL | | match true { true => { } _ => {} }; +LL | | } + | |_^ expected isize, found () + | + = note: expected type `isize` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/liveness-move-call-arg.rs b/src/test/ui/compile-fail-migration/liveness-move-call-arg.rs new file mode 100644 index 00000000000..9340964c1fb --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-move-call-arg.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn take(_x: Box) {} + +fn main() { + + let x: Box = box 25; + loop { + take(x); //~ ERROR use of moved value: `x` + } +} diff --git a/src/test/ui/compile-fail-migration/liveness-move-call-arg.stderr b/src/test/ui/compile-fail-migration/liveness-move-call-arg.stderr new file mode 100644 index 00000000000..f3423b8f5fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-move-call-arg.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `x` + --> $DIR/liveness-move-call-arg.rs:19:14 + | +LL | take(x); //~ ERROR use of moved value: `x` + | ^ value moved here in previous iteration of loop + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/liveness-move-in-loop.rs b/src/test/ui/compile-fail-migration/liveness-move-in-loop.rs new file mode 100644 index 00000000000..65ccaceac08 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-move-in-loop.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn main() { + let y: Box = box 42; + let mut x: Box; + loop { + println!("{}", y); + loop { + loop { + loop { + x = y; //~ ERROR use of moved value + x.clone(); + } + } + } + } +} diff --git a/src/test/ui/compile-fail-migration/liveness-move-in-loop.stderr b/src/test/ui/compile-fail-migration/liveness-move-in-loop.stderr new file mode 100644 index 00000000000..decc7659a64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-move-in-loop.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `y` + --> $DIR/liveness-move-in-loop.rs:21:25 + | +LL | x = y; //~ ERROR use of moved value + | ^ value moved here in previous iteration of loop + | + = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/liveness-move-in-while.nll.stderr b/src/test/ui/compile-fail-migration/liveness-move-in-while.nll.stderr new file mode 100644 index 00000000000..5ca5dc64709 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-move-in-while.nll.stderr @@ -0,0 +1,21 @@ +error[E0382]: borrow of moved value: `y` + --> $DIR/liveness-move-in-while.rs:17:24 + | +LL | println!("{}", y); //~ ERROR use of moved value: `y` + | ^ value borrowed here after move +LL | while true { while true { while true { x = y; x.clone(); } } } + | - value moved here + | + = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `y` + --> $DIR/liveness-move-in-while.rs:18:52 + | +LL | while true { while true { while true { x = y; x.clone(); } } } + | ^ value moved here in previous iteration of loop + | + = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/liveness-move-in-while.rs b/src/test/ui/compile-fail-migration/liveness-move-in-while.rs new file mode 100644 index 00000000000..cadfd487121 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-move-in-while.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn main() { + let y: Box = box 42; + let mut x: Box; + loop { + println!("{}", y); //~ ERROR use of moved value: `y` + while true { while true { while true { x = y; x.clone(); } } } + //~^ ERROR use of moved value: `y` + } +} diff --git a/src/test/ui/compile-fail-migration/liveness-move-in-while.stderr b/src/test/ui/compile-fail-migration/liveness-move-in-while.stderr new file mode 100644 index 00000000000..7ac3ea38cb5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-move-in-while.stderr @@ -0,0 +1,21 @@ +error[E0382]: use of moved value: `y` + --> $DIR/liveness-move-in-while.rs:17:24 + | +LL | println!("{}", y); //~ ERROR use of moved value: `y` + | ^ value used here after move +LL | while true { while true { while true { x = y; x.clone(); } } } + | - value moved here + | + = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `y` + --> $DIR/liveness-move-in-while.rs:18:52 + | +LL | while true { while true { while true { x = y; x.clone(); } } } + | ^ value moved here in previous iteration of loop + | + = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/liveness-unused.rs b/src/test/ui/compile-fail-migration/liveness-unused.rs new file mode 100644 index 00000000000..d056d6be806 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-unused.rs @@ -0,0 +1,151 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![warn(unused)] +#![deny(unused_variables)] +#![deny(unused_assignments)] +#![allow(dead_code, non_camel_case_types, trivial_numeric_casts)] + +use std::ops::AddAssign; + +fn f1(x: isize) { + //~^ ERROR unused variable: `x` +} + +fn f1b(x: &mut isize) { + //~^ ERROR unused variable: `x` +} + +#[allow(unused_variables)] +fn f1c(x: isize) {} + +fn f1d() { + let x: isize; + //~^ ERROR unused variable: `x` +} + +fn f2() { + let x = 3; + //~^ ERROR unused variable: `x` +} + +fn f3() { + let mut x = 3; + //~^ ERROR variable `x` is assigned to, but never used + x += 4; + //~^ ERROR value assigned to `x` is never read +} + +fn f3b() { + let mut z = 3; + //~^ ERROR variable `z` is assigned to, but never used + loop { + z += 4; + } +} + +#[allow(unused_variables)] +fn f3c() { + let mut z = 3; + loop { z += 4; } +} + +#[allow(unused_variables)] +#[allow(unused_assignments)] +fn f3d() { + let mut x = 3; + x += 4; +} + +fn f4() { + match Some(3) { + Some(i) => { + //~^ ERROR unused variable: `i` + } + None => {} + } +} + +enum tri { + a(isize), b(isize), c(isize) +} + +fn f4b() -> isize { + match tri::a(3) { + tri::a(i) | tri::b(i) | tri::c(i) => { + i + } + } +} + +fn f5a() { + for x in 1..10 { } + //~^ ERROR unused variable: `x` +} + +fn f5b() { + for (x, _) in [1, 2, 3].iter().enumerate() { } + //~^ ERROR unused variable: `x` +} + +fn f5c() { + for (_, x) in [1, 2, 3].iter().enumerate() { + //~^ ERROR unused variable: `x` + continue; + drop(*x as i32); //~ WARNING unreachable statement + } +} + +struct View<'a>(&'a mut [i32]); + +impl<'a> AddAssign for View<'a> { + fn add_assign(&mut self, rhs: i32) { + for lhs in self.0.iter_mut() { + *lhs += rhs; + } + } +} + +fn f6() { + let mut array = [1, 2, 3]; + let mut v = View(&mut array); + + // ensure an error shows up for x even if lhs of an overloaded add assign + + let x; + //~^ ERROR variable `x` is assigned to, but never used + + *({ + x = 0; //~ ERROR value assigned to `x` is never read + &mut v + }) += 1; +} + + +struct MutRef<'a>(&'a mut i32); + +impl<'a> AddAssign for MutRef<'a> { + fn add_assign(&mut self, rhs: i32) { + *self.0 += rhs; + } +} + +fn f7() { + let mut a = 1; + { + // `b` does not trigger unused_variables + let mut b = MutRef(&mut a); + b += 1; + } + drop(a); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/liveness-unused.stderr b/src/test/ui/compile-fail-migration/liveness-unused.stderr new file mode 100644 index 00000000000..2846f242fbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-unused.stderr @@ -0,0 +1,111 @@ +warning: unreachable statement + --> $DIR/liveness-unused.rs:102:9 + | +LL | drop(*x as i32); //~ WARNING unreachable statement + | ^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/liveness-unused.rs:11:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: #[warn(unreachable_code)] implied by #[warn(unused)] + +error: unused variable: `x` + --> $DIR/liveness-unused.rs:18:7 + | +LL | fn f1(x: isize) { + | ^ help: consider using `_x` instead + | +note: lint level defined here + --> $DIR/liveness-unused.rs:12:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +error: unused variable: `x` + --> $DIR/liveness-unused.rs:22:8 + | +LL | fn f1b(x: &mut isize) { + | ^ help: consider using `_x` instead + +error: unused variable: `x` + --> $DIR/liveness-unused.rs:30:9 + | +LL | let x: isize; + | ^ help: consider using `_x` instead + +error: unused variable: `x` + --> $DIR/liveness-unused.rs:35:9 + | +LL | let x = 3; + | ^ help: consider using `_x` instead + +error: variable `x` is assigned to, but never used + --> $DIR/liveness-unused.rs:40:13 + | +LL | let mut x = 3; + | ^ + | + = note: consider using `_x` instead + +error: value assigned to `x` is never read + --> $DIR/liveness-unused.rs:42:5 + | +LL | x += 4; + | ^ + | +note: lint level defined here + --> $DIR/liveness-unused.rs:13:9 + | +LL | #![deny(unused_assignments)] + | ^^^^^^^^^^^^^^^^^^ + +error: variable `z` is assigned to, but never used + --> $DIR/liveness-unused.rs:47:13 + | +LL | let mut z = 3; + | ^ + | + = note: consider using `_z` instead + +error: unused variable: `i` + --> $DIR/liveness-unused.rs:69:12 + | +LL | Some(i) => { + | ^ help: consider using `_i` instead + +error: unused variable: `x` + --> $DIR/liveness-unused.rs:89:9 + | +LL | for x in 1..10 { } + | ^ help: consider using `_x` instead + +error: unused variable: `x` + --> $DIR/liveness-unused.rs:94:10 + | +LL | for (x, _) in [1, 2, 3].iter().enumerate() { } + | ^ help: consider using `_x` instead + +error: unused variable: `x` + --> $DIR/liveness-unused.rs:99:13 + | +LL | for (_, x) in [1, 2, 3].iter().enumerate() { + | ^ help: consider using `_x` instead + +error: variable `x` is assigned to, but never used + --> $DIR/liveness-unused.rs:122:9 + | +LL | let x; + | ^ + | + = note: consider using `_x` instead + +error: value assigned to `x` is never read + --> $DIR/liveness-unused.rs:126:9 + | +LL | x = 0; //~ ERROR value assigned to `x` is never read + | ^ + +error: aborting due to 13 previous errors + diff --git a/src/test/ui/compile-fail-migration/liveness-use-after-move.nll.stderr b/src/test/ui/compile-fail-migration/liveness-use-after-move.nll.stderr new file mode 100644 index 00000000000..62d9a8b115a --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-use-after-move.nll.stderr @@ -0,0 +1,11 @@ +error[E0382]: borrow of moved value: `*x` + --> $DIR/liveness-use-after-move.rs:16:20 + | +LL | let y = x; + | - value moved here +LL | println!("{}", *x); //~ ERROR use of moved value: `*x` + | ^^ value borrowed here after move + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/liveness-use-after-move.rs b/src/test/ui/compile-fail-migration/liveness-use-after-move.rs new file mode 100644 index 00000000000..6fcab380030 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-use-after-move.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn main() { + let x: Box<_> = box 5; + let y = x; + println!("{}", *x); //~ ERROR use of moved value: `*x` + y.clone(); +} diff --git a/src/test/ui/compile-fail-migration/liveness-use-after-move.stderr b/src/test/ui/compile-fail-migration/liveness-use-after-move.stderr new file mode 100644 index 00000000000..be6f89c7357 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-use-after-move.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `*x` + --> $DIR/liveness-use-after-move.rs:16:20 + | +LL | let y = x; + | - value moved here +LL | println!("{}", *x); //~ ERROR use of moved value: `*x` + | ^^ value used here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/liveness-use-after-send.nll.stderr b/src/test/ui/compile-fail-migration/liveness-use-after-send.nll.stderr new file mode 100644 index 00000000000..dbffe6c9135 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-use-after-send.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: borrow of moved value: `message` + --> $DIR/liveness-use-after-send.rs:26:20 + | +LL | send(ch, message); + | ------- value moved here +LL | println!("{}", message); //~ ERROR use of moved value: `message` + | ^^^^^^^ value borrowed here after move + | + = note: move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/liveness-use-after-send.rs b/src/test/ui/compile-fail-migration/liveness-use-after-send.rs new file mode 100644 index 00000000000..03d8d62e0b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-use-after-send.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker; + +fn send(ch: _chan, data: T) { + println!("{:?}", ch); + println!("{:?}", data); + panic!(); +} + +#[derive(Debug)] +struct _chan(isize, marker::PhantomData); + +// Tests that "log(debug, message);" is flagged as using +// message after the send deinitializes it +fn test00_start(ch: _chan>, message: Box, _count: Box) { + send(ch, message); + println!("{}", message); //~ ERROR use of moved value: `message` +} + +fn main() { panic!(); } diff --git a/src/test/ui/compile-fail-migration/liveness-use-after-send.stderr b/src/test/ui/compile-fail-migration/liveness-use-after-send.stderr new file mode 100644 index 00000000000..94499aabb97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/liveness-use-after-send.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `message` + --> $DIR/liveness-use-after-send.rs:26:20 + | +LL | send(ch, message); + | ------- value moved here +LL | println!("{}", message); //~ ERROR use of moved value: `message` + | ^^^^^^^ value used here after move + | + = note: move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/loop-break-value.rs b/src/test/ui/compile-fail-migration/loop-break-value.rs new file mode 100644 index 00000000000..938f7fba2a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-break-value.rs @@ -0,0 +1,103 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] + +fn main() { + let val: ! = loop { break break; }; + //~^ ERROR mismatched types + + loop { + if true { + break "asdf"; + } else { + break 123; //~ ERROR mismatched types + } + }; + + let _: i32 = loop { + break "asdf"; //~ ERROR mismatched types + }; + + let _: i32 = 'outer_loop: loop { + loop { + break 'outer_loop "nope"; //~ ERROR mismatched types + break "ok"; + }; + }; + + 'while_loop: while true { + break; + break (); //~ ERROR `break` with value from a `while` loop + loop { + break 'while_loop 123; + //~^ ERROR `break` with value from a `while` loop + break 456; + break 789; + }; + } + + while let Some(_) = Some(()) { + if break () { //~ ERROR `break` with value from a `while let` loop + } + } + + while let Some(_) = Some(()) { + break None; + //~^ ERROR `break` with value from a `while let` loop + } + + 'while_let_loop: while let Some(_) = Some(()) { + loop { + break 'while_let_loop "nope"; + //~^ ERROR `break` with value from a `while let` loop + break 33; + }; + } + + for _ in &[1,2,3] { + break (); //~ ERROR `break` with value from a `for` loop + break [()]; + //~^ ERROR `break` with value from a `for` loop + } + + 'for_loop: for _ in &[1,2,3] { + loop { + break Some(3); + break 'for_loop Some(17); + //~^ ERROR `break` with value from a `for` loop + }; + } + + let _: i32 = 'a: loop { + let _: () = 'b: loop { + break ('c: loop { + break; + break 'c 123; //~ ERROR mismatched types + }); + break 'a 123; + }; + }; + + loop { + break (break, break); //~ ERROR mismatched types + }; + + loop { + break; + break 2; //~ ERROR mismatched types + }; + + loop { + break 2; + break; //~ ERROR mismatched types + break 4; + }; +} diff --git a/src/test/ui/compile-fail-migration/loop-break-value.stderr b/src/test/ui/compile-fail-migration/loop-break-value.stderr new file mode 100644 index 00000000000..ca286285c38 --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-break-value.stderr @@ -0,0 +1,156 @@ +error[E0571]: `break` with value from a `while` loop + --> $DIR/loop-break-value.rs:38:9 + | +LL | break (); //~ ERROR `break` with value from a `while` loop + | ^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `while` loop + | +LL | break; //~ ERROR `break` with value from a `while` loop + | ^^^^^ + +error[E0571]: `break` with value from a `while` loop + --> $DIR/loop-break-value.rs:40:13 + | +LL | break 'while_loop 123; + | ^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `while` loop + | +LL | break; + | ^^^^^ + +error[E0571]: `break` with value from a `while let` loop + --> $DIR/loop-break-value.rs:48:12 + | +LL | if break () { //~ ERROR `break` with value from a `while let` loop + | ^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `while let` loop + | +LL | if break { //~ ERROR `break` with value from a `while let` loop + | ^^^^^ + +error[E0571]: `break` with value from a `while let` loop + --> $DIR/loop-break-value.rs:53:9 + | +LL | break None; + | ^^^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `while let` loop + | +LL | break; + | ^^^^^ + +error[E0571]: `break` with value from a `while let` loop + --> $DIR/loop-break-value.rs:59:13 + | +LL | break 'while_let_loop "nope"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `while let` loop + | +LL | break; + | ^^^^^ + +error[E0571]: `break` with value from a `for` loop + --> $DIR/loop-break-value.rs:66:9 + | +LL | break (); //~ ERROR `break` with value from a `for` loop + | ^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `for` loop + | +LL | break; //~ ERROR `break` with value from a `for` loop + | ^^^^^ + +error[E0571]: `break` with value from a `for` loop + --> $DIR/loop-break-value.rs:67:9 + | +LL | break [()]; + | ^^^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `for` loop + | +LL | break; + | ^^^^^ + +error[E0571]: `break` with value from a `for` loop + --> $DIR/loop-break-value.rs:74:13 + | +LL | break 'for_loop Some(17); + | ^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block +help: instead, use `break` on its own without a value inside this `for` loop + | +LL | break; + | ^^^^^ + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:14:31 + | +LL | let val: ! = loop { break break; }; + | ^^^^^ expected (), found ! + | + = note: expected type `()` + found type `!` + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:21:19 + | +LL | break 123; //~ ERROR mismatched types + | ^^^ expected &str, found integral variable + | + = note: expected type `&str` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:26:15 + | +LL | break "asdf"; //~ ERROR mismatched types + | ^^^^^^ expected i32, found reference + | + = note: expected type `i32` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:31:31 + | +LL | break 'outer_loop "nope"; //~ ERROR mismatched types + | ^^^^^^ expected i32, found reference + | + = note: expected type `i32` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:83:26 + | +LL | break 'c 123; //~ ERROR mismatched types + | ^^^ expected (), found integral variable + | + = note: expected type `()` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:90:15 + | +LL | break (break, break); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^ expected (), found tuple + | + = note: expected type `()` + found type `(!, !)` + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:95:15 + | +LL | break 2; //~ ERROR mismatched types + | ^ expected (), found integral variable + | + = note: expected type `()` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:100:9 + | +LL | break; //~ ERROR mismatched types + | ^^^^^ expected (), found integral variable + | + = note: expected type `()` + found type `{integer}` + +error: aborting due to 16 previous errors + +Some errors occurred: E0308, E0571. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/loop-labeled-break-value.rs b/src/test/ui/compile-fail-migration/loop-labeled-break-value.rs new file mode 100644 index 00000000000..f0792c145d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-labeled-break-value.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + loop { + let _: i32 = loop { break }; //~ ERROR mismatched types + } + loop { + let _: i32 = 'inner: loop { break 'inner }; //~ ERROR mismatched types + } + loop { + let _: i32 = 'inner2: loop { loop { break 'inner2 } }; //~ ERROR mismatched types + } +} diff --git a/src/test/ui/compile-fail-migration/loop-labeled-break-value.stderr b/src/test/ui/compile-fail-migration/loop-labeled-break-value.stderr new file mode 100644 index 00000000000..7d140aa8aac --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-labeled-break-value.stderr @@ -0,0 +1,30 @@ +error[E0308]: mismatched types + --> $DIR/loop-labeled-break-value.rs:13:29 + | +LL | let _: i32 = loop { break }; //~ ERROR mismatched types + | ^^^^^ expected (), found i32 + | + = note: expected type `()` + found type `i32` + +error[E0308]: mismatched types + --> $DIR/loop-labeled-break-value.rs:16:37 + | +LL | let _: i32 = 'inner: loop { break 'inner }; //~ ERROR mismatched types + | ^^^^^^^^^^^^ expected (), found i32 + | + = note: expected type `()` + found type `i32` + +error[E0308]: mismatched types + --> $DIR/loop-labeled-break-value.rs:19:45 + | +LL | let _: i32 = 'inner2: loop { loop { break 'inner2 } }; //~ ERROR mismatched types + | ^^^^^^^^^^^^^ expected (), found i32 + | + = note: expected type `()` + found type `i32` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/loop-proper-liveness.nll.stderr b/src/test/ui/compile-fail-migration/loop-proper-liveness.nll.stderr new file mode 100644 index 00000000000..cbf7094d837 --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-proper-liveness.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `x` + --> $DIR/loop-proper-liveness.rs:19:22 + | +LL | println!("{:?}", x); //~ ERROR use of possibly uninitialized variable + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/loop-proper-liveness.rs b/src/test/ui/compile-fail-migration/loop-proper-liveness.rs new file mode 100644 index 00000000000..e411313c273 --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-proper-liveness.rs @@ -0,0 +1,42 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn test1() { + // In this test the outer 'a loop may terminate without `x` getting initialised. Although the + // `x = loop { ... }` statement is reached, the value itself ends up never being computed and + // thus leaving `x` uninit. + let x: i32; + 'a: loop { + x = loop { break 'a }; + } + println!("{:?}", x); //~ ERROR use of possibly uninitialized variable +} + +// test2 and test3 should not fail. +fn test2() { + // In this test the `'a` loop will never terminate thus making the use of `x` unreachable. + let x: i32; + 'a: loop { + x = loop { continue 'a }; + } + println!("{:?}", x); +} + +fn test3() { + let x: i32; + // Similarly, the use of variable `x` is unreachable. + 'a: loop { + x = loop { return }; + } + println!("{:?}", x); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/loop-proper-liveness.stderr b/src/test/ui/compile-fail-migration/loop-proper-liveness.stderr new file mode 100644 index 00000000000..554abea91e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-proper-liveness.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/loop-proper-liveness.rs:19:22 + | +LL | println!("{:?}", x); //~ ERROR use of possibly uninitialized variable + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/loop-properly-diverging-2.rs b/src/test/ui/compile-fail-migration/loop-properly-diverging-2.rs new file mode 100644 index 00000000000..c22091ce63c --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-properly-diverging-2.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn forever2() -> i32 { + let x: i32 = loop { break }; //~ ERROR mismatched types + x +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/loop-properly-diverging-2.stderr b/src/test/ui/compile-fail-migration/loop-properly-diverging-2.stderr new file mode 100644 index 00000000000..f9836538382 --- /dev/null +++ b/src/test/ui/compile-fail-migration/loop-properly-diverging-2.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/loop-properly-diverging-2.rs:12:23 + | +LL | let x: i32 = loop { break }; //~ ERROR mismatched types + | ^^^^^ expected (), found i32 + | + = note: expected type `()` + found type `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/lto-duplicate-symbols.rs b/src/test/ui/compile-fail-migration/lto-duplicate-symbols.rs new file mode 100644 index 00000000000..9c1dbfc2af9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lto-duplicate-symbols.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lto-duplicate-symbols1.rs +// aux-build:lto-duplicate-symbols2.rs +// error-pattern:Linking globals named 'foo': symbol multiply defined! +// compile-flags: -C lto +// no-prefer-dynamic + +extern crate lto_duplicate_symbols1; +extern crate lto_duplicate_symbols2; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lto-duplicate-symbols.stderr b/src/test/ui/compile-fail-migration/lto-duplicate-symbols.stderr new file mode 100644 index 00000000000..2f0e57199bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/lto-duplicate-symbols.stderr @@ -0,0 +1,6 @@ +warning: Linking globals named 'foo': symbol multiply defined! + +error: failed to load bc of "lto_duplicate_symbols10-8787f43e282added376259c1adb08b80.rs": + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/lub-if.nll.stderr b/src/test/ui/compile-fail-migration/lub-if.nll.stderr new file mode 100644 index 00000000000..a34e280bfa6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lub-if.nll.stderr @@ -0,0 +1,30 @@ +warning: not reporting region error due to nll + --> $DIR/lub-if.rs:38:9 + | +LL | s //~ ERROR E0312 + | ^ + +warning: not reporting region error due to nll + --> $DIR/lub-if.rs:45:9 + | +LL | s //~ ERROR E0312 + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/lub-if.rs:34:8 + | +LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { + | -- lifetime `'a` defined here +LL | if maybestr.is_none() { + | ^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/lub-if.rs:43:8 + | +LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { + | -- lifetime `'a` defined here +LL | if maybestr.is_some() { + | ^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lub-if.rs b/src/test/ui/compile-fail-migration/lub-if.rs new file mode 100644 index 00000000000..8d2a0fd07e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lub-if.rs @@ -0,0 +1,52 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we correctly consider the type of `match` to be the LUB +// of the various arms, particularly in the case where regions are +// involved. + +pub fn opt_str0<'a>(maybestr: &'a Option) -> &'a str { + if maybestr.is_none() { + "(none)" + } else { + let s: &'a str = maybestr.as_ref().unwrap(); + s + } +} + +pub fn opt_str1<'a>(maybestr: &'a Option) -> &'a str { + if maybestr.is_some() { + let s: &'a str = maybestr.as_ref().unwrap(); + s + } else { + "(none)" + } +} + +pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { + if maybestr.is_none() { + "(none)" + } else { + let s: &'a str = maybestr.as_ref().unwrap(); + s //~ ERROR E0312 + } +} + +pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { + if maybestr.is_some() { + let s: &'a str = maybestr.as_ref().unwrap(); + s //~ ERROR E0312 + } else { + "(none)" + } +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lub-if.stderr b/src/test/ui/compile-fail-migration/lub-if.stderr new file mode 100644 index 00000000000..4a436810170 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lub-if.stderr @@ -0,0 +1,29 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/lub-if.rs:38:9 + | +LL | s //~ ERROR E0312 + | ^ + | + = note: ...the reference is valid for the static lifetime... +note: ...but the borrowed content is only valid for the lifetime 'a as defined on the function body at 33:17 + --> $DIR/lub-if.rs:33:17 + | +LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { + | ^^ + +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/lub-if.rs:45:9 + | +LL | s //~ ERROR E0312 + | ^ + | + = note: ...the reference is valid for the static lifetime... +note: ...but the borrowed content is only valid for the lifetime 'a as defined on the function body at 42:17 + --> $DIR/lub-if.rs:42:17 + | +LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/lub-match.nll.stderr b/src/test/ui/compile-fail-migration/lub-match.nll.stderr new file mode 100644 index 00000000000..22bd6ea4081 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lub-match.nll.stderr @@ -0,0 +1,30 @@ +warning: not reporting region error due to nll + --> $DIR/lub-match.rs:40:13 + | +LL | s //~ ERROR E0312 + | ^ + +warning: not reporting region error due to nll + --> $DIR/lub-match.rs:49:13 + | +LL | s //~ ERROR E0312 + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/lub-match.rs:36:11 + | +LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { + | -- lifetime `'a` defined here +LL | match *maybestr { + | ^^^^^^^^^ requires that `'a` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/lub-match.rs:46:11 + | +LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { + | -- lifetime `'a` defined here +LL | match *maybestr { + | ^^^^^^^^^ requires that `'a` must outlive `'static` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/lub-match.rs b/src/test/ui/compile-fail-migration/lub-match.rs new file mode 100644 index 00000000000..b9423feb5c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/lub-match.rs @@ -0,0 +1,55 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we correctly consider the type of `match` to be the LUB +// of the various arms, particularly in the case where regions are +// involved. + +pub fn opt_str0<'a>(maybestr: &'a Option) -> &'a str { + match *maybestr { + Some(ref s) => { + let s: &'a str = s; + s + } + None => "(none)", + } +} + +pub fn opt_str1<'a>(maybestr: &'a Option) -> &'a str { + match *maybestr { + None => "(none)", + Some(ref s) => { + let s: &'a str = s; + s + } + } +} + +pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { + match *maybestr { + None => "(none)", + Some(ref s) => { + let s: &'a str = s; + s //~ ERROR E0312 + } + } +} + +pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { + match *maybestr { + Some(ref s) => { + let s: &'a str = s; + s //~ ERROR E0312 + } + None => "(none)", + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/lub-match.stderr b/src/test/ui/compile-fail-migration/lub-match.stderr new file mode 100644 index 00000000000..3543676ad2f --- /dev/null +++ b/src/test/ui/compile-fail-migration/lub-match.stderr @@ -0,0 +1,29 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/lub-match.rs:40:13 + | +LL | s //~ ERROR E0312 + | ^ + | + = note: ...the reference is valid for the static lifetime... +note: ...but the borrowed content is only valid for the lifetime 'a as defined on the function body at 35:17 + --> $DIR/lub-match.rs:35:17 + | +LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { + | ^^ + +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/lub-match.rs:49:13 + | +LL | s //~ ERROR E0312 + | ^ + | + = note: ...the reference is valid for the static lifetime... +note: ...but the borrowed content is only valid for the lifetime 'a as defined on the function body at 45:17 + --> $DIR/lub-match.rs:45:17 + | +LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/macro-attribute.rs b/src/test/ui/compile-fail-migration/macro-attribute.rs new file mode 100644 index 00000000000..a77b1724876 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-attribute.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[doc = $not_there] //~ ERROR arbitrary tokens in non-macro attributes are unstable +fn main() { } diff --git a/src/test/ui/compile-fail-migration/macro-attribute.stderr b/src/test/ui/compile-fail-migration/macro-attribute.stderr new file mode 100644 index 00000000000..8a3eb207953 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-attribute.stderr @@ -0,0 +1,8 @@ +error: unexpected token: `$` + --> $DIR/macro-attribute.rs:11:7 + | +LL | #[doc = $not_there] //~ error: unexpected token: `$` + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-comma-behavior.core.stderr b/src/test/ui/compile-fail-migration/macro-comma-behavior.core.stderr new file mode 100644 index 00000000000..5ff31f05079 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-comma-behavior.core.stderr @@ -0,0 +1,44 @@ +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:27:23 + | +LL | assert_eq!(1, 1, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:30:23 + | +LL | assert_ne!(1, 2, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:36:29 + | +LL | debug_assert_eq!(1, 1, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:39:29 + | +LL | debug_assert_ne!(1, 2, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:60:19 + | +LL | format_args!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:78:21 + | +LL | unimplemented!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:87:24 + | +LL | write!(f, "{}",)?; + | ^^ + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-comma-behavior.rs b/src/test/ui/compile-fail-migration/macro-comma-behavior.rs new file mode 100644 index 00000000000..620e57b463d --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-comma-behavior.rs @@ -0,0 +1,101 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Companion test to the similarly-named file in run-pass. + +// compile-flags: -C debug_assertions=yes +// revisions: std core + +#![cfg_attr(core, no_std)] + +#[cfg(std)] use std::fmt; +#[cfg(core)] use core::fmt; + +// (see documentation of the similarly-named test in run-pass) +fn to_format_or_not_to_format() { + let falsum = || false; + + // assert!(true, "{}",); // see run-pass + + assert_eq!(1, 1, "{}",); + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments + assert_ne!(1, 2, "{}",); + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments + + // debug_assert!(true, "{}",); // see run-pass + + debug_assert_eq!(1, 1, "{}",); + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments + debug_assert_ne!(1, 2, "{}",); + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments + + #[cfg(std)] { + eprint!("{}",); + //[std]~^ ERROR no arguments + } + + #[cfg(std)] { + // FIXME: compile-fail says "expected error not found" even though + // rustc does emit an error + // eprintln!("{}",); + // [std]~^ ERROR no arguments + } + + #[cfg(std)] { + format!("{}",); + //[std]~^ ERROR no arguments + } + + format_args!("{}",); + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments + + // if falsum() { panic!("{}",); } // see run-pass + + #[cfg(std)] { + print!("{}",); + //[std]~^ ERROR no arguments + } + + #[cfg(std)] { + // FIXME: compile-fail says "expected error not found" even though + // rustc does emit an error + // println!("{}",); + // [std]~^ ERROR no arguments + } + + unimplemented!("{}",); + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments + + // if falsum() { unreachable!("{}",); } // see run-pass + + struct S; + impl fmt::Display for S { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}",)?; + //[core]~^ ERROR no arguments + //[std]~^^ ERROR no arguments + + // FIXME: compile-fail says "expected error not found" even though + // rustc does emit an error + // writeln!(f, "{}",)?; + // [core]~^ ERROR no arguments + // [std]~^^ ERROR no arguments + Ok(()) + } + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/macro-comma-behavior.std.stderr b/src/test/ui/compile-fail-migration/macro-comma-behavior.std.stderr new file mode 100644 index 00000000000..a87271ed026 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-comma-behavior.std.stderr @@ -0,0 +1,62 @@ +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:27:23 + | +LL | assert_eq!(1, 1, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:30:23 + | +LL | assert_ne!(1, 2, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:36:29 + | +LL | debug_assert_eq!(1, 1, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:39:29 + | +LL | debug_assert_ne!(1, 2, "{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:44:18 + | +LL | eprint!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:56:18 + | +LL | format!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:60:19 + | +LL | format_args!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:67:17 + | +LL | print!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:78:21 + | +LL | unimplemented!("{}",); + | ^^ + +error: 1 positional argument in format string, but no arguments were given + --> $DIR/macro-comma-behavior.rs:87:24 + | +LL | write!(f, "{}",)?; + | ^^ + +error: aborting due to 10 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-comma-support.rs b/src/test/ui/compile-fail-migration/macro-comma-support.rs new file mode 100644 index 00000000000..e5fe9b4dd7f --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-comma-support.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This is a companion to the similarly-named test in run-pass. +// +// It tests macros that unavoidably produce compile errors. + +fn compile_error() { + compile_error!("lel"); //~ ERROR lel + compile_error!("lel",); //~ ERROR lel +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/macro-comma-support.stderr b/src/test/ui/compile-fail-migration/macro-comma-support.stderr new file mode 100644 index 00000000000..2ebba22d7a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-comma-support.stderr @@ -0,0 +1,14 @@ +error: lel + --> $DIR/macro-comma-support.rs:16:5 + | +LL | compile_error!("lel"); //~ ERROR lel + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: lel + --> $DIR/macro-comma-support.rs:17:5 + | +LL | compile_error!("lel",); //~ ERROR lel + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.rs b/src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.rs new file mode 100644 index 00000000000..76211b88bd7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:macro_crate_nonterminal.rs + +mod foo { + #[macro_use] + extern crate macro_crate_nonterminal; //~ ERROR must be at the crate root +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.stderr b/src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.stderr new file mode 100644 index 00000000000..029128ae92a --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-crate-nonterminal-non-root.stderr @@ -0,0 +1,9 @@ +error[E0468]: an `extern crate` loading macros must be at the crate root + --> $DIR/macro-crate-nonterminal-non-root.rs:15:5 + | +LL | extern crate macro_crate_nonterminal; //~ ERROR must be at the crate root + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0468`. diff --git a/src/test/ui/compile-fail-migration/macro-error.rs b/src/test/ui/compile-fail-migration/macro-error.rs new file mode 100644 index 00000000000..82a5aa48729 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-error.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($a:expr) => a; //~ ERROR macro rhs must be delimited +} + +fn main() { + foo!(0); // Check that we report errors at macro definition, not expansion. + + let _: cfg!(foo) = (); //~ ERROR non-type macro in type position +} diff --git a/src/test/ui/compile-fail-migration/macro-error.stderr b/src/test/ui/compile-fail-migration/macro-error.stderr new file mode 100644 index 00000000000..42808eb2a6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-error.stderr @@ -0,0 +1,14 @@ +error: macro rhs must be delimited + --> $DIR/macro-error.rs:12:18 + | +LL | ($a:expr) => a; //~ ERROR macro rhs must be delimited + | ^ + +error: non-type macro in type position: cfg + --> $DIR/macro-error.rs:18:12 + | +LL | let _: cfg!(foo) = (); //~ ERROR non-type macro in type position + | ^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-expanded-include/file.txt b/src/test/ui/compile-fail-migration/macro-expanded-include/file.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/test/ui/compile-fail-migration/macro-expanded-include/foo/mod.rs b/src/test/ui/compile-fail-migration/macro-expanded-include/foo/mod.rs new file mode 100644 index 00000000000..888bdf5179a --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-expanded-include/foo/mod.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test + +macro_rules! m { + () => { include!("file.txt"); } +} + +macro_rules! n { + () => { unsafe { asm!(include_str!("file.txt")); } } +} diff --git a/src/test/ui/compile-fail-migration/macro-expanded-include/test.rs b/src/test/ui/compile-fail-migration/macro-expanded-include/test.rs new file mode 100644 index 00000000000..4afb61ab76c --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-expanded-include/test.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-emscripten no asm! support + +#![feature(asm, rustc_attrs)] +#![allow(unused)] + +#[macro_use] +mod foo; + +m!(); +fn f() { n!(); } + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/macro-expanded-include/test.stderr b/src/test/ui/compile-fail-migration/macro-expanded-include/test.stderr new file mode 100644 index 00000000000..3ef0275cfbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-expanded-include/test.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/test.rs:23:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-expansion-tests.rs b/src/test/ui/compile-fail-migration/macro-expansion-tests.rs new file mode 100644 index 00000000000..06f2d86e5d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-expansion-tests.rs @@ -0,0 +1,50 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_macros)] + +mod macros_cant_escape_fns { + fn f() { + macro_rules! m { () => { 3 + 4 } } + } + fn g() -> i32 { m!() } + //~^ ERROR cannot find macro +} + +mod macros_cant_escape_mods { + mod f { + macro_rules! m { () => { 3 + 4 } } + } + fn g() -> i32 { m!() } + //~^ ERROR cannot find macro +} + +mod macros_can_escape_flattened_mods_test { + #[macro_use] + mod f { + macro_rules! m { () => { 3 + 4 } } + } + fn g() -> i32 { m!() } +} + +fn macro_tokens_should_match() { + macro_rules! m { (a) => { 13 } } + m!(a); +} + +// should be able to use a bound identifier as a literal in a macro definition: +fn self_macro_parsing() { + macro_rules! foo { (zz) => { 287; } } + fn f(zz: i32) { + foo!(zz); + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/macro-expansion-tests.stderr b/src/test/ui/compile-fail-migration/macro-expansion-tests.stderr new file mode 100644 index 00000000000..a3d4f3cd348 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-expansion-tests.stderr @@ -0,0 +1,18 @@ +error: cannot find macro `m!` in this scope + --> $DIR/macro-expansion-tests.rs:17:21 + | +LL | fn g() -> i32 { m!() } + | ^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: cannot find macro `m!` in this scope + --> $DIR/macro-expansion-tests.rs:25:21 + | +LL | fn g() -> i32 { m!() } + | ^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-follow.rs b/src/test/ui/compile-fail-migration/macro-follow.rs new file mode 100644 index 00000000000..6e80e9b574b --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-follow.rs @@ -0,0 +1,124 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Check the macro follow sets (see corresponding rpass test). + +#![allow(unused_macros)] + +// FOLLOW(pat) = {FatArrow, Comma, Eq, Or, Ident(if), Ident(in)} +macro_rules! follow_pat { + ($p:pat ()) => {}; //~ERROR `$p:pat` is followed by `(` + ($p:pat []) => {}; //~ERROR `$p:pat` is followed by `[` + ($p:pat {}) => {}; //~ERROR `$p:pat` is followed by `{` + ($p:pat :) => {}; //~ERROR `$p:pat` is followed by `:` + ($p:pat >) => {}; //~ERROR `$p:pat` is followed by `>` + ($p:pat +) => {}; //~ERROR `$p:pat` is followed by `+` + ($p:pat ident) => {}; //~ERROR `$p:pat` is followed by `ident` + ($p:pat $p:pat) => {}; //~ERROR `$p:pat` is followed by `$p:pat` + ($p:pat $e:expr) => {}; //~ERROR `$p:pat` is followed by `$e:expr` + ($p:pat $t:ty) => {}; //~ERROR `$p:pat` is followed by `$t:ty` + ($p:pat $s:stmt) => {}; //~ERROR `$p:pat` is followed by `$s:stmt` + ($p:pat $p:path) => {}; //~ERROR `$p:pat` is followed by `$p:path` + ($p:pat $b:block) => {}; //~ERROR `$p:pat` is followed by `$b:block` + ($p:pat $i:ident) => {}; //~ERROR `$p:pat` is followed by `$i:ident` + ($p:pat $t:tt) => {}; //~ERROR `$p:pat` is followed by `$t:tt` + ($p:pat $i:item) => {}; //~ERROR `$p:pat` is followed by `$i:item` + ($p:pat $m:meta) => {}; //~ERROR `$p:pat` is followed by `$m:meta` +} +// FOLLOW(expr) = {FatArrow, Comma, Semicolon} +macro_rules! follow_expr { + ($e:expr ()) => {}; //~ERROR `$e:expr` is followed by `(` + ($e:expr []) => {}; //~ERROR `$e:expr` is followed by `[` + ($e:expr {}) => {}; //~ERROR `$e:expr` is followed by `{` + ($e:expr =) => {}; //~ERROR `$e:expr` is followed by `=` + ($e:expr |) => {}; //~ERROR `$e:expr` is followed by `|` + ($e:expr :) => {}; //~ERROR `$e:expr` is followed by `:` + ($e:expr >) => {}; //~ERROR `$e:expr` is followed by `>` + ($e:expr +) => {}; //~ERROR `$e:expr` is followed by `+` + ($e:expr ident) => {}; //~ERROR `$e:expr` is followed by `ident` + ($e:expr if) => {}; //~ERROR `$e:expr` is followed by `if` + ($e:expr in) => {}; //~ERROR `$e:expr` is followed by `in` + ($e:expr $p:pat) => {}; //~ERROR `$e:expr` is followed by `$p:pat` + ($e:expr $e:expr) => {}; //~ERROR `$e:expr` is followed by `$e:expr` + ($e:expr $t:ty) => {}; //~ERROR `$e:expr` is followed by `$t:ty` + ($e:expr $s:stmt) => {}; //~ERROR `$e:expr` is followed by `$s:stmt` + ($e:expr $p:path) => {}; //~ERROR `$e:expr` is followed by `$p:path` + ($e:expr $b:block) => {}; //~ERROR `$e:expr` is followed by `$b:block` + ($e:expr $i:ident) => {}; //~ERROR `$e:expr` is followed by `$i:ident` + ($e:expr $t:tt) => {}; //~ERROR `$e:expr` is followed by `$t:tt` + ($e:expr $i:item) => {}; //~ERROR `$e:expr` is followed by `$i:item` + ($e:expr $m:meta) => {}; //~ERROR `$e:expr` is followed by `$m:meta` +} +// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or, +// Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)} +macro_rules! follow_ty { + ($t:ty ()) => {}; //~ERROR `$t:ty` is followed by `(` + ($t:ty []) => {}; // ok (RFC 1462) + ($t:ty +) => {}; //~ERROR `$t:ty` is followed by `+` + ($t:ty ident) => {}; //~ERROR `$t:ty` is followed by `ident` + ($t:ty if) => {}; //~ERROR `$t:ty` is followed by `if` + ($t:ty $p:pat) => {}; //~ERROR `$t:ty` is followed by `$p:pat` + ($t:ty $e:expr) => {}; //~ERROR `$t:ty` is followed by `$e:expr` + ($t:ty $t:ty) => {}; //~ERROR `$t:ty` is followed by `$t:ty` + ($t:ty $s:stmt) => {}; //~ERROR `$t:ty` is followed by `$s:stmt` + ($t:ty $p:path) => {}; //~ERROR `$t:ty` is followed by `$p:path` + ($t:ty $b:block) => {}; // ok (RFC 1494) + ($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident` + ($t:ty $t:tt) => {}; //~ERROR `$t:ty` is followed by `$t:tt` + ($t:ty $i:item) => {}; //~ERROR `$t:ty` is followed by `$i:item` + ($t:ty $m:meta) => {}; //~ERROR `$t:ty` is followed by `$m:meta` +} +// FOLLOW(stmt) = FOLLOW(expr) +macro_rules! follow_stmt { + ($s:stmt ()) => {}; //~ERROR `$s:stmt` is followed by `(` + ($s:stmt []) => {}; //~ERROR `$s:stmt` is followed by `[` + ($s:stmt {}) => {}; //~ERROR `$s:stmt` is followed by `{` + ($s:stmt =) => {}; //~ERROR `$s:stmt` is followed by `=` + ($s:stmt |) => {}; //~ERROR `$s:stmt` is followed by `|` + ($s:stmt :) => {}; //~ERROR `$s:stmt` is followed by `:` + ($s:stmt >) => {}; //~ERROR `$s:stmt` is followed by `>` + ($s:stmt +) => {}; //~ERROR `$s:stmt` is followed by `+` + ($s:stmt ident) => {}; //~ERROR `$s:stmt` is followed by `ident` + ($s:stmt if) => {}; //~ERROR `$s:stmt` is followed by `if` + ($s:stmt in) => {}; //~ERROR `$s:stmt` is followed by `in` + ($s:stmt $p:pat) => {}; //~ERROR `$s:stmt` is followed by `$p:pat` + ($s:stmt $e:expr) => {}; //~ERROR `$s:stmt` is followed by `$e:expr` + ($s:stmt $t:ty) => {}; //~ERROR `$s:stmt` is followed by `$t:ty` + ($s:stmt $s:stmt) => {}; //~ERROR `$s:stmt` is followed by `$s:stmt` + ($s:stmt $p:path) => {}; //~ERROR `$s:stmt` is followed by `$p:path` + ($s:stmt $b:block) => {}; //~ERROR `$s:stmt` is followed by `$b:block` + ($s:stmt $i:ident) => {}; //~ERROR `$s:stmt` is followed by `$i:ident` + ($s:stmt $t:tt) => {}; //~ERROR `$s:stmt` is followed by `$t:tt` + ($s:stmt $i:item) => {}; //~ERROR `$s:stmt` is followed by `$i:item` + ($s:stmt $m:meta) => {}; //~ERROR `$s:stmt` is followed by `$m:meta` +} +// FOLLOW(path) = FOLLOW(ty) +macro_rules! follow_path { + ($p:path ()) => {}; //~ERROR `$p:path` is followed by `(` + ($p:path []) => {}; // ok (RFC 1462) + ($p:path +) => {}; //~ERROR `$p:path` is followed by `+` + ($p:path ident) => {}; //~ERROR `$p:path` is followed by `ident` + ($p:path if) => {}; //~ERROR `$p:path` is followed by `if` + ($p:path $p:pat) => {}; //~ERROR `$p:path` is followed by `$p:pat` + ($p:path $e:expr) => {}; //~ERROR `$p:path` is followed by `$e:expr` + ($p:path $t:ty) => {}; //~ERROR `$p:path` is followed by `$t:ty` + ($p:path $s:stmt) => {}; //~ERROR `$p:path` is followed by `$s:stmt` + ($p:path $p:path) => {}; //~ERROR `$p:path` is followed by `$p:path` + ($p:path $b:block) => {}; // ok (RFC 1494) + ($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident` + ($p:path $t:tt) => {}; //~ERROR `$p:path` is followed by `$t:tt` + ($p:path $i:item) => {}; //~ERROR `$p:path` is followed by `$i:item` + ($p:path $m:meta) => {}; //~ERROR `$p:path` is followed by `$m:meta` +} +// FOLLOW(block) = any token +// FOLLOW(ident) = any token + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/macro-follow.stderr b/src/test/ui/compile-fail-migration/macro-follow.stderr new file mode 100644 index 00000000000..ccd658af89f --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-follow.stderr @@ -0,0 +1,512 @@ +error: `$p:pat` is followed by `(`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:17:14 + | +LL | ($p:pat ()) => {}; //~ERROR `$p:pat` is followed by `(` + | ^ + +error: `$p:pat` is followed by `[`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:18:14 + | +LL | ($p:pat []) => {}; //~ERROR `$p:pat` is followed by `[` + | ^ + +error: `$p:pat` is followed by `{`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:19:14 + | +LL | ($p:pat {}) => {}; //~ERROR `$p:pat` is followed by `{` + | ^ + +error: `$p:pat` is followed by `:`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:20:13 + | +LL | ($p:pat :) => {}; //~ERROR `$p:pat` is followed by `:` + | ^ + +error: `$p:pat` is followed by `>`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:21:13 + | +LL | ($p:pat >) => {}; //~ERROR `$p:pat` is followed by `>` + | ^ + +error: `$p:pat` is followed by `+`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:22:13 + | +LL | ($p:pat +) => {}; //~ERROR `$p:pat` is followed by `+` + | ^ + +error: `$p:pat` is followed by `ident`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:23:13 + | +LL | ($p:pat ident) => {}; //~ERROR `$p:pat` is followed by `ident` + | ^^^^^ + +error: `$p:pat` is followed by `$p:pat`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:24:13 + | +LL | ($p:pat $p:pat) => {}; //~ERROR `$p:pat` is followed by `$p:pat` + | ^^^^^^ + +error: `$p:pat` is followed by `$e:expr`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:25:13 + | +LL | ($p:pat $e:expr) => {}; //~ERROR `$p:pat` is followed by `$e:expr` + | ^^^^^^^ + +error: `$p:pat` is followed by `$t:ty`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:26:13 + | +LL | ($p:pat $t:ty) => {}; //~ERROR `$p:pat` is followed by `$t:ty` + | ^^^^^ + +error: `$p:pat` is followed by `$s:stmt`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:27:13 + | +LL | ($p:pat $s:stmt) => {}; //~ERROR `$p:pat` is followed by `$s:stmt` + | ^^^^^^^ + +error: `$p:pat` is followed by `$p:path`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:28:13 + | +LL | ($p:pat $p:path) => {}; //~ERROR `$p:pat` is followed by `$p:path` + | ^^^^^^^ + +error: `$p:pat` is followed by `$b:block`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:29:13 + | +LL | ($p:pat $b:block) => {}; //~ERROR `$p:pat` is followed by `$b:block` + | ^^^^^^^^ + +error: `$p:pat` is followed by `$i:ident`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:30:13 + | +LL | ($p:pat $i:ident) => {}; //~ERROR `$p:pat` is followed by `$i:ident` + | ^^^^^^^^ + +error: `$p:pat` is followed by `$t:tt`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:31:13 + | +LL | ($p:pat $t:tt) => {}; //~ERROR `$p:pat` is followed by `$t:tt` + | ^^^^^ + +error: `$p:pat` is followed by `$i:item`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:32:13 + | +LL | ($p:pat $i:item) => {}; //~ERROR `$p:pat` is followed by `$i:item` + | ^^^^^^^ + +error: `$p:pat` is followed by `$m:meta`, which is not allowed for `pat` fragments + --> $DIR/macro-follow.rs:33:13 + | +LL | ($p:pat $m:meta) => {}; //~ERROR `$p:pat` is followed by `$m:meta` + | ^^^^^^^ + +error: `$e:expr` is followed by `(`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:37:15 + | +LL | ($e:expr ()) => {}; //~ERROR `$e:expr` is followed by `(` + | ^ + +error: `$e:expr` is followed by `[`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:38:15 + | +LL | ($e:expr []) => {}; //~ERROR `$e:expr` is followed by `[` + | ^ + +error: `$e:expr` is followed by `{`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:39:15 + | +LL | ($e:expr {}) => {}; //~ERROR `$e:expr` is followed by `{` + | ^ + +error: `$e:expr` is followed by `=`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:40:14 + | +LL | ($e:expr =) => {}; //~ERROR `$e:expr` is followed by `=` + | ^ + +error: `$e:expr` is followed by `|`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:41:14 + | +LL | ($e:expr |) => {}; //~ERROR `$e:expr` is followed by `|` + | ^ + +error: `$e:expr` is followed by `:`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:42:14 + | +LL | ($e:expr :) => {}; //~ERROR `$e:expr` is followed by `:` + | ^ + +error: `$e:expr` is followed by `>`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:43:14 + | +LL | ($e:expr >) => {}; //~ERROR `$e:expr` is followed by `>` + | ^ + +error: `$e:expr` is followed by `+`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:44:14 + | +LL | ($e:expr +) => {}; //~ERROR `$e:expr` is followed by `+` + | ^ + +error: `$e:expr` is followed by `ident`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:45:14 + | +LL | ($e:expr ident) => {}; //~ERROR `$e:expr` is followed by `ident` + | ^^^^^ + +error: `$e:expr` is followed by `if`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:46:14 + | +LL | ($e:expr if) => {}; //~ERROR `$e:expr` is followed by `if` + | ^^ + +error: `$e:expr` is followed by `in`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:47:14 + | +LL | ($e:expr in) => {}; //~ERROR `$e:expr` is followed by `in` + | ^^ + +error: `$e:expr` is followed by `$p:pat`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:48:14 + | +LL | ($e:expr $p:pat) => {}; //~ERROR `$e:expr` is followed by `$p:pat` + | ^^^^^^ + +error: `$e:expr` is followed by `$e:expr`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:49:14 + | +LL | ($e:expr $e:expr) => {}; //~ERROR `$e:expr` is followed by `$e:expr` + | ^^^^^^^ + +error: `$e:expr` is followed by `$t:ty`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:50:14 + | +LL | ($e:expr $t:ty) => {}; //~ERROR `$e:expr` is followed by `$t:ty` + | ^^^^^ + +error: `$e:expr` is followed by `$s:stmt`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:51:14 + | +LL | ($e:expr $s:stmt) => {}; //~ERROR `$e:expr` is followed by `$s:stmt` + | ^^^^^^^ + +error: `$e:expr` is followed by `$p:path`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:52:14 + | +LL | ($e:expr $p:path) => {}; //~ERROR `$e:expr` is followed by `$p:path` + | ^^^^^^^ + +error: `$e:expr` is followed by `$b:block`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:53:14 + | +LL | ($e:expr $b:block) => {}; //~ERROR `$e:expr` is followed by `$b:block` + | ^^^^^^^^ + +error: `$e:expr` is followed by `$i:ident`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:54:14 + | +LL | ($e:expr $i:ident) => {}; //~ERROR `$e:expr` is followed by `$i:ident` + | ^^^^^^^^ + +error: `$e:expr` is followed by `$t:tt`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:55:14 + | +LL | ($e:expr $t:tt) => {}; //~ERROR `$e:expr` is followed by `$t:tt` + | ^^^^^ + +error: `$e:expr` is followed by `$i:item`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:56:14 + | +LL | ($e:expr $i:item) => {}; //~ERROR `$e:expr` is followed by `$i:item` + | ^^^^^^^ + +error: `$e:expr` is followed by `$m:meta`, which is not allowed for `expr` fragments + --> $DIR/macro-follow.rs:57:14 + | +LL | ($e:expr $m:meta) => {}; //~ERROR `$e:expr` is followed by `$m:meta` + | ^^^^^^^ + +error: `$t:ty` is followed by `(`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:62:13 + | +LL | ($t:ty ()) => {}; //~ERROR `$t:ty` is followed by `(` + | ^ + +error: `$t:ty` is followed by `+`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:64:12 + | +LL | ($t:ty +) => {}; //~ERROR `$t:ty` is followed by `+` + | ^ + +error: `$t:ty` is followed by `ident`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:65:12 + | +LL | ($t:ty ident) => {}; //~ERROR `$t:ty` is followed by `ident` + | ^^^^^ + +error: `$t:ty` is followed by `if`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:66:12 + | +LL | ($t:ty if) => {}; //~ERROR `$t:ty` is followed by `if` + | ^^ + +error: `$t:ty` is followed by `$p:pat`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:67:12 + | +LL | ($t:ty $p:pat) => {}; //~ERROR `$t:ty` is followed by `$p:pat` + | ^^^^^^ + +error: `$t:ty` is followed by `$e:expr`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:68:12 + | +LL | ($t:ty $e:expr) => {}; //~ERROR `$t:ty` is followed by `$e:expr` + | ^^^^^^^ + +error: `$t:ty` is followed by `$t:ty`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:69:12 + | +LL | ($t:ty $t:ty) => {}; //~ERROR `$t:ty` is followed by `$t:ty` + | ^^^^^ + +error: `$t:ty` is followed by `$s:stmt`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:70:12 + | +LL | ($t:ty $s:stmt) => {}; //~ERROR `$t:ty` is followed by `$s:stmt` + | ^^^^^^^ + +error: `$t:ty` is followed by `$p:path`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:71:12 + | +LL | ($t:ty $p:path) => {}; //~ERROR `$t:ty` is followed by `$p:path` + | ^^^^^^^ + +error: `$t:ty` is followed by `$i:ident`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:73:12 + | +LL | ($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident` + | ^^^^^^^^ + +error: `$t:ty` is followed by `$t:tt`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:74:12 + | +LL | ($t:ty $t:tt) => {}; //~ERROR `$t:ty` is followed by `$t:tt` + | ^^^^^ + +error: `$t:ty` is followed by `$i:item`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:75:12 + | +LL | ($t:ty $i:item) => {}; //~ERROR `$t:ty` is followed by `$i:item` + | ^^^^^^^ + +error: `$t:ty` is followed by `$m:meta`, which is not allowed for `ty` fragments + --> $DIR/macro-follow.rs:76:12 + | +LL | ($t:ty $m:meta) => {}; //~ERROR `$t:ty` is followed by `$m:meta` + | ^^^^^^^ + +error: `$s:stmt` is followed by `(`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:80:15 + | +LL | ($s:stmt ()) => {}; //~ERROR `$s:stmt` is followed by `(` + | ^ + +error: `$s:stmt` is followed by `[`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:81:15 + | +LL | ($s:stmt []) => {}; //~ERROR `$s:stmt` is followed by `[` + | ^ + +error: `$s:stmt` is followed by `{`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:82:15 + | +LL | ($s:stmt {}) => {}; //~ERROR `$s:stmt` is followed by `{` + | ^ + +error: `$s:stmt` is followed by `=`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:83:14 + | +LL | ($s:stmt =) => {}; //~ERROR `$s:stmt` is followed by `=` + | ^ + +error: `$s:stmt` is followed by `|`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:84:14 + | +LL | ($s:stmt |) => {}; //~ERROR `$s:stmt` is followed by `|` + | ^ + +error: `$s:stmt` is followed by `:`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:85:14 + | +LL | ($s:stmt :) => {}; //~ERROR `$s:stmt` is followed by `:` + | ^ + +error: `$s:stmt` is followed by `>`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:86:14 + | +LL | ($s:stmt >) => {}; //~ERROR `$s:stmt` is followed by `>` + | ^ + +error: `$s:stmt` is followed by `+`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:87:14 + | +LL | ($s:stmt +) => {}; //~ERROR `$s:stmt` is followed by `+` + | ^ + +error: `$s:stmt` is followed by `ident`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:88:14 + | +LL | ($s:stmt ident) => {}; //~ERROR `$s:stmt` is followed by `ident` + | ^^^^^ + +error: `$s:stmt` is followed by `if`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:89:14 + | +LL | ($s:stmt if) => {}; //~ERROR `$s:stmt` is followed by `if` + | ^^ + +error: `$s:stmt` is followed by `in`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:90:14 + | +LL | ($s:stmt in) => {}; //~ERROR `$s:stmt` is followed by `in` + | ^^ + +error: `$s:stmt` is followed by `$p:pat`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:91:14 + | +LL | ($s:stmt $p:pat) => {}; //~ERROR `$s:stmt` is followed by `$p:pat` + | ^^^^^^ + +error: `$s:stmt` is followed by `$e:expr`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:92:14 + | +LL | ($s:stmt $e:expr) => {}; //~ERROR `$s:stmt` is followed by `$e:expr` + | ^^^^^^^ + +error: `$s:stmt` is followed by `$t:ty`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:93:14 + | +LL | ($s:stmt $t:ty) => {}; //~ERROR `$s:stmt` is followed by `$t:ty` + | ^^^^^ + +error: `$s:stmt` is followed by `$s:stmt`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:94:14 + | +LL | ($s:stmt $s:stmt) => {}; //~ERROR `$s:stmt` is followed by `$s:stmt` + | ^^^^^^^ + +error: `$s:stmt` is followed by `$p:path`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:95:14 + | +LL | ($s:stmt $p:path) => {}; //~ERROR `$s:stmt` is followed by `$p:path` + | ^^^^^^^ + +error: `$s:stmt` is followed by `$b:block`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:96:14 + | +LL | ($s:stmt $b:block) => {}; //~ERROR `$s:stmt` is followed by `$b:block` + | ^^^^^^^^ + +error: `$s:stmt` is followed by `$i:ident`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:97:14 + | +LL | ($s:stmt $i:ident) => {}; //~ERROR `$s:stmt` is followed by `$i:ident` + | ^^^^^^^^ + +error: `$s:stmt` is followed by `$t:tt`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:98:14 + | +LL | ($s:stmt $t:tt) => {}; //~ERROR `$s:stmt` is followed by `$t:tt` + | ^^^^^ + +error: `$s:stmt` is followed by `$i:item`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:99:14 + | +LL | ($s:stmt $i:item) => {}; //~ERROR `$s:stmt` is followed by `$i:item` + | ^^^^^^^ + +error: `$s:stmt` is followed by `$m:meta`, which is not allowed for `stmt` fragments + --> $DIR/macro-follow.rs:100:14 + | +LL | ($s:stmt $m:meta) => {}; //~ERROR `$s:stmt` is followed by `$m:meta` + | ^^^^^^^ + +error: `$p:path` is followed by `(`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:104:15 + | +LL | ($p:path ()) => {}; //~ERROR `$p:path` is followed by `(` + | ^ + +error: `$p:path` is followed by `+`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:106:14 + | +LL | ($p:path +) => {}; //~ERROR `$p:path` is followed by `+` + | ^ + +error: `$p:path` is followed by `ident`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:107:14 + | +LL | ($p:path ident) => {}; //~ERROR `$p:path` is followed by `ident` + | ^^^^^ + +error: `$p:path` is followed by `if`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:108:14 + | +LL | ($p:path if) => {}; //~ERROR `$p:path` is followed by `if` + | ^^ + +error: `$p:path` is followed by `$p:pat`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:109:14 + | +LL | ($p:path $p:pat) => {}; //~ERROR `$p:path` is followed by `$p:pat` + | ^^^^^^ + +error: `$p:path` is followed by `$e:expr`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:110:14 + | +LL | ($p:path $e:expr) => {}; //~ERROR `$p:path` is followed by `$e:expr` + | ^^^^^^^ + +error: `$p:path` is followed by `$t:ty`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:111:14 + | +LL | ($p:path $t:ty) => {}; //~ERROR `$p:path` is followed by `$t:ty` + | ^^^^^ + +error: `$p:path` is followed by `$s:stmt`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:112:14 + | +LL | ($p:path $s:stmt) => {}; //~ERROR `$p:path` is followed by `$s:stmt` + | ^^^^^^^ + +error: `$p:path` is followed by `$p:path`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:113:14 + | +LL | ($p:path $p:path) => {}; //~ERROR `$p:path` is followed by `$p:path` + | ^^^^^^^ + +error: `$p:path` is followed by `$i:ident`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:115:14 + | +LL | ($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident` + | ^^^^^^^^ + +error: `$p:path` is followed by `$t:tt`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:116:14 + | +LL | ($p:path $t:tt) => {}; //~ERROR `$p:path` is followed by `$t:tt` + | ^^^^^ + +error: `$p:path` is followed by `$i:item`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:117:14 + | +LL | ($p:path $i:item) => {}; //~ERROR `$p:path` is followed by `$i:item` + | ^^^^^^^ + +error: `$p:path` is followed by `$m:meta`, which is not allowed for `path` fragments + --> $DIR/macro-follow.rs:118:14 + | +LL | ($p:path $m:meta) => {}; //~ERROR `$p:path` is followed by `$m:meta` + | ^^^^^^^ + +error: aborting due to 85 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.rs b/src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.rs new file mode 100644 index 00000000000..21cc946ded6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #25436: check that things which can be +// followed by any token also permit X* to come afterwards. + +#![allow(unused_macros)] + +macro_rules! foo { + ( $a:expr $($b:tt)* ) => { }; //~ ERROR not allowed for `expr` fragments + ( $a:ty $($b:tt)* ) => { }; //~ ERROR not allowed for `ty` fragments +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.stderr b/src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.stderr new file mode 100644 index 00000000000..bb070334d36 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-followed-by-seq-bad.stderr @@ -0,0 +1,14 @@ +error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments + --> $DIR/macro-followed-by-seq-bad.rs:17:15 + | +LL | ( $a:expr $($b:tt)* ) => { }; //~ ERROR not allowed for `expr` fragments + | ^^^^^ + +error: `$a:ty` is followed by `$b:tt`, which is not allowed for `ty` fragments + --> $DIR/macro-followed-by-seq-bad.rs:18:13 + | +LL | ( $a:ty $($b:tt)* ) => { }; //~ ERROR not allowed for `ty` fragments + | ^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-inner-attributes.rs b/src/test/ui/compile-fail-migration/macro-inner-attributes.rs new file mode 100644 index 00000000000..1111b21d455 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-inner-attributes.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(custom_attribute)] + +macro_rules! test { ($nm:ident, + #[$a:meta], + $i:item) => (mod $nm { #![$a] $i }); } + +test!(a, + #[cfg(qux)], + pub fn bar() { }); + +test!(b, + #[cfg(not(qux))], + pub fn bar() { }); + +#[qux] +fn main() { + a::bar(); + //~^ ERROR failed to resolve. Use of undeclared type or module `a` + b::bar(); +} diff --git a/src/test/ui/compile-fail-migration/macro-inner-attributes.stderr b/src/test/ui/compile-fail-migration/macro-inner-attributes.stderr new file mode 100644 index 00000000000..11922bc448b --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-inner-attributes.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `a` + --> $DIR/macro-inner-attributes.rs:27:5 + | +LL | a::bar(); + | ^ Use of undeclared type or module `a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/macro-input-future-proofing.rs b/src/test/ui/compile-fail-migration/macro-input-future-proofing.rs new file mode 100644 index 00000000000..e5fdba63b0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-input-future-proofing.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_macros)] + +macro_rules! errors_everywhere { + ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` + ($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` + ($ty:ty , ) => (); + ( ( $ty:ty ) ) => (); + ( { $ty:ty } ) => (); + ( [ $ty:ty ] ) => (); + ($bl:block < ) => (); + ($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat` + ($pa:pat , ) => (); + ($pa:pat $pb:pat $ty:ty ,) => (); + //~^ ERROR `$pa:pat` is followed by `$pb:pat`, which is not allowed + //~^^ ERROR `$pb:pat` is followed by `$ty:ty`, which is not allowed + ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-` + ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-` + ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty` + ( $($a:expr)* $($b:tt)* ) => { }; + //~^ ERROR `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/macro-input-future-proofing.stderr b/src/test/ui/compile-fail-migration/macro-input-future-proofing.stderr new file mode 100644 index 00000000000..aed7a8a119c --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-input-future-proofing.stderr @@ -0,0 +1,56 @@ +error: `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments + --> $DIR/macro-input-future-proofing.rs:14:13 + | +LL | ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` + | ^ + +error: `$ty:ty` is followed by `<`, which is not allowed for `ty` fragments + --> $DIR/macro-input-future-proofing.rs:15:13 + | +LL | ($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` + | ^ + +error: `$pa:pat` is followed by `>`, which is not allowed for `pat` fragments + --> $DIR/macro-input-future-proofing.rs:21:14 + | +LL | ($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat` + | ^ + +error: `$pa:pat` is followed by `$pb:pat`, which is not allowed for `pat` fragments + --> $DIR/macro-input-future-proofing.rs:23:14 + | +LL | ($pa:pat $pb:pat $ty:ty ,) => (); + | ^^^^^^^ + +error: `$pb:pat` is followed by `$ty:ty`, which is not allowed for `pat` fragments + --> $DIR/macro-input-future-proofing.rs:23:22 + | +LL | ($pa:pat $pb:pat $ty:ty ,) => (); + | ^^^^^^ + +error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments + --> $DIR/macro-input-future-proofing.rs:26:17 + | +LL | ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-` + | ^ + +error: `$b:ty` is followed by `-`, which is not allowed for `ty` fragments + --> $DIR/macro-input-future-proofing.rs:27:23 + | +LL | ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-` + | ^ + +error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments + --> $DIR/macro-input-future-proofing.rs:28:7 + | +LL | ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty` + | ^^^^^^^^ + +error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments + --> $DIR/macro-input-future-proofing.rs:29:21 + | +LL | ( $($a:expr)* $($b:tt)* ) => { }; + | ^^^^^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/compile-fail-migration/macro-local-data-key-priv.rs b/src/test/ui/compile-fail-migration/macro-local-data-key-priv.rs new file mode 100644 index 00000000000..3ae629cd895 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-local-data-key-priv.rs @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// check that the local data keys are private by default. + +mod bar { + thread_local!(static baz: f64 = 0.0); +} + +fn main() { + bar::baz.with(|_| ()); + //~^ ERROR `baz` is private +} diff --git a/src/test/ui/compile-fail-migration/macro-local-data-key-priv.stderr b/src/test/ui/compile-fail-migration/macro-local-data-key-priv.stderr new file mode 100644 index 00000000000..57f4f790cb1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-local-data-key-priv.stderr @@ -0,0 +1,9 @@ +error[E0603]: constant `baz` is private + --> $DIR/macro-local-data-key-priv.rs:18:5 + | +LL | bar::baz.with(|_| ()); + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/macro-match-nonterminal.rs b/src/test/ui/compile-fail-migration/macro-match-nonterminal.rs new file mode 100644 index 00000000000..6cca729e2c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-match-nonterminal.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! test { ($a, $b) => (()); } //~ ERROR missing fragment + +fn main() { + test!() +} diff --git a/src/test/ui/compile-fail-migration/macro-match-nonterminal.stderr b/src/test/ui/compile-fail-migration/macro-match-nonterminal.stderr new file mode 100644 index 00000000000..26648c443cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-match-nonterminal.stderr @@ -0,0 +1,8 @@ +error: missing fragment specifier + --> $DIR/macro-match-nonterminal.rs:11:24 + | +LL | macro_rules! test { ($a, $b) => (()); } //~ ERROR missing fragment + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-missing-delimiters.rs b/src/test/ui/compile-fail-migration/macro-missing-delimiters.rs new file mode 100644 index 00000000000..eed2a207e89 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-missing-delimiters.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! baz( + baz => () //~ ERROR invalid macro matcher; +); + +fn main() { + baz!(baz); +} diff --git a/src/test/ui/compile-fail-migration/macro-missing-delimiters.stderr b/src/test/ui/compile-fail-migration/macro-missing-delimiters.stderr new file mode 100644 index 00000000000..eb43e39ea56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-missing-delimiters.stderr @@ -0,0 +1,8 @@ +error: invalid macro matcher; matchers must be contained in balanced delimiters + --> $DIR/macro-missing-delimiters.rs:12:5 + | +LL | baz => () //~ ERROR invalid macro matcher; + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-missing-fragment.rs b/src/test/ui/compile-fail-migration/macro-missing-fragment.rs new file mode 100644 index 00000000000..66f4ce55be8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-missing-fragment.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! m { + ( $( any_token $field_rust_type )* ) => {}; //~ ERROR missing fragment +} + +fn main() { + m!(); +} diff --git a/src/test/ui/compile-fail-migration/macro-missing-fragment.stderr b/src/test/ui/compile-fail-migration/macro-missing-fragment.stderr new file mode 100644 index 00000000000..48e07ed9dbd --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-missing-fragment.stderr @@ -0,0 +1,8 @@ +error: missing fragment specifier + --> $DIR/macro-missing-fragment.rs:12:20 + | +LL | ( $( any_token $field_rust_type )* ) => {}; //~ ERROR missing fragment + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-non-lifetime.rs b/src/test/ui/compile-fail-migration/macro-non-lifetime.rs new file mode 100644 index 00000000000..647d7aaa759 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-non-lifetime.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for issue #50381: non-lifetime passed to :lifetime. + +#![feature(macro_lifetime_matcher)] + +macro_rules! m { ($x:lifetime) => { } } + +fn main() { + m!(a); + //~^ ERROR no rules expected the token `a` +} diff --git a/src/test/ui/compile-fail-migration/macro-non-lifetime.stderr b/src/test/ui/compile-fail-migration/macro-non-lifetime.stderr new file mode 100644 index 00000000000..93b7f481842 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-non-lifetime.stderr @@ -0,0 +1,8 @@ +error: no rules expected the token `a` + --> $DIR/macro-non-lifetime.rs:18:8 + | +LL | m!(a); + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-outer-attributes.rs b/src/test/ui/compile-fail-migration/macro-outer-attributes.rs new file mode 100644 index 00000000000..acb58596fe4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-outer-attributes.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(custom_attribute)] + +macro_rules! test { ($nm:ident, + #[$a:meta], + $i:item) => (mod $nm { #[$a] $i }); } + +test!(a, + #[cfg(qux)], + pub fn bar() { }); + +test!(b, + #[cfg(not(qux))], + pub fn bar() { }); + +// test1!(#[bar]) +#[qux] +fn main() { + a::bar(); //~ ERROR cannot find function `bar` in module `a` + b::bar(); +} diff --git a/src/test/ui/compile-fail-migration/macro-outer-attributes.stderr b/src/test/ui/compile-fail-migration/macro-outer-attributes.stderr new file mode 100644 index 00000000000..4cc8cd5dc90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-outer-attributes.stderr @@ -0,0 +1,13 @@ +error[E0425]: cannot find function `bar` in module `a` + --> $DIR/macro-outer-attributes.rs:28:8 + | +LL | a::bar(); //~ ERROR cannot find function `bar` in module `a` + | ^^^ not found in `a` +help: possible candidate is found in another module, you can import it into scope + | +LL | use b::bar; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/macro-parameter-span.rs b/src/test/ui/compile-fail-migration/macro-parameter-span.rs new file mode 100644 index 00000000000..3b168fec953 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-parameter-span.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($id: ident) => { + $id + } +} + +// Testing that the error span points to the parameter 'x' in the callsite, +// not to the macro variable '$id' +fn main() { + foo!( + x //~ ERROR cannot find value `x` in this scope + ); +} diff --git a/src/test/ui/compile-fail-migration/macro-parameter-span.stderr b/src/test/ui/compile-fail-migration/macro-parameter-span.stderr new file mode 100644 index 00000000000..749221e9bf0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-parameter-span.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `x` in this scope + --> $DIR/macro-parameter-span.rs:21:9 + | +LL | x //~ ERROR cannot find value `x` in this scope + | ^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/macro-stability.rs b/src/test/ui/compile-fail-migration/macro-stability.rs new file mode 100644 index 00000000000..a4b922c0fe1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-stability.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:unstable-macros.rs + +#![feature(staged_api)] +#[macro_use] extern crate unstable_macros; + +#[unstable(feature = "local_unstable", issue = "0")] +macro_rules! local_unstable { () => () } + +fn main() { + local_unstable!(); + unstable_macro!(); //~ ERROR: macro unstable_macro! is unstable +} diff --git a/src/test/ui/compile-fail-migration/macro-stability.stderr b/src/test/ui/compile-fail-migration/macro-stability.stderr new file mode 100644 index 00000000000..947133f287d --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-stability.stderr @@ -0,0 +1,11 @@ +error[E0658]: macro unstable_macro! is unstable + --> $DIR/macro-stability.rs:21:5 + | +LL | unstable_macro!(); //~ ERROR: macro unstable_macro! is unstable + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unstable_macros)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/macro-stmt-matchers.rs b/src/test/ui/compile-fail-migration/macro-stmt-matchers.rs new file mode 100644 index 00000000000..8f46d3301eb --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-stmt-matchers.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +#[rustc_error] +fn main() { //~ ERROR compilation successful + macro_rules! m { ($s:stmt;) => { $s } } + m!(vec![].push(0);); +} diff --git a/src/test/ui/compile-fail-migration/macro-stmt-matchers.stderr b/src/test/ui/compile-fail-migration/macro-stmt-matchers.stderr new file mode 100644 index 00000000000..ef6210bb6f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-stmt-matchers.stderr @@ -0,0 +1,11 @@ +error: compilation successful + --> $DIR/macro-stmt-matchers.rs:14:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | macro_rules! m { ($s:stmt;) => { $s } } +LL | | m!(vec![].push(0);); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-tt-matchers.rs b/src/test/ui/compile-fail-migration/macro-tt-matchers.rs new file mode 100644 index 00000000000..7255e7d00b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-tt-matchers.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +macro_rules! foo { + ($x:tt) => (type Alias = $x;) +} + +foo!(Box); + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/macro-tt-matchers.stderr b/src/test/ui/compile-fail-migration/macro-tt-matchers.stderr new file mode 100644 index 00000000000..b7551c1bd93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-tt-matchers.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/macro-tt-matchers.rs:21:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-use-bad-args-1.rs b/src/test/ui/compile-fail-migration/macro-use-bad-args-1.rs new file mode 100644 index 00000000000..a07cc834411 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-bad-args-1.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] + +#[allow(unused_extern_crates)] +#[macro_use(foo(bar))] //~ ERROR bad macro import +extern crate std; diff --git a/src/test/ui/compile-fail-migration/macro-use-bad-args-1.stderr b/src/test/ui/compile-fail-migration/macro-use-bad-args-1.stderr new file mode 100644 index 00000000000..19a8c7c0382 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-bad-args-1.stderr @@ -0,0 +1,14 @@ +error[E0466]: bad macro import + --> $DIR/macro-use-bad-args-1.rs:14:13 + | +LL | #[macro_use(foo(bar))] //~ ERROR bad macro import + | ^^^^^^^^ + +error[E0601]: `main` function not found in crate `macro_use_bad_args_1` + | + = note: consider adding a `main` function to `$DIR/macro-use-bad-args-1.rs` + +error: aborting due to 2 previous errors + +Some errors occurred: E0466, E0601. +For more information about an error, try `rustc --explain E0466`. diff --git a/src/test/ui/compile-fail-migration/macro-use-bad-args-2.rs b/src/test/ui/compile-fail-migration/macro-use-bad-args-2.rs new file mode 100644 index 00000000000..89004f16897 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-bad-args-2.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] + +#[allow(unused_extern_crates)] +#[macro_use(foo="bar")] //~ ERROR bad macro import +extern crate std; diff --git a/src/test/ui/compile-fail-migration/macro-use-bad-args-2.stderr b/src/test/ui/compile-fail-migration/macro-use-bad-args-2.stderr new file mode 100644 index 00000000000..0ac18201d79 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-bad-args-2.stderr @@ -0,0 +1,14 @@ +error[E0466]: bad macro import + --> $DIR/macro-use-bad-args-2.rs:14:13 + | +LL | #[macro_use(foo="bar")] //~ ERROR bad macro import + | ^^^^^^^^^ + +error[E0601]: `main` function not found in crate `macro_use_bad_args_2` + | + = note: consider adding a `main` function to `$DIR/macro-use-bad-args-2.rs` + +error: aborting due to 2 previous errors + +Some errors occurred: E0466, E0601. +For more information about an error, try `rustc --explain E0466`. diff --git a/src/test/ui/compile-fail-migration/macro-use-scope.rs b/src/test/ui/compile-fail-migration/macro-use-scope.rs new file mode 100644 index 00000000000..9d389413ba9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-scope.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:two_macros.rs + +#![feature(rustc_attrs)] +#![allow(unused)] + +fn f() { + let _ = macro_one!(); +} +#[macro_use(macro_one)] // Check that this macro is usable in the above function +extern crate two_macros; + +fn g() { + macro_two!(); +} +macro_rules! m { () => { + #[macro_use(macro_two)] // Check that this macro is usable in the above function + extern crate two_macros as _two_macros; +} } +m!(); + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/macro-use-scope.stderr b/src/test/ui/compile-fail-migration/macro-use-scope.stderr new file mode 100644 index 00000000000..2e81750d43b --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-scope.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/macro-use-scope.rs:32:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-use-undef.rs b/src/test/ui/compile-fail-migration/macro-use-undef.rs new file mode 100644 index 00000000000..dd725aae95e --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-undef.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:two_macros.rs + +#[macro_use(macro_two, no_way)] //~ ERROR imported macro not found +extern crate two_macros; + +pub fn main() { + macro_two!(); +} diff --git a/src/test/ui/compile-fail-migration/macro-use-undef.stderr b/src/test/ui/compile-fail-migration/macro-use-undef.stderr new file mode 100644 index 00000000000..6fc57a34794 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-undef.stderr @@ -0,0 +1,9 @@ +error[E0469]: imported macro not found + --> $DIR/macro-use-undef.rs:13:24 + | +LL | #[macro_use(macro_two, no_way)] //~ ERROR imported macro not found + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0469`. diff --git a/src/test/ui/compile-fail-migration/macro-use-wrong-name.rs b/src/test/ui/compile-fail-migration/macro-use-wrong-name.rs new file mode 100644 index 00000000000..143ecb4ce5e --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-wrong-name.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:two_macros.rs + +#[macro_use(macro_one)] +extern crate two_macros; + +pub fn main() { + macro_two!(); + //~^ ERROR cannot find macro +} diff --git a/src/test/ui/compile-fail-migration/macro-use-wrong-name.stderr b/src/test/ui/compile-fail-migration/macro-use-wrong-name.stderr new file mode 100644 index 00000000000..26271a21623 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-use-wrong-name.stderr @@ -0,0 +1,8 @@ +error: cannot find macro `macro_two!` in this scope + --> $DIR/macro-use-wrong-name.rs:17:5 + | +LL | macro_two!(); + | ^^^^^^^^^ help: you could try the macro: `macro_one` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/macro-with-seps-err-msg.rs b/src/test/ui/compile-fail-migration/macro-with-seps-err-msg.rs new file mode 100644 index 00000000000..1281adce5c5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-with-seps-err-msg.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// gate-test-use_extern_macros + +fn main() { + globnar::brotz!(); //~ ERROR non-ident macro paths are experimental +} diff --git a/src/test/ui/compile-fail-migration/macro-with-seps-err-msg.stderr b/src/test/ui/compile-fail-migration/macro-with-seps-err-msg.stderr new file mode 100644 index 00000000000..a19d3337282 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macro-with-seps-err-msg.stderr @@ -0,0 +1,27 @@ +error[E0658]: non-ident macro paths are experimental (see issue #35896) + --> $DIR/macro-with-seps-err-msg.rs:16:5 + | +LL | globnar::brotz!(); //~ ERROR non-ident macro paths are experimental + | ^^^^^^^^^^^^^^ + | + = help: add #![feature(use_extern_macros)] to the crate attributes to enable + +error[E0658]: non-ident macro paths are experimental (see issue #35896) + --> $DIR/macro-with-seps-err-msg.rs:17:14 + | +LL | #[derive(foo::Bar)] struct T; //~ ERROR non-ident macro paths are experimental + | ^^^^^^^^ + | + = help: add #![feature(use_extern_macros)] to the crate attributes to enable + +error[E0658]: non-ident macro paths are experimental (see issue #35896) + --> $DIR/macro-with-seps-err-msg.rs:18:5 + | +LL | ::foo!(); //~ ERROR non-ident macro paths are experimental + | ^^^^^ + | + = help: add #![feature(use_extern_macros)] to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/macros-in-extern.rs b/src/test/ui/compile-fail-migration/macros-in-extern.rs new file mode 100644 index 00000000000..40053853b15 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macros-in-extern.rs @@ -0,0 +1,42 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-wasm32 + +#![feature(decl_macro)] + +macro_rules! returns_isize( + ($ident:ident) => ( + fn $ident() -> isize; + ) +); + +macro takes_u32_returns_u32($ident:ident) { + fn $ident (arg: u32) -> u32; +} + +macro_rules! emits_nothing( + () => () +); + +fn main() { + assert_eq!(unsafe { rust_get_test_int() }, 0isize); + assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEFu32); +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + returns_isize!(rust_get_test_int); + //~^ ERROR macro invocations in `extern {}` blocks are experimental + takes_u32_returns_u32!(rust_dbg_extern_identity_u32); + //~^ ERROR macro invocations in `extern {}` blocks are experimental + emits_nothing!(); + //~^ ERROR macro invocations in `extern {}` blocks are experimental +} diff --git a/src/test/ui/compile-fail-migration/macros-in-extern.stderr b/src/test/ui/compile-fail-migration/macros-in-extern.stderr new file mode 100644 index 00000000000..ffac282040c --- /dev/null +++ b/src/test/ui/compile-fail-migration/macros-in-extern.stderr @@ -0,0 +1,27 @@ +error[E0658]: macro and proc-macro invocations in `extern {}` blocks are experimental. (see issue #49476) + --> $DIR/macros-in-extern.rs:36:5 + | +LL | returns_isize!(rust_get_test_int); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(macros_in_extern)] to the crate attributes to enable + +error[E0658]: macro and proc-macro invocations in `extern {}` blocks are experimental. (see issue #49476) + --> $DIR/macros-in-extern.rs:38:5 + | +LL | takes_u32_returns_u32!(rust_dbg_extern_identity_u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(macros_in_extern)] to the crate attributes to enable + +error[E0658]: macro and proc-macro invocations in `extern {}` blocks are experimental. (see issue #49476) + --> $DIR/macros-in-extern.rs:40:5 + | +LL | emits_nothing!(); + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(macros_in_extern)] to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/macros-nonfatal-errors.rs b/src/test/ui/compile-fail-migration/macros-nonfatal-errors.rs new file mode 100644 index 00000000000..7046ee12b50 --- /dev/null +++ b/src/test/ui/compile-fail-migration/macros-nonfatal-errors.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// test that errors in a (selection) of macros don't kill compilation +// immediately, so that we get more errors listed at a time. + +#![feature(asm)] +#![feature(trace_macros, concat_idents)] + +#[derive(Default)] //~ ERROR +enum OrDeriveThis {} + +fn main() { + asm!(invalid); //~ ERROR + + concat_idents!("not", "idents"); //~ ERROR + + option_env!(invalid); //~ ERROR + env!(invalid); //~ ERROR + env!(foo, abr, baz); //~ ERROR + env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); //~ ERROR + + foo::blah!(); //~ ERROR + + format!(invalid); //~ ERROR + + include!(invalid); //~ ERROR + + include_str!(invalid); //~ ERROR + include_str!("i'd be quite surprised if a file with this name existed"); //~ ERROR + include_bytes!(invalid); //~ ERROR + include_bytes!("i'd be quite surprised if a file with this name existed"); //~ ERROR + + trace_macros!(invalid); //~ ERROR +} diff --git a/src/test/ui/compile-fail-migration/macros-nonfatal-errors.stderr b/src/test/ui/compile-fail-migration/macros-nonfatal-errors.stderr new file mode 100644 index 00000000000..c44dcfd12af --- /dev/null +++ b/src/test/ui/compile-fail-migration/macros-nonfatal-errors.stderr @@ -0,0 +1,100 @@ +error[E0665]: `Default` cannot be derived for enums, only structs + --> $DIR/macros-nonfatal-errors.rs:17:10 + | +LL | #[derive(Default)] //~ ERROR + | ^^^^^^^ + +error: inline assembly must be a string literal + --> $DIR/macros-nonfatal-errors.rs:21:10 + | +LL | asm!(invalid); //~ ERROR + | ^^^^^^^ + +error: concat_idents! requires ident args. + --> $DIR/macros-nonfatal-errors.rs:23:5 + | +LL | concat_idents!("not", "idents"); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: argument must be a string literal + --> $DIR/macros-nonfatal-errors.rs:25:17 + | +LL | option_env!(invalid); //~ ERROR + | ^^^^^^^ + +error: expected string literal + --> $DIR/macros-nonfatal-errors.rs:26:10 + | +LL | env!(invalid); //~ ERROR + | ^^^^^^^ + +error: expected string literal + --> $DIR/macros-nonfatal-errors.rs:27:10 + | +LL | env!(foo, abr, baz); //~ ERROR + | ^^^ + +error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined + --> $DIR/macros-nonfatal-errors.rs:28:5 + | +LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: non-ident macro paths are experimental (see issue #35896) + --> $DIR/macros-nonfatal-errors.rs:30:5 + | +LL | foo::blah!(); //~ ERROR + | ^^^^^^^^^ + | + = help: add #![feature(use_extern_macros)] to the crate attributes to enable + +error: format argument must be a string literal + --> $DIR/macros-nonfatal-errors.rs:32:13 + | +LL | format!(invalid); //~ ERROR + | ^^^^^^^ +help: you might be missing a string literal to format with + | +LL | format!("{}", invalid); //~ ERROR + | ^^^^^ + +error: argument must be a string literal + --> $DIR/macros-nonfatal-errors.rs:34:14 + | +LL | include!(invalid); //~ ERROR + | ^^^^^^^ + +error: argument must be a string literal + --> $DIR/macros-nonfatal-errors.rs:36:18 + | +LL | include_str!(invalid); //~ ERROR + | ^^^^^^^ + +error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: No such file or directory (os error 2) + --> $DIR/macros-nonfatal-errors.rs:37:5 + | +LL | include_str!("i'd be quite surprised if a file with this name existed"); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: argument must be a string literal + --> $DIR/macros-nonfatal-errors.rs:38:20 + | +LL | include_bytes!(invalid); //~ ERROR + | ^^^^^^^ + +error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: No such file or directory (os error 2) + --> $DIR/macros-nonfatal-errors.rs:39:5 + | +LL | include_bytes!("i'd be quite surprised if a file with this name existed"); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: trace_macros! accepts only `true` or `false` + --> $DIR/macros-nonfatal-errors.rs:41:5 + | +LL | trace_macros!(invalid); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 15 previous errors + +Some errors occurred: E0658, E0665. +For more information about an error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/main-wrong-type.rs b/src/test/ui/compile-fail-migration/main-wrong-type.rs new file mode 100644 index 00000000000..402cd3a2d31 --- /dev/null +++ b/src/test/ui/compile-fail-migration/main-wrong-type.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S { + x: isize, + y: isize, +} + +fn main(foo: S) { +//~^ ERROR: main function has wrong type [E0580] +} diff --git a/src/test/ui/compile-fail-migration/main-wrong-type.stderr b/src/test/ui/compile-fail-migration/main-wrong-type.stderr new file mode 100644 index 00000000000..15094bd1fbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/main-wrong-type.stderr @@ -0,0 +1,12 @@ +error[E0580]: main function has wrong type + --> $DIR/main-wrong-type.rs:16:1 + | +LL | fn main(foo: S) { + | ^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected type `fn()` + found type `fn(S)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0580`. diff --git a/src/test/ui/compile-fail-migration/malformed-derive-entry.rs b/src/test/ui/compile-fail-migration/malformed-derive-entry.rs new file mode 100644 index 00000000000..ac000628f2b --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-derive-entry.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Copy(Bad))] +//~^ ERROR expected one of `)`, `,`, or `::`, found `(` +struct Test1; + +#[derive(Copy="bad")] +//~^ ERROR expected one of `)`, `,`, or `::`, found `=` +struct Test2; + +#[derive()] +//~^ WARNING empty trait list +struct Test3; + +#[derive] +//~^ WARNING empty trait list +struct Test4; diff --git a/src/test/ui/compile-fail-migration/malformed-derive-entry.stderr b/src/test/ui/compile-fail-migration/malformed-derive-entry.stderr new file mode 100644 index 00000000000..b1984f52430 --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-derive-entry.stderr @@ -0,0 +1,26 @@ +error: expected one of `)`, `,`, or `::`, found `(` + --> $DIR/malformed-derive-entry.rs:11:14 + | +LL | #[derive(Copy(Bad))] + | ^ expected one of `)`, `,`, or `::` here + +error: expected one of `)`, `,`, or `::`, found `=` + --> $DIR/malformed-derive-entry.rs:15:14 + | +LL | #[derive(Copy="bad")] + | ^ expected one of `)`, `,`, or `::` here + +warning: empty trait list in `derive` + --> $DIR/malformed-derive-entry.rs:19:1 + | +LL | #[derive()] + | ^^^^^^^^^^^ + +warning: empty trait list in `derive` + --> $DIR/malformed-derive-entry.rs:23:1 + | +LL | #[derive] + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/malformed-plugin-1.rs b/src/test/ui/compile-fail-migration/malformed-plugin-1.rs new file mode 100644 index 00000000000..214a5e5e3eb --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-plugin-1.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin)] +#![plugin] //~ ERROR malformed plugin attribute + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/malformed-plugin-1.stderr b/src/test/ui/compile-fail-migration/malformed-plugin-1.stderr new file mode 100644 index 00000000000..5ceabc3b8ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-plugin-1.stderr @@ -0,0 +1,9 @@ +error[E0498]: malformed plugin attribute + --> $DIR/malformed-plugin-1.rs:12:1 + | +LL | #![plugin] //~ ERROR malformed plugin attribute + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0498`. diff --git a/src/test/ui/compile-fail-migration/malformed-plugin-2.rs b/src/test/ui/compile-fail-migration/malformed-plugin-2.rs new file mode 100644 index 00000000000..1b112608bee --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-plugin-2.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin)] +#![plugin="bleh"] //~ ERROR malformed plugin attribute + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/malformed-plugin-2.stderr b/src/test/ui/compile-fail-migration/malformed-plugin-2.stderr new file mode 100644 index 00000000000..56c87f9f8dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-plugin-2.stderr @@ -0,0 +1,9 @@ +error[E0498]: malformed plugin attribute + --> $DIR/malformed-plugin-2.rs:12:1 + | +LL | #![plugin="bleh"] //~ ERROR malformed plugin attribute + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0498`. diff --git a/src/test/ui/compile-fail-migration/malformed-plugin-3.rs b/src/test/ui/compile-fail-migration/malformed-plugin-3.rs new file mode 100644 index 00000000000..0c948831de2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-plugin-3.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin)] +#![plugin(foo="bleh")] //~ ERROR malformed plugin attribute + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/malformed-plugin-3.stderr b/src/test/ui/compile-fail-migration/malformed-plugin-3.stderr new file mode 100644 index 00000000000..fff52c649e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed-plugin-3.stderr @@ -0,0 +1,9 @@ +error[E0498]: malformed plugin attribute + --> $DIR/malformed-plugin-3.rs:12:1 + | +LL | #![plugin(foo="bleh")] //~ ERROR malformed plugin attribute + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0498`. diff --git a/src/test/ui/compile-fail-migration/malformed_macro_lhs.rs b/src/test/ui/compile-fail-migration/malformed_macro_lhs.rs new file mode 100644 index 00000000000..0b437be5393 --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed_macro_lhs.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! my_precioooous { + t => (1); //~ ERROR invalid macro matcher +} + +fn main() { + my_precioooous!(); +} diff --git a/src/test/ui/compile-fail-migration/malformed_macro_lhs.stderr b/src/test/ui/compile-fail-migration/malformed_macro_lhs.stderr new file mode 100644 index 00000000000..6b4241890b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/malformed_macro_lhs.stderr @@ -0,0 +1,8 @@ +error: invalid macro matcher; matchers must be contained in balanced delimiters + --> $DIR/malformed_macro_lhs.rs:12:5 + | +LL | t => (1); //~ ERROR invalid macro matcher + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/manual-link-bad-form.rs b/src/test/ui/compile-fail-migration/manual-link-bad-form.rs new file mode 100644 index 00000000000..fc4fa838a56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-bad-form.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-l static= +// error-pattern: empty library name given via `-l` + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/manual-link-bad-form.stderr b/src/test/ui/compile-fail-migration/manual-link-bad-form.stderr new file mode 100644 index 00000000000..ed3c4c4fc4d --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-bad-form.stderr @@ -0,0 +1,4 @@ +error: empty library name given via `-l` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/manual-link-bad-kind.rs b/src/test/ui/compile-fail-migration/manual-link-bad-kind.rs new file mode 100644 index 00000000000..e9cbdb09948 --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-bad-kind.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-l bar=foo +// error-pattern: unknown library kind `bar`, expected one of dylib, framework, or static + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/manual-link-bad-kind.stderr b/src/test/ui/compile-fail-migration/manual-link-bad-kind.stderr new file mode 100644 index 00000000000..03c33a97512 --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-bad-kind.stderr @@ -0,0 +1,2 @@ +error: unknown library kind `bar`, expected one of dylib, framework, or static + diff --git a/src/test/ui/compile-fail-migration/manual-link-bad-search-path.rs b/src/test/ui/compile-fail-migration/manual-link-bad-search-path.rs new file mode 100644 index 00000000000..2bf61cbe24c --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-bad-search-path.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-L native= +// error-pattern: empty search path given via `-L` + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/manual-link-bad-search-path.stderr b/src/test/ui/compile-fail-migration/manual-link-bad-search-path.stderr new file mode 100644 index 00000000000..2c0649ea152 --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-bad-search-path.stderr @@ -0,0 +1,2 @@ +error: empty search path given via `-L` + diff --git a/src/test/ui/compile-fail-migration/manual-link-framework.rs b/src/test/ui/compile-fail-migration/manual-link-framework.rs new file mode 100644 index 00000000000..1ecf63813e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-framework.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-macos +// ignore-ios +// compile-flags:-l framework=foo +// error-pattern: native frameworks are only available on macOS targets + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/manual-link-framework.stderr b/src/test/ui/compile-fail-migration/manual-link-framework.stderr new file mode 100644 index 00000000000..3e8da8b2f93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/manual-link-framework.stderr @@ -0,0 +1,4 @@ +error: native frameworks are only available on macOS targets + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/map-types.rs b/src/test/ui/compile-fail-migration/map-types.rs new file mode 100644 index 00000000000..e8ff9e817af --- /dev/null +++ b/src/test/ui/compile-fail-migration/map-types.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +use std::collections::HashMap; + +trait Map +{ + fn get(&self, k: K) -> V { panic!() } +} + +impl Map for HashMap {} + +// Test that trait types printed in error msgs include the type arguments. + +fn main() { + let x: Box> = box HashMap::new(); + let x: Box> = x; + let y: Box> = Box::new(x); + //~^ ERROR `std::boxed::Box>: Map` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/map-types.stderr b/src/test/ui/compile-fail-migration/map-types.stderr new file mode 100644 index 00000000000..722113c7525 --- /dev/null +++ b/src/test/ui/compile-fail-migration/map-types.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `std::boxed::Box>: Map` is not satisfied + --> $DIR/map-types.rs:27:37 + | +LL | let y: Box> = Box::new(x); + | ^^^^^^^^^^^ the trait `Map` is not implemented for `std::boxed::Box>` + | + = note: required for the cast to the object type `dyn Map` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/match-argm-statics-2.rs b/src/test/ui/compile-fail-migration/match-argm-statics-2.rs new file mode 100644 index 00000000000..70e148627c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-argm-statics-2.rs @@ -0,0 +1,73 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use self::Direction::{North, East, South, West}; + +#[derive(PartialEq, Eq)] +struct NewBool(bool); + +#[derive(PartialEq, Eq)] +enum Direction { + North, + East, + South, + West +} + +const TRUE_TRUE: (bool, bool) = (true, true); + +fn nonexhaustive_1() { + match (true, false) { + //~^ ERROR non-exhaustive patterns: `(true, false)` not covered + TRUE_TRUE => (), + (false, false) => (), + (false, true) => () + } +} + +const NONE: Option = None; +const EAST: Direction = East; + +fn nonexhaustive_2() { + match Some(Some(North)) { + //~^ ERROR non-exhaustive patterns: `Some(Some(West))` not covered + Some(NONE) => (), + Some(Some(North)) => (), + Some(Some(EAST)) => (), + Some(Some(South)) => (), + None => () + } +} + +const NEW_FALSE: NewBool = NewBool(false); +struct Foo { + bar: Option, + baz: NewBool +} + +const STATIC_FOO: Foo = Foo { bar: None, baz: NEW_FALSE }; + +fn nonexhaustive_3() { + match (Foo { bar: Some(North), baz: NewBool(true) }) { + //~^ ERROR non-exhaustive patterns: `Foo { bar: Some(North), baz: NewBool(true) }` + Foo { bar: None, baz: NewBool(true) } => (), + Foo { bar: _, baz: NEW_FALSE } => (), + Foo { bar: Some(West), baz: NewBool(true) } => (), + Foo { bar: Some(South), .. } => (), + Foo { bar: Some(EAST), .. } => () + } +} + +fn main() { + nonexhaustive_1(); + nonexhaustive_2(); + nonexhaustive_3(); +} + diff --git a/src/test/ui/compile-fail-migration/match-argm-statics-2.stderr b/src/test/ui/compile-fail-migration/match-argm-statics-2.stderr new file mode 100644 index 00000000000..485b2a3202f --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-argm-statics-2.stderr @@ -0,0 +1,21 @@ +error[E0004]: non-exhaustive patterns: `(true, false)` not covered + --> $DIR/match-argm-statics-2.rs:27:11 + | +LL | match (true, false) { + | ^^^^^^^^^^^^^ pattern `(true, false)` not covered + +error[E0004]: non-exhaustive patterns: `Some(Some(West))` not covered + --> $DIR/match-argm-statics-2.rs:39:11 + | +LL | match Some(Some(North)) { + | ^^^^^^^^^^^^^^^^^ pattern `Some(Some(West))` not covered + +error[E0004]: non-exhaustive patterns: `Foo { bar: Some(North), baz: NewBool(true) }` not covered + --> $DIR/match-argm-statics-2.rs:58:11 + | +LL | match (Foo { bar: Some(North), baz: NewBool(true) }) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { bar: Some(North), baz: NewBool(true) }` not covered + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/match-arm-statics.rs b/src/test/ui/compile-fail-migration/match-arm-statics.rs new file mode 100644 index 00000000000..40d73ab51c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-arm-statics.rs @@ -0,0 +1,79 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![deny(unreachable_patterns)] + +use self::Direction::{North, East, South, West}; + +#[derive(PartialEq, Eq)] +struct NewBool(bool); + +#[derive(PartialEq, Eq)] +enum Direction { + North, + East, + South, + West +} + +const TRUE_TRUE: (bool, bool) = (true, true); + +fn unreachable_1() { + match (true, false) { + TRUE_TRUE => (), + (false, false) => (), + (false, true) => (), + (true, false) => (), + (true, true) => () + //~^ ERROR unreachable pattern + } +} + +const NONE: Option = None; +const EAST: Direction = East; + +fn unreachable_2() { + match Some(Some(North)) { + Some(NONE) => (), + Some(Some(North)) => (), + Some(Some(EAST)) => (), + Some(Some(South)) => (), + Some(Some(West)) => (), + Some(Some(East)) => (), + //~^ ERROR unreachable pattern + None => () + } +} + +const NEW_FALSE: NewBool = NewBool(false); +struct Foo { + bar: Option, + baz: NewBool +} + +fn unreachable_3() { + match (Foo { bar: Some(EAST), baz: NewBool(true) }) { + Foo { bar: None, baz: NewBool(true) } => (), + Foo { bar: _, baz: NEW_FALSE } => (), + Foo { bar: Some(West), baz: NewBool(true) } => (), + Foo { bar: Some(South), .. } => (), + Foo { bar: Some(EAST), .. } => (), + Foo { bar: Some(North), baz: NewBool(true) } => (), + Foo { bar: Some(EAST), baz: NewBool(false) } => () + //~^ ERROR unreachable pattern + } +} + +fn main() { + unreachable_1(); + unreachable_2(); + unreachable_3(); +} diff --git a/src/test/ui/compile-fail-migration/match-arm-statics.stderr b/src/test/ui/compile-fail-migration/match-arm-statics.stderr new file mode 100644 index 00000000000..8862be2254f --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-arm-statics.stderr @@ -0,0 +1,26 @@ +error: unreachable pattern + --> $DIR/match-arm-statics.rs:35:9 + | +LL | (true, true) => () + | ^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/match-arm-statics.rs:12:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-arm-statics.rs:50:9 + | +LL | Some(Some(East)) => (), + | ^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-arm-statics.rs:70:9 + | +LL | Foo { bar: Some(EAST), baz: NewBool(false) } => () + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/match-byte-array-patterns-2.rs b/src/test/ui/compile-fail-migration/match-byte-array-patterns-2.rs new file mode 100644 index 00000000000..abb770df107 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-byte-array-patterns-2.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let buf = &[0, 1, 2, 3]; + + match buf { //~ ERROR non-exhaustive + b"AAAA" => {} + } + + let buf: &[u8] = buf; + + match buf { //~ ERROR non-exhaustive + b"AAAA" => {} + } +} + diff --git a/src/test/ui/compile-fail-migration/match-byte-array-patterns-2.stderr b/src/test/ui/compile-fail-migration/match-byte-array-patterns-2.stderr new file mode 100644 index 00000000000..bc52376d824 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-byte-array-patterns-2.stderr @@ -0,0 +1,15 @@ +error[E0004]: non-exhaustive patterns: `&[_, _, _, _]` not covered + --> $DIR/match-byte-array-patterns-2.rs:14:11 + | +LL | match buf { //~ ERROR non-exhaustive + | ^^^ pattern `&[_, _, _, _]` not covered + +error[E0004]: non-exhaustive patterns: `&[]`, `&[_]`, `&[_, _]` and 3 more not covered + --> $DIR/match-byte-array-patterns-2.rs:20:11 + | +LL | match buf { //~ ERROR non-exhaustive + | ^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 3 more not covered + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/match-byte-array-patterns.rs b/src/test/ui/compile-fail-migration/match-byte-array-patterns.rs new file mode 100644 index 00000000000..9db4319b786 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-byte-array-patterns.rs @@ -0,0 +1,66 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] +#![deny(unreachable_patterns)] + +fn main() { + let buf = &[0, 1, 2, 3]; + + match buf { + b"AAAA" => {}, + &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern + _ => {} + } + + match buf { + &[0x41, 0x41, 0x41, 0x41] => {} + b"AAAA" => {}, //~ ERROR unreachable pattern + _ => {} + } + + match buf { + &[_, 0x41, 0x41, 0x41] => {}, + b"AAAA" => {}, //~ ERROR unreachable pattern + _ => {} + } + + match buf { + &[0x41, .., 0x41] => {} + b"AAAA" => {}, //~ ERROR unreachable pattern + _ => {} + } + + let buf: &[u8] = buf; + + match buf { + b"AAAA" => {}, + &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern + _ => {} + } + + match buf { + &[0x41, 0x41, 0x41, 0x41] => {} + b"AAAA" => {}, //~ ERROR unreachable pattern + _ => {} + } + + match buf { + &[_, 0x41, 0x41, 0x41] => {}, + b"AAAA" => {}, //~ ERROR unreachable pattern + _ => {} + } + + match buf { + &[0x41, .., 0x41] => {} + b"AAAA" => {}, //~ ERROR unreachable pattern + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/match-byte-array-patterns.stderr b/src/test/ui/compile-fail-migration/match-byte-array-patterns.stderr new file mode 100644 index 00000000000..da3d57743aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-byte-array-patterns.stderr @@ -0,0 +1,56 @@ +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:19:9 + | +LL | &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/match-byte-array-patterns.rs:12:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:25:9 + | +LL | b"AAAA" => {}, //~ ERROR unreachable pattern + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:31:9 + | +LL | b"AAAA" => {}, //~ ERROR unreachable pattern + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:37:9 + | +LL | b"AAAA" => {}, //~ ERROR unreachable pattern + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:45:9 + | +LL | &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:51:9 + | +LL | b"AAAA" => {}, //~ ERROR unreachable pattern + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:57:9 + | +LL | b"AAAA" => {}, //~ ERROR unreachable pattern + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/match-byte-array-patterns.rs:63:9 + | +LL | b"AAAA" => {}, //~ ERROR unreachable pattern + | ^^^^^^^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/compile-fail-migration/match-ill-type2.rs b/src/test/ui/compile-fail-migration/match-ill-type2.rs new file mode 100644 index 00000000000..aa47ea670fd --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ill-type2.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match 1i32 { + 1i32 => 1, + 2u32 => 1, //~ ERROR mismatched types + _ => 2, + }; +} diff --git a/src/test/ui/compile-fail-migration/match-ill-type2.stderr b/src/test/ui/compile-fail-migration/match-ill-type2.stderr new file mode 100644 index 00000000000..b649a38476e --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ill-type2.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/match-ill-type2.rs:14:9 + | +LL | 2u32 => 1, //~ ERROR mismatched types + | ^^^^ expected i32, found u32 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/match-join.rs b/src/test/ui/compile-fail-migration/match-join.rs new file mode 100644 index 00000000000..888094fd016 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-join.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// a good test that we merge paths correctly in the presence of a +// variable that's used before it's declared + +fn my_panic() -> ! { panic!(); } + +fn main() { + match true { false => { my_panic(); } true => { } } + + println!("{}", x); //~ ERROR cannot find value `x` in this scope + let x: isize; +} diff --git a/src/test/ui/compile-fail-migration/match-join.stderr b/src/test/ui/compile-fail-migration/match-join.stderr new file mode 100644 index 00000000000..a4a8a9d7174 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-join.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `x` in this scope + --> $DIR/match-join.rs:19:20 + | +LL | println!("{}", x); //~ ERROR cannot find value `x` in this scope + | ^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.rs b/src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.rs new file mode 100644 index 00000000000..db08f5e5e66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(warnings)] +#![deny(unreachable_code)] + +enum Void { } + +fn foo(v: Void) { + match v { } + let x = 2; //~ ERROR unreachable +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.stderr b/src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.stderr new file mode 100644 index 00000000000..35fae051870 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-no-arms-unreachable-after.stderr @@ -0,0 +1,14 @@ +error: unreachable statement + --> $DIR/match-no-arms-unreachable-after.rs:18:5 + | +LL | let x = 2; //~ ERROR unreachable + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/match-no-arms-unreachable-after.rs:12:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/match-non-exhaustive.rs b/src/test/ui/compile-fail-migration/match-non-exhaustive.rs new file mode 100644 index 00000000000..a24d2ed4b7f --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-non-exhaustive.rs @@ -0,0 +1,14 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match 0 { 1 => () } //~ ERROR non-exhaustive patterns + match 0 { 0 if false => () } //~ ERROR non-exhaustive patterns +} diff --git a/src/test/ui/compile-fail-migration/match-non-exhaustive.stderr b/src/test/ui/compile-fail-migration/match-non-exhaustive.stderr new file mode 100644 index 00000000000..04f09caceed --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-non-exhaustive.stderr @@ -0,0 +1,15 @@ +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/match-non-exhaustive.rs:12:11 + | +LL | match 0 { 1 => () } //~ ERROR non-exhaustive patterns + | ^ pattern `_` not covered + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/match-non-exhaustive.rs:13:11 + | +LL | match 0 { 0 if false => () } //~ ERROR non-exhaustive patterns + | ^ pattern `_` not covered + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.rs b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.rs new file mode 100644 index 00000000000..aed9130d60e --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + enum color { + rgb(usize, usize, usize), + cmyk(usize, usize, usize, usize), + no_color, + } + + fn foo(c: color) { + match c { + color::rgb(_, _, _) => { } + color::cmyk(_, _, _, _) => { } + color::no_color(_) => { } + //~^ ERROR expected tuple struct/variant, found unit variant `color::no_color` + } + } +} diff --git a/src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.stderr b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.stderr new file mode 100644 index 00000000000..b43fa9149bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch-2.stderr @@ -0,0 +1,9 @@ +error[E0532]: expected tuple struct/variant, found unit variant `color::no_color` + --> $DIR/match-pattern-field-mismatch-2.rs:22:11 + | +LL | color::no_color(_) => { } + | ^^^^^^^^^^^^^^^ not a tuple struct/variant + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0532`. diff --git a/src/test/ui/compile-fail-migration/match-pattern-field-mismatch.rs b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch.rs new file mode 100644 index 00000000000..ddd5d633170 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + enum color { + rgb(usize, usize, usize), + cmyk(usize, usize, usize, usize), + no_color, + } + + fn foo(c: color) { + match c { + color::rgb(_, _) => { } + //~^ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields + color::cmyk(_, _, _, _) => { } + color::no_color => { } + } + } +} diff --git a/src/test/ui/compile-fail-migration/match-pattern-field-mismatch.stderr b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch.stderr new file mode 100644 index 00000000000..d975f9afc7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-pattern-field-mismatch.stderr @@ -0,0 +1,9 @@ +error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 3 fields + --> $DIR/match-pattern-field-mismatch.rs:20:11 + | +LL | color::rgb(_, _) => { } + | ^^^^^^^^^^^^^^^^ expected 3 fields, found 2 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0023`. diff --git a/src/test/ui/compile-fail-migration/match-privately-empty.rs b/src/test/ui/compile-fail-migration/match-privately-empty.rs new file mode 100644 index 00000000000..8777ef2ffe3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-privately-empty.rs @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] +#![feature(exhaustive_patterns)] + +mod private { + pub struct Private { + _bot: !, + pub misc: bool, + } + pub const DATA: Option = None; +} + +fn main() { + match private::DATA { + //~^ ERROR non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered + None => {} + Some(private::Private { + misc: false, + .. + }) => {} + } +} diff --git a/src/test/ui/compile-fail-migration/match-privately-empty.stderr b/src/test/ui/compile-fail-migration/match-privately-empty.stderr new file mode 100644 index 00000000000..04b4ce00e9b --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-privately-empty.stderr @@ -0,0 +1,9 @@ +error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered + --> $DIR/match-privately-empty.rs:23:11 + | +LL | match private::DATA { + | ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/match-range-fail-2.rs b/src/test/ui/compile-fail-migration/match-range-fail-2.rs new file mode 100644 index 00000000000..b42e2ff919a --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-range-fail-2.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(exclusive_range_pattern)] + +fn main() { + match 5 { + 6 ..= 1 => { } + _ => { } + }; + //~^^^ ERROR lower range bound must be less than or equal to upper + + match 5 { + 0 .. 0 => { } + _ => { } + }; + //~^^^ ERROR lower range bound must be less than upper + + match 5u64 { + 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } + _ => { } + }; + //~^^^ ERROR lower range bound must be less than or equal to upper +} diff --git a/src/test/ui/compile-fail-migration/match-range-fail-2.stderr b/src/test/ui/compile-fail-migration/match-range-fail-2.stderr new file mode 100644 index 00000000000..616f74ed858 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-range-fail-2.stderr @@ -0,0 +1,22 @@ +error[E0030]: lower range bound must be less than or equal to upper + --> $DIR/match-range-fail-2.rs:15:9 + | +LL | 6 ..= 1 => { } + | ^ lower bound larger than upper bound + +error[E0579]: lower range bound must be less than upper + --> $DIR/match-range-fail-2.rs:21:9 + | +LL | 0 .. 0 => { } + | ^ + +error[E0030]: lower range bound must be less than or equal to upper + --> $DIR/match-range-fail-2.rs:27:9 + | +LL | 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } + | ^^^^^^^^^^^^^^^^^^^^^ lower bound larger than upper bound + +error: aborting due to 3 previous errors + +Some errors occurred: E0030, E0579. +For more information about an error, try `rustc --explain E0030`. diff --git a/src/test/ui/compile-fail-migration/match-range-fail-dominate.rs b/src/test/ui/compile-fail-migration/match-range-fail-dominate.rs new file mode 100644 index 00000000000..256aa180f4a --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-range-fail-dominate.rs @@ -0,0 +1,49 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//error-pattern: unreachable +//error-pattern: unreachable +//error-pattern: unreachable +//error-pattern: unreachable +//error-pattern: unreachable + +#![deny(unreachable_patterns)] + +fn main() { + match 5 { + 1 ... 10 => { } + 5 ... 6 => { } + _ => {} + }; + + match 5 { + 3 ... 6 => { } + 4 ... 6 => { } + _ => {} + }; + + match 5 { + 4 ... 6 => { } + 4 ... 6 => { } + _ => {} + }; + + match 'c' { + 'A' ... 'z' => {} + 'a' ... 'z' => {} + _ => {} + }; + + match 1.0f64 { + 0.01f64 ... 6.5f64 => {} + 0.02f64 => {} + _ => {} + }; +} diff --git a/src/test/ui/compile-fail-migration/match-range-fail-dominate.stderr b/src/test/ui/compile-fail-migration/match-range-fail-dominate.stderr new file mode 100644 index 00000000000..d75630e09c5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-range-fail-dominate.stderr @@ -0,0 +1,66 @@ +error: unreachable pattern + --> $DIR/match-range-fail-dominate.rs:22:7 + | +LL | 5 ... 6 => { } + | ^^^^^^^ + | +note: lint level defined here + --> $DIR/match-range-fail-dominate.rs:17:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-range-fail-dominate.rs:28:7 + | +LL | 4 ... 6 => { } + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/match-range-fail-dominate.rs:34:7 + | +LL | 4 ... 6 => { } + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/match-range-fail-dominate.rs:40:7 + | +LL | 'a' ... 'z' => {} + | ^^^^^^^^^^^ + +warning: floating-point types cannot be used in patterns + --> $DIR/match-range-fail-dominate.rs:45:7 + | +LL | 0.01f64 ... 6.5f64 => {} + | ^^^^^^^ + | + = note: #[warn(illegal_floating_point_literal_pattern)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +warning: floating-point types cannot be used in patterns + --> $DIR/match-range-fail-dominate.rs:45:19 + | +LL | 0.01f64 ... 6.5f64 => {} + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +warning: floating-point types cannot be used in patterns + --> $DIR/match-range-fail-dominate.rs:46:7 + | +LL | 0.02f64 => {} + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: unreachable pattern + --> $DIR/match-range-fail-dominate.rs:46:7 + | +LL | 0.02f64 => {} + | ^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/match-range-fail.rs b/src/test/ui/compile-fail-migration/match-range-fail.rs new file mode 100644 index 00000000000..ca99b0c7b89 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-range-fail.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match "wow" { + "bar" ..= "foo" => { } + }; + //~^^ ERROR only char and numeric types are allowed in range + //~| start type: &'static str + //~| end type: &'static str + + match "wow" { + 10 ..= "what" => () + }; + //~^^ ERROR only char and numeric types are allowed in range + //~| start type: {integer} + //~| end type: &'static str + + match 5 { + 'c' ..= 100 => { } + _ => { } + }; + //~^^^ ERROR mismatched types + //~| expected type `{integer}` + //~| found type `char` +} diff --git a/src/test/ui/compile-fail-migration/match-range-fail.stderr b/src/test/ui/compile-fail-migration/match-range-fail.stderr new file mode 100644 index 00000000000..dbc251020a9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-range-fail.stderr @@ -0,0 +1,31 @@ +error[E0029]: only char and numeric types are allowed in range patterns + --> $DIR/match-range-fail.rs:13:9 + | +LL | "bar" ..= "foo" => { } + | ^^^^^^^^^^^^^^^ ranges require char or numeric types + | + = note: start type: &'static str + = note: end type: &'static str + +error[E0029]: only char and numeric types are allowed in range patterns + --> $DIR/match-range-fail.rs:20:16 + | +LL | 10 ..= "what" => () + | ^^^^^^ ranges require char or numeric types + | + = note: start type: {integer} + = note: end type: &'static str + +error[E0308]: mismatched types + --> $DIR/match-range-fail.rs:27:9 + | +LL | 'c' ..= 100 => { } + | ^^^^^^^^^^^ expected integral variable, found char + | + = note: expected type `{integer}` + found type `char` + +error: aborting due to 3 previous errors + +Some errors occurred: E0029, E0308. +For more information about an error, try `rustc --explain E0029`. diff --git a/src/test/ui/compile-fail-migration/match-ref-ice.rs b/src/test/ui/compile-fail-migration/match-ref-ice.rs new file mode 100644 index 00000000000..cb8f8fad532 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-ice.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unreachable_patterns)] + +// The arity of `ref x` is always 1. If the pattern is compared to some non-structural type whose +// arity is always 0, an ICE occurs. +// +// Related issue: #23009 + +fn main() { + let homura = [1, 2, 3]; + + match homura { + [1, ref _madoka, 3] => (), + [1, 2, 3] => (), //~ ERROR unreachable pattern + [_, _, _] => (), + } +} diff --git a/src/test/ui/compile-fail-migration/match-ref-ice.stderr b/src/test/ui/compile-fail-migration/match-ref-ice.stderr new file mode 100644 index 00000000000..1dc87afddea --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-ice.stderr @@ -0,0 +1,14 @@ +error: unreachable pattern + --> $DIR/match-ref-ice.rs:23:9 + | +LL | [1, 2, 3] => (), //~ ERROR unreachable pattern + | ^^^^^^^^^ + | +note: lint level defined here + --> $DIR/match-ref-ice.rs:11:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/match-ref-mut-invariance.nll.stderr b/src/test/ui/compile-fail-migration/match-ref-mut-invariance.nll.stderr new file mode 100644 index 00000000000..cabf933bb81 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-mut-invariance.nll.stderr @@ -0,0 +1,21 @@ +warning: not reporting region error due to nll + --> $DIR/match-ref-mut-invariance.rs:20:37 + | +LL | match self.0 { ref mut x => x } //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/match-ref-mut-invariance.rs:19:49 + | +LL | impl<'b> S<'b> { + | -- lifetime `'b` defined here +LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { + | ____________--___________________________________^ + | | | + | | lifetime `'a` defined here +LL | | match self.0 { ref mut x => x } //~ ERROR mismatched types +LL | | } + | |_____^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/match-ref-mut-invariance.rs b/src/test/ui/compile-fail-migration/match-ref-mut-invariance.rs new file mode 100644 index 00000000000..c2b54a972bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-mut-invariance.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that when making a ref mut binding with type `&mut T`, the +// type `T` must match precisely the type `U` of the value being +// matched, and in particular cannot be some supertype of `U`. Issue +// #23116. This test focuses on a `match`. + +#![allow(dead_code)] +struct S<'b>(&'b i32); +impl<'b> S<'b> { + fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { + match self.0 { ref mut x => x } //~ ERROR mismatched types + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/match-ref-mut-invariance.stderr b/src/test/ui/compile-fail-migration/match-ref-mut-invariance.stderr new file mode 100644 index 00000000000..24677fe8597 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-mut-invariance.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/match-ref-mut-invariance.rs:20:37 + | +LL | match self.0 { ref mut x => x } //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `&'a mut &'a i32` + found type `&'a mut &'b i32` +note: the lifetime 'a as defined on the method body at 19:12... + --> $DIR/match-ref-mut-invariance.rs:19:12 + | +LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 18:6 + --> $DIR/match-ref-mut-invariance.rs:18:6 + | +LL | impl<'b> S<'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.nll.stderr b/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.nll.stderr new file mode 100644 index 00000000000..f01a9f3a3b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.nll.stderr @@ -0,0 +1,22 @@ +warning: not reporting region error due to nll + --> $DIR/match-ref-mut-let-invariance.rs:21:9 + | +LL | x //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/match-ref-mut-let-invariance.rs:19:49 + | +LL | impl<'b> S<'b> { + | -- lifetime `'b` defined here +LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { + | ____________--___________________________________^ + | | | + | | lifetime `'a` defined here +LL | | let ref mut x = self.0; +LL | | x //~ ERROR mismatched types +LL | | } + | |_____^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.rs b/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.rs new file mode 100644 index 00000000000..ea16c61dfd4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that when making a ref mut binding with type `&mut T`, the +// type `T` must match precisely the type `U` of the value being +// matched, and in particular cannot be some supertype of `U`. Issue +// #23116. This test focuses on a `let`. + +#![allow(dead_code)] +struct S<'b>(&'b i32); +impl<'b> S<'b> { + fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { + let ref mut x = self.0; + x //~ ERROR mismatched types + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.stderr b/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.stderr new file mode 100644 index 00000000000..cc096d68ebd --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-ref-mut-let-invariance.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/match-ref-mut-let-invariance.rs:21:9 + | +LL | x //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `&'a mut &'a i32` + found type `&'a mut &'b i32` +note: the lifetime 'a as defined on the method body at 19:12... + --> $DIR/match-ref-mut-let-invariance.rs:19:12 + | +LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 18:6 + --> $DIR/match-ref-mut-let-invariance.rs:18:6 + | +LL | impl<'b> S<'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/match-slice-patterns.rs b/src/test/ui/compile-fail-migration/match-slice-patterns.rs new file mode 100644 index 00000000000..a8ec95da3d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-slice-patterns.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] + +fn check(list: &[Option<()>]) { + match list { + //~^ ERROR `&[_, Some(_), None, _]` not covered + &[] => {}, + &[_] => {}, + &[_, _] => {}, + &[_, None, ..] => {}, + &[.., Some(_), _] => {}, + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/match-slice-patterns.stderr b/src/test/ui/compile-fail-migration/match-slice-patterns.stderr new file mode 100644 index 00000000000..cefd7df8b78 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-slice-patterns.stderr @@ -0,0 +1,9 @@ +error[E0004]: non-exhaustive patterns: `&[_, Some(_), None, _]` not covered + --> $DIR/match-slice-patterns.rs:14:11 + | +LL | match list { + | ^^^^ pattern `&[_, Some(_), None, _]` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/match-static-const-lc.rs b/src/test/ui/compile-fail-migration/match-static-const-lc.rs new file mode 100644 index 00000000000..afc858c0c29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-static-const-lc.rs @@ -0,0 +1,61 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #7526: lowercase static constants in patterns look like bindings + +#![allow(dead_code)] +#![deny(non_upper_case_globals)] + +#[allow(non_upper_case_globals)] +pub const a : isize = 97; + +fn f() { + let r = match (0,0) { + (0, a) => 0, + //~^ ERROR constant in pattern `a` should have an upper case name such as `A` + (x, y) => 1 + x + y, + }; + assert_eq!(r, 1); +} + +mod m { + #[allow(non_upper_case_globals)] + pub const aha : isize = 7; +} + +fn g() { + use self::m::aha; + let r = match (0,0) { + (0, aha) => 0, + //~^ ERROR constant in pattern `aha` should have an upper case name such as `AHA` + (x, y) => 1 + x + y, + }; + assert_eq!(r, 1); +} + +mod n { + pub const OKAY : isize = 8; +} + +fn h() { + use self::n::OKAY as not_okay; + let r = match (0,0) { + (0, not_okay) => 0, +//~^ ERROR constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY` + (x, y) => 1 + x + y, + }; + assert_eq!(r, 1); +} + +fn main () { + f(); + g(); + h(); +} diff --git a/src/test/ui/compile-fail-migration/match-static-const-lc.stderr b/src/test/ui/compile-fail-migration/match-static-const-lc.stderr new file mode 100644 index 00000000000..08eb5712875 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-static-const-lc.stderr @@ -0,0 +1,26 @@ +error: constant in pattern `a` should have an upper case name such as `A` + --> $DIR/match-static-const-lc.rs:21:13 + | +LL | (0, a) => 0, + | ^ + | +note: lint level defined here + --> $DIR/match-static-const-lc.rs:14:9 + | +LL | #![deny(non_upper_case_globals)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: constant in pattern `aha` should have an upper case name such as `AHA` + --> $DIR/match-static-const-lc.rs:36:13 + | +LL | (0, aha) => 0, + | ^^^ + +error: constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY` + --> $DIR/match-static-const-lc.rs:50:13 + | +LL | (0, not_okay) => 0, + | ^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/match-struct.rs b/src/test/ui/compile-fail-migration/match-struct.rs new file mode 100644 index 00000000000..0dbdda1f9ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-struct.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct S { a: isize } +enum E { C(isize) } + +fn main() { + match (S { a: 1 }) { + E::C(_) => (), + //~^ ERROR mismatched types + //~| expected type `S` + //~| found type `E` + //~| expected struct `S`, found enum `E` + _ => () + } +} diff --git a/src/test/ui/compile-fail-migration/match-struct.stderr b/src/test/ui/compile-fail-migration/match-struct.stderr new file mode 100644 index 00000000000..43f17b2d747 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-struct.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/match-struct.rs:17:9 + | +LL | E::C(_) => (), + | ^^^^^^^ expected struct `S`, found enum `E` + | + = note: expected type `S` + found type `E` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/match-tag-nullary.rs b/src/test/ui/compile-fail-migration/match-tag-nullary.rs new file mode 100644 index 00000000000..0fb26200359 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-tag-nullary.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types + +enum a { A, } +enum b { B, } + +fn main() { let x: a = a::A; match x { b::B => { } } } diff --git a/src/test/ui/compile-fail-migration/match-tag-nullary.stderr b/src/test/ui/compile-fail-migration/match-tag-nullary.stderr new file mode 100644 index 00000000000..869d8ac7747 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-tag-nullary.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/match-tag-nullary.rs:16:40 + | +LL | fn main() { let x: a = a::A; match x { b::B => { } } } + | ^^^^ expected enum `a`, found enum `b` + | + = note: expected type `a` + found type `b` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/match-tag-unary.rs b/src/test/ui/compile-fail-migration/match-tag-unary.rs new file mode 100644 index 00000000000..48733fd423d --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-tag-unary.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types + +enum a { A(isize), } +enum b { B(isize), } + +fn main() { let x: a = a::A(0); match x { b::B(y) => { } } } diff --git a/src/test/ui/compile-fail-migration/match-tag-unary.stderr b/src/test/ui/compile-fail-migration/match-tag-unary.stderr new file mode 100644 index 00000000000..bb4deee2569 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-tag-unary.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/match-tag-unary.rs:16:43 + | +LL | fn main() { let x: a = a::A(0); match x { b::B(y) => { } } } + | ^^^^^^^ expected enum `a`, found enum `b` + | + = note: expected type `a` + found type `b` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.rs b/src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.rs new file mode 100644 index 00000000000..aae0f3135d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_parens)] +#![deny(unreachable_code)] + +fn main() { + match (return) { } //~ ERROR unreachable expression +} diff --git a/src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.stderr b/src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.stderr new file mode 100644 index 00000000000..10a86f92fe1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-unreachable-warning-with-diverging-discrim.stderr @@ -0,0 +1,14 @@ +error: unreachable expression + --> $DIR/match-unreachable-warning-with-diverging-discrim.rs:15:5 + | +LL | match (return) { } //~ ERROR unreachable expression + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/match-unreachable-warning-with-diverging-discrim.rs:12:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/match-unresolved-one-arm.rs b/src/test/ui/compile-fail-migration/match-unresolved-one-arm.rs new file mode 100644 index 00000000000..ea0f8db99e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-unresolved-one-arm.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() -> T { panic!("Rocks for my pillow") } + +fn main() { + let x = match () { //~ ERROR type annotations needed + () => foo() // T here should be unresolved + }; +} diff --git a/src/test/ui/compile-fail-migration/match-unresolved-one-arm.stderr b/src/test/ui/compile-fail-migration/match-unresolved-one-arm.stderr new file mode 100644 index 00000000000..fa689a8092b --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-unresolved-one-arm.stderr @@ -0,0 +1,12 @@ +error[E0282]: type annotations needed + --> $DIR/match-unresolved-one-arm.rs:14:9 + | +LL | let x = match () { //~ ERROR type annotations needed + | ^ + | | + | cannot infer type + | consider giving `x` a type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/compile-fail-migration/match-vec-fixed.rs b/src/test/ui/compile-fail-migration/match-vec-fixed.rs new file mode 100644 index 00000000000..05971d70167 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-fixed.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unreachable_patterns)] + +fn a() { + let v = [1, 2, 3]; + match v { + [_, _, _] => {} + [_, _, _] => {} //~ ERROR unreachable pattern + } + match v { + [_, 1, _] => {} + [_, 1, _] => {} //~ ERROR unreachable pattern + _ => {} + } +} + +fn main() { + a(); +} diff --git a/src/test/ui/compile-fail-migration/match-vec-fixed.stderr b/src/test/ui/compile-fail-migration/match-vec-fixed.stderr new file mode 100644 index 00000000000..1b85034ef6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-fixed.stderr @@ -0,0 +1,20 @@ +error: unreachable pattern + --> $DIR/match-vec-fixed.rs:17:9 + | +LL | [_, _, _] => {} //~ ERROR unreachable pattern + | ^^^^^^^^^ + | +note: lint level defined here + --> $DIR/match-vec-fixed.rs:11:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-vec-fixed.rs:21:9 + | +LL | [_, 1, _] => {} //~ ERROR unreachable pattern + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/match-vec-mismatch-2.rs b/src/test/ui/compile-fail-migration/match-vec-mismatch-2.rs new file mode 100644 index 00000000000..52c5375f4e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-mismatch-2.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match () { + [()] => { } + //~^ ERROR expected an array or slice, found `()` + } +} diff --git a/src/test/ui/compile-fail-migration/match-vec-mismatch-2.stderr b/src/test/ui/compile-fail-migration/match-vec-mismatch-2.stderr new file mode 100644 index 00000000000..66f58bdff32 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-mismatch-2.stderr @@ -0,0 +1,9 @@ +error[E0529]: expected an array or slice, found `()` + --> $DIR/match-vec-mismatch-2.rs:13:9 + | +LL | [()] => { } + | ^^^^ pattern cannot match with input type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0529`. diff --git a/src/test/ui/compile-fail-migration/match-vec-mismatch.rs b/src/test/ui/compile-fail-migration/match-vec-mismatch.rs new file mode 100644 index 00000000000..d737aa0029b --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-mismatch.rs @@ -0,0 +1,48 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] + +fn main() { + match "foo".to_string() { + ['f', 'o', ..] => {} + //~^ ERROR expected an array or slice, found `std::string::String` + _ => { } + }; + + // Note that this one works with default binding modes. + match &[0, 1, 2] { + [..] => {} + }; + + match &[0, 1, 2] { + &[..] => {} // ok + }; + + match [0, 1, 2] { + [0] => {}, //~ ERROR pattern requires + + [0, 1, x..] => { + let a: [_; 1] = x; + } + [0, 1, 2, 3, x..] => {} //~ ERROR pattern requires + }; + + match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope + [] => {} + }; +} + +fn another_fn_to_avoid_suppression() { + match Default::default() + { + [] => {} //~ ERROR type annotations needed + }; +} diff --git a/src/test/ui/compile-fail-migration/match-vec-mismatch.stderr b/src/test/ui/compile-fail-migration/match-vec-mismatch.stderr new file mode 100644 index 00000000000..c30ddf9d0fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-mismatch.stderr @@ -0,0 +1,36 @@ +error[E0425]: cannot find value `does_not_exist` in this scope + --> $DIR/match-vec-mismatch.rs:38:11 + | +LL | match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope + | ^^^^^^^^^^^^^^ not found in this scope + +error[E0529]: expected an array or slice, found `std::string::String` + --> $DIR/match-vec-mismatch.rs:15:9 + | +LL | ['f', 'o', ..] => {} + | ^^^^^^^^^^^^^^ pattern cannot match with input type `std::string::String` + +error[E0527]: pattern requires 1 elements but array has 3 + --> $DIR/match-vec-mismatch.rs:30:9 + | +LL | [0] => {}, //~ ERROR pattern requires + | ^^^ expected 3 elements + +error[E0528]: pattern requires at least 4 elements but array has 3 + --> $DIR/match-vec-mismatch.rs:35:9 + | +LL | [0, 1, 2, 3, x..] => {} //~ ERROR pattern requires + | ^^^^^^^^^^^^^^^^^ pattern cannot match array of 3 elements + +error[E0282]: type annotations needed + --> $DIR/match-vec-mismatch.rs:46:9 + | +LL | [] => {} //~ ERROR type annotations needed + | ^^ cannot infer type + | + = note: type must be known at this point + +error: aborting due to 5 previous errors + +Some errors occurred: E0282, E0425, E0527, E0528, E0529. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/compile-fail-migration/match-vec-unreachable.rs b/src/test/ui/compile-fail-migration/match-vec-unreachable.rs new file mode 100644 index 00000000000..d6e3fdbe088 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-unreachable.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] +#![deny(unreachable_patterns)] + +fn main() { + let x: Vec<(isize, isize)> = Vec::new(); + let x: &[(isize, isize)] = &x; + match *x { + [a, (2, 3), _] => (), + [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern + _ => () + } + + let x: Vec = vec!["foo".to_string(), + "bar".to_string(), + "baz".to_string()]; + let x: &[String] = &x; + match *x { + [ref a, _, _, ..] => { println!("{}", a); } + [_, _, _, _, _] => { } //~ ERROR unreachable pattern + _ => { } + } + + let x: Vec = vec!['a', 'b', 'c']; + let x: &[char] = &x; + match *x { + ['a', 'b', 'c', ref _tail..] => {} + ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/match-vec-unreachable.stderr b/src/test/ui/compile-fail-migration/match-vec-unreachable.stderr new file mode 100644 index 00000000000..e8869e86bf9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/match-vec-unreachable.stderr @@ -0,0 +1,26 @@ +error: unreachable pattern + --> $DIR/match-vec-unreachable.rs:19:9 + | +LL | [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern + | ^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/match-vec-unreachable.rs:12:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-vec-unreachable.rs:29:9 + | +LL | [_, _, _, _, _] => { } //~ ERROR unreachable pattern + | ^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/match-vec-unreachable.rs:37:9 + | +LL | ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern + | ^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.rs b/src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.rs new file mode 100644 index 00000000000..f10526200ff --- /dev/null +++ b/src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +struct S(*const T) where T: ?Sized; + +#[rustc_error] +fn main() { //~ ERROR compilation successful + let u = vec![1, 2, 3]; + let _s: S<[u8]> = S(&u[..]); +} diff --git a/src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.stderr b/src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.stderr new file mode 100644 index 00000000000..d60e4cdffb4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/maybe-bounds-where-cpass.stderr @@ -0,0 +1,11 @@ +error: compilation successful + --> $DIR/maybe-bounds-where-cpass.rs:16:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | let u = vec![1, 2, 3]; +LL | | let _s: S<[u8]> = S(&u[..]); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/maybe-bounds-where.rs b/src/test/ui/compile-fail-migration/maybe-bounds-where.rs new file mode 100644 index 00000000000..211fac2ee23 --- /dev/null +++ b/src/test/ui/compile-fail-migration/maybe-bounds-where.rs @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S1(T) where (T): ?Sized; +//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared + +struct S2(T) where u8: ?Sized; +//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared + +struct S3(T) where &'static T: ?Sized; +//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared + +trait Trait<'a> {} + +struct S4(T) where for<'a> T: ?Trait<'a>; +//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared + +struct S5(*const T) where T: ?Trait<'static> + ?Sized; +//~^ ERROR type parameter has more than one relaxed default bound +//~| WARN default bound relaxed for a type parameter + +impl S1 { + fn f() where T: ?Sized {} + //~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared +} + +fn main() { + let u = vec![1, 2, 3]; + let _s: S5<[u8]> = S5(&u[..]); // OK +} diff --git a/src/test/ui/compile-fail-migration/maybe-bounds-where.stderr b/src/test/ui/compile-fail-migration/maybe-bounds-where.stderr new file mode 100644 index 00000000000..02aafecb7a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/maybe-bounds-where.stderr @@ -0,0 +1,45 @@ +error: `?Trait` bounds are only permitted at the point where a type parameter is declared + --> $DIR/maybe-bounds-where.rs:11:23 + | +LL | struct S1(T) where (T): ?Sized; + | ^^^ + +error: `?Trait` bounds are only permitted at the point where a type parameter is declared + --> $DIR/maybe-bounds-where.rs:14:23 + | +LL | struct S2(T) where u8: ?Sized; + | ^^ + +error: `?Trait` bounds are only permitted at the point where a type parameter is declared + --> $DIR/maybe-bounds-where.rs:17:23 + | +LL | struct S3(T) where &'static T: ?Sized; + | ^^^^^^^^^^ + +error: `?Trait` bounds are only permitted at the point where a type parameter is declared + --> $DIR/maybe-bounds-where.rs:22:31 + | +LL | struct S4(T) where for<'a> T: ?Trait<'a>; + | ^ + +error: `?Trait` bounds are only permitted at the point where a type parameter is declared + --> $DIR/maybe-bounds-where.rs:30:18 + | +LL | fn f() where T: ?Sized {} + | ^ + +error[E0203]: type parameter has more than one relaxed default bound, only one is supported + --> $DIR/maybe-bounds-where.rs:25:11 + | +LL | struct S5(*const T) where T: ?Trait<'static> + ?Sized; + | ^ + +warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default. Only `?Sized` is supported + --> $DIR/maybe-bounds-where.rs:25:11 + | +LL | struct S5(*const T) where T: ?Trait<'static> + ?Sized; + | ^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0203`. diff --git a/src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.a.stderr b/src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.a.stderr new file mode 100644 index 00000000000..20b93068c64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.a.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/meta-expected-error-correct-rev.rs:17:18 + | +LL | let x: u32 = 22_usize; //[a]~ ERROR mismatched types + | ^^^^^^^^ expected u32, found usize + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.rs b/src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.rs new file mode 100644 index 00000000000..bd70879d13e --- /dev/null +++ b/src/test/ui/compile-fail-migration/meta-expected-error-correct-rev.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: a + +// Counterpart to `meta-expected-error-wrong-rev.rs` + +#[cfg(a)] +fn foo() { + let x: u32 = 22_usize; //[a]~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.a.stderr b/src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.a.stderr new file mode 100644 index 00000000000..e78144be157 --- /dev/null +++ b/src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.a.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/meta-expected-error-wrong-rev.rs:21:18 + | +LL | let x: u32 = 22_usize; //[b]~ ERROR mismatched types + | ^^^^^^^^ expected u32, found usize + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.rs b/src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.rs new file mode 100644 index 00000000000..3c13050812c --- /dev/null +++ b/src/test/ui/compile-fail-migration/meta-expected-error-wrong-rev.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: a +// should-fail + +// This is a "meta-test" of the compilertest framework itself. In +// particular, it includes the right error message, but the message +// targets the wrong revision, so we expect the execution to fail. +// See also `meta-expected-error-correct-rev.rs`. + +#[cfg(a)] +fn foo() { + let x: u32 = 22_usize; //[b]~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.rs b/src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.rs new file mode 100644 index 00000000000..9acf5a52166 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.rs @@ -0,0 +1,46 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we invoking `foo()` successfully resolves to the trait `foo` +// (prompting the mismatched types error) but does not influence the choice +// of what kind of `Vec` we have, eventually leading to a type error. + +trait foo { + fn foo(&self) -> isize; +} + +impl foo for Vec { + fn foo(&self) -> isize {1} +} + +impl foo for Vec { + fn foo(&self) -> isize {2} +} + +// This is very hokey: we have heuristics to suppress messages about +// type annotations required. But placing these two bits of code into +// distinct functions, in this order, causes us to print out both +// errors I'd like to see. + +fn m1() { + // we couldn't infer the type of the vector just based on calling foo()... + let mut x = Vec::new(); + //~^ ERROR type annotations needed [E0282] + x.foo(); +} + +fn m2() { + let mut x = Vec::new(); + + // ...but we still resolved `foo()` to the trait and hence know the return type. + let y: usize = x.foo(); //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.stderr b/src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.stderr new file mode 100644 index 00000000000..7f034b9e53d --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-one-trait-unknown-int-type.stderr @@ -0,0 +1,18 @@ +error[E0282]: type annotations needed + --> $DIR/method-ambig-one-trait-unknown-int-type.rs:34:17 + | +LL | let mut x = Vec::new(); + | ----- ^^^^^^^^ cannot infer type for `T` + | | + | consider giving `x` a type + +error[E0308]: mismatched types + --> $DIR/method-ambig-one-trait-unknown-int-type.rs:43:20 + | +LL | let y: usize = x.foo(); //~ ERROR mismatched types + | ^^^^^^^ expected usize, found isize + +error: aborting due to 2 previous errors + +Some errors occurred: E0282, E0308. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.rs b/src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.rs new file mode 100644 index 00000000000..c1d4551fd9e --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.rs @@ -0,0 +1,21 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test an ambiguity scenario where one copy of the method is available +// from a trait imported from another crate. + +// aux-build:ambig_impl_2_lib.rs +extern crate ambig_impl_2_lib; +use ambig_impl_2_lib::me; +trait me2 { + fn me(&self) -> usize; +} +impl me2 for usize { fn me(&self) -> usize { *self } } +fn main() { 1_usize.me(); } //~ ERROR E0034 diff --git a/src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.stderr b/src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.stderr new file mode 100644 index 00000000000..7a75f20f65a --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-two-traits-cross-crate.stderr @@ -0,0 +1,16 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/method-ambig-two-traits-cross-crate.rs:21:21 + | +LL | fn main() { 1_usize.me(); } //~ ERROR E0034 + | ^^ multiple `me` found + | +note: candidate #1 is defined in an impl of the trait `me2` for the type `usize` + --> $DIR/method-ambig-two-traits-cross-crate.rs:20:22 + | +LL | impl me2 for usize { fn me(&self) -> usize { *self } } + | ^^^^^^^^^^^^^^^^^^^^^ + = note: candidate #2 is defined in an impl of the trait `ambig_impl_2_lib::me` for the type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.rs b/src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.rs new file mode 100644 index 00000000000..184927c0135 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait A { fn foo(&self); } +trait B { fn foo(&self); } + +fn foo(t: T) { + t.foo(); //~ ERROR E0034 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.stderr b/src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.stderr new file mode 100644 index 00000000000..06003d900b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-two-traits-from-bounds.stderr @@ -0,0 +1,22 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/method-ambig-two-traits-from-bounds.rs:15:7 + | +LL | t.foo(); //~ ERROR E0034 + | ^^^ multiple `foo` found + | +note: candidate #1 is defined in the trait `A` + --> $DIR/method-ambig-two-traits-from-bounds.rs:11:11 + | +LL | trait A { fn foo(&self); } + | ^^^^^^^^^^^^^^ + = help: to disambiguate the method call, write `A::foo(t)` instead +note: candidate #2 is defined in the trait `B` + --> $DIR/method-ambig-two-traits-from-bounds.rs:12:11 + | +LL | trait B { fn foo(&self); } + | ^^^^^^^^^^^^^^ + = help: to disambiguate the method call, write `B::foo(t)` instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.rs b/src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.rs new file mode 100644 index 00000000000..17312fb1869 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.rs @@ -0,0 +1,23 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we correctly report an ambiguity where two applicable traits +// are in scope and the method being invoked is a default method not +// defined directly in the impl. + +trait Foo { fn method(&self) {} } +trait Bar { fn method(&self) {} } + +impl Foo for usize {} +impl Bar for usize {} + +fn main() { + 1_usize.method(); //~ ERROR E0034 +} diff --git a/src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.stderr b/src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.stderr new file mode 100644 index 00000000000..d67e17d228f --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-ambig-two-traits-with-default-method.stderr @@ -0,0 +1,20 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/method-ambig-two-traits-with-default-method.rs:22:13 + | +LL | 1_usize.method(); //~ ERROR E0034 + | ^^^^^^ multiple `method` found + | +note: candidate #1 is defined in an impl of the trait `Foo` for the type `usize` + --> $DIR/method-ambig-two-traits-with-default-method.rs:15:13 + | +LL | trait Foo { fn method(&self) {} } + | ^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `Bar` for the type `usize` + --> $DIR/method-ambig-two-traits-with-default-method.rs:16:13 + | +LL | trait Bar { fn method(&self) {} } + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.rs b/src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.rs new file mode 100644 index 00000000000..b2a94e0af42 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.rs @@ -0,0 +1,97 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(late_bound_lifetime_arguments)] +#![allow(unused)] + +struct S; + +impl S { + fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + fn late_implicit(self, _: &u8, _: &u8) {} + fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + + // 'late lifetimes here belong to nested types not to the tested functions. + fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8), + _: Box Fn(&'late u8)>) + -> &'a u8 { loop {} } + fn early_tricky_implicit<'a>(_: fn(&u8), + _: Box) + -> &'a u8 { loop {} } +} + +fn method_call() { + S.late(&0, &0); // OK + S.late::<'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late::<'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late::<'static, 'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_early(&0); // OK + S.late_early::<'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_early::<'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_early::<'static, 'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + + S.late_implicit(&0, &0); // OK + S.late_implicit::<'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit::<'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit::<'static, 'static, 'static>(&0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit_early(&0); // OK + S.late_implicit_early::<'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit_early::<'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + S.late_implicit_early::<'static, 'static, 'static>(&0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + + S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK + S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK +} + +fn ufcs() { + S::late_early::<'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted + + S::late_implicit_early::<'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted +} + +fn lint_not_inference_error() { + fn f<'early, 'late, T: 'early>() {} + + // Make sure `u8` is substituted and not replaced with an inference variable + f::<'static, u8>; + //~^ ERROR cannot specify lifetime arguments explicitly + //~| WARN this was previously accepted +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.stderr b/src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.stderr new file mode 100644 index 00000000000..682cfbdb84a --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args-lint.stderr @@ -0,0 +1,187 @@ +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:33:14 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | -- the late bound lifetime parameter is introduced here +... +LL | S.late::<'static>(&0, &0); + | ^^^^^^^ + | +note: lint level defined here + --> $DIR/method-call-lifetime-args-lint.rs:11:9 + | +LL | #![deny(late_bound_lifetime_arguments)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:36:14 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | -- the late bound lifetime parameter is introduced here +... +LL | S.late::<'static, 'static>(&0, &0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:39:14 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | -- the late bound lifetime parameter is introduced here +... +LL | S.late::<'static, 'static, 'static>(&0, &0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:43:20 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | -- the late bound lifetime parameter is introduced here +... +LL | S.late_early::<'static>(&0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:46:20 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | -- the late bound lifetime parameter is introduced here +... +LL | S.late_early::<'static, 'static>(&0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:49:20 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | -- the late bound lifetime parameter is introduced here +... +LL | S.late_early::<'static, 'static, 'static>(&0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:54:23 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | - the late bound lifetime parameter is introduced here +... +LL | S.late_implicit::<'static>(&0, &0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:57:23 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | - the late bound lifetime parameter is introduced here +... +LL | S.late_implicit::<'static, 'static>(&0, &0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:60:23 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | - the late bound lifetime parameter is introduced here +... +LL | S.late_implicit::<'static, 'static, 'static>(&0, &0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:64:29 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | - the late bound lifetime parameter is introduced here +... +LL | S.late_implicit_early::<'static>(&0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:67:29 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | - the late bound lifetime parameter is introduced here +... +LL | S.late_implicit_early::<'static, 'static>(&0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:70:29 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | - the late bound lifetime parameter is introduced here +... +LL | S.late_implicit_early::<'static, 'static, 'static>(&0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:79:21 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | -- the late bound lifetime parameter is introduced here +... +LL | S::late_early::<'static>(S, &0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:83:30 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | - the late bound lifetime parameter is introduced here +... +LL | S::late_implicit_early::<'static>(S, &0); + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args-lint.rs:92:9 + | +LL | fn f<'early, 'late, T: 'early>() {} + | ----- the late bound lifetime parameter is introduced here +... +LL | f::<'static, u8>; + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42868 + +error: aborting due to 15 previous errors + diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.rs b/src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.rs new file mode 100644 index 00000000000..a9505e4f936 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(unused)] + +struct S; + +impl S { + fn early_and_type<'a, T>(self) -> &'a T { loop {} } +} + +fn test() { + S.early_and_type::(); +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.stderr b/src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.stderr new file mode 100644 index 00000000000..2848ff88c17 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args-subst-index.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/method-call-lifetime-args-subst-index.rs:25:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.rs b/src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.rs new file mode 100644 index 00000000000..4910bfaf4f6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + 0.clone::<'a>(); //~ ERROR use of undeclared lifetime name `'a` +} diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.stderr b/src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.stderr new file mode 100644 index 00000000000..8eb860d9474 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args-unresolved.stderr @@ -0,0 +1,9 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/method-call-lifetime-args-unresolved.rs:12:15 + | +LL | 0.clone::<'a>(); //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args.rs b/src/test/ui/compile-fail-migration/method-call-lifetime-args.rs new file mode 100644 index 00000000000..f0a87c74703 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args.rs @@ -0,0 +1,82 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S; + +impl S { + fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + fn late_implicit(self, _: &u8, _: &u8) {} + fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } + fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } + fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } + fn life_and_type<'a, T>(self) -> &'a T { loop {} } +} + +fn method_call() { + S.early(); // OK + S.early::<'static>(); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + S.early::<'static, 'static, 'static>(); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters + let _: &u8 = S.life_and_type::<'static>(); + S.life_and_type::(); + S.life_and_type::<'static, u8>(); +} + +fn ufcs() { + S::late(S, &0, &0); // OK + S::late::<'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late::<'static, 'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late::<'static, 'static, 'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_early(S, &0); // OK + S::late_early::<'static, 'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_early::<'static, 'static, 'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + + S::late_implicit(S, &0, &0); // OK + S::late_implicit::<'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit::<'static, 'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit::<'static, 'static, 'static>(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_early(S, &0); // OK + S::late_implicit_early::<'static, 'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_early::<'static, 'static, 'static>(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_self_early(&S); // OK + S::late_implicit_self_early::<'static, 'static>(&S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_self_early::<'static, 'static, 'static>(&S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_unused_early(S); // OK + S::late_unused_early::<'static, 'static>(S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_unused_early::<'static, 'static, 'static>(S); + //~^ ERROR cannot specify lifetime arguments explicitly + + S::early(S); // OK + S::early::<'static>(S); + //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter + S::early::<'static, 'static, 'static>(S); + //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters + let _: &u8 = S::life_and_type::<'static>(S); + S::life_and_type::(S); + S::life_and_type::<'static, u8>(S); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/method-call-lifetime-args.stderr b/src/test/ui/compile-fail-migration/method-call-lifetime-args.stderr new file mode 100644 index 00000000000..736dba9061e --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-lifetime-args.stderr @@ -0,0 +1,196 @@ +error[E0090]: too few lifetime parameters provided: expected 2 lifetime parameters, found 1 lifetime parameter + --> $DIR/method-call-lifetime-args.rs:26:7 + | +LL | S.early::<'static>(); + | ^^^^^ expected 2 lifetime parameters + +error[E0088]: too many lifetime parameters provided: expected at most 2 lifetime parameters, found 3 lifetime parameters + --> $DIR/method-call-lifetime-args.rs:28:33 + | +LL | S.early::<'static, 'static, 'static>(); + | ^^^^^^^ expected 2 lifetime parameters + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:37:15 + | +LL | S::late::<'static>(S, &0, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:14:13 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:39:15 + | +LL | S::late::<'static, 'static>(S, &0, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:14:13 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:41:15 + | +LL | S::late::<'static, 'static, 'static>(S, &0, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:14:13 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:44:21 + | +LL | S::late_early::<'static, 'static>(S, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:17:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:46:21 + | +LL | S::late_early::<'static, 'static, 'static>(S, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:17:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:50:24 + | +LL | S::late_implicit::<'static>(S, &0, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:15:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:52:24 + | +LL | S::late_implicit::<'static, 'static>(S, &0, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:15:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:54:24 + | +LL | S::late_implicit::<'static, 'static, 'static>(S, &0, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:15:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:57:30 + | +LL | S::late_implicit_early::<'static, 'static>(S, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:18:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:59:30 + | +LL | S::late_implicit_early::<'static, 'static, 'static>(S, &0); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:18:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:62:35 + | +LL | S::late_implicit_self_early::<'static, 'static>(&S); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:19:37 + | +LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } + | ^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:64:35 + | +LL | S::late_implicit_self_early::<'static, 'static, 'static>(&S); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:19:37 + | +LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } + | ^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:67:28 + | +LL | S::late_unused_early::<'static, 'static>(S); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:20:26 + | +LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } + | ^^ + +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/method-call-lifetime-args.rs:69:28 + | +LL | S::late_unused_early::<'static, 'static, 'static>(S); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args.rs:20:26 + | +LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } + | ^^ + +error[E0090]: too few lifetime parameters provided: expected 2 lifetime parameters, found 1 lifetime parameter + --> $DIR/method-call-lifetime-args.rs:73:5 + | +LL | S::early::<'static>(S); + | ^^^^^^^^^^^^^^^^^^^ expected 2 lifetime parameters + +error[E0088]: too many lifetime parameters provided: expected at most 2 lifetime parameters, found 3 lifetime parameters + --> $DIR/method-call-lifetime-args.rs:75:34 + | +LL | S::early::<'static, 'static, 'static>(S); + | ^^^^^^^ expected 2 lifetime parameters + +error: aborting due to 18 previous errors + +Some errors occurred: E0088, E0090. +For more information about an error, try `rustc --explain E0088`. diff --git a/src/test/ui/compile-fail-migration/method-call-type-binding.rs b/src/test/ui/compile-fail-migration/method-call-type-binding.rs new file mode 100644 index 00000000000..6c0793ee78f --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-type-binding.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + 0.clone::(); //~ ERROR associated type bindings are not allowed here +} diff --git a/src/test/ui/compile-fail-migration/method-call-type-binding.stderr b/src/test/ui/compile-fail-migration/method-call-type-binding.stderr new file mode 100644 index 00000000000..aafc84804b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-call-type-binding.stderr @@ -0,0 +1,9 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/method-call-type-binding.rs:12:15 + | +LL | 0.clone::(); //~ ERROR associated type bindings are not allowed here + | ^^^^^^ associated type not allowed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0229`. diff --git a/src/test/ui/compile-fail-migration/method-macro-backtrace.rs b/src/test/ui/compile-fail-migration/method-macro-backtrace.rs new file mode 100644 index 00000000000..f3c227849dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-macro-backtrace.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// forbid-output: in this expansion of + +macro_rules! make_method { + ($name:ident) => ( fn $name(&self) { } ) +} + +struct S; + +impl S { + // We had a bug where these wouldn't clean up macro backtrace frames. + make_method!(foo1); + make_method!(foo2); + make_method!(foo3); + make_method!(foo4); + make_method!(foo5); + make_method!(foo6); + make_method!(foo7); + make_method!(foo8); + + // Cause an error. It shouldn't have any macro backtrace frames. + fn bar(&self) { } + fn bar(&self) { } //~ ERROR duplicate definitions +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/method-macro-backtrace.stderr b/src/test/ui/compile-fail-migration/method-macro-backtrace.stderr new file mode 100644 index 00000000000..28f46dba1cc --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-macro-backtrace.stderr @@ -0,0 +1,11 @@ +error[E0201]: duplicate definitions with name `bar`: + --> $DIR/method-macro-backtrace.rs:32:5 + | +LL | fn bar(&self) { } + | ----------------- previous definition of `bar` here +LL | fn bar(&self) { } //~ ERROR duplicate definitions + | ^^^^^^^^^^^^^^^^^ duplicate definition + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0201`. diff --git a/src/test/ui/compile-fail-migration/method-path-in-pattern.rs b/src/test/ui/compile-fail-migration/method-path-in-pattern.rs new file mode 100644 index 00000000000..671a518073c --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-path-in-pattern.rs @@ -0,0 +1,36 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo; + +impl Foo { + fn bar(&self) {} +} + +trait MyTrait { + fn trait_bar() {} +} + +impl MyTrait for Foo {} + +fn main() { + match 0u32 { + Foo::bar => {} + //~^ ERROR expected unit struct/variant or constant, found method `::bar` + } + match 0u32 { + ::bar => {} + //~^ ERROR expected unit struct/variant or constant, found method `::bar` + } + match 0u32 { + ::trait_bar => {} + //~^ ERROR expected unit struct/variant or constant, found method `::trait_bar` + } +} diff --git a/src/test/ui/compile-fail-migration/method-path-in-pattern.stderr b/src/test/ui/compile-fail-migration/method-path-in-pattern.stderr new file mode 100644 index 00000000000..1fae336c79c --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-path-in-pattern.stderr @@ -0,0 +1,21 @@ +error[E0533]: expected unit struct/variant or constant, found method `::bar` + --> $DIR/method-path-in-pattern.rs:25:9 + | +LL | Foo::bar => {} + | ^^^^^^^^ + +error[E0533]: expected unit struct/variant or constant, found method `::bar` + --> $DIR/method-path-in-pattern.rs:29:9 + | +LL | ::bar => {} + | ^^^^^^^^^^ + +error[E0533]: expected unit struct/variant or constant, found method `::trait_bar` + --> $DIR/method-path-in-pattern.rs:33:9 + | +LL | ::trait_bar => {} + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0533`. diff --git a/src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.rs b/src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.rs new file mode 100644 index 00000000000..4d8959466b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo; + +trait MyTrait { + fn trait_bar() {} +} + +impl MyTrait for Foo {} + +fn main() { + match 0u32 { + ::trait_bar => {} + //~^ ERROR expected unit struct/variant or constant, found method `MyTrait::trait_bar` + } +} diff --git a/src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.stderr b/src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.stderr new file mode 100644 index 00000000000..c86367dac08 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-resolvable-path-in-pattern.stderr @@ -0,0 +1,9 @@ +error[E0532]: expected unit struct/variant or constant, found method `MyTrait::trait_bar` + --> $DIR/method-resolvable-path-in-pattern.rs:21:9 + | +LL | ::trait_bar => {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct/variant or constant + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0532`. diff --git a/src/test/ui/compile-fail-migration/method-self-arg-1.rs b/src/test/ui/compile-fail-migration/method-self-arg-1.rs new file mode 100644 index 00000000000..4c8800878f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-self-arg-1.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test method calls with self as an argument cannot subvert type checking. + +struct Foo; + +impl Foo { + fn bar(&self) {} +} + +fn main() { + let x = Foo; + Foo::bar(x); //~ ERROR mismatched types + //~| expected type `&Foo` + //~| found type `Foo` + //~| expected &Foo, found struct `Foo` + Foo::bar(&42); //~ ERROR mismatched types + //~| expected type `&Foo` + //~| found type `&{integer}` + //~| expected struct `Foo`, found integral variable +} diff --git a/src/test/ui/compile-fail-migration/method-self-arg-1.stderr b/src/test/ui/compile-fail-migration/method-self-arg-1.stderr new file mode 100644 index 00000000000..4a5ac2b5aed --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-self-arg-1.stderr @@ -0,0 +1,24 @@ +error[E0308]: mismatched types + --> $DIR/method-self-arg-1.rs:21:14 + | +LL | Foo::bar(x); //~ ERROR mismatched types + | ^ + | | + | expected &Foo, found struct `Foo` + | help: consider borrowing here: `&x` + | + = note: expected type `&Foo` + found type `Foo` + +error[E0308]: mismatched types + --> $DIR/method-self-arg-1.rs:25:14 + | +LL | Foo::bar(&42); //~ ERROR mismatched types + | ^^^ expected struct `Foo`, found integral variable + | + = note: expected type `&Foo` + found type `&{integer}` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/method-self-arg-2.rs b/src/test/ui/compile-fail-migration/method-self-arg-2.rs new file mode 100644 index 00000000000..dd5b2004145 --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-self-arg-2.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test method calls with self as an argument cannot subvert borrow checking. + +struct Foo; + +impl Foo { + fn bar(&self) {} + fn baz(&mut self) {} +} + +fn main() { + let mut x = Foo; + let y = &mut x; + Foo::bar(&x); //~ERROR cannot borrow `x` + + let mut x = Foo; + let y = &mut x; + Foo::baz(&mut x); //~ERROR cannot borrow `x` +} diff --git a/src/test/ui/compile-fail-migration/method-self-arg-2.stderr b/src/test/ui/compile-fail-migration/method-self-arg-2.stderr new file mode 100644 index 00000000000..d4e049d7f6e --- /dev/null +++ b/src/test/ui/compile-fail-migration/method-self-arg-2.stderr @@ -0,0 +1,25 @@ +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/method-self-arg-2.rs:23:15 + | +LL | let y = &mut x; + | - mutable borrow occurs here +LL | Foo::bar(&x); //~ERROR cannot borrow `x` + | ^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/method-self-arg-2.rs:27:19 + | +LL | let y = &mut x; + | - first mutable borrow occurs here +LL | Foo::baz(&mut x); //~ERROR cannot borrow `x` + | ^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error: aborting due to 2 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/minus-string.rs b/src/test/ui/compile-fail-migration/minus-string.rs new file mode 100644 index 00000000000..1ba30c67a03 --- /dev/null +++ b/src/test/ui/compile-fail-migration/minus-string.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:cannot apply unary operator `-` to type `std::string::String` + +fn main() { -"foo".to_string(); } diff --git a/src/test/ui/compile-fail-migration/minus-string.stderr b/src/test/ui/compile-fail-migration/minus-string.stderr new file mode 100644 index 00000000000..cbbb11ae33a --- /dev/null +++ b/src/test/ui/compile-fail-migration/minus-string.stderr @@ -0,0 +1,11 @@ +error[E0600]: cannot apply unary operator `-` to type `std::string::String` + --> $DIR/minus-string.rs:13:13 + | +LL | fn main() { -"foo".to_string(); } + | ^^^^^^^^^^^^^^^^^^ cannot apply unary operator `-` + | + = note: an implementation of `std::ops::Neg` might be missing for `std::string::String` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0600`. diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/README.md b/src/test/ui/compile-fail-migration/mir-dataflow/README.md new file mode 100644 index 00000000000..a3ab14b23c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/README.md @@ -0,0 +1,53 @@ +This directory contains unit tests for the MIR-based dataflow +analysis. + +These unit tests check the dataflow analysis by embedding calls to a +special `rustc_peek` intrinsic within the code, in tandem with an +attribute `#[rustc_mir(rustc_peek_maybe_init)]` (\*). With that +attribute in place, `rustc_peek` calls are a signal to the compiler to +lookup the computed dataflow state for the Lvalue corresponding to the +argument expression being fed to `rustc_peek`. If the dataflow state +for that Lvalue is a 1-bit at that point in the control flow, then no +error is emitted by the compiler at that point; if it is a 0-bit, then +that invocation of `rustc_peek` will emit an error with the message +"rustc_peek: bit not set". + +(\*): Or `#[rustc_mir(rustc_peek_maybe_uninit)]`, and perhaps other +variants in the future. + +The end effect is that one can write unit tests for MIR dataflow that +perform simple-queries of the computed dataflow state, and the tests +should be able to be robust in the face of changes to how MIR is +represented or constructed. + +---- + +Sometimes understanding the dataflow results is difficult without +looking at the actual MIR control-flow graph being processed with the +corresponding GEN and KILL sets. + +For a graphviz-rendering with dataflow annotations, add the attribute +`#[rustc_mir(borrowck_graphviz_postflow="/path/to/suffix.dot")]` to +the function in question. (You can change the content of +`"suffix.dot"` to control the filenames used for the output). This +will generate a separate file for each dataflow analysis, adding a +prefix (corresponding to the name of the analysis) to the filename in +each generated output path. + + * For example, the above attribute will currently cause two files to + be generated: `/path/to/maybe_init_suffix.dot` and + `/path/to/maybe_uninit_suffix.dot`. + + * The generated `.dot` file shows both the computed dataflow results + on *entry* to each block, as well as the gen- and kill-sets that + were so-called "transfer functions" summarizing the effect of each + basic block. + + * (In addition to the `borrowck_graphviz_postflow` attribute-key + noted above, there is also `borrowck_graphviz_preflow`; it has the + same interface and generates the same set of files, but it renders + the dataflow state after building the gen- and kill-sets but + *before* running the dataflow analysis itself, so each entry-set is + just the initial default state for that dataflow analysis. This is + less useful for understanding the error message output in these + tests.) diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.rs b/src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.rs new file mode 100644 index 00000000000..f5f0ede6864 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.rs @@ -0,0 +1,62 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// General test of maybe_uninits state computed by MIR dataflow. + +#![feature(nll)] +#![feature(core_intrinsics, rustc_attrs)] + +use std::intrinsics::rustc_peek; +use std::mem::{drop, replace}; + +struct S(i32); + +#[rustc_mir(rustc_peek_definite_init,stop_after_dataflow)] +fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { + let ret; + // `ret` starts off uninitialized + unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set + + // All function formal parameters start off initialized. + + unsafe { rustc_peek(&x) }; + unsafe { rustc_peek(&y) }; + unsafe { rustc_peek(&z) }; + + ret = if test { + ::std::mem::replace(x, y) + } else { + z = y; + z + }; + + // `z` may be uninitialized here. + unsafe { rustc_peek(&z); } //~ ERROR rustc_peek: bit not set + + // `y` is definitely uninitialized here. + unsafe { rustc_peek(&y); } //~ ERROR rustc_peek: bit not set + + // `x` is still (definitely) initialized (replace above is a reborrow). + unsafe { rustc_peek(&x); } + + ::std::mem::drop(x); + + // `x` is *definitely* uninitialized here + unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set + + // `ret` is now definitely initialized (via `if` above). + unsafe { rustc_peek(&ret); } + + ret +} +fn main() { + foo(true, &mut S(13), S(14), S(15)); + foo(false, &mut S(13), S(14), S(15)); +} diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.stderr b/src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.stderr new file mode 100644 index 00000000000..84d3c66ac33 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/def-inits-1.stderr @@ -0,0 +1,28 @@ +error: rustc_peek: bit not set + --> $DIR/def-inits-1.rs:25:14 + | +LL | unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/def-inits-1.rs:41:14 + | +LL | unsafe { rustc_peek(&z); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/def-inits-1.rs:44:14 + | +LL | unsafe { rustc_peek(&y); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/def-inits-1.rs:52:14 + | +LL | unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: stop_after_dataflow ended compilation + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/inits-1.rs b/src/test/ui/compile-fail-migration/mir-dataflow/inits-1.rs new file mode 100644 index 00000000000..595f01f7c94 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/inits-1.rs @@ -0,0 +1,64 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// General test of maybe_inits state computed by MIR dataflow. + +#![feature(nll)] +#![feature(core_intrinsics, rustc_attrs)] + +use std::intrinsics::rustc_peek; +use std::mem::{drop, replace}; + +struct S(i32); + +#[rustc_mir(rustc_peek_maybe_init,stop_after_dataflow)] +fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { + let ret; + // `ret` starts off uninitialized, so we get an error report here. + unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set + + // All function formal parameters start off initialized. + + unsafe { rustc_peek(&x) }; + unsafe { rustc_peek(&y) }; + unsafe { rustc_peek(&z) }; + + ret = if test { + ::std::mem::replace(x, y) + } else { + z = y; + z + }; + + + // `z` may be initialized here. + unsafe { rustc_peek(&z); } + + // `y` is definitely uninitialized here. + unsafe { rustc_peek(&y); } //~ ERROR rustc_peek: bit not set + + // `x` is still (definitely) initialized (replace above is a reborrow). + unsafe { rustc_peek(&x); } + + ::std::mem::drop(x); + + // `x` is *definitely* uninitialized here + unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set + + // `ret` is now definitely initialized (via `if` above). + unsafe { rustc_peek(&ret); } + + ret +} + +fn main() { + foo(true, &mut S(13), S(14), S(15)); + foo(false, &mut S(13), S(14), S(15)); +} diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/inits-1.stderr b/src/test/ui/compile-fail-migration/mir-dataflow/inits-1.stderr new file mode 100644 index 00000000000..c39c9c8efba --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/inits-1.stderr @@ -0,0 +1,22 @@ +error: rustc_peek: bit not set + --> $DIR/inits-1.rs:25:14 + | +LL | unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/inits-1.rs:45:14 + | +LL | unsafe { rustc_peek(&y); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/inits-1.rs:53:14 + | +LL | unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: stop_after_dataflow ended compilation + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.rs b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.rs new file mode 100644 index 00000000000..bb10c03254e --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.rs @@ -0,0 +1,62 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// General test of maybe_uninits state computed by MIR dataflow. + +#![feature(nll)] +#![feature(core_intrinsics, rustc_attrs)] + +use std::intrinsics::rustc_peek; +use std::mem::{drop, replace}; + +struct S(i32); + +#[rustc_mir(rustc_peek_maybe_uninit,stop_after_dataflow)] +fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { + let ret; + // `ret` starts off uninitialized + unsafe { rustc_peek(&ret); } + + // All function formal parameters start off initialized. + + unsafe { rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set + unsafe { rustc_peek(&y) }; //~ ERROR rustc_peek: bit not set + unsafe { rustc_peek(&z) }; //~ ERROR rustc_peek: bit not set + + ret = if test { + ::std::mem::replace(x, y) + } else { + z = y; + z + }; + + // `z` may be uninitialized here. + unsafe { rustc_peek(&z); } + + // `y` is definitely uninitialized here. + unsafe { rustc_peek(&y); } + + // `x` is still (definitely) initialized (replace above is a reborrow). + unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set + + ::std::mem::drop(x); + + // `x` is *definitely* uninitialized here + unsafe { rustc_peek(&x); } + + // `ret` is now definitely initialized (via `if` above). + unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set + + ret +} +fn main() { + foo(true, &mut S(13), S(14), S(15)); + foo(false, &mut S(13), S(14), S(15)); +} diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.stderr b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.stderr new file mode 100644 index 00000000000..c76012404ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-1.stderr @@ -0,0 +1,34 @@ +error: rustc_peek: bit not set + --> $DIR/uninits-1.rs:29:14 + | +LL | unsafe { rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/uninits-1.rs:30:14 + | +LL | unsafe { rustc_peek(&y) }; //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/uninits-1.rs:31:14 + | +LL | unsafe { rustc_peek(&z) }; //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/uninits-1.rs:47:14 + | +LL | unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: rustc_peek: bit not set + --> $DIR/uninits-1.rs:55:14 + | +LL | unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^^^ + +error: stop_after_dataflow ended compilation + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.rs b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.rs new file mode 100644 index 00000000000..9854ea779b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// General test of maybe_uninits state computed by MIR dataflow. + +#![feature(nll)] +#![feature(core_intrinsics, rustc_attrs)] + +use std::intrinsics::rustc_peek; +use std::mem::{drop, replace}; + +struct S(i32); + +#[rustc_mir(rustc_peek_maybe_uninit,stop_after_dataflow)] +fn foo(x: &mut S) { + // `x` is initialized here, so maybe-uninit bit is 0. + + unsafe { rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set + + ::std::mem::drop(x); + + // `x` definitely uninitialized here, so maybe-uninit bit is 1. + unsafe { rustc_peek(&x) }; +} +fn main() { + foo(&mut S(13)); + foo(&mut S(13)); +} diff --git a/src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.stderr b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.stderr new file mode 100644 index 00000000000..8ed735111bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-dataflow/uninits-2.stderr @@ -0,0 +1,10 @@ +error: rustc_peek: bit not set + --> $DIR/uninits-2.rs:25:14 + | +LL | unsafe { rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set + | ^^^^^^^^^^^^^^ + +error: stop_after_dataflow ended compilation + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/mir-unpretty.rs b/src/test/ui/compile-fail-migration/mir-unpretty.rs new file mode 100644 index 00000000000..fa936502157 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-unpretty.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z unpretty=mir + +fn main() { + let x: () = 0; //~ ERROR: mismatched types +} diff --git a/src/test/ui/compile-fail-migration/mir-unpretty.stderr b/src/test/ui/compile-fail-migration/mir-unpretty.stderr new file mode 100644 index 00000000000..5a53b69ebbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/mir-unpretty.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/mir-unpretty.rs:14:17 + | +LL | let x: () = 0; //~ ERROR: mismatched types + | ^ expected (), found integral variable + | + = note: expected type `()` + found type `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/missing-derivable-attr.rs b/src/test/ui/compile-fail-migration/missing-derivable-attr.rs new file mode 100644 index 00000000000..7eee51e4076 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-derivable-attr.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait MyEq { + fn eq(&self, other: &Self) -> bool; +} + +struct A { + x: isize +} + +impl MyEq for isize { + fn eq(&self, other: &isize) -> bool { *self == *other } +} + +impl MyEq for A {} //~ ERROR not all trait items implemented, missing: `eq` + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/missing-derivable-attr.stderr b/src/test/ui/compile-fail-migration/missing-derivable-attr.stderr new file mode 100644 index 00000000000..cccba2f5f3f --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-derivable-attr.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `eq` + --> $DIR/missing-derivable-attr.rs:23:1 + | +LL | fn eq(&self, other: &Self) -> bool; + | ----------------------------------- `eq` from trait +... +LL | impl MyEq for A {} //~ ERROR not all trait items implemented, missing: `eq` + | ^^^^^^^^^^^^^^^ missing `eq` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/compile-fail-migration/missing-macro-use.rs b/src/test/ui/compile-fail-migration/missing-macro-use.rs new file mode 100644 index 00000000000..bfe49ea0009 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-macro-use.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:two_macros.rs + +extern crate two_macros; + +pub fn main() { + macro_two!(); + //~^ ERROR cannot find macro `macro_two!` in this scope +} diff --git a/src/test/ui/compile-fail-migration/missing-macro-use.stderr b/src/test/ui/compile-fail-migration/missing-macro-use.stderr new file mode 100644 index 00000000000..6986b4d5733 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-macro-use.stderr @@ -0,0 +1,8 @@ +error: cannot find macro `macro_two!` in this scope + --> $DIR/missing-macro-use.rs:16:5 + | +LL | macro_two!(); + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/missing-main.rs b/src/test/ui/compile-fail-migration/missing-main.rs new file mode 100644 index 00000000000..2788a5c2d58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-main.rs @@ -0,0 +1,12 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: `main` function not found +fn mian() { } diff --git a/src/test/ui/compile-fail-migration/missing-main.stderr b/src/test/ui/compile-fail-migration/missing-main.stderr new file mode 100644 index 00000000000..34b03ada3d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-main.stderr @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `missing_main` + | + = note: consider adding a `main` function to `$DIR/missing-main.rs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/missing-return.rs b/src/test/ui/compile-fail-migration/missing-return.rs new file mode 100644 index 00000000000..efd0c827a35 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-return.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: return + +fn f() -> isize { } + +fn main() { f(); } diff --git a/src/test/ui/compile-fail-migration/missing-return.stderr b/src/test/ui/compile-fail-migration/missing-return.stderr new file mode 100644 index 00000000000..d12a5832877 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-return.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/missing-return.rs:13:17 + | +LL | fn f() -> isize { } + | ^^^ expected isize, found () + | + = note: expected type `isize` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/missing-semicolon-warning.rs b/src/test/ui/compile-fail-migration/missing-semicolon-warning.rs new file mode 100644 index 00000000000..bbc958b87a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-semicolon-warning.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(unused)] + +macro_rules! m { + ($($e1:expr),*; $($e2:expr),*) => { + $( let x = $e1 )*; //~ WARN expected `;` + $( println!("{}", $e2) )*; //~ WARN expected `;` + } +} + +#[rustc_error] +fn main() { m!(0, 0; 0, 0); } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/missing-semicolon-warning.stderr b/src/test/ui/compile-fail-migration/missing-semicolon-warning.stderr new file mode 100644 index 00000000000..72319a257d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-semicolon-warning.stderr @@ -0,0 +1,30 @@ +warning: expected `;`, found `let` + --> $DIR/missing-semicolon-warning.rs:16:12 + | +LL | $( let x = $e1 )*; //~ WARN expected `;` + | ^^^ +... +LL | fn main() { m!(0, 0; 0, 0); } //~ ERROR compilation successful + | --------------- in this macro invocation + | + = note: This was erroneously allowed and will become a hard error in a future release + +warning: expected `;`, found `println` + --> $DIR/missing-semicolon-warning.rs:17:12 + | +LL | $( println!("{}", $e2) )*; //~ WARN expected `;` + | ^^^^^^^ +... +LL | fn main() { m!(0, 0; 0, 0); } //~ ERROR compilation successful + | --------------- in this macro invocation + | + = note: This was erroneously allowed and will become a hard error in a future release + +error: compilation successful + --> $DIR/missing-semicolon-warning.rs:22:1 + | +LL | fn main() { m!(0, 0; 0, 0); } //~ ERROR compilation successful + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/missing-stability.rs b/src/test/ui/compile-fail-migration/missing-stability.rs new file mode 100644 index 00000000000..1922efb5e19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-stability.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks that exported items without stability attributes cause an error + +#![crate_type="lib"] +#![feature(staged_api)] + +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +pub fn unmarked() { + //~^ ERROR This node does not have a stability attribute + () +} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub mod foo { + // #[unstable] is inherited + pub fn unmarked() {} +} + +#[stable(feature = "stable_test_feature", since="1.0.0")] +pub mod bar { + // #[stable] is not inherited + pub fn unmarked() {} + //~^ ERROR This node does not have a stability attribute +} diff --git a/src/test/ui/compile-fail-migration/missing-stability.stderr b/src/test/ui/compile-fail-migration/missing-stability.stderr new file mode 100644 index 00000000000..6e2802e43c5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing-stability.stderr @@ -0,0 +1,17 @@ +error: This node does not have a stability attribute + --> $DIR/missing-stability.rs:18:1 + | +LL | / pub fn unmarked() { +LL | | //~^ ERROR This node does not have a stability attribute +LL | | () +LL | | } + | |_^ + +error: This node does not have a stability attribute + --> $DIR/missing-stability.rs:32:5 + | +LL | pub fn unmarked() {} + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/missing_debug_impls.rs b/src/test/ui/compile-fail-migration/missing_debug_impls.rs new file mode 100644 index 00000000000..ddc9081e33b --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing_debug_impls.rs @@ -0,0 +1,48 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --crate-type lib +#![deny(missing_debug_implementations)] +#![allow(unused)] + +use std::fmt; + +pub enum A {} //~ ERROR type does not implement `fmt::Debug` + +#[derive(Debug)] +pub enum B {} + +pub enum C {} + +impl fmt::Debug for C { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + Ok(()) + } +} + +pub struct Foo; //~ ERROR type does not implement `fmt::Debug` + +#[derive(Debug)] +pub struct Bar; + +pub struct Baz; + +impl fmt::Debug for Baz { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + Ok(()) + } +} + +struct PrivateStruct; + +enum PrivateEnum {} + +#[derive(Debug)] +struct GenericType(T); diff --git a/src/test/ui/compile-fail-migration/missing_debug_impls.stderr b/src/test/ui/compile-fail-migration/missing_debug_impls.stderr new file mode 100644 index 00000000000..4b4c05f79f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/missing_debug_impls.stderr @@ -0,0 +1,20 @@ +error: type does not implement `fmt::Debug`; consider adding #[derive(Debug)] or a manual implementation + --> $DIR/missing_debug_impls.rs:17:1 + | +LL | pub enum A {} //~ ERROR type does not implement `fmt::Debug` + | ^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/missing_debug_impls.rs:12:9 + | +LL | #![deny(missing_debug_implementations)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type does not implement `fmt::Debug`; consider adding #[derive(Debug)] or a manual implementation + --> $DIR/missing_debug_impls.rs:30:1 + | +LL | pub struct Foo; //~ ERROR type does not implement `fmt::Debug` + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/mod_file_aux.rs b/src/test/ui/compile-fail-migration/mod_file_aux.rs new file mode 100644 index 00000000000..b7470811f60 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mod_file_aux.rs @@ -0,0 +1,13 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test Not a test. Used by other tests + +pub fn foo() -> isize { 10 } diff --git a/src/test/ui/compile-fail-migration/mod_file_correct_spans.rs b/src/test/ui/compile-fail-migration/mod_file_correct_spans.rs new file mode 100644 index 00000000000..52837479869 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mod_file_correct_spans.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Testing that the codemap is maintained correctly when parsing mods from external files + +mod mod_file_aux; + +fn main() { + assert!(mod_file_aux::bar() == 10); + //~^ ERROR cannot find function `bar` in module `mod_file_aux` +} diff --git a/src/test/ui/compile-fail-migration/mod_file_correct_spans.stderr b/src/test/ui/compile-fail-migration/mod_file_correct_spans.stderr new file mode 100644 index 00000000000..6f5e4cc51eb --- /dev/null +++ b/src/test/ui/compile-fail-migration/mod_file_correct_spans.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `bar` in module `mod_file_aux` + --> $DIR/mod_file_correct_spans.rs:16:27 + | +LL | assert!(mod_file_aux::bar() == 10); + | ^^^ not found in `mod_file_aux` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/mod_file_disambig.rs b/src/test/ui/compile-fail-migration/mod_file_disambig.rs new file mode 100644 index 00000000000..27c253234be --- /dev/null +++ b/src/test/ui/compile-fail-migration/mod_file_disambig.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both + +fn main() { + assert_eq!(mod_file_aux::bar(), 10); +} diff --git a/src/test/ui/compile-fail-migration/mod_file_disambig.stderr b/src/test/ui/compile-fail-migration/mod_file_disambig.stderr new file mode 100644 index 00000000000..16a013ebfdb --- /dev/null +++ b/src/test/ui/compile-fail-migration/mod_file_disambig.stderr @@ -0,0 +1,11 @@ +error[E0584]: file for module `mod_file_disambig_aux` found at both mod_file_disambig_aux.rs and mod_file_disambig_aux/mod.rs + --> $DIR/mod_file_disambig.rs:13:5 + | +LL | mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: delete or rename one of them to remove the ambiguity + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0584`. diff --git a/src/test/ui/compile-fail-migration/mod_file_disambig_aux.rs b/src/test/ui/compile-fail-migration/mod_file_disambig_aux.rs new file mode 100644 index 00000000000..f617b293463 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mod_file_disambig_aux.rs @@ -0,0 +1,11 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test not a test. aux file diff --git a/src/test/ui/compile-fail-migration/mod_file_disambig_aux/mod.rs b/src/test/ui/compile-fail-migration/mod_file_disambig_aux/mod.rs new file mode 100644 index 00000000000..f617b293463 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mod_file_disambig_aux/mod.rs @@ -0,0 +1,11 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test not a test. aux file diff --git a/src/test/ui/compile-fail-migration/module-macro_use-arguments.rs b/src/test/ui/compile-fail-migration/module-macro_use-arguments.rs new file mode 100644 index 00000000000..6d3038b4820 --- /dev/null +++ b/src/test/ui/compile-fail-migration/module-macro_use-arguments.rs @@ -0,0 +1,16 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use(foo, bar)] //~ ERROR arguments to macro_use are not allowed here +mod foo { +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/module-macro_use-arguments.stderr b/src/test/ui/compile-fail-migration/module-macro_use-arguments.stderr new file mode 100644 index 00000000000..c61288776dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/module-macro_use-arguments.stderr @@ -0,0 +1,8 @@ +error: arguments to macro_use are not allowed here + --> $DIR/module-macro_use-arguments.rs:11:1 + | +LL | #[macro_use(foo, bar)] //~ ERROR arguments to macro_use are not allowed here + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/move-guard-same-consts.rs b/src/test/ui/compile-fail-migration/move-guard-same-consts.rs new file mode 100644 index 00000000000..05fe48e0199 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-guard-same-consts.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #47295: We used to have a hack of special-casing adjacent amtch +// arms whose patterns were composed solely of constants to not have +// them linked in the cfg. +// +// THis was broken for various reasons. In particular, that hack was +// originally authored under the assunption that other checks +// elsewhere would ensure that the two patterns did not overlap. But +// that assumption did not hold, at least not in the long run (namely, +// overlapping patterns were turned into warnings rather than errors). + +#![feature(box_syntax)] + +fn main() { + let x: Box<_> = box 1; + + let v = (1, 2); + + match v { + (1, 2) if take(x) => (), + (1, 2) if take(x) => (), //~ ERROR use of moved value: `x` + _ => (), + } +} + +fn take(_: T) -> bool { false } diff --git a/src/test/ui/compile-fail-migration/move-guard-same-consts.stderr b/src/test/ui/compile-fail-migration/move-guard-same-consts.stderr new file mode 100644 index 00000000000..71f90ee7e54 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-guard-same-consts.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-same-consts.rs:30:24 + | +LL | (1, 2) if take(x) => (), + | - value moved here +LL | (1, 2) if take(x) => (), //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/move-in-guard-1.rs b/src/test/ui/compile-fail-migration/move-in-guard-1.rs new file mode 100644 index 00000000000..068bfa3cd7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-in-guard-1.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +pub fn main() { + let x: Box<_> = box 1; + + let v = (1, 2); + + match v { + (1, _) if take(x) => (), + (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` + _ => (), + } +} + +fn take(_: T) -> bool { false } diff --git a/src/test/ui/compile-fail-migration/move-in-guard-1.stderr b/src/test/ui/compile-fail-migration/move-in-guard-1.stderr new file mode 100644 index 00000000000..5dd46a61176 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-in-guard-1.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `x` + --> $DIR/move-in-guard-1.rs:20:24 + | +LL | (1, _) if take(x) => (), + | - value moved here +LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/move-in-guard-2.rs b/src/test/ui/compile-fail-migration/move-in-guard-2.rs new file mode 100644 index 00000000000..984963b2f83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-in-guard-2.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +pub fn main() { + let x: Box<_> = box 1; + + let v = (1, 2); + + match v { + (1, _) | + (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` + _ => (), + } +} + +fn take(_: T) -> bool { false } diff --git a/src/test/ui/compile-fail-migration/move-in-guard-2.stderr b/src/test/ui/compile-fail-migration/move-in-guard-2.stderr new file mode 100644 index 00000000000..a12d9e98b1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-in-guard-2.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `x` + --> $DIR/move-in-guard-2.rs:20:24 + | +LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` + | ^ value moved here in previous iteration of loop + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/move-into-dead-array-1.nll.stderr b/src/test/ui/compile-fail-migration/move-into-dead-array-1.nll.stderr new file mode 100644 index 00000000000..42f43d3f661 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-into-dead-array-1.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `a` + --> $DIR/move-into-dead-array-1.rs:24:5 + | +LL | a[i] = d(); //~ ERROR use of possibly uninitialized variable: `a` + | ^^^^ use of possibly uninitialized `a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/move-into-dead-array-1.rs b/src/test/ui/compile-fail-migration/move-into-dead-array-1.rs new file mode 100644 index 00000000000..61ccb694fd2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-into-dead-array-1.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that we cannot move into an uninitialized fixed-size array. + +struct D { _x: u8 } + +fn d() -> D { D { _x: 0 } } + +fn main() { + foo(1); + foo(3); +} + +fn foo(i: usize) { + let mut a: [D; 4]; + a[i] = d(); //~ ERROR use of possibly uninitialized variable: `a` +} diff --git a/src/test/ui/compile-fail-migration/move-into-dead-array-1.stderr b/src/test/ui/compile-fail-migration/move-into-dead-array-1.stderr new file mode 100644 index 00000000000..ac18565f194 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-into-dead-array-1.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `a` + --> $DIR/move-into-dead-array-1.rs:24:5 + | +LL | a[i] = d(); //~ ERROR use of possibly uninitialized variable: `a` + | ^^^^^^^^^^ use of possibly uninitialized `a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/move-into-dead-array-2.nll.stderr b/src/test/ui/compile-fail-migration/move-into-dead-array-2.nll.stderr new file mode 100644 index 00000000000..cc6cc4211c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-into-dead-array-2.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `a` + --> $DIR/move-into-dead-array-2.rs:24:5 + | +LL | drop(a); + | - value moved here +LL | a[i] = d(); //~ ERROR use of moved value: `a` + | ^^^^ value used here after move + | + = note: move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/move-into-dead-array-2.rs b/src/test/ui/compile-fail-migration/move-into-dead-array-2.rs new file mode 100644 index 00000000000..d484837c001 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-into-dead-array-2.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that we cannot move into an uninitialized fixed-size array. + +struct D { _x: u8 } + +fn d() -> D { D { _x: 0 } } + +fn main() { + foo([d(), d(), d(), d()], 1); + foo([d(), d(), d(), d()], 3); +} + +fn foo(mut a: [D; 4], i: usize) { + drop(a); + a[i] = d(); //~ ERROR use of moved value: `a` +} diff --git a/src/test/ui/compile-fail-migration/move-into-dead-array-2.stderr b/src/test/ui/compile-fail-migration/move-into-dead-array-2.stderr new file mode 100644 index 00000000000..0d999e67f98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-into-dead-array-2.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `a` + --> $DIR/move-into-dead-array-2.rs:24:5 + | +LL | drop(a); + | - value moved here +LL | a[i] = d(); //~ ERROR use of moved value: `a` + | ^^^^^^^^^^ value used here after move + | + = note: move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/move-out-of-array-1.rs b/src/test/ui/compile-fail-migration/move-out-of-array-1.rs new file mode 100644 index 00000000000..796b13538b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-array-1.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that we cannot move out of a fixed-size array (especially +// when the element type has a destructor). + + +struct D { _x: u8 } + +impl Drop for D { fn drop(&mut self) { } } + +fn main() { + fn d() -> D { D { _x: 0 } } + + let _d1 = foo([d(), d(), d(), d()], 1); + let _d3 = foo([d(), d(), d(), d()], 3); +} + +fn foo(a: [D; 4], i: usize) -> D { + a[i] //~ ERROR cannot move out of type `[D; 4]`, a non-copy array +} diff --git a/src/test/ui/compile-fail-migration/move-out-of-array-1.stderr b/src/test/ui/compile-fail-migration/move-out-of-array-1.stderr new file mode 100644 index 00000000000..d015505a46b --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-array-1.stderr @@ -0,0 +1,9 @@ +error[E0508]: cannot move out of type `[D; 4]`, a non-copy array + --> $DIR/move-out-of-array-1.rs:27:5 + | +LL | a[i] //~ ERROR cannot move out of type `[D; 4]`, a non-copy array + | ^^^^ cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/compile-fail-migration/move-out-of-slice-1.nll.stderr b/src/test/ui/compile-fail-migration/move-out-of-slice-1.nll.stderr new file mode 100644 index 00000000000..b061b6a7963 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-slice-1.nll.stderr @@ -0,0 +1,14 @@ +error[E0508]: cannot move out of type `[A]`, a non-copy slice + --> $DIR/move-out-of-slice-1.rs:17:11 + | +LL | match a { + | ^ cannot move out of here +LL | box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice + | - + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/compile-fail-migration/move-out-of-slice-1.rs b/src/test/ui/compile-fail-migration/move-out-of-slice-1.rs new file mode 100644 index 00000000000..5efbef549dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-slice-1.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_patterns)] + +struct A; + +fn main() { + let a: Box<[A]> = Box::new([A]); + match a { + box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/move-out-of-slice-1.stderr b/src/test/ui/compile-fail-migration/move-out-of-slice-1.stderr new file mode 100644 index 00000000000..87e68140774 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-slice-1.stderr @@ -0,0 +1,12 @@ +error[E0508]: cannot move out of type `[A]`, a non-copy slice + --> $DIR/move-out-of-slice-1.rs:18:13 + | +LL | box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice + | ^-^ + | || + | |hint: to prevent move, use `ref a` or `ref mut a` + | cannot move out of here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/compile-fail-migration/move-out-of-tuple-field.nll.stderr b/src/test/ui/compile-fail-migration/move-out-of-tuple-field.nll.stderr new file mode 100644 index 00000000000..e18db1b48a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-tuple-field.nll.stderr @@ -0,0 +1,23 @@ +error[E0382]: use of moved value: `x.0` + --> $DIR/move-out-of-tuple-field.rs:18:13 + | +LL | let y = x.0; + | --- value moved here +LL | let z = x.0; //~ ERROR use of moved value: `x.0` + | ^^^ value used here after move + | + = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.0` + --> $DIR/move-out-of-tuple-field.rs:22:13 + | +LL | let y = x.0; + | --- value moved here +LL | let z = x.0; //~ ERROR use of moved value: `x.0` + | ^^^ value used here after move + | + = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/move-out-of-tuple-field.rs b/src/test/ui/compile-fail-migration/move-out-of-tuple-field.rs new file mode 100644 index 00000000000..b7393666719 --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-tuple-field.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct Foo(Box); + +fn main() { + let x: (Box<_>,) = (box 1,); + let y = x.0; + let z = x.0; //~ ERROR use of moved value: `x.0` + + let x = Foo(box 1); + let y = x.0; + let z = x.0; //~ ERROR use of moved value: `x.0` +} diff --git a/src/test/ui/compile-fail-migration/move-out-of-tuple-field.stderr b/src/test/ui/compile-fail-migration/move-out-of-tuple-field.stderr new file mode 100644 index 00000000000..1e8acf5a64b --- /dev/null +++ b/src/test/ui/compile-fail-migration/move-out-of-tuple-field.stderr @@ -0,0 +1,23 @@ +error[E0382]: use of moved value: `x.0` + --> $DIR/move-out-of-tuple-field.rs:18:9 + | +LL | let y = x.0; + | - value moved here +LL | let z = x.0; //~ ERROR use of moved value: `x.0` + | ^ value used here after move + | + = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.0` + --> $DIR/move-out-of-tuple-field.rs:22:9 + | +LL | let y = x.0; + | - value moved here +LL | let z = x.0; //~ ERROR use of moved value: `x.0` + | ^ value used here after move + | + = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.nll.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.nll.stderr new file mode 100644 index 00000000000..39c7f0633e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-access-to-field.rs:21:12 + | +LL | consume(x.into_iter().next().unwrap()); + | - value moved here +LL | touch(&x[0]); //~ ERROR use of moved value: `x` + | ^ value borrowed here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.rs b/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.rs new file mode 100644 index 00000000000..63fb4ff02a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that if you move from `x.f` or `x[0]`, `x` is inaccessible. +// Also tests that we give a more specific error message. + +struct Foo { f: String, y: isize } +fn consume(_s: String) {} +fn touch(_a: &A) {} + +fn f20() { + let x = vec!["hi".to_string()]; + consume(x.into_iter().next().unwrap()); + touch(&x[0]); //~ ERROR use of moved value: `x` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.stderr new file mode 100644 index 00000000000..81546511e03 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-access-to-field.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-access-to-field.rs:21:12 + | +LL | consume(x.into_iter().next().unwrap()); + | - value moved here +LL | touch(&x[0]); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.nll.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.nll.stderr new file mode 100644 index 00000000000..0081fa67b9d --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.nll.stderr @@ -0,0 +1,16 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-capture-clause-bad.rs:18:20 + | +LL | thread::spawn(move|| { + | ------ value moved into closure here +LL | println!("{}", x); + | - variable moved due to use in closure +LL | }); +LL | println!("{}", x); //~ ERROR use of moved value + | ^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.rs b/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.rs new file mode 100644 index 00000000000..32fa773ec80 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::thread; + +fn main() { + let x = "Hello world!".to_string(); + thread::spawn(move|| { + println!("{}", x); + }); + println!("{}", x); //~ ERROR use of moved value +} diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.stderr new file mode 100644 index 00000000000..54b25678819 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-capture-clause-bad.stderr @@ -0,0 +1,14 @@ +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-capture-clause-bad.rs:18:20 + | +LL | thread::spawn(move|| { + | ------ value moved (into closure) here +... +LL | println!("{}", x); //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.nll.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.nll.stderr new file mode 100644 index 00000000000..50b51c6f397 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.nll.stderr @@ -0,0 +1,14 @@ +error[E0382]: use of moved value: `node` + --> $DIR/moves-based-on-type-cyclic-types-issue-4821.rs:23:13 + | +LL | Some(right) => consume(right), + | ----- value moved here +... +LL | consume(node) + r //~ ERROR use of partially moved value: `node` + | ^^^^ value used here after move + | + = note: move occurs because value has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.rs new file mode 100644 index 00000000000..0c4aae8cfad --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for a subtle failure computing kinds of cyclic types, in which +// temporary kinds wound up being stored in a cache and used later. +// See rustc::ty::type_contents() for more information. + + +struct List { key: isize, next: Option> } + +fn foo(node: Box) -> isize { + let r = match node.next { + Some(right) => consume(right), + None => 0 + }; + consume(node) + r //~ ERROR use of partially moved value: `node` +} + +fn consume(v: Box) -> isize { + v.key +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.stderr new file mode 100644 index 00000000000..421d25721e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-cyclic-types-issue-4821.stderr @@ -0,0 +1,14 @@ +error[E0382]: use of partially moved value: `node` + --> $DIR/moves-based-on-type-cyclic-types-issue-4821.rs:23:13 + | +LL | Some(right) => consume(right), + | ----- value moved here +... +LL | consume(node) + r //~ ERROR use of partially moved value: `node` + | ^^^^ value used here after move + | + = note: move occurs because the value has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.nll.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.nll.stderr new file mode 100644 index 00000000000..82420730644 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.nll.stderr @@ -0,0 +1,25 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11 + | +LL | let _y = Foo { f:x }; + | - value moved here +LL | //~^ NOTE value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:30:11 + | +LL | let _y = Foo { f:(((x))) }; + | ------- value moved here +LL | //~^ NOTE value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.rs b/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.rs new file mode 100644 index 00000000000..5329dcaaaf4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.rs @@ -0,0 +1,59 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that references to move-by-default values trigger moves when +// they occur as part of various kinds of expressions. + +struct Foo { f: A } +fn touch(_a: &A) {} + +fn f00() { + let x = "hi".to_string(); + let _y = Foo { f:x }; + //~^ NOTE value moved here + touch(&x); //~ ERROR use of moved value: `x` + //~^ NOTE value used here after move + //~| NOTE move occurs because `x` has type `std::string::String` +} + +fn f05() { + let x = "hi".to_string(); + let _y = Foo { f:(((x))) }; + //~^ NOTE value moved here + touch(&x); //~ ERROR use of moved value: `x` + //~^ NOTE value used here after move + //~| NOTE move occurs because `x` has type `std::string::String` +} + +fn f10() { + let x = "hi".to_string(); + let _y = Foo { f:x.clone() }; + touch(&x); +} + +fn f20() { + let x = "hi".to_string(); + let _y = Foo { f:(x).clone() }; + touch(&x); +} + +fn f30() { + let x = "hi".to_string(); + let _y = Foo { f:((x)).clone() }; + touch(&x); +} + +fn f40() { + let x = "hi".to_string(); + let _y = Foo { f:(((((((x)).clone()))))) }; + touch(&x); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.stderr new file mode 100644 index 00000000000..8c40b4db4f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-distribute-copy-over-paren.stderr @@ -0,0 +1,25 @@ +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:12 + | +LL | let _y = Foo { f:x }; + | - value moved here +LL | //~^ NOTE value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:30:12 + | +LL | let _y = Foo { f:(((x))) }; + | ------- value moved here +LL | //~^ NOTE value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.nll.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.nll.stderr new file mode 100644 index 00000000000..aa248dab85c --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.nll.stderr @@ -0,0 +1,118 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:22:11 + | +LL | let _y = Foo { f:x }; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:28:11 + | +LL | let _y = (x, 3); + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:45:11 + | +LL | x + | - value moved here +... +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:46:11 + | +LL | y + | - value moved here +... +LL | touch(&y); //~ ERROR use of moved value: `y` + | ^^ value borrowed here after move + | + = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:56:11 + | +LL | true => x, + | - value moved here +... +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:57:11 + | +LL | false => y + | - value moved here +... +LL | touch(&y); //~ ERROR use of moved value: `y` + | ^^ value borrowed here after move + | + = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:68:11 + | +LL | _ if guard(x) => 10, + | - value moved here +... +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:75:11 + | +LL | let _y = [x]; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:81:11 + | +LL | let _y = vec![x]; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:87:11 + | +LL | let _y = x.into_iter().next().unwrap(); + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:93:11 + | +LL | let _y = [x.into_iter().next().unwrap(); 1]; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^^ value borrowed here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 11 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.rs b/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.rs new file mode 100644 index 00000000000..194f278259b --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.rs @@ -0,0 +1,103 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that references to move-by-default values trigger moves when +// they occur as part of various kinds of expressions. + + +struct Foo { f: A } +fn guard(_s: String) -> bool {panic!()} +fn touch(_a: &A) {} + +fn f10() { + let x = "hi".to_string(); + let _y = Foo { f:x }; + touch(&x); //~ ERROR use of moved value: `x` +} + +fn f20() { + let x = "hi".to_string(); + let _y = (x, 3); + touch(&x); //~ ERROR use of moved value: `x` +} + +fn f21() { + let x = vec![1, 2, 3]; + let _y = (x[0], 3); + touch(&x); +} + +fn f30(cond: bool) { + let x = "hi".to_string(); + let y = "ho".to_string(); + let _y = if cond { + x + } else { + y + }; + touch(&x); //~ ERROR use of moved value: `x` + touch(&y); //~ ERROR use of moved value: `y` +} + +fn f40(cond: bool) { + let x = "hi".to_string(); + let y = "ho".to_string(); + let _y = match cond { + true => x, + false => y + }; + touch(&x); //~ ERROR use of moved value: `x` + touch(&y); //~ ERROR use of moved value: `y` +} + +fn f50(cond: bool) { + let x = "hi".to_string(); + let y = "ho".to_string(); + let _y = match cond { + _ if guard(x) => 10, + true => 10, + false => 20, + }; + touch(&x); //~ ERROR use of moved value: `x` + touch(&y); +} + +fn f70() { + let x = "hi".to_string(); + let _y = [x]; + touch(&x); //~ ERROR use of moved value: `x` +} + +fn f80() { + let x = "hi".to_string(); + let _y = vec![x]; + touch(&x); //~ ERROR use of moved value: `x` +} + +fn f100() { + let x = vec!["hi".to_string()]; + let _y = x.into_iter().next().unwrap(); + touch(&x); //~ ERROR use of moved value: `x` +} + +fn f110() { + let x = vec!["hi".to_string()]; + let _y = [x.into_iter().next().unwrap(); 1]; + touch(&x); //~ ERROR use of moved value: `x` +} + +fn f120() { + let mut x = vec!["hi".to_string(), "ho".to_string()]; + x.swap(0, 1); + touch(&x[0]); + touch(&x[1]); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.stderr new file mode 100644 index 00000000000..003ae017b58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-exprs.stderr @@ -0,0 +1,118 @@ +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:22:12 + | +LL | let _y = Foo { f:x }; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:28:12 + | +LL | let _y = (x, 3); + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:45:12 + | +LL | x + | - value moved here +... +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:46:12 + | +LL | y + | - value moved here +... +LL | touch(&y); //~ ERROR use of moved value: `y` + | ^ value used here after move + | + = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:56:12 + | +LL | true => x, + | - value moved here +... +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:57:12 + | +LL | false => y + | - value moved here +... +LL | touch(&y); //~ ERROR use of moved value: `y` + | ^ value used here after move + | + = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:68:12 + | +LL | _ if guard(x) => 10, + | - value moved here +... +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:75:12 + | +LL | let _y = [x]; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:81:12 + | +LL | let _y = vec![x]; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:87:12 + | +LL | let _y = x.into_iter().next().unwrap(); + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:93:12 + | +LL | let _y = [x.into_iter().next().unwrap(); 1]; + | - value moved here +LL | touch(&x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 11 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr new file mode 100644 index 00000000000..4f2220b0de3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of captured variable in an `Fn` closure + --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:28 + | +LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out + | ^ cannot move out of captured variable in an `Fn` closure + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.rs new file mode 100644 index 00000000000..4251be36ab4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax, unboxed_closures)] + +use std::usize; + +fn to_fn>(f: F) -> F { f } + +fn test(_x: Box) {} + +fn main() { + let i = box 3; + let _f = to_fn(|| test(i)); //~ ERROR cannot move out +} diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr new file mode 100644 index 00000000000..43de9016a7d --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr @@ -0,0 +1,11 @@ +error[E0507]: cannot move out of captured outer variable in an `Fn` closure + --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:28 + | +LL | let i = box 3; + | - captured outer variable +LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out + | ^ cannot move out of captured outer variable in an `Fn` closure + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.nll.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.nll.stderr new file mode 100644 index 00000000000..e23a6beb87e --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.nll.stderr @@ -0,0 +1,24 @@ +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:30:27 + | +LL | (f.c)(f, true); + | ------^------- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + | borrow later used here + +error[E0382]: borrow of moved value: `f` + --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:42:5 + | +LL | let mut r = R {c: Box::new(f)}; + | - value moved here +LL | f(&mut r, false) //~ ERROR use of moved value + | ^ value borrowed here after move + | + = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +Some errors occurred: E0382, E0499. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.rs new file mode 100644 index 00000000000..d5296065999 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.rs @@ -0,0 +1,45 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests correct kind-checking of the reason stack closures without the :Copy +// bound must be noncopyable. For details see +// http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/ + +struct R<'a> { + // This struct is needed to create the + // otherwise infinite type of a fn that + // accepts itself as argument: + c: Box +} + +fn innocent_looking_victim() { + let mut x = Some("hello".to_string()); + conspirator(|f, writer| { + if writer { + x = None; + } else { + match x { + Some(ref msg) => { + (f.c)(f, true); + //~^ ERROR: cannot borrow `*f` as mutable more than once at a time + println!("{}", msg); + }, + None => panic!("oops"), + } + } + }) +} + +fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { + let mut r = R {c: Box::new(f)}; + f(&mut r, false) //~ ERROR use of moved value +} + +fn main() { innocent_looking_victim() } diff --git a/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.stderr b/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.stderr new file mode 100644 index 00000000000..65cea57f0ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-based-on-type-no-recursive-stack-closure.stderr @@ -0,0 +1,23 @@ +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:30:27 + | +LL | (f.c)(f, true); + | ----- ^ - first borrow ends here + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + +error[E0382]: use of moved value: `f` + --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:42:5 + | +LL | let mut r = R {c: Box::new(f)}; + | - value moved here +LL | f(&mut r, false) //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +Some errors occurred: E0382, E0499. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-sru-moved-field.nll.stderr b/src/test/ui/compile-fail-migration/moves-sru-moved-field.nll.stderr new file mode 100644 index 00000000000..d1a528c50a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-sru-moved-field.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `f.moved` + --> $DIR/moves-sru-moved-field.rs:30:14 + | +LL | let _b = Foo {noncopyable: g, ..f}; + | ------------------------- value moved here +LL | let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ value used here after move + | + = note: move occurs because `f.moved` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/moves-sru-moved-field.rs b/src/test/ui/compile-fail-migration/moves-sru-moved-field.rs new file mode 100644 index 00000000000..15977fbeb73 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-sru-moved-field.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +type Noncopyable = Box; + +struct Foo { + copied: isize, + moved: Box, + noncopyable: Noncopyable +} + +fn test0(f: Foo, g: Noncopyable, h: Noncopyable) { + // just copy implicitly copyable fields from `f`, no moves: + let _b = Foo {moved: box 1, noncopyable: g, ..f}; + let _c = Foo {moved: box 2, noncopyable: h, ..f}; +} + +fn test1(f: Foo, g: Noncopyable, h: Noncopyable) { + // copying move-by-default fields from `f`, so move: + let _b = Foo {noncopyable: g, ..f}; + let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/moves-sru-moved-field.stderr b/src/test/ui/compile-fail-migration/moves-sru-moved-field.stderr new file mode 100644 index 00000000000..878dd7ba830 --- /dev/null +++ b/src/test/ui/compile-fail-migration/moves-sru-moved-field.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `f.moved` + --> $DIR/moves-sru-moved-field.rs:30:37 + | +LL | let _b = Foo {noncopyable: g, ..f}; + | - value moved here +LL | let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved` + | ^ value used here after move + | + = note: move occurs because `f.moved` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/multiple-main-2.rs b/src/test/ui/compile-fail-migration/multiple-main-2.rs new file mode 100644 index 00000000000..d9c232d7dac --- /dev/null +++ b/src/test/ui/compile-fail-migration/multiple-main-2.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(main)] + +#[main] +fn bar() { +} + +#[main] +fn foo() { //~ ERROR multiple functions with a #[main] attribute +} diff --git a/src/test/ui/compile-fail-migration/multiple-main-2.stderr b/src/test/ui/compile-fail-migration/multiple-main-2.stderr new file mode 100644 index 00000000000..e63bbc5cc43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/multiple-main-2.stderr @@ -0,0 +1,14 @@ +error[E0137]: multiple functions with a #[main] attribute + --> $DIR/multiple-main-2.rs:18:1 + | +LL | / fn bar() { +LL | | } + | |_- first #[main] function +... +LL | / fn foo() { //~ ERROR multiple functions with a #[main] attribute +LL | | } + | |_^ additional #[main] function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0137`. diff --git a/src/test/ui/compile-fail-migration/multiple-main-3.rs b/src/test/ui/compile-fail-migration/multiple-main-3.rs new file mode 100644 index 00000000000..866a59e7a4f --- /dev/null +++ b/src/test/ui/compile-fail-migration/multiple-main-3.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(main)] + +#[main] +fn main1() { +} + +mod foo { + #[main] + fn main2() { //~ ERROR multiple functions with a #[main] attribute + } +} diff --git a/src/test/ui/compile-fail-migration/multiple-main-3.stderr b/src/test/ui/compile-fail-migration/multiple-main-3.stderr new file mode 100644 index 00000000000..d489e34b875 --- /dev/null +++ b/src/test/ui/compile-fail-migration/multiple-main-3.stderr @@ -0,0 +1,14 @@ +error[E0137]: multiple functions with a #[main] attribute + --> $DIR/multiple-main-3.rs:19:5 + | +LL | / fn main1() { +LL | | } + | |_- first #[main] function +... +LL | / fn main2() { //~ ERROR multiple functions with a #[main] attribute +LL | | } + | |_____^ additional #[main] function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0137`. diff --git a/src/test/ui/compile-fail-migration/multiple-plugin-registrars.rs b/src/test/ui/compile-fail-migration/multiple-plugin-registrars.rs new file mode 100644 index 00000000000..f5ebf84b8e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/multiple-plugin-registrars.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: multiple plugin registration functions found + +#![feature(plugin_registrar)] + +// the registration function isn't typechecked yet +#[plugin_registrar] +pub fn one() {} + +#[plugin_registrar] +pub fn two() {} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/multiple-plugin-registrars.stderr b/src/test/ui/compile-fail-migration/multiple-plugin-registrars.stderr new file mode 100644 index 00000000000..f1370df0f8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/multiple-plugin-registrars.stderr @@ -0,0 +1,15 @@ +error: multiple plugin registration functions found + | +note: one is here + --> $DIR/multiple-plugin-registrars.rs:17:1 + | +LL | pub fn one() {} + | ^^^^^^^^^^^^^^^ +note: one is here + --> $DIR/multiple-plugin-registrars.rs:20:1 + | +LL | pub fn two() {} + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/mut-cant-alias.rs b/src/test/ui/compile-fail-migration/mut-cant-alias.rs new file mode 100644 index 00000000000..99d7258477a --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-cant-alias.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cell::RefCell; + +fn main() { + let m = RefCell::new(0); + let mut b = m.borrow_mut(); + let b1 = &mut *b; + let b2 = &mut *b; //~ ERROR cannot borrow +} diff --git a/src/test/ui/compile-fail-migration/mut-cant-alias.stderr b/src/test/ui/compile-fail-migration/mut-cant-alias.stderr new file mode 100644 index 00000000000..d8f23e64c31 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-cant-alias.stderr @@ -0,0 +1,13 @@ +error[E0499]: cannot borrow `b` as mutable more than once at a time + --> $DIR/mut-cant-alias.rs:17:20 + | +LL | let b1 = &mut *b; + | - first mutable borrow occurs here +LL | let b2 = &mut *b; //~ ERROR cannot borrow + | ^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/mut-cross-borrowing.rs b/src/test/ui/compile-fail-migration/mut-cross-borrowing.rs new file mode 100644 index 00000000000..73982fa2811 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-cross-borrowing.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn f(_: &mut isize) {} + +fn main() { + let mut x: Box<_> = box 3; + f(x) //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/mut-cross-borrowing.stderr b/src/test/ui/compile-fail-migration/mut-cross-borrowing.stderr new file mode 100644 index 00000000000..be32f235be3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-cross-borrowing.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/mut-cross-borrowing.rs:17:7 + | +LL | f(x) //~ ERROR mismatched types + | ^ + | | + | expected &mut isize, found struct `std::boxed::Box` + | help: consider mutably borrowing here: `&mut x` + | + = note: expected type `&mut isize` + found type `std::boxed::Box<{integer}>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.nll.stderr b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.nll.stderr new file mode 100644 index 00000000000..0df303eed77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.nll.stderr @@ -0,0 +1,26 @@ +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/mut-pattern-internal-mutability.rs:18:5 + | +LL | let &mut x = foo; + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^^ cannot assign twice to immutable variable + +error[E0506]: cannot assign to `*foo` because it is borrowed + --> $DIR/mut-pattern-internal-mutability.rs:27:5 + | +LL | let &mut ref x = foo; + | ----- borrow of `*foo` occurs here +LL | *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `*foo` occurs here +LL | //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed +LL | drop(x); + | - borrow later used here + +error: aborting due to 2 previous errors + +Some errors occurred: E0384, E0506. +For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.stderr b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.stderr new file mode 100644 index 00000000000..47a33e320bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.ast.stderr @@ -0,0 +1,20 @@ +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/mut-pattern-internal-mutability.rs:18:5 + | +LL | let &mut x = foo; + | - first assignment to `x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^^ cannot assign twice to immutable variable + +error[E0506]: cannot assign to `*foo` because it is borrowed + --> $DIR/mut-pattern-internal-mutability.rs:27:5 + | +LL | let &mut ref x = foo; + | ----- borrow of `*foo` occurs here +LL | *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `*foo` occurs here + +error: aborting due to 2 previous errors + +Some errors occurred: E0384, E0506. +For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.mir.stderr b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.mir.stderr new file mode 100644 index 00000000000..0df303eed77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.mir.stderr @@ -0,0 +1,26 @@ +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/mut-pattern-internal-mutability.rs:18:5 + | +LL | let &mut x = foo; + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^^ cannot assign twice to immutable variable + +error[E0506]: cannot assign to `*foo` because it is borrowed + --> $DIR/mut-pattern-internal-mutability.rs:27:5 + | +LL | let &mut ref x = foo; + | ----- borrow of `*foo` occurs here +LL | *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `*foo` occurs here +LL | //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed +LL | drop(x); + | - borrow later used here + +error: aborting due to 2 previous errors + +Some errors occurred: E0384, E0506. +For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.rs b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.rs new file mode 100644 index 00000000000..a05ee64937e --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-pattern-internal-mutability.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn main() { + let foo = &mut 1; + + let &mut x = foo; + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable + //[mir]~^ ERROR cannot assign twice to immutable variable `x` + + // explicitly mut-ify internals + let &mut mut x = foo; + x += 1; + + // check borrowing is detected successfully + let &mut ref x = foo; + *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed + //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed + drop(x); +} diff --git a/src/test/ui/compile-fail-migration/mut-pattern-mismatched.rs b/src/test/ui/compile-fail-migration/mut-pattern-mismatched.rs new file mode 100644 index 00000000000..7685a5c0808 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-pattern-mismatched.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let foo = &mut 1; + + // (separate lines to ensure the spans are accurate) + + let &_ //~ ERROR mismatched types + //~| expected type `&mut {integer}` + //~| found type `&_` + //~| types differ in mutability + = foo; + let &mut _ = foo; + + let bar = &1; + let &_ = bar; + let &mut _ //~ ERROR mismatched types + //~| expected type `&{integer}` + //~| found type `&mut _` + //~| types differ in mutability + = bar; +} diff --git a/src/test/ui/compile-fail-migration/mut-pattern-mismatched.stderr b/src/test/ui/compile-fail-migration/mut-pattern-mismatched.stderr new file mode 100644 index 00000000000..20bd804addc --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-pattern-mismatched.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/mut-pattern-mismatched.rs:16:10 + | +LL | let &_ //~ ERROR mismatched types + | ^^ types differ in mutability + | + = note: expected type `&mut {integer}` + found type `&_` + +error[E0308]: mismatched types + --> $DIR/mut-pattern-mismatched.rs:25:9 + | +LL | let &mut _ //~ ERROR mismatched types + | ^^^^^^ types differ in mutability + | + = note: expected type `&{integer}` + found type `&mut _` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/mut-suggestion.nll.stderr b/src/test/ui/compile-fail-migration/mut-suggestion.nll.stderr new file mode 100644 index 00000000000..39a1e93d619 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-suggestion.nll.stderr @@ -0,0 +1,21 @@ +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable + --> $DIR/mut-suggestion.rs:21:5 + | +LL | fn func(arg: S) { + | --- help: consider changing this to be mutable: `mut arg` +LL | //~^ consider changing this to `mut arg` +LL | arg.mutate(); + | ^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable + --> $DIR/mut-suggestion.rs:29:5 + | +LL | let local = S; + | ----- help: consider changing this to be mutable: `mut local` +LL | //~^ consider changing this to `mut local` +LL | local.mutate(); + | ^^^^^ cannot borrow as mutable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/mut-suggestion.rs b/src/test/ui/compile-fail-migration/mut-suggestion.rs new file mode 100644 index 00000000000..0015c8e5c00 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-suggestion.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Copy, Clone)] +struct S; + +impl S { + fn mutate(&mut self) { + } +} + +fn func(arg: S) { + //~^ consider changing this to `mut arg` + arg.mutate(); + //~^ ERROR cannot borrow immutable argument + //~| cannot borrow mutably +} + +fn main() { + let local = S; + //~^ consider changing this to `mut local` + local.mutate(); + //~^ ERROR cannot borrow immutable local variable + //~| cannot borrow mutably +} diff --git a/src/test/ui/compile-fail-migration/mut-suggestion.stderr b/src/test/ui/compile-fail-migration/mut-suggestion.stderr new file mode 100644 index 00000000000..4aa964903f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mut-suggestion.stderr @@ -0,0 +1,21 @@ +error[E0596]: cannot borrow immutable argument `arg` as mutable + --> $DIR/mut-suggestion.rs:21:5 + | +LL | fn func(arg: S) { + | --- consider changing this to `mut arg` +LL | //~^ consider changing this to `mut arg` +LL | arg.mutate(); + | ^^^ cannot borrow mutably + +error[E0596]: cannot borrow immutable local variable `local` as mutable + --> $DIR/mut-suggestion.rs:29:5 + | +LL | let local = S; + | ----- consider changing this to `mut local` +LL | //~^ consider changing this to `mut local` +LL | local.mutate(); + | ^^^^^ cannot borrow mutably + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/mutable-class-fields-2.nll.stderr b/src/test/ui/compile-fail-migration/mutable-class-fields-2.nll.stderr new file mode 100644 index 00000000000..3433f9f0b21 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-class-fields-2.nll.stderr @@ -0,0 +1,11 @@ +error[E0594]: cannot assign to `self.how_hungry` which is behind a `&` reference + --> $DIR/mutable-class-fields-2.rs:19:5 + | +LL | pub fn eat(&self) { + | ----- help: consider changing this to be a mutable reference: `&mut self` +LL | self.how_hungry -= 5; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/mutable-class-fields-2.rs b/src/test/ui/compile-fail-migration/mutable-class-fields-2.rs new file mode 100644 index 00000000000..46af3a862c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-class-fields-2.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct cat { + meows : usize, + + how_hungry : isize, +} + +impl cat { + pub fn eat(&self) { + self.how_hungry -= 5; //~ ERROR cannot assign + } + +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +fn main() { + let nyan : cat = cat(52, 99); + nyan.eat(); +} diff --git a/src/test/ui/compile-fail-migration/mutable-class-fields-2.stderr b/src/test/ui/compile-fail-migration/mutable-class-fields-2.stderr new file mode 100644 index 00000000000..aa588d8acaf --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-class-fields-2.stderr @@ -0,0 +1,11 @@ +error[E0594]: cannot assign to field `self.how_hungry` of immutable binding + --> $DIR/mutable-class-fields-2.rs:19:5 + | +LL | pub fn eat(&self) { + | ----- use `&mut self` here to make mutable +LL | self.how_hungry -= 5; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/mutable-class-fields.ast.nll.stderr b/src/test/ui/compile-fail-migration/mutable-class-fields.ast.nll.stderr new file mode 100644 index 00000000000..1d1e58de587 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-class-fields.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0384]: cannot assign twice to immutable variable `nyan` + --> $DIR/mutable-class-fields.rs:28:3 + | +LL | let nyan : cat = cat(52, 99); + | ---- + | | + | first assignment to `nyan` + | consider changing this to `mut nyan` +LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign + | ^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/mutable-class-fields.ast.stderr b/src/test/ui/compile-fail-migration/mutable-class-fields.ast.stderr new file mode 100644 index 00000000000..0a4d3a0e968 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-class-fields.ast.stderr @@ -0,0 +1,11 @@ +error[E0594]: cannot assign to field `nyan.how_hungry` of immutable binding + --> $DIR/mutable-class-fields.rs:28:3 + | +LL | let nyan : cat = cat(52, 99); + | ---- consider changing this to `mut nyan` +LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign + | ^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/mutable-class-fields.mir.stderr b/src/test/ui/compile-fail-migration/mutable-class-fields.mir.stderr new file mode 100644 index 00000000000..1d1e58de587 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-class-fields.mir.stderr @@ -0,0 +1,14 @@ +error[E0384]: cannot assign twice to immutable variable `nyan` + --> $DIR/mutable-class-fields.rs:28:3 + | +LL | let nyan : cat = cat(52, 99); + | ---- + | | + | first assignment to `nyan` + | consider changing this to `mut nyan` +LL | nyan.how_hungry = 0; //[ast]~ ERROR cannot assign + | ^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/mutable-class-fields.rs b/src/test/ui/compile-fail-migration/mutable-class-fields.rs new file mode 100644 index 00000000000..f138ae93f71 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-class-fields.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct cat { + meows : usize, + how_hungry : isize, +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +fn main() { + let nyan : cat = cat(52, 99); + nyan.how_hungry = 0; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign +} diff --git a/src/test/ui/compile-fail-migration/mutable-enum-indirect.rs b/src/test/ui/compile-fail-migration/mutable-enum-indirect.rs new file mode 100644 index 00000000000..9107745b0e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-enum-indirect.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that an `&` pointer to something inherently mutable is itself +// to be considered mutable. + +#![feature(optin_builtin_traits)] + +use std::marker::Sync; + +struct NoSync; +impl !Sync for NoSync {} + +enum Foo { A(NoSync) } + +fn bar(_: T) {} + +fn main() { + let x = Foo::A(NoSync); + bar(&x); + //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/mutable-enum-indirect.stderr b/src/test/ui/compile-fail-migration/mutable-enum-indirect.stderr new file mode 100644 index 00000000000..1ad4b6a1517 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutable-enum-indirect.stderr @@ -0,0 +1,18 @@ +error[E0277]: `NoSync` cannot be shared between threads safely + --> $DIR/mutable-enum-indirect.rs:27:5 + | +LL | bar(&x); + | ^^^ `NoSync` cannot be shared between threads safely + | + = help: within `&Foo`, the trait `std::marker::Sync` is not implemented for `NoSync` + = note: required because it appears within the type `Foo` + = note: required because it appears within the type `&Foo` +note: required by `bar` + --> $DIR/mutable-enum-indirect.rs:23:1 + | +LL | fn bar(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/mutexguard-sync.rs b/src/test/ui/compile-fail-migration/mutexguard-sync.rs new file mode 100644 index 00000000000..2d4b50eb7b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutexguard-sync.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// MutexGuard> must not be Sync, that would be unsound. +use std::sync::Mutex; +use std::cell::Cell; + +fn test_sync(_t: T) {} + +fn main() +{ + let m = Mutex::new(Cell::new(0i32)); + let guard = m.lock().unwrap(); + test_sync(guard); + //~^ ERROR `std::cell::Cell` cannot be shared between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/mutexguard-sync.stderr b/src/test/ui/compile-fail-migration/mutexguard-sync.stderr new file mode 100644 index 00000000000..709829e484b --- /dev/null +++ b/src/test/ui/compile-fail-migration/mutexguard-sync.stderr @@ -0,0 +1,17 @@ +error[E0277]: `std::cell::Cell` cannot be shared between threads safely + --> $DIR/mutexguard-sync.rs:21:5 + | +LL | test_sync(guard); + | ^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` + = note: required because of the requirements on the impl of `std::marker::Sync` for `std::sync::MutexGuard<'_, std::cell::Cell>` +note: required by `test_sync` + --> $DIR/mutexguard-sync.rs:15:1 + | +LL | fn test_sync(_t: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/namespace-mix.rs b/src/test/ui/compile-fail-migration/namespace-mix.rs new file mode 100644 index 00000000000..c1c724fc431 --- /dev/null +++ b/src/test/ui/compile-fail-migration/namespace-mix.rs @@ -0,0 +1,165 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:namespace-mix.rs + +extern crate namespace_mix; +use namespace_mix::*; + +mod c { + pub struct S {} + pub struct TS(); + pub struct US; + pub enum E { + V {}, + TV(), + UV, + } + + pub struct Item; +} + +// Use something emitting the type argument name, e.g. unsatisfied bound. +trait Impossible {} +fn check(_: T) {} + +mod m1 { + pub use ::c::*; + pub type S = ::c::Item; +} +mod m2 { + pub use ::c::*; + pub const S: ::c::Item = ::c::Item; +} + +fn f12() { + check(m1::S{}); //~ ERROR c::Item + check(m1::S); //~ ERROR expected value, found type alias `m1::S` + check(m2::S{}); //~ ERROR c::S + check(m2::S); //~ ERROR c::Item +} +fn xf12() { + check(xm1::S{}); //~ ERROR c::Item + check(xm1::S); //~ ERROR expected value, found type alias `xm1::S` + check(xm2::S{}); //~ ERROR c::S + check(xm2::S); //~ ERROR c::Item +} + +mod m3 { + pub use ::c::*; + pub type TS = ::c::Item; +} +mod m4 { + pub use ::c::*; + pub const TS: ::c::Item = ::c::Item; +} + +fn f34() { + check(m3::TS{}); //~ ERROR c::Item + check(m3::TS); //~ ERROR c::TS + check(m4::TS{}); //~ ERROR c::TS + check(m4::TS); //~ ERROR c::Item +} +fn xf34() { + check(xm3::TS{}); //~ ERROR c::Item + check(xm3::TS); //~ ERROR c::TS + check(xm4::TS{}); //~ ERROR c::TS + check(xm4::TS); //~ ERROR c::Item +} + +mod m5 { + pub use ::c::*; + pub type US = ::c::Item; +} +mod m6 { + pub use ::c::*; + pub const US: ::c::Item = ::c::Item; +} + +fn f56() { + check(m5::US{}); //~ ERROR c::Item + check(m5::US); //~ ERROR c::US + check(m6::US{}); //~ ERROR c::US + check(m6::US); //~ ERROR c::Item +} +fn xf56() { + check(xm5::US{}); //~ ERROR c::Item + check(xm5::US); //~ ERROR c::US + check(xm6::US{}); //~ ERROR c::US + check(xm6::US); //~ ERROR c::Item +} + +mod m7 { + pub use ::c::E::*; + pub type V = ::c::Item; +} +mod m8 { + pub use ::c::E::*; + pub const V: ::c::Item = ::c::Item; +} + +fn f78() { + check(m7::V{}); //~ ERROR c::Item + check(m7::V); //~ ERROR expected value, found struct variant `m7::V` + check(m8::V{}); //~ ERROR c::E + check(m8::V); //~ ERROR c::Item +} +fn xf78() { + check(xm7::V{}); //~ ERROR c::Item + check(xm7::V); //~ ERROR expected value, found struct variant `xm7::V` + check(xm8::V{}); //~ ERROR c::E + check(xm8::V); //~ ERROR c::Item +} + +mod m9 { + pub use ::c::E::*; + pub type TV = ::c::Item; +} +mod mA { + pub use ::c::E::*; + pub const TV: ::c::Item = ::c::Item; +} + +fn f9A() { + check(m9::TV{}); //~ ERROR c::Item + check(m9::TV); //~ ERROR c::E + check(mA::TV{}); //~ ERROR c::E + check(mA::TV); //~ ERROR c::Item +} +fn xf9A() { + check(xm9::TV{}); //~ ERROR c::Item + check(xm9::TV); //~ ERROR c::E + check(xmA::TV{}); //~ ERROR c::E + check(xmA::TV); //~ ERROR c::Item +} + +mod mB { + pub use ::c::E::*; + pub type UV = ::c::Item; +} +mod mC { + pub use ::c::E::*; + pub const UV: ::c::Item = ::c::Item; +} + +fn fBC() { + check(mB::UV{}); //~ ERROR c::Item + check(mB::UV); //~ ERROR c::E + check(mC::UV{}); //~ ERROR c::E + check(mC::UV); //~ ERROR c::Item +} +fn xfBC() { + check(xmB::UV{}); //~ ERROR c::Item + check(xmB::UV); //~ ERROR c::E + check(xmC::UV{}); //~ ERROR c::E + check(xmC::UV); //~ ERROR c::Item +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/namespace-mix.stderr b/src/test/ui/compile-fail-migration/namespace-mix.stderr new file mode 100644 index 00000000000..6d72b6044ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/namespace-mix.stderr @@ -0,0 +1,594 @@ +error[E0423]: expected value, found type alias `m1::S` + --> $DIR/namespace-mix.rs:44:11 + | +LL | check(m1::S); //~ ERROR expected value, found type alias `m1::S` + | ^^^^- + | | + | did you mean `TS`? + | + = note: can't use a type alias as a constructor +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use m2::S; + | +LL | use namespace_mix::xm2::S; + | + +error[E0423]: expected value, found type alias `xm1::S` + --> $DIR/namespace-mix.rs:50:11 + | +LL | check(xm1::S); //~ ERROR expected value, found type alias `xm1::S` + | ^^^^^- + | | + | did you mean `TS`? + | + = note: can't use a type alias as a constructor +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use m2::S; + | +LL | use namespace_mix::xm2::S; + | + +error[E0423]: expected value, found struct variant `m7::V` + --> $DIR/namespace-mix.rs:110:11 + | +LL | check(m7::V); //~ ERROR expected value, found struct variant `m7::V` + | ^^^^- + | | | + | | did you mean `TV`? + | did you mean `m7::V { /* fields */ }`? +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use m8::V; + | +LL | use namespace_mix::xm8::V; + | + +error[E0423]: expected value, found struct variant `xm7::V` + --> $DIR/namespace-mix.rs:116:11 + | +LL | check(xm7::V); //~ ERROR expected value, found struct variant `xm7::V` + | ^^^^^- + | | | + | | did you mean `TV`? + | did you mean `xm7::V { /* fields */ }`? +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use m8::V; + | +LL | use namespace_mix::xm8::V; + | + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:43:5 + | +LL | check(m1::S{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::S: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:45:5 + | +LL | check(m2::S{}); //~ ERROR c::S + | ^^^^^ the trait `Impossible` is not implemented for `c::S` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:46:5 + | +LL | check(m2::S); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:49:5 + | +LL | check(xm1::S{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::S: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:51:5 + | +LL | check(xm2::S{}); //~ ERROR c::S + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::S` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:52:5 + | +LL | check(xm2::S); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:65:5 + | +LL | check(m3::TS{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `fn() -> c::TS {c::TS::{{constructor}}}: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:66:5 + | +LL | check(m3::TS); //~ ERROR c::TS + | ^^^^^ the trait `Impossible` is not implemented for `fn() -> c::TS {c::TS::{{constructor}}}` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::TS: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:67:5 + | +LL | check(m4::TS{}); //~ ERROR c::TS + | ^^^^^ the trait `Impossible` is not implemented for `c::TS` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:68:5 + | +LL | check(m4::TS); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:71:5 + | +LL | check(xm3::TS{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `fn() -> namespace_mix::c::TS {namespace_mix::c::TS::{{constructor}}}: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:72:5 + | +LL | check(xm3::TS); //~ ERROR c::TS + | ^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::TS {namespace_mix::c::TS::{{constructor}}}` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::TS: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:73:5 + | +LL | check(xm4::TS{}); //~ ERROR c::TS + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::TS` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:74:5 + | +LL | check(xm4::TS); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:87:5 + | +LL | check(m5::US{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::US: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:88:5 + | +LL | check(m5::US); //~ ERROR c::US + | ^^^^^ the trait `Impossible` is not implemented for `c::US` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::US: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:89:5 + | +LL | check(m6::US{}); //~ ERROR c::US + | ^^^^^ the trait `Impossible` is not implemented for `c::US` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:90:5 + | +LL | check(m6::US); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:93:5 + | +LL | check(xm5::US{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::US: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:94:5 + | +LL | check(xm5::US); //~ ERROR c::US + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::US: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:95:5 + | +LL | check(xm6::US{}); //~ ERROR c::US + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:96:5 + | +LL | check(xm6::US); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:109:5 + | +LL | check(m7::V{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:111:5 + | +LL | check(m8::V{}); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:112:5 + | +LL | check(m8::V); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:115:5 + | +LL | check(xm7::V{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:117:5 + | +LL | check(xm8::V{}); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:118:5 + | +LL | check(xm8::V); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:131:5 + | +LL | check(m9::TV{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `fn() -> c::E {c::E::TV}: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:132:5 + | +LL | check(m9::TV); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `fn() -> c::E {c::E::TV}` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:133:5 + | +LL | check(mA::TV{}); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:134:5 + | +LL | check(mA::TV); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:137:5 + | +LL | check(xm9::TV{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `fn() -> namespace_mix::c::E {namespace_mix::c::E::TV}: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:138:5 + | +LL | check(xm9::TV); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::E {namespace_mix::c::E::TV}` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:139:5 + | +LL | check(xmA::TV{}); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:140:5 + | +LL | check(xmA::TV); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:153:5 + | +LL | check(mB::UV{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:154:5 + | +LL | check(mB::UV); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:155:5 + | +LL | check(mC::UV{}); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:156:5 + | +LL | check(mC::UV); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:159:5 + | +LL | check(xmB::UV{}); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:160:5 + | +LL | check(xmB::UV); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:161:5 + | +LL | check(xmC::UV{}); //~ ERROR c::E + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisfied + --> $DIR/namespace-mix.rs:162:5 + | +LL | check(xmC::UV); //~ ERROR c::Item + | ^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` + | +note: required by `check` + --> $DIR/namespace-mix.rs:31:1 + | +LL | fn check(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 48 previous errors + +Some errors occurred: E0277, E0423. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.rs b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.rs new file mode 100644 index 00000000000..67800f8de4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:namespaced_enums.rs +extern crate namespaced_enums; + +mod m { + pub use namespaced_enums::Foo::*; +} + +pub fn main() { + use namespaced_enums::Foo::*; + + foo(); //~ ERROR cannot find function `foo` in this scope + m::foo(); //~ ERROR cannot find function `foo` in module `m` + bar(); //~ ERROR cannot find function `bar` in this scope + m::bar(); //~ ERROR cannot find function `bar` in module `m` +} diff --git a/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.stderr b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.stderr new file mode 100644 index 00000000000..47ecb1248b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls-xcrate.stderr @@ -0,0 +1,27 @@ +error[E0425]: cannot find function `foo` in this scope + --> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:21:5 + | +LL | foo(); //~ ERROR cannot find function `foo` in this scope + | ^^^ not found in this scope + +error[E0425]: cannot find function `foo` in module `m` + --> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:22:8 + | +LL | m::foo(); //~ ERROR cannot find function `foo` in module `m` + | ^^^ not found in `m` + +error[E0425]: cannot find function `bar` in this scope + --> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:23:5 + | +LL | bar(); //~ ERROR cannot find function `bar` in this scope + | ^^^ not found in this scope + +error[E0425]: cannot find function `bar` in module `m` + --> $DIR/namespaced-enum-glob-import-no-impls-xcrate.rs:24:8 + | +LL | m::bar(); //~ ERROR cannot find function `bar` in module `m` + | ^^^ not found in `m` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.rs b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.rs new file mode 100644 index 00000000000..d5e659c236e --- /dev/null +++ b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m2 { + pub enum Foo { + A, + B(isize), + C { a: isize }, + } + + impl Foo { + pub fn foo() {} + pub fn bar(&self) {} + } +} + +mod m { + pub use m2::Foo::*; +} + +pub fn main() { + use m2::Foo::*; + + foo(); //~ ERROR cannot find function `foo` in this scope + m::foo(); //~ ERROR cannot find function `foo` in module `m` + bar(); //~ ERROR cannot find function `bar` in this scope + m::bar(); //~ ERROR cannot find function `bar` in module `m` +} diff --git a/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.stderr b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.stderr new file mode 100644 index 00000000000..916801df2e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/namespaced-enum-glob-import-no-impls.stderr @@ -0,0 +1,27 @@ +error[E0425]: cannot find function `foo` in this scope + --> $DIR/namespaced-enum-glob-import-no-impls.rs:31:5 + | +LL | foo(); //~ ERROR cannot find function `foo` in this scope + | ^^^ not found in this scope + +error[E0425]: cannot find function `foo` in module `m` + --> $DIR/namespaced-enum-glob-import-no-impls.rs:32:8 + | +LL | m::foo(); //~ ERROR cannot find function `foo` in module `m` + | ^^^ not found in `m` + +error[E0425]: cannot find function `bar` in this scope + --> $DIR/namespaced-enum-glob-import-no-impls.rs:33:5 + | +LL | bar(); //~ ERROR cannot find function `bar` in this scope + | ^^^ not found in this scope + +error[E0425]: cannot find function `bar` in module `m` + --> $DIR/namespaced-enum-glob-import-no-impls.rs:34:8 + | +LL | m::bar(); //~ ERROR cannot find function `bar` in module `m` + | ^^^ not found in `m` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/nested-cfg-attrs.rs b/src/test/ui/compile-fail-migration/nested-cfg-attrs.rs new file mode 100644 index 00000000000..f0c41ff7854 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nested-cfg-attrs.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg_attr(all(), cfg_attr(all(), cfg(foo)))] +fn f() {} + +fn main() { f() } //~ ERROR cannot find function `f` in this scope diff --git a/src/test/ui/compile-fail-migration/nested-cfg-attrs.stderr b/src/test/ui/compile-fail-migration/nested-cfg-attrs.stderr new file mode 100644 index 00000000000..5501dc8c6ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/nested-cfg-attrs.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `f` in this scope + --> $DIR/nested-cfg-attrs.rs:14:13 + | +LL | fn main() { f() } //~ ERROR cannot find function `f` in this scope + | ^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/nested-ty-params.rs b/src/test/ui/compile-fail-migration/nested-ty-params.rs new file mode 100644 index 00000000000..aac37289bb7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nested-ty-params.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:can't use type parameters from outer function +fn hd(v: Vec ) -> U { + fn hd1(w: [U]) -> U { return w[0]; } + + return hd1(v); +} diff --git a/src/test/ui/compile-fail-migration/nested-ty-params.stderr b/src/test/ui/compile-fail-migration/nested-ty-params.stderr new file mode 100644 index 00000000000..93b934f610f --- /dev/null +++ b/src/test/ui/compile-fail-migration/nested-ty-params.stderr @@ -0,0 +1,28 @@ +error[E0401]: can't use type parameters from outer function + --> $DIR/nested-ty-params.rs:13:16 + | +LL | fn hd(v: Vec ) -> U { + | - type variable from outer function +LL | fn hd1(w: [U]) -> U { return w[0]; } + | --- ^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `hd1` + +error[E0401]: can't use type parameters from outer function + --> $DIR/nested-ty-params.rs:13:23 + | +LL | fn hd(v: Vec ) -> U { + | - type variable from outer function +LL | fn hd1(w: [U]) -> U { return w[0]; } + | --- ^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `hd1` + +error[E0601]: `main` function not found in crate `nested_ty_params` + | + = note: consider adding a `main` function to `$DIR/nested-ty-params.rs` + +error: aborting due to 3 previous errors + +Some errors occurred: E0401, E0601. +For more information about an error, try `rustc --explain E0401`. diff --git a/src/test/ui/compile-fail-migration/never-assign-dead-code.rs b/src/test/ui/compile-fail-migration/never-assign-dead-code.rs new file mode 100644 index 00000000000..0fb75b535c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/never-assign-dead-code.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an assignment of type ! makes the rest of the block dead code. + +#![feature(never_type)] +#![feature(rustc_attrs)] +#![warn(unused)] + +#[rustc_error] +fn main() { //~ ERROR: compilation successful + let x: ! = panic!("aah"); //~ WARN unused + drop(x); //~ WARN unreachable + //~^ WARN unreachable +} diff --git a/src/test/ui/compile-fail-migration/never-assign-dead-code.stderr b/src/test/ui/compile-fail-migration/never-assign-dead-code.stderr new file mode 100644 index 00000000000..7c7126c93c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/never-assign-dead-code.stderr @@ -0,0 +1,44 @@ +warning: unreachable statement + --> $DIR/never-assign-dead-code.rs:20:5 + | +LL | drop(x); //~ WARN unreachable + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/never-assign-dead-code.rs:15:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: #[warn(unreachable_code)] implied by #[warn(unused)] + +warning: unreachable expression + --> $DIR/never-assign-dead-code.rs:20:5 + | +LL | drop(x); //~ WARN unreachable + | ^^^^^^^ + +warning: unused variable: `x` + --> $DIR/never-assign-dead-code.rs:19:9 + | +LL | let x: ! = panic!("aah"); //~ WARN unused + | ^ help: consider using `_x` instead + | +note: lint level defined here + --> $DIR/never-assign-dead-code.rs:15:9 + | +LL | #![warn(unused)] + | ^^^^^^ + = note: #[warn(unused_variables)] implied by #[warn(unused)] + +error: compilation successful + --> $DIR/never-assign-dead-code.rs:18:1 + | +LL | / fn main() { //~ ERROR: compilation successful +LL | | let x: ! = panic!("aah"); //~ WARN unused +LL | | drop(x); //~ WARN unreachable +LL | | //~^ WARN unreachable +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/never-assign-wrong-type.rs b/src/test/ui/compile-fail-migration/never-assign-wrong-type.rs new file mode 100644 index 00000000000..c0dd2cab749 --- /dev/null +++ b/src/test/ui/compile-fail-migration/never-assign-wrong-type.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can't use another type in place of ! + +#![feature(never_type)] +#![deny(warnings)] + +fn main() { + let x: ! = "hello"; //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/never-assign-wrong-type.stderr b/src/test/ui/compile-fail-migration/never-assign-wrong-type.stderr new file mode 100644 index 00000000000..41afe88b384 --- /dev/null +++ b/src/test/ui/compile-fail-migration/never-assign-wrong-type.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/never-assign-wrong-type.rs:17:16 + | +LL | let x: ! = "hello"; //~ ERROR mismatched types + | ^^^^^^^ expected !, found reference + | + = note: expected type `!` + found type `&'static str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/never_transmute_never.rs b/src/test/ui/compile-fail-migration/never_transmute_never.rs new file mode 100644 index 00000000000..cbcc47f60c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/never_transmute_never.rs @@ -0,0 +1,33 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![crate_type="lib"] + +#![feature(never_type)] +#![allow(dead_code)] +#![allow(unreachable_code)] +#![allow(unused_variables)] + +struct Foo; + +pub fn f(x: !) -> ! { + x +} + +pub fn ub() { + // This is completely undefined behaviour, + // but we still want to make sure it compiles. + let x: ! = unsafe { + std::mem::transmute::(Foo) + }; + f(x) +} diff --git a/src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.rs b/src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.rs new file mode 100644 index 00000000000..7b1dd9265af --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #47053 + +#![feature(nll)] +#![feature(thread_local)] + +#[thread_local] +static FOO: isize = 5; + +fn main() { + FOO = 6; //~ ERROR cannot assign to immutable static item `FOO` [E0594] +} diff --git a/src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.stderr b/src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.stderr new file mode 100644 index 00000000000..3aa95fcad01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/constant-thread-locals-issue-47053.stderr @@ -0,0 +1,9 @@ +error[E0594]: cannot assign to immutable static item `FOO` + --> $DIR/constant-thread-locals-issue-47053.rs:20:5 + | +LL | FOO = 6; //~ ERROR cannot assign to immutable static item `FOO` [E0594] + | ^^^^^^^ cannot assign + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.rs b/src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.rs new file mode 100644 index 00000000000..2a4295fd90a --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the 'static bound from the Copy impl is respected. Regression test for #29149. + +#![feature(nll)] + +#[derive(Clone)] struct Foo<'a>(&'a u32); +impl Copy for Foo<'static> {} + +fn main() { + let s = 2; + let a = Foo(&s); //~ ERROR `s` does not live long enough [E0597] + drop(a); + drop(a); +} diff --git a/src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.stderr b/src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.stderr new file mode 100644 index 00000000000..edf32d3d223 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/do-not-ignore-lifetime-bounds-in-copy.stderr @@ -0,0 +1,14 @@ +error[E0597]: `s` does not live long enough + --> $DIR/do-not-ignore-lifetime-bounds-in-copy.rs:20:17 + | +LL | let a = Foo(&s); //~ ERROR `s` does not live long enough [E0597] + | ^^ borrowed value does not live long enough +... +LL | } + | - `s` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.rs b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.rs new file mode 100644 index 00000000000..97126e98cbf --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.rs @@ -0,0 +1,50 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// compile-flags:-Zborrowck=compare + +#![allow(warnings)] +#![feature(rustc_attrs)] + + +fn main() { +} + +fn nll_fail() { + let mut data = ('a', 'b', 'c'); + let c = &mut data.0; + capitalize(c); + data.0 = 'e'; + //~^ ERROR (Ast) [E0506] + //~| ERROR (Mir) [E0506] + data.0 = 'f'; + //~^ ERROR (Ast) [E0506] + //~| ERROR (Mir) [E0506] + data.0 = 'g'; + //~^ ERROR (Ast) [E0506] + //~| ERROR (Mir) [E0506] + capitalize(c); +} + +fn nll_ok() { + let mut data = ('a', 'b', 'c'); + let c = &mut data.0; + capitalize(c); + data.0 = 'e'; + //~^ ERROR (Ast) [E0506] + data.0 = 'f'; + //~^ ERROR (Ast) [E0506] + data.0 = 'g'; + //~^ ERROR (Ast) [E0506] +} + +fn capitalize(_: &mut char) { +} diff --git a/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.stderr b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.stderr new file mode 100644 index 00000000000..9afae71edbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_pair.stderr @@ -0,0 +1,93 @@ +error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) + --> $DIR/loan_ends_mid_block_pair.rs:25:5 + | +LL | let c = &mut data.0; + | ------ borrow of `data.0` occurs here +LL | capitalize(c); +LL | data.0 = 'e'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) + --> $DIR/loan_ends_mid_block_pair.rs:28:5 + | +LL | let c = &mut data.0; + | ------ borrow of `data.0` occurs here +... +LL | data.0 = 'f'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) + --> $DIR/loan_ends_mid_block_pair.rs:31:5 + | +LL | let c = &mut data.0; + | ------ borrow of `data.0` occurs here +... +LL | data.0 = 'g'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) + --> $DIR/loan_ends_mid_block_pair.rs:41:5 + | +LL | let c = &mut data.0; + | ------ borrow of `data.0` occurs here +LL | capitalize(c); +LL | data.0 = 'e'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) + --> $DIR/loan_ends_mid_block_pair.rs:43:5 + | +LL | let c = &mut data.0; + | ------ borrow of `data.0` occurs here +... +LL | data.0 = 'f'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Ast) + --> $DIR/loan_ends_mid_block_pair.rs:45:5 + | +LL | let c = &mut data.0; + | ------ borrow of `data.0` occurs here +... +LL | data.0 = 'g'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Mir) + --> $DIR/loan_ends_mid_block_pair.rs:25:5 + | +LL | let c = &mut data.0; + | ----------- borrow of `data.0` occurs here +LL | capitalize(c); +LL | data.0 = 'e'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here +... +LL | capitalize(c); + | - borrow later used here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Mir) + --> $DIR/loan_ends_mid_block_pair.rs:28:5 + | +LL | let c = &mut data.0; + | ----------- borrow of `data.0` occurs here +... +LL | data.0 = 'f'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here +... +LL | capitalize(c); + | - borrow later used here + +error[E0506]: cannot assign to `data.0` because it is borrowed (Mir) + --> $DIR/loan_ends_mid_block_pair.rs:31:5 + | +LL | let c = &mut data.0; + | ----------- borrow of `data.0` occurs here +... +LL | data.0 = 'g'; + | ^^^^^^^^^^^^ assignment to borrowed `data.0` occurs here +... +LL | capitalize(c); + | - borrow later used here + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.rs b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.rs new file mode 100644 index 00000000000..b5357d0ee82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.rs @@ -0,0 +1,49 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// compile-flags:-Zborrowck=compare + +#![allow(warnings)] +#![feature(rustc_attrs)] + +fn main() { +} + +fn nll_fail() { + let mut data = vec!['a', 'b', 'c']; + let slice = &mut data; + capitalize(slice); + data.push('d'); + //~^ ERROR (Ast) [E0499] + //~| ERROR (Mir) [E0499] + data.push('e'); + //~^ ERROR (Ast) [E0499] + //~| ERROR (Mir) [E0499] + data.push('f'); + //~^ ERROR (Ast) [E0499] + //~| ERROR (Mir) [E0499] + capitalize(slice); +} + +fn nll_ok() { + let mut data = vec!['a', 'b', 'c']; + let slice = &mut data; + capitalize(slice); + data.push('d'); + //~^ ERROR (Ast) [E0499] + data.push('e'); + //~^ ERROR (Ast) [E0499] + data.push('f'); + //~^ ERROR (Ast) [E0499] +} + +fn capitalize(_: &mut [char]) { +} diff --git a/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.stderr b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.stderr new file mode 100644 index 00000000000..4c739cfe978 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/loan_ends_mid_block_vec.stderr @@ -0,0 +1,111 @@ +error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) + --> $DIR/loan_ends_mid_block_vec.rs:24:5 + | +LL | let slice = &mut data; + | ---- first mutable borrow occurs here +LL | capitalize(slice); +LL | data.push('d'); + | ^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) + --> $DIR/loan_ends_mid_block_vec.rs:27:5 + | +LL | let slice = &mut data; + | ---- first mutable borrow occurs here +... +LL | data.push('e'); + | ^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) + --> $DIR/loan_ends_mid_block_vec.rs:30:5 + | +LL | let slice = &mut data; + | ---- first mutable borrow occurs here +... +LL | data.push('f'); + | ^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) + --> $DIR/loan_ends_mid_block_vec.rs:40:5 + | +LL | let slice = &mut data; + | ---- first mutable borrow occurs here +LL | capitalize(slice); +LL | data.push('d'); + | ^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) + --> $DIR/loan_ends_mid_block_vec.rs:42:5 + | +LL | let slice = &mut data; + | ---- first mutable borrow occurs here +... +LL | data.push('e'); + | ^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Ast) + --> $DIR/loan_ends_mid_block_vec.rs:44:5 + | +LL | let slice = &mut data; + | ---- first mutable borrow occurs here +... +LL | data.push('f'); + | ^^^^ second mutable borrow occurs here +LL | //~^ ERROR (Ast) [E0499] +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) + --> $DIR/loan_ends_mid_block_vec.rs:24:5 + | +LL | let slice = &mut data; + | --------- first mutable borrow occurs here +LL | capitalize(slice); +LL | data.push('d'); + | ^^^^ second mutable borrow occurs here +... +LL | capitalize(slice); + | ----- borrow later used here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) + --> $DIR/loan_ends_mid_block_vec.rs:27:5 + | +LL | let slice = &mut data; + | --------- first mutable borrow occurs here +... +LL | data.push('e'); + | ^^^^ second mutable borrow occurs here +... +LL | capitalize(slice); + | ----- borrow later used here + +error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) + --> $DIR/loan_ends_mid_block_vec.rs:30:5 + | +LL | let slice = &mut data; + | --------- first mutable borrow occurs here +... +LL | data.push('f'); + | ^^^^ second mutable borrow occurs here +... +LL | capitalize(slice); + | ----- borrow later used here + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.nll.stderr b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.nll.stderr new file mode 100644 index 00000000000..54b1fcbd5bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.nll.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/match-guards-always-borrow.rs:23:13 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.stderr b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.stderr new file mode 100644 index 00000000000..d6186d7561a --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.ast.stderr @@ -0,0 +1,12 @@ +error: compilation successful + --> $DIR/match-guards-always-borrow.rs:57:1 + | +LL | / fn main() { //[ast]~ ERROR compilation successful +LL | | should_reject_destructive_mutate_in_guard(); +LL | | allow_mutate_in_arm_body(); +LL | | allow_move_into_arm_body(); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.mir.stderr b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.mir.stderr new file mode 100644 index 00000000000..54b1fcbd5bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.mir.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/match-guards-always-borrow.rs:23:13 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.rs b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.rs new file mode 100644 index 00000000000..98553144627 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/match-guards-always-borrow.rs @@ -0,0 +1,61 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//revisions: ast mir +//[mir] compile-flags: -Z borrowck=mir + +#![feature(rustc_attrs)] + +// Here is arielb1's basic example from rust-lang/rust#27282 +// that AST borrowck is flummoxed by: + +fn should_reject_destructive_mutate_in_guard() { + match Some(&4) { + None => {}, + ref mut foo if { + (|| { let bar = foo; bar.take() })(); + //[mir]~^ ERROR cannot move out of borrowed content [E0507] + false } => { }, + Some(s) => std::process::exit(*s), + } +} + +// Here below is a case that needs to keep working: we only use the +// binding via immutable-borrow in the guard, and we mutate in the arm +// body. +fn allow_mutate_in_arm_body() { + match Some(&4) { + None => {}, + ref mut foo if foo.is_some() && false => { foo.take(); () } + Some(s) => std::process::exit(*s), + } +} + +// Here below is a case that needs to keep working: we only use the +// binding via immutable-borrow in the guard, and we move into the arm +// body. +fn allow_move_into_arm_body() { + match Some(&4) { + None => {}, + mut foo if foo.is_some() && false => { foo.take(); () } + Some(s) => std::process::exit(*s), + } +} + +// Since this is a compile-fail test that is explicitly encoding the +// different behavior of AST- vs MIR-borrowck where AST-borrowck does +// not error, we need to use rustc_error to placate the test harness +// that wants *some* error to occur. +#[rustc_error] +fn main() { //[ast]~ ERROR compilation successful + should_reject_destructive_mutate_in_guard(); + allow_mutate_in_arm_body(); + allow_move_into_arm_body(); +} diff --git a/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.nll.stderr b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.nll.stderr new file mode 100644 index 00000000000..caa3173d746 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/reference-carried-through-struct-field.rs:21:5 + | +LL | let wrapper = Wrap { w: &mut x }; + | ------ borrow of `x` occurs here +LL | x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] + | ^^^^^^ use of borrowed `x` +LL | //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] +LL | *wrapper.w += 1; + | --------------- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.stderr b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.stderr new file mode 100644 index 00000000000..c1022d66070 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.ast.stderr @@ -0,0 +1,11 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/reference-carried-through-struct-field.rs:21:5 + | +LL | let wrapper = Wrap { w: &mut x }; + | - borrow of `x` occurs here +LL | x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] + | ^^^^^^ assignment to borrowed `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.mir.stderr b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.mir.stderr new file mode 100644 index 00000000000..caa3173d746 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.mir.stderr @@ -0,0 +1,14 @@ +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/reference-carried-through-struct-field.rs:21:5 + | +LL | let wrapper = Wrap { w: &mut x }; + | ------ borrow of `x` occurs here +LL | x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] + | ^^^^^^ use of borrowed `x` +LL | //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] +LL | *wrapper.w += 1; + | --------------- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.rs b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.rs new file mode 100644 index 00000000000..589a3daa38d --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/reference-carried-through-struct-field.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//revisions: ast mir +//[mir] compile-flags: -Z borrowck=mir + +#![allow(unused_assignments)] + +struct Wrap<'a> { w: &'a mut u32 } + +fn foo() { + let mut x = 22; + let wrapper = Wrap { w: &mut x }; + x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] + //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] + *wrapper.w += 1; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.nll.stderr b/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.nll.stderr new file mode 100644 index 00000000000..fa3a5e0c0d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.nll.stderr @@ -0,0 +1,39 @@ +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) + --> $DIR/region-ends-after-if-condition.rs:29:9 + | +LL | let value = &my_struct.field; + | --------------- immutable borrow occurs here +LL | if value.is_empty() { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) + --> $DIR/region-ends-after-if-condition.rs:39:9 + | +LL | let value = &my_struct.field; + | --------------- immutable borrow occurs here +LL | if value.is_empty() { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Mir) + --> $DIR/region-ends-after-if-condition.rs:39:9 + | +LL | let value = &my_struct.field; + | ---------------- immutable borrow occurs here +LL | if value.is_empty() { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here +... +LL | drop(value); + | ----- borrow later used here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.rs b/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.rs new file mode 100644 index 00000000000..e1c47a6bbff --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.rs @@ -0,0 +1,46 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Basic test for liveness constraints: the region (`R1`) that appears +// in the type of `p` includes the points after `&v[0]` up to (but not +// including) the call to `use_x`. The `else` branch is not included. + +// compile-flags:-Zborrowck=compare + +#![allow(warnings)] +#![feature(rustc_attrs)] + +struct MyStruct { + field: String +} + +fn foo1() { + let mut my_struct = MyStruct { field: format!("Hello") }; + + let value = &my_struct.field; + if value.is_empty() { + my_struct.field.push_str("Hello, world!"); + //~^ ERROR (Ast) [E0502] + } +} + +fn foo2() { + let mut my_struct = MyStruct { field: format!("Hello") }; + + let value = &my_struct.field; + if value.is_empty() { + my_struct.field.push_str("Hello, world!"); + //~^ ERROR (Ast) [E0502] + //~| ERROR (Mir) [E0502] + } + drop(value); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.stderr b/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.stderr new file mode 100644 index 00000000000..d966c62c85f --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/region-ends-after-if-condition.stderr @@ -0,0 +1,39 @@ +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) + --> $DIR/region-ends-after-if-condition.rs:29:9 + | +LL | let value = &my_struct.field; + | --------------- immutable borrow occurs here +LL | if value.is_empty() { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Ast) + --> $DIR/region-ends-after-if-condition.rs:39:9 + | +LL | let value = &my_struct.field; + | --------------- immutable borrow occurs here +LL | if value.is_empty() { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `my_struct.field` as mutable because it is also borrowed as immutable (Mir) + --> $DIR/region-ends-after-if-condition.rs:39:9 + | +LL | let value = &my_struct.field; + | ---------------- immutable borrow occurs here +LL | if value.is_empty() { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ mutable borrow occurs here +... +LL | drop(value); + | ----- borrow later used here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/nll/return_from_loop.rs b/src/test/ui/compile-fail-migration/nll/return_from_loop.rs new file mode 100644 index 00000000000..13f1ca6431b --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/return_from_loop.rs @@ -0,0 +1,49 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Basic test for liveness constraints: the region (`R1`) that appears +// in the type of `p` includes the points after `&v[0]` up to (but not +// including) the call to `use_x`. The `else` branch is not included. + +// compile-flags:-Zborrowck=compare + +#![allow(warnings)] +#![feature(rustc_attrs)] + +struct MyStruct { + field: String +} + +fn main() { +} + +fn nll_fail() { + let mut my_struct = MyStruct { field: format!("Hello") }; + + let value = &mut my_struct.field; + loop { + my_struct.field.push_str("Hello, world!"); + //~^ ERROR (Ast) [E0499] + //~| ERROR (Mir) [E0499] + value.len(); + return; + } +} + +fn nll_ok() { + let mut my_struct = MyStruct { field: format!("Hello") }; + + let value = &mut my_struct.field; + loop { + my_struct.field.push_str("Hello, world!"); + //~^ ERROR (Ast) [E0499] + return; + } +} diff --git a/src/test/ui/compile-fail-migration/nll/return_from_loop.stderr b/src/test/ui/compile-fail-migration/nll/return_from_loop.stderr new file mode 100644 index 00000000000..7130aa64dab --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/return_from_loop.stderr @@ -0,0 +1,39 @@ +error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Ast) + --> $DIR/return_from_loop.rs:32:9 + | +LL | let value = &mut my_struct.field; + | --------------- first mutable borrow occurs here +LL | loop { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Ast) + --> $DIR/return_from_loop.rs:45:9 + | +LL | let value = &mut my_struct.field; + | --------------- first mutable borrow occurs here +LL | loop { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `my_struct.field` as mutable more than once at a time (Mir) + --> $DIR/return_from_loop.rs:32:9 + | +LL | let value = &mut my_struct.field; + | -------------------- first mutable borrow occurs here +LL | loop { +LL | my_struct.field.push_str("Hello, world!"); + | ^^^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | value.len(); + | ----- borrow later used here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.rs b/src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.rs new file mode 100644 index 00000000000..e9110b8114b --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] +#![deny(unused_mut)] + +fn main() { + vec![(42, 22)].iter().map(|(mut x, _y)| ()).count(); + //~^ ERROR: variable does not need to be mutable +} diff --git a/src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.stderr b/src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.stderr new file mode 100644 index 00000000000..bfc67e213ec --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/unused-mut-issue-50343.stderr @@ -0,0 +1,16 @@ +error: variable does not need to be mutable + --> $DIR/unused-mut-issue-50343.rs:15:33 + | +LL | vec![(42, 22)].iter().map(|(mut x, _y)| ()).count(); + | ----^ + | | + | help: remove this `mut` + | +note: lint level defined here + --> $DIR/unused-mut-issue-50343.rs:12:9 + | +LL | #![deny(unused_mut)] + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.rs b/src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.rs new file mode 100644 index 00000000000..0efdd19df3c --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Zborrowck=mir + +#![allow(dead_code)] + +fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) +where + 'a: 'b, +{ + (x, y) +} + +fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + foo(x, y) + //~^ ERROR unsatisfied lifetime constraints + //~| WARNING not reporting region error due to nll +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.stderr b/src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.stderr new file mode 100644 index 00000000000..3d5dd4beb04 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/where_clauses_in_functions.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/where_clauses_in_functions.rs:23:5 + | +LL | foo(x, y) + | ^^^ + +error: unsatisfied lifetime constraints + --> $DIR/where_clauses_in_functions.rs:23:5 + | +LL | fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | foo(x, y) + | ^^^^^^^^^ argument requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.rs b/src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.rs new file mode 100644 index 00000000000..92e7db86173 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z borrowck=mir + +#![allow(dead_code)] + +use std::cell::Cell; + +struct Foo<'a: 'b, 'b> { + x: Cell<&'a u32>, + y: Cell<&'b u32>, +} + +fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) { + Foo { x, y }; + //~^ ERROR unsatisfied lifetime constraints + //~| WARNING not reporting region error due to nll +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.stderr b/src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.stderr new file mode 100644 index 00000000000..c7ad9879b29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nll/where_clauses_in_structs.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/where_clauses_in_structs.rs:23:5 + | +LL | Foo { x, y }; + | ^^^ + +error: unsatisfied lifetime constraints + --> $DIR/where_clauses_in_structs.rs:23:11 + | +LL | fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | Foo { x, y }; + | ^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/no-capture-arc.nll.stderr b/src/test/ui/compile-fail-migration/no-capture-arc.nll.stderr new file mode 100644 index 00000000000..a58d5ad6fa7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-capture-arc.nll.stderr @@ -0,0 +1,29 @@ +error[E0382]: borrow of moved value: `arc_v` + --> $DIR/no-capture-arc.rs:24:18 + | +LL | thread::spawn(move|| { + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure +... +LL | assert_eq!((*arc_v)[2], 3); + | ^^^^^ value borrowed here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `arc_v` + --> $DIR/no-capture-arc.rs:26:23 + | +LL | thread::spawn(move|| { + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure +... +LL | println!("{:?}", *arc_v); + | ^^^^^ value borrowed here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/no-capture-arc.rs b/src/test/ui/compile-fail-migration/no-capture-arc.rs new file mode 100644 index 00000000000..5e1d22bf63b --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-capture-arc.rs @@ -0,0 +1,27 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: use of moved value + +use std::sync::Arc; +use std::thread; + +fn main() { + let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let arc_v = Arc::new(v); + + thread::spawn(move|| { + assert_eq!((*arc_v)[3], 4); + }); + + assert_eq!((*arc_v)[2], 3); + + println!("{:?}", *arc_v); +} diff --git a/src/test/ui/compile-fail-migration/no-capture-arc.stderr b/src/test/ui/compile-fail-migration/no-capture-arc.stderr new file mode 100644 index 00000000000..d6801d7e6e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-capture-arc.stderr @@ -0,0 +1,25 @@ +error[E0382]: use of moved value: `arc_v` + --> $DIR/no-capture-arc.rs:24:18 + | +LL | thread::spawn(move|| { + | ------ value moved (into closure) here +... +LL | assert_eq!((*arc_v)[2], 3); + | ^^^^^ value used here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `arc_v` + --> $DIR/no-capture-arc.rs:26:23 + | +LL | thread::spawn(move|| { + | ------ value moved (into closure) here +... +LL | println!("{:?}", *arc_v); + | ^^^^^ value used here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/no-implicit-prelude-nested.rs b/src/test/ui/compile-fail-migration/no-implicit-prelude-nested.rs new file mode 100644 index 00000000000..c64839ad0de --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-implicit-prelude-nested.rs @@ -0,0 +1,64 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that things from the prelude aren't in scope. Use many of them +// so that renaming some things won't magically make this test fail +// for the wrong reason (e.g. if `Add` changes to `Addition`, and +// `no_implicit_prelude` stops working, then the `impl Add` will still +// fail with the same error message). + +#[no_implicit_prelude] +mod foo { + mod baz { + struct Test; + impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope + impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope + impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope + impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope + impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + + fn foo() { + drop(2) //~ ERROR cannot find function `drop` in this scope + } + } + + struct Test; + impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope + impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope + impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope + impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope + impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + + fn foo() { + drop(2) //~ ERROR cannot find function `drop` in this scope + } +} + +fn qux() { + #[no_implicit_prelude] + mod qux_inner { + struct Test; + impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope + impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope + impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope + impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope + impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + + fn foo() { + drop(2) //~ ERROR cannot find function `drop` in this scope + } + } +} + + +fn main() { + // these should work fine + drop(2) +} diff --git a/src/test/ui/compile-fail-migration/no-implicit-prelude-nested.stderr b/src/test/ui/compile-fail-migration/no-implicit-prelude-nested.stderr new file mode 100644 index 00000000000..dd0666a6fd4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-implicit-prelude-nested.stderr @@ -0,0 +1,196 @@ +error[E0405]: cannot find trait `Add` in this scope + --> $DIR/no-implicit-prelude-nested.rs:21:14 + | +LL | impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope + | ^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use std::ops::Add; + | + +error[E0405]: cannot find trait `Clone` in this scope + --> $DIR/no-implicit-prelude-nested.rs:22:14 + | +LL | impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope + | ^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::clone::Clone; + | +LL | use std::prelude::v1::Clone; + | + +error[E0405]: cannot find trait `Iterator` in this scope + --> $DIR/no-implicit-prelude-nested.rs:23:14 + | +LL | impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::iter::Iterator; + | +LL | use std::prelude::v1::Iterator; + | + +error[E0405]: cannot find trait `ToString` in this scope + --> $DIR/no-implicit-prelude-nested.rs:24:14 + | +LL | impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::prelude::v1::ToString; + | +LL | use std::string::ToString; + | + +error[E0405]: cannot find trait `Writer` in this scope + --> $DIR/no-implicit-prelude-nested.rs:25:14 + | +LL | impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + | ^^^^^^ not found in this scope + +error[E0425]: cannot find function `drop` in this scope + --> $DIR/no-implicit-prelude-nested.rs:28:13 + | +LL | drop(2) //~ ERROR cannot find function `drop` in this scope + | ^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::mem::drop; + | +LL | use std::prelude::v1::drop; + | + +error[E0405]: cannot find trait `Add` in this scope + --> $DIR/no-implicit-prelude-nested.rs:33:10 + | +LL | impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope + | ^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use std::ops::Add; + | + +error[E0405]: cannot find trait `Clone` in this scope + --> $DIR/no-implicit-prelude-nested.rs:34:10 + | +LL | impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope + | ^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::clone::Clone; + | +LL | use std::prelude::v1::Clone; + | + +error[E0405]: cannot find trait `Iterator` in this scope + --> $DIR/no-implicit-prelude-nested.rs:35:10 + | +LL | impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::iter::Iterator; + | +LL | use std::prelude::v1::Iterator; + | + +error[E0405]: cannot find trait `ToString` in this scope + --> $DIR/no-implicit-prelude-nested.rs:36:10 + | +LL | impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::prelude::v1::ToString; + | +LL | use std::string::ToString; + | + +error[E0405]: cannot find trait `Writer` in this scope + --> $DIR/no-implicit-prelude-nested.rs:37:10 + | +LL | impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + | ^^^^^^ not found in this scope + +error[E0425]: cannot find function `drop` in this scope + --> $DIR/no-implicit-prelude-nested.rs:40:9 + | +LL | drop(2) //~ ERROR cannot find function `drop` in this scope + | ^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::mem::drop; + | +LL | use std::prelude::v1::drop; + | + +error[E0405]: cannot find trait `Add` in this scope + --> $DIR/no-implicit-prelude-nested.rs:48:14 + | +LL | impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope + | ^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use std::ops::Add; + | + +error[E0405]: cannot find trait `Clone` in this scope + --> $DIR/no-implicit-prelude-nested.rs:49:14 + | +LL | impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope + | ^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::clone::Clone; + | +LL | use std::prelude::v1::Clone; + | + +error[E0405]: cannot find trait `Iterator` in this scope + --> $DIR/no-implicit-prelude-nested.rs:50:14 + | +LL | impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::iter::Iterator; + | +LL | use std::prelude::v1::Iterator; + | + +error[E0405]: cannot find trait `ToString` in this scope + --> $DIR/no-implicit-prelude-nested.rs:51:14 + | +LL | impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::prelude::v1::ToString; + | +LL | use std::string::ToString; + | + +error[E0405]: cannot find trait `Writer` in this scope + --> $DIR/no-implicit-prelude-nested.rs:52:14 + | +LL | impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + | ^^^^^^ not found in this scope + +error[E0425]: cannot find function `drop` in this scope + --> $DIR/no-implicit-prelude-nested.rs:55:13 + | +LL | drop(2) //~ ERROR cannot find function `drop` in this scope + | ^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::mem::drop; + | +LL | use std::prelude::v1::drop; + | + +error: aborting due to 18 previous errors + +Some errors occurred: E0405, E0425. +For more information about an error, try `rustc --explain E0405`. diff --git a/src/test/ui/compile-fail-migration/no-implicit-prelude.rs b/src/test/ui/compile-fail-migration/no-implicit-prelude.rs new file mode 100644 index 00000000000..0e39d9ebdc1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-implicit-prelude.rs @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_implicit_prelude] + +// Test that things from the prelude aren't in scope. Use many of them +// so that renaming some things won't magically make this test fail +// for the wrong reason (e.g. if `Add` changes to `Addition`, and +// `no_implicit_prelude` stops working, then the `impl Add` will still +// fail with the same error message). + +struct Test; +impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope +impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope +impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope +impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope +impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + +fn main() { + drop(2) //~ ERROR cannot find function `drop` in this scope +} diff --git a/src/test/ui/compile-fail-migration/no-implicit-prelude.stderr b/src/test/ui/compile-fail-migration/no-implicit-prelude.stderr new file mode 100644 index 00000000000..ae1098585b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-implicit-prelude.stderr @@ -0,0 +1,68 @@ +error[E0405]: cannot find trait `Add` in this scope + --> $DIR/no-implicit-prelude.rs:20:6 + | +LL | impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope + | ^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use std::ops::Add; + | + +error[E0405]: cannot find trait `Clone` in this scope + --> $DIR/no-implicit-prelude.rs:21:6 + | +LL | impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope + | ^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::clone::Clone; + | +LL | use std::prelude::v1::Clone; + | + +error[E0405]: cannot find trait `Iterator` in this scope + --> $DIR/no-implicit-prelude.rs:22:6 + | +LL | impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::iter::Iterator; + | +LL | use std::prelude::v1::Iterator; + | + +error[E0405]: cannot find trait `ToString` in this scope + --> $DIR/no-implicit-prelude.rs:23:6 + | +LL | impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope + | ^^^^^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::prelude::v1::ToString; + | +LL | use std::string::ToString; + | + +error[E0405]: cannot find trait `Writer` in this scope + --> $DIR/no-implicit-prelude.rs:24:6 + | +LL | impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope + | ^^^^^^ not found in this scope + +error[E0425]: cannot find function `drop` in this scope + --> $DIR/no-implicit-prelude.rs:27:5 + | +LL | drop(2) //~ ERROR cannot find function `drop` in this scope + | ^^^^ not found in this scope +help: possible candidates are found in other modules, you can import them into scope + | +LL | use std::mem::drop; + | +LL | use std::prelude::v1::drop; + | + +error: aborting due to 6 previous errors + +Some errors occurred: E0405, E0425. +For more information about an error, try `rustc --explain E0405`. diff --git a/src/test/ui/compile-fail-migration/no-link.rs b/src/test/ui/compile-fail-migration/no-link.rs new file mode 100644 index 00000000000..f74ff55e2c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-link.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:empty-struct.rs + +#[no_link] +extern crate empty_struct; +//~^ WARN proc macro crates and `#[no_link]` crates have no effect without `#[macro_use]` + +fn main() { + empty_struct::XEmpty1; //~ ERROR cannot find value `XEmpty1` in module `empty_struct` +} diff --git a/src/test/ui/compile-fail-migration/no-link.stderr b/src/test/ui/compile-fail-migration/no-link.stderr new file mode 100644 index 00000000000..3af7968f640 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-link.stderr @@ -0,0 +1,15 @@ +warning: proc macro crates and `#[no_link]` crates have no effect without `#[macro_use]` + --> $DIR/no-link.rs:14:1 + | +LL | extern crate empty_struct; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0425]: cannot find value `XEmpty1` in module `empty_struct` + --> $DIR/no-link.rs:18:19 + | +LL | empty_struct::XEmpty1; //~ ERROR cannot find value `XEmpty1` in module `empty_struct` + | ^^^^^^^ not found in `empty_struct` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/no-patterns-in-args-2.rs b/src/test/ui/compile-fail-migration/no-patterns-in-args-2.rs new file mode 100644 index 00000000000..4d2412c34a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-patterns-in-args-2.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(patterns_in_fns_without_body)] + +trait Tr { + fn f1(mut arg: u8); //~ ERROR patterns aren't allowed in methods without bodies + //~^ WARN was previously accepted + fn f2(&arg: u8); //~ ERROR patterns aren't allowed in methods without bodies + fn g1(arg: u8); // OK + fn g2(_: u8); // OK + #[allow(anonymous_parameters)] + fn g3(u8); // OK +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/no-patterns-in-args-2.stderr b/src/test/ui/compile-fail-migration/no-patterns-in-args-2.stderr new file mode 100644 index 00000000000..11476169c7d --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-patterns-in-args-2.stderr @@ -0,0 +1,23 @@ +error[E0642]: patterns aren't allowed in methods without bodies + --> $DIR/no-patterns-in-args-2.rs:16:11 + | +LL | fn f2(&arg: u8); //~ ERROR patterns aren't allowed in methods without bodies + | ^^^^ + +error: patterns aren't allowed in methods without bodies + --> $DIR/no-patterns-in-args-2.rs:14:11 + | +LL | fn f1(mut arg: u8); //~ ERROR patterns aren't allowed in methods without bodies + | ^^^^^^^ + | +note: lint level defined here + --> $DIR/no-patterns-in-args-2.rs:11:9 + | +LL | #![deny(patterns_in_fns_without_body)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #35203 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0642`. diff --git a/src/test/ui/compile-fail-migration/no-patterns-in-args-macro.rs b/src/test/ui/compile-fail-migration/no-patterns-in-args-macro.rs new file mode 100644 index 00000000000..f85ce8f57ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-patterns-in-args-macro.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! m { + ($pat: pat) => { + trait Tr { + fn trait_method($pat: u8); + } + + type A = fn($pat: u8); + + extern { + fn foreign_fn($pat: u8); + } + } +} + +mod good_pat { + m!(good_pat); // OK +} + +mod bad_pat { + m!((bad, pat)); + //~^ ERROR patterns aren't allowed in function pointer types + //~| ERROR patterns aren't allowed in foreign function declarations + //~| ERROR patterns aren't allowed in methods without bodies +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/no-patterns-in-args-macro.stderr b/src/test/ui/compile-fail-migration/no-patterns-in-args-macro.stderr new file mode 100644 index 00000000000..57af3178439 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-patterns-in-args-macro.stderr @@ -0,0 +1,22 @@ +error[E0642]: patterns aren't allowed in methods without bodies + --> $DIR/no-patterns-in-args-macro.rs:30:8 + | +LL | m!((bad, pat)); + | ^^^^^^^^^^ + +error[E0561]: patterns aren't allowed in function pointer types + --> $DIR/no-patterns-in-args-macro.rs:30:8 + | +LL | m!((bad, pat)); + | ^^^^^^^^^^ + +error[E0130]: patterns aren't allowed in foreign function declarations + --> $DIR/no-patterns-in-args-macro.rs:30:8 + | +LL | m!((bad, pat)); + | ^^^^^^^^^^ pattern not allowed in foreign function + +error: aborting due to 3 previous errors + +Some errors occurred: E0130, E0561, E0642. +For more information about an error, try `rustc --explain E0130`. diff --git a/src/test/ui/compile-fail-migration/no-reuse-move-arc.nll.stderr b/src/test/ui/compile-fail-migration/no-reuse-move-arc.nll.stderr new file mode 100644 index 00000000000..902affc8046 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-reuse-move-arc.nll.stderr @@ -0,0 +1,29 @@ +error[E0382]: borrow of moved value: `arc_v` + --> $DIR/no-reuse-move-arc.rs:22:18 + | +LL | thread::spawn(move|| { + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure +... +LL | assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` + | ^^^^^ value borrowed here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `arc_v` + --> $DIR/no-reuse-move-arc.rs:24:23 + | +LL | thread::spawn(move|| { + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure +... +LL | println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` + | ^^^^^ value borrowed here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/no-reuse-move-arc.rs b/src/test/ui/compile-fail-migration/no-reuse-move-arc.rs new file mode 100644 index 00000000000..76c8a444320 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-reuse-move-arc.rs @@ -0,0 +1,25 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::sync::Arc; +use std::thread; + +fn main() { + let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let arc_v = Arc::new(v); + + thread::spawn(move|| { + assert_eq!((*arc_v)[3], 4); + }); + + assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` + + println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` +} diff --git a/src/test/ui/compile-fail-migration/no-reuse-move-arc.stderr b/src/test/ui/compile-fail-migration/no-reuse-move-arc.stderr new file mode 100644 index 00000000000..91cba6e76ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-reuse-move-arc.stderr @@ -0,0 +1,25 @@ +error[E0382]: use of moved value: `arc_v` + --> $DIR/no-reuse-move-arc.rs:22:18 + | +LL | thread::spawn(move|| { + | ------ value moved (into closure) here +... +LL | assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` + | ^^^^^ value used here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `arc_v` + --> $DIR/no-reuse-move-arc.rs:24:23 + | +LL | thread::spawn(move|| { + | ------ value moved (into closure) here +... +LL | println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` + | ^^^^^ value used here after move + | + = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/no-send-res-ports.rs b/src/test/ui/compile-fail-migration/no-send-res-ports.rs new file mode 100644 index 00000000000..6825963c486 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-send-res-ports.rs @@ -0,0 +1,40 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::thread; +use std::rc::Rc; + +#[derive(Debug)] +struct Port(Rc); + +fn main() { + #[derive(Debug)] + struct foo { + _x: Port<()>, + } + + impl Drop for foo { + fn drop(&mut self) {} + } + + fn foo(x: Port<()>) -> foo { + foo { + _x: x + } + } + + let x = foo(Port(Rc::new(()))); + + thread::spawn(move|| { + //~^ ERROR `std::rc::Rc<()>` cannot be sent between threads safely + let y = x; + println!("{:?}", y); + }); +} diff --git a/src/test/ui/compile-fail-migration/no-send-res-ports.stderr b/src/test/ui/compile-fail-migration/no-send-res-ports.stderr new file mode 100644 index 00000000000..936b95413ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-send-res-ports.stderr @@ -0,0 +1,15 @@ +error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely + --> $DIR/no-send-res-ports.rs:35:5 + | +LL | thread::spawn(move|| { + | ^^^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely + | + = help: within `[closure@$DIR/no-send-res-ports.rs:35:19: 39:6 x:main::foo]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<()>` + = note: required because it appears within the type `Port<()>` + = note: required because it appears within the type `main::foo` + = note: required because it appears within the type `[closure@$DIR/no-send-res-ports.rs:35:19: 39:6 x:main::foo]` + = note: required by `std::thread::spawn` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/no-std-inject.rs b/src/test/ui/compile-fail-migration/no-std-inject.rs new file mode 100644 index 00000000000..49064853d21 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-std-inject.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] +#![allow(unused_extern_crates)] + +extern crate core; //~ ERROR: the name `core` is defined multiple times +extern crate std; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/no-std-inject.stderr b/src/test/ui/compile-fail-migration/no-std-inject.stderr new file mode 100644 index 00000000000..c1ea823a9bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-std-inject.stderr @@ -0,0 +1,15 @@ +error[E0259]: the name `core` is defined multiple times + --> $DIR/no-std-inject.rs:14:1 + | +LL | extern crate core; //~ ERROR: the name `core` is defined multiple times + | ^^^^^^^^^^^^^^^^^^ `core` reimported here + | + = note: `core` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | extern crate core as other_core; //~ ERROR: the name `core` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0259`. diff --git a/src/test/ui/compile-fail-migration/no-type-for-node-ice.rs b/src/test/ui/compile-fail-migration/no-type-for-node-ice.rs new file mode 100644 index 00000000000..f049f69e4bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-type-for-node-ice.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Related issues: #20401, #20506, #20614, #20752, #20829, #20846, #20885, #20886 + +fn main() { + "".homura[""]; //~ no field `homura` on type `&'static str` +} diff --git a/src/test/ui/compile-fail-migration/no-type-for-node-ice.stderr b/src/test/ui/compile-fail-migration/no-type-for-node-ice.stderr new file mode 100644 index 00000000000..c9de7d28af0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-type-for-node-ice.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `homura` on type `&'static str` + --> $DIR/no-type-for-node-ice.rs:14:8 + | +LL | "".homura[""]; //~ no field `homura` on type `&'static str` + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.rs b/src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.rs new file mode 100644 index 00000000000..2940b891534 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.rs @@ -0,0 +1,56 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue 34101: Circa 2016-06-05, `fn inline` below issued an +// erroneous warning from the elaborate_drops pass about moving out of +// a field in `Foo`, which has a destructor (and thus cannot have +// content moved out of it). The reason that the warning is erroneous +// in this case is that we are doing a *replace*, not a move, of the +// content in question, and it is okay to replace fields within `Foo`. +// +// Another more subtle problem was that the elaborate_drops was +// creating a separate drop flag for that internally replaced content, +// even though the compiler should enforce an invariant that any drop +// flag for such subcontent of `Foo` will always have the same value +// as the drop flag for `Foo` itself. +// +// This test is structured in a funny way; we cannot test for emission +// of the warning in question via the lint system, and therefore +// `#![deny(warnings)]` does nothing to detect it. +// +// So instead we use `#[rustc_error]` and put the test into +// `compile_fail`, where the emitted warning *will* be caught. + +#![feature(rustc_attrs)] + +struct Foo(String); + +impl Drop for Foo { + fn drop(&mut self) {} +} + +fn inline() { + // (dummy variable so `f` gets assigned `var1` in MIR for both fn's) + let _s = (); + let mut f = Foo(String::from("foo")); + f.0 = String::from("bar"); +} + +fn outline() { + let _s = String::from("foo"); + let mut f = Foo(_s); + f.0 = String::from("bar"); +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful + inline(); + outline(); +} diff --git a/src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.stderr b/src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.stderr new file mode 100644 index 00000000000..91a90266e5e --- /dev/null +++ b/src/test/ui/compile-fail-migration/no-warn-on-field-replace-issue-34101.stderr @@ -0,0 +1,11 @@ +error: compilation successful + --> $DIR/no-warn-on-field-replace-issue-34101.rs:53:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | inline(); +LL | | outline(); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/no_crate_type.rs b/src/test/ui/compile-fail-migration/no_crate_type.rs new file mode 100644 index 00000000000..b2cc5cae697 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_crate_type.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// regression test for issue 11256 +#![crate_type] //~ ERROR `crate_type` requires a value + +fn main() { + return +} diff --git a/src/test/ui/compile-fail-migration/no_crate_type.stderr b/src/test/ui/compile-fail-migration/no_crate_type.stderr new file mode 100644 index 00000000000..87f83f2d8df --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_crate_type.stderr @@ -0,0 +1,10 @@ +error: `crate_type` requires a value + --> $DIR/no_crate_type.rs:12:1 + | +LL | #![crate_type] //~ ERROR `crate_type` requires a value + | ^^^^^^^^^^^^^^ + | + = note: for example: `#![crate_type="lib"]` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/no_owned_box_lang_item.rs b/src/test/ui/compile-fail-migration/no_owned_box_lang_item.rs new file mode 100644 index 00000000000..1c2bf1573dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_owned_box_lang_item.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we don't ICE when we are missing the owned_box lang item. + +// error-pattern: requires `owned_box` lang_item + +#![feature(lang_items, box_syntax)] +#![no_std] + +fn main() { + let x = box 1i32; +} + +#[lang = "eh_personality"] extern fn eh_personality() {} +#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {} +#[lang = "panic_impl"] fn panic_impl() -> ! { loop {} } diff --git a/src/test/ui/compile-fail-migration/no_owned_box_lang_item.stderr b/src/test/ui/compile-fail-migration/no_owned_box_lang_item.stderr new file mode 100644 index 00000000000..c55c246b5e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_owned_box_lang_item.stderr @@ -0,0 +1,4 @@ +error: requires `owned_box` lang_item + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/no_send-enum.rs b/src/test/ui/compile-fail-migration/no_send-enum.rs new file mode 100644 index 00000000000..83f19ed19ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_send-enum.rs @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +use std::marker::Send; + +struct NoSend; +impl !Send for NoSend {} + +enum Foo { + A(NoSend) +} + +fn bar(_: T) {} + +fn main() { + let x = Foo::A(NoSend); + bar(x); + //~^ ERROR `NoSend` cannot be sent between threads safely +} diff --git a/src/test/ui/compile-fail-migration/no_send-enum.stderr b/src/test/ui/compile-fail-migration/no_send-enum.stderr new file mode 100644 index 00000000000..4d53c5f3013 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_send-enum.stderr @@ -0,0 +1,17 @@ +error[E0277]: `NoSend` cannot be sent between threads safely + --> $DIR/no_send-enum.rs:26:5 + | +LL | bar(x); + | ^^^ `NoSend` cannot be sent between threads safely + | + = help: within `Foo`, the trait `std::marker::Send` is not implemented for `NoSend` + = note: required because it appears within the type `Foo` +note: required by `bar` + --> $DIR/no_send-enum.rs:22:1 + | +LL | fn bar(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/no_send-rc.rs b/src/test/ui/compile-fail-migration/no_send-rc.rs new file mode 100644 index 00000000000..d3616d14422 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_send-rc.rs @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::rc::Rc; + +fn bar(_: T) {} + +fn main() { + let x = Rc::new(5); + bar(x); + //~^ ERROR `std::rc::Rc<{integer}>` cannot be sent between threads safely +} diff --git a/src/test/ui/compile-fail-migration/no_send-rc.stderr b/src/test/ui/compile-fail-migration/no_send-rc.stderr new file mode 100644 index 00000000000..a0dce6c817c --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_send-rc.stderr @@ -0,0 +1,16 @@ +error[E0277]: `std::rc::Rc<{integer}>` cannot be sent between threads safely + --> $DIR/no_send-rc.rs:17:5 + | +LL | bar(x); + | ^^^ `std::rc::Rc<{integer}>` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `std::rc::Rc<{integer}>` +note: required by `bar` + --> $DIR/no_send-rc.rs:13:1 + | +LL | fn bar(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/no_send-struct.rs b/src/test/ui/compile-fail-migration/no_send-struct.rs new file mode 100644 index 00000000000..d38d993e7e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_send-struct.rs @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +use std::marker::Send; + +struct Foo { + a: isize, +} + +impl !Send for Foo {} + +fn bar(_: T) {} + +fn main() { + let x = Foo { a: 5 }; + bar(x); + //~^ ERROR `Foo` cannot be sent between threads safely +} diff --git a/src/test/ui/compile-fail-migration/no_send-struct.stderr b/src/test/ui/compile-fail-migration/no_send-struct.stderr new file mode 100644 index 00000000000..dc7b5ec67f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_send-struct.stderr @@ -0,0 +1,16 @@ +error[E0277]: `Foo` cannot be sent between threads safely + --> $DIR/no_send-struct.rs:25:5 + | +LL | bar(x); + | ^^^ `Foo` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `Foo` +note: required by `bar` + --> $DIR/no_send-struct.rs:21:1 + | +LL | fn bar(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/no_share-enum.rs b/src/test/ui/compile-fail-migration/no_share-enum.rs new file mode 100644 index 00000000000..77a7012b3b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_share-enum.rs @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +use std::marker::Sync; + +struct NoSync; +impl !Sync for NoSync {} + +enum Foo { A(NoSync) } + +fn bar(_: T) {} + +fn main() { + let x = Foo::A(NoSync); + bar(x); + //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/no_share-enum.stderr b/src/test/ui/compile-fail-migration/no_share-enum.stderr new file mode 100644 index 00000000000..57b889158d0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_share-enum.stderr @@ -0,0 +1,17 @@ +error[E0277]: `NoSync` cannot be shared between threads safely + --> $DIR/no_share-enum.rs:24:5 + | +LL | bar(x); + | ^^^ `NoSync` cannot be shared between threads safely + | + = help: within `Foo`, the trait `std::marker::Sync` is not implemented for `NoSync` + = note: required because it appears within the type `Foo` +note: required by `bar` + --> $DIR/no_share-enum.rs:20:1 + | +LL | fn bar(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/no_share-struct.rs b/src/test/ui/compile-fail-migration/no_share-struct.rs new file mode 100644 index 00000000000..34e43e9f2aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_share-struct.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +use std::marker::Sync; + +struct Foo { a: isize } +impl !Sync for Foo {} + +fn bar(_: T) {} + +fn main() { + let x = Foo { a: 5 }; + bar(x); + //~^ ERROR `Foo` cannot be shared between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/no_share-struct.stderr b/src/test/ui/compile-fail-migration/no_share-struct.stderr new file mode 100644 index 00000000000..66291db5e53 --- /dev/null +++ b/src/test/ui/compile-fail-migration/no_share-struct.stderr @@ -0,0 +1,16 @@ +error[E0277]: `Foo` cannot be shared between threads safely + --> $DIR/no_share-struct.rs:22:5 + | +LL | bar(x); + | ^^^ `Foo` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `Foo` +note: required by `bar` + --> $DIR/no_share-struct.rs:18:1 + | +LL | fn bar(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/noexporttypeexe.rs b/src/test/ui/compile-fail-migration/noexporttypeexe.rs new file mode 100644 index 00000000000..c950ef5b680 --- /dev/null +++ b/src/test/ui/compile-fail-migration/noexporttypeexe.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:noexporttypelib.rs + +extern crate noexporttypelib; + +fn main() { + // Here, the type returned by foo() is not exported. + // This used to cause internal errors when serializing + // because the def_id associated with the type was + // not convertible to a path. + let x: isize = noexporttypelib::foo(); + //~^ ERROR mismatched types + //~| expected type `isize` + //~| found type `std::option::Option` + //~| expected isize, found enum `std::option::Option` +} diff --git a/src/test/ui/compile-fail-migration/noexporttypeexe.stderr b/src/test/ui/compile-fail-migration/noexporttypeexe.stderr new file mode 100644 index 00000000000..1671b3eae49 --- /dev/null +++ b/src/test/ui/compile-fail-migration/noexporttypeexe.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/noexporttypeexe.rs:20:18 + | +LL | let x: isize = noexporttypelib::foo(); + | ^^^^^^^^^^^^^^^^^^^^^^ expected isize, found enum `std::option::Option` + | + = note: expected type `isize` + found type `std::option::Option` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/nolink-with-link-args.nll.stderr b/src/test/ui/compile-fail-migration/nolink-with-link-args.nll.stderr new file mode 100644 index 00000000000..df666db753d --- /dev/null +++ b/src/test/ui/compile-fail-migration/nolink-with-link-args.nll.stderr @@ -0,0 +1,9 @@ +error: linking with `ld` failed: exit code: 1 + | + = note: "ld" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args.nll/a.nolink_with_link_args0-317d481089b8c8fe83113de504472633.rs.rcgu.o" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args.nll/a.nolink_with_link_args1-317d481089b8c8fe83113de504472633.rs.rcgu.o" "-o" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args.nll/a" "--gc-sections" "-pie" "-zrelro" "-znow" "-O1" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args.nll/auxiliary" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--start-group" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-e05e3c08f9f6faf5" "--end-group" "-Bstatic" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ce73107aecc35a63.rlib" "-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil" "-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-rpath,/home/david/projects/rust/workdirs/rust1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--enable-new-dtags" "aFdEfSeVEEE" + = note: ld: unrecognized option '-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib' + ld: use the --help option for usage information + + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/nolink-with-link-args.rs b/src/test/ui/compile-fail-migration/nolink-with-link-args.rs new file mode 100644 index 00000000000..6dfd74f541e --- /dev/null +++ b/src/test/ui/compile-fail-migration/nolink-with-link-args.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:aFdEfSeVEE +// compile-flags: -Z linker-flavor=ld + +/* We're testing that link_args are indeed passed when nolink is specified. +So we try to compile with junk link_args and make sure they are visible in +the compiler output. */ + +#![feature(link_args)] + +#[link_args = "aFdEfSeVEEE"] +extern {} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/nolink-with-link-args.stderr b/src/test/ui/compile-fail-migration/nolink-with-link-args.stderr new file mode 100644 index 00000000000..4c62e556a39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nolink-with-link-args.stderr @@ -0,0 +1,9 @@ +error: linking with `ld` failed: exit code: 1 + | + = note: "ld" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args/a.nolink_with_link_args0-317d481089b8c8fe83113de504472633.rs.rcgu.o" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args/a.nolink_with_link_args1-317d481089b8c8fe83113de504472633.rs.rcgu.o" "-o" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args/a" "--gc-sections" "-pie" "-zrelro" "-znow" "-O1" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/test/ui/compile-fail-migration/nolink-with-link-args/auxiliary" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--start-group" "-L" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-e05e3c08f9f6faf5" "--end-group" "-Bstatic" "/home/david/projects/rust/workdirs/rust1/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ce73107aecc35a63.rlib" "-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil" "-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-rpath,/home/david/projects/rust/workdirs/rust1/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--enable-new-dtags" "aFdEfSeVEEE" + = note: ld: unrecognized option '-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib' + ld: use the --help option for usage information + + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/non-constant-in-const-path.rs b/src/test/ui/compile-fail-migration/non-constant-in-const-path.rs new file mode 100644 index 00000000000..1aae25105a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-constant-in-const-path.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = 0; + match 1 { + 0 ..= x => {} + //~^ ERROR runtime values cannot be referenced in patterns + }; +} diff --git a/src/test/ui/compile-fail-migration/non-constant-in-const-path.stderr b/src/test/ui/compile-fail-migration/non-constant-in-const-path.stderr new file mode 100644 index 00000000000..91ef9fd81e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-constant-in-const-path.stderr @@ -0,0 +1,9 @@ +error[E0080]: runtime values cannot be referenced in patterns + --> $DIR/non-constant-in-const-path.rs:14:15 + | +LL | 0 ..= x => {} + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/non-copyable-void.rs b/src/test/ui/compile-fail-migration/non-copyable-void.rs new file mode 100644 index 00000000000..63e5f963754 --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-copyable-void.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +extern crate libc; + +fn main() { + let x : *const Vec = &vec![1,2,3]; + let y : *const libc::c_void = x as *const libc::c_void; + unsafe { + let _z = (*y).clone(); + //~^ ERROR no method named `clone` found + } +} diff --git a/src/test/ui/compile-fail-migration/non-copyable-void.stderr b/src/test/ui/compile-fail-migration/non-copyable-void.stderr new file mode 100644 index 00000000000..b5c83ec2289 --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-copyable-void.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `clone` found for type `libc::c_void` in the current scope + --> $DIR/non-copyable-void.rs:21:23 + | +LL | let _z = (*y).clone(); + | ^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/non-exhaustive-match-nested.rs b/src/test/ui/compile-fail-migration/non-exhaustive-match-nested.rs new file mode 100644 index 00000000000..1d524217a12 --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-exhaustive-match-nested.rs @@ -0,0 +1,31 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] + +enum t { a(u), b } +enum u { c, d } + +fn match_nested_vecs<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str { + match (l1, l2) { //~ ERROR non-exhaustive patterns: `(Some(&[]), Err(_))` not covered + (Some(&[]), Ok(&[])) => "Some(empty), Ok(empty)", + (Some(&[_, ..]), Ok(_)) | (Some(&[_, ..]), Err(())) => "Some(non-empty), any", + (None, Ok(&[])) | (None, Err(())) | (None, Ok(&[_])) => "None, Ok(less than one element)", + (None, Ok(&[_, _, ..])) => "None, Ok(at least two elements)" + } +} + +fn main() { + let x = t::a(u::c); + match x { //~ ERROR non-exhaustive patterns: `a(c)` not covered + t::a(u::d) => { panic!("hello"); } + t::b => { panic!("goodbye"); } + } +} diff --git a/src/test/ui/compile-fail-migration/non-exhaustive-match-nested.stderr b/src/test/ui/compile-fail-migration/non-exhaustive-match-nested.stderr new file mode 100644 index 00000000000..6fb9788139f --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-exhaustive-match-nested.stderr @@ -0,0 +1,15 @@ +error[E0004]: non-exhaustive patterns: `(Some(&[]), Err(_))` not covered + --> $DIR/non-exhaustive-match-nested.rs:17:11 + | +LL | match (l1, l2) { //~ ERROR non-exhaustive patterns: `(Some(&[]), Err(_))` not covered + | ^^^^^^^^ pattern `(Some(&[]), Err(_))` not covered + +error[E0004]: non-exhaustive patterns: `a(c)` not covered + --> $DIR/non-exhaustive-match-nested.rs:27:11 + | +LL | match x { //~ ERROR non-exhaustive patterns: `a(c)` not covered + | ^ pattern `a(c)` not covered + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/non-exhaustive-match.rs b/src/test/ui/compile-fail-migration/non-exhaustive-match.rs new file mode 100644 index 00000000000..13b62429f46 --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-exhaustive-match.rs @@ -0,0 +1,73 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] +#![allow(illegal_floating_point_literal_pattern)] + +enum t { a, b, } + +fn main() { + let x = t::a; + match x { t::b => { } } //~ ERROR non-exhaustive patterns: `a` not covered + match true { //~ ERROR non-exhaustive patterns: `false` not covered + true => {} + } + match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered + None => {} + } + match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered + (_, _, 4) => {} + } + match (t::a, t::a) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered + (t::a, t::b) => {} + (t::b, t::a) => {} + } + match t::a { //~ ERROR non-exhaustive patterns: `b` not covered + t::a => {} + } + // This is exhaustive, though the algorithm got it wrong at one point + match (t::a, t::b) { + (t::a, _) => {} + (_, t::a) => {} + (t::b, t::b) => {} + } + let vec = vec![Some(42), None, Some(21)]; + let vec: &[Option] = &vec; + match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered + [Some(..), None, ref tail..] => {} + [Some(..), Some(..), ref tail..] => {} + [None] => {} + } + let vec = vec![1]; + let vec: &[isize] = &vec; + match *vec { + [_, ref tail..] => (), + [] => () + } + let vec = vec![0.5f32]; + let vec: &[f32] = &vec; + match *vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered + [0.1, 0.2, 0.3] => (), + [0.1, 0.2] => (), + [0.1] => (), + [] => () + } + let vec = vec![Some(42), None, Some(21)]; + let vec: &[Option] = &vec; + match *vec { + [Some(..), None, ref tail..] => {} + [Some(..), Some(..), ref tail..] => {} + [None, None, ref tail..] => {} + [None, Some(..), ref tail..] => {} + [Some(_)] => {} + [None] => {} + [] => {} + } +} diff --git a/src/test/ui/compile-fail-migration/non-exhaustive-match.stderr b/src/test/ui/compile-fail-migration/non-exhaustive-match.stderr new file mode 100644 index 00000000000..f48a0bc15eb --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-exhaustive-match.stderr @@ -0,0 +1,51 @@ +error[E0004]: non-exhaustive patterns: `a` not covered + --> $DIR/non-exhaustive-match.rs:18:11 + | +LL | match x { t::b => { } } //~ ERROR non-exhaustive patterns: `a` not covered + | ^ pattern `a` not covered + +error[E0004]: non-exhaustive patterns: `false` not covered + --> $DIR/non-exhaustive-match.rs:19:11 + | +LL | match true { //~ ERROR non-exhaustive patterns: `false` not covered + | ^^^^ pattern `false` not covered + +error[E0004]: non-exhaustive patterns: `Some(_)` not covered + --> $DIR/non-exhaustive-match.rs:22:11 + | +LL | match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered + | ^^^^^^^^ pattern `Some(_)` not covered + +error[E0004]: non-exhaustive patterns: `(_, _, _)` not covered + --> $DIR/non-exhaustive-match.rs:25:11 + | +LL | match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered + | ^^^^^^^^^ pattern `(_, _, _)` not covered + +error[E0004]: non-exhaustive patterns: `(a, a)` not covered + --> $DIR/non-exhaustive-match.rs:28:11 + | +LL | match (t::a, t::a) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered + | ^^^^^^^^^^^^ pattern `(a, a)` not covered + +error[E0004]: non-exhaustive patterns: `b` not covered + --> $DIR/non-exhaustive-match.rs:32:11 + | +LL | match t::a { //~ ERROR non-exhaustive patterns: `b` not covered + | ^^^^ pattern `b` not covered + +error[E0004]: non-exhaustive patterns: `[]` not covered + --> $DIR/non-exhaustive-match.rs:43:11 + | +LL | match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered + | ^^^^ pattern `[]` not covered + +error[E0004]: non-exhaustive patterns: `[_, _, _, _]` not covered + --> $DIR/non-exhaustive-match.rs:56:11 + | +LL | match *vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered + | ^^^^ pattern `[_, _, _, _]` not covered + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/non-interger-atomic.rs b/src/test/ui/compile-fail-migration/non-interger-atomic.rs new file mode 100644 index 00000000000..2a6e148ca79 --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-interger-atomic.rs @@ -0,0 +1,100 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(core_intrinsics)] +#![allow(warnings)] +#![crate_type = "rlib"] + +use std::intrinsics; + +#[derive(Copy, Clone)] +pub struct Foo(i64); +pub type Bar = &'static Fn(); +pub type Quux = [u8; 100]; + +pub unsafe fn test_bool_load(p: &mut bool, v: bool) { + intrinsics::atomic_load(p); + //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool` +} + +pub unsafe fn test_bool_store(p: &mut bool, v: bool) { + intrinsics::atomic_store(p, v); + //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool` +} + +pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) { + intrinsics::atomic_xchg(p, v); + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool` +} + +pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) { + intrinsics::atomic_cxchg(p, v, v); + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool` +} + +pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) { + intrinsics::atomic_load(p); + //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo` +} + +pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) { + intrinsics::atomic_store(p, v); + //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo` +} + +pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) { + intrinsics::atomic_xchg(p, v); + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo` +} + +pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) { + intrinsics::atomic_cxchg(p, v, v); + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo` +} + +pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) { + intrinsics::atomic_load(p); + //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` +} + +pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) { + intrinsics::atomic_store(p, v); + //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` +} + +pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) { + intrinsics::atomic_xchg(p, v); + //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` +} + +pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) { + intrinsics::atomic_cxchg(p, v, v); + //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` +} + +pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) { + intrinsics::atomic_load(p); + //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]` +} + +pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) { + intrinsics::atomic_store(p, v); + //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]` +} + +pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) { + intrinsics::atomic_xchg(p, v); + //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]` +} + +pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) { + intrinsics::atomic_cxchg(p, v, v); + //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]` +} diff --git a/src/test/ui/compile-fail-migration/non-interger-atomic.stderr b/src/test/ui/compile-fail-migration/non-interger-atomic.stderr new file mode 100644 index 00000000000..8cb114dd42c --- /dev/null +++ b/src/test/ui/compile-fail-migration/non-interger-atomic.stderr @@ -0,0 +1,99 @@ +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `bool` + --> $DIR/non-interger-atomic.rs:23:5 + | +LL | intrinsics::atomic_load(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `bool` + --> $DIR/non-interger-atomic.rs:28:5 + | +LL | intrinsics::atomic_store(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `bool` + --> $DIR/non-interger-atomic.rs:33:5 + | +LL | intrinsics::atomic_xchg(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `bool` + --> $DIR/non-interger-atomic.rs:38:5 + | +LL | intrinsics::atomic_cxchg(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `Foo` + --> $DIR/non-interger-atomic.rs:43:5 + | +LL | intrinsics::atomic_load(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `Foo` + --> $DIR/non-interger-atomic.rs:48:5 + | +LL | intrinsics::atomic_store(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `Foo` + --> $DIR/non-interger-atomic.rs:53:5 + | +LL | intrinsics::atomic_xchg(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `Foo` + --> $DIR/non-interger-atomic.rs:58:5 + | +LL | intrinsics::atomic_cxchg(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()` + --> $DIR/non-interger-atomic.rs:63:5 + | +LL | intrinsics::atomic_load(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()` + --> $DIR/non-interger-atomic.rs:68:5 + | +LL | intrinsics::atomic_store(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()` + --> $DIR/non-interger-atomic.rs:73:5 + | +LL | intrinsics::atomic_xchg(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `&dyn std::ops::Fn()` + --> $DIR/non-interger-atomic.rs:78:5 + | +LL | intrinsics::atomic_cxchg(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]` + --> $DIR/non-interger-atomic.rs:83:5 + | +LL | intrinsics::atomic_load(p); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]` + --> $DIR/non-interger-atomic.rs:88:5 + | +LL | intrinsics::atomic_store(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]` + --> $DIR/non-interger-atomic.rs:93:5 + | +LL | intrinsics::atomic_xchg(p, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]` + --> $DIR/non-interger-atomic.rs:98:5 + | +LL | intrinsics::atomic_cxchg(p, v, v); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 16 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/noncopyable-class.rs b/src/test/ui/compile-fail-migration/noncopyable-class.rs new file mode 100644 index 00000000000..f5712b0c957 --- /dev/null +++ b/src/test/ui/compile-fail-migration/noncopyable-class.rs @@ -0,0 +1,46 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a class with a non-copyable field can't be +// copied + +#[derive(Debug)] +struct bar { + x: isize, +} + +impl Drop for bar { + fn drop(&mut self) {} +} + +fn bar(x:isize) -> bar { + bar { + x: x + } +} + +#[derive(Debug)] +struct foo { + i: isize, + j: bar, +} + +fn foo(i:isize) -> foo { + foo { + i: i, + j: bar(5) + } +} + +fn main() { + let x = foo(10); + let _y = x.clone(); //~ ERROR no method named `clone` found + println!("{:?}", x); +} diff --git a/src/test/ui/compile-fail-migration/noncopyable-class.stderr b/src/test/ui/compile-fail-migration/noncopyable-class.stderr new file mode 100644 index 00000000000..49ad30e56af --- /dev/null +++ b/src/test/ui/compile-fail-migration/noncopyable-class.stderr @@ -0,0 +1,16 @@ +error[E0599]: no method named `clone` found for type `foo` in the current scope + --> $DIR/noncopyable-class.rs:44:16 + | +LL | struct foo { + | ---------- method `clone` not found for this +... +LL | let _y = x.clone(); //~ ERROR no method named `clone` found + | ^^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `std::clone::Clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/nonscalar-cast.rs b/src/test/ui/compile-fail-migration/nonscalar-cast.rs new file mode 100644 index 00000000000..0abbc05eef0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nonscalar-cast.rs @@ -0,0 +1,18 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +struct foo { + x: isize +} + +fn main() { + println!("{}", foo{ x: 1 } as isize); //~ non-primitive cast: `foo` as `isize` [E0605] +} diff --git a/src/test/ui/compile-fail-migration/nonscalar-cast.stderr b/src/test/ui/compile-fail-migration/nonscalar-cast.stderr new file mode 100644 index 00000000000..d66ccd08f55 --- /dev/null +++ b/src/test/ui/compile-fail-migration/nonscalar-cast.stderr @@ -0,0 +1,11 @@ +error[E0605]: non-primitive cast: `foo` as `isize` + --> $DIR/nonscalar-cast.rs:17:20 + | +LL | println!("{}", foo{ x: 1 } as isize); //~ non-primitive cast: `foo` as `isize` [E0605] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/not-clone-closure.rs b/src/test/ui/compile-fail-migration/not-clone-closure.rs new file mode 100644 index 00000000000..967cb3610ca --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-clone-closure.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that closures do not implement `Clone` if their environment is not `Clone`. + +struct S(i32); + +fn main() { + let a = S(5); + let hello = move || { + println!("Hello {}", a.0); + }; + + let hello = hello.clone(); //~ ERROR the trait bound `S: std::clone::Clone` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/not-clone-closure.stderr b/src/test/ui/compile-fail-migration/not-clone-closure.stderr new file mode 100644 index 00000000000..eda9b1c495e --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-clone-closure.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `S: std::clone::Clone` is not satisfied in `[closure@$DIR/not-clone-closure.rs:17:17: 19:6 a:S]` + --> $DIR/not-clone-closure.rs:21:23 + | +LL | let hello = hello.clone(); //~ ERROR the trait bound `S: std::clone::Clone` is not satisfied + | ^^^^^ within `[closure@$DIR/not-clone-closure.rs:17:17: 19:6 a:S]`, the trait `std::clone::Clone` is not implemented for `S` + | + = note: required because it appears within the type `[closure@$DIR/not-clone-closure.rs:17:17: 19:6 a:S]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-copy-closure.nll.stderr b/src/test/ui/compile-fail-migration/not-copy-closure.nll.stderr new file mode 100644 index 00000000000..b278df5e4b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-copy-closure.nll.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `hello` + --> $DIR/not-copy-closure.rs:20:13 + | +LL | let b = hello; + | ----- value moved here +LL | let c = hello; //~ ERROR use of moved value: `hello` [E0382] + | ^^^^^ value used here after move + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/not-copy-closure.rs b/src/test/ui/compile-fail-migration/not-copy-closure.rs new file mode 100644 index 00000000000..10567c5c961 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-copy-closure.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that closures do not implement `Copy` if their environment is not `Copy`. + +fn main() { + let mut a = 5; + let hello = || { + a += 1; + }; + + let b = hello; + let c = hello; //~ ERROR use of moved value: `hello` [E0382] +} diff --git a/src/test/ui/compile-fail-migration/not-copy-closure.stderr b/src/test/ui/compile-fail-migration/not-copy-closure.stderr new file mode 100644 index 00000000000..7193a3ed027 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-copy-closure.stderr @@ -0,0 +1,17 @@ +error[E0382]: use of moved value: `hello` + --> $DIR/not-copy-closure.rs:20:9 + | +LL | let b = hello; + | - value moved here +LL | let c = hello; //~ ERROR use of moved value: `hello` [E0382] + | ^ value used here after move + | +note: closure cannot be invoked more than once because it moves the variable `a` out of its environment + --> $DIR/not-copy-closure.rs:16:9 + | +LL | a += 1; + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-2.rs b/src/test/ui/compile-fail-migration/not-panic-safe-2.rs new file mode 100644 index 00000000000..5490acf4bd6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-2.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +use std::panic::UnwindSafe; +use std::rc::Rc; +use std::cell::RefCell; + +fn assert() {} + +fn main() { + assert::>>(); + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a +} diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-2.stderr b/src/test/ui/compile-fail-migration/not-panic-safe-2.stderr new file mode 100644 index 00000000000..19408623ea3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-2.stderr @@ -0,0 +1,34 @@ +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-2.rs:20:5 + | +LL | assert::>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `std::rc::Rc>` +note: required by `assert` + --> $DIR/not-panic-safe-2.rs:17:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-2.rs:20:5 + | +LL | assert::>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::Cell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `std::rc::Rc>` +note: required by `assert` + --> $DIR/not-panic-safe-2.rs:17:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-3.rs b/src/test/ui/compile-fail-migration/not-panic-safe-3.rs new file mode 100644 index 00000000000..0fac395a115 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-3.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +use std::panic::UnwindSafe; +use std::sync::Arc; +use std::cell::RefCell; + +fn assert() {} + +fn main() { + assert::>>(); + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a +} diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-3.stderr b/src/test/ui/compile-fail-migration/not-panic-safe-3.stderr new file mode 100644 index 00000000000..a353c82c687 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-3.stderr @@ -0,0 +1,34 @@ +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-3.rs:20:5 + | +LL | assert::>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `std::sync::Arc>` +note: required by `assert` + --> $DIR/not-panic-safe-3.rs:17:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-3.rs:20:5 + | +LL | assert::>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::Cell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `std::sync::Arc>` +note: required by `assert` + --> $DIR/not-panic-safe-3.rs:17:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-4.rs b/src/test/ui/compile-fail-migration/not-panic-safe-4.rs new file mode 100644 index 00000000000..bf0392018b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-4.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +use std::panic::UnwindSafe; +use std::cell::RefCell; + +fn assert() {} + +fn main() { + assert::<&RefCell>(); + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a +} diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-4.stderr b/src/test/ui/compile-fail-migration/not-panic-safe-4.stderr new file mode 100644 index 00000000000..27d3defe123 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-4.stderr @@ -0,0 +1,34 @@ +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-4.rs:19:5 + | +LL | assert::<&RefCell>(); + | ^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&std::cell::RefCell` +note: required by `assert` + --> $DIR/not-panic-safe-4.rs:16:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-4.rs:19:5 + | +LL | assert::<&RefCell>(); + | ^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::Cell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&std::cell::RefCell` +note: required by `assert` + --> $DIR/not-panic-safe-4.rs:16:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-5.rs b/src/test/ui/compile-fail-migration/not-panic-safe-5.rs new file mode 100644 index 00000000000..627a0fe78cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-5.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +use std::panic::UnwindSafe; +use std::cell::UnsafeCell; + +fn assert() {} + +fn main() { + assert::<*const UnsafeCell>(); //~ ERROR E0277 +} diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-5.stderr b/src/test/ui/compile-fail-migration/not-panic-safe-5.stderr new file mode 100644 index 00000000000..ba3b3fadb6a --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-5.stderr @@ -0,0 +1,17 @@ +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-5.rs:19:5 + | +LL | assert::<*const UnsafeCell>(); //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `*const std::cell::UnsafeCell` +note: required by `assert` + --> $DIR/not-panic-safe-5.rs:16:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-6.rs b/src/test/ui/compile-fail-migration/not-panic-safe-6.rs new file mode 100644 index 00000000000..950f0a0b53a --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-6.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +use std::panic::UnwindSafe; +use std::cell::RefCell; + +fn assert() {} + +fn main() { + assert::<*mut RefCell>(); + //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a + //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a +} diff --git a/src/test/ui/compile-fail-migration/not-panic-safe-6.stderr b/src/test/ui/compile-fail-migration/not-panic-safe-6.stderr new file mode 100644 index 00000000000..da6c2a58294 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe-6.stderr @@ -0,0 +1,34 @@ +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-6.rs:19:5 + | +LL | assert::<*mut RefCell>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `*mut std::cell::RefCell` +note: required by `assert` + --> $DIR/not-panic-safe-6.rs:16:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the type `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/not-panic-safe-6.rs:19:5 + | +LL | assert::<*mut RefCell>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `std::cell::RefCell`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `std::cell::Cell` + = note: required because it appears within the type `std::cell::RefCell` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `*mut std::cell::RefCell` +note: required by `assert` + --> $DIR/not-panic-safe-6.rs:16:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-panic-safe.rs b/src/test/ui/compile-fail-migration/not-panic-safe.rs new file mode 100644 index 00000000000..0ebf3d3fed7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![feature(recover)] + +use std::panic::UnwindSafe; + +fn assert() {} + +fn main() { + assert::<&mut i32>(); + //~^ ERROR the type `&mut i32` may not be safely transferred across an unwind boundary +} diff --git a/src/test/ui/compile-fail-migration/not-panic-safe.stderr b/src/test/ui/compile-fail-migration/not-panic-safe.stderr new file mode 100644 index 00000000000..f349b5d2e26 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-panic-safe.stderr @@ -0,0 +1,16 @@ +error[E0277]: the type `&mut i32` may not be safely transferred across an unwind boundary + --> $DIR/not-panic-safe.rs:19:5 + | +LL | assert::<&mut i32>(); + | ^^^^^^^^^^^^^^^^^^ `&mut i32` may not be safely transferred across an unwind boundary + | + = help: the trait `std::panic::UnwindSafe` is not implemented for `&mut i32` +note: required by `assert` + --> $DIR/not-panic-safe.rs:16:1 + | +LL | fn assert() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-sync.rs b/src/test/ui/compile-fail-migration/not-sync.rs new file mode 100644 index 00000000000..a383244f415 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-sync.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cell::{Cell, RefCell}; +use std::rc::{Rc, Weak}; +use std::sync::mpsc::{Receiver, Sender}; + +fn test() {} + +fn main() { + test::>(); + //~^ ERROR `std::cell::Cell` cannot be shared between threads safely [E0277] + test::>(); + //~^ ERROR `std::cell::RefCell` cannot be shared between threads safely [E0277] + + test::>(); + //~^ ERROR `std::rc::Rc` cannot be shared between threads safely [E0277] + test::>(); + //~^ ERROR `std::rc::Weak` cannot be shared between threads safely [E0277] + + test::>(); + //~^ ERROR `std::sync::mpsc::Receiver` cannot be shared between threads safely [E0277] + test::>(); + //~^ ERROR `std::sync::mpsc::Sender` cannot be shared between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/not-sync.stderr b/src/test/ui/compile-fail-migration/not-sync.stderr new file mode 100644 index 00000000000..026fd5dd713 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-sync.stderr @@ -0,0 +1,81 @@ +error[E0277]: `std::cell::Cell` cannot be shared between threads safely + --> $DIR/not-sync.rs:18:5 + | +LL | test::>(); + | ^^^^^^^^^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` +note: required by `test` + --> $DIR/not-sync.rs:15:1 + | +LL | fn test() {} + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::cell::RefCell` cannot be shared between threads safely + --> $DIR/not-sync.rs:20:5 + | +LL | test::>(); + | ^^^^^^^^^^^^^^^^^^^^ `std::cell::RefCell` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::cell::RefCell` +note: required by `test` + --> $DIR/not-sync.rs:15:1 + | +LL | fn test() {} + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::rc::Rc` cannot be shared between threads safely + --> $DIR/not-sync.rs:23:5 + | +LL | test::>(); + | ^^^^^^^^^^^^^^^ `std::rc::Rc` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::rc::Rc` +note: required by `test` + --> $DIR/not-sync.rs:15:1 + | +LL | fn test() {} + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::rc::Weak` cannot be shared between threads safely + --> $DIR/not-sync.rs:25:5 + | +LL | test::>(); + | ^^^^^^^^^^^^^^^^^ `std::rc::Weak` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::rc::Weak` +note: required by `test` + --> $DIR/not-sync.rs:15:1 + | +LL | fn test() {} + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::sync::mpsc::Receiver` cannot be shared between threads safely + --> $DIR/not-sync.rs:28:5 + | +LL | test::>(); + | ^^^^^^^^^^^^^^^^^^^^^ `std::sync::mpsc::Receiver` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Receiver` +note: required by `test` + --> $DIR/not-sync.rs:15:1 + | +LL | fn test() {} + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::sync::mpsc::Sender` cannot be shared between threads safely + --> $DIR/not-sync.rs:30:5 + | +LL | test::>(); + | ^^^^^^^^^^^^^^^^^^^ `std::sync::mpsc::Sender` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::sync::mpsc::Sender` +note: required by `test` + --> $DIR/not-sync.rs:15:1 + | +LL | fn test() {} + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/not-utf8.bin b/src/test/ui/compile-fail-migration/not-utf8.bin new file mode 100644 index 00000000000..4148e5b88fe Binary files /dev/null and b/src/test/ui/compile-fail-migration/not-utf8.bin differ diff --git a/src/test/ui/compile-fail-migration/not-utf8.rs b/src/test/ui/compile-fail-migration/not-utf8.rs new file mode 100644 index 00000000000..5331062d9b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-utf8.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: did not contain valid UTF-8 + +fn foo() { + include!("not-utf8.bin") +} diff --git a/src/test/ui/compile-fail-migration/not-utf8.stderr b/src/test/ui/compile-fail-migration/not-utf8.stderr new file mode 100644 index 00000000000..28c23f4f348 --- /dev/null +++ b/src/test/ui/compile-fail-migration/not-utf8.stderr @@ -0,0 +1,8 @@ +error: couldn't read "$DIR/not-utf8.bin": stream did not contain valid UTF-8 + --> $DIR/not-utf8.rs:14:5 + | +LL | include!("not-utf8.bin") + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/object-does-not-impl-trait.rs b/src/test/ui/compile-fail-migration/object-does-not-impl-trait.rs new file mode 100644 index 00000000000..30f8d5e2f45 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-does-not-impl-trait.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an object type `Box` is not considered to implement the +// trait `Foo`. Issue #5087. + +trait Foo {} +fn take_foo(f: F) {} +fn take_object(f: Box) { take_foo(f); } +//~^ ERROR `std::boxed::Box: Foo` is not satisfied +fn main() {} diff --git a/src/test/ui/compile-fail-migration/object-does-not-impl-trait.stderr b/src/test/ui/compile-fail-migration/object-does-not-impl-trait.stderr new file mode 100644 index 00000000000..a1ebdf3e666 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-does-not-impl-trait.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `std::boxed::Box: Foo` is not satisfied + --> $DIR/object-does-not-impl-trait.rs:16:31 + | +LL | fn take_object(f: Box) { take_foo(f); } + | ^^^^^^^^ the trait `Foo` is not implemented for `std::boxed::Box` + | +note: required by `take_foo` + --> $DIR/object-does-not-impl-trait.rs:15:1 + | +LL | fn take_foo(f: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.rs b/src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.rs new file mode 100644 index 00000000000..3df83d91999 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.rs @@ -0,0 +1,58 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that if a struct declares multiple region bounds for a given +// type parameter, an explicit lifetime bound is required on object +// lifetimes within. + +#![allow(dead_code)] + +trait Test { + fn foo(&self) { } +} + +struct Ref0 { + r: *mut T +} + +struct Ref1<'a,T:'a+?Sized> { + r: &'a T +} + +struct Ref2<'a,'b:'a,T:'a+'b+?Sized> { + r: &'a &'b T +} + +fn a<'a,'b>(t: Ref2<'a,'b,Test>) { + //~^ ERROR lifetime bound for this object type cannot be deduced from context +} + +fn b(t: Ref2) { + //~^ ERROR lifetime bound for this object type cannot be deduced from context +} + +fn c(t: Ref2<&Test>) { + // In this case, the &'a overrides. +} + +fn d(t: Ref2>) { + // In this case, the lifetime parameter from the Ref1 overrides. +} + +fn e(t: Ref2>) { + // In this case, Ref2 is ambiguous, but Ref0 overrides with 'static. +} + +fn f(t: &Ref2) { + //~^ ERROR lifetime bound for this object type cannot be deduced from context +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.stderr new file mode 100644 index 00000000000..cb603f2c472 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-ambiguous.stderr @@ -0,0 +1,21 @@ +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound + --> $DIR/object-lifetime-default-ambiguous.rs:33:27 + | +LL | fn a<'a,'b>(t: Ref2<'a,'b,Test>) { + | ^^^^ + +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound + --> $DIR/object-lifetime-default-ambiguous.rs:37:14 + | +LL | fn b(t: Ref2) { + | ^^^^ + +error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound + --> $DIR/object-lifetime-default-ambiguous.rs:53:15 + | +LL | fn f(t: &Ref2) { + | ^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0228`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-elision.nll.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-elision.nll.stderr new file mode 100644 index 00000000000..509d35a9433 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-elision.nll.stderr @@ -0,0 +1,24 @@ +warning: not reporting region error due to nll + --> $DIR/object-lifetime-default-elision.rs:81:5 + | +LL | ss + | ^^ + +error: unsatisfied lifetime constraints + --> $DIR/object-lifetime-default-elision.rs:64:53 + | +LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { + | __________--_--______________________________________^ + | | | | + | | | lifetime `'b` defined here + | | lifetime `'a` defined here +LL | | // Under old rules, the fully elaborated types of input/output were: +LL | | // +LL | | // for<'a,'b,'c>fn(&'a (SomeTrait+'c)) -> &'b (SomeTrait+'a) +... | +LL | | //~| ERROR cannot infer +LL | | } + | |_^ return requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-elision.rs b/src/test/ui/compile-fail-migration/object-lifetime-default-elision.rs new file mode 100644 index 00000000000..e37b6a2bb9c --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-elision.rs @@ -0,0 +1,87 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test various cases where the old rules under lifetime elision +// yield slightly different results than the new rules. + +#![allow(dead_code)] + +trait SomeTrait { + fn dummy(&self) { } +} + +struct SomeStruct<'a> { + r: Box +} + +fn deref(ss: &T) -> T { + // produces the type of a deref without worrying about whether a + // move out would actually be legal + loop { } +} + +fn load0<'a>(ss: &'a Box) -> Box { + // Under old rules, the fully elaborated types of input/output were: + // + // for<'a,'b> fn(&'a Box) -> Box + // + // Under new rules the result is: + // + // for<'a> fn(&'a Box) -> Box + // + // Therefore, no type error. + + deref(ss) +} + +fn load1(ss: &SomeTrait) -> &SomeTrait { + // Under old rules, the fully elaborated types of input/output were: + // + // for<'a,'b> fn(&'a (SomeTrait+'b)) -> &'a (SomeTrait+'a) + // + // Under new rules the result is: + // + // for<'a> fn(&'a (SomeTrait+'a)) -> &'a (SomeTrait+'a) + // + // In both cases, returning `ss` is legal. + + ss +} + +fn load2<'a>(ss: &'a SomeTrait) -> &SomeTrait { + // Same as `load1` but with an explicit name thrown in for fun. + + ss +} + +fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { + // Under old rules, the fully elaborated types of input/output were: + // + // for<'a,'b,'c>fn(&'a (SomeTrait+'c)) -> &'b (SomeTrait+'a) + // + // Based on the input/output types, the compiler could infer that + // 'c : 'a + // 'b : 'a + // must hold, and therefore it permitted `&'a (Sometrait+'c)` to be + // coerced to `&'b (SomeTrait+'a)`. + // + // Under the newer defaults, though, we get: + // + // for<'a,'b> fn(&'a (SomeTrait+'a)) -> &'b (SomeTrait+'b) + // + // which fails to type check. + + ss + //~^ ERROR cannot infer + //~| ERROR cannot infer +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-elision.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-elision.stderr new file mode 100644 index 00000000000..45e7d8451f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-elision.stderr @@ -0,0 +1,53 @@ +error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements + --> $DIR/object-lifetime-default-elision.rs:81:5 + | +LL | ss + | ^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 64:10... + --> $DIR/object-lifetime-default-elision.rs:64:10 + | +LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { + | ^^ +note: ...so that the type `(dyn SomeTrait + 'a)` is not borrowed for too long + --> $DIR/object-lifetime-default-elision.rs:81:5 + | +LL | ss + | ^^ +note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 64:13... + --> $DIR/object-lifetime-default-elision.rs:64:13 + | +LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { + | ^^ + = note: ...so that the expression is assignable: + expected &'b (dyn SomeTrait + 'b) + found &dyn SomeTrait + +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/object-lifetime-default-elision.rs:81:5 + | +LL | ss + | ^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 64:10... + --> $DIR/object-lifetime-default-elision.rs:64:10 + | +LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { + | ^^ +note: ...so that the declared lifetime parameter bounds are satisfied + --> $DIR/object-lifetime-default-elision.rs:81:5 + | +LL | ss + | ^^ +note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 64:13... + --> $DIR/object-lifetime-default-elision.rs:64:13 + | +LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { + | ^^ + = note: ...so that the expression is assignable: + expected &'b (dyn SomeTrait + 'b) + found &dyn SomeTrait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.nll.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.nll.stderr new file mode 100644 index 00000000000..5cfced1a72f --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.nll.stderr @@ -0,0 +1,45 @@ +warning: not reporting region error due to nll + --> $DIR/object-lifetime-default-from-box-error.rs:28:5 + | +LL | ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] + | ^^^^ + +warning: not reporting region error due to nll + --> $DIR/object-lifetime-default-from-box-error.rs:41:12 + | +LL | ss.r = b; //~ ERROR 41:12: 41:13: explicit lifetime required in the type of `ss` [E0621] + | ^ + +error[E0621]: explicit lifetime required in the type of `ss` + --> $DIR/object-lifetime-default-from-box-error.rs:24:48 + | +LL | fn load(ss: &mut SomeStruct) -> Box { + | _____________---------------____________________^ + | | | + | | help: add explicit lifetime `'static` to the type of `ss`: `&mut SomeStruct<'static>` +LL | | // `Box` defaults to a `'static` bound, so this return +LL | | // is illegal. +LL | | +LL | | ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] +LL | | } + | |_^ lifetime `'static` required + +error[E0507]: cannot move out of borrowed content + --> $DIR/object-lifetime-default-from-box-error.rs:28:5 + | +LL | ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] + | ^^^^ cannot move out of borrowed content + +error[E0621]: explicit lifetime required in the type of `ss` + --> $DIR/object-lifetime-default-from-box-error.rs:41:5 + | +LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { + | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` +... +LL | ss.r = b; //~ ERROR 41:12: 41:13: explicit lifetime required in the type of `ss` [E0621] + | ^^^^ lifetime `'b` required + +error: aborting due to 3 previous errors + +Some errors occurred: E0507, E0621. +For more information about an error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.rs b/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.rs new file mode 100644 index 00000000000..b253612bc32 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.rs @@ -0,0 +1,45 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test various cases where the defaults should lead to errors being +// reported. + +#![allow(dead_code)] + +trait SomeTrait { + fn dummy(&self) { } +} + +struct SomeStruct<'a> { + r: Box +} + +fn load(ss: &mut SomeStruct) -> Box { + // `Box` defaults to a `'static` bound, so this return + // is illegal. + + ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] +} + +fn store(ss: &mut SomeStruct, b: Box) { + // No error: b is bounded by 'static which outlives the + // (anonymous) lifetime on the struct. + + ss.r = b; +} + +fn store1<'b>(ss: &mut SomeStruct, b: Box) { + // Here we override the lifetimes explicitly, and so naturally we get an error. + + ss.r = b; //~ ERROR 41:12: 41:13: explicit lifetime required in the type of `ss` [E0621] +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.stderr new file mode 100644 index 00000000000..9972930c13e --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-box-error.stderr @@ -0,0 +1,21 @@ +error[E0621]: explicit lifetime required in the type of `ss` + --> $DIR/object-lifetime-default-from-box-error.rs:28:5 + | +LL | fn load(ss: &mut SomeStruct) -> Box { + | --------------- help: add explicit lifetime `'static` to the type of `ss`: `&mut SomeStruct<'static>` +... +LL | ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] + | ^^^^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `ss` + --> $DIR/object-lifetime-default-from-box-error.rs:41:12 + | +LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { + | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` +... +LL | ss.r = b; //~ ERROR 41:12: 41:13: explicit lifetime required in the type of `ss` [E0621] + | ^ lifetime `'b` required + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.nll.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.nll.stderr new file mode 100644 index 00000000000..42bcdf2bd8c --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:25:12 + | +LL | ss.t = t; //~ ERROR mismatched types + | ^ + +error: borrowed data escapes outside of function + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:25:5 + | +LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { + | - `t` is a reference that is only valid in the function body +LL | ss.t = t; //~ ERROR mismatched types + | ^^^^^^^^ `t` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.rs b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.rs new file mode 100644 index 00000000000..98301ef1a0a --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the lifetime from the enclosing `&` is "inherited" +// through the `Box` struct. + +#![allow(dead_code)] + +trait Test { + fn foo(&self) { } +} + +struct SomeStruct<'a> { + t: &'a Box, +} + +fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { + ss.t = t; //~ ERROR mismatched types +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.stderr new file mode 100644 index 00000000000..a59d8090baf --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-box-error.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:25:12 + | +LL | ss.t = t; //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `&'a std::boxed::Box<(dyn Test + 'static)>` + found type `&'a std::boxed::Box<(dyn Test + 'a)>` +note: the lifetime 'a as defined on the function body at 24:6... + --> $DIR/object-lifetime-default-from-rptr-box-error.rs:24:6 + | +LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.nll.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.nll.stderr new file mode 100644 index 00000000000..73b419d5113 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:31:12 + | +LL | ss.t = t; //~ ERROR mismatched types + | ^ + +error: borrowed data escapes outside of function + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:31:5 + | +LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { + | - `t` is a reference that is only valid in the function body +LL | ss.t = t; //~ ERROR mismatched types + | ^^^^^^^^ `t` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.rs b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.rs new file mode 100644 index 00000000000..836e4fa1142 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the lifetime from the enclosing `&` is "inherited" +// through the `MyBox` struct. + +#![allow(dead_code)] +#![feature(rustc_error)] + +trait Test { + fn foo(&self) { } +} + +struct SomeStruct<'a> { + t: &'a MyBox, + u: &'a MyBox, +} + +struct MyBox { + b: Box +} + +fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { + ss.t = t; //~ ERROR mismatched types +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.stderr new file mode 100644 index 00000000000..beda4df5295 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-from-rptr-struct-error.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:31:12 + | +LL | ss.t = t; //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `&'a MyBox<(dyn Test + 'static)>` + found type `&'a MyBox<(dyn Test + 'a)>` +note: the lifetime 'a as defined on the function body at 30:6... + --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:30:6 + | +LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.nll.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.nll.stderr new file mode 100644 index 00000000000..f76a03d078b --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.nll.stderr @@ -0,0 +1,33 @@ +warning: not reporting region error due to nll + --> $DIR/object-lifetime-default-mybox.rs:37:5 + | +LL | a //~ ERROR lifetime mismatch + | ^ + +warning: not reporting region error due to nll + --> $DIR/object-lifetime-default-mybox.rs:41:11 + | +LL | load0(ss) //~ ERROR mismatched types + | ^^ + +error: unsatisfied lifetime constraints + --> $DIR/object-lifetime-default-mybox.rs:37:5 + | +LL | fn load1<'a,'b>(a: &'a MyBox, + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | a //~ ERROR lifetime mismatch + | ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + +error: borrowed data escapes outside of function + --> $DIR/object-lifetime-default-mybox.rs:41:5 + | +LL | fn load2<'a>(ss: &MyBox) -> MyBox { + | -- `ss` is a reference that is only valid in the function body +LL | load0(ss) //~ ERROR mismatched types + | ^^^^^^^^^ `ss` escapes the function body here + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.rs b/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.rs new file mode 100644 index 00000000000..54657e76e97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.rs @@ -0,0 +1,45 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a "pass-through" object-lifetime-default that produces errors. + +#![allow(dead_code)] + +trait SomeTrait { + fn dummy(&self) { } +} + +struct MyBox { + r: Box +} + +fn deref(ss: &T) -> T { + // produces the type of a deref without worrying about whether a + // move out would actually be legal + loop { } +} + +fn load0(ss: &MyBox) -> MyBox { + deref(ss) +} + +fn load1<'a,'b>(a: &'a MyBox, + b: &'b MyBox) + -> &'b MyBox +{ + a //~ ERROR lifetime mismatch +} + +fn load2<'a>(ss: &MyBox) -> MyBox { + load0(ss) //~ ERROR mismatched types +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.stderr new file mode 100644 index 00000000000..ec003693617 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default-mybox.stderr @@ -0,0 +1,31 @@ +error[E0623]: lifetime mismatch + --> $DIR/object-lifetime-default-mybox.rs:37:5 + | +LL | fn load1<'a,'b>(a: &'a MyBox, + | -------------------- this parameter and the return type are declared with different lifetimes... +LL | b: &'b MyBox) +LL | -> &'b MyBox + | -------------------- +LL | { +LL | a //~ ERROR lifetime mismatch + | ^ ...but data from `a` is returned here + +error[E0308]: mismatched types + --> $DIR/object-lifetime-default-mybox.rs:41:11 + | +LL | load0(ss) //~ ERROR mismatched types + | ^^ lifetime mismatch + | + = note: expected type `&MyBox<(dyn SomeTrait + 'static)>` + found type `&MyBox<(dyn SomeTrait + 'a)>` +note: the lifetime 'a as defined on the function body at 40:10... + --> $DIR/object-lifetime-default-mybox.rs:40:10 + | +LL | fn load2<'a>(ss: &MyBox) -> MyBox { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to 2 previous errors + +Some errors occurred: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default.rs b/src/test/ui/compile-fail-migration/object-lifetime-default.rs new file mode 100644 index 00000000000..104e10f3207 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +#[rustc_object_lifetime_default] +struct A(T); //~ ERROR BaseDefault + +#[rustc_object_lifetime_default] +struct B<'a,T>(&'a (), T); //~ ERROR BaseDefault + +#[rustc_object_lifetime_default] +struct C<'a,T:'a>(&'a T); //~ ERROR 'a + +#[rustc_object_lifetime_default] +struct D<'a,'b,T:'a+'b>(&'a T, &'b T); //~ ERROR Ambiguous + +#[rustc_object_lifetime_default] +struct E<'a,'b:'a,T:'b>(&'a T, &'b T); //~ ERROR 'b + +#[rustc_object_lifetime_default] +struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U); //~ ERROR 'a,'b + +#[rustc_object_lifetime_default] +struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Ambiguous + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/object-lifetime-default.stderr b/src/test/ui/compile-fail-migration/object-lifetime-default.stderr new file mode 100644 index 00000000000..a7ff6cfd772 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-lifetime-default.stderr @@ -0,0 +1,44 @@ +error: BaseDefault + --> $DIR/object-lifetime-default.rs:14:1 + | +LL | struct A(T); //~ ERROR BaseDefault + | ^^^^^^^^^^^^^^^ + +error: BaseDefault + --> $DIR/object-lifetime-default.rs:17:1 + | +LL | struct B<'a,T>(&'a (), T); //~ ERROR BaseDefault + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: 'a + --> $DIR/object-lifetime-default.rs:20:1 + | +LL | struct C<'a,T:'a>(&'a T); //~ ERROR 'a + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Ambiguous + --> $DIR/object-lifetime-default.rs:23:1 + | +LL | struct D<'a,'b,T:'a+'b>(&'a T, &'b T); //~ ERROR Ambiguous + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: 'b + --> $DIR/object-lifetime-default.rs:26:1 + | +LL | struct E<'a,'b:'a,T:'b>(&'a T, &'b T); //~ ERROR 'b + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: 'a,'b + --> $DIR/object-lifetime-default.rs:29:1 + | +LL | struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U); //~ ERROR 'a,'b + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: 'a,Ambiguous + --> $DIR/object-lifetime-default.rs:32:1 + | +LL | struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Ambiguous + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/compile-fail-migration/object-pointer-types.rs b/src/test/ui/compile-fail-migration/object-pointer-types.rs new file mode 100644 index 00000000000..98c14cee942 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-pointer-types.rs @@ -0,0 +1,41 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +trait Foo { + fn borrowed(&self); + fn borrowed_mut(&mut self); + + fn owned(self: Box); +} + +fn borrowed_receiver(x: &Foo) { + x.borrowed(); + x.borrowed_mut(); // See [1] + x.owned(); //~ ERROR no method named `owned` found +} + +fn borrowed_mut_receiver(x: &mut Foo) { + x.borrowed(); + x.borrowed_mut(); + x.owned(); //~ ERROR no method named `owned` found +} + +fn owned_receiver(x: Box) { + x.borrowed(); + x.borrowed_mut(); // See [1] + x.managed(); //~ ERROR no method named `managed` found + x.owned(); +} + +fn main() {} + +// [1]: These cases are illegal, but the error is not detected +// until borrowck, so see the test borrowck-object-mutability.rs diff --git a/src/test/ui/compile-fail-migration/object-pointer-types.stderr b/src/test/ui/compile-fail-migration/object-pointer-types.stderr new file mode 100644 index 00000000000..5d8679b8aa5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-pointer-types.stderr @@ -0,0 +1,29 @@ +error[E0599]: no method named `owned` found for type `&dyn Foo` in the current scope + --> $DIR/object-pointer-types.rs:22:7 + | +LL | x.owned(); //~ ERROR no method named `owned` found + | ^^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `owned`, perhaps you need to implement it: + candidate #1: `Foo` + +error[E0599]: no method named `owned` found for type `&mut dyn Foo` in the current scope + --> $DIR/object-pointer-types.rs:28:7 + | +LL | x.owned(); //~ ERROR no method named `owned` found + | ^^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `owned`, perhaps you need to implement it: + candidate #1: `Foo` + +error[E0599]: no method named `managed` found for type `std::boxed::Box<(dyn Foo + 'static)>` in the current scope + --> $DIR/object-pointer-types.rs:34:7 + | +LL | x.managed(); //~ ERROR no method named `managed` found + | ^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.nll.stderr b/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.nll.stderr new file mode 100644 index 00000000000..cf0ee588263 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.nll.stderr @@ -0,0 +1,9 @@ +error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined + --> $DIR/object-safety-by-value-self-use.rs:25:5 + | +LL | t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.rs b/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.rs new file mode 100644 index 00000000000..e575bbb6cea --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that while a trait with by-value self is object-safe, we +// can't actually invoke it from an object (yet...?). + +#![feature(rustc_attrs)] + +trait Bar { + fn bar(self); +} + +trait Baz { + fn baz(self: Self); +} + +fn use_bar(t: Box) { + t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.stderr b/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.stderr new file mode 100644 index 00000000000..015284657af --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-by-value-self-use.stderr @@ -0,0 +1,9 @@ +error[E0161]: cannot move a value of type (dyn Bar + 'static): the size of (dyn Bar + 'static) cannot be statically determined + --> $DIR/object-safety-by-value-self-use.rs:25:5 + | +LL | t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/object-safety-by-value-self.rs b/src/test/ui/compile-fail-migration/object-safety-by-value-self.rs new file mode 100644 index 00000000000..5a8772d6142 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-by-value-self.rs @@ -0,0 +1,56 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that a trait with by-value self is considered object-safe. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(trivial_casts)] + +trait Bar { + fn bar(self); +} + +trait Baz { + fn baz(self: Self); +} + +trait Quux { + // Legal because of the where clause: + fn baz(self: Self) where Self : Sized; +} + +fn make_bar(t: &T) -> &Bar { + t // legal +} + +fn make_bar_explicit(t: &T) -> &Bar { + t as &Bar // legal +} + +fn make_baz(t: &T) -> &Baz { + t // legal +} + +fn make_baz_explicit(t: &T) -> &Baz { + t as &Baz // legal +} + +fn make_quux(t: &T) -> &Quux { + t +} + +fn make_quux_explicit(t: &T) -> &Quux { + t as &Quux +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful +} diff --git a/src/test/ui/compile-fail-migration/object-safety-by-value-self.stderr b/src/test/ui/compile-fail-migration/object-safety-by-value-self.stderr new file mode 100644 index 00000000000..61259641c0e --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-by-value-self.stderr @@ -0,0 +1,9 @@ +error: compilation successful + --> $DIR/object-safety-by-value-self.rs:55:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/object-safety-issue-22040.rs b/src/test/ui/compile-fail-migration/object-safety-issue-22040.rs new file mode 100644 index 00000000000..06d2441d3c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-issue-22040.rs @@ -0,0 +1,52 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #22040. + +use std::fmt::Debug; + +trait Expr: Debug + PartialEq { + fn print_element_count(&self); +} + +//#[derive(PartialEq)] +#[derive(Debug)] +struct SExpr<'x> { + elements: Vec>, + //~^ ERROR E0038 +} + +impl<'x> PartialEq for SExpr<'x> { + fn eq(&self, other:&SExpr<'x>) -> bool { + println!("L1: {} L2: {}", self.elements.len(), other.elements.len()); + + let result = self.elements.len() == other.elements.len(); + + println!("Got compare {}", result); + return result; + } +} + +impl <'x> SExpr<'x> { + fn new() -> SExpr<'x> { return SExpr{elements: Vec::new(),}; } +} + +impl <'x> Expr for SExpr<'x> { + fn print_element_count(&self) { + println!("element count: {}", self.elements.len()); + } +} + +fn main() { + let a: Box = Box::new(SExpr::new()); + let b: Box = Box::new(SExpr::new()); + + // assert_eq!(a , b); +} diff --git a/src/test/ui/compile-fail-migration/object-safety-issue-22040.stderr b/src/test/ui/compile-fail-migration/object-safety-issue-22040.stderr new file mode 100644 index 00000000000..b718e92fc47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-issue-22040.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `Expr` cannot be made into an object + --> $DIR/object-safety-issue-22040.rs:22:23 + | +LL | elements: Vec>, + | ^^^^^^^^ the trait `Expr` cannot be made into an object + | + = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/object-safety-no-static.rs b/src/test/ui/compile-fail-migration/object-safety-no-static.rs new file mode 100644 index 00000000000..dd1d5af3f4a --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-no-static.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we correctly prevent users from making trait objects +// from traits with static methods. + +trait Foo { + fn foo(); +} + +fn foo_implicit(b: Box) -> Box { + //~^ ERROR E0038 + loop { } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-safety-no-static.stderr b/src/test/ui/compile-fail-migration/object-safety-no-static.stderr new file mode 100644 index 00000000000..f17d2907148 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-no-static.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety-no-static.rs:18:1 + | +LL | fn foo_implicit(b: Box) -> Box { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object + | + = note: method `foo` has no receiver + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/object-safety-phantom-fn.rs b/src/test/ui/compile-fail-migration/object-safety-phantom-fn.rs new file mode 100644 index 00000000000..518c45ac9df --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-phantom-fn.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that `Self` appearing in a phantom fn does not make a trait not object safe. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait Baz { +} + +trait Bar { +} + +fn make_bar>(t: &T) -> &Bar { + t +} + +fn make_baz(t: &T) -> &Baz { + t +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful +} diff --git a/src/test/ui/compile-fail-migration/object-safety-phantom-fn.stderr b/src/test/ui/compile-fail-migration/object-safety-phantom-fn.stderr new file mode 100644 index 00000000000..645867f4606 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-phantom-fn.stderr @@ -0,0 +1,9 @@ +error: compilation successful + --> $DIR/object-safety-phantom-fn.rs:31:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/object-safety-sized-2.rs b/src/test/ui/compile-fail-migration/object-safety-sized-2.rs new file mode 100644 index 00000000000..3e1942d5a01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-sized-2.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we correctly prevent users from making trait objects +// from traits where `Self : Sized`. + +trait Bar + where Self : Sized +{ + fn bar(&self, t: T); +} + +fn make_bar(t: &T) -> &Bar { + //~^ ERROR E0038 + loop { } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/object-safety-sized-2.stderr b/src/test/ui/compile-fail-migration/object-safety-sized-2.stderr new file mode 100644 index 00000000000..1e179b662b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/object-safety-sized-2.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `Bar` cannot be made into an object + --> $DIR/object-safety-sized-2.rs:20:1 + | +LL | fn make_bar(t: &T) -> &Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object + | + = note: the trait cannot require that `Self : Sized` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/occurs-check-2.rs b/src/test/ui/compile-fail-migration/occurs-check-2.rs new file mode 100644 index 00000000000..5d162fe944e --- /dev/null +++ b/src/test/ui/compile-fail-migration/occurs-check-2.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn main() { + let f; + let g; + g = f; + f = box g; + //~^ ERROR mismatched types + //~| cyclic type of infinite size +} diff --git a/src/test/ui/compile-fail-migration/occurs-check-2.stderr b/src/test/ui/compile-fail-migration/occurs-check-2.stderr new file mode 100644 index 00000000000..547491c395b --- /dev/null +++ b/src/test/ui/compile-fail-migration/occurs-check-2.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/occurs-check-2.rs:17:9 + | +LL | f = box g; + | ^^^^^ + | | + | cyclic type of infinite size + | help: try using a conversion method: `box g.to_string()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/occurs-check-3.rs b/src/test/ui/compile-fail-migration/occurs-check-3.rs new file mode 100644 index 00000000000..ba7688e8524 --- /dev/null +++ b/src/test/ui/compile-fail-migration/occurs-check-3.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:mismatched types +// From Issue #778 +enum clam { a(T), } +fn main() { let c; c = clam::a(c); match c { clam::a::(_) => { } } } diff --git a/src/test/ui/compile-fail-migration/occurs-check-3.stderr b/src/test/ui/compile-fail-migration/occurs-check-3.stderr new file mode 100644 index 00000000000..1483d41d723 --- /dev/null +++ b/src/test/ui/compile-fail-migration/occurs-check-3.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/occurs-check-3.rs:14:24 + | +LL | fn main() { let c; c = clam::a(c); match c { clam::a::(_) => { } } } + | ^^^^^^^^^^ cyclic type of infinite size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/occurs-check.rs b/src/test/ui/compile-fail-migration/occurs-check.rs new file mode 100644 index 00000000000..2c784365ea9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/occurs-check.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn main() { + let f; + f = box f; + //~^ ERROR mismatched types + //~| cyclic type of infinite size +} diff --git a/src/test/ui/compile-fail-migration/occurs-check.stderr b/src/test/ui/compile-fail-migration/occurs-check.stderr new file mode 100644 index 00000000000..c6994d0c537 --- /dev/null +++ b/src/test/ui/compile-fail-migration/occurs-check.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/occurs-check.rs:15:9 + | +LL | f = box f; + | ^^^^^ + | | + | cyclic type of infinite size + | help: try using a conversion method: `box f.to_string()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.rs b/src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.rs new file mode 100644 index 00000000000..9a71dc98014 --- /dev/null +++ b/src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let a = 1_is; //~ ERROR invalid suffix + let b = 2_us; //~ ERROR invalid suffix +} diff --git a/src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.stderr b/src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.stderr new file mode 100644 index 00000000000..d580a18f46b --- /dev/null +++ b/src/test/ui/compile-fail-migration/old-suffixes-are-really-forbidden.stderr @@ -0,0 +1,18 @@ +error: invalid suffix `is` for numeric literal + --> $DIR/old-suffixes-are-really-forbidden.rs:12:13 + | +LL | let a = 1_is; //~ ERROR invalid suffix + | ^^^^ + | + = help: the suffix must be one of the integral types (`u32`, `isize`, etc) + +error: invalid suffix `us` for numeric literal + --> $DIR/old-suffixes-are-really-forbidden.rs:13:13 + | +LL | let b = 2_us; //~ ERROR invalid suffix + | ^^^^ + | + = help: the suffix must be one of the integral types (`u32`, `isize`, etc) + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.rs b/src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.rs new file mode 100644 index 00000000000..6441f308f29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.rs @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Testing guarantees provided by once functions. +// This program would segfault if it were legal. + +#![feature(once_fns)] +use std::sync::Arc; + +fn foo(blk: F) { + blk(); + blk(); //~ ERROR use of moved value +} + +fn main() { + let x = Arc::new(true); + foo(move|| { + assert!(*x); + drop(x); + }); +} diff --git a/src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.stderr b/src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.stderr new file mode 100644 index 00000000000..81a501f5680 --- /dev/null +++ b/src/test/ui/compile-fail-migration/once-cant-call-twice-on-heap.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `blk` + --> $DIR/once-cant-call-twice-on-heap.rs:19:5 + | +LL | blk(); + | --- value moved here +LL | blk(); //~ ERROR use of moved value + | ^^^ value used here after move + | + = note: move occurs because `blk` has type `F`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/opt-in-copy.rs b/src/test/ui/compile-fail-migration/opt-in-copy.rs new file mode 100644 index 00000000000..bc18b52a0c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/opt-in-copy.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct CantCopyThis; + +struct IWantToCopyThis { + but_i_cant: CantCopyThis, +} + +impl Copy for IWantToCopyThis {} +//~^ ERROR the trait `Copy` may not be implemented for this type + +enum CantCopyThisEither { + A, + B, +} + +enum IWantToCopyThisToo { + ButICant(CantCopyThisEither), +} + +impl Copy for IWantToCopyThisToo {} +//~^ ERROR the trait `Copy` may not be implemented for this type + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/opt-in-copy.stderr b/src/test/ui/compile-fail-migration/opt-in-copy.stderr new file mode 100644 index 00000000000..c6440804be6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/opt-in-copy.stderr @@ -0,0 +1,21 @@ +error[E0204]: the trait `Copy` may not be implemented for this type + --> $DIR/opt-in-copy.rs:17:6 + | +LL | but_i_cant: CantCopyThis, + | ------------------------ this field does not implement `Copy` +... +LL | impl Copy for IWantToCopyThis {} + | ^^^^ + +error[E0204]: the trait `Copy` may not be implemented for this type + --> $DIR/opt-in-copy.rs:29:6 + | +LL | ButICant(CantCopyThisEither), + | ------------------ this field does not implement `Copy` +... +LL | impl Copy for IWantToCopyThisToo {} + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0204`. diff --git a/src/test/ui/compile-fail-migration/or-patter-mismatch.rs b/src/test/ui/compile-fail-migration/or-patter-mismatch.rs new file mode 100644 index 00000000000..59508d6ac95 --- /dev/null +++ b/src/test/ui/compile-fail-migration/or-patter-mismatch.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types + +enum blah { a(isize, isize, usize), b(isize, isize), } + +fn main() { match blah::a(1, 1, 2) { blah::a(_, x, y) | blah::b(x, y) => { } } } diff --git a/src/test/ui/compile-fail-migration/or-patter-mismatch.stderr b/src/test/ui/compile-fail-migration/or-patter-mismatch.stderr new file mode 100644 index 00000000000..8bf4d2e5332 --- /dev/null +++ b/src/test/ui/compile-fail-migration/or-patter-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/or-patter-mismatch.rs:15:68 + | +LL | fn main() { match blah::a(1, 1, 2) { blah::a(_, x, y) | blah::b(x, y) => { } } } + | ^ expected usize, found isize + | + = note: expected type `usize` + found type `isize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/orphan-check-diagnostics.rs b/src/test/ui/compile-fail-migration/orphan-check-diagnostics.rs new file mode 100644 index 00000000000..8201565c331 --- /dev/null +++ b/src/test/ui/compile-fail-migration/orphan-check-diagnostics.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:orphan_check_diagnostics.rs +// see #22388 + +extern crate orphan_check_diagnostics; + +use orphan_check_diagnostics::RemoteTrait; + +trait LocalTrait { fn dummy(&self) { } } + +impl RemoteTrait for T where T: LocalTrait {} +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/orphan-check-diagnostics.stderr b/src/test/ui/compile-fail-migration/orphan-check-diagnostics.stderr new file mode 100644 index 00000000000..dc134dd8d6f --- /dev/null +++ b/src/test/ui/compile-fail-migration/orphan-check-diagnostics.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/orphan-check-diagnostics.rs:20:1 + | +LL | impl RemoteTrait for T where T: LocalTrait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/osx-frameworks.rs b/src/test/ui/compile-fail-migration/osx-frameworks.rs new file mode 100644 index 00000000000..026ef3c95f6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/osx-frameworks.rs @@ -0,0 +1,18 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-macos this is supposed to succeed on osx + +#[link(name = "foo", kind = "framework")] +extern {} +//~^^ ERROR: native frameworks are only available on macOS + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/osx-frameworks.stderr b/src/test/ui/compile-fail-migration/osx-frameworks.stderr new file mode 100644 index 00000000000..cdc2357c36c --- /dev/null +++ b/src/test/ui/compile-fail-migration/osx-frameworks.stderr @@ -0,0 +1,9 @@ +error[E0455]: native frameworks are only available on macOS targets + --> $DIR/osx-frameworks.rs:13:1 + | +LL | #[link(name = "foo", kind = "framework")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0455`. diff --git a/src/test/ui/compile-fail-migration/out-of-order-shadowing.rs b/src/test/ui/compile-fail-migration/out-of-order-shadowing.rs new file mode 100644 index 00000000000..1fafaf85112 --- /dev/null +++ b/src/test/ui/compile-fail-migration/out-of-order-shadowing.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:define_macro.rs +// error-pattern: `bar` is already in scope + +macro_rules! bar { () => {} } +define_macro!(bar); +bar!(); + +macro_rules! m { () => { #[macro_use] extern crate define_macro; } } +m!(); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/out-of-order-shadowing.stderr b/src/test/ui/compile-fail-migration/out-of-order-shadowing.stderr new file mode 100644 index 00000000000..78e32e23ff6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/out-of-order-shadowing.stderr @@ -0,0 +1,11 @@ +error: `bar` is already in scope + --> $DIR/out-of-order-shadowing.rs:15:1 + | +LL | define_macro!(bar); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: macro-expanded `macro_rules!`s may not shadow existing macros (see RFC 1560) + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/output-type-mismatch.rs b/src/test/ui/compile-fail-migration/output-type-mismatch.rs new file mode 100644 index 00000000000..158e99ac200 --- /dev/null +++ b/src/test/ui/compile-fail-migration/output-type-mismatch.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types + +fn f() { } + +fn main() { let i: isize; i = f(); } diff --git a/src/test/ui/compile-fail-migration/output-type-mismatch.stderr b/src/test/ui/compile-fail-migration/output-type-mismatch.stderr new file mode 100644 index 00000000000..e869dfa78a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/output-type-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/output-type-mismatch.rs:15:31 + | +LL | fn main() { let i: isize; i = f(); } + | ^^^ expected isize, found () + | + = note: expected type `isize` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/overlap-marker-trait.rs b/src/test/ui/compile-fail-migration/overlap-marker-trait.rs new file mode 100644 index 00000000000..a649ae25f34 --- /dev/null +++ b/src/test/ui/compile-fail-migration/overlap-marker-trait.rs @@ -0,0 +1,41 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for RFC 1268: we allow overlapping impls of marker traits, +// that is, traits without items. In this case, a type `T` is +// `MyMarker` if it is either `Debug` or `Display`. This test just +// checks that we don't consider **all** types to be `MyMarker`. See +// also the companion test in +// `run-pass/overlap-permitted-for-marker-traits.rs`. + +#![feature(overlapping_marker_traits)] +#![feature(optin_builtin_traits)] + +use std::fmt::{Debug, Display}; + +trait Marker {} + +impl Marker for T {} +impl Marker for T {} + +fn is_marker() { } + +struct NotDebugOrDisplay; + +fn main() { + // Debug && Display: + is_marker::(); + + // Debug && !Display: + is_marker::>(); + + // !Debug && !Display + is_marker::(); //~ ERROR +} diff --git a/src/test/ui/compile-fail-migration/overlap-marker-trait.stderr b/src/test/ui/compile-fail-migration/overlap-marker-trait.stderr new file mode 100644 index 00000000000..d739dfc59d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/overlap-marker-trait.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied + --> $DIR/overlap-marker-trait.rs:40:5 + | +LL | is_marker::(); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` + | +note: required by `is_marker` + --> $DIR/overlap-marker-trait.rs:28:1 + | +LL | fn is_marker() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/overloaded-calls-nontuple.rs b/src/test/ui/compile-fail-migration/overloaded-calls-nontuple.rs new file mode 100644 index 00000000000..7113224664b --- /dev/null +++ b/src/test/ui/compile-fail-migration/overloaded-calls-nontuple.rs @@ -0,0 +1,37 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(fn_traits, unboxed_closures)] + +use std::ops::FnMut; + +struct S { + x: isize, + y: isize, +} + +impl FnMut for S { + extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { + self.x + self.y + z + } +} + +impl FnOnce for S { + type Output = isize; + extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } +} + +fn main() { + let mut s = S { + x: 1, + y: 2, + }; + drop(s(3)) //~ ERROR cannot use call notation +} diff --git a/src/test/ui/compile-fail-migration/overloaded-calls-nontuple.stderr b/src/test/ui/compile-fail-migration/overloaded-calls-nontuple.stderr new file mode 100644 index 00000000000..78b86889553 --- /dev/null +++ b/src/test/ui/compile-fail-migration/overloaded-calls-nontuple.stderr @@ -0,0 +1,9 @@ +error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit + --> $DIR/overloaded-calls-nontuple.rs:36:10 + | +LL | drop(s(3)) //~ ERROR cannot use call notation + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0059`. diff --git a/src/test/ui/compile-fail-migration/packed-struct-generic-transmute.rs b/src/test/ui/compile-fail-migration/packed-struct-generic-transmute.rs new file mode 100644 index 00000000000..c96184d5988 --- /dev/null +++ b/src/test/ui/compile-fail-migration/packed-struct-generic-transmute.rs @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This assumes the packed and non-packed structs are different sizes. + +// the error points to the start of the file, not the line with the +// transmute + +// error-pattern: transmute called with types of different sizes + +use std::mem; + +#[repr(packed)] +struct Foo { + bar: T, + baz: S +} + +struct Oof { + rab: T, + zab: S +} + +fn main() { + let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 }; + unsafe { + let oof: Oof<[u8; 5], i32> = mem::transmute(foo); + println!("{:?} {:?}", &oof.rab[..], oof.zab); + } +} diff --git a/src/test/ui/compile-fail-migration/packed-struct-generic-transmute.stderr b/src/test/ui/compile-fail-migration/packed-struct-generic-transmute.stderr new file mode 100644 index 00000000000..397b1ddba71 --- /dev/null +++ b/src/test/ui/compile-fail-migration/packed-struct-generic-transmute.stderr @@ -0,0 +1,12 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/packed-struct-generic-transmute.rs:34:38 + | +LL | let oof: Oof<[u8; 5], i32> = mem::transmute(foo); + | ^^^^^^^^^^^^^^ + | + = note: source type: Foo<[u8; 5], i32> (72 bits) + = note: target type: Oof<[u8; 5], i32> (96 bits) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/compile-fail-migration/packed-struct-transmute.rs b/src/test/ui/compile-fail-migration/packed-struct-transmute.rs new file mode 100644 index 00000000000..abb02dd39e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/packed-struct-transmute.rs @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This assumes the packed and non-packed structs are different sizes. + +// the error points to the start of the file, not the line with the +// transmute + +// error-pattern: transmute called with types of different sizes + +use std::mem; + +#[repr(packed)] +struct Foo { + bar: u8, + baz: usize +} + +#[derive(Debug)] +struct Oof { + rab: u8, + zab: usize +} + +fn main() { + let foo = Foo { bar: 1, baz: 10 }; + unsafe { + let oof: Oof = mem::transmute(foo); + println!("{:?}", oof); + } +} diff --git a/src/test/ui/compile-fail-migration/packed-struct-transmute.stderr b/src/test/ui/compile-fail-migration/packed-struct-transmute.stderr new file mode 100644 index 00000000000..6158dea524e --- /dev/null +++ b/src/test/ui/compile-fail-migration/packed-struct-transmute.stderr @@ -0,0 +1,12 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/packed-struct-transmute.rs:35:24 + | +LL | let oof: Oof = mem::transmute(foo); + | ^^^^^^^^^^^^^^ + | + = note: source type: Foo (72 bits) + = note: target type: Oof (128 bits) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.rs b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.rs new file mode 100644 index 00000000000..fec11fdbd7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(panic_implementation)] +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic( + info: PanicInfo, //~ ERROR argument should be `&PanicInfo` +) -> () //~ ERROR return type should be `!` +{ +} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.stderr b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.stderr new file mode 100644 index 00000000000..0e020fbc78b --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-1.stderr @@ -0,0 +1,14 @@ +error: return type should be `!` + --> $DIR/panic-implementation-bad-signature-1.rs:22:6 + | +LL | ) -> () //~ ERROR return type should be `!` + | ^^ + +error: argument should be `&PanicInfo` + --> $DIR/panic-implementation-bad-signature-1.rs:21:11 + | +LL | info: PanicInfo, //~ ERROR argument should be `&PanicInfo` + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.rs b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.rs new file mode 100644 index 00000000000..2a628c05699 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.rs @@ -0,0 +1,25 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(panic_implementation)] +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic( + info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo` +) -> ! +{ + loop {} +} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.stderr b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.stderr new file mode 100644 index 00000000000..71ed1efdcf2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-2.stderr @@ -0,0 +1,8 @@ +error: argument should be `&PanicInfo` + --> $DIR/panic-implementation-bad-signature-2.rs:21:11 + | +LL | info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo` + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.rs b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.rs new file mode 100644 index 00000000000..29337025b70 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(panic_implementation)] +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic() -> ! { //~ ERROR function should have one argument + loop {} +} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.stderr b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.stderr new file mode 100644 index 00000000000..3fd29bcd3e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-3.stderr @@ -0,0 +1,10 @@ +error: function should have one argument + --> $DIR/panic-implementation-bad-signature-3.rs:20:1 + | +LL | / fn panic() -> ! { //~ ERROR function should have one argument +LL | | loop {} +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.rs b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.rs new file mode 100644 index 00000000000..d5f942ba2d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(panic_implementation)] +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic(pi: &PanicInfo) -> ! { + //~^ ERROR `#[panic_implementation]` function should have no type parameters + loop {} +} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.stderr b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.stderr new file mode 100644 index 00000000000..362be2fc3b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-bad-signature-4.stderr @@ -0,0 +1,11 @@ +error: `#[panic_implementation]` function should have no type parameters + --> $DIR/panic-implementation-bad-signature-4.rs:20:1 + | +LL | / fn panic(pi: &PanicInfo) -> ! { +LL | | //~^ ERROR `#[panic_implementation]` function should have no type parameters +LL | | loop {} +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-implementation-duplicate.rs b/src/test/ui/compile-fail-migration/panic-implementation-duplicate.rs new file mode 100644 index 00000000000..017113af409 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-duplicate.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(lang_items)] +#![feature(panic_implementation)] +#![no_std] +#![no_main] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: &PanicInfo) -> ! { + loop {} +} + +#[lang = "panic_impl"] +fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`. + loop {} +} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-duplicate.stderr b/src/test/ui/compile-fail-migration/panic-implementation-duplicate.stderr new file mode 100644 index 00000000000..d553c02379c --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-duplicate.stderr @@ -0,0 +1,19 @@ +error[E0152]: duplicate lang item found: `panic_impl`. + --> $DIR/panic-implementation-duplicate.rs:26:1 + | +LL | / fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`. +LL | | loop {} +LL | | } + | |_^ + | +note: first defined here. + --> $DIR/panic-implementation-duplicate.rs:21:1 + | +LL | / fn panic(info: &PanicInfo) -> ! { +LL | | loop {} +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0152`. diff --git a/src/test/ui/compile-fail-migration/panic-implementation-missing.rs b/src/test/ui/compile-fail-migration/panic-implementation-missing.rs new file mode 100644 index 00000000000..b11081a3e3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-missing.rs @@ -0,0 +1,18 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: `#[panic_implementation]` function required, but not found + +#![feature(lang_items)] +#![no_main] +#![no_std] + +#[lang = "eh_personality"] +fn eh() {} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-missing.stderr b/src/test/ui/compile-fail-migration/panic-implementation-missing.stderr new file mode 100644 index 00000000000..e813338dcc0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-missing.stderr @@ -0,0 +1,4 @@ +error: `#[panic_implementation]` function required, but not found + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.rs b/src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.rs new file mode 100644 index 00000000000..597f44d9832 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.rs @@ -0,0 +1,26 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort +// error-pattern: language item required, but not found: `panic_info` + +#![feature(lang_items)] +#![feature(no_core)] +#![feature(panic_implementation)] +#![no_core] +#![no_main] + +#[panic_implementation] +fn panic() -> ! { + loop {} +} + +#[lang = "sized"] +trait Sized {} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.stderr b/src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.stderr new file mode 100644 index 00000000000..2bae12efbde --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-requires-panic-info.stderr @@ -0,0 +1,4 @@ +error: language item required, but not found: `panic_info` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-implementation-std.rs b/src/test/ui/compile-fail-migration/panic-implementation-std.rs new file mode 100644 index 00000000000..f25cd3605c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-std.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: duplicate lang item found: `panic_impl`. + +#![feature(panic_implementation)] + +use std::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: PanicInfo) -> ! { + loop {} +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-std.stderr b/src/test/ui/compile-fail-migration/panic-implementation-std.stderr new file mode 100644 index 00000000000..5016d502cee --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-std.stderr @@ -0,0 +1,13 @@ +error[E0152]: duplicate lang item found: `panic_impl`. + --> $DIR/panic-implementation-std.rs:18:1 + | +LL | / fn panic(info: PanicInfo) -> ! { +LL | | loop {} +LL | | } + | |_^ + | + = note: first defined in crate `std`. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0152`. diff --git a/src/test/ui/compile-fail-migration/panic-implementation-twice.rs b/src/test/ui/compile-fail-migration/panic-implementation-twice.rs new file mode 100644 index 00000000000..78dc545c036 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-twice.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:some-panic-impl.rs + +#![feature(panic_implementation)] +#![feature(lang_items)] +#![no_std] +#![no_main] + +extern crate some_panic_impl; + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: &PanicInfo) -> ! { + //~^ error duplicate lang item found: `panic_impl` + loop {} +} + +#[lang = "eh_personality"] +fn eh() {} diff --git a/src/test/ui/compile-fail-migration/panic-implementation-twice.stderr b/src/test/ui/compile-fail-migration/panic-implementation-twice.stderr new file mode 100644 index 00000000000..3cb6ebeb59a --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-implementation-twice.stderr @@ -0,0 +1,14 @@ +error[E0152]: duplicate lang item found: `panic_impl`. + --> $DIR/panic-implementation-twice.rs:23:1 + | +LL | / fn panic(info: &PanicInfo) -> ! { +LL | | //~^ error duplicate lang item found: `panic_impl` +LL | | loop {} +LL | | } + | |_^ + | + = note: first defined in crate `some_panic_impl`. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0152`. diff --git a/src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.rs b/src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.rs new file mode 100644 index 00000000000..f392ccd7676 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort -C prefer-dynamic +// ignore-musl - no dylibs here +// ignore-cloudabi +// ignore-emscripten +// error-pattern:`panic_unwind` is not compiled with this crate's panic strategy + +// This is a test where the local crate, compiled with `panic=abort`, links to +// the standard library **dynamically** which is already linked against +// `panic=unwind`. We should fail because the linked panic runtime does not +// correspond with our `-C panic` option. +// +// Note that this test assumes that the dynamic version of the standard library +// is linked to `panic_unwind`, which is currently the case. + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.stderr b/src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.stderr new file mode 100644 index 00000000000..704b81ae1ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/abort-link-to-unwind-dylib.stderr @@ -0,0 +1,4 @@ +error: the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/depends.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/depends.rs new file mode 100644 index 00000000000..b90dec9281b --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/depends.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] +#![panic_runtime] +#![no_std] + +extern crate needs_panic_runtime; diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/needs-panic-runtime.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/needs-panic-runtime.rs new file mode 100644 index 00000000000..d6c21fecf6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/needs-panic-runtime.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![feature(needs_panic_runtime)] +#![crate_type = "rlib"] +#![needs_panic_runtime] +#![no_std] diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-abort.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-abort.rs new file mode 100644 index 00000000000..3b74156b6b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-abort.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] + +#![no_std] +#![panic_runtime] + +#[no_mangle] +pub extern fn __rust_maybe_catch_panic() {} + +#[no_mangle] +pub extern fn __rust_start_panic() {} + +#[no_mangle] +pub extern fn rust_eh_personality() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-lang-items.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-lang-items.rs new file mode 100644 index 00000000000..d9848a554ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-lang-items.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +#![no_std] +#![feature(lang_items)] + +use core::panic::PanicInfo; + +#[lang = "panic_impl"] +fn panic_impl(info: &PanicInfo) -> ! { loop {} } +#[lang = "eh_personality"] +fn eh_personality() {} +#[lang = "eh_unwind_resume"] +fn eh_unwind_resume() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind.rs new file mode 100644 index 00000000000..4bb36839d98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=unwind +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] + +#![no_std] +#![panic_runtime] + +#[no_mangle] +pub extern fn __rust_maybe_catch_panic() {} + +#[no_mangle] +pub extern fn __rust_start_panic() {} + +#[no_mangle] +pub extern fn rust_eh_personality() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind2.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind2.rs new file mode 100644 index 00000000000..4bb36839d98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/panic-runtime-unwind2.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=unwind +// no-prefer-dynamic + +#![feature(panic_runtime)] +#![crate_type = "rlib"] + +#![no_std] +#![panic_runtime] + +#[no_mangle] +pub extern fn __rust_maybe_catch_panic() {} + +#[no_mangle] +pub extern fn __rust_start_panic() {} + +#[no_mangle] +pub extern fn rust_eh_personality() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-abort.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-abort.rs new file mode 100644 index 00000000000..e1902e44a60 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-abort.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![no_std] + +extern crate panic_runtime_abort; diff --git a/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs new file mode 100644 index 00000000000..2183338b249 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![no_std] + +extern crate panic_runtime_unwind; diff --git a/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.rs b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.rs new file mode 100644 index 00000000000..f067b6b8349 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=foo +// error-pattern:either `panic` or `abort` was expected + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.stderr b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.stderr new file mode 100644 index 00000000000..3a65419c98f --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag1.stderr @@ -0,0 +1,2 @@ +error: incorrect value `foo` for codegen option `panic` - either `panic` or `abort` was expected + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.rs b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.rs new file mode 100644 index 00000000000..0ecf65f080f --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic +// error-pattern:requires either `panic` or `abort` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.stderr b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.stderr new file mode 100644 index 00000000000..8d919e55c90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/bad-panic-flag2.stderr @@ -0,0 +1,2 @@ +error: codegen option `panic` requires either `panic` or `abort` (C panic=) + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.rs b/src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.rs new file mode 100644 index 00000000000..71751034c39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:is not compiled with this crate's panic strategy `abort` +// compile-flags:-C panic=abort +// ignore-wasm32-bare compiled with panic=abort by default + +#![feature(test)] + +extern crate test; + +fn main() { +} + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.stderr b/src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.stderr new file mode 100644 index 00000000000..704b81ae1ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/libtest-unwinds.stderr @@ -0,0 +1,4 @@ +error: the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/needs-gate.rs b/src/test/ui/compile-fail-migration/panic-runtime/needs-gate.rs new file mode 100644 index 00000000000..1b3b978c408 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/needs-gate.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// gate-test-needs_panic_runtime +// gate-test-panic_runtime + +#![panic_runtime] //~ ERROR: is an experimental feature +#![needs_panic_runtime] //~ ERROR: is an experimental feature + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/needs-gate.stderr b/src/test/ui/compile-fail-migration/panic-runtime/needs-gate.stderr new file mode 100644 index 00000000000..aa2b97556dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/needs-gate.stderr @@ -0,0 +1,19 @@ +error[E0658]: the `#[panic_runtime]` attribute is an experimental feature (see issue #32837) + --> $DIR/needs-gate.rs:14:1 + | +LL | #![panic_runtime] //~ ERROR: is an experimental feature + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(panic_runtime)] to the crate attributes to enable + +error[E0658]: the `#[needs_panic_runtime]` attribute is an experimental feature (see issue #32837) + --> $DIR/needs-gate.rs:15:1 + | +LL | #![needs_panic_runtime] //~ ERROR: is an experimental feature + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(needs_panic_runtime)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.rs b/src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.rs new file mode 100644 index 00000000000..7cfdacbd983 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:needs-panic-runtime.rs +// aux-build:depends.rs +// error-pattern:cannot depend on a crate that needs a panic runtime + +extern crate depends; diff --git a/src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.stderr b/src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.stderr new file mode 100644 index 00000000000..0e68c9b806d --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/runtime-depend-on-needs-runtime.stderr @@ -0,0 +1,9 @@ +error: the crate `depends` cannot depend on a crate that needs a panic runtime, but it depends on `needs_panic_runtime` + +error[E0601]: `main` function not found in crate `runtime_depend_on_needs_runtime` + | + = note: consider adding a `main` function to `$DIR/runtime-depend-on-needs-runtime.rs` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.rs b/src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.rs new file mode 100644 index 00000000000..f886aac9a10 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:panic-runtime-unwind.rs +// aux-build:panic-runtime-abort.rs +// aux-build:wants-panic-runtime-unwind.rs +// aux-build:wants-panic-runtime-abort.rs +// aux-build:panic-runtime-lang-items.rs +// error-pattern: is not compiled with this crate's panic strategy `unwind` +// ignore-wasm32-bare compiled with panic=abort by default + +#![no_std] + +extern crate wants_panic_runtime_unwind; +extern crate wants_panic_runtime_abort; +extern crate panic_runtime_lang_items; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.stderr b/src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.stderr new file mode 100644 index 00000000000..4af754c81f9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/transitive-link-a-bunch.stderr @@ -0,0 +1,10 @@ +error: cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_abort + +error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind` + +error: the crate `wants_panic_runtime_abort` is compiled with the panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: the crate `panic_runtime_abort` is compiled with the panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.rs b/src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.rs new file mode 100644 index 00000000000..0fe0da2fa2c --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2 +// ignore-tidy-linelength +// aux-build:panic-runtime-unwind.rs +// aux-build:panic-runtime-unwind2.rs +// aux-build:panic-runtime-lang-items.rs + +#![no_std] + +extern crate panic_runtime_unwind; +extern crate panic_runtime_unwind2; +extern crate panic_runtime_lang_items; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.stderr b/src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.stderr new file mode 100644 index 00000000000..0c81a103049 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/two-panic-runtimes.stderr @@ -0,0 +1,4 @@ +error: cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2 + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.rs b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.rs new file mode 100644 index 00000000000..b178006411b --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:is not compiled with this crate's panic strategy `abort` +// aux-build:panic-runtime-unwind.rs +// compile-flags:-C panic=abort + +extern crate panic_runtime_unwind; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.stderr b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.stderr new file mode 100644 index 00000000000..69064b75ac5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind.stderr @@ -0,0 +1,6 @@ +error: cannot link together two panic runtimes: panic_unwind and panic_runtime_unwind + +error: the linked panic runtime `panic_runtime_unwind` is not compiled with this crate's panic strategy `abort` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.rs b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.rs new file mode 100644 index 00000000000..de8e010c3cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:is not compiled with this crate's panic strategy `abort` +// aux-build:panic-runtime-unwind.rs +// aux-build:wants-panic-runtime-unwind.rs +// compile-flags:-C panic=abort + +extern crate wants_panic_runtime_unwind; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.stderr b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.stderr new file mode 100644 index 00000000000..69064b75ac5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-abort-got-unwind2.stderr @@ -0,0 +1,6 @@ +error: cannot link together two panic runtimes: panic_unwind and panic_runtime_unwind + +error: the linked panic runtime `panic_runtime_unwind` is not compiled with this crate's panic strategy `abort` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.rs b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.rs new file mode 100644 index 00000000000..dda92d9a560 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:is incompatible with this crate's strategy of `unwind` +// aux-build:panic-runtime-abort.rs +// aux-build:panic-runtime-lang-items.rs +// ignore-wasm32-bare compiled with panic=abort by default + +#![no_std] + +extern crate panic_runtime_abort; +extern crate panic_runtime_lang_items; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.stderr b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.stderr new file mode 100644 index 00000000000..d4fd2cca81f --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort.stderr @@ -0,0 +1,6 @@ +error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind` + +error: the crate `panic_runtime_abort` is compiled with the panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.rs b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.rs new file mode 100644 index 00000000000..49f719057d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:is incompatible with this crate's strategy of `unwind` +// aux-build:panic-runtime-abort.rs +// aux-build:wants-panic-runtime-abort.rs +// aux-build:panic-runtime-lang-items.rs +// ignore-wasm32-bare compiled with panic=abort by default + +#![no_std] + +extern crate wants_panic_runtime_abort; +extern crate panic_runtime_lang_items; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.stderr b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.stderr new file mode 100644 index 00000000000..364a27a24eb --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic-runtime/want-unwind-got-abort2.stderr @@ -0,0 +1,8 @@ +error: the linked panic runtime `panic_runtime_abort` is not compiled with this crate's panic strategy `unwind` + +error: the crate `wants_panic_runtime_abort` is compiled with the panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: the crate `panic_runtime_abort` is compiled with the panic strategy `abort` which is incompatible with this crate's strategy of `unwind` + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/panic_implementation-closures.rs b/src/test/ui/compile-fail-migration/panic_implementation-closures.rs new file mode 100644 index 00000000000..4fa9a639928 --- /dev/null +++ b/src/test/ui/compile-fail-migration/panic_implementation-closures.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![crate_type = "rlib"] +#![no_std] +#![feature(panic_implementation)] + +#[panic_implementation] +pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { + |x: u8| x; + loop {} +} diff --git a/src/test/ui/compile-fail-migration/paren-span.rs b/src/test/ui/compile-fail-migration/paren-span.rs new file mode 100644 index 00000000000..8ed5050f3de --- /dev/null +++ b/src/test/ui/compile-fail-migration/paren-span.rs @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Be smart about span of parenthesized expression in macro. + +macro_rules! paren { + ($e:expr) => (($e)) + // ^^^^ do not highlight here +} + +mod m { + pub struct S { + x: i32 + } + pub fn make() -> S { + S { x: 0 } + } +} + +fn main() { + let s = m::make(); + paren!(s.x); //~ ERROR field `x` of struct `m::S` is private + // ^^^ highlight here +} diff --git a/src/test/ui/compile-fail-migration/paren-span.stderr b/src/test/ui/compile-fail-migration/paren-span.stderr new file mode 100644 index 00000000000..df6881a1af3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/paren-span.stderr @@ -0,0 +1,9 @@ +error[E0616]: field `x` of struct `m::S` is private + --> $DIR/paren-span.rs:29:12 + | +LL | paren!(s.x); //~ ERROR field `x` of struct `m::S` is private + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0616`. diff --git a/src/test/ui/compile-fail-migration/parse-error-correct.rs b/src/test/ui/compile-fail-migration/parse-error-correct.rs new file mode 100644 index 00000000000..bc7c333723d --- /dev/null +++ b/src/test/ui/compile-fail-migration/parse-error-correct.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z continue-parse-after-error + +// Test that the parser is error correcting missing idents. Despite a parsing +// error (or two), we still run type checking (and don't get extra errors there). + +fn main() { + let y = 42; + let x = y.; //~ ERROR unexpected token + let x = y.(); //~ ERROR unexpected token + //~^ ERROR expected function, found `{integer}` + let x = y.foo; //~ ERROR `{integer}` is a primitive type and therefore doesn't have fields [E061 +} diff --git a/src/test/ui/compile-fail-migration/parse-error-correct.stderr b/src/test/ui/compile-fail-migration/parse-error-correct.stderr new file mode 100644 index 00000000000..3eb0b19a6aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/parse-error-correct.stderr @@ -0,0 +1,31 @@ +error: unexpected token: `;` + --> $DIR/parse-error-correct.rs:18:15 + | +LL | let x = y.; //~ ERROR unexpected token + | ^ + +error: unexpected token: `(` + --> $DIR/parse-error-correct.rs:19:15 + | +LL | let x = y.(); //~ ERROR unexpected token + | ^ + +error[E0618]: expected function, found `{integer}` + --> $DIR/parse-error-correct.rs:19:13 + | +LL | let y = 42; + | - `{integer}` defined here +LL | let x = y.; //~ ERROR unexpected token +LL | let x = y.(); //~ ERROR unexpected token + | ^^^^ not a function + +error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields + --> $DIR/parse-error-correct.rs:21:15 + | +LL | let x = y.foo; //~ ERROR `{integer}` is a primitive type and therefore doesn't have fields [E061 + | ^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0610, E0618. +For more information about an error, try `rustc --explain E0610`. diff --git a/src/test/ui/compile-fail-migration/parser-recovery-1.rs b/src/test/ui/compile-fail-migration/parser-recovery-1.rs new file mode 100644 index 00000000000..9fb4d6facdd --- /dev/null +++ b/src/test/ui/compile-fail-migration/parser-recovery-1.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z continue-parse-after-error + +// Test that we can recover from missing braces in the parser. + +trait Foo { + fn bar() { + let x = foo(); //~ ERROR cannot find function `foo` in this scope + +} + +fn main() { + let x = y.; //~ ERROR unexpected token + //~^ ERROR cannot find value `y` in this scope +} //~ ERROR this file contains an un-closed delimiter diff --git a/src/test/ui/compile-fail-migration/parser-recovery-1.stderr b/src/test/ui/compile-fail-migration/parser-recovery-1.stderr new file mode 100644 index 00000000000..bf4070682fb --- /dev/null +++ b/src/test/ui/compile-fail-migration/parser-recovery-1.stderr @@ -0,0 +1,38 @@ +error: this file contains an un-closed delimiter + --> $DIR/parser-recovery-1.rs:24:55 + | +LL | } //~ ERROR this file contains an un-closed delimiter + | ^ + | +help: did you mean to close this delimiter? + --> $DIR/parser-recovery-1.rs:15:11 + | +LL | trait Foo { + | ^ + +error: unexpected token: `;` + --> $DIR/parser-recovery-1.rs:22:15 + | +LL | let x = y.; //~ ERROR unexpected token + | ^ + +error[E0425]: cannot find function `foo` in this scope + --> $DIR/parser-recovery-1.rs:17:17 + | +LL | let x = foo(); //~ ERROR cannot find function `foo` in this scope + | ^^^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/parser-recovery-1.rs:22:13 + | +LL | let x = y.; //~ ERROR unexpected token + | ^ not found in this scope + +error[E0601]: `main` function not found in crate `parser_recovery_1` + | + = note: consider adding a `main` function to `$DIR/parser-recovery-1.rs` + +error: aborting due to 5 previous errors + +Some errors occurred: E0425, E0601. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/parser-recovery-2.rs b/src/test/ui/compile-fail-migration/parser-recovery-2.rs new file mode 100644 index 00000000000..03b1a9b876f --- /dev/null +++ b/src/test/ui/compile-fail-migration/parser-recovery-2.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z continue-parse-after-error + +// Test that we can recover from mismatched braces in the parser. + +trait Foo { + fn bar() { + let x = foo(); //~ ERROR cannot find function `foo` in this scope + ) //~ ERROR incorrect close delimiter: `)` +} + +fn main() { + let x = y.; //~ ERROR unexpected token + //~^ ERROR cannot find value `y` in this scope +} diff --git a/src/test/ui/compile-fail-migration/parser-recovery-2.stderr b/src/test/ui/compile-fail-migration/parser-recovery-2.stderr new file mode 100644 index 00000000000..7b520607352 --- /dev/null +++ b/src/test/ui/compile-fail-migration/parser-recovery-2.stderr @@ -0,0 +1,33 @@ +error: incorrect close delimiter: `)` + --> $DIR/parser-recovery-2.rs:18:5 + | +LL | ) //~ ERROR incorrect close delimiter: `)` + | ^ + | +note: unclosed delimiter + --> $DIR/parser-recovery-2.rs:16:14 + | +LL | fn bar() { + | ^ + +error: unexpected token: `;` + --> $DIR/parser-recovery-2.rs:22:15 + | +LL | let x = y.; //~ ERROR unexpected token + | ^ + +error[E0425]: cannot find function `foo` in this scope + --> $DIR/parser-recovery-2.rs:17:17 + | +LL | let x = foo(); //~ ERROR cannot find function `foo` in this scope + | ^^^ not found in this scope + +error[E0425]: cannot find value `y` in this scope + --> $DIR/parser-recovery-2.rs:22:13 + | +LL | let x = y.; //~ ERROR unexpected token + | ^ not found in this scope + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.rs b/src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.rs new file mode 100644 index 00000000000..3dbe08f1908 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct foo(usize); + +fn main() { + let (foo, _) = (2, 3); //~ ERROR let bindings cannot shadow tuple structs +} diff --git a/src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.stderr b/src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.stderr new file mode 100644 index 00000000000..9dd6a318e98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pat-shadow-in-nested-binding.stderr @@ -0,0 +1,12 @@ +error[E0530]: let bindings cannot shadow tuple structs + --> $DIR/pat-shadow-in-nested-binding.rs:14:10 + | +LL | struct foo(usize); + | ------------------ a tuple struct `foo` is defined here +... +LL | let (foo, _) = (2, 3); //~ ERROR let bindings cannot shadow tuple structs + | ^^^ cannot be named the same as a tuple struct + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0530`. diff --git a/src/test/ui/compile-fail-migration/pat-tuple-bad-type.rs b/src/test/ui/compile-fail-migration/pat-tuple-bad-type.rs new file mode 100644 index 00000000000..251e7b47dcc --- /dev/null +++ b/src/test/ui/compile-fail-migration/pat-tuple-bad-type.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x; + + match x { + (..) => {} //~ ERROR type annotations needed + _ => {} + } + + match 0u8 { + (..) => {} //~ ERROR mismatched types + _ => {} + } + + x = 10; +} diff --git a/src/test/ui/compile-fail-migration/pat-tuple-bad-type.stderr b/src/test/ui/compile-fail-migration/pat-tuple-bad-type.stderr new file mode 100644 index 00000000000..d4f80550b3e --- /dev/null +++ b/src/test/ui/compile-fail-migration/pat-tuple-bad-type.stderr @@ -0,0 +1,24 @@ +error[E0282]: type annotations needed + --> $DIR/pat-tuple-bad-type.rs:15:9 + | +LL | let x; + | - consider giving `x` a type +... +LL | (..) => {} //~ ERROR type annotations needed + | ^^^^ cannot infer type + | + = note: type must be known at this point + +error[E0308]: mismatched types + --> $DIR/pat-tuple-bad-type.rs:20:9 + | +LL | (..) => {} //~ ERROR mismatched types + | ^^^^ expected u8, found () + | + = note: expected type `u8` + found type `()` + +error: aborting due to 2 previous errors + +Some errors occurred: E0282, E0308. +For more information about an error, try `rustc --explain E0282`. diff --git a/src/test/ui/compile-fail-migration/pat-tuple-overfield.rs b/src/test/ui/compile-fail-migration/pat-tuple-overfield.rs new file mode 100644 index 00000000000..851fa5c5be6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pat-tuple-overfield.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S(u8, u8, u8); + +fn main() { + match (1, 2, 3) { + (1, 2, 3, 4) => {} //~ ERROR mismatched types + (1, 2, .., 3, 4) => {} //~ ERROR mismatched types + _ => {} + } + match S(1, 2, 3) { + S(1, 2, 3, 4) => {} + //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields + S(1, 2, .., 3, 4) => {} + //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/pat-tuple-overfield.stderr b/src/test/ui/compile-fail-migration/pat-tuple-overfield.stderr new file mode 100644 index 00000000000..2802b42f313 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pat-tuple-overfield.stderr @@ -0,0 +1,34 @@ +error[E0308]: mismatched types + --> $DIR/pat-tuple-overfield.rs:15:9 + | +LL | (1, 2, 3, 4) => {} //~ ERROR mismatched types + | ^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements + | + = note: expected type `({integer}, {integer}, {integer})` + found type `(_, _, _, _)` + +error[E0308]: mismatched types + --> $DIR/pat-tuple-overfield.rs:16:9 + | +LL | (1, 2, .., 3, 4) => {} //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements + | + = note: expected type `({integer}, {integer}, {integer})` + found type `(_, _, _, _)` + +error[E0023]: this pattern has 4 fields, but the corresponding tuple struct has 3 fields + --> $DIR/pat-tuple-overfield.rs:20:9 + | +LL | S(1, 2, 3, 4) => {} + | ^^^^^^^^^^^^^ expected 3 fields, found 4 + +error[E0023]: this pattern has 4 fields, but the corresponding tuple struct has 3 fields + --> $DIR/pat-tuple-overfield.rs:22:9 + | +LL | S(1, 2, .., 3, 4) => {} + | ^^^^^^^^^^^^^^^^^ expected 3 fields, found 4 + +error: aborting due to 4 previous errors + +Some errors occurred: E0023, E0308. +For more information about an error, try `rustc --explain E0023`. diff --git a/src/test/ui/compile-fail-migration/patkind-litrange-no-expr.rs b/src/test/ui/compile-fail-migration/patkind-litrange-no-expr.rs new file mode 100644 index 00000000000..8fef98f815f --- /dev/null +++ b/src/test/ui/compile-fail-migration/patkind-litrange-no-expr.rs @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! enum_number { + ($name:ident { $($variant:ident = $value:expr, )* }) => { + enum $name { + $($variant = $value,)* + } + + fn foo(value: i32) -> Option<$name> { + match value { + $( $value => Some($name::$variant), )* // PatKind::Lit + $( $value ..= 42 => Some($name::$variant), )* // PatKind::Range + _ => None + } + } + } +} + +enum_number!(Change { + Pos = 1, + Neg = -1, + Arith = 1 + 1, //~ ERROR arbitrary expressions aren't allowed in patterns + //~^ ERROR only char and numeric types are allowed in range patterns +}); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/patkind-litrange-no-expr.stderr b/src/test/ui/compile-fail-migration/patkind-litrange-no-expr.stderr new file mode 100644 index 00000000000..f22870fb029 --- /dev/null +++ b/src/test/ui/compile-fail-migration/patkind-litrange-no-expr.stderr @@ -0,0 +1,18 @@ +error: arbitrary expressions aren't allowed in patterns + --> $DIR/patkind-litrange-no-expr.rs:30:13 + | +LL | Arith = 1 + 1, //~ ERROR arbitrary expressions aren't allowed in patterns + | ^^^^^ + +error[E0029]: only char and numeric types are allowed in range patterns + --> $DIR/patkind-litrange-no-expr.rs:30:13 + | +LL | Arith = 1 + 1, //~ ERROR arbitrary expressions aren't allowed in patterns + | ^^^^^ ranges require char or numeric types + | + = note: start type: {integer} + = note: end type: {integer} + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0029`. diff --git a/src/test/ui/compile-fail-migration/pattern-binding-disambiguation.rs b/src/test/ui/compile-fail-migration/pattern-binding-disambiguation.rs new file mode 100644 index 00000000000..c740f6bb47c --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-binding-disambiguation.rs @@ -0,0 +1,67 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct UnitStruct; +struct TupleStruct(); +struct BracedStruct{} + +enum E { + UnitVariant, + TupleVariant(), + BracedVariant{}, +} +use E::*; + +const CONST: () = (); +static STATIC: () = (); + +fn function() {} + +fn main() { + let doesnt_matter = 0; + + match UnitStruct { + UnitStruct => {} // OK, `UnitStruct` is a unit struct pattern + } + match doesnt_matter { + TupleStruct => {} //~ ERROR match bindings cannot shadow tuple structs + } + match doesnt_matter { + BracedStruct => {} // OK, `BracedStruct` is a fresh binding + } + match UnitVariant { + UnitVariant => {} // OK, `UnitVariant` is a unit variant pattern + } + match doesnt_matter { + TupleVariant => {} //~ ERROR match bindings cannot shadow tuple variants + } + match doesnt_matter { + BracedVariant => {} //~ ERROR match bindings cannot shadow struct variants + } + match CONST { + CONST => {} // OK, `CONST` is a const pattern + } + match doesnt_matter { + STATIC => {} //~ ERROR match bindings cannot shadow statics + } + match doesnt_matter { + function => {} // OK, `function` is a fresh binding + } + + let UnitStruct = UnitStruct; // OK, `UnitStruct` is a unit struct pattern + let TupleStruct = doesnt_matter; //~ ERROR let bindings cannot shadow tuple structs + let BracedStruct = doesnt_matter; // OK, `BracedStruct` is a fresh binding + let UnitVariant = UnitVariant; // OK, `UnitVariant` is a unit variant pattern + let TupleVariant = doesnt_matter; //~ ERROR let bindings cannot shadow tuple variants + let BracedVariant = doesnt_matter; //~ ERROR let bindings cannot shadow struct variants + let CONST = CONST; // OK, `CONST` is a const pattern + let STATIC = doesnt_matter; //~ ERROR let bindings cannot shadow statics + let function = doesnt_matter; // OK, `function` is a fresh binding +} diff --git a/src/test/ui/compile-fail-migration/pattern-binding-disambiguation.stderr b/src/test/ui/compile-fail-migration/pattern-binding-disambiguation.stderr new file mode 100644 index 00000000000..7acdb07e10d --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-binding-disambiguation.stderr @@ -0,0 +1,75 @@ +error[E0530]: match bindings cannot shadow tuple structs + --> $DIR/pattern-binding-disambiguation.rs:34:9 + | +LL | struct TupleStruct(); + | --------------------- a tuple struct `TupleStruct` is defined here +... +LL | TupleStruct => {} //~ ERROR match bindings cannot shadow tuple structs + | ^^^^^^^^^^^ cannot be named the same as a tuple struct + +error[E0530]: match bindings cannot shadow tuple variants + --> $DIR/pattern-binding-disambiguation.rs:43:9 + | +LL | use E::*; + | ---- a tuple variant `TupleVariant` is imported here +... +LL | TupleVariant => {} //~ ERROR match bindings cannot shadow tuple variants + | ^^^^^^^^^^^^ cannot be named the same as a tuple variant + +error[E0530]: match bindings cannot shadow struct variants + --> $DIR/pattern-binding-disambiguation.rs:46:9 + | +LL | use E::*; + | ---- a struct variant `BracedVariant` is imported here +... +LL | BracedVariant => {} //~ ERROR match bindings cannot shadow struct variants + | ^^^^^^^^^^^^^ cannot be named the same as a struct variant + +error[E0530]: match bindings cannot shadow statics + --> $DIR/pattern-binding-disambiguation.rs:52:9 + | +LL | static STATIC: () = (); + | ----------------------- a static `STATIC` is defined here +... +LL | STATIC => {} //~ ERROR match bindings cannot shadow statics + | ^^^^^^ cannot be named the same as a static + +error[E0530]: let bindings cannot shadow tuple structs + --> $DIR/pattern-binding-disambiguation.rs:59:9 + | +LL | struct TupleStruct(); + | --------------------- a tuple struct `TupleStruct` is defined here +... +LL | let TupleStruct = doesnt_matter; //~ ERROR let bindings cannot shadow tuple structs + | ^^^^^^^^^^^ cannot be named the same as a tuple struct + +error[E0530]: let bindings cannot shadow tuple variants + --> $DIR/pattern-binding-disambiguation.rs:62:9 + | +LL | use E::*; + | ---- a tuple variant `TupleVariant` is imported here +... +LL | let TupleVariant = doesnt_matter; //~ ERROR let bindings cannot shadow tuple variants + | ^^^^^^^^^^^^ cannot be named the same as a tuple variant + +error[E0530]: let bindings cannot shadow struct variants + --> $DIR/pattern-binding-disambiguation.rs:63:9 + | +LL | use E::*; + | ---- a struct variant `BracedVariant` is imported here +... +LL | let BracedVariant = doesnt_matter; //~ ERROR let bindings cannot shadow struct variants + | ^^^^^^^^^^^^^ cannot be named the same as a struct variant + +error[E0530]: let bindings cannot shadow statics + --> $DIR/pattern-binding-disambiguation.rs:65:9 + | +LL | static STATIC: () = (); + | ----------------------- a static `STATIC` is defined here +... +LL | let STATIC = doesnt_matter; //~ ERROR let bindings cannot shadow statics + | ^^^^^^ cannot be named the same as a static + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0530`. diff --git a/src/test/ui/compile-fail-migration/pattern-bindings-after-at.rs b/src/test/ui/compile-fail-migration/pattern-bindings-after-at.rs new file mode 100644 index 00000000000..da2a97b0ca8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-bindings-after-at.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Option { + None, + Some(T), +} + +fn main() { + match &mut Some(1) { + ref mut z @ &mut Some(ref a) => { + //~^ ERROR pattern bindings are not allowed after an `@` + **z = None; + println!("{}", *a); + } + _ => () + } +} diff --git a/src/test/ui/compile-fail-migration/pattern-bindings-after-at.stderr b/src/test/ui/compile-fail-migration/pattern-bindings-after-at.stderr new file mode 100644 index 00000000000..8c715001baa --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-bindings-after-at.stderr @@ -0,0 +1,9 @@ +error[E0303]: pattern bindings are not allowed after an `@` + --> $DIR/pattern-bindings-after-at.rs:18:31 + | +LL | ref mut z @ &mut Some(ref a) => { + | ^^^^^ not allowed after `@` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0303`. diff --git a/src/test/ui/compile-fail-migration/pattern-error-continue.rs b/src/test/ui/compile-fail-migration/pattern-error-continue.rs new file mode 100644 index 00000000000..e63b84594aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-error-continue.rs @@ -0,0 +1,47 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that certain pattern-match type errors are non-fatal + +enum A { + B(isize, isize), + C(isize, isize, isize), + D +} + +struct S { + a: isize +} + +fn f(_c: char) {} + +fn main() { + match A::B(1, 2) { + A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but + A::D(_) => (), //~ ERROR expected tuple struct/variant, found unit variant `A::D` + _ => () + } + match 'c' { + S { .. } => (), + //~^ ERROR mismatched types + //~| expected type `char` + //~| found type `S` + //~| expected char, found struct `S` + + _ => () + } + f(true); + //~^ ERROR mismatched types + //~| expected char, found bool + + match () { + E::V => {} //~ ERROR failed to resolve. Use of undeclared type or module `E` + } +} diff --git a/src/test/ui/compile-fail-migration/pattern-error-continue.stderr b/src/test/ui/compile-fail-migration/pattern-error-continue.stderr new file mode 100644 index 00000000000..b24366c48bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-error-continue.stderr @@ -0,0 +1,39 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `E` + --> $DIR/pattern-error-continue.rs:45:9 + | +LL | E::V => {} //~ ERROR failed to resolve. Use of undeclared type or module `E` + | ^ Use of undeclared type or module `E` + +error[E0532]: expected tuple struct/variant, found unit variant `A::D` + --> $DIR/pattern-error-continue.rs:28:9 + | +LL | A::D(_) => (), //~ ERROR expected tuple struct/variant, found unit variant `A::D` + | ^^^- + | | + | did you mean `B`? + +error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields + --> $DIR/pattern-error-continue.rs:27:9 + | +LL | A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but + | ^^^^^^^^^^^^^ expected 2 fields, found 3 + +error[E0308]: mismatched types + --> $DIR/pattern-error-continue.rs:32:9 + | +LL | S { .. } => (), + | ^^^^^^^^ expected char, found struct `S` + | + = note: expected type `char` + found type `S` + +error[E0308]: mismatched types + --> $DIR/pattern-error-continue.rs:40:7 + | +LL | f(true); + | ^^^^ expected char, found bool + +error: aborting due to 5 previous errors + +Some errors occurred: E0023, E0308, E0433, E0532. +For more information about an error, try `rustc --explain E0023`. diff --git a/src/test/ui/compile-fail-migration/pattern-ident-path-generics.rs b/src/test/ui/compile-fail-migration/pattern-ident-path-generics.rs new file mode 100644 index 00000000000..0b7886842b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-ident-path-generics.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + match Some("foo") { + None:: => {} //~ ERROR mismatched types + Some(_) => {} + } +} diff --git a/src/test/ui/compile-fail-migration/pattern-ident-path-generics.stderr b/src/test/ui/compile-fail-migration/pattern-ident-path-generics.stderr new file mode 100644 index 00000000000..cd205956571 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-ident-path-generics.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/pattern-ident-path-generics.rs:13:9 + | +LL | None:: => {} //~ ERROR mismatched types + | ^^^^^^^^^^^^^ expected &str, found isize + | + = note: expected type `std::option::Option<&str>` + found type `std::option::Option` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/pattern-tyvar-2.rs b/src/test/ui/compile-fail-migration/pattern-tyvar-2.rs new file mode 100644 index 00000000000..cd4a98835c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-tyvar-2.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum bar { t1((), Option>), t2, } + +// n.b. my change changes this error message, but I think it's right -- tjc +fn foo(t: bar) -> isize { match t { bar::t1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } +//~^ ERROR binary operation `*` cannot be applied to + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/pattern-tyvar-2.stderr b/src/test/ui/compile-fail-migration/pattern-tyvar-2.stderr new file mode 100644 index 00000000000..fd7ab84cc56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-tyvar-2.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `*` cannot be applied to type `std::vec::Vec` + --> $DIR/pattern-tyvar-2.rs:14:69 + | +LL | fn foo(t: bar) -> isize { match t { bar::t1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } + | ^^^^^ + | + = note: an implementation of `std::ops::Mul` might be missing for `std::vec::Vec` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/pattern-tyvar.rs b/src/test/ui/compile-fail-migration/pattern-tyvar.rs new file mode 100644 index 00000000000..be8d3e027e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-tyvar.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types + +enum bar { t1((), Option >), t2, } + +fn foo(t: bar) { + match t { + bar::t1(_, Some::(x)) => { + println!("{}", x); + } + _ => { panic!(); } + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/pattern-tyvar.stderr b/src/test/ui/compile-fail-migration/pattern-tyvar.stderr new file mode 100644 index 00000000000..55e09e02a1d --- /dev/null +++ b/src/test/ui/compile-fail-migration/pattern-tyvar.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/pattern-tyvar.rs:17:18 + | +LL | bar::t1(_, Some::(x)) => { + | ^^^^^^^^^^^^^^^^ expected struct `std::vec::Vec`, found isize + | + = note: expected type `std::option::Option>` + found type `std::option::Option` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/phantom-oibit.rs b/src/test/ui/compile-fail-migration/phantom-oibit.rs new file mode 100644 index 00000000000..51e7d5da98f --- /dev/null +++ b/src/test/ui/compile-fail-migration/phantom-oibit.rs @@ -0,0 +1,40 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that OIBIT checks `T` when it encounters a `PhantomData` field, instead of checking +// the `PhantomData` type itself (which almost always implements an auto trait) + +#![feature(optin_builtin_traits)] + +use std::marker::{PhantomData}; + +unsafe auto trait Zen {} + +unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} + +struct Guard<'a, T: 'a> { + _marker: PhantomData<&'a T>, +} + +struct Nested(T); + +fn is_zen(_: T) {} + +fn not_sync(x: Guard) { + is_zen(x) + //~^ ERROR `T` cannot be shared between threads safely [E0277] +} + +fn nested_not_sync(x: Nested>) { + is_zen(x) + //~^ ERROR `T` cannot be shared between threads safely [E0277] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/phantom-oibit.stderr b/src/test/ui/compile-fail-migration/phantom-oibit.stderr new file mode 100644 index 00000000000..5156ba94cef --- /dev/null +++ b/src/test/ui/compile-fail-migration/phantom-oibit.stderr @@ -0,0 +1,38 @@ +error[E0277]: `T` cannot be shared between threads safely + --> $DIR/phantom-oibit.rs:31:5 + | +LL | is_zen(x) + | ^^^^^^ `T` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `T` + = help: consider adding a `where T: std::marker::Sync` bound + = note: required because of the requirements on the impl of `Zen` for `&T` + = note: required because it appears within the type `std::marker::PhantomData<&T>` + = note: required because it appears within the type `Guard<'_, T>` +note: required by `is_zen` + --> $DIR/phantom-oibit.rs:28:1 + | +LL | fn is_zen(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `T` cannot be shared between threads safely + --> $DIR/phantom-oibit.rs:36:5 + | +LL | is_zen(x) + | ^^^^^^ `T` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `T` + = help: consider adding a `where T: std::marker::Sync` bound + = note: required because of the requirements on the impl of `Zen` for `&T` + = note: required because it appears within the type `std::marker::PhantomData<&T>` + = note: required because it appears within the type `Guard<'_, T>` + = note: required because it appears within the type `Nested>` +note: required by `is_zen` + --> $DIR/phantom-oibit.rs:28:1 + | +LL | fn is_zen(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/platform-intrinsic-params.rs b/src/test/ui/compile-fail-migration/platform-intrinsic-params.rs new file mode 100644 index 00000000000..e8a9031dba8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/platform-intrinsic-params.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(platform_intrinsics)] +extern "platform-intrinsic" { + fn x86_mm_movemask_ps() -> i32; //~ERROR found 0, expected 1 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/platform-intrinsic-params.stderr b/src/test/ui/compile-fail-migration/platform-intrinsic-params.stderr new file mode 100644 index 00000000000..e41de9fe02d --- /dev/null +++ b/src/test/ui/compile-fail-migration/platform-intrinsic-params.stderr @@ -0,0 +1,9 @@ +error[E0444]: platform-specific intrinsic has invalid number of arguments: found 0, expected 1 + --> $DIR/platform-intrinsic-params.rs:13:5 + | +LL | fn x86_mm_movemask_ps() -> i32; //~ERROR found 0, expected 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0444`. diff --git a/src/test/ui/compile-fail-migration/pptypedef.rs b/src/test/ui/compile-fail-migration/pptypedef.rs new file mode 100644 index 00000000000..7ece52e7537 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pptypedef.rs @@ -0,0 +1,21 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn let_in(x: T, f: F) where F: FnOnce(T) {} + +fn main() { + let_in(3u32, |i| { assert!(i == 3i32); }); + //~^ ERROR mismatched types + //~| expected u32, found i32 + + let_in(3i32, |i| { assert!(i == 3u32); }); + //~^ ERROR mismatched types + //~| expected i32, found u32 +} diff --git a/src/test/ui/compile-fail-migration/pptypedef.stderr b/src/test/ui/compile-fail-migration/pptypedef.stderr new file mode 100644 index 00000000000..bde48d86ba5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/pptypedef.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/pptypedef.rs:14:37 + | +LL | let_in(3u32, |i| { assert!(i == 3i32); }); + | ^^^^ expected u32, found i32 + +error[E0308]: mismatched types + --> $DIR/pptypedef.rs:18:37 + | +LL | let_in(3i32, |i| { assert!(i == 3u32); }); + | ^^^^ expected i32, found u32 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/prim-with-args.rs b/src/test/ui/compile-fail-migration/prim-with-args.rs new file mode 100644 index 00000000000..cc0b74dc82a --- /dev/null +++ b/src/test/ui/compile-fail-migration/prim-with-args.rs @@ -0,0 +1,37 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + +let x: isize; //~ ERROR type parameters are not allowed on this type +let x: i8; //~ ERROR type parameters are not allowed on this type +let x: i16; //~ ERROR type parameters are not allowed on this type +let x: i32; //~ ERROR type parameters are not allowed on this type +let x: i64; //~ ERROR type parameters are not allowed on this type +let x: usize; //~ ERROR type parameters are not allowed on this type +let x: u8; //~ ERROR type parameters are not allowed on this type +let x: u16; //~ ERROR type parameters are not allowed on this type +let x: u32; //~ ERROR type parameters are not allowed on this type +let x: u64; //~ ERROR type parameters are not allowed on this type +let x: char; //~ ERROR type parameters are not allowed on this type + +let x: isize<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: i8<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: i16<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: i32<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: i64<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: usize<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: u8<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: u16<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: u32<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: u64<'static>; //~ ERROR lifetime parameters are not allowed on this type +let x: char<'static>; //~ ERROR lifetime parameters are not allowed on this type + +} diff --git a/src/test/ui/compile-fail-migration/prim-with-args.stderr b/src/test/ui/compile-fail-migration/prim-with-args.stderr new file mode 100644 index 00000000000..bfe7256f8a2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/prim-with-args.stderr @@ -0,0 +1,136 @@ +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:13:14 + | +LL | let x: isize; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:14:11 + | +LL | let x: i8; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:15:12 + | +LL | let x: i16; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:16:12 + | +LL | let x: i32; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:17:12 + | +LL | let x: i64; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:18:14 + | +LL | let x: usize; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:19:11 + | +LL | let x: u8; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:20:12 + | +LL | let x: u16; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:21:12 + | +LL | let x: u32; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:22:12 + | +LL | let x: u64; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/prim-with-args.rs:23:13 + | +LL | let x: char; //~ ERROR type parameters are not allowed on this type + | ^^^^^ type parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:25:14 + | +LL | let x: isize<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:26:11 + | +LL | let x: i8<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:27:12 + | +LL | let x: i16<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:28:12 + | +LL | let x: i32<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:29:12 + | +LL | let x: i64<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:30:14 + | +LL | let x: usize<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:31:11 + | +LL | let x: u8<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:32:12 + | +LL | let x: u16<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:33:12 + | +LL | let x: u32<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:34:12 + | +LL | let x: u64<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/prim-with-args.rs:35:13 + | +LL | let x: char<'static>; //~ ERROR lifetime parameters are not allowed on this type + | ^^^^^^^ lifetime parameter not allowed + +error: aborting due to 22 previous errors + +Some errors occurred: E0109, E0110. +For more information about an error, try `rustc --explain E0109`. diff --git a/src/test/ui/compile-fail-migration/priv-in-bad-locations.rs b/src/test/ui/compile-fail-migration/priv-in-bad-locations.rs new file mode 100644 index 00000000000..8901d8c08e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/priv-in-bad-locations.rs @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub extern { //~ ERROR unnecessary visibility qualifier + pub fn bar(); +} + +trait A { + fn foo(&self) {} +} + +struct B; + +pub impl B {} //~ ERROR unnecessary visibility qualifier + +pub impl A for B { //~ ERROR unnecessary visibility qualifier + pub fn foo(&self) {} //~ ERROR unnecessary visibility qualifier +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/priv-in-bad-locations.stderr b/src/test/ui/compile-fail-migration/priv-in-bad-locations.stderr new file mode 100644 index 00000000000..e395a2243df --- /dev/null +++ b/src/test/ui/compile-fail-migration/priv-in-bad-locations.stderr @@ -0,0 +1,31 @@ +error[E0449]: unnecessary visibility qualifier + --> $DIR/priv-in-bad-locations.rs:11:1 + | +LL | pub extern { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual foreign items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/priv-in-bad-locations.rs:21:1 + | +LL | pub impl B {} //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual impl items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/priv-in-bad-locations.rs:23:1 + | +LL | pub impl A for B { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/priv-in-bad-locations.rs:24:5 + | +LL | pub fn foo(&self) {} //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/src/test/ui/compile-fail-migration/privacy-in-paths.rs b/src/test/ui/compile-fail-migration/privacy-in-paths.rs new file mode 100644 index 00000000000..0a8689ea6d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-in-paths.rs @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub use self::bar::S; + mod bar { + pub struct S; + pub use baz; + } + + trait T { + type Assoc; + } + impl T for () { + type Assoc = S; + } +} + +impl foo::S { + fn f() {} +} + +pub mod baz { + fn f() {} + + fn g() { + ::foo::bar::baz::f(); //~ERROR module `bar` is private + ::foo::bar::S::f(); //~ERROR module `bar` is private + <() as ::foo::T>::Assoc::f(); //~ERROR trait `T` is private + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/privacy-in-paths.stderr b/src/test/ui/compile-fail-migration/privacy-in-paths.stderr new file mode 100644 index 00000000000..f0aa3d36479 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-in-paths.stderr @@ -0,0 +1,21 @@ +error[E0603]: module `bar` is private + --> $DIR/privacy-in-paths.rs:34:9 + | +LL | ::foo::bar::baz::f(); //~ERROR module `bar` is private + | ^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `bar` is private + --> $DIR/privacy-in-paths.rs:35:9 + | +LL | ::foo::bar::S::f(); //~ERROR module `bar` is private + | ^^^^^^^^^^^^^^^^ + +error[E0603]: trait `T` is private + --> $DIR/privacy-in-paths.rs:36:9 + | +LL | <() as ::foo::T>::Assoc::f(); //~ERROR trait `T` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/privacy-ns1.rs b/src/test/ui/compile-fail-migration/privacy-ns1.rs new file mode 100644 index 00000000000..e7e522f99d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-ns1.rs @@ -0,0 +1,65 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check we do the correct privacy checks when we import a name and there is an +// item with that name in both the value and type namespaces. + +#![allow(dead_code)] +#![allow(unused_imports)] + + +// public type, private value +pub mod foo1 { + pub trait Bar { + } + pub struct Baz; + + fn Bar() { } +} + +fn test_glob1() { + use foo1::*; + + Bar(); //~ ERROR expected function, found trait `Bar` +} + +// private type, public value +pub mod foo2 { + trait Bar { + } + pub struct Baz; + + pub fn Bar() { } +} + +fn test_glob2() { + use foo2::*; + + let _x: Box; //~ ERROR expected type, found function `Bar` +} + +// neither public +pub mod foo3 { + trait Bar { + } + pub struct Baz; + + fn Bar() { } +} + +fn test_glob3() { + use foo3::*; + + Bar(); //~ ERROR cannot find function `Bar` in this scope + let _x: Box; //~ ERROR cannot find type `Bar` in this scope +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/privacy-ns1.stderr b/src/test/ui/compile-fail-migration/privacy-ns1.stderr new file mode 100644 index 00000000000..503cfbfaa2d --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-ns1.stderr @@ -0,0 +1,60 @@ +error[E0423]: expected function, found trait `Bar` + --> $DIR/privacy-ns1.rs:30:5 + | +LL | Bar(); //~ ERROR expected function, found trait `Bar` + | ^^^ did you mean `Baz`? +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error[E0573]: expected type, found function `Bar` + --> $DIR/privacy-ns1.rs:45:17 + | +LL | let _x: Box; //~ ERROR expected type, found function `Bar` + | ^^^ did you mean `Baz`? +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error[E0425]: cannot find function `Bar` in this scope + --> $DIR/privacy-ns1.rs:60:5 + | +LL | Bar(); //~ ERROR cannot find function `Bar` in this scope + | ^^^ did you mean `Baz`? +help: possible candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error[E0412]: cannot find type `Bar` in this scope + --> $DIR/privacy-ns1.rs:61:17 + | +LL | let _x: Box; //~ ERROR cannot find type `Bar` in this scope + | ^^^ did you mean `Baz`? +help: possible candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error: aborting due to 4 previous errors + +Some errors occurred: E0412, E0423, E0425, E0573. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/compile-fail-migration/privacy-ns2.rs b/src/test/ui/compile-fail-migration/privacy-ns2.rs new file mode 100644 index 00000000000..ec9396b5e7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-ns2.rs @@ -0,0 +1,88 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check we do the correct privacy checks when we import a name and there is an +// item with that name in both the value and type namespaces. + +#![allow(dead_code)] +#![allow(unused_imports)] + + +// public type, private value +pub mod foo1 { + pub trait Bar { + } + pub struct Baz; + + fn Bar() { } +} + +fn test_single1() { + use foo1::Bar; + + Bar(); //~ ERROR expected function, found trait `Bar` +} + +fn test_list1() { + use foo1::{Bar,Baz}; + + Bar(); //~ ERROR expected function, found trait `Bar` +} + +// private type, public value +pub mod foo2 { + trait Bar { + } + pub struct Baz; + + pub fn Bar() { } +} + +fn test_single2() { + use foo2::Bar; + + let _x : Box; //~ ERROR expected type, found function `Bar` +} + +fn test_list2() { + use foo2::{Bar,Baz}; + + let _x: Box; //~ ERROR expected type, found function `Bar` +} + +// neither public +pub mod foo3 { + trait Bar { + } + pub struct Baz; + + fn Bar() { } +} + +fn test_unused3() { + use foo3::Bar; //~ ERROR `Bar` is private +} + +fn test_single3() { + use foo3::Bar; //~ ERROR `Bar` is private + + Bar(); + let _x: Box; +} + +fn test_list3() { + use foo3::{Bar,Baz}; //~ ERROR `Bar` is private + + Bar(); + let _x: Box; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/privacy-ns2.stderr b/src/test/ui/compile-fail-migration/privacy-ns2.stderr new file mode 100644 index 00000000000..0cd341d9a58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-ns2.stderr @@ -0,0 +1,78 @@ +error[E0423]: expected function, found trait `Bar` + --> $DIR/privacy-ns2.rs:30:5 + | +LL | Bar(); //~ ERROR expected function, found trait `Bar` + | ^^^ not a function +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error[E0423]: expected function, found trait `Bar` + --> $DIR/privacy-ns2.rs:36:5 + | +LL | Bar(); //~ ERROR expected function, found trait `Bar` + | ^^^ did you mean `Baz`? +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error[E0573]: expected type, found function `Bar` + --> $DIR/privacy-ns2.rs:51:18 + | +LL | let _x : Box; //~ ERROR expected type, found function `Bar` + | ^^^ not a type +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error[E0573]: expected type, found function `Bar` + --> $DIR/privacy-ns2.rs:57:17 + | +LL | let _x: Box; //~ ERROR expected type, found function `Bar` + | ^^^ did you mean `Baz`? +help: possible better candidates are found in other modules, you can import them into scope + | +LL | use foo1::Bar; + | +LL | use foo2::Bar; + | +LL | use foo3::Bar; + | + +error[E0603]: trait `Bar` is private + --> $DIR/privacy-ns2.rs:70:9 + | +LL | use foo3::Bar; //~ ERROR `Bar` is private + | ^^^^^^^^^ + +error[E0603]: trait `Bar` is private + --> $DIR/privacy-ns2.rs:74:9 + | +LL | use foo3::Bar; //~ ERROR `Bar` is private + | ^^^^^^^^^ + +error[E0603]: trait `Bar` is private + --> $DIR/privacy-ns2.rs:81:16 + | +LL | use foo3::{Bar,Baz}; //~ ERROR `Bar` is private + | ^^^ + +error: aborting due to 7 previous errors + +Some errors occurred: E0423, E0573, E0603. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/compile-fail-migration/privacy-sanity.rs b/src/test/ui/compile-fail-migration/privacy-sanity.rs new file mode 100644 index 00000000000..f245b7cef29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-sanity.rs @@ -0,0 +1,92 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +pub trait Tr { + fn f(); + const C: u8; + type T; +} +pub struct S { + pub a: u8 +} +struct Ts(pub u8); + +pub impl Tr for S { //~ ERROR unnecessary visibility qualifier + pub fn f() {} //~ ERROR unnecessary visibility qualifier + pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier + pub type T = u8; //~ ERROR unnecessary visibility qualifier +} +pub impl S { //~ ERROR unnecessary visibility qualifier + pub fn f() {} + pub const C: u8 = 0; + // pub type T = u8; +} +pub extern "C" { //~ ERROR unnecessary visibility qualifier + pub fn f(); + pub static St: u8; +} + +const MAIN: u8 = { + pub trait Tr { + fn f(); + const C: u8; + type T; + } + pub struct S { + pub a: u8 + } + struct Ts(pub u8); + + pub impl Tr for S { //~ ERROR unnecessary visibility qualifier + pub fn f() {} //~ ERROR unnecessary visibility qualifier + pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier + pub type T = u8; //~ ERROR unnecessary visibility qualifier + } + pub impl S { //~ ERROR unnecessary visibility qualifier + pub fn f() {} + pub const C: u8 = 0; + // pub type T = u8; + } + pub extern "C" { //~ ERROR unnecessary visibility qualifier + pub fn f(); + pub static St: u8; + } + + 0 +}; + +fn main() { + pub trait Tr { + fn f(); + const C: u8; + type T; + } + pub struct S { + pub a: u8 + } + struct Ts(pub u8); + + pub impl Tr for S { //~ ERROR unnecessary visibility qualifier + pub fn f() {} //~ ERROR unnecessary visibility qualifier + pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier + pub type T = u8; //~ ERROR unnecessary visibility qualifier + } + pub impl S { //~ ERROR unnecessary visibility qualifier + pub fn f() {} + pub const C: u8 = 0; + // pub type T = u8; + } + pub extern "C" { //~ ERROR unnecessary visibility qualifier + pub fn f(); + pub static St: u8; + } +} diff --git a/src/test/ui/compile-fail-migration/privacy-sanity.stderr b/src/test/ui/compile-fail-migration/privacy-sanity.stderr new file mode 100644 index 00000000000..fbfa15f8cb0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-sanity.stderr @@ -0,0 +1,123 @@ +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:23:1 + | +LL | pub impl Tr for S { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:24:5 + | +LL | pub fn f() {} //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:25:5 + | +LL | pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:26:5 + | +LL | pub type T = u8; //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:28:1 + | +LL | pub impl S { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual impl items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:33:1 + | +LL | pub extern "C" { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual foreign items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:49:5 + | +LL | pub impl Tr for S { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:50:9 + | +LL | pub fn f() {} //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:51:9 + | +LL | pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:52:9 + | +LL | pub type T = u8; //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:54:5 + | +LL | pub impl S { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual impl items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:59:5 + | +LL | pub extern "C" { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual foreign items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:78:5 + | +LL | pub impl Tr for S { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:79:9 + | +LL | pub fn f() {} //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:80:9 + | +LL | pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:81:9 + | +LL | pub type T = u8; //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:83:5 + | +LL | pub impl S { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual impl items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/privacy-sanity.rs:88:5 + | +LL | pub extern "C" { //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + | + = note: place qualifiers on individual foreign items instead + +error: aborting due to 18 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/src/test/ui/compile-fail-migration/privacy-ufcs.rs b/src/test/ui/compile-fail-migration/privacy-ufcs.rs new file mode 100644 index 00000000000..28c1a003e39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-ufcs.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test to ensure private traits are inaccessible with UFCS angle-bracket syntax. + +mod foo { + trait Bar { + fn baz() {} + } + + impl Bar for i32 {} +} + +fn main() { + ::baz(); //~ERROR trait `Bar` is private +} diff --git a/src/test/ui/compile-fail-migration/privacy-ufcs.stderr b/src/test/ui/compile-fail-migration/privacy-ufcs.stderr new file mode 100644 index 00000000000..2030e2e0f1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy-ufcs.stderr @@ -0,0 +1,9 @@ +error[E0603]: trait `Bar` is private + --> $DIR/privacy-ufcs.rs:22:5 + | +LL | ::baz(); //~ERROR trait `Bar` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.rs b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.rs new file mode 100644 index 00000000000..63cb6e82c25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.rs @@ -0,0 +1,122 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(decl_macro, associated_type_defaults)] +#![allow(unused, private_in_public)] + +mod priv_nominal { + pub struct Pub; + impl Pub { + fn method(&self) {} + const CONST: u8 = 0; + // type AssocTy = u8; + } + + pub macro mac() { + let value = Pub::method; + //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + value; + //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + Pub.method(); + //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + Pub::CONST; + //~^ ERROR associated constant `CONST` is private + // let _: Pub::AssocTy; + // pub type InSignatureTy = Pub::AssocTy; + } +} +fn priv_nominal() { + priv_nominal::mac!(); +} + +mod priv_signature { + struct Priv; + pub struct Pub; + impl Pub { + pub fn method(&self, arg: Priv) {} + } + + pub macro mac() { + let value = Pub::method; + //~^ ERROR type `priv_signature::Priv` is private + value; + //~^ ERROR type `priv_signature::Priv` is private + Pub.method(loop {}); + //~^ ERROR type `priv_signature::Priv` is private + } +} +fn priv_signature() { + priv_signature::mac!(); +} + +mod priv_substs { + struct Priv; + pub struct Pub; + impl Pub { + pub fn method(&self) {} + } + + pub macro mac() { + let value = Pub::method::; + //~^ ERROR type `priv_substs::Priv` is private + value; + //~^ ERROR type `priv_substs::Priv` is private + Pub.method::(); + //~^ ERROR type `priv_substs::Priv` is private + } +} +fn priv_substs() { + priv_substs::mac!(); +} + +mod priv_parent_substs { + struct Priv; + pub struct Pub(T); + impl Pub { + pub fn method(&self) {} + pub fn static_method() {} + pub const CONST: u8 = 0; + // pub type AssocTy = u8; + } + + pub macro mac() { + let value = ::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + let value = Pub::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + let value = ::static_method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + let value = Pub::static_method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + Pub(Priv).method(); + //~^ ERROR type `priv_parent_substs::Priv` is private + + ::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + Pub::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + + // let _: Pub::AssocTy; + // pub type InSignatureTy = Pub::AssocTy; + } +} +fn priv_parent_substs() { + priv_parent_substs::mac!(); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.stderr b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.stderr new file mode 100644 index 00000000000..391e5bbb4c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-inherent.stderr @@ -0,0 +1,191 @@ +error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + --> $DIR/associated-item-privacy-inherent.rs:23:21 + | +LL | let value = Pub::method; + | ^^^^^^^^^^^ +... +LL | priv_nominal::mac!(); + | --------------------- in this macro invocation + +error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + --> $DIR/associated-item-privacy-inherent.rs:25:9 + | +LL | value; + | ^^^^^ +... +LL | priv_nominal::mac!(); + | --------------------- in this macro invocation + +error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private + --> $DIR/associated-item-privacy-inherent.rs:27:13 + | +LL | Pub.method(); + | ^^^^^^ +... +LL | priv_nominal::mac!(); + | --------------------- in this macro invocation + +error: associated constant `CONST` is private + --> $DIR/associated-item-privacy-inherent.rs:29:9 + | +LL | Pub::CONST; + | ^^^^^^^^^^ +... +LL | priv_nominal::mac!(); + | --------------------- in this macro invocation + +error: type `priv_signature::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:47:21 + | +LL | let value = Pub::method; + | ^^^^^^^^^^^ +... +LL | priv_signature::mac!(); + | ----------------------- in this macro invocation + +error: type `priv_signature::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:49:9 + | +LL | value; + | ^^^^^ +... +LL | priv_signature::mac!(); + | ----------------------- in this macro invocation + +error: type `priv_signature::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:51:13 + | +LL | Pub.method(loop {}); + | ^^^^^^ +... +LL | priv_signature::mac!(); + | ----------------------- in this macro invocation + +error: type `priv_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:67:21 + | +LL | let value = Pub::method::; + | ^^^^^^^^^^^^^^^^^^^ +... +LL | priv_substs::mac!(); + | -------------------- in this macro invocation + +error: type `priv_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:69:9 + | +LL | value; + | ^^^^^ +... +LL | priv_substs::mac!(); + | -------------------- in this macro invocation + +error: type `priv_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:71:9 + | +LL | Pub.method::(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_substs::mac!(); + | -------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:90:21 + | +LL | let value = ::method; + | ^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:92:9 + | +LL | value; + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:94:21 + | +LL | let value = Pub::method; + | ^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:96:9 + | +LL | value; + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:98:21 + | +LL | let value = ::static_method; + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:100:9 + | +LL | value; + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:102:21 + | +LL | let value = Pub::static_method; + | ^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:104:9 + | +LL | value; + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:106:19 + | +LL | Pub(Priv).method(); + | ^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:109:10 + | +LL | ::CONST; + | ^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-inherent.rs:111:9 + | +LL | Pub::CONST; + | ^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: aborting due to 21 previous errors + diff --git a/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.rs b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.rs new file mode 100644 index 00000000000..bdc0c680a92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.rs @@ -0,0 +1,151 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +#![feature(decl_macro, associated_type_defaults)] +#![allow(unused, private_in_public)] + +mod priv_trait { + trait PrivTr { + fn method(&self) {} + const CONST: u8 = 0; + type AssocTy = u8; + } + pub struct Pub; + impl PrivTr for Pub {} + pub trait PubTr: PrivTr {} + + pub macro mac() { + let value = ::method; + //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private + value; + //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private + Pub.method(); + //~^ ERROR type `for<'r> fn(&'r Self) {::method}` is private + ::CONST; + //~^ ERROR associated constant `PrivTr::CONST` is private + let _: ::AssocTy; + //~^ ERROR trait `priv_trait::PrivTr` is private + //~| ERROR trait `priv_trait::PrivTr` is private + pub type InSignatureTy = ::AssocTy; + //~^ ERROR trait `priv_trait::PrivTr` is private + pub trait InSignatureTr: PrivTr {} + //~^ ERROR trait `priv_trait::PrivTr` is private + impl PrivTr for u8 {} + //~^ ERROR trait `priv_trait::PrivTr` is private + } +} +fn priv_trait() { + priv_trait::mac!(); +} + +mod priv_signature { + pub trait PubTr { + fn method(&self, arg: Priv) {} + } + struct Priv; + pub struct Pub; + impl PubTr for Pub {} + + pub macro mac() { + let value = ::method; + //~^ ERROR type `priv_signature::Priv` is private + value; + //~^ ERROR type `priv_signature::Priv` is private + Pub.method(loop {}); + //~^ ERROR type `priv_signature::Priv` is private + } +} +fn priv_signature() { + priv_signature::mac!(); +} + +mod priv_substs { + pub trait PubTr { + fn method(&self) {} + } + struct Priv; + pub struct Pub; + impl PubTr for Pub {} + + pub macro mac() { + let value = ::method::; + //~^ ERROR type `priv_substs::Priv` is private + value; + //~^ ERROR type `priv_substs::Priv` is private + Pub.method::(); + //~^ ERROR type `priv_substs::Priv` is private + } +} +fn priv_substs() { + priv_substs::mac!(); +} + +mod priv_parent_substs { + pub trait PubTr { + fn method(&self) {} + const CONST: u8 = 0; + type AssocTy = u8; + } + struct Priv; + pub struct Pub; + impl PubTr for Pub {} + impl PubTr for Priv {} + + pub macro mac() { + let value = ::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + let value = >::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + Pub.method(); + //~^ ERROR type `priv_parent_substs::Priv` is private + + let value = >::method; + //~^ ERROR type `priv_parent_substs::Priv` is private + value; + //~^ ERROR type `priv_parent_substs::Priv` is private + Priv.method(); + //~^ ERROR type `priv_parent_substs::Priv` is private + + ::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + >::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + >::CONST; + //~^ ERROR type `priv_parent_substs::Priv` is private + + let _: ::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + //~| ERROR type `priv_parent_substs::Priv` is private + let _: >::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + //~| ERROR type `priv_parent_substs::Priv` is private + let _: >::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + //~| ERROR type `priv_parent_substs::Priv` is private + + pub type InSignatureTy1 = ::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + pub type InSignatureTy2 = >::AssocTy; + //~^ ERROR type `priv_parent_substs::Priv` is private + impl PubTr for u8 {} + //~^ ERROR type `priv_parent_substs::Priv` is private + } +} +fn priv_parent_substs() { + priv_parent_substs::mac!(); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.stderr b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.stderr new file mode 100644 index 00000000000..5aac27346f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-trait.stderr @@ -0,0 +1,317 @@ +error: type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private + --> $DIR/associated-item-privacy-trait.rs:27:21 + | +LL | let value = ::method; + | ^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private + --> $DIR/associated-item-privacy-trait.rs:29:9 + | +LL | value; + | ^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: type `for<'r> fn(&'r Self) {::method}` is private + --> $DIR/associated-item-privacy-trait.rs:31:13 + | +LL | Pub.method(); + | ^^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: associated constant `PrivTr::CONST` is private + --> $DIR/associated-item-privacy-trait.rs:33:9 + | +LL | ::CONST; + | ^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: trait `priv_trait::PrivTr` is private + --> $DIR/associated-item-privacy-trait.rs:35:13 + | +LL | let _: ::AssocTy; + | ^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: trait `priv_trait::PrivTr` is private + --> $DIR/associated-item-privacy-trait.rs:35:16 + | +LL | let _: ::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: trait `priv_trait::PrivTr` is private + --> $DIR/associated-item-privacy-trait.rs:38:34 + | +LL | pub type InSignatureTy = ::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: trait `priv_trait::PrivTr` is private + --> $DIR/associated-item-privacy-trait.rs:40:34 + | +LL | pub trait InSignatureTr: PrivTr {} + | ^^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: trait `priv_trait::PrivTr` is private + --> $DIR/associated-item-privacy-trait.rs:42:14 + | +LL | impl PrivTr for u8 {} + | ^^^^^^ +... +LL | priv_trait::mac!(); + | ------------------- in this macro invocation + +error: type `priv_signature::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:59:21 + | +LL | let value = ::method; + | ^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_signature::mac!(); + | ----------------------- in this macro invocation + +error: type `priv_signature::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:61:9 + | +LL | value; + | ^^^^^ +... +LL | priv_signature::mac!(); + | ----------------------- in this macro invocation + +error: type `priv_signature::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:63:13 + | +LL | Pub.method(loop {}); + | ^^^^^^ +... +LL | priv_signature::mac!(); + | ----------------------- in this macro invocation + +error: type `priv_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:80:21 + | +LL | let value = ::method::; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_substs::mac!(); + | -------------------- in this macro invocation + +error: type `priv_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:82:9 + | +LL | value; + | ^^^^^ +... +LL | priv_substs::mac!(); + | -------------------- in this macro invocation + +error: type `priv_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:84:9 + | +LL | Pub.method::(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_substs::mac!(); + | -------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:104:21 + | +LL | let value = ::method; + | ^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:106:9 + | +LL | value; + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:108:21 + | +LL | let value = >::method; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:110:9 + | +LL | value; + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:112:9 + | +LL | Pub.method(); + | ^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:115:21 + | +LL | let value = >::method; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:117:9 + | +LL | value; + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:119:9 + | +LL | Priv.method(); + | ^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:122:9 + | +LL | ::CONST; + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:124:9 + | +LL | >::CONST; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:126:9 + | +LL | >::CONST; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:129:13 + | +LL | let _: ::AssocTy; + | ^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:129:16 + | +LL | let _: ::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:132:13 + | +LL | let _: >::AssocTy; + | ^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:132:16 + | +LL | let _: >::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:135:13 + | +LL | let _: >::AssocTy; + | ^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:135:16 + | +LL | let _: >::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:139:35 + | +LL | pub type InSignatureTy1 = ::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:141:35 + | +LL | pub type InSignatureTy2 = >::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-trait.rs:143:14 + | +LL | impl PubTr for u8 {} + | ^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: aborting due to 35 previous errors + diff --git a/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.rs b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.rs new file mode 100644 index 00000000000..6019369aa2e --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.rs @@ -0,0 +1,74 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(decl_macro, associated_type_defaults)] +#![allow(unused, private_in_public)] + +mod priv_trait { + trait PrivTr { + type AssocTy = u8; + } + pub trait PubTr: PrivTr {} + + pub macro mac1() { + let _: Box>; + //~^ ERROR type `(dyn priv_trait::PubTr + ')` is private + //~| ERROR type `(dyn priv_trait::PubTr + ')` is private + type InSignatureTy2 = Box>; + //~^ ERROR type `(dyn priv_trait::PubTr + 'static)` is private + trait InSignatureTr2: PubTr {} + //~^ ERROR trait `priv_trait::PrivTr` is private + } + pub macro mac2() { + let _: Box>; + //~^ ERROR type `(dyn priv_trait::PrivTr + ')` is private + //~| ERROR type `(dyn priv_trait::PrivTr + ')` is private + type InSignatureTy1 = Box>; + //~^ ERROR type `(dyn priv_trait::PrivTr + 'static)` is private + trait InSignatureTr1: PrivTr {} + //~^ ERROR trait `priv_trait::PrivTr` is private + } +} +fn priv_trait1() { + priv_trait::mac1!(); +} +fn priv_trait2() { + priv_trait::mac2!(); +} + +mod priv_parent_substs { + pub trait PubTrWithParam { + type AssocTy = u8; + } + struct Priv; + pub trait PubTr: PubTrWithParam {} + + pub macro mac() { + let _: Box>; + //~^ ERROR type `priv_parent_substs::Priv` is private + //~| ERROR type `priv_parent_substs::Priv` is private + let _: Box>; + //~^ ERROR type `priv_parent_substs::Priv` is private + //~| ERROR type `priv_parent_substs::Priv` is private + pub type InSignatureTy1 = Box>; + //~^ ERROR type `priv_parent_substs::Priv` is private + pub type InSignatureTy2 = Box>; + //~^ ERROR type `priv_parent_substs::Priv` is private + trait InSignatureTr1: PubTrWithParam {} + //~^ ERROR type `priv_parent_substs::Priv` is private + trait InSignatureTr2: PubTr {} + //~^ ERROR type `priv_parent_substs::Priv` is private + } +} +fn priv_parent_substs() { + priv_parent_substs::mac!(); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.stderr b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.stderr new file mode 100644 index 00000000000..e762dc62853 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/associated-item-privacy-type-binding.stderr @@ -0,0 +1,146 @@ +error: type `(dyn priv_trait::PubTr + ')` is private + --> $DIR/associated-item-privacy-type-binding.rs:21:13 + | +LL | let _: Box>; + | ^ +... +LL | priv_trait::mac1!(); + | -------------------- in this macro invocation + +error: type `(dyn priv_trait::PubTr + ')` is private + --> $DIR/associated-item-privacy-type-binding.rs:21:16 + | +LL | let _: Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac1!(); + | -------------------- in this macro invocation + +error: type `(dyn priv_trait::PubTr + 'static)` is private + --> $DIR/associated-item-privacy-type-binding.rs:24:31 + | +LL | type InSignatureTy2 = Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac1!(); + | -------------------- in this macro invocation + +error: trait `priv_trait::PrivTr` is private + --> $DIR/associated-item-privacy-type-binding.rs:26:31 + | +LL | trait InSignatureTr2: PubTr {} + | ^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac1!(); + | -------------------- in this macro invocation + +error: type `(dyn priv_trait::PrivTr + ')` is private + --> $DIR/associated-item-privacy-type-binding.rs:30:13 + | +LL | let _: Box>; + | ^ +... +LL | priv_trait::mac2!(); + | -------------------- in this macro invocation + +error: type `(dyn priv_trait::PrivTr + ')` is private + --> $DIR/associated-item-privacy-type-binding.rs:30:16 + | +LL | let _: Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac2!(); + | -------------------- in this macro invocation + +error: type `(dyn priv_trait::PrivTr + 'static)` is private + --> $DIR/associated-item-privacy-type-binding.rs:33:31 + | +LL | type InSignatureTy1 = Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac2!(); + | -------------------- in this macro invocation + +error: trait `priv_trait::PrivTr` is private + --> $DIR/associated-item-privacy-type-binding.rs:35:31 + | +LL | trait InSignatureTr1: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_trait::mac2!(); + | -------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:54:13 + | +LL | let _: Box>; + | ^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:54:16 + | +LL | let _: Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:57:13 + | +LL | let _: Box>; + | ^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:57:16 + | +LL | let _: Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:60:35 + | +LL | pub type InSignatureTy1 = Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:62:35 + | +LL | pub type InSignatureTy2 = Box>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:64:31 + | +LL | trait InSignatureTr1: PubTrWithParam {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: type `priv_parent_substs::Priv` is private + --> $DIR/associated-item-privacy-type-binding.rs:66:31 + | +LL | trait InSignatureTr2: PubTr {} + | ^^^^^^^^^^^^^^^^^^^ +... +LL | priv_parent_substs::mac!(); + | --------------------------- in this macro invocation + +error: aborting due to 16 previous errors + diff --git a/src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.rs b/src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.rs new file mode 100644 index 00000000000..95144916fd7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.rs @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +#![allow(unused)] + +use m::S; + +mod m { + pub struct S(u8); + + mod n { + use S; + fn f() { + S(10); + //~^ ERROR private struct constructors are not usable through re-exports in outer modules + //~| WARN this was previously accepted + } + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.stderr b/src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.stderr new file mode 100644 index 00000000000..7652d65a3a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/legacy-ctor-visibility.stderr @@ -0,0 +1,12 @@ +error: private struct constructors are not usable through re-exports in outer modules + --> $DIR/legacy-ctor-visibility.rs:23:13 + | +LL | S(10); + | ^ + | + = note: #[deny(legacy_constructor_visibility)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #39207 + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/auxiliary/pub_restricted.rs b/src/test/ui/compile-fail-migration/privacy/restricted/auxiliary/pub_restricted.rs new file mode 100644 index 00000000000..c4ab96c8456 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/auxiliary/pub_restricted.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(crate_visibility_modifier)] + +pub(crate) struct Crate; + +#[derive(Default)] +pub struct Universe { + pub x: i32, + pub(crate) y: i32, + crate z: i32, +} + +impl Universe { + pub fn f(&self) {} + pub(crate) fn g(&self) {} + crate fn h(&self) {} +} diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.rs b/src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.rs new file mode 100644 index 00000000000..abd71b9c90b --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.rs @@ -0,0 +1,44 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(warnings)] + +mod foo { + pub use foo::bar::S; + mod bar { + #[derive(Default)] + pub struct S { + pub(in foo) x: i32, + } + impl S { + pub(in foo) fn f(&self) -> i32 { 0 } + } + + pub struct S2 { + pub(crate) x: bool, + } + impl S2 { + pub(crate) fn f(&self) -> bool { false } + } + + impl ::std::ops::Deref for S { + type Target = S2; + fn deref(&self) -> &S2 { unimplemented!() } + } + } +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful + let s = foo::S::default(); + let _: bool = s.x; + let _: bool = s.f(); +} diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.stderr b/src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.stderr new file mode 100644 index 00000000000..7fc53e8c324 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/lookup-ignores-private.stderr @@ -0,0 +1,12 @@ +error: compilation successful + --> $DIR/lookup-ignores-private.rs:40:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | let s = foo::S::default(); +LL | | let _: bool = s.x; +LL | | let _: bool = s.f(); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.rs b/src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.rs new file mode 100644 index 00000000000..4d3f5377797 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(crate_visibility_modifier)] + +mod foo { + struct Priv; + mod bar { + use foo::Priv; + pub(super) fn f(_: Priv) {} + pub(crate) fn g(_: Priv) {} //~ ERROR E0446 + crate fn h(_: Priv) {} //~ ERROR E0446 + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.stderr b/src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.stderr new file mode 100644 index 00000000000..e0d3abdc213 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/private-in-public.stderr @@ -0,0 +1,21 @@ +error[E0446]: private type `foo::Priv` in public interface + --> $DIR/private-in-public.rs:18:9 + | +LL | struct Priv; + | - `foo::Priv` declared as private +... +LL | pub(crate) fn g(_: Priv) {} //~ ERROR E0446 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `foo::Priv` in public interface + --> $DIR/private-in-public.rs:19:9 + | +LL | struct Priv; + | - `foo::Priv` declared as private +... +LL | crate fn h(_: Priv) {} //~ ERROR E0446 + | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.rs b/src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.rs new file mode 100644 index 00000000000..21d90dfea4b --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(warnings)] + +mod foo { + pub mod bar { + pub struct S { + pub(in foo) x: i32, + } + } + + fn f() { + use foo::bar::S; + S { x: 0 }; // ok + } +} + +fn main() { + use foo::bar::S; + S { x: 0 }; //~ ERROR private +} diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.stderr b/src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.stderr new file mode 100644 index 00000000000..6d668c8767a --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/struct-literal-field.stderr @@ -0,0 +1,9 @@ +error[E0451]: field `x` of struct `foo::bar::S` is private + --> $DIR/struct-literal-field.rs:28:9 + | +LL | S { x: 0 }; //~ ERROR private + | ^^^^ field `x` is private + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/test.rs b/src/test/ui/compile-fail-migration/privacy/restricted/test.rs new file mode 100644 index 00000000000..8c1d609e244 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/test.rs @@ -0,0 +1,62 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:pub_restricted.rs + +#![allow(warnings)] +extern crate pub_restricted; + +mod foo { + pub mod bar { + pub(super) fn f() {} + #[derive(Default)] + pub struct S { + pub(super) x: i32, + } + impl S { + pub(super) fn f(&self) {} + pub(super) fn g() {} + } + } + fn f() { + use foo::bar::S; + pub(self) use foo::bar::f; // ok + pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported + S::default().x; // ok + S::default().f(); // ok + S::g(); // ok + } +} + +fn f() { + use foo::bar::S; + use foo::bar::f; //~ ERROR private + S::default().x; //~ ERROR private + S::default().f(); //~ ERROR private + S::g(); //~ ERROR private +} + +fn main() { + use pub_restricted::Universe; + use pub_restricted::Crate; //~ ERROR private + + let u = Universe::default(); + let _ = u.x; + let _ = u.y; //~ ERROR private + let _ = u.z; //~ ERROR private + u.f(); + u.g(); //~ ERROR private + u.h(); //~ ERROR private +} + +mod pathological { + pub(in bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`? + pub(in foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules +} diff --git a/src/test/ui/compile-fail-migration/privacy/restricted/test.stderr b/src/test/ui/compile-fail-migration/privacy/restricted/test.stderr new file mode 100644 index 00000000000..67a95c35590 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/restricted/test.stderr @@ -0,0 +1,82 @@ +error[E0433]: failed to resolve. Maybe a missing `extern crate bad;`? + --> $DIR/test.rs:60:12 + | +LL | pub(in bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`? + | ^^^ Maybe a missing `extern crate bad;`? + +error: visibilities can only be restricted to ancestor modules + --> $DIR/test.rs:61:12 + | +LL | pub(in foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules + | ^^^ + +error[E0364]: `f` is private, and cannot be re-exported + --> $DIR/test.rs:31:24 + | +LL | pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported + | ^^^^^^^^^^^^^^^^ + | +note: consider marking `f` as `pub` in the imported module + --> $DIR/test.rs:31:24 + | +LL | pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported + | ^^^^^^^^^^^^^^^^ + +error[E0603]: struct `Crate` is private + --> $DIR/test.rs:48:9 + | +LL | use pub_restricted::Crate; //~ ERROR private + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: function `f` is private + --> $DIR/test.rs:40:9 + | +LL | use foo::bar::f; //~ ERROR private + | ^^^^^^^^^^^ + +error[E0616]: field `x` of struct `foo::bar::S` is private + --> $DIR/test.rs:41:5 + | +LL | S::default().x; //~ ERROR private + | ^^^^^^^^^^^^^^ + +error[E0624]: method `f` is private + --> $DIR/test.rs:42:18 + | +LL | S::default().f(); //~ ERROR private + | ^ + +error[E0624]: method `g` is private + --> $DIR/test.rs:43:5 + | +LL | S::g(); //~ ERROR private + | ^^^^ + +error[E0616]: field `y` of struct `pub_restricted::Universe` is private + --> $DIR/test.rs:52:13 + | +LL | let _ = u.y; //~ ERROR private + | ^^^ + +error[E0616]: field `z` of struct `pub_restricted::Universe` is private + --> $DIR/test.rs:53:13 + | +LL | let _ = u.z; //~ ERROR private + | ^^^ + +error[E0624]: method `g` is private + --> $DIR/test.rs:55:7 + | +LL | u.g(); //~ ERROR private + | ^ + +error[E0624]: method `h` is private + --> $DIR/test.rs:56:7 + | +LL | u.h(); //~ ERROR private + | ^ + +error: aborting due to 12 previous errors + +Some errors occurred: E0364, E0433, E0603, E0616, E0624. +For more information about an error, try `rustc --explain E0364`. diff --git a/src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.rs b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.rs new file mode 100644 index 00000000000..eeebb1b737a --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m { + pub union U { + pub a: u8, + pub(super) b: u8, + c: u8, + } +} + +fn main() { unsafe { + let u = m::U { a: 0 }; // OK + let u = m::U { b: 0 }; // OK + let u = m::U { c: 0 }; //~ ERROR field `c` of union `m::U` is private + + let m::U { a } = u; // OK + let m::U { b } = u; // OK + let m::U { c } = u; //~ ERROR field `c` of union `m::U` is private +}} diff --git a/src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.stderr b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.stderr new file mode 100644 index 00000000000..c93760a1b89 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-1.stderr @@ -0,0 +1,15 @@ +error[E0451]: field `c` of union `m::U` is private + --> $DIR/union-field-privacy-1.rs:22:20 + | +LL | let u = m::U { c: 0 }; //~ ERROR field `c` of union `m::U` is private + | ^^^^ field `c` is private + +error[E0451]: field `c` of union `m::U` is private + --> $DIR/union-field-privacy-1.rs:26:16 + | +LL | let m::U { c } = u; //~ ERROR field `c` of union `m::U` is private + | ^ field `c` is private + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.rs b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.rs new file mode 100644 index 00000000000..d6bb765202d --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m { + pub union U { + pub a: u8, + pub(super) b: u8, + c: u8, + } +} + +fn main() { + let u = m::U { a: 10 }; + + let a = u.a; // OK + let b = u.b; // OK + let c = u.c; //~ ERROR field `c` of struct `m::U` is private +} diff --git a/src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.stderr b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.stderr new file mode 100644 index 00000000000..cc12483a653 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy/union-field-privacy-2.stderr @@ -0,0 +1,9 @@ +error[E0616]: field `c` of struct `m::U` is private + --> $DIR/union-field-privacy-2.rs:24:13 + | +LL | let c = u.c; //~ ERROR field `c` of struct `m::U` is private + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0616`. diff --git a/src/test/ui/compile-fail-migration/privacy1.rs b/src/test/ui/compile-fail-migration/privacy1.rs new file mode 100644 index 00000000000..afe8c2fda3d --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy1.rs @@ -0,0 +1,172 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items, start, no_core)] +#![no_core] // makes debugging this test *a lot* easier (during resolve) + +#[lang="sized"] +pub trait Sized {} + +#[lang="copy"] +pub trait Copy {} + +mod bar { + // shouldn't bring in too much + pub use self::glob::*; + + // can't publicly re-export private items + pub use self::baz::{foo, bar}; + + pub struct A; + impl A { + pub fn foo() {} + fn bar() {} + + pub fn foo2(&self) {} + fn bar2(&self) {} + } + + trait B { + fn foo() -> Self; + } + + impl B for isize { fn foo() -> isize { 3 } } + + pub enum Enum { + Pub + } + + mod baz { + pub struct A; + impl A { + pub fn foo() {} + fn bar() {} + + pub fn foo2(&self) {} + fn bar2(&self) {} + } + + pub fn foo() {} + pub fn bar() {} + } + + extern { + fn epriv(); + pub fn epub(); + } + + fn test() { + self::Enum::Pub; + unsafe { + epriv(); + epub(); + } + self::baz::A; + self::baz::A::foo(); + self::baz::A::bar(); //~ ERROR: method `bar` is private + self::baz::A.foo2(); + + // this used to cause an ICE in privacy traversal. + super::gpub(); + } + + mod glob { + pub fn gpub() {} + fn gpriv() {} + } +} + +pub fn gpub() {} + +fn lol() { + bar::A; + bar::A::foo(); + bar::A::bar(); //~ ERROR: method `bar` is private + bar::A.foo2(); +} + +mod foo { + fn test() { + ::bar::A::foo(); + ::bar::A::bar(); //~ ERROR: method `bar` is private + ::bar::A.foo2(); + ::bar::baz::A::foo(); //~ ERROR: module `baz` is private + ::bar::baz::A::bar(); //~ ERROR: module `baz` is private + //~^ ERROR: method `bar` is private + ::bar::baz::A.foo2(); //~ ERROR: module `baz` is private + ::bar::baz::A.bar2(); //~ ERROR: module `baz` is private + //~^ ERROR: method `bar2` is private + + let _: isize = + ::bar::B::foo(); //~ ERROR: trait `B` is private + ::lol(); + + ::bar::Enum::Pub; + + unsafe { + ::bar::epriv(); //~ ERROR: function `epriv` is private + ::bar::epub(); + } + + ::bar::foo(); + ::bar::bar(); + + ::bar::gpub(); + + ::bar::baz::foo(); //~ ERROR: module `baz` is private + ::bar::baz::bar(); //~ ERROR: module `baz` is private + } + + fn test2() { + use bar::baz::{foo, bar}; + //~^ ERROR: module `baz` is private + //~| ERROR: module `baz` is private + + foo(); + bar(); + } + + fn test3() { + use bar::baz; + //~^ ERROR: module `baz` is private + } + + fn test4() { + use bar::{foo, bar}; + foo(); + bar(); + } + + fn test5() { + use bar; + bar::foo(); + bar::bar(); + } + + impl ::bar::B for f32 { fn foo() -> f32 { 1.0 } } + //~^ ERROR: trait `B` is private +} + +pub mod mytest { + // Even though the inner `A` struct is a publicly exported item (usable from + // external crates through `foo::foo`, it should not be accessible through + // its definition path (which has the private `i` module). + use self::foo::i::A; //~ ERROR: module `i` is private + + pub mod foo { + pub use self::i::A as foo; + + mod i { + pub struct A; + } + } +} + +#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/ui/compile-fail-migration/privacy1.stderr b/src/test/ui/compile-fail-migration/privacy1.stderr new file mode 100644 index 00000000000..344f990699f --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy1.stderr @@ -0,0 +1,112 @@ +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:128:24 + | +LL | use bar::baz::{foo, bar}; + | ^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:128:29 + | +LL | use bar::baz::{foo, bar}; + | ^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:137:13 + | +LL | use bar::baz; + | ^^^^^^^^ + +error[E0603]: module `i` is private + --> $DIR/privacy1.rs:161:9 + | +LL | use self::foo::i::A; //~ ERROR: module `i` is private + | ^^^^^^^^^^^^^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:100:9 + | +LL | ::bar::baz::A::foo(); //~ ERROR: module `baz` is private + | ^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:101:9 + | +LL | ::bar::baz::A::bar(); //~ ERROR: module `baz` is private + | ^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:103:9 + | +LL | ::bar::baz::A.foo2(); //~ ERROR: module `baz` is private + | ^^^^^^^^^^^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:104:9 + | +LL | ::bar::baz::A.bar2(); //~ ERROR: module `baz` is private + | ^^^^^^^^^^^^^ + +error[E0603]: trait `B` is private + --> $DIR/privacy1.rs:108:9 + | +LL | ::bar::B::foo(); //~ ERROR: trait `B` is private + | ^^^^^^^^^^^^^ + +error[E0603]: function `epriv` is private + --> $DIR/privacy1.rs:114:13 + | +LL | ::bar::epriv(); //~ ERROR: function `epriv` is private + | ^^^^^^^^^^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:123:9 + | +LL | ::bar::baz::foo(); //~ ERROR: module `baz` is private + | ^^^^^^^^^^^^^^^ + +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:124:9 + | +LL | ::bar::baz::bar(); //~ ERROR: module `baz` is private + | ^^^^^^^^^^^^^^^ + +error[E0603]: trait `B` is private + --> $DIR/privacy1.rs:153:10 + | +LL | impl ::bar::B for f32 { fn foo() -> f32 { 1.0 } } + | ^^^^^^^^ + +error[E0624]: method `bar` is private + --> $DIR/privacy1.rs:73:9 + | +LL | self::baz::A::bar(); //~ ERROR: method `bar` is private + | ^^^^^^^^^^^^^^^^^ + +error[E0624]: method `bar` is private + --> $DIR/privacy1.rs:91:5 + | +LL | bar::A::bar(); //~ ERROR: method `bar` is private + | ^^^^^^^^^^^ + +error[E0624]: method `bar` is private + --> $DIR/privacy1.rs:98:9 + | +LL | ::bar::A::bar(); //~ ERROR: method `bar` is private + | ^^^^^^^^^^^^^ + +error[E0624]: method `bar` is private + --> $DIR/privacy1.rs:101:9 + | +LL | ::bar::baz::A::bar(); //~ ERROR: module `baz` is private + | ^^^^^^^^^^^^^^^^^^ + +error[E0624]: method `bar2` is private + --> $DIR/privacy1.rs:104:23 + | +LL | ::bar::baz::A.bar2(); //~ ERROR: module `baz` is private + | ^^^^ + +error: aborting due to 18 previous errors + +Some errors occurred: E0603, E0624. +For more information about an error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/privacy2.rs b/src/test/ui/compile-fail-migration/privacy2.rs new file mode 100644 index 00000000000..113dd287940 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy2.rs @@ -0,0 +1,37 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(start, no_core)] +#![no_core] // makes debugging this test *a lot* easier (during resolve) + +// Test to make sure that globs don't leak in regular `use` statements. + +mod bar { + pub use self::glob::*; + + pub mod glob { + use foo; + } +} + +pub fn foo() {} + +fn test1() { + use bar::foo; + //~^ ERROR unresolved import `bar::foo` [E0432] + //~| no `foo` in `bar` +} + +fn test2() { + use bar::glob::foo; + //~^ ERROR `foo` is private +} + +#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/ui/compile-fail-migration/privacy2.stderr b/src/test/ui/compile-fail-migration/privacy2.stderr new file mode 100644 index 00000000000..ec5567b25e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy2.stderr @@ -0,0 +1,18 @@ +error[E0432]: unresolved import `bar::foo` + --> $DIR/privacy2.rs:27:9 + | +LL | use bar::foo; + | ^^^^^^^^ no `foo` in `bar` + +error[E0603]: function `foo` is private + --> $DIR/privacy2.rs:33:9 + | +LL | use bar::glob::foo; + | ^^^^^^^^^^^^^^ + +error: requires `sized` lang_item + +error: aborting due to 3 previous errors + +Some errors occurred: E0432, E0603. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/privacy3.rs b/src/test/ui/compile-fail-migration/privacy3.rs new file mode 100644 index 00000000000..b841717bd11 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy3.rs @@ -0,0 +1,37 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(start, no_core)] +#![no_core] // makes debugging this test *a lot* easier (during resolve) + +// Test to make sure that private items imported through globs remain private +// when they're used. + +mod bar { + pub use self::glob::*; + + mod glob { + fn gpriv() {} + } +} + +pub fn foo() {} + +fn test1() { + use bar::gpriv; + //~^ ERROR unresolved import `bar::gpriv` [E0432] + //~| no `gpriv` in `bar` + + // This should pass because the compiler will insert a fake name binding + // for `gpriv` + gpriv(); +} + +#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/ui/compile-fail-migration/privacy3.stderr b/src/test/ui/compile-fail-migration/privacy3.stderr new file mode 100644 index 00000000000..11c71616d90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy3.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `bar::gpriv` + --> $DIR/privacy3.rs:28:9 + | +LL | use bar::gpriv; + | ^^^^^^^^^^ no `gpriv` in `bar` + +error: requires `sized` lang_item + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/privacy4.rs b/src/test/ui/compile-fail-migration/privacy4.rs new file mode 100644 index 00000000000..d9f76744284 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy4.rs @@ -0,0 +1,35 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items, start, no_core)] +#![no_core] // makes debugging this test *a lot* easier (during resolve) + +#[lang = "sized"] pub trait Sized {} +#[lang="copy"] pub trait Copy {} + +// Test to make sure that private items imported through globs remain private +// when they're used. + +mod bar { + pub use self::glob::*; + + mod glob { + fn gpriv() {} + } +} + +pub fn foo() {} + +fn test2() { + use bar::glob::gpriv; //~ ERROR: module `glob` is private + gpriv(); +} + +#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/ui/compile-fail-migration/privacy4.stderr b/src/test/ui/compile-fail-migration/privacy4.stderr new file mode 100644 index 00000000000..811f5d5942a --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy4.stderr @@ -0,0 +1,9 @@ +error[E0603]: module `glob` is private + --> $DIR/privacy4.rs:31:9 + | +LL | use bar::glob::gpriv; //~ ERROR: module `glob` is private + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/privacy5.rs b/src/test/ui/compile-fail-migration/privacy5.rs new file mode 100644 index 00000000000..599c1f87160 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy5.rs @@ -0,0 +1,138 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:privacy_tuple_struct.rs + +extern crate privacy_tuple_struct as other; + +mod a { + pub struct A(()); + pub struct B(isize); + pub struct C(pub isize, isize); + pub struct D(pub isize); + + fn test() { + let a = A(()); + let b = B(2); + let c = C(2, 3); + let d = D(4); + + let A(()) = a; + let A(_) = a; + match a { A(()) => {} } + match a { A(_) => {} } + + let B(_) = b; + let B(_b) = b; + match b { B(_) => {} } + match b { B(_b) => {} } + match b { B(1) => {} B(_) => {} } + + let C(_, _) = c; + let C(_a, _) = c; + let C(_, _b) = c; + let C(_a, _b) = c; + match c { C(_, _) => {} } + match c { C(_a, _) => {} } + match c { C(_, _b) => {} } + match c { C(_a, _b) => {} } + + let D(_) = d; + let D(_d) = d; + match d { D(_) => {} } + match d { D(_d) => {} } + match d { D(1) => {} D(_) => {} } + + let a2 = A; + let b2 = B; + let c2 = C; + let d2 = D; + } +} + +fn this_crate() { + let a = a::A(()); //~ ERROR tuple struct `A` is private + let b = a::B(2); //~ ERROR tuple struct `B` is private + let c = a::C(2, 3); //~ ERROR tuple struct `C` is private + let d = a::D(4); + + let a::A(()) = a; //~ ERROR tuple struct `A` is private + let a::A(_) = a; //~ ERROR tuple struct `A` is private + match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private + match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private + + let a::B(_) = b; //~ ERROR tuple struct `B` is private + let a::B(_b) = b; //~ ERROR tuple struct `B` is private + match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private + match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private + match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private + //~^ ERROR tuple struct `B` is private + + let a::C(_, _) = c; //~ ERROR tuple struct `C` is private + let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private + let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private + let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private + match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private + match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private + match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private + match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private + + let a::D(_) = d; + let a::D(_d) = d; + match d { a::D(_) => {} } + match d { a::D(_d) => {} } + match d { a::D(1) => {} a::D(_) => {} } + + let a2 = a::A; //~ ERROR tuple struct `A` is private + let b2 = a::B; //~ ERROR tuple struct `B` is private + let c2 = a::C; //~ ERROR tuple struct `C` is private + let d2 = a::D; +} + +fn xcrate() { + let a = other::A(()); //~ ERROR tuple struct `A` is private + let b = other::B(2); //~ ERROR tuple struct `B` is private + let c = other::C(2, 3); //~ ERROR tuple struct `C` is private + let d = other::D(4); + + let other::A(()) = a; //~ ERROR tuple struct `A` is private + let other::A(_) = a; //~ ERROR tuple struct `A` is private + match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private + match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private + + let other::B(_) = b; //~ ERROR tuple struct `B` is private + let other::B(_b) = b; //~ ERROR tuple struct `B` is private + match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private + match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private + match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private + //~^ ERROR tuple struct `B` is private + + let other::C(_, _) = c; //~ ERROR tuple struct `C` is private + let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private + let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private + let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private + match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private + match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private + match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private + match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private + + let other::D(_) = d; + let other::D(_d) = d; + match d { other::D(_) => {} } + match d { other::D(_d) => {} } + match d { other::D(1) => {} other::D(_) => {} } + + let a2 = other::A; //~ ERROR tuple struct `A` is private + let b2 = other::B; //~ ERROR tuple struct `B` is private + let c2 = other::C; //~ ERROR tuple struct `C` is private + let d2 = other::D; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/privacy5.stderr b/src/test/ui/compile-fail-migration/privacy5.stderr new file mode 100644 index 00000000000..bcb63151362 --- /dev/null +++ b/src/test/ui/compile-fail-migration/privacy5.stderr @@ -0,0 +1,291 @@ +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:61:13 + | +LL | let a = a::A(()); //~ ERROR tuple struct `A` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:62:13 + | +LL | let b = a::B(2); //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:63:13 + | +LL | let c = a::C(2, 3); //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:66:9 + | +LL | let a::A(()) = a; //~ ERROR tuple struct `A` is private + | ^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:67:9 + | +LL | let a::A(_) = a; //~ ERROR tuple struct `A` is private + | ^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:68:15 + | +LL | match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private + | ^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:69:15 + | +LL | match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:71:9 + | +LL | let a::B(_) = b; //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:72:9 + | +LL | let a::B(_b) = b; //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:73:15 + | +LL | match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:74:15 + | +LL | match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:75:15 + | +LL | match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:75:29 + | +LL | match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:78:9 + | +LL | let a::C(_, _) = c; //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:79:9 + | +LL | let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:80:9 + | +LL | let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:81:9 + | +LL | let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:82:15 + | +LL | match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:83:15 + | +LL | match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:84:15 + | +LL | match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:85:15 + | +LL | match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:93:14 + | +LL | let a2 = a::A; //~ ERROR tuple struct `A` is private + | ^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:94:14 + | +LL | let b2 = a::B; //~ ERROR tuple struct `B` is private + | ^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:95:14 + | +LL | let c2 = a::C; //~ ERROR tuple struct `C` is private + | ^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:100:13 + | +LL | let a = other::A(()); //~ ERROR tuple struct `A` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:101:13 + | +LL | let b = other::B(2); //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:102:13 + | +LL | let c = other::C(2, 3); //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:105:9 + | +LL | let other::A(()) = a; //~ ERROR tuple struct `A` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:106:9 + | +LL | let other::A(_) = a; //~ ERROR tuple struct `A` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:107:15 + | +LL | match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:108:15 + | +LL | match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:110:9 + | +LL | let other::B(_) = b; //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:111:9 + | +LL | let other::B(_b) = b; //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:112:15 + | +LL | match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:113:15 + | +LL | match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:114:15 + | +LL | match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:114:33 + | +LL | match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:117:9 + | +LL | let other::C(_, _) = c; //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:118:9 + | +LL | let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:119:9 + | +LL | let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:120:9 + | +LL | let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:121:15 + | +LL | match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:122:15 + | +LL | match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:123:15 + | +LL | match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:124:15 + | +LL | match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `A` is private + --> $DIR/privacy5.rs:132:14 + | +LL | let a2 = other::A; //~ ERROR tuple struct `A` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `B` is private + --> $DIR/privacy5.rs:133:14 + | +LL | let b2 = other::B; //~ ERROR tuple struct `B` is private + | ^^^^^^^^ + +error[E0603]: tuple struct `C` is private + --> $DIR/privacy5.rs:134:14 + | +LL | let c2 = other::C; //~ ERROR tuple struct `C` is private + | ^^^^^^^^ + +error: aborting due to 48 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/private-impl-method.rs b/src/test/ui/compile-fail-migration/private-impl-method.rs new file mode 100644 index 00000000000..e04380f12ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-impl-method.rs @@ -0,0 +1,31 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + pub struct Foo { + pub x: isize + } + + impl Foo { + fn foo(&self) {} + } +} + +fn f() { + impl a::Foo { + fn bar(&self) {} // This should be visible outside `f` + } +} + +fn main() { + let s = a::Foo { x: 1 }; + s.bar(); + s.foo(); //~ ERROR method `foo` is private +} diff --git a/src/test/ui/compile-fail-migration/private-impl-method.stderr b/src/test/ui/compile-fail-migration/private-impl-method.stderr new file mode 100644 index 00000000000..0e36c7003ee --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-impl-method.stderr @@ -0,0 +1,9 @@ +error[E0624]: method `foo` is private + --> $DIR/private-impl-method.rs:30:7 + | +LL | s.foo(); //~ ERROR method `foo` is private + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/private-in-public-assoc-ty.rs b/src/test/ui/compile-fail-migration/private-in-public-assoc-ty.rs new file mode 100644 index 00000000000..59dee256642 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-assoc-ty.rs @@ -0,0 +1,43 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Private types and traits are not allowed in interfaces of associated types. +// This test also ensures that the checks are performed even inside private modules. + +#![feature(associated_type_defaults)] + +mod m { + struct Priv; + trait PrivTr {} + impl PrivTr for Priv {} + pub trait PubTrAux1 {} + pub trait PubTrAux2 { type A; } + + // "Private-in-public in associated types is hard error" in RFC 2145 + // applies only to the aliased types, not bounds. + pub trait PubTr { + //~^ WARN private trait `m::PrivTr` in public interface + //~| WARN this was previously accepted + //~| WARN private type `m::Priv` in public interface + //~| WARN this was previously accepted + type Alias1: PrivTr; + type Alias2: PubTrAux1 = u8; + type Alias3: PubTrAux2 = u8; + + type Alias4 = Priv; + //~^ ERROR private type `m::Priv` in public interface + } + impl PubTr for u8 { + type Alias1 = Priv; + //~^ ERROR private type `m::Priv` in public interface + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/private-in-public-assoc-ty.stderr b/src/test/ui/compile-fail-migration/private-in-public-assoc-ty.stderr new file mode 100644 index 00000000000..a95547bc507 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-assoc-ty.stderr @@ -0,0 +1,52 @@ +warning: private trait `m::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-assoc-ty.rs:25:5 + | +LL | / pub trait PubTr { +LL | | //~^ WARN private trait `m::PrivTr` in public interface +LL | | //~| WARN this was previously accepted +LL | | //~| WARN private type `m::Priv` in public interface +... | +LL | | //~^ ERROR private type `m::Priv` in public interface +LL | | } + | |_____^ + | + = note: #[warn(private_in_public)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +warning: private type `m::Priv` in public interface (error E0446) + --> $DIR/private-in-public-assoc-ty.rs:25:5 + | +LL | / pub trait PubTr { +LL | | //~^ WARN private trait `m::PrivTr` in public interface +LL | | //~| WARN this was previously accepted +LL | | //~| WARN private type `m::Priv` in public interface +... | +LL | | //~^ ERROR private type `m::Priv` in public interface +LL | | } + | |_____^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error[E0446]: private type `m::Priv` in public interface + --> $DIR/private-in-public-assoc-ty.rs:34:9 + | +LL | struct Priv; + | - `m::Priv` declared as private +... +LL | type Alias4 = Priv; + | ^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `m::Priv` in public interface + --> $DIR/private-in-public-assoc-ty.rs:38:9 + | +LL | struct Priv; + | - `m::Priv` declared as private +... +LL | type Alias1 = Priv; + | ^^^^^^^^^^^^^^^^^^^ can't leak private type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/compile-fail-migration/private-in-public-ill-formed.rs b/src/test/ui/compile-fail-migration/private-in-public-ill-formed.rs new file mode 100644 index 00000000000..480406054ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-ill-formed.rs @@ -0,0 +1,45 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod aliases_pub { + struct Priv; + mod m { + pub struct Pub3; + } + + trait PrivTr { + type AssocAlias; + } + impl PrivTr for Priv { + type AssocAlias = m::Pub3; + } + + impl ::AssocAlias { //~ ERROR no base type found for inherent implementation + pub fn f(arg: Priv) {} // private type `aliases_pub::Priv` in public interface + } +} + +mod aliases_priv { + struct Priv; + struct Priv3; + + trait PrivTr { + type AssocAlias; + } + impl PrivTr for Priv { + type AssocAlias = Priv3; + } + + impl ::AssocAlias { //~ ERROR no base type found for inherent implementation + pub fn f(arg: Priv) {} // OK + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/private-in-public-ill-formed.stderr b/src/test/ui/compile-fail-migration/private-in-public-ill-formed.stderr new file mode 100644 index 00000000000..649f5fc2fca --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-ill-formed.stderr @@ -0,0 +1,19 @@ +error[E0118]: no base type found for inherent implementation + --> $DIR/private-in-public-ill-formed.rs:24:10 + | +LL | impl ::AssocAlias { //~ ERROR no base type found for inherent implementation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl requires a base type + | + = note: either implement a trait on it or create a newtype to wrap it instead + +error[E0118]: no base type found for inherent implementation + --> $DIR/private-in-public-ill-formed.rs:40:10 + | +LL | impl ::AssocAlias { //~ ERROR no base type found for inherent implementation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl requires a base type + | + = note: either implement a trait on it or create a newtype to wrap it instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0118`. diff --git a/src/test/ui/compile-fail-migration/private-in-public-lint.rs b/src/test/ui/compile-fail-migration/private-in-public-lint.rs new file mode 100644 index 00000000000..fd92300cd15 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-lint.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m1 { + pub struct Pub; + struct Priv; + + impl Pub { + pub fn f() -> Priv {Priv} //~ ERROR private type `m1::Priv` in public interface + } +} + +mod m2 { + pub struct Pub; + struct Priv; + + impl Pub { + pub fn f() -> Priv {Priv} //~ ERROR private type `m2::Priv` in public interface + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/private-in-public-lint.stderr b/src/test/ui/compile-fail-migration/private-in-public-lint.stderr new file mode 100644 index 00000000000..202cb342d8c --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-lint.stderr @@ -0,0 +1,21 @@ +error[E0446]: private type `m1::Priv` in public interface + --> $DIR/private-in-public-lint.rs:16:9 + | +LL | struct Priv; + | - `m1::Priv` declared as private +... +LL | pub fn f() -> Priv {Priv} //~ ERROR private type `m1::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `m2::Priv` in public interface + --> $DIR/private-in-public-lint.rs:25:9 + | +LL | struct Priv; + | - `m2::Priv` declared as private +... +LL | pub fn f() -> Priv {Priv} //~ ERROR private type `m2::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/compile-fail-migration/private-in-public-warn.rs b/src/test/ui/compile-fail-migration/private-in-public-warn.rs new file mode 100644 index 00000000000..6eeb14638e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-warn.rs @@ -0,0 +1,282 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Private types and traits are not allowed in public interfaces. +// This test also ensures that the checks are performed even inside private modules. + +#![feature(associated_type_defaults)] +#![deny(private_in_public)] +#![allow(improper_ctypes)] + +mod types { + struct Priv; + pub struct Pub; + pub trait PubTr { + type Alias; + } + + pub type Alias = Priv; //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + pub enum E { + V1(Priv), //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + V2 { field: Priv }, //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + } + pub trait Tr { + const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + type Alias = Priv; //~ ERROR private type `types::Priv` in public interface + fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + } + extern { + pub static ES: Priv; //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + pub fn ef1(arg: Priv); //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + pub fn ef2() -> Priv; //~ ERROR private type `types::Priv` in public interface + //~^ WARNING hard error + } + impl PubTr for Pub { + type Alias = Priv; //~ ERROR private type `types::Priv` in public interface + } +} + +mod traits { + trait PrivTr {} + pub struct Pub(T); + pub trait PubTr {} + + pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface + //~| WARNING hard error + pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface + //~^ WARNING hard error + pub trait Tr2 {} //~ ERROR private trait `traits::PrivTr` in public interface + //~^ WARNING hard error + pub trait Tr3 { + //~^ ERROR private trait `traits::PrivTr` in public interface + //~| WARNING hard error + type Alias: PrivTr; + fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface + //~^ WARNING hard error + } + impl Pub {} //~ ERROR private trait `traits::PrivTr` in public interface + //~^ WARNING hard error + impl PubTr for Pub {} //~ ERROR private trait `traits::PrivTr` in public interface + //~^ WARNING hard error +} + +mod traits_where { + trait PrivTr {} + pub struct Pub(T); + pub trait PubTr {} + + pub type Alias where T: PrivTr = T; + //~^ ERROR private trait `traits_where::PrivTr` in public interface + //~| WARNING hard error + pub trait Tr2 where T: PrivTr {} + //~^ ERROR private trait `traits_where::PrivTr` in public interface + //~| WARNING hard error + pub trait Tr3 { + fn f(arg: T) where T: PrivTr {} + //~^ ERROR private trait `traits_where::PrivTr` in public interface + //~| WARNING hard error + } + impl Pub where T: PrivTr {} + //~^ ERROR private trait `traits_where::PrivTr` in public interface + //~| WARNING hard error + impl PubTr for Pub where T: PrivTr {} + //~^ ERROR private trait `traits_where::PrivTr` in public interface + //~| WARNING hard error +} + +mod generics { + struct Priv(T); + pub struct Pub(T); + trait PrivTr {} + pub trait PubTr {} + + pub trait Tr1: PrivTr {} + //~^ ERROR private trait `generics::PrivTr` in public interface + //~| WARNING hard error + pub trait Tr2: PubTr {} //~ ERROR private type `generics::Priv` in public interface + //~^ WARNING hard error + pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Priv` in public interface + //~^ WARNING hard error + pub trait Tr4: PubTr> {} //~ ERROR private type `generics::Priv` in public interface + //~^ WARNING hard error +} + +mod impls { + struct Priv; + pub struct Pub; + trait PrivTr { + type Alias; + } + pub trait PubTr { + type Alias; + } + + impl Priv { + pub fn f(arg: Priv) {} // OK + } + impl PrivTr for Priv { + type Alias = Priv; // OK + } + impl PubTr for Priv { + type Alias = Priv; // OK + } + impl PrivTr for Pub { + type Alias = Priv; // OK + } + impl PubTr for Pub { + type Alias = Priv; //~ ERROR private type `impls::Priv` in public interface + } +} + +mod impls_generics { + struct Priv(T); + pub struct Pub(T); + trait PrivTr { + type Alias; + } + pub trait PubTr { + type Alias; + } + + impl Priv { + pub fn f(arg: Priv) {} // OK + } + impl Pub { + pub fn f(arg: Priv) {} // OK + } + impl PrivTr for Priv { + type Alias = Priv; // OK + } + impl PubTr for Priv { + type Alias = Priv; // OK + } + impl PubTr for Priv { + type Alias = Priv; // OK + } + impl PubTr for [Priv; 1] { + type Alias = Priv; // OK + } + impl PubTr for Pub { + type Alias = Priv; // OK + } + impl PrivTr for Pub { + type Alias = Priv; // OK + } + impl PubTr for Pub { + type Alias = Priv; // OK + } +} + +mod aliases_pub { + struct Priv; + mod m { + pub struct Pub1; + pub struct Pub2; + pub struct Pub3; + pub trait PubTr { + type Check = u8; + } + } + + use self::m::Pub1 as PrivUseAlias; + use self::m::PubTr as PrivUseAliasTr; + type PrivAlias = m::Pub2; + trait PrivTr { + type AssocAlias; + } + impl PrivTr for Priv { + type AssocAlias = m::Pub3; + } + + pub fn f1(arg: PrivUseAlias) {} // OK + pub fn f2(arg: PrivAlias) {} // OK + + pub trait Tr1: PrivUseAliasTr {} // OK + pub trait Tr2: PrivUseAliasTr {} // OK + + impl PrivAlias { + pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface + //~^ WARNING hard error + } + impl PrivUseAliasTr for PrivUseAlias { + type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface + } + impl PrivUseAliasTr for PrivAlias { + type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface + } + impl PrivUseAliasTr for ::AssocAlias { + type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface + } +} + +mod aliases_priv { + struct Priv; + + struct Priv1; + struct Priv2; + struct Priv3; + trait PrivTr1 { + type Check = u8; + } + + use self::Priv1 as PrivUseAlias; + use self::PrivTr1 as PrivUseAliasTr; + type PrivAlias = Priv2; + trait PrivTr { + type AssocAlias; + } + impl PrivTr for Priv { + type AssocAlias = Priv3; + } + + pub trait Tr1: PrivUseAliasTr {} + //~^ ERROR private trait `aliases_priv::PrivTr1` in public interface + //~| WARNING hard error + pub trait Tr2: PrivUseAliasTr {} + //~^ ERROR private trait `aliases_priv::PrivTr1` in public interface + //~| WARNING hard error + //~| ERROR private type `aliases_priv::Priv2` in public interface + //~| WARNING hard error + + impl PrivUseAlias { + pub fn f(arg: Priv) {} // OK + } + impl PrivAlias { + pub fn f(arg: Priv) {} // OK + } + impl PrivUseAliasTr for PrivUseAlias { + type Check = Priv; // OK + } + impl PrivUseAliasTr for PrivAlias { + type Check = Priv; // OK + } + impl PrivUseAliasTr for ::AssocAlias { + type Check = Priv; // OK + } +} + +mod aliases_params { + struct Priv; + type PrivAliasGeneric = T; + type Result = ::std::result::Result; + + pub fn f1(arg: PrivAliasGeneric) {} // OK, not an error +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/private-in-public-warn.stderr b/src/test/ui/compile-fail-migration/private-in-public-warn.stderr new file mode 100644 index 00000000000..04e743a5b0e --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public-warn.stderr @@ -0,0 +1,329 @@ +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:25:5 + | +LL | pub type Alias = Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/private-in-public-warn.rs:15:9 + | +LL | #![deny(private_in_public)] + | ^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:28:12 + | +LL | V1(Priv), //~ ERROR private type `types::Priv` in public interface + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:30:14 + | +LL | V2 { field: Priv }, //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:34:9 + | +LL | const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public-warn.rs:36:9 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | type Alias = Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^ can't leak private type + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:37:9 + | +LL | fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:39:9 + | +LL | fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:43:9 + | +LL | pub static ES: Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:45:9 + | +LL | pub fn ef1(arg: Priv); //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `types::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:47:9 + | +LL | pub fn ef2() -> Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public-warn.rs:51:9 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | type Alias = Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^ can't leak private type + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:60:5 + | +LL | pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:62:5 + | +LL | pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:64:5 + | +LL | pub trait Tr2 {} //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:66:5 + | +LL | / pub trait Tr3 { +LL | | //~^ ERROR private trait `traits::PrivTr` in public interface +LL | | //~| WARNING hard error +LL | | type Alias: PrivTr; +LL | | fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface +LL | | //~^ WARNING hard error +LL | | } + | |_____^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:70:9 + | +LL | fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:73:5 + | +LL | impl Pub {} //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:75:5 + | +LL | impl PubTr for Pub {} //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits_where::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:84:5 + | +LL | pub type Alias where T: PrivTr = T; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits_where::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:87:5 + | +LL | pub trait Tr2 where T: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits_where::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:91:9 + | +LL | fn f(arg: T) where T: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits_where::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:95:5 + | +LL | impl Pub where T: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `traits_where::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:98:5 + | +LL | impl PubTr for Pub where T: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `generics::PrivTr` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:109:5 + | +LL | pub trait Tr1: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `generics::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:112:5 + | +LL | pub trait Tr2: PubTr {} //~ ERROR private type `generics::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `generics::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:114:5 + | +LL | pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `generics::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:116:5 + | +LL | pub trait Tr4: PubTr> {} //~ ERROR private type `generics::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error[E0446]: private type `impls::Priv` in public interface + --> $DIR/private-in-public-warn.rs:143:9 + | +LL | struct Priv; + | - `impls::Priv` declared as private +... +LL | type Alias = Priv; //~ ERROR private type `impls::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^ can't leak private type + +error: private type `aliases_pub::Priv` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:214:9 + | +LL | pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error[E0446]: private type `aliases_pub::Priv` in public interface + --> $DIR/private-in-public-warn.rs:218:9 + | +LL | struct Priv; + | - `aliases_pub::Priv` declared as private +... +LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_pub::Priv` in public interface + --> $DIR/private-in-public-warn.rs:221:9 + | +LL | struct Priv; + | - `aliases_pub::Priv` declared as private +... +LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_pub::Priv` in public interface + --> $DIR/private-in-public-warn.rs:224:9 + | +LL | struct Priv; + | - `aliases_pub::Priv` declared as private +... +LL | type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^ can't leak private type + +error: private trait `aliases_priv::PrivTr1` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:248:5 + | +LL | pub trait Tr1: PrivUseAliasTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private type `aliases_priv::Priv2` in public interface (error E0446) + --> $DIR/private-in-public-warn.rs:251:5 + | +LL | pub trait Tr2: PrivUseAliasTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: private trait `aliases_priv::PrivTr1` in public interface (error E0445) + --> $DIR/private-in-public-warn.rs:251:5 + | +LL | pub trait Tr2: PrivUseAliasTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: aborting due to 35 previous errors + +For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/compile-fail-migration/private-in-public.rs b/src/test/ui/compile-fail-migration/private-in-public.rs new file mode 100644 index 00000000000..b865e391d29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public.rs @@ -0,0 +1,158 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Private types and traits are not allowed in public interfaces. +// This test also ensures that the checks are performed even inside private modules. + +#![feature(associated_type_defaults)] + +mod types { + struct Priv; + pub struct Pub; + pub trait PubTr { + type Alias; + } + + pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + pub static S: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface + pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface + pub struct S1(pub Priv); //~ ERROR private type `types::Priv` in public interface + pub struct S2 { pub field: Priv } //~ ERROR private type `types::Priv` in public interface + impl Pub { + pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface + pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface + } +} + +mod traits { + trait PrivTr {} + pub struct Pub(T); + pub trait PubTr {} + + pub enum E { V(T) } //~ ERROR private trait `traits::PrivTr` in public interface + pub fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface + pub struct S1(T); //~ ERROR private trait `traits::PrivTr` in public interface + impl Pub { //~ ERROR private trait `traits::PrivTr` in public interface + pub fn f(arg: U) {} //~ ERROR private trait `traits::PrivTr` in public interface + } +} + +mod traits_where { + trait PrivTr {} + pub struct Pub(T); + pub trait PubTr {} + + pub enum E where T: PrivTr { V(T) } + //~^ ERROR private trait `traits_where::PrivTr` in public interface + pub fn f(arg: T) where T: PrivTr {} + //~^ ERROR private trait `traits_where::PrivTr` in public interface + pub struct S1(T) where T: PrivTr; + //~^ ERROR private trait `traits_where::PrivTr` in public interface + impl Pub where T: PrivTr { + //~^ ERROR private trait `traits_where::PrivTr` in public interface + pub fn f(arg: U) where U: PrivTr {} + //~^ ERROR private trait `traits_where::PrivTr` in public interface + } +} + +mod generics { + struct Priv(T); + pub struct Pub(T); + trait PrivTr {} + pub trait PubTr {} + + pub fn f1(arg: [Priv; 1]) {} //~ ERROR private type `generics::Priv` in public interface + pub fn f2(arg: Pub) {} //~ ERROR private type `generics::Priv` in public interface + pub fn f3(arg: Priv) {} + //~^ ERROR private type `generics::Priv` in public interface +} + +mod impls { + struct Priv; + pub struct Pub; + trait PrivTr { + type Alias; + } + pub trait PubTr { + type Alias; + } + + impl Pub { + pub fn f(arg: Priv) {} //~ ERROR private type `impls::Priv` in public interface + } +} + +mod aliases_pub { + struct Priv; + mod m { + pub struct Pub1; + pub struct Pub2; + pub struct Pub3; + pub trait PubTr { + type Check = u8; + } + } + + use self::m::Pub1 as PrivUseAlias; + use self::m::PubTr as PrivUseAliasTr; + type PrivAlias = m::Pub2; + trait PrivTr { + type Assoc = m::Pub3; + } + impl PrivTr for Priv {} + + // This should be OK, but associated type aliases are not substituted yet + pub fn f3(arg: ::Assoc) {} + //~^ ERROR private type `::Assoc` in public interface + //~| ERROR private type `aliases_pub::Priv` in public interface + + impl PrivUseAlias { + pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface + } +} + +mod aliases_priv { + struct Priv; + + struct Priv1; + struct Priv2; + struct Priv3; + trait PrivTr1 { + type Check = u8; + } + + use self::Priv1 as PrivUseAlias; + use self::PrivTr1 as PrivUseAliasTr; + type PrivAlias = Priv2; + trait PrivTr { + type Assoc = Priv3; + } + impl PrivTr for Priv {} + + pub fn f1(arg: PrivUseAlias) {} //~ ERROR private type `aliases_priv::Priv1` in public interface + pub fn f2(arg: PrivAlias) {} //~ ERROR private type `aliases_priv::Priv2` in public interface + pub fn f3(arg: ::Assoc) {} + //~^ ERROR private type `::Assoc` in public + //~| ERROR private type `aliases_priv::Priv` in public interface +} + +mod aliases_params { + struct Priv; + type PrivAliasGeneric = T; + type Result = ::std::result::Result; + + pub fn f2(arg: PrivAliasGeneric) {} + //~^ ERROR private type `aliases_params::Priv` in public interface + pub fn f3(arg: Result) {} //~ ERROR private type `aliases_params::Priv` in public interface +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/private-in-public.stderr b/src/test/ui/compile-fail-migration/private-in-public.stderr new file mode 100644 index 00000000000..586327fbf26 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-in-public.stderr @@ -0,0 +1,268 @@ +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:23:5 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:24:5 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub static S: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:25:5 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:26:5 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:27:19 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub struct S1(pub Priv); //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:28:21 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub struct S2 { pub field: Priv } //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:30:9 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:31:9 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `types::Priv` in public interface + --> $DIR/private-in-public.rs:32:9 + | +LL | struct Priv; + | - `types::Priv` declared as private +... +LL | pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0445]: private trait `traits::PrivTr` in public interface + --> $DIR/private-in-public.rs:41:5 + | +LL | pub enum E { V(T) } //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `traits::PrivTr` in public interface + --> $DIR/private-in-public.rs:42:5 + | +LL | pub fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `traits::PrivTr` in public interface + --> $DIR/private-in-public.rs:43:5 + | +LL | pub struct S1(T); //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `traits::PrivTr` in public interface + --> $DIR/private-in-public.rs:44:5 + | +LL | / impl Pub { //~ ERROR private trait `traits::PrivTr` in public interface +LL | | pub fn f(arg: U) {} //~ ERROR private trait `traits::PrivTr` in public interface +LL | | } + | |_____^ can't leak private trait + +error[E0445]: private trait `traits::PrivTr` in public interface + --> $DIR/private-in-public.rs:45:9 + | +LL | pub fn f(arg: U) {} //~ ERROR private trait `traits::PrivTr` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `traits_where::PrivTr` in public interface + --> $DIR/private-in-public.rs:54:5 + | +LL | pub enum E where T: PrivTr { V(T) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `traits_where::PrivTr` in public interface + --> $DIR/private-in-public.rs:56:5 + | +LL | pub fn f(arg: T) where T: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `traits_where::PrivTr` in public interface + --> $DIR/private-in-public.rs:58:5 + | +LL | pub struct S1(T) where T: PrivTr; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `traits_where::PrivTr` in public interface + --> $DIR/private-in-public.rs:60:5 + | +LL | / impl Pub where T: PrivTr { +LL | | //~^ ERROR private trait `traits_where::PrivTr` in public interface +LL | | pub fn f(arg: U) where U: PrivTr {} +LL | | //~^ ERROR private trait `traits_where::PrivTr` in public interface +LL | | } + | |_____^ can't leak private trait + +error[E0445]: private trait `traits_where::PrivTr` in public interface + --> $DIR/private-in-public.rs:62:9 + | +LL | pub fn f(arg: U) where U: PrivTr {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0446]: private type `generics::Priv` in public interface + --> $DIR/private-in-public.rs:73:5 + | +LL | struct Priv(T); + | - `generics::Priv` declared as private +... +LL | pub fn f1(arg: [Priv; 1]) {} //~ ERROR private type `generics::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `generics::Priv` in public interface + --> $DIR/private-in-public.rs:74:5 + | +LL | struct Priv(T); + | - `generics::Priv` declared as private +... +LL | pub fn f2(arg: Pub) {} //~ ERROR private type `generics::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `generics::Priv` in public interface + --> $DIR/private-in-public.rs:75:5 + | +LL | struct Priv(T); + | - `generics::Priv` declared as private +... +LL | pub fn f3(arg: Priv) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `impls::Priv` in public interface + --> $DIR/private-in-public.rs:90:9 + | +LL | struct Priv; + | - `impls::Priv` declared as private +... +LL | pub fn f(arg: Priv) {} //~ ERROR private type `impls::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `::Assoc` in public interface + --> $DIR/private-in-public.rs:114:5 + | +LL | trait PrivTr { + | - `::Assoc` declared as private +... +LL | pub fn f3(arg: ::Assoc) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_pub::Priv` in public interface + --> $DIR/private-in-public.rs:114:5 + | +LL | struct Priv; + | - `aliases_pub::Priv` declared as private +... +LL | pub fn f3(arg: ::Assoc) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_pub::Priv` in public interface + --> $DIR/private-in-public.rs:119:9 + | +LL | struct Priv; + | - `aliases_pub::Priv` declared as private +... +LL | pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_priv::Priv1` in public interface + --> $DIR/private-in-public.rs:141:5 + | +LL | struct Priv1; + | - `aliases_priv::Priv1` declared as private +... +LL | pub fn f1(arg: PrivUseAlias) {} //~ ERROR private type `aliases_priv::Priv1` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_priv::Priv2` in public interface + --> $DIR/private-in-public.rs:142:5 + | +LL | struct Priv2; + | - `aliases_priv::Priv2` declared as private +... +LL | pub fn f2(arg: PrivAlias) {} //~ ERROR private type `aliases_priv::Priv2` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `::Assoc` in public interface + --> $DIR/private-in-public.rs:143:5 + | +LL | trait PrivTr { + | - `::Assoc` declared as private +... +LL | pub fn f3(arg: ::Assoc) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_priv::Priv` in public interface + --> $DIR/private-in-public.rs:143:5 + | +LL | struct Priv; + | - `aliases_priv::Priv` declared as private +... +LL | pub fn f3(arg: ::Assoc) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_params::Priv` in public interface + --> $DIR/private-in-public.rs:153:5 + | +LL | struct Priv; + | - `aliases_params::Priv` declared as private +... +LL | pub fn f2(arg: PrivAliasGeneric) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `aliases_params::Priv` in public interface + --> $DIR/private-in-public.rs:155:5 + | +LL | struct Priv; + | - `aliases_params::Priv` declared as private +... +LL | pub fn f3(arg: Result) {} //~ ERROR private type `aliases_params::Priv` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error: aborting due to 32 previous errors + +Some errors occurred: E0445, E0446. +For more information about an error, try `rustc --explain E0445`. diff --git a/src/test/ui/compile-fail-migration/private-inferred-type-1.rs b/src/test/ui/compile-fail-migration/private-inferred-type-1.rs new file mode 100644 index 00000000000..ba8b3d1810a --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type-1.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Arr0 { + fn arr0_secret(&self); +} +trait TyParam { + fn ty_param_secret(&self); +} + +mod m { + struct Priv; + + impl ::Arr0 for [Priv; 0] { fn arr0_secret(&self) {} } + impl ::TyParam for Option { fn ty_param_secret(&self) {} } +} + +fn main() { + [].arr0_secret(); //~ ERROR type `m::Priv` is private + None.ty_param_secret(); //~ ERROR type `m::Priv` is private +} diff --git a/src/test/ui/compile-fail-migration/private-inferred-type-1.stderr b/src/test/ui/compile-fail-migration/private-inferred-type-1.stderr new file mode 100644 index 00000000000..4036152c27f --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type-1.stderr @@ -0,0 +1,14 @@ +error: type `m::Priv` is private + --> $DIR/private-inferred-type-1.rs:26:5 + | +LL | [].arr0_secret(); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type-1.rs:27:5 + | +LL | None.ty_param_secret(); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/private-inferred-type-2.rs b/src/test/ui/compile-fail-migration/private-inferred-type-2.rs new file mode 100644 index 00000000000..e981f125750 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type-2.rs @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:private-inferred-type.rs + +extern crate private_inferred_type as ext; + +mod m { + struct Priv; + pub struct Pub(pub T); + + impl Pub { + pub fn get_priv() -> Priv { Priv } + pub fn static_method() {} + } +} + +fn main() { + m::Pub::get_priv; //~ ERROR type `m::Priv` is private + m::Pub::static_method; //~ ERROR type `m::Priv` is private + ext::Pub::static_method; //~ ERROR type `ext::Priv` is private +} diff --git a/src/test/ui/compile-fail-migration/private-inferred-type-2.stderr b/src/test/ui/compile-fail-migration/private-inferred-type-2.stderr new file mode 100644 index 00000000000..0559473e361 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type-2.stderr @@ -0,0 +1,20 @@ +error: type `m::Priv` is private + --> $DIR/private-inferred-type-2.rs:26:5 + | +LL | m::Pub::get_priv; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type-2.rs:27:5 + | +LL | m::Pub::static_method; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^ + +error: type `ext::Priv` is private + --> $DIR/private-inferred-type-2.rs:28:5 + | +LL | ext::Pub::static_method; //~ ERROR type `ext::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/private-inferred-type-3.rs b/src/test/ui/compile-fail-migration/private-inferred-type-3.rs new file mode 100644 index 00000000000..0c393f02323 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type-3.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:private-inferred-type.rs + +// error-pattern:type `fn() {ext::priv_fn}` is private +// error-pattern:static `PRIV_STATIC` is private +// error-pattern:type `ext::PrivEnum` is private +// error-pattern:type `fn() {::method}` is private +// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is pr +// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is priv +// error-pattern:type `for<'r> fn(&'r ext::Pub) {>::priv_method}` is private + +#![feature(decl_macro)] + +extern crate private_inferred_type as ext; + +fn main() { + ext::m!(); +} diff --git a/src/test/ui/compile-fail-migration/private-inferred-type-3.stderr b/src/test/ui/compile-fail-migration/private-inferred-type-3.stderr new file mode 100644 index 00000000000..3c37a7ee1e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type-3.stderr @@ -0,0 +1,58 @@ +error: type `fn() {ext::priv_fn}` is private + --> $DIR/private-inferred-type-3.rs:26:5 + | +LL | ext::m!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: static `PRIV_STATIC` is private + --> $DIR/private-inferred-type-3.rs:26:5 + | +LL | ext::m!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: type `ext::PrivEnum` is private + --> $DIR/private-inferred-type-3.rs:26:5 + | +LL | ext::m!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: type `fn() {::method}` is private + --> $DIR/private-inferred-type-3.rs:26:5 + | +LL | ext::m!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is private + --> $DIR/private-inferred-type-3.rs:26:5 + | +LL | ext::m!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is private + --> $DIR/private-inferred-type-3.rs:26:5 + | +LL | ext::m!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: type `for<'r> fn(&'r ext::Pub) {>::priv_method}` is private + --> $DIR/private-inferred-type-3.rs:26:5 + | +LL | ext::m!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/compile-fail-migration/private-inferred-type.rs b/src/test/ui/compile-fail-migration/private-inferred-type.rs new file mode 100644 index 00000000000..3ca8b1eb2ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type.rs @@ -0,0 +1,143 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_consts)] +#![feature(decl_macro)] +#![allow(private_in_public)] + +mod m { + fn priv_fn() {} + static PRIV_STATIC: u8 = 0; + enum PrivEnum { Variant } + pub enum PubEnum { Variant } + trait PrivTrait { fn method() {} } + impl PrivTrait for u8 {} + pub trait PubTrait { fn method() {} } + impl PubTrait for u8 {} + struct PrivTupleStruct(u8); + pub struct PubTupleStruct(u8); + impl PubTupleStruct { fn method() {} } + + struct Priv; + pub type Alias = Priv; + pub struct Pub(pub T); + + impl Pub { + pub fn static_method() {} + pub const INHERENT_ASSOC_CONST: u8 = 0; + } + impl Pub { + pub fn static_method_generic_self() {} + pub const INHERENT_ASSOC_CONST_GENERIC_SELF: u8 = 0; + } + impl Pub { + fn priv_method(&self) {} + pub fn method_with_substs(&self) {} + pub fn method_with_priv_params(&self, _: Priv) {} + } + impl TraitWithAssocConst for Priv {} + impl TraitWithAssocTy for Priv { type AssocTy = u8; } + + pub macro m() { + priv_fn; //~ ERROR type `fn() {m::priv_fn}` is private + PRIV_STATIC; // OK, not cross-crate + PrivEnum::Variant; //~ ERROR type `m::PrivEnum` is private + PubEnum::Variant; // OK + ::method; //~ ERROR type `fn() {::method}` is private + ::method; // OK + PrivTupleStruct; + //~^ ERROR type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct::{{constructor}}}` is priv + PubTupleStruct; + //~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is privat + Pub(0u8).priv_method(); + //~^ ERROR type `for<'r> fn(&'r m::Pub) {>::priv_method}` is private + } + + trait Trait {} + pub trait TraitWithTyParam {} + pub trait TraitWithTyParam2 { fn pub_method() {} } + pub trait TraitWithAssocTy { type AssocTy; } + pub trait TraitWithAssocConst { const TRAIT_ASSOC_CONST: u8 = 0; } + impl Trait for u8 {} + impl TraitWithTyParam for u8 {} + impl TraitWithTyParam2 for u8 {} + impl TraitWithAssocTy for u8 { type AssocTy = Priv; } + //~^ ERROR private type `m::Priv` in public interface + + pub fn leak_anon1() -> impl Trait + 'static { 0 } + pub fn leak_anon2() -> impl TraitWithTyParam { 0 } + pub fn leak_anon3() -> impl TraitWithAssocTy { 0 } + + pub fn leak_dyn1() -> Box { Box::new(0) } + pub fn leak_dyn2() -> Box> { Box::new(0) } + pub fn leak_dyn3() -> Box> { Box::new(0) } +} + +mod adjust { + // Construct a chain of derefs with a private type in the middle + use std::ops::Deref; + + pub struct S1; + struct S2; + pub type S2Alias = S2; + pub struct S3; + + impl Deref for S1 { + type Target = S2Alias; //~ ERROR private type `adjust::S2` in public interface + fn deref(&self) -> &Self::Target { loop {} } + } + impl Deref for S2 { + type Target = S3; + fn deref(&self) -> &Self::Target { loop {} } + } + + impl S3 { + pub fn method_s3(&self) {} + } +} + +fn main() { + let _: m::Alias; //~ ERROR type `m::Priv` is private + //~^ ERROR type `m::Priv` is private + let _: ::AssocTy; //~ ERROR type `m::Priv` is private + m::Alias {}; //~ ERROR type `m::Priv` is private + m::Pub { 0: m::Alias {} }; //~ ERROR type `m::Priv` is private + m::Pub { 0: loop {} }; // OK, `m::Pub` is in value context, so it means Pub<_>, not Pub + m::Pub::static_method; //~ ERROR type `m::Priv` is private + m::Pub::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private + m::Pub(0u8).method_with_substs::(); //~ ERROR type `m::Priv` is private + m::Pub(0u8).method_with_priv_params(loop{}); //~ ERROR type `m::Priv` is private + ::TRAIT_ASSOC_CONST; //~ ERROR type `m::Priv` is private + >::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private + >::INHERENT_ASSOC_CONST_GENERIC_SELF; //~ ERROR type `m::Priv` is private + >::static_method_generic_self; //~ ERROR type `m::Priv` is private + use m::TraitWithTyParam2; + u8::pub_method; //~ ERROR type `m::Priv` is private + + adjust::S1.method_s3(); //~ ERROR type `adjust::S2` is private + + m::m!(); + + m::leak_anon1(); //~ ERROR trait `m::Trait` is private + m::leak_anon2(); //~ ERROR type `m::Priv` is private + m::leak_anon3(); //~ ERROR type `m::Priv` is private + + m::leak_dyn1(); //~ ERROR type `(dyn m::Trait + 'static)` is private + m::leak_dyn2(); //~ ERROR type `m::Priv` is private + m::leak_dyn3(); //~ ERROR type `m::Priv` is private + + // Check that messages are not duplicated for various kinds of assignments + let a = m::Alias {}; //~ ERROR type `m::Priv` is private + let mut b = a; //~ ERROR type `m::Priv` is private + b = a; //~ ERROR type `m::Priv` is private + match a { //~ ERROR type `m::Priv` is private + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/private-inferred-type.stderr b/src/test/ui/compile-fail-migration/private-inferred-type.stderr new file mode 100644 index 00000000000..abbe43fe384 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-inferred-type.stderr @@ -0,0 +1,225 @@ +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:107:9 + | +LL | let _: m::Alias; //~ ERROR type `m::Priv` is private + | ^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:107:12 + | +LL | let _: m::Alias; //~ ERROR type `m::Priv` is private + | ^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:109:13 + | +LL | let _: ::AssocTy; //~ ERROR type `m::Priv` is private + | ^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:110:5 + | +LL | m::Alias {}; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:111:5 + | +LL | m::Pub { 0: m::Alias {} }; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:113:5 + | +LL | m::Pub::static_method; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:114:5 + | +LL | m::Pub::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:115:5 + | +LL | m::Pub(0u8).method_with_substs::(); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:116:17 + | +LL | m::Pub(0u8).method_with_priv_params(loop{}); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:117:5 + | +LL | ::TRAIT_ASSOC_CONST; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:118:6 + | +LL | >::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:119:5 + | +LL | >::INHERENT_ASSOC_CONST_GENERIC_SELF; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:120:5 + | +LL | >::static_method_generic_self; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:122:5 + | +LL | u8::pub_method; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^ + +error: type `adjust::S2` is private + --> $DIR/private-inferred-type.rs:124:5 + | +LL | adjust::S1.method_s3(); //~ ERROR type `adjust::S2` is private + | ^^^^^^^^^^ + +error: type `fn() {m::priv_fn}` is private + --> $DIR/private-inferred-type.rs:49:9 + | +LL | priv_fn; //~ ERROR type `fn() {m::priv_fn}` is private + | ^^^^^^^ +... +LL | m::m!(); + | -------- in this macro invocation + +error: type `m::PrivEnum` is private + --> $DIR/private-inferred-type.rs:51:9 + | +LL | PrivEnum::Variant; //~ ERROR type `m::PrivEnum` is private + | ^^^^^^^^^^^^^^^^^ +... +LL | m::m!(); + | -------- in this macro invocation + +error: type `fn() {::method}` is private + --> $DIR/private-inferred-type.rs:53:9 + | +LL | ::method; //~ ERROR type `fn() {::method}` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | m::m!(); + | -------- in this macro invocation + +error: type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct::{{constructor}}}` is private + --> $DIR/private-inferred-type.rs:55:9 + | +LL | PrivTupleStruct; + | ^^^^^^^^^^^^^^^ +... +LL | m::m!(); + | -------- in this macro invocation + +error: type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is private + --> $DIR/private-inferred-type.rs:57:9 + | +LL | PubTupleStruct; + | ^^^^^^^^^^^^^^ +... +LL | m::m!(); + | -------- in this macro invocation + +error: type `for<'r> fn(&'r m::Pub) {>::priv_method}` is private + --> $DIR/private-inferred-type.rs:59:18 + | +LL | Pub(0u8).priv_method(); + | ^^^^^^^^^^^ +... +LL | m::m!(); + | -------- in this macro invocation + +error: trait `m::Trait` is private + --> $DIR/private-inferred-type.rs:128:5 + | +LL | m::leak_anon1(); //~ ERROR trait `m::Trait` is private + | ^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:129:5 + | +LL | m::leak_anon2(); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:130:5 + | +LL | m::leak_anon3(); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^ + +error: type `(dyn m::Trait + 'static)` is private + --> $DIR/private-inferred-type.rs:132:5 + | +LL | m::leak_dyn1(); //~ ERROR type `(dyn m::Trait + 'static)` is private + | ^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:133:5 + | +LL | m::leak_dyn2(); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:134:5 + | +LL | m::leak_dyn3(); //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:137:13 + | +LL | let a = m::Alias {}; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:138:17 + | +LL | let mut b = a; //~ ERROR type `m::Priv` is private + | ^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:139:9 + | +LL | b = a; //~ ERROR type `m::Priv` is private + | ^ + +error: type `m::Priv` is private + --> $DIR/private-inferred-type.rs:140:11 + | +LL | match a { //~ ERROR type `m::Priv` is private + | ^ + +error[E0446]: private type `m::Priv` in public interface + --> $DIR/private-inferred-type.rs:71:36 + | +LL | struct Priv; + | - `m::Priv` declared as private +... +LL | impl TraitWithAssocTy for u8 { type AssocTy = Priv; } + | ^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error[E0446]: private type `adjust::S2` in public interface + --> $DIR/private-inferred-type.rs:93:9 + | +LL | struct S2; + | - `adjust::S2` declared as private +... +LL | type Target = S2Alias; //~ ERROR private type `adjust::S2` in public interface + | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private type + +error: aborting due to 33 previous errors + +For more information about this error, try `rustc --explain E0446`. diff --git a/src/test/ui/compile-fail-migration/private-item-simple.rs b/src/test/ui/compile-fail-migration/private-item-simple.rs new file mode 100644 index 00000000000..2b9e32b8f58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-item-simple.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + fn f() {} +} + +fn main() { + a::f(); //~ ERROR function `f` is private +} diff --git a/src/test/ui/compile-fail-migration/private-item-simple.stderr b/src/test/ui/compile-fail-migration/private-item-simple.stderr new file mode 100644 index 00000000000..811b026eab9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-item-simple.stderr @@ -0,0 +1,9 @@ +error[E0603]: function `f` is private + --> $DIR/private-item-simple.rs:16:5 + | +LL | a::f(); //~ ERROR function `f` is private + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/private-method-cross-crate.rs b/src/test/ui/compile-fail-migration/private-method-cross-crate.rs new file mode 100644 index 00000000000..68059baa385 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-method-cross-crate.rs @@ -0,0 +1,18 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:cci_class_5.rs +extern crate cci_class_5; +use cci_class_5::kitties::cat; + +fn main() { + let nyan : cat = cat(52, 99); + nyan.nap(); //~ ERROR method `nap` is private +} diff --git a/src/test/ui/compile-fail-migration/private-method-cross-crate.stderr b/src/test/ui/compile-fail-migration/private-method-cross-crate.stderr new file mode 100644 index 00000000000..27d398c0166 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-method-cross-crate.stderr @@ -0,0 +1,9 @@ +error[E0624]: method `nap` is private + --> $DIR/private-method-cross-crate.rs:17:8 + | +LL | nyan.nap(); //~ ERROR method `nap` is private + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/private-method-inherited.rs b/src/test/ui/compile-fail-migration/private-method-inherited.rs new file mode 100644 index 00000000000..c6419991b11 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-method-inherited.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that inherited visibility applies to methods. + +mod a { + pub struct Foo; + + impl Foo { + fn f(self) {} + } +} + +fn main() { + let x = a::Foo; + x.f(); //~ ERROR method `f` is private +} diff --git a/src/test/ui/compile-fail-migration/private-method-inherited.stderr b/src/test/ui/compile-fail-migration/private-method-inherited.stderr new file mode 100644 index 00000000000..3f10750e46f --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-method-inherited.stderr @@ -0,0 +1,9 @@ +error[E0624]: method `f` is private + --> $DIR/private-method-inherited.rs:23:7 + | +LL | x.f(); //~ ERROR method `f` is private + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/private-method.rs b/src/test/ui/compile-fail-migration/private-method.rs new file mode 100644 index 00000000000..16510c2c8c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-method.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:method `nap` is private + +mod kitties { + pub struct cat { + meows : usize, + + how_hungry : isize, + } + + impl cat { + fn nap(&self) {} + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} + +fn main() { + let nyan : kitties::cat = kitties::cat(52, 99); + nyan.nap(); +} diff --git a/src/test/ui/compile-fail-migration/private-method.stderr b/src/test/ui/compile-fail-migration/private-method.stderr new file mode 100644 index 00000000000..fce03d35e39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-method.stderr @@ -0,0 +1,9 @@ +error[E0624]: method `nap` is private + --> $DIR/private-method.rs:34:8 + | +LL | nyan.nap(); + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/private-struct-field-cross-crate.rs b/src/test/ui/compile-fail-migration/private-struct-field-cross-crate.rs new file mode 100644 index 00000000000..067c17668c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field-cross-crate.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:cci_class.rs +extern crate cci_class; +use cci_class::kitties::cat; + +fn main() { + let nyan : cat = cat(52, 99); + assert_eq!(nyan.meows, 52); + //~^ ERROR field `meows` of struct `cci_class::kitties::cat` is private +} diff --git a/src/test/ui/compile-fail-migration/private-struct-field-cross-crate.stderr b/src/test/ui/compile-fail-migration/private-struct-field-cross-crate.stderr new file mode 100644 index 00000000000..b9401baf0d0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field-cross-crate.stderr @@ -0,0 +1,9 @@ +error[E0616]: field `meows` of struct `cci_class::kitties::cat` is private + --> $DIR/private-struct-field-cross-crate.rs:17:14 + | +LL | assert_eq!(nyan.meows, 52); + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0616`. diff --git a/src/test/ui/compile-fail-migration/private-struct-field-ctor.rs b/src/test/ui/compile-fail-migration/private-struct-field-ctor.rs new file mode 100644 index 00000000000..0a0f2d490a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field-ctor.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + pub struct Foo { + x: isize + } +} + +fn main() { + let s = a::Foo { x: 1 }; //~ ERROR field `x` of struct `a::Foo` is private +} diff --git a/src/test/ui/compile-fail-migration/private-struct-field-ctor.stderr b/src/test/ui/compile-fail-migration/private-struct-field-ctor.stderr new file mode 100644 index 00000000000..711d265c559 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field-ctor.stderr @@ -0,0 +1,9 @@ +error[E0451]: field `x` of struct `a::Foo` is private + --> $DIR/private-struct-field-ctor.rs:18:22 + | +LL | let s = a::Foo { x: 1 }; //~ ERROR field `x` of struct `a::Foo` is private + | ^^^^ field `x` is private + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/compile-fail-migration/private-struct-field-pattern.rs b/src/test/ui/compile-fail-migration/private-struct-field-pattern.rs new file mode 100644 index 00000000000..e9dd6cd1d74 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field-pattern.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use a::Foo; + +mod a { + pub struct Foo { + x: isize + } + + pub fn make() -> Foo { + Foo { x: 3 } + } +} + +fn main() { + match a::make() { + Foo { x: _ } => {} //~ ERROR field `x` of struct `a::Foo` is private + } +} diff --git a/src/test/ui/compile-fail-migration/private-struct-field-pattern.stderr b/src/test/ui/compile-fail-migration/private-struct-field-pattern.stderr new file mode 100644 index 00000000000..bc09a2a6daf --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field-pattern.stderr @@ -0,0 +1,9 @@ +error[E0451]: field `x` of struct `a::Foo` is private + --> $DIR/private-struct-field-pattern.rs:25:15 + | +LL | Foo { x: _ } => {} //~ ERROR field `x` of struct `a::Foo` is private + | ^^^^ field `x` is private + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0451`. diff --git a/src/test/ui/compile-fail-migration/private-struct-field.rs b/src/test/ui/compile-fail-migration/private-struct-field.rs new file mode 100644 index 00000000000..1423117dc81 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod cat { + pub struct Cat { + meows: usize + } + + pub fn new_cat() -> Cat { + Cat { meows: 52 } + } +} + +fn main() { + let nyan = cat::new_cat(); + assert_eq!(nyan.meows, 52); //~ ERROR field `meows` of struct `cat::Cat` is private +} diff --git a/src/test/ui/compile-fail-migration/private-struct-field.stderr b/src/test/ui/compile-fail-migration/private-struct-field.stderr new file mode 100644 index 00000000000..db16e1ba1fc --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-struct-field.stderr @@ -0,0 +1,9 @@ +error[E0616]: field `meows` of struct `cat::Cat` is private + --> $DIR/private-struct-field.rs:23:16 + | +LL | assert_eq!(nyan.meows, 52); //~ ERROR field `meows` of struct `cat::Cat` is private + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0616`. diff --git a/src/test/ui/compile-fail-migration/private-type-in-interface.rs b/src/test/ui/compile-fail-migration/private-type-in-interface.rs new file mode 100644 index 00000000000..4235b4be271 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-type-in-interface.rs @@ -0,0 +1,42 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:private-inferred-type.rs + +#![allow(warnings)] + +extern crate private_inferred_type as ext; + +mod m { + struct Priv; + pub type Alias = Priv; + + pub trait Trait { type X; } + impl Trait for Priv { type X = u8; } +} + +fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private + //~^ ERROR type `m::Priv` is private +fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private + //~^ ERROR type `ext::Priv` is private + +trait Tr1 {} +impl m::Alias {} //~ ERROR type `m::Priv` is private +impl Tr1 for ext::Alias {} //~ ERROR type `ext::Priv` is private +type A = ::X; //~ ERROR type `m::Priv` is private + +trait Tr2 {} +impl Tr2 for u8 {} +fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private +//~^ ERROR type `m::Priv` is private +fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private +//~^ ERROR type `ext::Priv` is private + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/private-type-in-interface.stderr b/src/test/ui/compile-fail-migration/private-type-in-interface.stderr new file mode 100644 index 00000000000..5b12ed5e5f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-type-in-interface.stderr @@ -0,0 +1,68 @@ +error: type `m::Priv` is private + --> $DIR/private-type-in-interface.rs:25:9 + | +LL | fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private + | ^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-type-in-interface.rs:25:6 + | +LL | fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private + | ^ + +error: type `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:27:13 + | +LL | fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private + | ^^^^^^^^^^ + +error: type `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:27:10 + | +LL | fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private + | ^ + +error: type `m::Priv` is private + --> $DIR/private-type-in-interface.rs:31:6 + | +LL | impl m::Alias {} //~ ERROR type `m::Priv` is private + | ^^^^^^^^ + +error: type `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:32:14 + | +LL | impl Tr1 for ext::Alias {} //~ ERROR type `ext::Priv` is private + | ^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-type-in-interface.rs:33:10 + | +LL | type A = ::X; //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-type-in-interface.rs:37:11 + | +LL | fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^^^^^^ + +error: type `m::Priv` is private + --> $DIR/private-type-in-interface.rs:37:16 + | +LL | fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private + | ^^^^^^^^^^^^^ + +error: type `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:39:15 + | +LL | fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private + | ^^^^^^^^^^^^^^^^^^^^ + +error: type `ext::Priv` is private + --> $DIR/private-type-in-interface.rs:39:20 + | +LL | fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private + | ^^^^^^^^^^^^^^^ + +error: aborting due to 11 previous errors + diff --git a/src/test/ui/compile-fail-migration/private-variant-reexport.rs b/src/test/ui/compile-fail-migration/private-variant-reexport.rs new file mode 100644 index 00000000000..5d770f88155 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-variant-reexport.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m1 { + pub use ::E::V; //~ ERROR variant `V` is private and cannot be re-exported +} + +mod m2 { + pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be re-exported +} + +mod m3 { + pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be re-exported +} + +mod m4 { + pub use ::E::*; //~ ERROR enum is private and its variants cannot be re-exported +} + +enum E { V } + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/private-variant-reexport.stderr b/src/test/ui/compile-fail-migration/private-variant-reexport.stderr new file mode 100644 index 00000000000..11e13ab9ba8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/private-variant-reexport.stderr @@ -0,0 +1,29 @@ +error: variant `V` is private and cannot be re-exported + --> $DIR/private-variant-reexport.rs:12:13 + | +LL | pub use ::E::V; //~ ERROR variant `V` is private and cannot be re-exported + | ^^^^^^ +... +LL | enum E { V } + | ------ help: consider making the enum public: `pub enum E` + +error: variant `V` is private and cannot be re-exported + --> $DIR/private-variant-reexport.rs:16:19 + | +LL | pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be re-exported + | ^ + +error: variant `V` is private and cannot be re-exported + --> $DIR/private-variant-reexport.rs:20:22 + | +LL | pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be re-exported + | ^^^^ + +error: enum is private and its variants cannot be re-exported + --> $DIR/private-variant-reexport.rs:24:13 + | +LL | pub use ::E::*; //~ ERROR enum is private and its variants cannot be re-exported + | ^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/ptr-coercion.rs b/src/test/ui/compile-fail-migration/ptr-coercion.rs new file mode 100644 index 00000000000..1390c9507c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ptr-coercion.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test coercions between pointers which don't do anything fancy like unsizing. +// These are testing that we don't lose mutability when converting to raw pointers. + +pub fn main() { + // *const -> *mut + let x: *const isize = &42; + let x: *mut isize = x; //~ ERROR mismatched types + //~| expected type `*mut isize` + //~| found type `*const isize` + //~| types differ in mutability + + // & -> *mut + let x: *mut isize = &42; //~ ERROR mismatched types + //~| expected type `*mut isize` + //~| found type `&isize` + //~| types differ in mutability + + let x: *const isize = &42; + let x: *mut isize = x; //~ ERROR mismatched types + //~| expected type `*mut isize` + //~| found type `*const isize` + //~| types differ in mutability +} diff --git a/src/test/ui/compile-fail-migration/ptr-coercion.stderr b/src/test/ui/compile-fail-migration/ptr-coercion.stderr new file mode 100644 index 00000000000..c5ed80db1a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ptr-coercion.stderr @@ -0,0 +1,30 @@ +error[E0308]: mismatched types + --> $DIR/ptr-coercion.rs:17:25 + | +LL | let x: *mut isize = x; //~ ERROR mismatched types + | ^ types differ in mutability + | + = note: expected type `*mut isize` + found type `*const isize` + +error[E0308]: mismatched types + --> $DIR/ptr-coercion.rs:23:25 + | +LL | let x: *mut isize = &42; //~ ERROR mismatched types + | ^^^ types differ in mutability + | + = note: expected type `*mut isize` + found type `&isize` + +error[E0308]: mismatched types + --> $DIR/ptr-coercion.rs:29:25 + | +LL | let x: *mut isize = x; //~ ERROR mismatched types + | ^ types differ in mutability + | + = note: expected type `*mut isize` + found type `*const isize` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.rs b/src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.rs new file mode 100644 index 00000000000..2e71e007e9e --- /dev/null +++ b/src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.rs @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +extern crate core; +pub use core as reexported_core; //~ ERROR `core` is private, and cannot be re-exported + //~^ WARN this was previously accepted + +mod foo1 { + extern crate core; +} + +mod foo2 { + use foo1::core; //~ ERROR `core` is private, and cannot be re-exported + //~^ WARN this was previously accepted + pub mod bar { + extern crate core; + } +} + +mod baz { + pub use foo2::bar::core; //~ ERROR `core` is private, and cannot be re-exported + //~^ WARN this was previously accepted +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.stderr b/src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.stderr new file mode 100644 index 00000000000..d298542bd5d --- /dev/null +++ b/src/test/ui/compile-fail-migration/pub-reexport-priv-extern-crate.stderr @@ -0,0 +1,30 @@ +error: extern crate `core` is private, and cannot be re-exported (error E0365), consider declaring with `pub` + --> $DIR/pub-reexport-priv-extern-crate.rs:14:9 + | +LL | pub use core as reexported_core; //~ ERROR `core` is private, and cannot be re-exported + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[deny(pub_use_of_private_extern_crate)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: extern crate `core` is private, and cannot be re-exported (error E0365), consider declaring with `pub` + --> $DIR/pub-reexport-priv-extern-crate.rs:22:9 + | +LL | use foo1::core; //~ ERROR `core` is private, and cannot be re-exported + | ^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: extern crate `core` is private, and cannot be re-exported (error E0365), consider declaring with `pub` + --> $DIR/pub-reexport-priv-extern-crate.rs:30:13 + | +LL | pub use foo2::bar::core; //~ ERROR `core` is private, and cannot be re-exported + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #34537 + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/qualified-path-params.rs b/src/test/ui/compile-fail-migration/qualified-path-params.rs new file mode 100644 index 00000000000..018a3b2ae32 --- /dev/null +++ b/src/test/ui/compile-fail-migration/qualified-path-params.rs @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that qualified paths with type parameters +// fail during type checking and not during parsing + +struct S; + +trait Tr { + type A; +} + +impl Tr for S { + type A = S; +} + +impl S { + fn f() {} +} + +fn main() { + match 10 { + ::A::f:: => {} + //~^ ERROR expected unit struct/variant or constant, found method `<::A>::f` + 0 ..= ::A::f:: => {} //~ ERROR only char and numeric types are allowed in range + } +} diff --git a/src/test/ui/compile-fail-migration/qualified-path-params.stderr b/src/test/ui/compile-fail-migration/qualified-path-params.stderr new file mode 100644 index 00000000000..e76c373eec5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/qualified-path-params.stderr @@ -0,0 +1,19 @@ +error[E0533]: expected unit struct/variant or constant, found method `<::A>::f` + --> $DIR/qualified-path-params.rs:30:9 + | +LL | ::A::f:: => {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0029]: only char and numeric types are allowed in range patterns + --> $DIR/qualified-path-params.rs:32:15 + | +LL | 0 ..= ::A::f:: => {} //~ ERROR only char and numeric types are allowed in range + | ^^^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types + | + = note: start type: {integer} + = note: end type: fn() {S::f::} + +error: aborting due to 2 previous errors + +Some errors occurred: E0029, E0533. +For more information about an error, try `rustc --explain E0029`. diff --git a/src/test/ui/compile-fail-migration/question-mark-type-infer.rs b/src/test/ui/compile-fail-migration/question-mark-type-infer.rs new file mode 100644 index 00000000000..e15c9af41e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/question-mark-type-infer.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(question_mark, question_mark_carrier)] + +// Test that type inference fails where there are multiple possible return types +// for the `?` operator. + +fn f(x: &i32) -> Result { + Ok(*x) +} + +fn g() -> Result, ()> { + let l = [1, 2, 3, 4]; + l.iter().map(f).collect()? //~ ERROR type annotations required: cannot resolve +} + +fn main() { + g(); +} diff --git a/src/test/ui/compile-fail-migration/question-mark-type-infer.stderr b/src/test/ui/compile-fail-migration/question-mark-type-infer.stderr new file mode 100644 index 00000000000..53848ed0727 --- /dev/null +++ b/src/test/ui/compile-fail-migration/question-mark-type-infer.stderr @@ -0,0 +1,9 @@ +error[E0284]: type annotations required: cannot resolve `<_ as std::ops::Try>::Ok == _` + --> $DIR/question-mark-type-infer.rs:22:5 + | +LL | l.iter().map(f).collect()? //~ ERROR type annotations required: cannot resolve + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/src/test/ui/compile-fail-migration/quote-with-interpolated.rs b/src/test/ui/compile-fail-migration/quote-with-interpolated.rs new file mode 100644 index 00000000000..1fafb1c7a1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/quote-with-interpolated.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(quote)] +fn main() { + macro_rules! foo { + ($bar:expr) => { + quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token + } + } + foo!(bar); +} diff --git a/src/test/ui/compile-fail-migration/quote-with-interpolated.stderr b/src/test/ui/compile-fail-migration/quote-with-interpolated.stderr new file mode 100644 index 00000000000..10b3fc0a9ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/quote-with-interpolated.stderr @@ -0,0 +1,11 @@ +error: quote! with interpolated token + --> $DIR/quote-with-interpolated.rs:15:29 + | +LL | quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token + | ^^^^ +... +LL | foo!(bar); + | ---------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/range-1.rs b/src/test/ui/compile-fail-migration/range-1.rs new file mode 100644 index 00000000000..59c78052e15 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range-1.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test range syntax - type errors. + +pub fn main() { + // Mixed types. + let _ = 0u32..10i32; + //~^ ERROR mismatched types + + // Bool => does not implement iterator. + for i in false..true {} + //~^ ERROR `bool: std::iter::Step` is not satisfied + + // Unsized type. + let arr: &[_] = &[1, 2, 3]; + let range = *arr..; + //~^ ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/range-1.stderr b/src/test/ui/compile-fail-migration/range-1.stderr new file mode 100644 index 00000000000..7225c931fae --- /dev/null +++ b/src/test/ui/compile-fail-migration/range-1.stderr @@ -0,0 +1,28 @@ +error[E0308]: mismatched types + --> $DIR/range-1.rs:15:19 + | +LL | let _ = 0u32..10i32; + | ^^^^^ expected u32, found i32 + +error[E0277]: the trait bound `bool: std::iter::Step` is not satisfied + --> $DIR/range-1.rs:19:14 + | +LL | for i in false..true {} + | ^^^^^^^^^^^ the trait `std::iter::Step` is not implemented for `bool` + | + = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::ops::Range` + +error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time + --> $DIR/range-1.rs:24:17 + | +LL | let range = *arr..; + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `[{integer}]` + = note: to learn more, visit + = note: required by `std::ops::RangeFrom` + +error: aborting due to 3 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/range_traits-1.rs b/src/test/ui/compile-fail-migration/range_traits-1.rs new file mode 100644 index 00000000000..78d3702b449 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-1.rs @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::*; + +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +struct AllTheRanges { + a: Range, + //~^ ERROR can't compare + //~| ERROR Ord + b: RangeTo, + //~^ ERROR can't compare + //~| ERROR Ord + c: RangeFrom, + //~^ ERROR can't compare + //~| ERROR Ord + d: RangeFull, + //~^ ERROR can't compare + //~| ERROR Ord + e: RangeInclusive, + //~^ ERROR can't compare + //~| ERROR Ord + f: RangeToInclusive, + //~^ ERROR can't compare + //~| ERROR Ord +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/range_traits-1.stderr b/src/test/ui/compile-fail-migration/range_traits-1.stderr new file mode 100644 index 00000000000..ee72dfe13d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-1.stderr @@ -0,0 +1,105 @@ +error[E0277]: can't compare `std::ops::Range` with `std::ops::Range` + --> $DIR/range_traits-1.rs:15:5 + | +LL | a: Range, + | ^^^^^^^^^^^^^^^ no implementation for `std::ops::Range < std::ops::Range` and `std::ops::Range > std::ops::Range` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `std::ops::Range` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error[E0277]: can't compare `std::ops::RangeTo` with `std::ops::RangeTo` + --> $DIR/range_traits-1.rs:18:5 + | +LL | b: RangeTo, + | ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo < std::ops::RangeTo` and `std::ops::RangeTo > std::ops::RangeTo` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `std::ops::RangeTo` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error[E0277]: can't compare `std::ops::RangeFrom` with `std::ops::RangeFrom` + --> $DIR/range_traits-1.rs:21:5 + | +LL | c: RangeFrom, + | ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom < std::ops::RangeFrom` and `std::ops::RangeFrom > std::ops::RangeFrom` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `std::ops::RangeFrom` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull` + --> $DIR/range_traits-1.rs:24:5 + | +LL | d: RangeFull, + | ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `std::ops::RangeFull` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error[E0277]: can't compare `std::ops::RangeInclusive` with `std::ops::RangeInclusive` + --> $DIR/range_traits-1.rs:27:5 + | +LL | e: RangeInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive < std::ops::RangeInclusive` and `std::ops::RangeInclusive > std::ops::RangeInclusive` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `std::ops::RangeInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error[E0277]: can't compare `std::ops::RangeToInclusive` with `std::ops::RangeToInclusive` + --> $DIR/range_traits-1.rs:30:5 + | +LL | f: RangeToInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive < std::ops::RangeToInclusive` and `std::ops::RangeToInclusive > std::ops::RangeToInclusive` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `std::ops::RangeToInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error[E0277]: the trait bound `std::ops::Range: std::cmp::Ord` is not satisfied + --> $DIR/range_traits-1.rs:15:5 + | +LL | a: Range, + | ^^^^^^^^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `std::ops::Range` + | + = note: required by `std::cmp::Ord::cmp` + +error[E0277]: the trait bound `std::ops::RangeTo: std::cmp::Ord` is not satisfied + --> $DIR/range_traits-1.rs:18:5 + | +LL | b: RangeTo, + | ^^^^^^^^^^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `std::ops::RangeTo` + | + = note: required by `std::cmp::Ord::cmp` + +error[E0277]: the trait bound `std::ops::RangeFrom: std::cmp::Ord` is not satisfied + --> $DIR/range_traits-1.rs:21:5 + | +LL | c: RangeFrom, + | ^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `std::ops::RangeFrom` + | + = note: required by `std::cmp::Ord::cmp` + +error[E0277]: the trait bound `std::ops::RangeFull: std::cmp::Ord` is not satisfied + --> $DIR/range_traits-1.rs:24:5 + | +LL | d: RangeFull, + | ^^^^^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `std::ops::RangeFull` + | + = note: required by `std::cmp::Ord::cmp` + +error[E0277]: the trait bound `std::ops::RangeInclusive: std::cmp::Ord` is not satisfied + --> $DIR/range_traits-1.rs:27:5 + | +LL | e: RangeInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `std::ops::RangeInclusive` + | + = note: required by `std::cmp::Ord::cmp` + +error[E0277]: the trait bound `std::ops::RangeToInclusive: std::cmp::Ord` is not satisfied + --> $DIR/range_traits-1.rs:30:5 + | +LL | f: RangeToInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Ord` is not implemented for `std::ops::RangeToInclusive` + | + = note: required by `std::cmp::Ord::cmp` + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/range_traits-2.rs b/src/test/ui/compile-fail-migration/range_traits-2.rs new file mode 100644 index 00000000000..64fcd25f538 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-2.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::*; + +#[derive(Copy, Clone)] //~ ERROR Copy +struct R(Range); + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/range_traits-2.stderr b/src/test/ui/compile-fail-migration/range_traits-2.stderr new file mode 100644 index 00000000000..0151ede2164 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-2.stderr @@ -0,0 +1,11 @@ +error[E0204]: the trait `Copy` may not be implemented for this type + --> $DIR/range_traits-2.rs:13:10 + | +LL | #[derive(Copy, Clone)] //~ ERROR Copy + | ^^^^ +LL | struct R(Range); + | ------------ this field does not implement `Copy` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0204`. diff --git a/src/test/ui/compile-fail-migration/range_traits-3.rs b/src/test/ui/compile-fail-migration/range_traits-3.rs new file mode 100644 index 00000000000..d26b7956ae8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-3.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::*; + +#[derive(Copy, Clone)] //~ ERROR Copy +struct R(RangeFrom); + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/range_traits-3.stderr b/src/test/ui/compile-fail-migration/range_traits-3.stderr new file mode 100644 index 00000000000..a625fda2bc2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-3.stderr @@ -0,0 +1,11 @@ +error[E0204]: the trait `Copy` may not be implemented for this type + --> $DIR/range_traits-3.rs:13:10 + | +LL | #[derive(Copy, Clone)] //~ ERROR Copy + | ^^^^ +LL | struct R(RangeFrom); + | ---------------- this field does not implement `Copy` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0204`. diff --git a/src/test/ui/compile-fail-migration/range_traits-4.rs b/src/test/ui/compile-fail-migration/range_traits-4.rs new file mode 100644 index 00000000000..630969bdbdf --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-4.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +use std::ops::*; + +#[derive(Copy, Clone)] +struct R(RangeTo); + +#[rustc_error] +fn main() {} //~ ERROR success + diff --git a/src/test/ui/compile-fail-migration/range_traits-4.stderr b/src/test/ui/compile-fail-migration/range_traits-4.stderr new file mode 100644 index 00000000000..cf8ae671ffc --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-4.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/range_traits-4.rs:19:1 + | +LL | fn main() {} //~ ERROR success + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/range_traits-5.rs b/src/test/ui/compile-fail-migration/range_traits-5.rs new file mode 100644 index 00000000000..5963c4a9496 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-5.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +use std::ops::*; + +#[derive(Copy, Clone)] +struct R(RangeFull); + +#[rustc_error] +fn main() {} //~ ERROR success + diff --git a/src/test/ui/compile-fail-migration/range_traits-5.stderr b/src/test/ui/compile-fail-migration/range_traits-5.stderr new file mode 100644 index 00000000000..eadb3a08ba0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-5.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/range_traits-5.rs:19:1 + | +LL | fn main() {} //~ ERROR success + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/range_traits-6.rs b/src/test/ui/compile-fail-migration/range_traits-6.rs new file mode 100644 index 00000000000..f9510b5061c --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-6.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::*; + +#[derive(Copy, Clone)] //~ ERROR Copy +struct R(RangeInclusive); + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/range_traits-6.stderr b/src/test/ui/compile-fail-migration/range_traits-6.stderr new file mode 100644 index 00000000000..9470540cc5f --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-6.stderr @@ -0,0 +1,11 @@ +error[E0204]: the trait `Copy` may not be implemented for this type + --> $DIR/range_traits-6.rs:13:10 + | +LL | #[derive(Copy, Clone)] //~ ERROR Copy + | ^^^^ +LL | struct R(RangeInclusive); + | --------------------- this field does not implement `Copy` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0204`. diff --git a/src/test/ui/compile-fail-migration/range_traits-7.rs b/src/test/ui/compile-fail-migration/range_traits-7.rs new file mode 100644 index 00000000000..871b55b85cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-7.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +use std::ops::*; + +#[derive(Copy, Clone)] +struct R(RangeToInclusive); + +#[rustc_error] +fn main() {} //~ ERROR success + diff --git a/src/test/ui/compile-fail-migration/range_traits-7.stderr b/src/test/ui/compile-fail-migration/range_traits-7.stderr new file mode 100644 index 00000000000..516667a11cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/range_traits-7.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/range_traits-7.rs:19:1 + | +LL | fn main() {} //~ ERROR success + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/recursion.rs b/src/test/ui/compile-fail-migration/recursion.rs new file mode 100644 index 00000000000..3221ae46296 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursion.rs @@ -0,0 +1,32 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Nil {NilValue} +struct Cons {head:isize, tail:T} +trait Dot {fn dot(&self, other:Self) -> isize;} +impl Dot for Nil { + fn dot(&self, _:Nil) -> isize {0} +} +impl Dot for Cons { + fn dot(&self, other:Cons) -> isize { + self.head * other.head + self.tail.dot(other.tail) + } +} +fn test (n:isize, i:isize, first:T, second:T) ->isize { //~ ERROR recursion limit + match n { 0 => {first.dot(second)} + // FIXME(#4287) Error message should be here. It should be + // a type error to instantiate `test` at a type other than T. + _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} + } +} +pub fn main() { + let n = test(1, 0, Nil::NilValue, Nil::NilValue); + println!("{}", n); +} diff --git a/src/test/ui/compile-fail-migration/recursion.stderr b/src/test/ui/compile-fail-migration/recursion.stderr new file mode 100644 index 00000000000..5953e5c4087 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursion.stderr @@ -0,0 +1,14 @@ +error: reached the recursion limit while instantiating `test::>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + --> $DIR/recursion.rs:22:1 + | +LL | / fn test (n:isize, i:isize, first:T, second:T) ->isize { //~ ERROR recursion limit +LL | | match n { 0 => {first.dot(second)} +LL | | // FIXME(#4287) Error message should be here. It should be +LL | | // a type error to instantiate `test` at a type other than T. +LL | | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} +LL | | } +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/recursive-enum.rs b/src/test/ui/compile-fail-migration/recursive-enum.rs new file mode 100644 index 00000000000..555755cdb96 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-enum.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum list { cons(T, list), nil } +//~^ ERROR recursive type `list` has infinite size + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/recursive-enum.stderr b/src/test/ui/compile-fail-migration/recursive-enum.stderr new file mode 100644 index 00000000000..c06058b2b59 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-enum.stderr @@ -0,0 +1,13 @@ +error[E0072]: recursive type `list` has infinite size + --> $DIR/recursive-enum.rs:11:1 + | +LL | enum list { cons(T, list), nil } + | ^^^^^^^^^^^^ ------- recursive without indirection + | | + | recursive type has infinite size + | + = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `list` representable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/compile-fail-migration/recursive-reexports.rs b/src/test/ui/compile-fail-migration/recursive-reexports.rs new file mode 100644 index 00000000000..b57b73325c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-reexports.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:recursive_reexports.rs + +extern crate recursive_reexports; + +fn f() -> recursive_reexports::S {} //~ ERROR cannot find type `S` in module `recursive_reexports` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/recursive-reexports.stderr b/src/test/ui/compile-fail-migration/recursive-reexports.stderr new file mode 100644 index 00000000000..e6b8647a981 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-reexports.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `S` in module `recursive_reexports` + --> $DIR/recursive-reexports.rs:15:32 + | +LL | fn f() -> recursive_reexports::S {} //~ ERROR cannot find type `S` in module `recursive_reexports` + | ^ not found in `recursive_reexports` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/compile-fail-migration/recursive-static-definition.rs b/src/test/ui/compile-fail-migration/recursive-static-definition.rs new file mode 100644 index 00000000000..62c1859e09d --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-static-definition.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static FOO: u32 = FOO; +//~^ ERROR cycle detected when const-evaluating `FOO` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/recursive-static-definition.stderr b/src/test/ui/compile-fail-migration/recursive-static-definition.stderr new file mode 100644 index 00000000000..2ab93bfd685 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-static-definition.stderr @@ -0,0 +1,11 @@ +error[E0391]: cycle detected when const-evaluating `FOO` + --> $DIR/recursive-static-definition.rs:11:23 + | +LL | pub static FOO: u32 = FOO; + | ^^^ + | + = note: ...which again requires const-evaluating `FOO`, completing the cycle + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.rs b/src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.rs new file mode 100644 index 00000000000..fa936697072 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct R<'a> { + r: &'a R<'a>, +} + +fn foo(res: Result) -> u32 { + let Ok(x) = res; + //~^ ERROR refutable pattern + x +} + +fn main() { + foo(Ok(23)); +} + diff --git a/src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.stderr b/src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.stderr new file mode 100644 index 00000000000..c4d40412760 --- /dev/null +++ b/src/test/ui/compile-fail-migration/recursive-types-are-not-uninhabited.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in local binding: `Err(_)` not covered + --> $DIR/recursive-types-are-not-uninhabited.rs:16:9 + | +LL | let Ok(x) = res; + | ^^^^^ pattern `Err(_)` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/ref-suggestion.nll.stderr b/src/test/ui/compile-fail-migration/ref-suggestion.nll.stderr new file mode 100644 index 00000000000..3fbd497c7ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/ref-suggestion.nll.stderr @@ -0,0 +1,34 @@ +error[E0382]: use of moved value: `x` + --> $DIR/ref-suggestion.rs:14:5 + | +LL | let y = x; + | - value moved here +LL | x; //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/ref-suggestion.rs:18:5 + | +LL | let mut y = x; + | - value moved here +LL | x; //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/ref-suggestion.rs:26:5 + | +LL | (Some(y), ()) => {}, + | - value moved here +... +LL | x; //~ ERROR use of partially moved value + | ^ value used here after move + | + = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/ref-suggestion.rs b/src/test/ui/compile-fail-migration/ref-suggestion.rs new file mode 100644 index 00000000000..0a0867195d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ref-suggestion.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = vec![1]; + let y = x; + x; //~ ERROR use of moved value + + let x = vec![1]; + let mut y = x; + x; //~ ERROR use of moved value + + let x = (Some(vec![1]), ()); + + match x { + (Some(y), ()) => {}, + _ => {}, + } + x; //~ ERROR use of partially moved value +} diff --git a/src/test/ui/compile-fail-migration/ref-suggestion.stderr b/src/test/ui/compile-fail-migration/ref-suggestion.stderr new file mode 100644 index 00000000000..63ee203ed24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ref-suggestion.stderr @@ -0,0 +1,34 @@ +error[E0382]: use of moved value: `x` + --> $DIR/ref-suggestion.rs:14:5 + | +LL | let y = x; + | - value moved here +LL | x; //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/ref-suggestion.rs:18:5 + | +LL | let mut y = x; + | ----- value moved here +LL | x; //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error[E0382]: use of partially moved value: `x` + --> $DIR/ref-suggestion.rs:26:5 + | +LL | (Some(y), ()) => {}, + | - value moved here +... +LL | x; //~ ERROR use of partially moved value + | ^ value used here after move + | + = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/refutable-pattern-errors.rs b/src/test/ui/compile-fail-migration/refutable-pattern-errors.rs new file mode 100644 index 00000000000..7b4009481ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/refutable-pattern-errors.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn func((1, (Some(1), 2..=3)): (isize, (Option, isize))) { } +//~^ ERROR refutable pattern in function argument: `(_, _)` not covered + +fn main() { + let (1, (Some(1), 2..=3)) = (1, (None, 2)); + //~^ ERROR refutable pattern in local binding: `(_, _)` not covered +} diff --git a/src/test/ui/compile-fail-migration/refutable-pattern-errors.stderr b/src/test/ui/compile-fail-migration/refutable-pattern-errors.stderr new file mode 100644 index 00000000000..c2d5fe001fc --- /dev/null +++ b/src/test/ui/compile-fail-migration/refutable-pattern-errors.stderr @@ -0,0 +1,15 @@ +error[E0005]: refutable pattern in function argument: `(_, _)` not covered + --> $DIR/refutable-pattern-errors.rs:12:9 + | +LL | fn func((1, (Some(1), 2..=3)): (isize, (Option, isize))) { } + | ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered + +error[E0005]: refutable pattern in local binding: `(_, _)` not covered + --> $DIR/refutable-pattern-errors.rs:16:9 + | +LL | let (1, (Some(1), 2..=3)) = (1, (None, 2)); + | ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.rs b/src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.rs new file mode 100644 index 00000000000..be42f0f0ed8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let f = |3: isize| println!("hello"); + //~^ ERROR refutable pattern in function argument: `_` not covered + f(4); +} diff --git a/src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.stderr b/src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.stderr new file mode 100644 index 00000000000..e03532667f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/refutable-pattern-in-fn-arg.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in function argument: `_` not covered + --> $DIR/refutable-pattern-in-fn-arg.rs:12:14 + | +LL | let f = |3: isize| println!("hello"); + | ^ pattern `_` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.nll.stderr b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.nll.stderr new file mode 100644 index 00000000000..5f386e58fac --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.nll.stderr @@ -0,0 +1,25 @@ +error[E0597]: `x` does not live long enough + --> $DIR/region-borrow-params-issue-29793-big.rs:81:43 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | --------- ^ borrowed value does not live long enough + | | + | value captured here +... +LL | }); + | - `x` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/region-borrow-params-issue-29793-big.rs:81:54 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | --------- ^ borrowed value does not live long enough + | | + | value captured here +... +LL | }); + | - `y` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.stderr b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.stderr new file mode 100644 index 00000000000..23dc39db129 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.ast.stderr @@ -0,0 +1,29 @@ +error[E0597]: `x` does not live long enough + --> $DIR/region-borrow-params-issue-29793-big.rs:81:43 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | --------- ^ borrowed value does not live long enough + | | + | capture occurs here +... +LL | }); + | - borrowed value dropped before borrower + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `y` does not live long enough + --> $DIR/region-borrow-params-issue-29793-big.rs:81:54 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | --------- ^ borrowed value does not live long enough + | | + | capture occurs here +... +LL | }); + | - borrowed value dropped before borrower + | + = note: values in a scope are dropped in the opposite order they are created + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.mir.stderr b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.mir.stderr new file mode 100644 index 00000000000..5f386e58fac --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.mir.stderr @@ -0,0 +1,25 @@ +error[E0597]: `x` does not live long enough + --> $DIR/region-borrow-params-issue-29793-big.rs:81:43 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | --------- ^ borrowed value does not live long enough + | | + | value captured here +... +LL | }); + | - `x` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/region-borrow-params-issue-29793-big.rs:81:54 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | --------- ^ borrowed value does not live long enough + | | + | value captured here +... +LL | }); + | - `y` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.rs b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.rs new file mode 100644 index 00000000000..642e90f6de8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-borrow-params-issue-29793-big.rs @@ -0,0 +1,90 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #29793, big regression test: do not let borrows of +// parameters to ever be returned (expanded with exploration of +// variations). +// +// This is the version of the test that actually exposed unsound +// behavior (because the improperly accepted closure was actually +// able to be invoked). + +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct WrapA(Option); + +impl WrapA { + fn new() -> WrapA { + WrapA(None) + } + fn set(mut self, f: F) -> Self { + self.0 = Some(f); + self + } +} + +struct WrapB(Option); + +impl WrapB { + fn new() -> WrapB { + WrapB(None) + } + fn set(mut self, f: F) -> Self { + self.0 = Some(f); + self + } +} + +trait DoStuff : Sized { + fn handle(self); +} + +impl DoStuff for WrapA + where F: FnMut(usize, usize) -> T, T: DoStuff { + fn handle(mut self) { + if let Some(ref mut f) = self.0 { + let x = f(1, 2); + let _foo = [0usize; 16]; + x.handle(); + } + } + } + +impl DoStuff for WrapB where F: FnMut(bool) -> usize { + fn handle(mut self) { + if let Some(ref mut f) = self.0 { + println!("{}", f(true)); + } + } +} + +impl WrapA + where F: FnMut(usize, usize) -> T, T: DoStuff { + fn handle_ref(&mut self) { + if let Some(ref mut f) = self.0 { + let x = f(1, 2); + } + } + } + +fn main() { + let mut w = WrapA::new().set(|x: usize, y: usize| { + WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + //[ast]~^ ERROR `x` does not live long enough + //[ast]~| ERROR `y` does not live long enough + //[mir]~^^^ ERROR `x` does not live long enough + //[mir]~| ERROR `y` does not live long enough + }); + + w.handle(); // This works + // w.handle_ref(); // This doesn't +} diff --git a/src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.rs b/src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.rs new file mode 100644 index 00000000000..c1df057b396 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test related to #22779. In this case, the impl is an inherent impl, +// so it doesn't have to match any trait, so no error results. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct MySlice<'a, T:'a>(&'a mut [T]); + +impl<'a, T> MySlice<'a, T> { + fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b { + &mut self.0[..] + } +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.stderr b/src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.stderr new file mode 100644 index 00000000000..585ccf465d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bound-extra-bound-in-inherent-impl.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/region-bound-extra-bound-in-inherent-impl.rs:26:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.nll.stderr b/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.nll.stderr new file mode 100644 index 00000000000..da6ebaaefad --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.nll.stderr @@ -0,0 +1,14 @@ +error[E0505]: cannot move out of `f` because it is borrowed + --> $DIR/region-bound-on-closure-outlives-call.rs:12:25 + | +LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` + | --------------------^-- + | || | | + | || | move out of `f` occurs here + | || borrow occurs due to use in closure + | |borrow of `f` occurs here + | borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.rs b/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.rs new file mode 100644 index 00000000000..b73c283fa51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn call_rec(mut f: F) -> usize where F: FnMut(usize) -> usize { + (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.stderr b/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.stderr new file mode 100644 index 00000000000..7adf68ee9b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bound-on-closure-outlives-call.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `f` because it is borrowed + --> $DIR/region-bound-on-closure-outlives-call.rs:12:25 + | +LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` + | --- ^ move out of `f` occurs here + | | + | borrow of `f` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.rs b/src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.rs new file mode 100644 index 00000000000..3115e5a9a43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test related to #22779, but where the `'a:'b` relation +// appears in the trait too. No error here. + +#![feature(rustc_attrs)] + +trait Tr<'a, T> { + fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b; +} + +impl<'a, T> Tr<'a, T> for &'a mut [T] { + fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b { + &mut self[..] + } +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.stderr b/src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.stderr new file mode 100644 index 00000000000..ce9dd59bbf5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bound-same-bounds-in-trait-and-impl.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/region-bound-same-bounds-in-trait-and-impl.rs:27:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.rs b/src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.rs new file mode 100644 index 00000000000..fd8d5ff9e7e --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.rs @@ -0,0 +1,46 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test related to when a region bound is required to be specified. + +trait IsStatic : 'static { } +trait IsSend : Send { } +trait Is<'a> : 'a { } +trait Is2<'a> : 'a { } +trait SomeTrait { } + +// Bounds on object types: + +struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used + // All of these are ok, because we can derive exactly one bound: + a: Box, + b: Box>, + c: Box>, + d: Box, + e: Box+Send>, // we can derive two bounds, but one is 'static, so ok + f: Box, // OK, defaults to 'static due to RFC 599. + g: Box, + + z: Box+'b+'c>, + //~^ ERROR only a single explicit lifetime bound is permitted + //~| ERROR lifetime bound not satisfied +} + +fn test< + 'a, + 'b, + A:IsStatic, + B:Is<'a>+Is2<'b>, // OK in a parameter, but not an object type. + C:'b+Is<'a>+Is2<'b>, + D:Is<'a>+Is2<'static>, + E:'a+'b // OK in a parameter, but not an object type. +>() { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.stderr b/src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.stderr new file mode 100644 index 00000000000..7d1a836c674 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-bounds-on-objects-and-type-parameters.stderr @@ -0,0 +1,35 @@ +error[E0226]: only a single explicit lifetime bound is permitted + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:31:22 + | +LL | z: Box+'b+'c>, + | ^^ + +error[E0478]: lifetime bound not satisfied + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:31:5 + | +LL | z: Box+'b+'c>, + | ^^^^^^^^^^^^^^^^^^^^ + | +note: lifetime parameter instantiated with the lifetime 'b as defined on the struct at 21:15 + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:15 + | +LL | struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used + | ^^ +note: but lifetime parameter must outlive the lifetime 'a as defined on the struct at 21:12 + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:12 + | +LL | struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used + | ^^ + +error[E0392]: parameter `'c` is never used + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:18 + | +LL | struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used + | ^^ unused type parameter + | + = help: consider removing `'c` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 3 previous errors + +Some errors occurred: E0226, E0392, E0478. +For more information about an error, try `rustc --explain E0226`. diff --git a/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.nll.stderr b/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.nll.stderr new file mode 100644 index 00000000000..9fc12ae05b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.nll.stderr @@ -0,0 +1,22 @@ +warning: not reporting region error due to nll + --> $DIR/region-invariant-static-error-reporting.rs:24:15 + | +LL | let bad = if x.is_some() { + | _______________^ +LL | | x.unwrap() +LL | | } else { +LL | | mk_static() +LL | | }; + | |_____^ + +error: borrowed data escapes outside of function + --> $DIR/region-invariant-static-error-reporting.rs:25:9 + | +LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { + | - `x` is a reference that is only valid in the function body +LL | let bad = if x.is_some() { +LL | x.unwrap() + | ^^^^^^^^^^ `x` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.rs b/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.rs new file mode 100644 index 00000000000..646ae8183a2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.rs @@ -0,0 +1,32 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test checks that the error messages you get for this example +// at least mention `'a` and `'static`. The precise messages can drift +// over time, but this test used to exhibit some pretty bogus messages +// that were not remotely helpful. + +// error-pattern:the lifetime 'a +// error-pattern:the static lifetime + +struct Invariant<'a>(Option<&'a mut &'a mut ()>); + +fn mk_static() -> Invariant<'static> { Invariant(None) } + +fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { + let bad = if x.is_some() { + x.unwrap() + } else { + mk_static() + }; + f(bad); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.stderr b/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.stderr new file mode 100644 index 00000000000..a1f65561d3e --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-invariant-static-error-reporting.stderr @@ -0,0 +1,23 @@ +error[E0308]: if and else have incompatible types + --> $DIR/region-invariant-static-error-reporting.rs:24:15 + | +LL | let bad = if x.is_some() { + | _______________^ +LL | | x.unwrap() +LL | | } else { +LL | | mk_static() +LL | | }; + | |_____^ lifetime mismatch + | + = note: expected type `Invariant<'a>` + found type `Invariant<'static>` +note: the lifetime 'a as defined on the function body at 23:10... + --> $DIR/region-invariant-static-error-reporting.rs:23:10 + | +LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.nll.stderr b/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.nll.stderr new file mode 100644 index 00000000000..91243478313 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.nll.stderr @@ -0,0 +1,24 @@ +warning: not reporting region error due to nll + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:18:10 + | +LL | *x = *y; //~ ERROR E0623 + | ^^ + +warning: not reporting region error due to nll + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:24:5 + | +LL | a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] + | ^ + +error[E0308]: mismatched types + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:30:43 + | +LL | let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types + | ^ expected concrete lifetime, found bound lifetime parameter + | + = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` + found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.rs new file mode 100644 index 00000000000..e3d96f52e81 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { + // Note: this is legal because of the `'b:'a` declaration. + *x = *y; +} + +fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { + // Illegal now because there is no `'b:'a` declaration. + *x = *y; //~ ERROR E0623 +} + +fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { + // Here we try to call `foo` but do not know that `'a` and `'b` are + // related as required. + a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] +} + +fn d() { + // 'a and 'b are early bound in the function `a` because they appear + // inconstraints: + let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types +} + +fn e() { + // 'a and 'b are late bound in the function `b` because there are + // no constraints: + let _: fn(&mut &isize, &mut &isize) = b; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.stderr new file mode 100644 index 00000000000..0ca7ee8d8a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-lifetime-bounds-on-fns-where-clause.stderr @@ -0,0 +1,31 @@ +error[E0623]: lifetime mismatch + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:18:10 + | +LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +LL | // Illegal now because there is no `'b:'a` declaration. +LL | *x = *y; //~ ERROR E0623 + | ^^ ...but data from `y` flows into `x` here + +error[E0623]: lifetime mismatch + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:24:7 + | +LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +... +LL | a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] + | ^ ...but data from `y` flows into `x` here + +error[E0308]: mismatched types + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:30:43 + | +LL | let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types + | ^ expected concrete lifetime, found bound lifetime parameter + | + = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` + found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` + +error: aborting due to 3 previous errors + +Some errors occurred: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr b/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr new file mode 100644 index 00000000000..655b199fc65 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr @@ -0,0 +1,30 @@ +warning: not reporting region error due to nll + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:19:10 + | +LL | *x = *y; //~ ERROR E0623 + | ^^ + +warning: not reporting region error due to nll + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:20:10 + | +LL | *z = *y; //~ ERROR E0623 + | ^^ + +warning: not reporting region error due to nll + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:26:5 + | +LL | a(x, y, z); //~ ERROR 26:7: 26:8: lifetime mismatch [E0623] + | ^ + +error[E0308]: mismatched types + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:32:56 + | +LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR mismatched types + | ^ expected concrete lifetime, found bound lifetime parameter + | + = note: expected type `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` + found type `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize) {a::<'_, '_, '_>}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.rs new file mode 100644 index 00000000000..d8d12444ddd --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.rs @@ -0,0 +1,41 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c { + // Note: this is legal because of the `'b:'a` declaration. + *x = *y; + *z = *y; +} + +fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + // Illegal now because there is no `'b:'a` declaration. + *x = *y; //~ ERROR E0623 + *z = *y; //~ ERROR E0623 +} + +fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + // Here we try to call `foo` but do not know that `'a` and `'b` are + // related as required. + a(x, y, z); //~ ERROR 26:7: 26:8: lifetime mismatch [E0623] +} + +fn d() { + // 'a and 'b are early bound in the function `a` because they appear + // inconstraints: + let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR mismatched types +} + +fn e() { + // 'a and 'b are late bound in the function `b` because there are + // no constraints: + let _: fn(&mut &isize, &mut &isize, &mut &isize) = b; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.stderr new file mode 100644 index 00000000000..26e24b2ed16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-multiple-lifetime-bounds-on-fns-where-clause.stderr @@ -0,0 +1,42 @@ +error[E0623]: lifetime mismatch + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:19:10 + | +LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | --------- --------- these two types are declared with different lifetimes... +LL | // Illegal now because there is no `'b:'a` declaration. +LL | *x = *y; //~ ERROR E0623 + | ^^ ...but data from `y` flows into `x` here + +error[E0623]: lifetime mismatch + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:20:10 + | +LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | --------- --------- + | | + | these two types are declared with different lifetimes... +... +LL | *z = *y; //~ ERROR E0623 + | ^^ ...but data from `y` flows into `z` here + +error[E0623]: lifetime mismatch + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:26:7 + | +LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | --------- --------- these two types are declared with different lifetimes... +... +LL | a(x, y, z); //~ ERROR 26:7: 26:8: lifetime mismatch [E0623] + | ^ ...but data from `y` flows into `x` here + +error[E0308]: mismatched types + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:32:56 + | +LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR mismatched types + | ^ expected concrete lifetime, found bound lifetime parameter + | + = note: expected type `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` + found type `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize) {a::<'_, '_, '_>}` + +error: aborting due to 4 previous errors + +Some errors occurred: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-1.rs b/src/test/ui/compile-fail-migration/region-object-lifetime-1.rs new file mode 100644 index 00000000000..1e615be9d6a --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-1.rs @@ -0,0 +1,28 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various tests related to testing how region inference works +// with respect to the object receivers. + +#![feature(rustc_attrs)] +#![allow(warnings)] + +trait Foo { + fn borrowed<'a>(&'a self) -> &'a (); +} + +// Here the receiver and return value all have the same lifetime, +// so no error results. +fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () { + x.borrowed() +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-1.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-1.stderr new file mode 100644 index 00000000000..39deed32c76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-1.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/region-object-lifetime-1.rs:28:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-2.nll.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-2.nll.stderr new file mode 100644 index 00000000000..4395fee02c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-2.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/region-object-lifetime-2.rs:20:7 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^ + +error: borrowed data escapes outside of function + --> $DIR/region-object-lifetime-2.rs:20:5 + | +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { + | - `x` is a reference that is only valid in the function body +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^^^^^ `x` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-2.rs b/src/test/ui/compile-fail-migration/region-object-lifetime-2.rs new file mode 100644 index 00000000000..e011b8f5697 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-2.rs @@ -0,0 +1,23 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various tests related to testing how region inference works +// with respect to the object receivers. + +trait Foo { + fn borrowed<'a>(&'a self) -> &'a (); +} + +// Borrowed receiver but two distinct lifetimes, we get an error. +fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { + x.borrowed() //~ ERROR cannot infer +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-2.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-2.stderr new file mode 100644 index 00000000000..e396680f99b --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-2.stderr @@ -0,0 +1,30 @@ +error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements + --> $DIR/region-object-lifetime-2.rs:20:7 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 19:42... + --> $DIR/region-object-lifetime-2.rs:19:42 + | +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { + | ^^ +note: ...so that the type `(dyn Foo + 'a)` is not borrowed for too long + --> $DIR/region-object-lifetime-2.rs:20:5 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^ +note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 19:45... + --> $DIR/region-object-lifetime-2.rs:19:45 + | +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/region-object-lifetime-2.rs:20:5 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-3.rs b/src/test/ui/compile-fail-migration/region-object-lifetime-3.rs new file mode 100644 index 00000000000..84dd97643a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-3.rs @@ -0,0 +1,28 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various tests related to testing how region inference works +// with respect to the object receivers. + +#![feature(rustc_attrs)] +#![allow(warnings)] + +trait Foo { + fn borrowed<'a>(&'a self) -> &'a (); +} + +// Borrowed receiver with two distinct lifetimes, but we know that +// 'b:'a, hence &'a () is permitted. +fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (Foo+'b)) -> &'a () { + x.borrowed() +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-3.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-3.stderr new file mode 100644 index 00000000000..9431e8f5291 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-3.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/region-object-lifetime-3.rs:28:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-4.nll.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-4.nll.stderr new file mode 100644 index 00000000000..7bae6ccb37c --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-4.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/region-object-lifetime-4.rs:22:7 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/region-object-lifetime-4.rs:22:5 + | +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-4.rs b/src/test/ui/compile-fail-migration/region-object-lifetime-4.rs new file mode 100644 index 00000000000..0a68e7f1076 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-4.rs @@ -0,0 +1,25 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various tests related to testing how region inference works +// with respect to the object receivers. + +trait Foo { + fn borrowed<'a>(&'a self) -> &'a (); +} + +// Here we have two distinct lifetimes, but we try to return a pointer +// with the longer lifetime when (from the signature) we only know +// that it lives as long as the shorter lifetime. Therefore, error. +fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { + x.borrowed() //~ ERROR cannot infer +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-4.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-4.stderr new file mode 100644 index 00000000000..ef62afbef3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-4.stderr @@ -0,0 +1,30 @@ +error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements + --> $DIR/region-object-lifetime-4.rs:22:7 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 21:41... + --> $DIR/region-object-lifetime-4.rs:21:41 + | +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/region-object-lifetime-4.rs:22:5 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^ +note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 21:44... + --> $DIR/region-object-lifetime-4.rs:21:44 + | +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/region-object-lifetime-4.rs:22:5 + | +LL | x.borrowed() //~ ERROR cannot infer + | ^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-5.nll.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-5.nll.stderr new file mode 100644 index 00000000000..3bfa5ec3941 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-5.nll.stderr @@ -0,0 +1,13 @@ +error[E0597]: `*x` does not live long enough + --> $DIR/region-object-lifetime-5.rs:21:5 + | +LL | x.borrowed() //~ ERROR `*x` does not live long enough + | ^ borrowed value does not live long enough +LL | } + | - `*x` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-5.rs b/src/test/ui/compile-fail-migration/region-object-lifetime-5.rs new file mode 100644 index 00000000000..26aad0e33b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-5.rs @@ -0,0 +1,24 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various tests related to testing how region inference works +// with respect to the object receivers. + +trait Foo { + fn borrowed<'a>(&'a self) -> &'a (); +} + +// Here, the object is bounded by an anonymous lifetime and returned +// as `&'static`, so you get an error. +fn owned_receiver(x: Box) -> &'static () { + x.borrowed() //~ ERROR `*x` does not live long enough +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-5.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-5.stderr new file mode 100644 index 00000000000..2dbdacfacdc --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-5.stderr @@ -0,0 +1,13 @@ +error[E0597]: `*x` does not live long enough + --> $DIR/region-object-lifetime-5.rs:21:5 + | +LL | x.borrowed() //~ ERROR `*x` does not live long enough + | ^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.nll.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.nll.stderr new file mode 100644 index 00000000000..87a0a3267ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.nll.stderr @@ -0,0 +1,74 @@ +warning: not reporting region error due to nll + --> $DIR/region-object-lifetime-in-coercion.rs:18:42 + | +LL | let x: Box = Box::new(v); + | ^ + +warning: not reporting region error due to nll + --> $DIR/region-object-lifetime-in-coercion.rs:24:14 + | +LL | Box::new(v) + | ^ + +warning: not reporting region error due to nll + --> $DIR/region-object-lifetime-in-coercion.rs:31:14 + | +LL | Box::new(v) + | ^ + +warning: not reporting region error due to nll + --> $DIR/region-object-lifetime-in-coercion.rs:36:14 + | +LL | Box::new(v) + | ^ + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/region-object-lifetime-in-coercion.rs:18:33 + | +LL | fn a(v: &[u8]) -> Box { + | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` +LL | let x: Box = Box::new(v); + | ^^^^^^^^^^^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/region-object-lifetime-in-coercion.rs:23:38 + | +LL | fn b(v: &[u8]) -> Box { + | _________-----________________________^ + | | | + | | help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` +LL | | Box::new(v) +LL | | //~^ ERROR explicit lifetime required in the type of `v` [E0621] +LL | | } + | |_^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/region-object-lifetime-in-coercion.rs:28:28 + | +LL | fn c(v: &[u8]) -> Box { + | _________-----______________^ + | | | + | | help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` +LL | | // same as previous case due to RFC 599 +LL | | +LL | | Box::new(v) +LL | | //~^ ERROR explicit lifetime required in the type of `v` [E0621] +LL | | } + | |_^ lifetime `'static` required + +error: unsatisfied lifetime constraints + --> $DIR/region-object-lifetime-in-coercion.rs:35:41 + | +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { + | ______--_--______________________________^ + | | | | + | | | lifetime `'b` defined here + | | lifetime `'a` defined here +LL | | Box::new(v) +LL | | //~^ ERROR cannot infer an appropriate lifetime due to conflicting +LL | | } + | |_^ return requires that `'a` must outlive `'b` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.rs b/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.rs new file mode 100644 index 00000000000..5bf397ab383 --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.rs @@ -0,0 +1,44 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that attempts to implicitly coerce a value into an +// object respect the lifetime bound on the object type. + +trait Foo {} +impl<'a> Foo for &'a [u8] {} + +fn a(v: &[u8]) -> Box { + let x: Box = Box::new(v); + //~^ ERROR explicit lifetime required in the type of `v` [E0621] + x +} + +fn b(v: &[u8]) -> Box { + Box::new(v) + //~^ ERROR explicit lifetime required in the type of `v` [E0621] +} + +fn c(v: &[u8]) -> Box { + // same as previous case due to RFC 599 + + Box::new(v) + //~^ ERROR explicit lifetime required in the type of `v` [E0621] +} + +fn d<'a,'b>(v: &'a [u8]) -> Box { + Box::new(v) + //~^ ERROR cannot infer an appropriate lifetime due to conflicting +} + +fn e<'a:'b,'b>(v: &'a [u8]) -> Box { + Box::new(v) // OK, thanks to 'a:'b +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.stderr b/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.stderr new file mode 100644 index 00000000000..ac8c4d3a16a --- /dev/null +++ b/src/test/ui/compile-fail-migration/region-object-lifetime-in-coercion.stderr @@ -0,0 +1,52 @@ +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/region-object-lifetime-in-coercion.rs:18:33 + | +LL | fn a(v: &[u8]) -> Box { + | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` +LL | let x: Box = Box::new(v); + | ^^^^^^^^^^^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/region-object-lifetime-in-coercion.rs:24:5 + | +LL | fn b(v: &[u8]) -> Box { + | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` +LL | Box::new(v) + | ^^^^^^^^^^^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/region-object-lifetime-in-coercion.rs:31:5 + | +LL | fn c(v: &[u8]) -> Box { + | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` +... +LL | Box::new(v) + | ^^^^^^^^^^^ lifetime `'static` required + +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/region-object-lifetime-in-coercion.rs:36:14 + | +LL | Box::new(v) + | ^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 35:6... + --> $DIR/region-object-lifetime-in-coercion.rs:35:6 + | +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { + | ^^ + = note: ...so that the expression is assignable: + expected &[u8] + found &'a [u8] +note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 35:9... + --> $DIR/region-object-lifetime-in-coercion.rs:35:9 + | +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { + | ^^ + = note: ...so that the expression is assignable: + expected std::boxed::Box<(dyn Foo + 'b)> + found std::boxed::Box + +error: aborting due to 4 previous errors + +Some errors occurred: E0495, E0621. +For more information about an error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-arg.nll.stderr b/src/test/ui/compile-fail-migration/regions-addr-of-arg.nll.stderr new file mode 100644 index 00000000000..9bfc80c9459 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-arg.nll.stderr @@ -0,0 +1,27 @@ +error[E0597]: `a` does not live long enough + --> $DIR/regions-addr-of-arg.rs:15:30 + | +LL | let _p: &'static isize = &a; //~ ERROR `a` does not live long enough + | ^^ borrowed value does not live long enough +LL | } + | - `a` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `a` does not live long enough + --> $DIR/regions-addr-of-arg.rs:23:5 + | +LL | &a //~ ERROR `a` does not live long enough + | ^^ borrowed value does not live long enough +LL | } + | - `a` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 22:8... + --> $DIR/regions-addr-of-arg.rs:22:8 + | +LL | fn zed<'a>(a: isize) -> &'a isize { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-arg.rs b/src/test/ui/compile-fail-migration/regions-addr-of-arg.rs new file mode 100644 index 00000000000..c54b4aaace5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-arg.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that taking the address of an argument yields a lifetime +// bounded by the current function call. + +fn foo(a: isize) { + let _p: &'static isize = &a; //~ ERROR `a` does not live long enough +} + +fn bar(a: isize) { + let _q: &isize = &a; +} + +fn zed<'a>(a: isize) -> &'a isize { + &a //~ ERROR `a` does not live long enough +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-arg.stderr b/src/test/ui/compile-fail-migration/regions-addr-of-arg.stderr new file mode 100644 index 00000000000..9158a4ac7a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-arg.stderr @@ -0,0 +1,27 @@ +error[E0597]: `a` does not live long enough + --> $DIR/regions-addr-of-arg.rs:15:31 + | +LL | let _p: &'static isize = &a; //~ ERROR `a` does not live long enough + | ^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `a` does not live long enough + --> $DIR/regions-addr-of-arg.rs:23:6 + | +LL | &a //~ ERROR `a` does not live long enough + | ^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 22:8... + --> $DIR/regions-addr-of-arg.rs:22:8 + | +LL | fn zed<'a>(a: isize) -> &'a isize { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-self.nll.stderr b/src/test/ui/compile-fail-migration/regions-addr-of-self.nll.stderr new file mode 100644 index 00000000000..cad1384f198 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-self.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/regions-addr-of-self.rs:17:37 + | +LL | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-addr-of-self.rs:17:37 + | +LL | pub fn chase_cat(&mut self) { + | - let's call the lifetime of this reference `'1` +LL | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^^^^^^^^ requires that `'1` must outlive `'static` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-self.rs b/src/test/ui/compile-fail-migration/regions-addr-of-self.rs new file mode 100644 index 00000000000..04ee0526403 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-self.rs @@ -0,0 +1,37 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct dog { + cats_chased: usize, +} + +impl dog { + pub fn chase_cat(&mut self) { + let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer + *p += 1; + } + + pub fn chase_cat_2(&mut self) { + let p: &mut usize = &mut self.cats_chased; + *p += 1; + } +} + +fn dog() -> dog { + dog { + cats_chased: 0 + } +} + +fn main() { + let mut d = dog(); + d.chase_cat(); + println!("cats_chased: {}", d.cats_chased); +} diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-self.stderr b/src/test/ui/compile-fail-migration/regions-addr-of-self.stderr new file mode 100644 index 00000000000..387aeeb8a5b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-self.stderr @@ -0,0 +1,29 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-addr-of-self.rs:17:37 + | +LL | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 16:5... + --> $DIR/regions-addr-of-self.rs:16:5 + | +LL | / pub fn chase_cat(&mut self) { +LL | | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer +LL | | *p += 1; +LL | | } + | |_____^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-addr-of-self.rs:17:37 + | +LL | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^^^^^^^^ + = note: but, the lifetime must be valid for the static lifetime... +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-addr-of-self.rs:17:37 + | +LL | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.nll.stderr b/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.nll.stderr new file mode 100644 index 00000000000..733ac7a06ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.nll.stderr @@ -0,0 +1,41 @@ +warning: not reporting region error due to nll + --> $DIR/regions-addr-of-upvar-self.rs:20:41 + | +LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-addr-of-upvar-self.rs:20:41 + | +LL | let _f = || { + | __________________- +LL | | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + | | ^^^^^^^^^^^^^^ requires that `'1` must outlive `'static` +LL | | *p = 3; +LL | | }; + | |_________- lifetime `'1` represents the closure body + +error: unsatisfied lifetime constraints + --> $DIR/regions-addr-of-upvar-self.rs:19:13 + | +LL | pub fn chase_cat(&mut self) { + | - let's call the lifetime of this reference `'1` +LL | let _f = || { + | ^^ requires that `'1` must outlive `'static` + +error[E0597]: `self` does not live long enough + --> $DIR/regions-addr-of-upvar-self.rs:20:46 + | +LL | let _f = || { + | -- value captured here +LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + | ^^^^ borrowed value does not live long enough +... +LL | } + | - `self` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.rs b/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.rs new file mode 100644 index 00000000000..28491f1155c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::usize; + +struct dog { + food: usize, +} + +impl dog { + pub fn chase_cat(&mut self) { + let _f = || { + let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + *p = 3; + }; + } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.stderr b/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.stderr new file mode 100644 index 00000000000..35e721288cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-addr-of-upvar-self.stderr @@ -0,0 +1,26 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-addr-of-upvar-self.rs:20:41 + | +LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime as defined on the body at 19:18... + --> $DIR/regions-addr-of-upvar-self.rs:19:18 + | +LL | let _f = || { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-addr-of-upvar-self.rs:20:41 + | +LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^ + = note: but, the lifetime must be valid for the static lifetime... +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-addr-of-upvar-self.rs:20:41 + | +LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.nll.stderr b/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.nll.stderr new file mode 100644 index 00000000000..f342155c8b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.nll.stderr @@ -0,0 +1,23 @@ +error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable + --> $DIR/regions-adjusted-lvalue-op.rs:24:16 + | +LL | v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because + | -----------^^- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable + --> $DIR/regions-adjusted-lvalue-op.rs:25:16 + | +LL | (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because + | -----------^^- + | | | | + | | | immutable borrow occurs here + | | mutable borrow occurs here + | borrow later used here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.rs b/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.rs new file mode 100644 index 00000000000..bb02d6d8bba --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// check that we link regions in mutable place ops correctly - issue #41774 + +struct Data(i32); + +trait OhNo { + fn oh_no(&mut self, other: &Vec) { loop {} } +} + +impl OhNo for Data {} +impl OhNo for [Data] {} + +fn main() { + let mut v = vec![Data(0)]; + v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because + (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because +} diff --git a/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.stderr b/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.stderr new file mode 100644 index 00000000000..95228d9ccbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-adjusted-lvalue-op.stderr @@ -0,0 +1,21 @@ +error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable + --> $DIR/regions-adjusted-lvalue-op.rs:24:17 + | +LL | v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because + | - ^- mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable + --> $DIR/regions-adjusted-lvalue-op.rs:25:17 + | +LL | (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because + | - ^- mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.rs b/src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.rs new file mode 100644 index 00000000000..f2ff877cd82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.rs @@ -0,0 +1,54 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are imposing the requirement that every associated +// type of a bound that appears in the where clause on a struct must +// outlive the location in which the type appears, even when the +// associted type is in a supertype. Issue #22246. + +#![allow(dead_code)] + +/////////////////////////////////////////////////////////////////////////// + +pub trait TheTrait { + type TheAssocType; +} + +pub trait TheSubTrait : TheTrait { +} + +pub struct TheType<'b> { + m: [fn(&'b()); 0] +} + +impl<'b> TheTrait for TheType<'b> { + type TheAssocType = &'b (); +} + +impl<'b> TheSubTrait for TheType<'b> { +} + +/////////////////////////////////////////////////////////////////////////// + +pub struct WithAssoc { + m: [T; 0] +} + +fn with_assoc<'a,'b>() { + // For this type to be valid, the rules require that all + // associated types of traits that appear in `WithAssoc` must + // outlive 'a. In this case, that means TheType<'b>::TheAssocType, + // which is &'b (), must outlive 'a. + + let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.stderr b/src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.stderr new file mode 100644 index 00000000000..3bfc6d3682c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-assoc-type-in-supertrait-outlives-container.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:50:12 + | +LL | let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 44:15 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:44:15 + | +LL | fn with_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 44:18 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:44:18 + | +LL | fn with_assoc<'a,'b>() { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.rs b/src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.rs new file mode 100644 index 00000000000..f921eccef1f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the compiler checks that arbitrary region bounds declared +// in the trait must be satisfied on the impl. Issue #20890. + +trait Foo<'a> { + type Value: 'a; + fn dummy(&'a self) { } +} + +impl<'a> Foo<'a> for &'a i16 { + // OK. + type Value = &'a i32; +} + +impl<'a> Foo<'static> for &'a i32 { + //~^ ERROR cannot infer + type Value = &'a i32; +} + +impl<'a,'b> Foo<'b> for &'a i64 { + //~^ ERROR cannot infer + type Value = &'a i32; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.stderr b/src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.stderr new file mode 100644 index 00000000000..2261e92166e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-assoc-type-region-bound-in-trait-not-met.stderr @@ -0,0 +1,49 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:24:10 + | +LL | impl<'a> Foo<'static> for &'a i32 { + | ^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 24:6... + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:24:6 + | +LL | impl<'a> Foo<'static> for &'a i32 { + | ^^ + = note: ...so that the types are compatible: + expected Foo<'static> + found Foo<'static> + = note: but, the lifetime must be valid for the static lifetime... +note: ...so that the type `&i32` will meet its required lifetime bounds + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:24:10 + | +LL | impl<'a> Foo<'static> for &'a i32 { + | ^^^^^^^^^^^^ + +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:29:13 + | +LL | impl<'a,'b> Foo<'b> for &'a i64 { + | ^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 29:6... + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:29:6 + | +LL | impl<'a,'b> Foo<'b> for &'a i64 { + | ^^ + = note: ...so that the types are compatible: + expected Foo<'b> + found Foo<'_> +note: but, the lifetime must be valid for the lifetime 'b as defined on the impl at 29:9... + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:29:9 + | +LL | impl<'a,'b> Foo<'b> for &'a i64 { + | ^^ +note: ...so that the type `&i32` will meet its required lifetime bounds + --> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:29:13 + | +LL | impl<'a,'b> Foo<'b> for &'a i64 { + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.rs b/src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.rs new file mode 100644 index 00000000000..1cf83b8ac58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the compiler checks that the 'static bound declared in +// the trait must be satisfied on the impl. Issue #20890. + +trait Foo { + type Value: 'static; + fn dummy(&self) { } +} + +impl<'a> Foo for &'a i32 { + //~^ ERROR cannot infer + type Value = &'a i32; +} + +impl<'a> Foo for i32 { + // OK. + type Value = i32; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.stderr b/src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.stderr new file mode 100644 index 00000000000..a7ae685c3a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-assoc-type-static-bound-in-trait-not-met.stderr @@ -0,0 +1,24 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:19:10 + | +LL | impl<'a> Foo for &'a i32 { + | ^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 19:6... + --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:19:6 + | +LL | impl<'a> Foo for &'a i32 { + | ^^ + = note: ...so that the types are compatible: + expected Foo + found Foo + = note: but, the lifetime must be valid for the static lifetime... +note: ...so that the type `&i32` will meet its required lifetime bounds + --> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:19:10 + | +LL | impl<'a> Foo for &'a i32 { + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.rs b/src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.rs new file mode 100644 index 00000000000..19c50d57e1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.rs @@ -0,0 +1,73 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test which of the builtin types are considered sendable. The tests +// in this file all test region bound and lifetime violations that are +// detected during type check. + +trait Dummy : 'static { } +fn assert_send() { } + +// lifetime pointers with 'static lifetime are ok + +fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) { + assert_send::<&'static isize>(); + assert_send::<&'static str>(); + assert_send::<&'static [isize]>(); + + // whether or not they are mutable + assert_send::<&'static mut isize>(); +} + +// otherwise lifetime pointers are not ok + +fn param_not_ok<'a>(x: &'a isize) { + assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime +} + +fn param_not_ok1<'a>(_: &'a isize) { + assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime +} + +fn param_not_ok2<'a>(_: &'a isize) { + assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime +} + +// boxes are ok + +fn box_ok() { + assert_send::>(); + assert_send::(); + assert_send::>(); +} + +// but not if they own a bad thing + +fn box_with_region_not_ok<'a>() { + assert_send::>(); //~ ERROR does not fulfill the required lifetime +} + +// raw pointers are ok unless they point at unsendable things + +fn unsafe_ok1<'a>(_: &'a isize) { + assert_send::<*const isize>(); + assert_send::<*mut isize>(); +} + +fn unsafe_ok2<'a>(_: &'a isize) { + assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime +} + +fn unsafe_ok3<'a>(_: &'a isize) { + assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.stderr b/src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.stderr new file mode 100644 index 00000000000..82fa271ca4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-by-trait-requiring-static.stderr @@ -0,0 +1,51 @@ +error[E0477]: the type `&'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5 + | +LL | assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error[E0477]: the type `&'a str` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:36:5 + | +LL | assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:40:5 + | +LL | assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error[E0477]: the type `std::boxed::Box<&'a isize>` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5 + | +LL | assert_send::>(); //~ ERROR does not fulfill the required lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:65:5 + | +LL | assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:69:5 + | +LL | assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0477`. diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.nll.stderr b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.nll.stderr new file mode 100644 index 00000000000..553eedec398 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.nll.stderr @@ -0,0 +1,19 @@ +warning: not reporting region error due to nll + --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:30:7 + | +LL | a.bigger_region(b) //~ ERROR 30:7: 30:20: lifetime mismatch [E0623] + | ^^^^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:30:5 + | +LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { + | -- -- lifetime `'y` defined here + | | + | lifetime `'x` defined here +LL | // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. +LL | a.bigger_region(b) //~ ERROR 30:7: 30:20: lifetime mismatch [E0623] + | ^^^^^^^^^^^^^^^^^^ argument requires that `'y` must outlive `'x` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.rs b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.rs new file mode 100644 index 00000000000..24e4c5fbd91 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:rbmtp_cross_crate_lib.rs + +// Check explicit region bounds on methods in the cross crate case. + +extern crate rbmtp_cross_crate_lib as lib; + +use lib::Inv; +use lib::MaybeOwned; +use lib::IntoMaybeOwned; + +fn call_into_maybe_owned<'x,F:IntoMaybeOwned<'x>>(f: F) { + // Exercise a code path I found to be buggy. We were not encoding + // the region parameters from the receiver correctly on trait + // methods. + f.into_maybe_owned(); +} + +fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { + // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. + a.bigger_region(b) //~ ERROR 30:7: 30:20: lifetime mismatch [E0623] +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.stderr b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.stderr new file mode 100644 index 00000000000..898629d8ab9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-cross-crate.stderr @@ -0,0 +1,12 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:30:7 + | +LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { + | ------- ------- these two types are declared with different lifetimes... +LL | // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. +LL | a.bigger_region(b) //~ ERROR 30:7: 30:20: lifetime mismatch [E0623] + | ^^^^^^^^^^^^^ ...but data from `b` flows into `a` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.nll.stderr b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.nll.stderr new file mode 100644 index 00000000000..adcf4921e53 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.nll.stderr @@ -0,0 +1,19 @@ +warning: not reporting region error due to nll + --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:30:7 + | +LL | f.method(b); //~ ERROR 30:7: 30:13: lifetime mismatch [E0623] + | ^^^^^^ + +error: borrowed data escapes outside of function + --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:30:5 + | +LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + | - - `b` is a reference that is only valid in the function body + | | + | `a` is declared here, outside of the function body +LL | // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. +LL | f.method(b); //~ ERROR 30:7: 30:13: lifetime mismatch [E0623] + | ^^^^^^^^^^^ `b` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.rs b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.rs new file mode 100644 index 00000000000..3e9d2aa6c3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that explicit region bounds are allowed on the various +// nominal types (but not on other types) and that they are type +// checked. + +struct Inv<'a> { // invariant w/r/t 'a + x: &'a mut &'a isize +} + +trait Foo<'x> { + fn method<'y:'x>(self, y: Inv<'y>); +} + +fn caller1<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + // Here the value provided for 'y is 'a, and hence 'a:'a holds. + f.method(a); +} + +fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. + f.method(b); //~ ERROR 30:7: 30:13: lifetime mismatch [E0623] +} + +fn caller3<'a,'b:'a,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + // Here the value provided for 'y is 'b, and hence 'b:'a holds. + f.method(b); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.stderr b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.stderr new file mode 100644 index 00000000000..f9f9c38b1b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters-trait-bound.stderr @@ -0,0 +1,12 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:30:7 + | +LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + | ------- ------- these two types are declared with different lifetimes... +LL | // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. +LL | f.method(b); //~ ERROR 30:7: 30:13: lifetime mismatch [E0623] + | ^^^^^^ ...but data from `b` flows into `a` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.rs b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.rs new file mode 100644 index 00000000000..da4e8231a23 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that explicit region bounds are allowed on the various +// nominal types (but not on other types) and that they are type +// checked. + +struct Foo; + +impl Foo { + fn some_method(self) { } +} + +fn caller<'a>(x: &isize) { + Foo.some_method::<&'a isize>(); + //~^ ERROR does not fulfill the required lifetime +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.stderr b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.stderr new file mode 100644 index 00000000000..8649ca9281f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounded-method-type-parameters.stderr @@ -0,0 +1,11 @@ +error[E0477]: the type `&'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-method-type-parameters.rs:22:9 + | +LL | Foo.some_method::<&'a isize>(); + | ^^^^^^^^^^^ + | + = note: type must satisfy the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0477`. diff --git a/src/test/ui/compile-fail-migration/regions-bounds.nll.stderr b/src/test/ui/compile-fail-migration/regions-bounds.nll.stderr new file mode 100644 index 00000000000..4d4a30a88c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounds.nll.stderr @@ -0,0 +1,34 @@ +warning: not reporting region error due to nll + --> $DIR/regions-bounds.rs:19:12 + | +LL | return e; //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-bounds.rs:23:12 + | +LL | return e; //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-bounds.rs:19:12 + | +LL | fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | return e; //~ ERROR mismatched types + | ^ return requires that `'a` must outlive `'b` + +error: unsatisfied lifetime constraints + --> $DIR/regions-bounds.rs:23:12 + | +LL | fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | return e; //~ ERROR mismatched types + | ^ return requires that `'a` must outlive `'b` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/regions-bounds.rs b/src/test/ui/compile-fail-migration/regions-bounds.rs new file mode 100644 index 00000000000..5ce80be98d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounds.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that explicit region bounds are allowed on the various +// nominal types (but not on other types) and that they are type +// checked. + +struct an_enum<'a>(&'a isize); +struct a_class<'a> { x:&'a isize } + +fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { + return e; //~ ERROR mismatched types +} + +fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { + return e; //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-bounds.stderr b/src/test/ui/compile-fail-migration/regions-bounds.stderr new file mode 100644 index 00000000000..7d5a47c0df3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-bounds.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/regions-bounds.rs:19:12 + | +LL | return e; //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `an_enum<'b>` + found type `an_enum<'a>` +note: the lifetime 'a as defined on the function body at 18:10... + --> $DIR/regions-bounds.rs:18:10 + | +LL | fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the function body at 18:13 + --> $DIR/regions-bounds.rs:18:13 + | +LL | fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { + | ^^ + +error[E0308]: mismatched types + --> $DIR/regions-bounds.rs:23:12 + | +LL | return e; //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `a_class<'b>` + found type `a_class<'a>` +note: the lifetime 'a as defined on the function body at 22:10... + --> $DIR/regions-bounds.rs:22:10 + | +LL | fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the function body at 22:13 + --> $DIR/regions-bounds.rs:22:13 + | +LL | fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.nll.stderr new file mode 100644 index 00000000000..5bec650a41d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.nll.stderr @@ -0,0 +1,60 @@ +warning: not reporting region error due to nll + --> $DIR/regions-close-associated-type-into-object.rs:25:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-associated-type-into-object.rs:32:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-associated-type-into-object.rs:38:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-associated-type-into-object.rs:45:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +error[E0310]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:25:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'static`... + +error[E0310]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:32:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'static`... + +error[E0309]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:38:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'a`... + +error[E0309]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:45:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'a`... + +error: aborting due to 4 previous errors + +Some errors occurred: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.rs b/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.rs new file mode 100644 index 00000000000..6b88abfca6c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.rs @@ -0,0 +1,81 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +trait X {} + +trait Iter { + type Item: X; + + fn into_item(self) -> Self::Item; + fn as_item(&self) -> &Self::Item; +} + +fn bad1(v: T) -> Box +{ + let item = v.into_item(); + Box::new(item) //~ ERROR associated type `::Item` may not live long enough +} + +fn bad2(v: T) -> Box + where Box : X +{ + let item: Box<_> = box v.into_item(); + Box::new(item) //~ ERROR associated type `::Item` may not live long enough +} + +fn bad3<'a, T: Iter>(v: T) -> Box +{ + let item = v.into_item(); + Box::new(item) //~ ERROR associated type `::Item` may not live long enough +} + +fn bad4<'a, T: Iter>(v: T) -> Box + where Box : X +{ + let item: Box<_> = box v.into_item(); + Box::new(item) //~ ERROR associated type `::Item` may not live long enough +} + +fn ok1<'a, T: Iter>(v: T) -> Box + where T::Item : 'a +{ + let item = v.into_item(); + Box::new(item) // OK, T::Item : 'a is declared +} + +fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box + where T::Item : Clone +{ + let item = Clone::clone(w); + Box::new(item) // OK, T::Item : 'a is implied +} + +fn ok3<'a, T: Iter>(v: &'a T) -> Box + where T::Item : Clone + 'a +{ + let item = Clone::clone(v.as_item()); + Box::new(item) // OK, T::Item : 'a was declared +} + +fn meh1<'a, T: Iter>(v: &'a T) -> Box + where T::Item : Clone +{ + // This case is kind of interesting. It's the same as `ok3` but + // without the explicit declaration. This is valid because `T: 'a + // => T::Item: 'a`, and the former we can deduce from our argument + // of type `&'a T`. + + let item = Clone::clone(v.as_item()); + Box::new(item) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.stderr b/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.stderr new file mode 100644 index 00000000000..9d56de4c152 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-associated-type-into-object.stderr @@ -0,0 +1,56 @@ +error[E0310]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:25:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'static`... +note: ...so that the type `::Item` will meet its required lifetime bounds + --> $DIR/regions-close-associated-type-into-object.rs:25:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +error[E0310]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:32:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'static`... +note: ...so that the type `std::boxed::Box<::Item>` will meet its required lifetime bounds + --> $DIR/regions-close-associated-type-into-object.rs:32:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +error[E0309]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:38:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'a`... +note: ...so that the type `::Item` will meet its required lifetime bounds + --> $DIR/regions-close-associated-type-into-object.rs:38:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +error[E0309]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:45:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'a`... +note: ...so that the type `std::boxed::Box<::Item>` will meet its required lifetime bounds + --> $DIR/regions-close-associated-type-into-object.rs:45:5 + | +LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough + | ^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.nll.stderr new file mode 100644 index 00000000000..84e486872a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.nll.stderr @@ -0,0 +1,13 @@ +error[E0597]: `*v` does not live long enough + --> $DIR/regions-close-object-into-object-1.rs:22:11 + | +LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough + | ^^^ borrowed value does not live long enough +LL | } + | - `*v` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.rs b/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.rs new file mode 100644 index 00000000000..5d9818d624b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] +#![allow(warnings)] + +trait A { } +struct B<'a, T:'a>(&'a (A+'a)); + +trait X { } + +impl<'a, T> X for B<'a, T> {} + +fn f<'a, T:'static, U>(v: Box+'static>) -> Box { + box B(&*v) as Box //~ ERROR `*v` does not live long enough +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.stderr new file mode 100644 index 00000000000..bd05a63c398 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-1.stderr @@ -0,0 +1,13 @@ +error[E0597]: `*v` does not live long enough + --> $DIR/regions-close-object-into-object-1.rs:22:12 + | +LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough + | ^^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.nll.stderr new file mode 100644 index 00000000000..5258dbe793a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.nll.stderr @@ -0,0 +1,30 @@ +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-2.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-close-object-into-object-2.rs:19:57 + | +LL | fn g<'a, T: 'static>(v: Box+'a>) -> Box { + | ______--_________________________________________________^ + | | | + | | lifetime `'a` defined here +LL | | box B(&*v) as Box //~ ERROR cannot infer +LL | | } + | |_^ return requires that `'a` must outlive `'static` + +error[E0597]: `*v` does not live long enough + --> $DIR/regions-close-object-into-object-2.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ borrowed value does not live long enough +LL | } + | - `*v` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.rs b/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.rs new file mode 100644 index 00000000000..6cef9956655 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +trait A { } +struct B<'a, T:'a>(&'a (A+'a)); + +trait X { } +impl<'a, T> X for B<'a, T> {} + +fn g<'a, T: 'static>(v: Box+'a>) -> Box { + box B(&*v) as Box //~ ERROR cannot infer +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.stderr new file mode 100644 index 00000000000..b2e44cd2c77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-2.stderr @@ -0,0 +1,24 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-close-object-into-object-2.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 19:6... + --> $DIR/regions-close-object-into-object-2.rs:19:6 + | +LL | fn g<'a, T: 'static>(v: Box+'a>) -> Box { + | ^^ +note: ...so that the type `(dyn A + 'a)` is not borrowed for too long + --> $DIR/regions-close-object-into-object-2.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ + = note: but, the lifetime must be valid for the static lifetime... + = note: ...so that the expression is assignable: + expected std::boxed::Box<(dyn X + 'static)> + found std::boxed::Box + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.nll.stderr new file mode 100644 index 00000000000..62504ab8d80 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.nll.stderr @@ -0,0 +1,13 @@ +error[E0597]: `*v` does not live long enough + --> $DIR/regions-close-object-into-object-3.rs:21:11 + | +LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough + | ^^^ borrowed value does not live long enough +LL | } + | - `*v` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.rs b/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.rs new file mode 100644 index 00000000000..3004245b15a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] +#![allow(warnings)] + +trait A { } +struct B<'a, T:'a>(&'a (A+'a)); + +trait X { } +impl<'a, T> X for B<'a, T> {} + +fn h<'a, T, U:'static>(v: Box+'static>) -> Box { + box B(&*v) as Box //~ ERROR `*v` does not live long enough +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.stderr new file mode 100644 index 00000000000..9e412e50da9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-3.stderr @@ -0,0 +1,13 @@ +error[E0597]: `*v` does not live long enough + --> $DIR/regions-close-object-into-object-3.rs:21:12 + | +LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough + | ^^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.nll.stderr new file mode 100644 index 00000000000..62146778f68 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.nll.stderr @@ -0,0 +1,71 @@ +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-4.rs:20:5 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-4.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-4.rs:20:9 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-4.rs:20:9 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-4.rs:20:5 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-close-object-into-object-4.rs:19:51 + | +LL | fn i<'a, T, U>(v: Box+'a>) -> Box { + | ______--___________________________________________^ + | | | + | | lifetime `'a` defined here +LL | | box B(&*v) as Box //~ ERROR cannot infer +LL | | } + | |_^ return requires that `'a` must outlive `'static` + +error[E0310]: the parameter type `U` may not live long enough + --> $DIR/regions-close-object-into-object-4.rs:20:5 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `U: 'static`... + +error[E0310]: the parameter type `U` may not live long enough + --> $DIR/regions-close-object-into-object-4.rs:20:9 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^^^^ + | + = help: consider adding an explicit lifetime bound `U: 'static`... + +error[E0597]: `*v` does not live long enough + --> $DIR/regions-close-object-into-object-4.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ borrowed value does not live long enough +LL | } + | - `*v` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 4 previous errors + +Some errors occurred: E0310, E0597. +For more information about an error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.rs b/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.rs new file mode 100644 index 00000000000..bc5b7b7cf78 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +trait A { } +struct B<'a, T:'a>(&'a (A+'a)); + +trait X { } +impl<'a, T> X for B<'a, T> {} + +fn i<'a, T, U>(v: Box+'a>) -> Box { + box B(&*v) as Box //~ ERROR cannot infer +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.stderr new file mode 100644 index 00000000000..15e53f1b54d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-4.stderr @@ -0,0 +1,24 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-close-object-into-object-4.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 19:6... + --> $DIR/regions-close-object-into-object-4.rs:19:6 + | +LL | fn i<'a, T, U>(v: Box+'a>) -> Box { + | ^^ +note: ...so that the type `(dyn A + 'a)` is not borrowed for too long + --> $DIR/regions-close-object-into-object-4.rs:20:11 + | +LL | box B(&*v) as Box //~ ERROR cannot infer + | ^^^ + = note: but, the lifetime must be valid for the static lifetime... + = note: ...so that the expression is assignable: + expected std::boxed::Box<(dyn X + 'static)> + found std::boxed::Box + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.nll.stderr new file mode 100644 index 00000000000..d7f9253d0b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.nll.stderr @@ -0,0 +1,61 @@ +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-5.rs:27:5 + | +LL | box B(&*v) as Box + | ^^^^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-5.rs:27:11 + | +LL | box B(&*v) as Box + | ^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | box B(&*v) as Box + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | box B(&*v) as Box + | ^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-object-into-object-5.rs:27:5 + | +LL | box B(&*v) as Box + | ^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:5 + | +LL | box B(&*v) as Box + | ^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | box B(&*v) as Box + | ^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error[E0597]: `*v` does not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:11 + | +LL | box B(&*v) as Box + | ^^^ borrowed value does not live long enough +... +LL | } + | - `*v` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 3 previous errors + +Some errors occurred: E0310, E0597. +For more information about an error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.rs b/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.rs new file mode 100644 index 00000000000..6cbe5234ce0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] +#![allow(warnings)] + +trait A +{ + fn get(&self) -> T { panic!() } +} + +struct B<'a, T:'a>(&'a (A+'a)); + +trait X { fn foo(&self) {} } + +impl<'a, T> X for B<'a, T> {} + +fn f<'a, T, U>(v: Box+'static>) -> Box { + // oh dear! + box B(&*v) as Box + //~^ ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough + //~| ERROR the parameter type `T` may not live long enough +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.stderr b/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.stderr new file mode 100644 index 00000000000..2c3cc603e04 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-object-into-object-5.stderr @@ -0,0 +1,93 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:5 + | +LL | fn f<'a, T, U>(v: Box+'static>) -> Box { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // oh dear! +LL | box B(&*v) as Box + | ^^^^^^^^^^ + | +note: ...so that the type `B<'_, T>` will meet its required lifetime bounds + --> $DIR/regions-close-object-into-object-5.rs:27:5 + | +LL | box B(&*v) as Box + | ^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:5 + | +LL | fn f<'a, T, U>(v: Box+'static>) -> Box { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // oh dear! +LL | box B(&*v) as Box + | ^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that it can be closed over into an object + --> $DIR/regions-close-object-into-object-5.rs:27:5 + | +LL | box B(&*v) as Box + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | fn f<'a, T, U>(v: Box+'static>) -> Box { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // oh dear! +LL | box B(&*v) as Box + | ^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | box B(&*v) as Box + | ^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | fn f<'a, T, U>(v: Box+'static>) -> Box { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // oh dear! +LL | box B(&*v) as Box + | ^^^^^^ + | +note: ...so that the reference type `&dyn A` does not outlive the data it points at + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | box B(&*v) as Box + | ^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | fn f<'a, T, U>(v: Box+'static>) -> Box { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // oh dear! +LL | box B(&*v) as Box + | ^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-close-object-into-object-5.rs:27:9 + | +LL | box B(&*v) as Box + | ^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:27:11 + | +LL | fn f<'a, T, U>(v: Box+'static>) -> Box { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // oh dear! +LL | box B(&*v) as Box + | ^^^ + | +note: ...so that the type `(dyn A + 'static)` is not borrowed for too long + --> $DIR/regions-close-object-into-object-5.rs:27:11 + | +LL | box B(&*v) as Box + | ^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.nll.stderr new file mode 100644 index 00000000000..ff74d46b011 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.nll.stderr @@ -0,0 +1,44 @@ +warning: not reporting region error due to nll + --> $DIR/regions-close-over-type-parameter-1.rs:20:5 + | +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-over-type-parameter-1.rs:20:5 + | +LL | box v as Box + | ^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-over-type-parameter-1.rs:30:5 + | +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-over-type-parameter-1.rs:30:5 + | +LL | box v as Box + | ^^^^^ + +error[E0310]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:20:5 + | +LL | box v as Box + | ^^^^^ + | + = help: consider adding an explicit lifetime bound `A: 'static`... + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:30:5 + | +LL | box v as Box + | ^^^^^ + | + = help: consider adding an explicit lifetime bound `A: 'b`... + +error: aborting due to 2 previous errors + +Some errors occurred: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.rs b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.rs new file mode 100644 index 00000000000..b70ec59420d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +// Test for what happens when a type parameter `A` is closed over into +// an object. This should yield errors unless `A` (and the object) +// both have suitable bounds. + +trait SomeTrait { fn get(&self) -> isize; } + +fn make_object1(v: A) -> Box { + box v as Box + //~^ ERROR the parameter type `A` may not live long enough + //~| ERROR the parameter type `A` may not live long enough +} + +fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box { + box v as Box +} + +fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { + box v as Box + //~^ ERROR the parameter type `A` may not live long enough + //~| ERROR the parameter type `A` may not live long enough +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.stderr b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.stderr new file mode 100644 index 00000000000..9158cf26838 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-1.stderr @@ -0,0 +1,60 @@ +error[E0310]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:20:5 + | +LL | fn make_object1(v: A) -> Box { + | -- help: consider adding an explicit lifetime bound `A: 'static`... +LL | box v as Box + | ^^^^^ + | +note: ...so that the type `A` will meet its required lifetime bounds + --> $DIR/regions-close-over-type-parameter-1.rs:20:5 + | +LL | box v as Box + | ^^^^^ + +error[E0310]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:20:5 + | +LL | fn make_object1(v: A) -> Box { + | -- help: consider adding an explicit lifetime bound `A: 'static`... +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that it can be closed over into an object + --> $DIR/regions-close-over-type-parameter-1.rs:20:5 + | +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:30:5 + | +LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { + | -- help: consider adding an explicit lifetime bound `A: 'b`... +LL | box v as Box + | ^^^^^ + | +note: ...so that the type `A` will meet its required lifetime bounds + --> $DIR/regions-close-over-type-parameter-1.rs:30:5 + | +LL | box v as Box + | ^^^^^ + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:30:5 + | +LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { + | -- help: consider adding an explicit lifetime bound `A: 'b`... +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that it can be closed over into an object + --> $DIR/regions-close-over-type-parameter-1.rs:30:5 + | +LL | box v as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.nll.stderr new file mode 100644 index 00000000000..9e0dd9da0e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/regions-close-over-type-parameter-multiple.rs:30:5 + | +LL | box v as Box //~ ERROR cannot infer an appropriate lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-multiple.rs:30:5 + | +LL | box v as Box //~ ERROR cannot infer an appropriate lifetime + | ^^^^^ + | + = help: consider adding an explicit lifetime bound `A: 'c`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.rs b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.rs new file mode 100644 index 00000000000..ad6c5a31bbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +// Various tests where we over type parameters with multiple lifetime +// bounds. + +trait SomeTrait { fn get(&self) -> isize; } + +fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { + // A outlives 'a AND 'b... + box v as Box // ...hence this type is safe. +} + +fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { + // A outlives 'a AND 'b... + box v as Box // ...hence this type is safe. +} + +fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { + // A outlives 'a AND 'b...but not 'c. + box v as Box //~ ERROR cannot infer an appropriate lifetime +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.stderr b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.stderr new file mode 100644 index 00000000000..f85041e8ced --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-over-type-parameter-multiple.stderr @@ -0,0 +1,28 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-close-over-type-parameter-multiple.rs:30:5 + | +LL | box v as Box //~ ERROR cannot infer an appropriate lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 28:20... + --> $DIR/regions-close-over-type-parameter-multiple.rs:28:20 + | +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { + | ^^ +note: ...so that the declared lifetime parameter bounds are satisfied + --> $DIR/regions-close-over-type-parameter-multiple.rs:30:5 + | +LL | box v as Box //~ ERROR cannot infer an appropriate lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: but, the lifetime must be valid for the lifetime 'c as defined on the function body at 28:26... + --> $DIR/regions-close-over-type-parameter-multiple.rs:28:26 + | +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { + | ^^ + = note: ...so that the expression is assignable: + expected std::boxed::Box<(dyn SomeTrait + 'c)> + found std::boxed::Box + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-close-param-into-object.nll.stderr b/src/test/ui/compile-fail-migration/regions-close-param-into-object.nll.stderr new file mode 100644 index 00000000000..260a4067e10 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-param-into-object.nll.stderr @@ -0,0 +1,60 @@ +warning: not reporting region error due to nll + --> $DIR/regions-close-param-into-object.rs:16:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-param-into-object.rs:22:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-param-into-object.rs:28:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-close-param-into-object.rs:34:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:16:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:22:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:28:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'a`... + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:34:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'a`... + +error: aborting due to 4 previous errors + +Some errors occurred: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-close-param-into-object.rs b/src/test/ui/compile-fail-migration/regions-close-param-into-object.rs new file mode 100644 index 00000000000..c9063405bd7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-param-into-object.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait X { fn foo(&self) {} } + +fn p1(v: T) -> Box + where T : X +{ + Box::new(v) //~ ERROR parameter type `T` may not live long enough +} + +fn p2(v: Box) -> Box + where Box : X +{ + Box::new(v) //~ ERROR parameter type `T` may not live long enough +} + +fn p3<'a,T>(v: T) -> Box + where T : X +{ + Box::new(v) //~ ERROR parameter type `T` may not live long enough +} + +fn p4<'a,T>(v: Box) -> Box + where Box : X +{ + Box::new(v) //~ ERROR parameter type `T` may not live long enough +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-close-param-into-object.stderr b/src/test/ui/compile-fail-migration/regions-close-param-into-object.stderr new file mode 100644 index 00000000000..72ed7ac9448 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-close-param-into-object.stderr @@ -0,0 +1,64 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:16:5 + | +LL | fn p1(v: T) -> Box + | - help: consider adding an explicit lifetime bound `T: 'static`... +... +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-close-param-into-object.rs:16:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:22:5 + | +LL | fn p2(v: Box) -> Box + | - help: consider adding an explicit lifetime bound `T: 'static`... +... +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | +note: ...so that the type `std::boxed::Box` will meet its required lifetime bounds + --> $DIR/regions-close-param-into-object.rs:22:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:28:5 + | +LL | fn p3<'a,T>(v: T) -> Box + | - help: consider adding an explicit lifetime bound `T: 'a`... +... +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-close-param-into-object.rs:28:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:34:5 + | +LL | fn p4<'a,T>(v: Box) -> Box + | - help: consider adding an explicit lifetime bound `T: 'a`... +... +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + | +note: ...so that the type `std::boxed::Box` will meet its required lifetime bounds + --> $DIR/regions-close-param-into-object.rs:34:5 + | +LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough + | ^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums.nll.stderr b/src/test/ui/compile-fail-migration/regions-creating-enums.nll.stderr new file mode 100644 index 00000000000..58dff9c6c37 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums.nll.stderr @@ -0,0 +1,31 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-creating-enums.rs:33:17 + | +LL | return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13... + --> $DIR/regions-creating-enums.rs:30:13 + | +LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { + | ^^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-creating-enums.rs:38:17 + | +LL | return &ast::add(m_x, m_y); //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13... + --> $DIR/regions-creating-enums.rs:30:13 + | +LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums.rs b/src/test/ui/compile-fail-migration/regions-creating-enums.rs new file mode 100644 index 00000000000..ad2dc28afef --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums.rs @@ -0,0 +1,43 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum ast<'a> { + num(usize), + add(&'a ast<'a>, &'a ast<'a>) +} + +fn build() { + let x = ast::num(3); + let y = ast::num(4); + let z = ast::add(&x, &y); + compute(&z); +} + +fn compute(x: &ast) -> usize { + match *x { + ast::num(x) => { x } + ast::add(x, y) => { compute(x) + compute(y) } + } +} + +fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { + match *x { + ast::num(x) => { + return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough + } + ast::add(x, y) => { + let m_x = map_nums(x, f); + let m_y = map_nums(y, f); + return &ast::add(m_x, m_y); //~ ERROR borrowed value does not live long enough + } + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums.stderr b/src/test/ui/compile-fail-migration/regions-creating-enums.stderr new file mode 100644 index 00000000000..7b0847739d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums.stderr @@ -0,0 +1,33 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-creating-enums.rs:33:17 + | +LL | return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13... + --> $DIR/regions-creating-enums.rs:30:13 + | +LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { + | ^^ + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-creating-enums.rs:38:17 + | +LL | return &ast::add(m_x, m_y); //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13... + --> $DIR/regions-creating-enums.rs:30:13 + | +LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { + | ^^ + = note: consider using a `let` binding to increase its lifetime + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums3.nll.stderr b/src/test/ui/compile-fail-migration/regions-creating-enums3.nll.stderr new file mode 100644 index 00000000000..9b327100667 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums3.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-creating-enums3.rs:17:5 + | +LL | ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623] + | ^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-creating-enums3.rs:17:14 + | +LL | fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623] + | ^ requires that `'b` must outlive `'a` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums3.rs b/src/test/ui/compile-fail-migration/regions-creating-enums3.rs new file mode 100644 index 00000000000..dcc579d26c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums3.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum ast<'a> { + num(usize), + add(&'a ast<'a>, &'a ast<'a>) +} + +fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> { + ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623] +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums3.stderr b/src/test/ui/compile-fail-migration/regions-creating-enums3.stderr new file mode 100644 index 00000000000..b2cca9a3c62 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums3.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-creating-enums3.rs:17:5 + | +LL | fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> { + | ----------- ------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623] + | ^^^^^^^^^^^^^^ ...but data from `y` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums4.nll.stderr b/src/test/ui/compile-fail-migration/regions-creating-enums4.nll.stderr new file mode 100644 index 00000000000..6a3554b41a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums4.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-creating-enums4.rs:17:5 + | +LL | ast::add(x, y) //~ ERROR cannot infer + | ^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-creating-enums4.rs:17:14 + | +LL | fn mk_add_bad2<'a,'b>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'b> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | ast::add(x, y) //~ ERROR cannot infer + | ^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums4.rs b/src/test/ui/compile-fail-migration/regions-creating-enums4.rs new file mode 100644 index 00000000000..5dc9b370f32 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums4.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum ast<'a> { + num(usize), + add(&'a ast<'a>, &'a ast<'a>) +} + +fn mk_add_bad2<'a,'b>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'b> { + ast::add(x, y) //~ ERROR cannot infer +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-creating-enums4.stderr b/src/test/ui/compile-fail-migration/regions-creating-enums4.stderr new file mode 100644 index 00000000000..729dc2f107a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-creating-enums4.stderr @@ -0,0 +1,26 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/regions-creating-enums4.rs:17:5 + | +LL | ast::add(x, y) //~ ERROR cannot infer + | ^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 16:16... + --> $DIR/regions-creating-enums4.rs:16:16 + | +LL | fn mk_add_bad2<'a,'b>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'b> { + | ^^ + = note: ...so that the expression is assignable: + expected &ast<'_> + found &ast<'a> +note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 16:19... + --> $DIR/regions-creating-enums4.rs:16:19 + | +LL | fn mk_add_bad2<'a,'b>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'b> { + | ^^ + = note: ...so that the expression is assignable: + expected ast<'b> + found ast<'_> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-early-bound-error-method.nll.stderr b/src/test/ui/compile-fail-migration/regions-early-bound-error-method.nll.stderr new file mode 100644 index 00000000000..0319d63d596 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-early-bound-error-method.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-early-bound-error-method.rs:30:9 + | +LL | g2.get() + | ^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-early-bound-error-method.rs:30:9 + | +LL | impl<'a> Box<'a> { + | -- lifetime `'a` defined here +LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { + | -- lifetime `'b` defined here +LL | g2.get() + | ^^^^^^^^ argument requires that `'b` must outlive `'a` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-early-bound-error-method.rs b/src/test/ui/compile-fail-migration/regions-early-bound-error-method.rs new file mode 100644 index 00000000000..eaf9a750570 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-early-bound-error-method.rs @@ -0,0 +1,36 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that you can use a fn lifetime parameter as part of +// the value for a type parameter in a bound. + +trait GetRef<'a> { + fn get(&self) -> &'a isize; +} + +struct Box<'a> { + t: &'a isize +} + +impl<'a> GetRef<'a> for Box<'a> { + fn get(&self) -> &'a isize { + self.t + } +} + +impl<'a> Box<'a> { + fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { + g2.get() + //~^ ERROR E0312 + } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-early-bound-error-method.stderr b/src/test/ui/compile-fail-migration/regions-early-bound-error-method.stderr new file mode 100644 index 00000000000..6c542ef5ddf --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-early-bound-error-method.stderr @@ -0,0 +1,20 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-early-bound-error-method.rs:30:9 + | +LL | g2.get() + | ^^^^^^^^ + | +note: ...the reference is valid for the lifetime 'a as defined on the impl at 28:6... + --> $DIR/regions-early-bound-error-method.rs:28:6 + | +LL | impl<'a> Box<'a> { + | ^^ +note: ...but the borrowed content is only valid for the lifetime 'b as defined on the method body at 29:11 + --> $DIR/regions-early-bound-error-method.rs:29:11 + | +LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/regions-early-bound-error.nll.stderr b/src/test/ui/compile-fail-migration/regions-early-bound-error.nll.stderr new file mode 100644 index 00000000000..b19de2201f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-early-bound-error.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-early-bound-error.rs:29:5 + | +LL | g1.get() + | ^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-early-bound-error.rs:29:5 + | +LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | g1.get() + | ^^^^^^^^ argument requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-early-bound-error.rs b/src/test/ui/compile-fail-migration/regions-early-bound-error.rs new file mode 100644 index 00000000000..90a33950047 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-early-bound-error.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that you can use a fn lifetime parameter as part of +// the value for a type parameter in a bound. + +trait GetRef<'a, T> { + fn get(&self) -> &'a T; +} + +struct Box<'a, T:'a> { + t: &'a T +} + +impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { + fn get(&self) -> &'a T { + self.t + } +} + +fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { + g1.get() + //~^ ERROR E0312 +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-early-bound-error.stderr b/src/test/ui/compile-fail-migration/regions-early-bound-error.stderr new file mode 100644 index 00000000000..579a7c91e43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-early-bound-error.stderr @@ -0,0 +1,20 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-early-bound-error.rs:29:5 + | +LL | g1.get() + | ^^^^^^^^ + | +note: ...the reference is valid for the lifetime 'b as defined on the function body at 28:11... + --> $DIR/regions-early-bound-error.rs:28:11 + | +LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { + | ^^ +note: ...but the borrowed content is only valid for the lifetime 'a as defined on the function body at 28:8 + --> $DIR/regions-early-bound-error.rs:28:8 + | +LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/regions-enum-not-wf.rs b/src/test/ui/compile-fail-migration/regions-enum-not-wf.rs new file mode 100644 index 00000000000..e21f92bc9b8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-enum-not-wf.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various examples of structs whose fields are not well-formed. + +#![allow(dead_code)] + +enum Ref1<'a, T> { + Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough +} + +enum Ref2<'a, T> { + Ref2Variant1, + Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough +} + +enum RefOk<'a, T:'a> { + RefOkVariant1(&'a T) +} + +enum RefIndirect<'a, T> { + RefIndirectVariant1(isize, RefOk<'a,T>) + //~^ ERROR the parameter type `T` may not live long enough +} + +enum RefDouble<'a, 'b, T> { + RefDoubleVariant1(&'a &'b T) + //~^ ERROR reference has a longer lifetime than the data +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-enum-not-wf.stderr b/src/test/ui/compile-fail-migration/regions-enum-not-wf.stderr new file mode 100644 index 00000000000..381a8aada5a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-enum-not-wf.stderr @@ -0,0 +1,64 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:16:18 + | +LL | enum Ref1<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-enum-not-wf.rs:16:18 + | +LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:21:25 + | +LL | enum Ref2<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | Ref2Variant1, +LL | Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-enum-not-wf.rs:21:25 + | +LL | Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:29:32 + | +LL | enum RefIndirect<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | RefIndirectVariant1(isize, RefOk<'a,T>) + | ^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:29:32 + | +LL | RefIndirectVariant1(isize, RefOk<'a,T>) + | ^^^^^^^^^^^ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-enum-not-wf.rs:34:23 + | +LL | RefDoubleVariant1(&'a &'b T) + | ^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 33:16 + --> $DIR/regions-enum-not-wf.rs:33:16 + | +LL | enum RefDouble<'a, 'b, T> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 33:20 + --> $DIR/regions-enum-not-wf.rs:33:20 + | +LL | enum RefDouble<'a, 'b, T> { + | ^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-escape-method.nll.stderr b/src/test/ui/compile-fail-migration/regions-escape-method.nll.stderr new file mode 100644 index 00000000000..d0811206e4a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-escape-method.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-escape-method.rs:25:13 + | +LL | s.f(|p| p) //~ ERROR cannot infer + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-escape-method.rs:25:13 + | +LL | s.f(|p| p) //~ ERROR cannot infer + | ----^ + | || | + | || return requires that `'1` must outlive `'2` + | |has type `&'1 i32` + | lifetime `'2` appears in return type + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-escape-method.rs b/src/test/ui/compile-fail-migration/regions-escape-method.rs new file mode 100644 index 00000000000..e3771cfebba --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-escape-method.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a method call where the parameter `B` would (illegally) be +// inferred to a region bound in the method argument. If this program +// were accepted, then the closure passed to `s.f` could escape its +// argument. + +struct S; + +impl S { + fn f(&self, _: F) where F: FnOnce(&i32) -> B { + } +} + +fn main() { + let s = S; + s.f(|p| p) //~ ERROR cannot infer +} diff --git a/src/test/ui/compile-fail-migration/regions-escape-method.stderr b/src/test/ui/compile-fail-migration/regions-escape-method.stderr new file mode 100644 index 00000000000..fb0bf845f3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-escape-method.stderr @@ -0,0 +1,28 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-escape-method.rs:25:13 + | +LL | s.f(|p| p) //~ ERROR cannot infer + | ^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 25:9... + --> $DIR/regions-escape-method.rs:25:9 + | +LL | s.f(|p| p) //~ ERROR cannot infer + | ^^^^^ + = note: ...so that the expression is assignable: + expected &i32 + found &i32 +note: but, the lifetime must be valid for the method call at 25:5... + --> $DIR/regions-escape-method.rs:25:5 + | +LL | s.f(|p| p) //~ ERROR cannot infer + | ^^^^^^^^^^ +note: ...so that a type/lifetime parameter is in scope here + --> $DIR/regions-escape-method.rs:25:5 + | +LL | s.f(|p| p) //~ ERROR cannot infer + | ^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.nll.stderr b/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.nll.stderr new file mode 100644 index 00000000000..7ff49fd413c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-escape-via-trait-or-not.rs:28:14 + | +LL | with(|o| o) //~ ERROR cannot infer + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-escape-via-trait-or-not.rs:28:14 + | +LL | with(|o| o) //~ ERROR cannot infer + | ----^ + | || | + | || return requires that `'1` must outlive `'2` + | |has type `&'1 isize` + | lifetime `'2` appears in return type + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.rs b/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.rs new file mode 100644 index 00000000000..a4363b00e1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.rs @@ -0,0 +1,32 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +trait Deref { + fn get(self) -> isize; +} + +impl<'a> Deref for &'a isize { + fn get(self) -> isize { + *self + } +} + +fn with(f: F) -> isize where F: FnOnce(&isize) -> R { + f(&3).get() +} + +fn return_it() -> isize { + with(|o| o) //~ ERROR cannot infer +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.stderr b/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.stderr new file mode 100644 index 00000000000..60bd14ba4d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-escape-via-trait-or-not.stderr @@ -0,0 +1,28 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-escape-via-trait-or-not.rs:28:14 + | +LL | with(|o| o) //~ ERROR cannot infer + | ^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 28:10... + --> $DIR/regions-escape-via-trait-or-not.rs:28:10 + | +LL | with(|o| o) //~ ERROR cannot infer + | ^^^^^ + = note: ...so that the expression is assignable: + expected &isize + found &isize +note: but, the lifetime must be valid for the expression at 28:5... + --> $DIR/regions-escape-via-trait-or-not.rs:28:5 + | +LL | with(|o| o) //~ ERROR cannot infer + | ^^^^ +note: ...so type `fn([closure@$DIR/regions-escape-via-trait-or-not.rs:28:10: 28:15]) -> isize {with::<&isize, [closure@$DIR/regions-escape-via-trait-or-not.rs:28:10: 28:15]>}` of expression is valid during the expression + --> $DIR/regions-escape-via-trait-or-not.rs:28:5 + | +LL | with(|o| o) //~ ERROR cannot infer + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.rs b/src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.rs new file mode 100644 index 00000000000..6be65a5e359 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.rs @@ -0,0 +1,67 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// In this fn, the type `F` is a function that takes a reference to a +// struct and returns another reference with the same lifetime. +// +// Meanwhile, the bare fn `foo` takes a reference to a struct with +// *ANY* lifetime and returns a reference with the 'static lifetime. +// This can safely be considered to be an instance of `F` because all +// lifetimes are sublifetimes of 'static. + +#![allow(dead_code)] +#![allow(unused_variables)] + +struct S; + +// Given 'cx, return 'cx +type F = for<'cx> fn(&'cx S) -> &'cx S; +fn want_F(f: F) { } + +// Given anything, return 'static +type G = for<'cx> fn(&'cx S) -> &'static S; +fn want_G(f: G) { } + +// Should meet both. +fn foo(x: &S) -> &'static S { + panic!() +} + +// Should meet both. +fn bar<'a,'b>(x: &'a S) -> &'b S { + panic!() +} + +// Meets F, but not G. +fn baz(x: &S) -> &S { + panic!() +} + +fn supply_F() { + want_F(foo); + + // FIXME(#33684) -- this should be a subtype, but current alg. rejects it incorrectly + want_F(bar); //~ ERROR E0308 + + want_F(baz); +} + +fn supply_G() { + want_G(foo); + want_G(bar); + want_G(baz); + //~^ ERROR mismatched types + //~| expected type `for<'cx> fn(&'cx S) -> &'static S` + //~| found type `for<'r> fn(&'r S) -> &'r S {baz}` + //~| expected concrete lifetime, found bound lifetime parameter 'cx +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.stderr b/src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.stderr new file mode 100644 index 00000000000..6d487666c6f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-fn-subtyping-return-static.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/regions-fn-subtyping-return-static.rs:51:12 + | +LL | want_F(bar); //~ ERROR E0308 + | ^^^ expected concrete lifetime, found bound lifetime parameter 'cx + | + = note: expected type `for<'cx> fn(&'cx S) -> &'cx S` + found type `for<'a> fn(&'a S) -> &S {bar::<'_>}` + +error[E0308]: mismatched types + --> $DIR/regions-fn-subtyping-return-static.rs:59:12 + | +LL | want_G(baz); + | ^^^ expected concrete lifetime, found bound lifetime parameter 'cx + | + = note: expected type `for<'cx> fn(&'cx S) -> &'static S` + found type `for<'r> fn(&'r S) -> &'r S {baz}` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.rs b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.rs new file mode 100644 index 00000000000..bd31d1a5a90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that callees correctly infer an ordering between free regions +// that appear in their parameter list. See also +// regions-free-region-ordering-caller.rs + +fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { + //~^ ERROR reference has a longer lifetime than the data it references + // Do not infer ordering from closure argument types. + let z: Option<&'a &'b usize> = None; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.stderr new file mode 100644 index 00000000000..70970a9cf3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee-4.stderr @@ -0,0 +1,24 @@ +error[E0491]: in type `&'a &'b usize`, reference has a longer lifetime than the data it references + --> $DIR/regions-free-region-ordering-callee-4.rs:15:1 + | +LL | / fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { +LL | | //~^ ERROR reference has a longer lifetime than the data it references +LL | | // Do not infer ordering from closure argument types. +LL | | let z: Option<&'a &'b usize> = None; +LL | | } + | |_^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 15:14 + --> $DIR/regions-free-region-ordering-callee-4.rs:15:14 + | +LL | fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 15:18 + --> $DIR/regions-free-region-ordering-callee-4.rs:15:18 + | +LL | fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.nll.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.nll.stderr new file mode 100644 index 00000000000..25f2e1a5657 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.nll.stderr @@ -0,0 +1,36 @@ +warning: not reporting region error due to nll + --> $DIR/regions-free-region-ordering-callee.rs:23:5 + | +LL | &*y //~ ERROR 23:5: 23:8: lifetime mismatch [E0623] + | ^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-free-region-ordering-callee.rs:28:24 + | +LL | let z: &'b usize = &*x; + | ^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-free-region-ordering-callee.rs:23:5 + | +LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | // However, it is not safe to assume that 'b <= 'a +LL | &*y //~ ERROR 23:5: 23:8: lifetime mismatch [E0623] + | ^^^ requires that `'a` must outlive `'b` + +error: unsatisfied lifetime constraints + --> $DIR/regions-free-region-ordering-callee.rs:28:24 + | +LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | // Do not infer an ordering from the return value. +LL | let z: &'b usize = &*x; + | ^^^ requires that `'a` must outlive `'b` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.rs b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.rs new file mode 100644 index 00000000000..073a4f79b05 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.rs @@ -0,0 +1,39 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that callees correctly infer an ordering between free regions +// that appear in their parameter list. See also +// regions-free-region-ordering-caller.rs + +fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize { + // It is safe to assume that 'a <= 'b due to the type of x + let y: &'b usize = &**x; + return y; +} + +fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { + // However, it is not safe to assume that 'b <= 'a + &*y //~ ERROR 23:5: 23:8: lifetime mismatch [E0623] +} + +fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { + // Do not infer an ordering from the return value. + let z: &'b usize = &*x; + //~^ ERROR 28:24: 28:27: lifetime mismatch [E0623] + panic!(); +} + +// see regions-free-region-ordering-callee-4.rs + +fn ordering5<'a, 'b>(a: &'a usize, b: &'b usize, x: Option<&'a &'b usize>) { + let z: Option<&'a &'b usize> = None; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.stderr new file mode 100644 index 00000000000..13d94f91c6d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-callee.stderr @@ -0,0 +1,25 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-free-region-ordering-callee.rs:23:5 + | +LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { + | ------------- --------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | // However, it is not safe to assume that 'b <= 'a +LL | &*y //~ ERROR 23:5: 23:8: lifetime mismatch [E0623] + | ^^^ ...but data from `x` is returned here + +error[E0623]: lifetime mismatch + --> $DIR/regions-free-region-ordering-callee.rs:28:24 + | +LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { + | --------- ------------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | // Do not infer an ordering from the return value. +LL | let z: &'b usize = &*x; + | ^^^ ...but data from `x` is returned here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.rs b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.rs new file mode 100644 index 00000000000..66b16744cc7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test various ways to construct a pointer with a longer lifetime +// than the thing it points at and ensure that they result in +// errors. See also regions-free-region-ordering-callee.rs + +struct Paramd<'a> { x: &'a usize } + +fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { + let z: Option<&'b &'a usize> = None;//~ ERROR E0623 +} + +fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { + let y: Paramd<'a> = Paramd { x: a }; + let z: Option<&'b Paramd<'a>> = None;//~ ERROR E0623 +} + +fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { + let z: Option<&'a &'b usize> = None;//~ ERROR E0623 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.stderr new file mode 100644 index 00000000000..a3645995b5e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller.stderr @@ -0,0 +1,32 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-free-region-ordering-caller.rs:18:12 + | +LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { + | --------- --------- + | | + | these two types are declared with different lifetimes... +LL | let z: Option<&'b &'a usize> = None;//~ ERROR E0623 + | ^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here + +error[E0623]: lifetime mismatch + --> $DIR/regions-free-region-ordering-caller.rs:23:12 + | +LL | fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { + | --------- --------- + | | + | these two types are declared with different lifetimes... +LL | let y: Paramd<'a> = Paramd { x: a }; +LL | let z: Option<&'b Paramd<'a>> = None;//~ ERROR E0623 + | ^^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here + +error[E0623]: lifetime mismatch + --> $DIR/regions-free-region-ordering-caller.rs:27:12 + | +LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { + | --------- --------- these two types are declared with different lifetimes... +LL | let z: Option<&'a &'b usize> = None;//~ ERROR E0623 + | ^^^^^^^^^^^^^^^^^^^^^ ...but data from `b` flows into `a` here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.nll.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.nll.stderr new file mode 100644 index 00000000000..acf7a033ade --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.nll.stderr @@ -0,0 +1,18 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-free-region-ordering-caller1.rs:19:27 + | +LL | let z: &'a & usize = &(&y); + | ^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:10... + --> $DIR/regions-free-region-ordering-caller1.rs:15:10 + | +LL | fn call1<'a>(x: &'a usize) { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.rs b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.rs new file mode 100644 index 00000000000..b29518ccdab --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test various ways to construct a pointer with a longer lifetime +// than the thing it points at and ensure that they result in +// errors. See also regions-free-region-ordering-callee.rs + +fn call1<'a>(x: &'a usize) { + // Test that creating a pointer like + // &'a &'z usize requires that 'a <= 'z: + let y: usize = 3; + let z: &'a & usize = &(&y); + //~^ ERROR borrowed value does not live long enough + //~^^ ERROR `y` does not live long enough +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.stderr new file mode 100644 index 00000000000..c0dff6ec384 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-caller1.stderr @@ -0,0 +1,33 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-free-region-ordering-caller1.rs:19:27 + | +LL | let z: &'a & usize = &(&y); + | ^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:10... + --> $DIR/regions-free-region-ordering-caller1.rs:15:10 + | +LL | fn call1<'a>(x: &'a usize) { + | ^^ + +error[E0597]: `y` does not live long enough + --> $DIR/regions-free-region-ordering-caller1.rs:19:29 + | +LL | let z: &'a & usize = &(&y); + | ^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:10... + --> $DIR/regions-free-region-ordering-caller1.rs:15:10 + | +LL | fn call1<'a>(x: &'a usize) { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.nll.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.nll.stderr new file mode 100644 index 00000000000..34fcd91b319 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.nll.stderr @@ -0,0 +1,21 @@ +warning: not reporting region error due to nll + --> $DIR/regions-free-region-ordering-incorrect.rs:27:15 + | +LL | None => &self.val //~ ERROR cannot infer + | ^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-free-region-ordering-incorrect.rs:25:5 + | +LL | impl<'b, T> Node<'b, T> { + | -- lifetime `'b` defined here +LL | fn get<'a>(&'a self) -> &'b T { + | -- lifetime `'a` defined here +LL | / match self.next { +LL | | Some(ref next) => next.get(), +LL | | None => &self.val //~ ERROR cannot infer +LL | | } + | |_____^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.rs b/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.rs new file mode 100644 index 00000000000..9cb61c24922 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.rs @@ -0,0 +1,32 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that free regions ordering only goes one way. That is, +// we have `&'a Node<'b, T>`, which implies that `'a <= 'b`, +// but not `'b <= 'a`. Hence returning `&self.val` (which has lifetime +// `'a`) where `'b` is expected yields an error. +// +// This test began its life as a test for issue #4325. + +struct Node<'b, T:'b> { + val: T, + next: Option<&'b Node<'b, T>> +} + +impl<'b, T> Node<'b, T> { + fn get<'a>(&'a self) -> &'b T { + match self.next { + Some(ref next) => next.get(), + None => &self.val //~ ERROR cannot infer + } + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.stderr b/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.stderr new file mode 100644 index 00000000000..3dce04e2452 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-free-region-ordering-incorrect.stderr @@ -0,0 +1,33 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-free-region-ordering-incorrect.rs:27:15 + | +LL | None => &self.val //~ ERROR cannot infer + | ^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the method body at 24:10... + --> $DIR/regions-free-region-ordering-incorrect.rs:24:10 + | +LL | fn get<'a>(&'a self) -> &'b T { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-free-region-ordering-incorrect.rs:27:15 + | +LL | None => &self.val //~ ERROR cannot infer + | ^^^^^^^^^ +note: but, the lifetime must be valid for the lifetime 'b as defined on the impl at 23:6... + --> $DIR/regions-free-region-ordering-incorrect.rs:23:6 + | +LL | impl<'b, T> Node<'b, T> { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-free-region-ordering-incorrect.rs:25:5 + | +LL | / match self.next { +LL | | Some(ref next) => next.get(), +LL | | None => &self.val //~ ERROR cannot infer +LL | | } + | |_____^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-glb-free-free.nll.stderr b/src/test/ui/compile-fail-migration/regions-glb-free-free.nll.stderr new file mode 100644 index 00000000000..93e8bd75bdb --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-glb-free-free.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-glb-free-free.rs:25:13 + | +LL | Flag { //~ ERROR 25:13: 30:14: explicit lifetime required in the type of `s` [E0621] + | ^^^^ + +error[E0621]: explicit lifetime required in the type of `s` + --> $DIR/regions-glb-free-free.rs:26:23 + | +LL | pub fn set_desc(self, s: &str) -> Flag<'a> { + | ---- help: add explicit lifetime `'a` to the type of `s`: `&'a str` +LL | Flag { //~ ERROR 25:13: 30:14: explicit lifetime required in the type of `s` [E0621] +LL | name: self.name, + | ^^^^^^^^^ lifetime `'a` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-glb-free-free.rs b/src/test/ui/compile-fail-migration/regions-glb-free-free.rs new file mode 100644 index 00000000000..843c5f512f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-glb-free-free.rs @@ -0,0 +1,39 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod argparse { + pub struct Flag<'a> { + name: &'a str, + pub desc: &'a str, + max_count: usize, + value: usize + } + + pub fn flag<'r>(name: &'r str, desc: &'r str) -> Flag<'r> { + Flag { name: name, desc: desc, max_count: 1, value: 0 } + } + + impl<'a> Flag<'a> { + pub fn set_desc(self, s: &str) -> Flag<'a> { + Flag { //~ ERROR 25:13: 30:14: explicit lifetime required in the type of `s` [E0621] + name: self.name, + desc: s, + max_count: self.max_count, + value: self.value + } + } + } +} + +fn main () { + let f : argparse::Flag = argparse::flag("flag", "My flag"); + let updated_flag = f.set_desc("My new flag"); + assert_eq!(updated_flag.desc, "My new flag"); +} diff --git a/src/test/ui/compile-fail-migration/regions-glb-free-free.stderr b/src/test/ui/compile-fail-migration/regions-glb-free-free.stderr new file mode 100644 index 00000000000..48c95a88654 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-glb-free-free.stderr @@ -0,0 +1,16 @@ +error[E0621]: explicit lifetime required in the type of `s` + --> $DIR/regions-glb-free-free.rs:25:13 + | +LL | pub fn set_desc(self, s: &str) -> Flag<'a> { + | ---- help: add explicit lifetime `'a` to the type of `s`: `&'a str` +LL | / Flag { //~ ERROR 25:13: 30:14: explicit lifetime required in the type of `s` [E0621] +LL | | name: self.name, +LL | | desc: s, +LL | | max_count: self.max_count, +LL | | value: self.value +LL | | } + | |_____________^ lifetime `'a` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.rs b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.rs new file mode 100644 index 00000000000..65594ab8f2e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.rs @@ -0,0 +1,40 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Illustrates the "projection gap": in this test, even though we know +// that `T::Foo: 'x`, that does not tell us that `T: 'x`, because +// there might be other ways for the caller of `func` to show that +// `T::Foo: 'x` holds (e.g., where-clause). + +trait Trait1<'x> { + type Foo; +} + +// calling this fn should trigger a check that the type argument +// supplied is well-formed. +fn wf() { } + +fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) +{ + wf::<&'x T>(); + //~^ ERROR the parameter type `T` may not live long enough +} + +fn caller2<'x, T:Trait1<'x>>(t: &'x T) +{ + wf::<&'x T::Foo>(); // OK +} + +fn caller3<'x, T:Trait1<'x>>(t: &'x T::Foo) +{ + wf::<&'x T::Foo>(); // OK +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.stderr b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.stderr new file mode 100644 index 00000000000..41ae515bb9a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-1.stderr @@ -0,0 +1,18 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-implied-bounds-projection-gap-1.rs:26:10 + | +LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) + | -- help: consider adding an explicit lifetime bound `T: 'x`... +LL | { +LL | wf::<&'x T>(); + | ^^^^^ + | +note: ...so that the reference type `&'x T` does not outlive the data it points at + --> $DIR/regions-implied-bounds-projection-gap-1.rs:26:10 + | +LL | wf::<&'x T>(); + | ^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.rs b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.rs new file mode 100644 index 00000000000..b3037a1e187 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Along with the other tests in this series, illustrates the +// "projection gap": in this test, we know that `T: 'x`, and that is +// enough to conclude that `T::Foo: 'x`. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +trait Trait1<'x> { + type Foo; +} + +// calling this fn should trigger a check that the type argument +// supplied is well-formed. +fn wf() { } + +fn func<'x, T:Trait1<'x>>(t: &'x T) +{ + wf::<&'x T::Foo>(); +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.stderr b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.stderr new file mode 100644 index 00000000000..7a38797e469 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-2.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/regions-implied-bounds-projection-gap-2.rs:33:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.rs b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.rs new file mode 100644 index 00000000000..a2e6de21376 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Along with the other tests in this series, illustrates the +// "projection gap": in this test, we know that `T::Foo: 'x`, and that +// is (naturally) enough to conclude that `T::Foo: 'x`. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +trait Trait1<'x> { + type Foo; +} + +// calling this fn should trigger a check that the type argument +// supplied is well-formed. +fn wf() { } + +fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) +{ + wf::<&'x T::Foo>(); +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.stderr b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.stderr new file mode 100644 index 00000000000..1a12697a474 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-3.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/regions-implied-bounds-projection-gap-3.rs:33:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.rs b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.rs new file mode 100644 index 00000000000..b8582f8c26b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Along with the other tests in this series, illustrates the +// "projection gap": in this test, we know that `T: 'x`, and that +// is (naturally) enough to conclude that `T: 'x`. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +trait Trait1<'x> { + type Foo; +} + +// calling this fn should trigger a check that the type argument +// supplied is well-formed. +fn wf() { } + +fn func<'x, T:Trait1<'x>>(t: &'x T) +{ + wf::<&'x T>(); +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.stderr b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.stderr new file mode 100644 index 00000000000..85b1702e2a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-4.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/regions-implied-bounds-projection-gap-4.rs:33:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.rs b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.rs new file mode 100644 index 00000000000..fd186d16559 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.rs @@ -0,0 +1,36 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The "projection gap" is particularly "fun" around higher-ranked +// projections. This is because the current code is hard-coded to say +// that a projection that contains escaping regions, like `>::Foo` where `'z` is bound, can only be found to +// outlive a region if all components that appear free (`'y`, where) +// outlive that region. However, we DON'T add those components to the +// implied bounds set, but rather we treat projections with escaping +// regions as opaque entities, just like projections without escaping +// regions. + +trait Trait1 { } + +trait Trait2<'a, 'b> { + type Foo; +} + +// As a side-effect of the conservative process above, the type of +// this argument `t` is not automatically considered well-formed, +// since for it to be WF, we would need to know that `'y: 'x`, but we +// do not infer that. +fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) + //~^ ERROR reference has a longer lifetime than the data it references +{ +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.stderr b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.stderr new file mode 100644 index 00000000000..172a3cdeade --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-implied-bounds-projection-gap-hr-1.stderr @@ -0,0 +1,23 @@ +error[E0491]: in type `&'x (dyn for<'z> Trait1<>::Foo> + 'x)`, reference has a longer lifetime than the data it references + --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:31:1 + | +LL | / fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) +LL | | //~^ ERROR reference has a longer lifetime than the data it references +LL | | { +LL | | } + | |_^ + | +note: the pointer is valid for the lifetime 'x as defined on the function body at 31:11 + --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:31:11 + | +LL | fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) + | ^^ +note: but the referenced data is only valid for the lifetime 'y as defined on the function body at 31:15 + --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:31:15 + | +LL | fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-in-enums-anon.rs b/src/test/ui/compile-fail-migration/regions-in-enums-anon.rs new file mode 100644 index 00000000000..305bf88c4d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-enums-anon.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that anonymous lifetimes are not permitted in enum declarations + +enum Foo { + Bar(&isize) //~ ERROR missing lifetime specifier +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-in-enums-anon.stderr b/src/test/ui/compile-fail-migration/regions-in-enums-anon.stderr new file mode 100644 index 00000000000..f5630f84aed --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-enums-anon.stderr @@ -0,0 +1,9 @@ +error[E0106]: missing lifetime specifier + --> $DIR/regions-in-enums-anon.rs:14:9 + | +LL | Bar(&isize) //~ ERROR missing lifetime specifier + | ^ expected lifetime parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/regions-in-enums.rs b/src/test/ui/compile-fail-migration/regions-in-enums.rs new file mode 100644 index 00000000000..613a90dda67 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-enums.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that lifetimes must be declared for use on enums. +// See also regions-undeclared.rs + +enum yes0<'lt> { + X3(&'lt usize) +} + +enum yes1<'a> { + X4(&'a usize) +} + +enum no0 { + X5(&'foo usize) //~ ERROR use of undeclared lifetime name `'foo` +} + +enum no1 { + X6(&'a usize) //~ ERROR use of undeclared lifetime name `'a` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-in-enums.stderr b/src/test/ui/compile-fail-migration/regions-in-enums.stderr new file mode 100644 index 00000000000..cdc0b6ca122 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-enums.stderr @@ -0,0 +1,15 @@ +error[E0261]: use of undeclared lifetime name `'foo` + --> $DIR/regions-in-enums.rs:23:9 + | +LL | X5(&'foo usize) //~ ERROR use of undeclared lifetime name `'foo` + | ^^^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-in-enums.rs:27:9 + | +LL | X6(&'a usize) //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/compile-fail-migration/regions-in-structs-anon.rs b/src/test/ui/compile-fail-migration/regions-in-structs-anon.rs new file mode 100644 index 00000000000..b85928b1b9f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-structs-anon.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that anonymous lifetimes are not permitted in struct declarations + +struct Foo { + x: &isize //~ ERROR missing lifetime specifier +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-in-structs-anon.stderr b/src/test/ui/compile-fail-migration/regions-in-structs-anon.stderr new file mode 100644 index 00000000000..ecfac87c6c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-structs-anon.stderr @@ -0,0 +1,9 @@ +error[E0106]: missing lifetime specifier + --> $DIR/regions-in-structs-anon.rs:14:8 + | +LL | x: &isize //~ ERROR missing lifetime specifier + | ^ expected lifetime parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/regions-in-structs.rs b/src/test/ui/compile-fail-migration/regions-in-structs.rs new file mode 100644 index 00000000000..c231d3a913e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-structs.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct yes1<'a> { + x: &'a usize, +} + +struct yes2<'a> { + x: &'a usize, +} + +struct StructDecl { + a: &'a isize, //~ ERROR use of undeclared lifetime name `'a` + b: &'a isize, //~ ERROR use of undeclared lifetime name `'a` +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-in-structs.stderr b/src/test/ui/compile-fail-migration/regions-in-structs.stderr new file mode 100644 index 00000000000..679a219fbb1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-in-structs.stderr @@ -0,0 +1,15 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-in-structs.rs:20:9 + | +LL | a: &'a isize, //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-in-structs.rs:21:9 + | +LL | b: &'a isize, //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.nll.stderr new file mode 100644 index 00000000000..6bc3dafea51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-at-fn-not-param.rs:23:57 + | +LL | fn take1<'a>(p: parameterized1) -> parameterized1<'a> { p } + | ^ + +error[E0621]: explicit lifetime required in the type of `p` + --> $DIR/regions-infer-at-fn-not-param.rs:23:57 + | +LL | fn take1<'a>(p: parameterized1) -> parameterized1<'a> { p } + | -------------- ^ lifetime `'a` required + | | + | help: add explicit lifetime `'a` to the type of `p`: `parameterized1<'a>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.rs b/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.rs new file mode 100644 index 00000000000..ec73bf90b6e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct parameterized1<'a> { + g: Box +} + +struct not_parameterized1 { + g: Box +} + +struct not_parameterized2 { + g: Box +} + +fn take1<'a>(p: parameterized1) -> parameterized1<'a> { p } +//~^ ERROR explicit lifetime required in the type of `p` + +fn take3(p: not_parameterized1) -> not_parameterized1 { p } +fn take4(p: not_parameterized2) -> not_parameterized2 { p } + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.stderr b/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.stderr new file mode 100644 index 00000000000..f129ffae23a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-at-fn-not-param.stderr @@ -0,0 +1,11 @@ +error[E0621]: explicit lifetime required in the type of `p` + --> $DIR/regions-infer-at-fn-not-param.rs:23:57 + | +LL | fn take1<'a>(p: parameterized1) -> parameterized1<'a> { p } + | -------------- ^ lifetime `'a` required + | | + | help: add explicit lifetime `'a` to the type of `p`: `parameterized1<'a>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.nll.stderr new file mode 100644 index 00000000000..28bf252bc95 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.nll.stderr @@ -0,0 +1,18 @@ +error[E0597]: `*p` does not live long enough + --> $DIR/regions-infer-borrow-scope-too-big.rs:22:22 + | +LL | let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - `*p` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:8... + --> $DIR/regions-infer-borrow-scope-too-big.rs:21:8 + | +LL | fn foo<'a>(p: Box) -> &'a isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.rs b/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.rs new file mode 100644 index 00000000000..2628e6a1ce2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct point { + x: isize, + y: isize, +} + +fn x_coord<'r>(p: &'r point) -> &'r isize { + return &p.x; +} + +fn foo<'a>(p: Box) -> &'a isize { + let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough + assert_eq!(*xc, 3); + return xc; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.stderr b/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.stderr new file mode 100644 index 00000000000..4c4a9b91958 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-borrow-scope-too-big.stderr @@ -0,0 +1,18 @@ +error[E0597]: `*p` does not live long enough + --> $DIR/regions-infer-borrow-scope-too-big.rs:22:23 + | +LL | let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:8... + --> $DIR/regions-infer-borrow-scope-too-big.rs:21:8 + | +LL | fn foo<'a>(p: Box) -> &'a isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.nll.stderr new file mode 100644 index 00000000000..c71bd17ac78 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-bound-from-trait-self.rs:56:9 + | +LL | check_bound(x, self) + | ^^^^^^^^^^^ + +error[E0309]: the parameter type `Self` may not live long enough + --> $DIR/regions-infer-bound-from-trait-self.rs:56:9 + | +LL | check_bound(x, self) + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `Self: 'a`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.rs b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.rs new file mode 100644 index 00000000000..23b8ebfe54b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.rs @@ -0,0 +1,61 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can derive lifetime bounds on `Self` from trait +// inheritance. + +trait Static : 'static { } + +trait Is<'a> : 'a { } + +struct Inv<'a> { + x: Option<&'a mut &'a isize> +} + +fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } + +// In these case, `Self` inherits `'static`. + +trait InheritsFromStatic : Sized + 'static { + fn foo1<'a>(self, x: Inv<'a>) { + check_bound(x, self) + } +} +trait InheritsFromStaticIndirectly : Sized + Static { + fn foo1<'a>(self, x: Inv<'a>) { + check_bound(x, self) + } +} + + +// In these case, `Self` inherits `'a`. + +trait InheritsFromIs<'a> : Sized + 'a { + fn foo(self, x: Inv<'a>) { + check_bound(x, self) + } +} + +trait InheritsFromIsIndirectly<'a> : Sized + Is<'a> { + fn foo(self, x: Inv<'a>) { + check_bound(x, self) + } +} + +// In this case, `Self` inherits nothing. + +trait InheritsFromNothing<'a> : Sized { + fn foo(self, x: Inv<'a>) { + check_bound(x, self) + //~^ ERROR parameter type `Self` may not live long enough + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.stderr b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.stderr new file mode 100644 index 00000000000..7b30f9a58f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait-self.stderr @@ -0,0 +1,16 @@ +error[E0309]: the parameter type `Self` may not live long enough + --> $DIR/regions-infer-bound-from-trait-self.rs:56:9 + | +LL | check_bound(x, self) + | ^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `Self: 'a`... +note: ...so that the type `Self` will meet its required lifetime bounds + --> $DIR/regions-infer-bound-from-trait-self.rs:56:9 + | +LL | check_bound(x, self) + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.nll.stderr new file mode 100644 index 00000000000..25f69031507 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.nll.stderr @@ -0,0 +1,31 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-bound-from-trait.rs:43:5 + | +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-infer-bound-from-trait.rs:47:5 + | +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^ + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-infer-bound-from-trait.rs:43:5 + | +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `A: 'a`... + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-infer-bound-from-trait.rs:47:5 + | +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `A: 'a`... + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.rs b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.rs new file mode 100644 index 00000000000..f7a91054766 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.rs @@ -0,0 +1,50 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can derive lifetime bounds on type parameters +// from trait inheritance. + +trait Static : 'static { } + +trait Is<'a> : 'a { } + +struct Inv<'a> { + x: Option<&'a mut &'a isize> +} + +fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } + +// In all of these cases, we can derive a bound for A that is longer +// than 'a based on the trait bound of A: + +fn foo1<'a,A:Static>(x: Inv<'a>, a: A) { + check_bound(x, a) +} + +fn foo2<'a,A:Static>(x: Inv<'static>, a: A) { + check_bound(x, a) +} + +fn foo3<'a,A:Is<'a>>(x: Inv<'a>, a: A) { + check_bound(x, a) +} + +// In these cases, there is no trait bound, so we cannot derive any +// bound for A and we get an error: + +fn bar1<'a,A>(x: Inv<'a>, a: A) { + check_bound(x, a) //~ ERROR parameter type `A` may not live long enough +} + +fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { + check_bound(x, a) //~ ERROR parameter type `A` may not live long enough +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.stderr b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.stderr new file mode 100644 index 00000000000..4c89f4bd8a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-bound-from-trait.stderr @@ -0,0 +1,31 @@ +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-infer-bound-from-trait.rs:43:5 + | +LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { + | - help: consider adding an explicit lifetime bound `A: 'a`... +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^ + | +note: ...so that the type `A` will meet its required lifetime bounds + --> $DIR/regions-infer-bound-from-trait.rs:43:5 + | +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^ + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-infer-bound-from-trait.rs:47:5 + | +LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { + | -- help: consider adding an explicit lifetime bound `A: 'a`... +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^ + | +note: ...so that the type `A` will meet its required lifetime bounds + --> $DIR/regions-infer-bound-from-trait.rs:47:5 + | +LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-call-3.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-call-3.nll.stderr new file mode 100644 index 00000000000..c8665fe6a11 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-call-3.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-call-3.rs:18:24 + | +LL | let z = with(|y| { select(x, y) }); + | ^^^^^^^^^^^^ + +error: borrowed data escapes outside of closure + --> $DIR/regions-infer-call-3.rs:18:24 + | +LL | let z = with(|y| { select(x, y) }); + | - ^^^^^^^^^^^^ `y` escapes the closure body here + | | + | `y` is a reference that is only valid in the closure body + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-infer-call-3.rs b/src/test/ui/compile-fail-migration/regions-infer-call-3.rs new file mode 100644 index 00000000000..95783a420b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-call-3.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn select<'r>(x: &'r isize, y: &'r isize) -> &'r isize { x } + +fn with(f: F) -> T where F: FnOnce(&isize) -> T { + f(&20) +} + +fn manip<'a>(x: &'a isize) -> isize { + let z = with(|y| { select(x, y) }); + //~^ ERROR cannot infer + *z +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-infer-call-3.stderr b/src/test/ui/compile-fail-migration/regions-infer-call-3.stderr new file mode 100644 index 00000000000..d42e5bfc7dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-call-3.stderr @@ -0,0 +1,30 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'r in function call due to conflicting requirements + --> $DIR/regions-infer-call-3.rs:18:24 + | +LL | let z = with(|y| { select(x, y) }); + | ^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 18:18... + --> $DIR/regions-infer-call-3.rs:18:18 + | +LL | let z = with(|y| { select(x, y) }); + | ^^^^^^^^^^^^^^^^^^^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-infer-call-3.rs:18:34 + | +LL | let z = with(|y| { select(x, y) }); + | ^ +note: but, the lifetime must be valid for the call at 18:13... + --> $DIR/regions-infer-call-3.rs:18:13 + | +LL | let z = with(|y| { select(x, y) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...so type `&isize` of expression is valid during the expression + --> $DIR/regions-infer-call-3.rs:18:13 + | +LL | let z = with(|y| { select(x, y) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.rs b/src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.rs new file mode 100644 index 00000000000..6e1c765724b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.rs @@ -0,0 +1,38 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a type which is contravariant with respect to its region +// parameter yields an error when used in a covariant way. +// +// Note: see variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +use std::marker; + +// This is contravariant with respect to 'a, meaning that +// Contravariant<'foo> <: Contravariant<'static> because +// 'foo <= 'static +struct Contravariant<'a> { + marker: marker::PhantomData<&'a()> +} + +fn use_<'short,'long>(c: Contravariant<'short>, + s: &'short isize, + l: &'long isize, + _where:Option<&'short &'long ()>) { + + // Test whether Contravariant<'short> <: Contravariant<'long>. Since + // 'short <= 'long, this would be true if the Contravariant type were + // covariant with respect to its parameter 'a. + + let _: Contravariant<'long> = c; //~ ERROR E0623 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.stderr b/src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.stderr new file mode 100644 index 00000000000..10cc253397f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-contravariance-due-to-decl.stderr @@ -0,0 +1,15 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-infer-contravariance-due-to-decl.rs:35:35 + | +LL | fn use_<'short,'long>(c: Contravariant<'short>, + | --------------------- these two types are declared with different lifetimes... +LL | s: &'short isize, +LL | l: &'long isize, + | ------------ +... +LL | let _: Contravariant<'long> = c; //~ ERROR E0623 + | ^ ...but data from `c` flows into `l` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.rs b/src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.rs new file mode 100644 index 00000000000..1ab8ba4439b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a type which is covariant with respect to its region +// parameter yields an error when used in a contravariant way. +// +// Note: see variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +use std::marker; + +struct Covariant<'a> { + marker: marker::PhantomData +} + +fn use_<'short,'long>(c: Covariant<'long>, + s: &'short isize, + l: &'long isize, + _where:Option<&'short &'long ()>) { + + // Test whether Covariant<'long> <: Covariant<'short>. Since + // 'short <= 'long, this would be true if the Covariant type were + // contravariant with respect to its parameter 'a. + + let _: Covariant<'short> = c; //~ ERROR E0623 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.stderr b/src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.stderr new file mode 100644 index 00000000000..fd853629f37 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-covariance-due-to-decl.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-infer-covariance-due-to-decl.rs:32:32 + | +LL | fn use_<'short,'long>(c: Covariant<'long>, + | ---------------- +LL | s: &'short isize, + | ------------- these two types are declared with different lifetimes... +... +LL | let _: Covariant<'short> = c; //~ ERROR E0623 + | ^ ...but data from `s` flows into `c` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.nll.stderr new file mode 100644 index 00000000000..86a7e1f2c48 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-invariance-due-to-decl.rs:22:5 + | +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-infer-invariance-due-to-decl.rs:22:5 + | +LL | fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { + | -- lifetime `'r` defined here +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ return requires that `'r` must outlive `'static` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.rs b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.rs new file mode 100644 index 00000000000..8c191fbd5bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker; + +struct invariant<'a> { + marker: marker::PhantomData<*mut &'a()> +} + +fn to_same_lifetime<'r>(b_isize: invariant<'r>) { + let bj: invariant<'r> = b_isize; +} + +fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { + b_isize //~ ERROR mismatched types +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.stderr b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.stderr new file mode 100644 index 00000000000..edd37b1622a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-decl.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-invariance-due-to-decl.rs:22:5 + | +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ lifetime mismatch + | + = note: expected type `invariant<'static>` + found type `invariant<'r>` +note: the lifetime 'r as defined on the function body at 21:23... + --> $DIR/regions-infer-invariance-due-to-decl.rs:21:23 + | +LL | fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.nll.stderr new file mode 100644 index 00000000000..a021239af1e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:21:5 + | +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:21:5 + | +LL | fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { + | -- lifetime `'r` defined here +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ return requires that `'r` must outlive `'static` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.rs b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.rs new file mode 100644 index 00000000000..f280e4d978e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct invariant<'a> { + f: Box, +} + +fn to_same_lifetime<'r>(b_isize: invariant<'r>) { + let bj: invariant<'r> = b_isize; +} + +fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { + b_isize //~ ERROR mismatched types +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.stderr b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.stderr new file mode 100644 index 00000000000..3a807b755af --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-3.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:21:5 + | +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ lifetime mismatch + | + = note: expected type `invariant<'static>` + found type `invariant<'r>` +note: the lifetime 'r as defined on the function body at 20:23... + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:20:23 + | +LL | fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.nll.stderr new file mode 100644 index 00000000000..20e0e730c02 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:21:5 + | +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:21:5 + | +LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { + | -- lifetime `'r` defined here +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ return requires that `'r` must outlive `'static` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.rs b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.rs new file mode 100644 index 00000000000..87b5efbfadd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct Invariant<'a> { + f: Box *mut &'a isize + 'static>, +} + +fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { + let bj: Invariant<'r> = b_isize; +} + +fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { + b_isize //~ ERROR mismatched types +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.stderr b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.stderr new file mode 100644 index 00000000000..fb47433ba17 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-invariance-due-to-mutability-4.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:21:5 + | +LL | b_isize //~ ERROR mismatched types + | ^^^^^^^ lifetime mismatch + | + = note: expected type `Invariant<'static>` + found type `Invariant<'r>` +note: the lifetime 'r as defined on the function body at 20:23... + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:20:23 + | +LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-not-param.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-not-param.nll.stderr new file mode 100644 index 00000000000..deeca293a1a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-not-param.nll.stderr @@ -0,0 +1,38 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-not-param.rs:25:54 + | +LL | fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-infer-not-param.rs:29:63 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-infer-not-param.rs:25:54 + | +LL | fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types + | -- -- lifetime `'b` defined here ^ return requires that `'a` must outlive `'b` + | | + | lifetime `'a` defined here + +error: unsatisfied lifetime constraints + --> $DIR/regions-infer-not-param.rs:29:63 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` + | | + | lifetime `'a` defined here + +error: unsatisfied lifetime constraints + --> $DIR/regions-infer-not-param.rs:29:63 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | -- -- lifetime `'b` defined here ^ return requires that `'a` must outlive `'b` + | | + | lifetime `'a` defined here + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/regions-infer-not-param.rs b/src/test/ui/compile-fail-migration/regions-infer-not-param.rs new file mode 100644 index 00000000000..131b7170951 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-not-param.rs @@ -0,0 +1,36 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct direct<'a> { + f: &'a isize +} + +struct indirect1 { + // Here the lifetime parameter of direct is bound by the fn() + g: Box +} + +struct indirect2<'a> { + // But here it is set to 'a + g: Box) + 'static> +} + +fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types + +fn take_indirect1(p: indirect1) -> indirect1 { p } + +fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types +//~| expected type `indirect2<'b>` +//~| found type `indirect2<'a>` +//~| ERROR mismatched types +//~| expected type `indirect2<'b>` +//~| found type `indirect2<'a>` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-infer-not-param.stderr b/src/test/ui/compile-fail-migration/regions-infer-not-param.stderr new file mode 100644 index 00000000000..2a029518953 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-not-param.stderr @@ -0,0 +1,60 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-not-param.rs:25:54 + | +LL | fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `direct<'b>` + found type `direct<'a>` +note: the lifetime 'a as defined on the function body at 25:16... + --> $DIR/regions-infer-not-param.rs:25:16 + | +LL | fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the function body at 25:19 + --> $DIR/regions-infer-not-param.rs:25:19 + | +LL | fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types + | ^^ + +error[E0308]: mismatched types + --> $DIR/regions-infer-not-param.rs:29:63 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `indirect2<'b>` + found type `indirect2<'a>` +note: the lifetime 'a as defined on the function body at 29:19... + --> $DIR/regions-infer-not-param.rs:29:19 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the function body at 29:22 + --> $DIR/regions-infer-not-param.rs:29:22 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | ^^ + +error[E0308]: mismatched types + --> $DIR/regions-infer-not-param.rs:29:63 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `indirect2<'b>` + found type `indirect2<'a>` +note: the lifetime 'b as defined on the function body at 29:22... + --> $DIR/regions-infer-not-param.rs:29:22 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | ^^ +note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 29:19 + --> $DIR/regions-infer-not-param.rs:29:19 + | +LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types + | ^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.nll.stderr new file mode 100644 index 00000000000..01ae2910bd5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-infer-paramd-indirect.rs:33:18 + | +LL | self.f = b; + | ^ + +error: borrowed data escapes outside of function + --> $DIR/regions-infer-paramd-indirect.rs:33:9 + | +LL | fn set_f_bad(&mut self, b: Box) { + | --------- - `b` is a reference that is only valid in the function body + | | + | `self` is declared here, outside of the function body +LL | self.f = b; + | ^^^^^^ `b` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.rs b/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.rs new file mode 100644 index 00000000000..c559992c865 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.rs @@ -0,0 +1,41 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// Check that we correctly infer that b and c must be region +// parameterized because they reference a which requires a region. + +type a<'a> = &'a isize; +type b<'a> = Box>; + +struct c<'a> { + f: Box> +} + +trait set_f<'a> { + fn set_f_ok(&mut self, b: Box>); + fn set_f_bad(&mut self, b: Box); +} + +impl<'a> set_f<'a> for c<'a> { + fn set_f_ok(&mut self, b: Box>) { + self.f = b; + } + + fn set_f_bad(&mut self, b: Box) { + self.f = b; + //~^ ERROR mismatched types + //~| expected type `std::boxed::Box>` + //~| found type `std::boxed::Box>` + //~| lifetime mismatch + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.stderr b/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.stderr new file mode 100644 index 00000000000..602f30957f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-paramd-indirect.stderr @@ -0,0 +1,28 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-paramd-indirect.rs:33:18 + | +LL | self.f = b; + | ^ lifetime mismatch + | + = note: expected type `std::boxed::Box>` + found type `std::boxed::Box>` +note: the anonymous lifetime #2 defined on the method body at 32:5... + --> $DIR/regions-infer-paramd-indirect.rs:32:5 + | +LL | / fn set_f_bad(&mut self, b: Box) { +LL | | self.f = b; +LL | | //~^ ERROR mismatched types +LL | | //~| expected type `std::boxed::Box>` +LL | | //~| found type `std::boxed::Box>` +LL | | //~| lifetime mismatch +LL | | } + | |_____^ +note: ...does not necessarily outlive the lifetime 'a as defined on the impl at 27:6 + --> $DIR/regions-infer-paramd-indirect.rs:27:6 + | +LL | impl<'a> set_f<'a> for c<'a> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.nll.stderr b/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.nll.stderr new file mode 100644 index 00000000000..fa358a9cc45 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/regions-infer-proc-static-upvar.rs:20:13 + | +LL | let y = &x; //~ ERROR `x` does not live long enough + | ^^ borrowed value does not live long enough +... +LL | } + | - `x` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.rs b/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.rs new file mode 100644 index 00000000000..ee5d5cad0a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that, when a variable of type `&T` is captured inside a proc, +// we correctly infer/require that its lifetime is 'static. + +fn foo(_p: F) { } + +static i: isize = 3; + +fn capture_local() { + let x = 3; + let y = &x; //~ ERROR `x` does not live long enough + foo(move|| { + let _a = *y; + }); +} + +fn capture_static() { + // Legal because &i can have static lifetime: + let y = &i; + foo(move|| { + let _a = *y; + }); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.stderr b/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.stderr new file mode 100644 index 00000000000..93fe45ed300 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-infer-proc-static-upvar.stderr @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/regions-infer-proc-static-upvar.rs:20:14 + | +LL | let y = &x; //~ ERROR `x` does not live long enough + | ^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.nll.stderr b/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.nll.stderr new file mode 100644 index 00000000000..01f0cfa4a71 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.nll.stderr @@ -0,0 +1,24 @@ +warning: not reporting region error due to nll + --> $DIR/regions-lifetime-bounds-on-fns.rs:18:10 + | +LL | *x = *y; //~ ERROR E0623 + | ^^ + +warning: not reporting region error due to nll + --> $DIR/regions-lifetime-bounds-on-fns.rs:24:5 + | +LL | a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] + | ^ + +error[E0308]: mismatched types + --> $DIR/regions-lifetime-bounds-on-fns.rs:30:43 + | +LL | let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types + | ^ expected concrete lifetime, found bound lifetime parameter + | + = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` + found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.rs b/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.rs new file mode 100644 index 00000000000..5955619ea92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { + // Note: this is legal because of the `'b:'a` declaration. + *x = *y; +} + +fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { + // Illegal now because there is no `'b:'a` declaration. + *x = *y; //~ ERROR E0623 +} + +fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { + // Here we try to call `foo` but do not know that `'a` and `'b` are + // related as required. + a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] +} + +fn d() { + // 'a and 'b are early bound in the function `a` because they appear + // inconstraints: + let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types +} + +fn e() { + // 'a and 'b are late bound in the function `b` because there are + // no constraints: + let _: fn(&mut &isize, &mut &isize) = b; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.stderr b/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.stderr new file mode 100644 index 00000000000..1b600ef905f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-lifetime-bounds-on-fns.stderr @@ -0,0 +1,31 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-lifetime-bounds-on-fns.rs:18:10 + | +LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +LL | // Illegal now because there is no `'b:'a` declaration. +LL | *x = *y; //~ ERROR E0623 + | ^^ ...but data from `y` flows into `x` here + +error[E0623]: lifetime mismatch + --> $DIR/regions-lifetime-bounds-on-fns.rs:24:7 + | +LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +... +LL | a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] + | ^ ...but data from `y` flows into `x` here + +error[E0308]: mismatched types + --> $DIR/regions-lifetime-bounds-on-fns.rs:30:43 + | +LL | let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types + | ^ expected concrete lifetime, found bound lifetime parameter + | + = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` + found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` + +error: aborting due to 3 previous errors + +Some errors occurred: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.rs b/src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.rs new file mode 100644 index 00000000000..46c486c63a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This tests verifies that unary structs and enum variants +// are treated as rvalues and their lifetime is not bounded to +// the static scope. + +fn id(x: T) -> T { x } + +struct Test; + +enum MyEnum { + Variant1 +} + +fn structLifetime<'a>() -> &'a Test { + let testValue = &id(Test); + //~^ ERROR borrowed value does not live long enough + testValue +} + +fn variantLifetime<'a>() -> &'a MyEnum { + let testValue = &id(MyEnum::Variant1); + //~^ ERROR borrowed value does not live long enough + testValue +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.stderr b/src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.stderr new file mode 100644 index 00000000000..390173ed749 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-lifetime-of-struct-or-enum-variant.stderr @@ -0,0 +1,33 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:24:20 + | +LL | let testValue = &id(Test); + | ^^^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:19... + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:23:19 + | +LL | fn structLifetime<'a>() -> &'a Test { + | ^^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:30:20 + | +LL | let testValue = &id(MyEnum::Variant1); + | ^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 29:20... + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:29:20 + | +LL | fn variantLifetime<'a>() -> &'a MyEnum { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-name-duplicated.rs b/src/test/ui/compile-fail-migration/regions-name-duplicated.rs new file mode 100644 index 00000000000..b4b9cfd75cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-name-duplicated.rs @@ -0,0 +1,15 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<'a, 'a> { //~ ERROR lifetime name `'a` declared twice + x: &'a isize +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-name-duplicated.stderr b/src/test/ui/compile-fail-migration/regions-name-duplicated.stderr new file mode 100644 index 00000000000..ad945d54ad1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-name-duplicated.stderr @@ -0,0 +1,11 @@ +error[E0263]: lifetime name `'a` declared twice in the same scope + --> $DIR/regions-name-duplicated.rs:11:16 + | +LL | struct Foo<'a, 'a> { //~ ERROR lifetime name `'a` declared twice + | -- ^^ declared twice + | | + | previous declaration here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0263`. diff --git a/src/test/ui/compile-fail-migration/regions-name-static.rs b/src/test/ui/compile-fail-migration/regions-name-static.rs new file mode 100644 index 00000000000..69d63f3820c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-name-static.rs @@ -0,0 +1,15 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<'static> { //~ ERROR invalid lifetime parameter name: `'static` + x: &'static isize +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-name-static.stderr b/src/test/ui/compile-fail-migration/regions-name-static.stderr new file mode 100644 index 00000000000..48077d61c45 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-name-static.stderr @@ -0,0 +1,9 @@ +error[E0262]: invalid lifetime parameter name: `'static` + --> $DIR/regions-name-static.rs:11:12 + | +LL | struct Foo<'static> { //~ ERROR invalid lifetime parameter name: `'static` + | ^^^^^^^ 'static is a reserved lifetime name + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0262`. diff --git a/src/test/ui/compile-fail-migration/regions-name-undeclared.rs b/src/test/ui/compile-fail-migration/regions-name-undeclared.rs new file mode 100644 index 00000000000..a61d3094933 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-name-undeclared.rs @@ -0,0 +1,60 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that lifetime resolver enforces the lifetime name scoping +// rules correctly in various scenarios. + +struct Foo<'a> { + x: &'a isize +} + +impl<'a> Foo<'a> { + // &'a is inherited: + fn m1(&self, arg: &'a isize) { } + fn m2(&'a self) { } + fn m3(&self, arg: Foo<'a>) { } + + // &'b is not: + fn m4(&self, arg: &'b isize) { } //~ ERROR undeclared lifetime + fn m5(&'b self) { } //~ ERROR undeclared lifetime + fn m6(&self, arg: Foo<'b>) { } //~ ERROR undeclared lifetime +} + +fn bar<'a>(x: &'a isize) { + // &'a is visible to code: + let y: &'a isize = x; + + // &'a is not visible to *items*: + type X = Option<&'a isize>; //~ ERROR undeclared lifetime + enum E { + E1(&'a isize) //~ ERROR undeclared lifetime + } + struct S { + f: &'a isize //~ ERROR undeclared lifetime + } + fn f(a: &'a isize) { } //~ ERROR undeclared lifetime + + // &'a CAN be declared on functions and used then: + fn g<'a>(a: &'a isize) { } // OK + fn h(a: Box FnOnce(&'a isize)>) { } // OK +} + +// Test nesting of lifetimes in fn type declarations +fn fn_types(a: &'a isize, //~ ERROR undeclared lifetime + b: Box FnOnce(&'a isize, + &'b isize, //~ ERROR undeclared lifetime + Box FnOnce(&'a isize, + &'b isize)>, + &'b isize)>, //~ ERROR undeclared lifetime + c: &'a isize) //~ ERROR undeclared lifetime +{ +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-name-undeclared.stderr b/src/test/ui/compile-fail-migration/regions-name-undeclared.stderr new file mode 100644 index 00000000000..62fc5f5c7f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-name-undeclared.stderr @@ -0,0 +1,69 @@ +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/regions-name-undeclared.rs:25:24 + | +LL | fn m4(&self, arg: &'b isize) { } //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/regions-name-undeclared.rs:26:12 + | +LL | fn m5(&'b self) { } //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/regions-name-undeclared.rs:27:27 + | +LL | fn m6(&self, arg: Foo<'b>) { } //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-name-undeclared.rs:35:22 + | +LL | type X = Option<&'a isize>; //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-name-undeclared.rs:37:13 + | +LL | E1(&'a isize) //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-name-undeclared.rs:40:13 + | +LL | f: &'a isize //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-name-undeclared.rs:42:14 + | +LL | fn f(a: &'a isize) { } //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-name-undeclared.rs:50:17 + | +LL | fn fn_types(a: &'a isize, //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/regions-name-undeclared.rs:52:36 + | +LL | &'b isize, //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/regions-name-undeclared.rs:55:36 + | +LL | &'b isize)>, //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-name-undeclared.rs:56:17 + | +LL | c: &'a isize) //~ ERROR undeclared lifetime + | ^^ undeclared lifetime + +error: aborting due to 11 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/compile-fail-migration/regions-nested-fns.nll.stderr b/src/test/ui/compile-fail-migration/regions-nested-fns.nll.stderr new file mode 100644 index 00000000000..d90015b1b21 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-nested-fns.nll.stderr @@ -0,0 +1,60 @@ +warning: not reporting region error due to nll + --> $DIR/regions-nested-fns.rs:24:27 + | +LL | if false { return x; } //~ ERROR E0312 + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-nested-fns.rs:15:18 + | +LL | let mut ay = &y; //~ ERROR E0495 + | ^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-nested-fns.rs:20:9 + | +LL | let mut ay = &y; //~ ERROR E0495 + | ------ lifetime `'2` appears in the type of `ay` +LL | +LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { + | - has type `&'1 isize` +... +LL | ay = z; + | ^^^^^^ requires that `'1` must outlive `'2` + +error: unsatisfied lifetime constraints + --> $DIR/regions-nested-fns.rs:14:9 + | +LL | fn nested<'x>(x: &'x isize) { + | -- lifetime `'x` defined here +LL | let y = 3; + | ^ requires that `'x` must outlive `'static` + +error[E0597]: `y` does not live long enough + --> $DIR/regions-nested-fns.rs:15:18 + | +LL | let mut ay = &y; //~ ERROR E0495 + | ^^ borrowed value does not live long enough +... +LL | } + | - `y` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: `y` does not live long enough + --> $DIR/regions-nested-fns.rs:19:15 + | +LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { + | --- value captured here +LL | ay = x; +LL | ay = &y; + | ^ borrowed value does not live long enough +... +LL | } + | - `y` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-nested-fns.rs b/src/test/ui/compile-fail-migration/regions-nested-fns.rs new file mode 100644 index 00000000000..010b7d17688 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-nested-fns.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn ignore(t: T) {} + +fn nested<'x>(x: &'x isize) { + let y = 3; + let mut ay = &y; //~ ERROR E0495 + + ignore:: FnMut(&'z isize)>>(Box::new(|z| { + ay = x; + ay = &y; + ay = z; + })); + + ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + if false { return x; } //~ ERROR E0312 + if false { return ay; } + return z; + })); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-nested-fns.stderr b/src/test/ui/compile-fail-migration/regions-nested-fns.stderr new file mode 100644 index 00000000000..93004b4c3bf --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-nested-fns.stderr @@ -0,0 +1,61 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-nested-fns.rs:15:18 + | +LL | let mut ay = &y; //~ ERROR E0495 + | ^^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 17:54... + --> $DIR/regions-nested-fns.rs:17:54 + | +LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { + | ______________________________________________________^ +LL | | ay = x; +LL | | ay = &y; +LL | | ay = z; +LL | | })); + | |_____^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-nested-fns.rs:20:14 + | +LL | ay = z; + | ^ +note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the body at 23:68... + --> $DIR/regions-nested-fns.rs:23:68 + | +LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ____________________________________________________________________^ +LL | | if false { return x; } //~ ERROR E0312 +LL | | if false { return ay; } +LL | | return z; +LL | | })); + | |_____^ + = note: ...so that the types are compatible: + expected &isize + found &isize + +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-nested-fns.rs:24:27 + | +LL | if false { return x; } //~ ERROR E0312 + | ^ + | +note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 23:68... + --> $DIR/regions-nested-fns.rs:23:68 + | +LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ____________________________________________________________________^ +LL | | if false { return x; } //~ ERROR E0312 +LL | | if false { return ay; } +LL | | return z; +LL | | })); + | |_____^ +note: ...but the borrowed content is only valid for the lifetime 'x as defined on the function body at 13:11 + --> $DIR/regions-nested-fns.rs:13:11 + | +LL | fn nested<'x>(x: &'x isize) { + | ^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0312, E0495. +For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.rs b/src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.rs new file mode 100644 index 00000000000..68642598ed2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.rs @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to normalize in the list of where-clauses, +// even if `'a: 'b` is required. + +trait Project<'a, 'b> { + type Item; +} + +impl<'a, 'b> Project<'a, 'b> for () + where 'a: 'b +{ + type Item = (); +} + +// No error here, we have 'a: 'b. We used to report an error here +// though, see https://github.com/rust-lang/rust/issues/45937. +fn foo<'a: 'b, 'b>() + where <() as Project<'a, 'b>>::Item : Eq +{ +} + +// Here we get an error: we need `'a: 'b`. +fn bar<'a, 'b>() //~ ERROR cannot infer + where <() as Project<'a, 'b>>::Item : Eq +{ +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.stderr b/src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.stderr new file mode 100644 index 00000000000..ec153f111d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-normalize-in-where-clause-list.stderr @@ -0,0 +1,26 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/regions-normalize-in-where-clause-list.rs:32:1 + | +LL | / fn bar<'a, 'b>() //~ ERROR cannot infer +LL | | where <() as Project<'a, 'b>>::Item : Eq +LL | | { +LL | | } + | |_^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 32:8... + --> $DIR/regions-normalize-in-where-clause-list.rs:32:8 + | +LL | fn bar<'a, 'b>() //~ ERROR cannot infer + | ^^ +note: ...but the lifetime must also be valid for the lifetime 'b as defined on the function body at 32:12... + --> $DIR/regions-normalize-in-where-clause-list.rs:32:12 + | +LL | fn bar<'a, 'b>() //~ ERROR cannot infer + | ^^ + = note: ...so that the types are compatible: + expected Project<'a, 'b> + found Project<'_, '_> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.rs new file mode 100644 index 00000000000..db25a0698fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_region { + struct Foo<'a> { + x: fn(&'a i32), + } + enum Bar<'a,'b> { + V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.stderr new file mode 100644 index 00000000000..5084097e30d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:24:11 + | +LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.rs new file mode 100644 index 00000000000..403757042d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_region { + struct Foo<'a> { + x: &'a i32, + } + enum Bar<'a,'b> { + V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.stderr new file mode 100644 index 00000000000..ce187eddfa9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-region.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-region.rs:24:11 + | +LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.rs new file mode 100644 index 00000000000..cc294651db7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_type { + struct Foo { + x: fn(T) + } + enum Bar<'a,'b> { + V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.stderr new file mode 100644 index 00000000000..8636b89b71a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:24:11 + | +LL | V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.rs new file mode 100644 index 00000000000..e269767cc16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: T + } + enum Bar<'a,'b> { + F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.stderr new file mode 100644 index 00000000000..c209547e20c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-enum-type.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-type.rs:24:11 + | +LL | F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.rs new file mode 100644 index 00000000000..c7e6ace8b92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_region { + struct Foo<'a> { + x: fn(&'a i32), + } + struct Bar<'a,'b> { + f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.stderr new file mode 100644 index 00000000000..48980bdf832 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:24:9 + | +LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.rs new file mode 100644 index 00000000000..2fe6444c33a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_region { + struct Foo<'a> { + x: &'a i32, + } + struct Bar<'a,'b> { + f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.stderr new file mode 100644 index 00000000000..e2b328886b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-region.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-region.rs:24:9 + | +LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.rs new file mode 100644 index 00000000000..c4b631bce98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_type { + struct Foo { + x: fn(T) + } + struct Bar<'a,'b> { + f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.stderr new file mode 100644 index 00000000000..2bf04ffa64a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:24:9 + | +LL | f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.rs b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.rs new file mode 100644 index 00000000000..1c9489444a6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: T + } + struct Bar<'a,'b> { + f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.stderr b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.stderr new file mode 100644 index 00000000000..af9f1d3722a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-nominal-type-struct-type.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-type.rs:24:9 + | +LL | f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.nll.stderr b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.nll.stderr new file mode 100644 index 00000000000..db1508a8c8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.nll.stderr @@ -0,0 +1,21 @@ +warning: not reporting region error due to nll + --> $DIR/regions-outlives-projection-container-hrtb.rs:42:12 + | +LL | let _: &'a WithHrAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-outlives-projection-container-hrtb.rs:63:12 + | +LL | let _: &'a WithHrAssocSub> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: compilation successful + --> $DIR/regions-outlives-projection-container-hrtb.rs:68:1 + | +LL | / fn main() { +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.rs b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.rs new file mode 100644 index 00000000000..ec0631a881a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.rs @@ -0,0 +1,69 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that structs with higher-ranked where clauses don't generate +// "outlives" requirements. Issue #22246. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +/////////////////////////////////////////////////////////////////////////// + +pub trait TheTrait<'b> { + type TheAssocType; +} + +pub struct TheType<'b> { + m: [fn(&'b()); 0] +} + +impl<'a,'b> TheTrait<'a> for TheType<'b> { + type TheAssocType = &'b (); +} + +/////////////////////////////////////////////////////////////////////////// + +pub struct WithHrAssoc + where for<'a> T : TheTrait<'a> +{ + m: [T; 0] +} + +fn with_assoc<'a,'b>() { + // We get an error because 'b:'a does not hold: + + let _: &'a WithHrAssoc> = loop { }; + //~^ ERROR reference has a longer lifetime +} + +/////////////////////////////////////////////////////////////////////////// + +pub trait TheSubTrait : for<'a> TheTrait<'a> { +} + +impl<'b> TheSubTrait for TheType<'b> { } + +pub struct WithHrAssocSub + where T : TheSubTrait +{ + m: [T; 0] +} + +fn with_assoc_sub<'a,'b>() { + // The error here is just because `'b:'a` must hold for the type + // below to be well-formed, it is not related to the HR relation. + + let _: &'a WithHrAssocSub> = loop { }; + //~^ ERROR reference has a longer lifetime +} + +#[rustc_error] +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.stderr b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.stderr new file mode 100644 index 00000000000..32c9359b684 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-hrtb.stderr @@ -0,0 +1,37 @@ +error[E0491]: in type `&'a WithHrAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container-hrtb.rs:42:12 + | +LL | let _: &'a WithHrAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 39:15 + --> $DIR/regions-outlives-projection-container-hrtb.rs:39:15 + | +LL | fn with_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 39:18 + --> $DIR/regions-outlives-projection-container-hrtb.rs:39:18 + | +LL | fn with_assoc<'a,'b>() { + | ^^ + +error[E0491]: in type `&'a WithHrAssocSub>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container-hrtb.rs:63:12 + | +LL | let _: &'a WithHrAssocSub> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 59:19 + --> $DIR/regions-outlives-projection-container-hrtb.rs:59:19 + | +LL | fn with_assoc_sub<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 59:22 + --> $DIR/regions-outlives-projection-container-hrtb.rs:59:22 + | +LL | fn with_assoc_sub<'a,'b>() { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.rs b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.rs new file mode 100644 index 00000000000..71606ba812f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.rs @@ -0,0 +1,49 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are imposing the requirement that every associated +// type of a bound that appears in the where clause on a struct must +// outlive the location in which the type appears, even when the +// constraint is in a where clause not a bound. Issue #22246. + +#![allow(dead_code)] + +/////////////////////////////////////////////////////////////////////////// + +pub trait TheTrait { + type TheAssocType; +} + +pub struct TheType<'b> { + m: [fn(&'b()); 0] +} + +impl<'b> TheTrait for TheType<'b> { + type TheAssocType = &'b (); +} + +/////////////////////////////////////////////////////////////////////////// + +pub struct WithAssoc where T : TheTrait { + m: [T; 0] +} + +fn with_assoc<'a,'b>() { + // For this type to be valid, the rules require that all + // associated types of traits that appear in `WithAssoc` must + // outlive 'a. In this case, that means TheType<'b>::TheAssocType, + // which is &'b (), must outlive 'a. + + let _: &'a WithAssoc> = loop { }; + //~^ ERROR reference has a longer lifetime +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.stderr b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.stderr new file mode 100644 index 00000000000..f0c1c0b3fc2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-container-wc.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container-wc.rs:44:12 + | +LL | let _: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 38:15 + --> $DIR/regions-outlives-projection-container-wc.rs:38:15 + | +LL | fn with_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 38:18 + --> $DIR/regions-outlives-projection-container-wc.rs:38:18 + | +LL | fn with_assoc<'a,'b>() { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-container.rs b/src/test/ui/compile-fail-migration/regions-outlives-projection-container.rs new file mode 100644 index 00000000000..957e56fe510 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-container.rs @@ -0,0 +1,86 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are imposing the requirement that every associated +// type of a bound that appears in the where clause on a struct must +// outlive the location in which the type appears. Issue #22246. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +/////////////////////////////////////////////////////////////////////////// + +pub trait TheTrait { + type TheAssocType; +} + +pub struct TheType<'b> { + m: [fn(&'b()); 0] +} + +impl<'b> TheTrait for TheType<'b> { + type TheAssocType = &'b (); +} + +/////////////////////////////////////////////////////////////////////////// + +pub struct WithAssoc { + m: [T; 0] +} + +pub struct WithoutAssoc { + m: [T; 0] +} + +fn with_assoc<'a,'b>() { + // For this type to be valid, the rules require that all + // associated types of traits that appear in `WithAssoc` must + // outlive 'a. In this case, that means TheType<'b>::TheAssocType, + // which is &'b (), must outlive 'a. + + let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime +} + +fn with_assoc1<'a,'b>() where 'b : 'a { + // For this type to be valid, the rules require that all + // associated types of traits that appear in `WithAssoc` must + // outlive 'a. In this case, that means TheType<'b>::TheAssocType, + // which is &'b (), must outlive 'a, so 'b : 'a must hold, and + // that is in the where clauses, so we're fine. + + let _: &'a WithAssoc> = loop { }; +} + +fn without_assoc<'a,'b>() { + // Here there are no associated types but there is a requirement + // that `'b:'a` holds because the `'b` appears in `TheType<'b>`. + + let _: &'a WithoutAssoc> = loop { }; //~ ERROR reference has a longer lifetime +} + +fn call_with_assoc<'a,'b>() { + // As `with_assoc`, but just checking that we impose the same rule + // on the value supplied for the type argument, even when there is + // no data. + + call::<&'a WithAssoc>>(); + //~^ ERROR reference has a longer lifetime +} + +fn call_without_assoc<'a,'b>() { + // As `without_assoc`, but in a distinct scenario. + + call::<&'a WithoutAssoc>>(); //~ ERROR reference has a longer lifetime +} + +fn call() { } + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-container.stderr b/src/test/ui/compile-fail-migration/regions-outlives-projection-container.stderr new file mode 100644 index 00000000000..ac8d84aa8fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-container.stderr @@ -0,0 +1,71 @@ +error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:48:12 + | +LL | let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 42:15 + --> $DIR/regions-outlives-projection-container.rs:42:15 + | +LL | fn with_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 42:18 + --> $DIR/regions-outlives-projection-container.rs:42:18 + | +LL | fn with_assoc<'a,'b>() { + | ^^ + +error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:65:12 + | +LL | let _: &'a WithoutAssoc> = loop { }; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 61:18 + --> $DIR/regions-outlives-projection-container.rs:61:18 + | +LL | fn without_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 61:21 + --> $DIR/regions-outlives-projection-container.rs:61:21 + | +LL | fn without_assoc<'a,'b>() { + | ^^ + +error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:73:12 + | +LL | call::<&'a WithAssoc>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 68:20 + --> $DIR/regions-outlives-projection-container.rs:68:20 + | +LL | fn call_with_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 68:23 + --> $DIR/regions-outlives-projection-container.rs:68:23 + | +LL | fn call_with_assoc<'a,'b>() { + | ^^ + +error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:80:12 + | +LL | call::<&'a WithoutAssoc>>(); //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the function body at 77:23 + --> $DIR/regions-outlives-projection-container.rs:77:23 + | +LL | fn call_without_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 77:26 + --> $DIR/regions-outlives-projection-container.rs:77:26 + | +LL | fn call_without_assoc<'a,'b>() { + | ^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.rs b/src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.rs new file mode 100644 index 00000000000..2d271b7be73 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.rs @@ -0,0 +1,36 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for the outlives relation when applied to a projection on a +// type with bound regions. In this case, we are checking that +// ` fn(&'r T) as TheTrait>::TheType: 'a` If we're not +// careful, we could wind up with a constraint that `'r:'a`, but since +// `'r` is bound, that leads to badness. This test checks that +// everything works. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait TheTrait { + type TheType; +} + +fn wf() { } + +type FnType = for<'r> fn(&'r T); + +fn foo<'a,'b,T>() + where FnType: TheTrait +{ + wf::< as TheTrait>::TheType >(); +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.stderr b/src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.stderr new file mode 100644 index 00000000000..ba4e318957e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-hrtype.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/regions-outlives-projection-hrtype.rs:36:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.rs b/src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.rs new file mode 100644 index 00000000000..04682a77297 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that `>::Type: 'b`, where `trait Foo<'a> { Type: +// 'a; }`, does not require that `F: 'b`. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait SomeTrait<'a> { + type Type: 'a; +} + +impl<'a: 'c, 'c, T> SomeTrait<'a> for &'c T where T: SomeTrait<'a> { + type Type = >::Type; + // ~~~~~~~~~~~~~~~~~~~~~~~~~~ + // | + // Note that this type must outlive 'a, due to the trait + // definition. If we fall back to OutlivesProjectionComponents + // here, then we would require that `T:'a`, which is too strong. +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.stderr b/src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.stderr new file mode 100644 index 00000000000..0a4cbe64d46 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-projection-trait-def.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/regions-outlives-projection-trait-def.rs:31:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-outlives-scalar.rs b/src/test/ui/compile-fail-migration/regions-outlives-scalar.rs new file mode 100644 index 00000000000..94f7a350cf7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-scalar.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that scalar values outlive all regions. +// Rule OutlivesScalar from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct Foo<'a> { + x: &'a i32, + y: &'static i32 +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/regions-outlives-scalar.stderr b/src/test/ui/compile-fail-migration/regions-outlives-scalar.stderr new file mode 100644 index 00000000000..d754bdd6032 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-outlives-scalar.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/regions-outlives-scalar.rs:23:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.nll.stderr b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.nll.stderr new file mode 100644 index 00000000000..c39d007312f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: `line` does not live long enough + --> $DIR/regions-pattern-typing-issue-19552.rs:15:14 + | +LL | match [&*line] { //~ ERROR `line` does not live long enough + | ^^^^ borrowed value does not live long enough +... +LL | } + | - `line` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.rs b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.rs new file mode 100644 index 00000000000..3401dd1becd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn assert_static(_t: T) {} + +fn main() { + let line = String::new(); + match [&*line] { //~ ERROR `line` does not live long enough + [ word ] => { assert_static(word); } + } +} diff --git a/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.stderr b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.stderr new file mode 100644 index 00000000000..cefedefa243 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19552.stderr @@ -0,0 +1,14 @@ +error[E0597]: `line` does not live long enough + --> $DIR/regions-pattern-typing-issue-19552.rs:15:14 + | +LL | match [&*line] { //~ ERROR `line` does not live long enough + | ^^^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.nll.stderr b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.nll.stderr new file mode 100644 index 00000000000..2acac5d5cf8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0506]: cannot assign to `a1` because it is borrowed + --> $DIR/regions-pattern-typing-issue-19997.rs:20:13 + | +LL | match (&a1,) { + | --- borrow of `a1` occurs here +LL | (&ref b0,) => { +LL | a1 = &f; //[ast]~ ERROR cannot assign + | ^^^^^^^ assignment to borrowed `a1` occurs here +LL | //[mir]~^ ERROR cannot assign to `a1` because it is borrowed +LL | drop(b0); + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.stderr b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.stderr new file mode 100644 index 00000000000..c26a0369740 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.ast.stderr @@ -0,0 +1,12 @@ +error[E0506]: cannot assign to `a1` because it is borrowed + --> $DIR/regions-pattern-typing-issue-19997.rs:20:13 + | +LL | match (&a1,) { + | -- borrow of `a1` occurs here +LL | (&ref b0,) => { +LL | a1 = &f; //[ast]~ ERROR cannot assign + | ^^^^^^^ assignment to borrowed `a1` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.mir.stderr b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.mir.stderr new file mode 100644 index 00000000000..2acac5d5cf8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.mir.stderr @@ -0,0 +1,15 @@ +error[E0506]: cannot assign to `a1` because it is borrowed + --> $DIR/regions-pattern-typing-issue-19997.rs:20:13 + | +LL | match (&a1,) { + | --- borrow of `a1` occurs here +LL | (&ref b0,) => { +LL | a1 = &f; //[ast]~ ERROR cannot assign + | ^^^^^^^ assignment to borrowed `a1` occurs here +LL | //[mir]~^ ERROR cannot assign to `a1` because it is borrowed +LL | drop(b0); + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.rs b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.rs new file mode 100644 index 00000000000..1f23dcbb725 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-pattern-typing-issue-19997.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn main() { + let a0 = 0; + let f = 1; + let mut a1 = &a0; + match (&a1,) { + (&ref b0,) => { + a1 = &f; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `a1` because it is borrowed + drop(b0); + } + } +} diff --git a/src/test/ui/compile-fail-migration/regions-proc-bound-capture.nll.stderr b/src/test/ui/compile-fail-migration/regions-proc-bound-capture.nll.stderr new file mode 100644 index 00000000000..00728aa4783 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-proc-bound-capture.nll.stderr @@ -0,0 +1,21 @@ +warning: not reporting region error due to nll + --> $DIR/regions-proc-bound-capture.rs:19:14 + | +LL | Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621] + | ^^^^^^^^^^^^^ + +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/regions-proc-bound-capture.rs:17:62 + | +LL | fn static_proc(x: &isize) -> Box(isize) + 'static> { + | ___________________------_____________________________________^ + | | | + | | help: add explicit lifetime `'static` to the type of `x`: `&'static isize` +LL | | // This is illegal, because the region bound on `proc` is 'static. +LL | | Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621] +LL | | } + | |_^ lifetime `'static` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-proc-bound-capture.rs b/src/test/ui/compile-fail-migration/regions-proc-bound-capture.rs new file mode 100644 index 00000000000..dd7b2bf9635 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-proc-bound-capture.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { + // This is legal, because the region bound on `proc` + // states that it captures `x`. + Box::new(move|| { *x }) +} + +fn static_proc(x: &isize) -> Box(isize) + 'static> { + // This is illegal, because the region bound on `proc` is 'static. + Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621] +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-proc-bound-capture.stderr b/src/test/ui/compile-fail-migration/regions-proc-bound-capture.stderr new file mode 100644 index 00000000000..b38543bdc43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-proc-bound-capture.stderr @@ -0,0 +1,12 @@ +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/regions-proc-bound-capture.rs:19:5 + | +LL | fn static_proc(x: &isize) -> Box(isize) + 'static> { + | ------ help: add explicit lifetime `'static` to the type of `x`: `&'static isize` +LL | // This is illegal, because the region bound on `proc` is 'static. +LL | Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621] + | ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr new file mode 100644 index 00000000000..761fa6f32ff --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr @@ -0,0 +1,20 @@ +warning: not reporting region error due to nll + --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:14:5 + | +LL | &mut ***p //~ ERROR 14:5: 14:14: lifetime mismatch [E0623] + | ^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:13:85 + | +LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { + | ______________________--__--_________________________________________________________^ + | | | | + | | | lifetime `'b` defined here + | | lifetime `'a` defined here +LL | | &mut ***p //~ ERROR 14:5: 14:14: lifetime mismatch [E0623] +LL | | } + | |_^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.rs b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.rs new file mode 100644 index 00000000000..f6f1a189e5e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #8624. Test for reborrowing with 3 levels, not just two. + +fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { + &mut ***p //~ ERROR 14:5: 14:14: lifetime mismatch [E0623] +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr new file mode 100644 index 00000000000..cddb60a4337 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:14:5 + | +LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { + | ----------------------------- ------------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | &mut ***p //~ ERROR 14:5: 14:14: lifetime mismatch [E0623] + | ^^^^^^^^^ ...but data from `p` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.nll.stderr b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.nll.stderr new file mode 100644 index 00000000000..c3eb6fd9097 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.nll.stderr @@ -0,0 +1,20 @@ +warning: not reporting region error due to nll + --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:16:5 + | +LL | &mut **p //~ ERROR 16:5: 16:13: lifetime mismatch [E0623] + | ^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:15:73 + | +LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { + | ______________________--__--_____________________________________________^ + | | | | + | | | lifetime `'b` defined here + | | lifetime `'a` defined here +LL | | &mut **p //~ ERROR 16:5: 16:13: lifetime mismatch [E0623] +LL | | } + | |_^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.rs b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.rs new file mode 100644 index 00000000000..7270b477d2d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #8624. Tests that reborrowing the contents of an `&'b mut` +// pointer which is backed by another `&'a mut` can only be done +// for `'a` (which must be a sublifetime of `'b`). + +fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { + &mut **p //~ ERROR 16:5: 16:13: lifetime mismatch [E0623] +} + +fn main() { + let mut x = 1; + let mut y = &mut x; + let z = copy_borrowed_ptr(&mut y); + *y += 1; + *z += 1; +} diff --git a/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.stderr b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.stderr new file mode 100644 index 00000000000..9f8d0168ede --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-reborrow-from-shorter-mut-ref.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:16:5 + | +LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { + | --------------------- ------------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | &mut **p //~ ERROR 16:5: 16:13: lifetime mismatch [E0623] + | ^^^^^^^^ ...but data from `p` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.nll.stderr b/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.nll.stderr new file mode 100644 index 00000000000..87fe858769d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.nll.stderr @@ -0,0 +1,22 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-ref-in-fn-arg.rs:14:13 + | +LL | fn arg_item(box ref x: Box) -> &'static isize { + | ^^^^^^^^^ temporary value does not live long enough +LL | x //~^ ERROR borrowed value does not live long enough +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-ref-in-fn-arg.rs:21:11 + | +LL | with(|box ref x| x) //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^ - temporary value only lives until here + | | + | temporary value does not live long enough + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.rs b/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.rs new file mode 100644 index 00000000000..bc8060e3915 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_patterns)] +#![feature(box_syntax)] + +fn arg_item(box ref x: Box) -> &'static isize { + x //~^ ERROR borrowed value does not live long enough +} + +fn with(f: F) -> R where F: FnOnce(Box) -> R { f(box 3) } + +fn arg_closure() -> &'static isize { + with(|box ref x| x) //~ ERROR borrowed value does not live long enough +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.stderr b/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.stderr new file mode 100644 index 00000000000..0250f6e26fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ref-in-fn-arg.stderr @@ -0,0 +1,24 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-ref-in-fn-arg.rs:14:17 + | +LL | fn arg_item(box ref x: Box) -> &'static isize { + | ^^^^^ borrowed value does not live long enough +LL | x //~^ ERROR borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-ref-in-fn-arg.rs:21:15 + | +LL | with(|box ref x| x) //~ ERROR borrowed value does not live long enough + | ^^^^^ - borrowed value only lives until here + | | + | borrowed value does not live long enough + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.nll.stderr b/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.nll.stderr new file mode 100644 index 00000000000..ae53ab692bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-ret-borrowed-1.rs:20:14 + | +LL | with(|o| o) + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-ret-borrowed-1.rs:20:14 + | +LL | with(|o| o) + | ----^ + | || | + | || return requires that `'1` must outlive `'2` + | |has type `&'1 isize` + | lifetime `'2` appears in return type + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.rs b/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.rs new file mode 100644 index 00000000000..b8cebe66518 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Similar to regions-ret-borrowed.rs, but using a named lifetime. At +// some point regions-ret-borrowed reported an error but this file did +// not, due to special hardcoding around the anonymous region. + +fn with(f: F) -> R where F: for<'a> FnOnce(&'a isize) -> R { + f(&3) +} + +fn return_it<'a>() -> &'a isize { + with(|o| o) + //~^ ERROR cannot infer +} + +fn main() { + let x = return_it(); + println!("foo={}", *x); +} diff --git a/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.stderr b/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.stderr new file mode 100644 index 00000000000..ac886bcbc7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret-borrowed-1.stderr @@ -0,0 +1,28 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-ret-borrowed-1.rs:20:14 + | +LL | with(|o| o) + | ^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 20:10... + --> $DIR/regions-ret-borrowed-1.rs:20:10 + | +LL | with(|o| o) + | ^^^^^ + = note: ...so that the expression is assignable: + expected &isize + found &isize +note: but, the lifetime must be valid for the lifetime 'a as defined on the function body at 19:14... + --> $DIR/regions-ret-borrowed-1.rs:19:14 + | +LL | fn return_it<'a>() -> &'a isize { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-ret-borrowed-1.rs:20:5 + | +LL | with(|o| o) + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-ret-borrowed.nll.stderr b/src/test/ui/compile-fail-migration/regions-ret-borrowed.nll.stderr new file mode 100644 index 00000000000..8d782b19723 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret-borrowed.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-ret-borrowed.rs:23:14 + | +LL | with(|o| o) + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-ret-borrowed.rs:23:14 + | +LL | with(|o| o) + | ----^ + | || | + | || return requires that `'1` must outlive `'2` + | |has type `&'1 isize` + | lifetime `'2` appears in return type + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-ret-borrowed.rs b/src/test/ui/compile-fail-migration/regions-ret-borrowed.rs new file mode 100644 index 00000000000..40909ddd4ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret-borrowed.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that you cannot use generic types to return a region outside +// of its bound. Here, in the `return_it()` fn, we call with() but +// with R bound to &isize from the return_it. Meanwhile, with() +// provides a value that is only good within its own stack frame. This +// used to successfully compile because we failed to account for the +// fact that fn(x: &isize) rebound the region &. + +fn with(f: F) -> R where F: FnOnce(&isize) -> R { + f(&3) +} + +fn return_it<'a>() -> &'a isize { + with(|o| o) + //~^ ERROR cannot infer +} + +fn main() { + let x = return_it(); + println!("foo={}", *x); +} diff --git a/src/test/ui/compile-fail-migration/regions-ret-borrowed.stderr b/src/test/ui/compile-fail-migration/regions-ret-borrowed.stderr new file mode 100644 index 00000000000..36c4ce7e174 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret-borrowed.stderr @@ -0,0 +1,28 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-ret-borrowed.rs:23:14 + | +LL | with(|o| o) + | ^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 23:10... + --> $DIR/regions-ret-borrowed.rs:23:10 + | +LL | with(|o| o) + | ^^^^^ + = note: ...so that the expression is assignable: + expected &isize + found &isize +note: but, the lifetime must be valid for the lifetime 'a as defined on the function body at 22:14... + --> $DIR/regions-ret-borrowed.rs:22:14 + | +LL | fn return_it<'a>() -> &'a isize { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-ret-borrowed.rs:23:5 + | +LL | with(|o| o) + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-ret.nll.stderr b/src/test/ui/compile-fail-migration/regions-ret.nll.stderr new file mode 100644 index 00000000000..cacc119d410 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret.nll.stderr @@ -0,0 +1,19 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-ret.rs:14:13 + | +LL | return &id(3); //~ ERROR borrowed value does not live long enough + | ^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 13:1... + --> $DIR/regions-ret.rs:13:1 + | +LL | / fn f(_x: &isize) -> &isize { +LL | | return &id(3); //~ ERROR borrowed value does not live long enough +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-ret.rs b/src/test/ui/compile-fail-migration/regions-ret.rs new file mode 100644 index 00000000000..c7cd3ced98d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn id(x: T) -> T { x } + +fn f(_x: &isize) -> &isize { + return &id(3); //~ ERROR borrowed value does not live long enough +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-ret.stderr b/src/test/ui/compile-fail-migration/regions-ret.stderr new file mode 100644 index 00000000000..84515a9b44c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-ret.stderr @@ -0,0 +1,20 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-ret.rs:14:13 + | +LL | return &id(3); //~ ERROR borrowed value does not live long enough + | ^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 13:1... + --> $DIR/regions-ret.rs:13:1 + | +LL | / fn f(_x: &isize) -> &isize { +LL | | return &id(3); //~ ERROR borrowed value does not live long enough +LL | | } + | |_^ + = note: consider using a `let` binding to increase its lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.nll.stderr b/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.nll.stderr new file mode 100644 index 00000000000..e3b981a1bf6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:17:24 + | +LL | let mut f = || &mut x; //~ ERROR cannot infer + | ^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:17:24 + | +LL | let mut f = || &mut x; //~ ERROR cannot infer + | ---^^^^^^ + | | | + | | return requires that `'1` must outlive `'2` + | lifetime `'1` represents the closure body + | lifetime `'2` appears in return type + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.rs b/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.rs new file mode 100644 index 00000000000..99e5cc03153 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that closures cannot subvert aliasing restrictions + +fn main() { + // Unboxed closure case + { + let mut x = 0; + let mut f = || &mut x; //~ ERROR cannot infer + let x = f(); + let y = f(); + } +} diff --git a/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.stderr b/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.stderr new file mode 100644 index 00000000000..c841c9605bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-return-ref-to-upvar-issue-17403.stderr @@ -0,0 +1,30 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:17:24 + | +LL | let mut f = || &mut x; //~ ERROR cannot infer + | ^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime as defined on the body at 17:21... + --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:17:21 + | +LL | let mut f = || &mut x; //~ ERROR cannot infer + | ^^^^^^^^^ +note: ...so that closure can access `x` + --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:17:24 + | +LL | let mut f = || &mut x; //~ ERROR cannot infer + | ^^^^^^ +note: but, the lifetime must be valid for the call at 19:17... + --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:19:17 + | +LL | let y = f(); + | ^^^ +note: ...so type `&mut i32` of expression is valid during the expression + --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:19:17 + | +LL | let y = f(); + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.rs b/src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.rs new file mode 100644 index 00000000000..b5d4e07d04b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we cannot return a stack allocated slice + +fn function(x: isize) -> &'static [isize] { + &[x] //~ ERROR borrowed value does not live long enough +} + +fn main() { + let x = function(1); + let y = x[0]; +} diff --git a/src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.stderr b/src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.stderr new file mode 100644 index 00000000000..77c1d177acb --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-return-stack-allocated-vec.stderr @@ -0,0 +1,13 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-return-stack-allocated-vec.rs:14:6 + | +LL | &[x] //~ ERROR borrowed value does not live long enough + | ^^^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-static-bound.ll.nll.stderr b/src/test/ui/compile-fail-migration/regions-static-bound.ll.nll.stderr new file mode 100644 index 00000000000..aaae14fede6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-static-bound.ll.nll.stderr @@ -0,0 +1,46 @@ +warning: not reporting region error due to nll + --> $DIR/regions-static-bound.rs:19:5 + | +LL | t //[ll]~ ERROR E0312 + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-static-bound.rs:25:5 + | +LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + | ^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-static-bound.rs:28:5 + | +LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + | ^^^^^^^^^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-static-bound.rs:19:5 + | +LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { + | -- lifetime `'a` defined here +LL | t //[ll]~ ERROR E0312 + | ^ return requires that `'a` must outlive `'static` + +error[E0621]: explicit lifetime required in the type of `u` + --> $DIR/regions-static-bound.rs:25:5 + | +LL | fn error(u: &(), v: &()) { + | --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()` +LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + | ^^^^^^^^^^^^^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/regions-static-bound.rs:28:5 + | +LL | fn error(u: &(), v: &()) { + | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` +... +LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + | ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-static-bound.ll.stderr b/src/test/ui/compile-fail-migration/regions-static-bound.ll.stderr new file mode 100644 index 00000000000..4a11677765d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-static-bound.ll.stderr @@ -0,0 +1,34 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-static-bound.rs:19:5 + | +LL | t //[ll]~ ERROR E0312 + | ^ + | + = note: ...the reference is valid for the static lifetime... +note: ...but the borrowed content is only valid for the lifetime 'a as defined on the function body at 18:24 + --> $DIR/regions-static-bound.rs:18:24 + | +LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { + | ^^ + +error[E0621]: explicit lifetime required in the type of `u` + --> $DIR/regions-static-bound.rs:25:5 + | +LL | fn error(u: &(), v: &()) { + | --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()` +LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + | ^^^^^^^^^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/regions-static-bound.rs:28:5 + | +LL | fn error(u: &(), v: &()) { + | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` +... +LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + | ^^^^^^^^^^^^^^^^^^ lifetime `'static` required + +error: aborting due to 3 previous errors + +Some errors occurred: E0312, E0621. +For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/regions-static-bound.nll.stderr b/src/test/ui/compile-fail-migration/regions-static-bound.nll.stderr new file mode 100644 index 00000000000..aaae14fede6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-static-bound.nll.stderr @@ -0,0 +1,46 @@ +warning: not reporting region error due to nll + --> $DIR/regions-static-bound.rs:19:5 + | +LL | t //[ll]~ ERROR E0312 + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-static-bound.rs:25:5 + | +LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + | ^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/regions-static-bound.rs:28:5 + | +LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + | ^^^^^^^^^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-static-bound.rs:19:5 + | +LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { + | -- lifetime `'a` defined here +LL | t //[ll]~ ERROR E0312 + | ^ return requires that `'a` must outlive `'static` + +error[E0621]: explicit lifetime required in the type of `u` + --> $DIR/regions-static-bound.rs:25:5 + | +LL | fn error(u: &(), v: &()) { + | --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()` +LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + | ^^^^^^^^^^^^^ lifetime `'static` required + +error[E0621]: explicit lifetime required in the type of `v` + --> $DIR/regions-static-bound.rs:28:5 + | +LL | fn error(u: &(), v: &()) { + | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` +... +LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + | ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/regions-static-bound.rs b/src/test/ui/compile-fail-migration/regions-static-bound.rs new file mode 100644 index 00000000000..0a37df4f0c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-static-bound.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ll nll +//[nll] compile-flags:-Zborrowck=mir + +fn static_id<'a,'b>(t: &'a ()) -> &'static () + where 'a: 'static { t } +fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () + where 'a: 'b, 'b: 'static { t } +fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { + t //[ll]~ ERROR E0312 + //[nll]~^ WARNING not reporting region error due to nll + //[nll]~| ERROR unsatisfied lifetime constraints +} + +fn error(u: &(), v: &()) { + static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + //[nll]~^ WARNING not reporting region error due to nll + //[nll]~| ERROR explicit lifetime required in the type of `u` [E0621] + static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + //[nll]~^ WARNING not reporting region error due to nll + //[nll]~| ERROR explicit lifetime required in the type of `v` [E0621] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-steal-closure.nll.stderr b/src/test/ui/compile-fail-migration/regions-steal-closure.nll.stderr new file mode 100644 index 00000000000..ed70e38362d --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-steal-closure.nll.stderr @@ -0,0 +1,15 @@ +error[E0597]: `i` does not live long enough + --> $DIR/regions-steal-closure.rs:24:28 + | +LL | box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough + | -- ^ borrowed value does not live long enough + | | + | value captured here +LL | }; + | - `i` dropped here while still borrowed +LL | cl_box.cl.call_mut(()); + | --------- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-steal-closure.rs b/src/test/ui/compile-fail-migration/regions-steal-closure.rs new file mode 100644 index 00000000000..7ca63b9896f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-steal-closure.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(fn_traits)] + +struct closure_box<'a> { + cl: Box, +} + +fn box_it<'r>(x: Box) -> closure_box<'r> { + closure_box {cl: x} +} + +fn main() { + let mut cl_box = { + let mut i = 3; + box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough + }; + cl_box.cl.call_mut(()); +} diff --git a/src/test/ui/compile-fail-migration/regions-steal-closure.stderr b/src/test/ui/compile-fail-migration/regions-steal-closure.stderr new file mode 100644 index 00000000000..44843d19e92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-steal-closure.stderr @@ -0,0 +1,16 @@ +error[E0597]: `i` does not live long enough + --> $DIR/regions-steal-closure.rs:24:28 + | +LL | box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough + | -- ^ borrowed value does not live long enough + | | + | capture occurs here +LL | }; + | - borrowed value only lives until here +LL | cl_box.cl.call_mut(()); +LL | } + | - borrowed value needs to live until here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-struct-not-wf.lexical.stderr b/src/test/ui/compile-fail-migration/regions-struct-not-wf.lexical.stderr new file mode 100644 index 00000000000..9433b8b1952 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-struct-not-wf.lexical.stderr @@ -0,0 +1,49 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | struct Ref<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: &'a T + | ^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | field: &'a T + | ^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | struct RefIndirect<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-struct-not-wf.rs:35:5 + | +LL | field: &'a &'b T + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 34:18 + --> $DIR/regions-struct-not-wf.rs:34:18 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 34:22 + --> $DIR/regions-struct-not-wf.rs:34:22 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-struct-not-wf.nll.stderr b/src/test/ui/compile-fail-migration/regions-struct-not-wf.nll.stderr new file mode 100644 index 00000000000..9433b8b1952 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-struct-not-wf.nll.stderr @@ -0,0 +1,49 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | struct Ref<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: &'a T + | ^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | field: &'a T + | ^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | struct RefIndirect<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-struct-not-wf.rs:35:5 + | +LL | field: &'a &'b T + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 34:18 + --> $DIR/regions-struct-not-wf.rs:34:18 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 34:22 + --> $DIR/regions-struct-not-wf.rs:34:22 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/regions-struct-not-wf.rs b/src/test/ui/compile-fail-migration/regions-struct-not-wf.rs new file mode 100644 index 00000000000..9106f1f0ba6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-struct-not-wf.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various examples of structs whose fields are not well-formed. + +// revisions:lexical nll + +#![allow(dead_code)] +#![cfg_attr(nll, feature(nll))] + +struct Ref<'a, T> { + field: &'a T + //[lexical]~^ ERROR the parameter type `T` may not live long enough + //[nll]~^^ ERROR the parameter type `T` may not live long enough +} + +struct RefOk<'a, T:'a> { + field: &'a T +} + +struct RefIndirect<'a, T> { + field: RefOk<'a, T> + //[lexical]~^ ERROR the parameter type `T` may not live long enough + //[nll]~^^ ERROR the parameter type `T` may not live long enough +} + +struct DoubleRef<'a, 'b, T> { + field: &'a &'b T + //[lexical]~^ ERROR reference has a longer lifetime than the data it references + //[nll]~^^ ERROR reference has a longer lifetime than the data it references +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-trait-1.rs b/src/test/ui/compile-fail-migration/regions-trait-1.rs new file mode 100644 index 00000000000..9cd08656b62 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-1.rs @@ -0,0 +1,40 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct ctxt { v: usize } + +trait get_ctxt { + // Here the `&` is bound in the method definition: + fn get_ctxt(&self) -> &ctxt; +} + +struct has_ctxt<'a> { c: &'a ctxt } + +impl<'a> get_ctxt for has_ctxt<'a> { + + // Here an error occurs because we used `&self` but + // the definition used `&`: + fn get_ctxt(&self) -> &'a ctxt { //~ ERROR method not compatible with trait + self.c + } + +} + +fn get_v(gc: Box) -> usize { + gc.get_ctxt().v +} + +fn main() { + let ctxt = ctxt { v: 22 }; + let hc = has_ctxt { c: &ctxt }; + assert_eq!(get_v(box hc as Box), 22); +} diff --git a/src/test/ui/compile-fail-migration/regions-trait-1.stderr b/src/test/ui/compile-fail-migration/regions-trait-1.stderr new file mode 100644 index 00000000000..dbc47a55950 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-1.stderr @@ -0,0 +1,24 @@ +error[E0308]: method not compatible with trait + --> $DIR/regions-trait-1.rs:26:5 + | +LL | fn get_ctxt(&self) -> &'a ctxt { //~ ERROR method not compatible with trait + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `fn(&has_ctxt<'a>) -> &ctxt` + found type `fn(&has_ctxt<'a>) -> &'a ctxt` +note: the lifetime 'a as defined on the impl at 22:6... + --> $DIR/regions-trait-1.rs:22:6 + | +LL | impl<'a> get_ctxt for has_ctxt<'a> { + | ^^ +note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 26:5 + --> $DIR/regions-trait-1.rs:26:5 + | +LL | / fn get_ctxt(&self) -> &'a ctxt { //~ ERROR method not compatible with trait +LL | | self.c +LL | | } + | |_____^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.nll.stderr b/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.nll.stderr new file mode 100644 index 00000000000..3d884f6fc5f --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.nll.stderr @@ -0,0 +1,39 @@ +warning: not reporting region error due to nll + --> $DIR/regions-trait-object-subtyping.rs:25:5 + | +LL | x //~ ERROR lifetime bound not satisfied + | ^ + +warning: not reporting region error due to nll + --> $DIR/regions-trait-object-subtyping.rs:32:5 + | +LL | x //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/regions-trait-object-subtyping.rs:23:51 + | +LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { + | _________--_--_____________________________________^ + | | | | + | | | lifetime `'b` defined here + | | lifetime `'a` defined here +LL | | // Without knowing 'a:'b, we can't coerce +LL | | x //~ ERROR lifetime bound not satisfied +LL | | //~^ ERROR cannot infer an appropriate lifetime +LL | | } + | |_^ return requires that `'a` must outlive `'b` + +error: unsatisfied lifetime constraints + --> $DIR/regions-trait-object-subtyping.rs:32:5 + | +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | // We can't coerce because it is packed in `Wrapper` +LL | x //~ ERROR mismatched types + | ^ return requires that `'b` must outlive `'a` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.rs b/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.rs new file mode 100644 index 00000000000..948fb7e1ef6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Dummy { fn dummy(&self); } + +fn foo1<'a:'b,'b>(x: &'a mut (Dummy+'a)) -> &'b mut (Dummy+'b) { + // Here, we are able to coerce + x +} + +fn foo2<'a:'b,'b>(x: &'b mut (Dummy+'a)) -> &'b mut (Dummy+'b) { + // Here, we are able to coerce + x +} + +fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { + // Without knowing 'a:'b, we can't coerce + x //~ ERROR lifetime bound not satisfied + //~^ ERROR cannot infer an appropriate lifetime +} + +struct Wrapper(T); +fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { + // We can't coerce because it is packed in `Wrapper` + x //~ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.stderr b/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.stderr new file mode 100644 index 00000000000..1b078855efd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-object-subtyping.stderr @@ -0,0 +1,65 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-trait-object-subtyping.rs:25:5 + | +LL | x //~ ERROR lifetime bound not satisfied + | ^ + | +note: lifetime parameter instantiated with the lifetime 'a as defined on the function body at 23:9 + --> $DIR/regions-trait-object-subtyping.rs:23:9 + | +LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { + | ^^ +note: but lifetime parameter must outlive the lifetime 'b as defined on the function body at 23:12 + --> $DIR/regions-trait-object-subtyping.rs:23:12 + | +LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { + | ^^ + +error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements + --> $DIR/regions-trait-object-subtyping.rs:25:5 + | +LL | x //~ ERROR lifetime bound not satisfied + | ^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 23:9... + --> $DIR/regions-trait-object-subtyping.rs:23:9 + | +LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { + | ^^ +note: ...so that the type `(dyn Dummy + 'a)` is not borrowed for too long + --> $DIR/regions-trait-object-subtyping.rs:25:5 + | +LL | x //~ ERROR lifetime bound not satisfied + | ^ +note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 23:12... + --> $DIR/regions-trait-object-subtyping.rs:23:12 + | +LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { + | ^^ + = note: ...so that the expression is assignable: + expected &'b mut (dyn Dummy + 'b) + found &mut (dyn Dummy + 'b) + +error[E0308]: mismatched types + --> $DIR/regions-trait-object-subtyping.rs:32:5 + | +LL | x //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `Wrapper<&'b mut (dyn Dummy + 'b)>` + found type `Wrapper<&'a mut (dyn Dummy + 'a)>` +note: the lifetime 'b as defined on the function body at 30:15... + --> $DIR/regions-trait-object-subtyping.rs:30:15 + | +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { + | ^^ +note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 30:9 + --> $DIR/regions-trait-object-subtyping.rs:30:9 + | +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { + | ^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0308, E0478, E0495. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-trait-variance.nll.stderr b/src/test/ui/compile-fail-migration/regions-trait-variance.nll.stderr new file mode 100644 index 00000000000..c610394c51b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-variance.nll.stderr @@ -0,0 +1,18 @@ +error[E0597]: `*b` does not live long enough + --> $DIR/regions-trait-variance.rs:47:18 + | +LL | let bb: &B = &*b; //~ ERROR `*b` does not live long enough + | ^^^ borrowed value does not live long enough +LL | make_a(bb) +LL | } + | - `*b` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 43:16... + --> $DIR/regions-trait-variance.rs:43:16 + | +LL | fn make_make_a<'a>() -> A<'a> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-trait-variance.rs b/src/test/ui/compile-fail-migration/regions-trait-variance.rs new file mode 100644 index 00000000000..9ba4ef4e358 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-variance.rs @@ -0,0 +1,54 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +// Issue #12470. + +trait X { + fn get_i(&self) -> isize; +} + +struct B { + i: isize +} + +impl X for B { + fn get_i(&self) -> isize { + self.i + } +} + +impl Drop for B { + fn drop(&mut self) { + println!("drop"); + } +} + +struct A<'r> { + p: &'r (X+'r) +} + +fn make_a(p:&X) -> A { + A{p:p} +} + +fn make_make_a<'a>() -> A<'a> { + let b: Box = box B { + i: 1, + }; + let bb: &B = &*b; //~ ERROR `*b` does not live long enough + make_a(bb) +} + +fn main() { + let a = make_make_a(); + println!("{}", a.p.get_i()); +} diff --git a/src/test/ui/compile-fail-migration/regions-trait-variance.stderr b/src/test/ui/compile-fail-migration/regions-trait-variance.stderr new file mode 100644 index 00000000000..cd48d6bf8af --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-trait-variance.stderr @@ -0,0 +1,18 @@ +error[E0597]: `*b` does not live long enough + --> $DIR/regions-trait-variance.rs:47:19 + | +LL | let bb: &B = &*b; //~ ERROR `*b` does not live long enough + | ^^ borrowed value does not live long enough +LL | make_a(bb) +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 43:16... + --> $DIR/regions-trait-variance.rs:43:16 + | +LL | fn make_make_a<'a>() -> A<'a> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-undeclared.rs b/src/test/ui/compile-fail-migration/regions-undeclared.rs new file mode 100644 index 00000000000..31908751580 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-undeclared.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static c_x: &'blk isize = &22; //~ ERROR use of undeclared lifetime name `'blk` + +enum EnumDecl { + Foo(&'a isize), //~ ERROR use of undeclared lifetime name `'a` + Bar(&'a isize), //~ ERROR use of undeclared lifetime name `'a` +} + +fn fnDecl(x: &'a isize, //~ ERROR use of undeclared lifetime name `'a` + y: &'a isize) //~ ERROR use of undeclared lifetime name `'a` +{} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/regions-undeclared.stderr b/src/test/ui/compile-fail-migration/regions-undeclared.stderr new file mode 100644 index 00000000000..9870f328abe --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-undeclared.stderr @@ -0,0 +1,33 @@ +error[E0261]: use of undeclared lifetime name `'blk` + --> $DIR/regions-undeclared.rs:11:14 + | +LL | static c_x: &'blk isize = &22; //~ ERROR use of undeclared lifetime name `'blk` + | ^^^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-undeclared.rs:14:10 + | +LL | Foo(&'a isize), //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-undeclared.rs:15:10 + | +LL | Bar(&'a isize), //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-undeclared.rs:18:15 + | +LL | fn fnDecl(x: &'a isize, //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/regions-undeclared.rs:19:15 + | +LL | y: &'a isize) //~ ERROR use of undeclared lifetime name `'a` + | ^^ undeclared lifetime + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.nll.stderr b/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.nll.stderr new file mode 100644 index 00000000000..54b1a6fa970 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.nll.stderr @@ -0,0 +1,15 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-var-type-out-of-scope.rs:19:14 + | +LL | x = &id(3); //~ ERROR borrowed value does not live long enough + | ^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough +LL | assert_eq!(*x, 3); + | ------------------ borrow later used here + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.rs b/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.rs new file mode 100644 index 00000000000..031091c4523 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn id(x: T) -> T { x } + +fn foo(cond: bool) { + // Here we will infer a type that uses the + // region of the if stmt then block: + let mut x; + + if cond { + x = &id(3); //~ ERROR borrowed value does not live long enough + assert_eq!(*x, 3); + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.stderr b/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.stderr new file mode 100644 index 00000000000..92a6451c3bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-var-type-out-of-scope.stderr @@ -0,0 +1,16 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/regions-var-type-out-of-scope.rs:19:14 + | +LL | x = &id(3); //~ ERROR borrowed value does not live long enough + | ^^^^^- temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +... +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.rs b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.rs new file mode 100644 index 00000000000..1dfebd54ec3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.rs @@ -0,0 +1,38 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a type which is covariant with respect to its region +// parameter yields an error when used in a contravariant way. +// +// Note: see variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +// `S` is contravariant with respect to both parameters. +struct S<'a, 'b> { + f: &'a isize, + g: &'b isize, +} + +fn use_<'short,'long>(c: S<'long, 'short>, + s: &'short isize, + l: &'long isize, + _where:Option<&'short &'long ()>) { + + let _: S<'long, 'short> = c; // OK + let _: S<'short, 'short> = c; // OK + + // Test whether S<_,'short> <: S<_,'long>. Since + // 'short <= 'long, this would be true if the Contravariant type were + // covariant with respect to its parameter 'a. + + let _: S<'long, 'long> = c; //~ ERROR E0623 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.stderr b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.stderr new file mode 100644 index 00000000000..45105e8714c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant-in-second-position.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:35:30 + | +LL | fn use_<'short,'long>(c: S<'long, 'short>, + | ---------------- + | | + | this type is declared with multiple lifetimes... +... +LL | let _: S<'long, 'long> = c; //~ ERROR E0623 + | ^ ...but data with one lifetime flows into the other here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.rs b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.rs new file mode 100644 index 00000000000..caf6a86fc0b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.rs @@ -0,0 +1,36 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a type which is covariant with respect to its region +// parameter yields an error when used in a contravariant way. +// +// Note: see variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +// This is contravariant with respect to 'a, meaning that +// Contravariant<'long> <: Contravariant<'short> iff +// 'short <= 'long +struct Contravariant<'a> { + f: &'a isize +} + +fn use_<'short,'long>(c: Contravariant<'short>, + s: &'short isize, + l: &'long isize, + _where:Option<&'short &'long ()>) { + + // Test whether Contravariant<'short> <: Contravariant<'long>. Since + // 'short <= 'long, this would be true if the Contravariant type were + // covariant with respect to its parameter 'a. + + let _: Contravariant<'long> = c; //~ ERROR E0623 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.stderr b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.stderr new file mode 100644 index 00000000000..c883691c348 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-contravariant-use-covariant.stderr @@ -0,0 +1,15 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-contravariant-use-covariant.rs:33:35 + | +LL | fn use_<'short,'long>(c: Contravariant<'short>, + | --------------------- these two types are declared with different lifetimes... +LL | s: &'short isize, +LL | l: &'long isize, + | ------------ +... +LL | let _: Contravariant<'long> = c; //~ ERROR E0623 + | ^ ...but data from `c` flows into `l` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.rs b/src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.rs new file mode 100644 index 00000000000..60dc3d94a2e --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.rs @@ -0,0 +1,36 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a type which is covariant with respect to its region +// parameter yields an error when used in a contravariant way. +// +// Note: see variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +// This is covariant with respect to 'a, meaning that +// Covariant<'foo> <: Covariant<'static> because +// 'foo <= 'static +struct Covariant<'a> { + f: extern "Rust" fn(&'a isize) +} + +fn use_<'short,'long>(c: Covariant<'long>, + s: &'short isize, + l: &'long isize, + _where:Option<&'short &'long ()>) { + + // Test whether Covariant<'long> <: Covariant<'short>. Since + // 'short <= 'long, this would be true if the Covariant type were + // contravariant with respect to its parameter 'a. + + let _: Covariant<'short> = c; //~ ERROR E0623 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.stderr b/src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.stderr new file mode 100644 index 00000000000..a448d26f81b --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-covariant-use-contravariant.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-covariant-use-contravariant.rs:33:32 + | +LL | fn use_<'short,'long>(c: Covariant<'long>, + | ---------------- +LL | s: &'short isize, + | ------------- these two types are declared with different lifetimes... +... +LL | let _: Covariant<'short> = c; //~ ERROR E0623 + | ^ ...but data from `s` flows into `c` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.rs b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.rs new file mode 100644 index 00000000000..96478fa5909 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an invariant region parameter used in a contravariant way +// yields an error. +// +// Note: see variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +struct Invariant<'a> { + f: &'a mut &'a isize +} + +fn use_<'short,'long>(c: Invariant<'long>, + s: &'short isize, + l: &'long isize, + _where:Option<&'short &'long ()>) { + + // Test whether Invariant<'long> <: Invariant<'short>. Since + // 'short <= 'long, this would be true if the Invariant type were + // contravariant with respect to its parameter 'a. + + let _: Invariant<'short> = c; //~ ERROR E0623 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.stderr b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.stderr new file mode 100644 index 00000000000..1b0cd8e646a --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-contravariant.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-invariant-use-contravariant.rs:30:32 + | +LL | fn use_<'short,'long>(c: Invariant<'long>, + | ---------------- +LL | s: &'short isize, + | ------------- these two types are declared with different lifetimes... +... +LL | let _: Invariant<'short> = c; //~ ERROR E0623 + | ^ ...but data from `s` flows into `c` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.rs b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.rs new file mode 100644 index 00000000000..bd944a8b52c --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a type which is invariant with respect to its region +// parameter used in a covariant way yields an error. +// +// Note: see variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +struct Invariant<'a> { + f: &'a mut &'a isize +} + +fn use_<'b>(c: Invariant<'b>) { + + // For this assignment to be legal, Invariant<'b> <: Invariant<'static>. + // Since 'b <= 'static, this would be true if Invariant were covariant + // with respect to its parameter 'a. + + let _: Invariant<'static> = c; //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.stderr b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.stderr new file mode 100644 index 00000000000..34111120a08 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-variance-invariant-use-covariant.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-variance-invariant-use-covariant.rs:27:33 + | +LL | let _: Invariant<'static> = c; //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `Invariant<'static>` + found type `Invariant<'b>` +note: the lifetime 'b as defined on the function body at 21:9... + --> $DIR/regions-variance-invariant-use-covariant.rs:21:9 + | +LL | fn use_<'b>(c: Invariant<'b>) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/regions-wf-trait-object.rs b/src/test/ui/compile-fail-migration/regions-wf-trait-object.rs new file mode 100644 index 00000000000..39b8482cfa3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-wf-trait-object.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that the explicit lifetime bound (`'b`, in this example) must +// outlive all the superbound from the trait (`'a`, in this example). + +trait TheTrait<'t>: 't { } + +struct Foo<'a,'b> { + x: Box+'b> //~ ERROR E0478 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/regions-wf-trait-object.stderr b/src/test/ui/compile-fail-migration/regions-wf-trait-object.stderr new file mode 100644 index 00000000000..caaa902abbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/regions-wf-trait-object.stderr @@ -0,0 +1,20 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-wf-trait-object.rs:17:5 + | +LL | x: Box+'b> //~ ERROR E0478 + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lifetime parameter instantiated with the lifetime 'b as defined on the struct at 16:15 + --> $DIR/regions-wf-trait-object.rs:16:15 + | +LL | struct Foo<'a,'b> { + | ^^ +note: but lifetime parameter must outlive the lifetime 'a as defined on the struct at 16:12 + --> $DIR/regions-wf-trait-object.rs:16:12 + | +LL | struct Foo<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/compile-fail-migration/reject-specialized-drops-8142.rs b/src/test/ui/compile-fail-migration/reject-specialized-drops-8142.rs new file mode 100644 index 00000000000..1ea956bbd54 --- /dev/null +++ b/src/test/ui/compile-fail-migration/reject-specialized-drops-8142.rs @@ -0,0 +1,67 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue 8142: Test that Drop impls cannot be specialized beyond the +// predicates attached to the struct/enum definition itself. + +trait Bound { fn foo(&self) { } } +struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } +struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } +struct M<'m> { x: &'m i8 } +struct N<'n> { x: &'n i8 } +struct O { x: *const To } +struct P { x: *const Tp } +struct Q { x: *const Tq } +struct R { x: *const Tr } +struct S { x: *const Ts } +struct T<'t,Ts:'t> { x: &'t Ts } +struct U; +struct V { x: *const Tva, y: *const Tvb } +struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } + +impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT + //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl. + fn drop(&mut self) { } } + +impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT + //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl. + fn drop(&mut self) { } } + +impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT + +impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT +//~^ ERROR mismatched types +//~| expected type `N<'n>` +//~| found type `N<'static>` + +impl Drop for O { fn drop(&mut self) { } } // ACCEPT + +impl Drop for P { fn drop(&mut self) { } } // REJECT +//~^ ERROR Implementations of Drop cannot be specialized + +impl Drop for Q { fn drop(&mut self) { } } // REJECT +//~^ ERROR The requirement `Adds_bnd: Bound` is added only by the Drop impl. + +impl<'rbnd,Adds_rbnd:'rbnd> Drop for R { fn drop(&mut self) { } } // REJECT +//~^ ERROR The requirement `Adds_rbnd : 'rbnd` is added only by the Drop impl. + +impl Drop for S { fn drop(&mut self) { } } // ACCEPT + +impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT + +impl Drop for U { fn drop(&mut self) { } } // ACCEPT + +impl Drop for V { fn drop(&mut self) { } } // REJECT +//~^ ERROR Implementations of Drop cannot be specialized + +impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT +//~^ ERROR cannot infer an appropriate lifetime + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/reject-specialized-drops-8142.stderr b/src/test/ui/compile-fail-migration/reject-specialized-drops-8142.stderr new file mode 100644 index 00000000000..c0f1525a761 --- /dev/null +++ b/src/test/ui/compile-fail-migration/reject-specialized-drops-8142.stderr @@ -0,0 +1,115 @@ +error[E0367]: The requirement `'adds_bnd : 'al` is added only by the Drop impl. + --> $DIR/reject-specialized-drops-8142.rs:29:1 + | +LL | / impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT +LL | | //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl. +LL | | fn drop(&mut self) { } } + | |____________________________^ + | +note: The same requirement must be part of the struct/enum definition + --> $DIR/reject-specialized-drops-8142.rs:15:1 + | +LL | struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0367]: The requirement `'adds_bnd : 'al` is added only by the Drop impl. + --> $DIR/reject-specialized-drops-8142.rs:33:1 + | +LL | / impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT +LL | | //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl. +LL | | fn drop(&mut self) { } } + | |____________________________^ + | +note: The same requirement must be part of the struct/enum definition + --> $DIR/reject-specialized-drops-8142.rs:16:1 + | +LL | struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/reject-specialized-drops-8142.rs:39:1 + | +LL | impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `N<'n>` + found type `N<'static>` +note: the lifetime 'n as defined on the struct at 18:10... + --> $DIR/reject-specialized-drops-8142.rs:18:10 + | +LL | struct N<'n> { x: &'n i8 } + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0366]: Implementations of Drop cannot be specialized + --> $DIR/reject-specialized-drops-8142.rs:46:1 + | +LL | impl Drop for P { fn drop(&mut self) { } } // REJECT + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Use same sequence of generic type and region parameters that is on the struct/enum definition + --> $DIR/reject-specialized-drops-8142.rs:20:1 + | +LL | struct P { x: *const Tp } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0367]: The requirement `Adds_bnd: Bound` is added only by the Drop impl. + --> $DIR/reject-specialized-drops-8142.rs:49:1 + | +LL | impl Drop for Q { fn drop(&mut self) { } } // REJECT + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: The same requirement must be part of the struct/enum definition + --> $DIR/reject-specialized-drops-8142.rs:21:1 + | +LL | struct Q { x: *const Tq } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0367]: The requirement `Adds_rbnd : 'rbnd` is added only by the Drop impl. + --> $DIR/reject-specialized-drops-8142.rs:52:1 + | +LL | impl<'rbnd,Adds_rbnd:'rbnd> Drop for R { fn drop(&mut self) { } } // REJECT + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: The same requirement must be part of the struct/enum definition + --> $DIR/reject-specialized-drops-8142.rs:22:1 + | +LL | struct R { x: *const Tr } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0366]: Implementations of Drop cannot be specialized + --> $DIR/reject-specialized-drops-8142.rs:61:1 + | +LL | impl Drop for V { fn drop(&mut self) { } } // REJECT + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: Use same sequence of generic type and region parameters that is on the struct/enum definition + --> $DIR/reject-specialized-drops-8142.rs:26:1 + | +LL | struct V { x: *const Tva, y: *const Tvb } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'lw` due to conflicting requirements + --> $DIR/reject-specialized-drops-8142.rs:64:1 + | +LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'l1 as defined on the struct at 27:10... + --> $DIR/reject-specialized-drops-8142.rs:27:10 + | +LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } + | ^^^ +note: ...but the lifetime must also be valid for the lifetime 'l2 as defined on the struct at 27:15... + --> $DIR/reject-specialized-drops-8142.rs:27:15 + | +LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } + | ^^^ + = note: ...so that the types are compatible: + expected W<'l1, 'l2> + found W<'_, '_> + +error: aborting due to 8 previous errors + +Some errors occurred: E0308, E0366, E0367, E0495. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.rs b/src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.rs new file mode 100644 index 00000000000..88441594a7e --- /dev/null +++ b/src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that one can't run a destructor twice with the repeated vector +// literal syntax. + +struct Foo { + x: isize, + +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("Goodbye!"); + } +} + +fn main() { + let a = Foo { x: 3 }; + let _ = [ a; 5 ]; + //~^ ERROR `Foo: std::marker::Copy` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.stderr b/src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.stderr new file mode 100644 index 00000000000..408c28af10e --- /dev/null +++ b/src/test/ui/compile-fail-migration/repeat-to-run-dtor-twice.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Foo: std::marker::Copy` is not satisfied + --> $DIR/repeat-to-run-dtor-twice.rs:27:13 + | +LL | let _ = [ a; 5 ]; + | ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `Foo` + | + = note: the `Copy` trait is required because the repeated element will be copied + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/repeat_count.rs b/src/test/ui/compile-fail-migration/repeat_count.rs new file mode 100644 index 00000000000..a716f3e29d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repeat_count.rs @@ -0,0 +1,49 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #3645 + +fn main() { + let n = 1; + let a = [0; n]; + //~^ ERROR attempt to use a non-constant value in a constant [E0435] + let b = [0; ()]; + //~^ ERROR mismatched types + //~| expected type `usize` + //~| found type `()` + //~| expected usize, found () + let c = [0; true]; + //~^ ERROR mismatched types + //~| expected usize, found bool + let d = [0; 0.5]; + //~^ ERROR mismatched types + //~| expected type `usize` + //~| found type `{float}` + //~| expected usize, found floating-point variable + let e = [0; "foo"]; + //~^ ERROR mismatched types + //~| expected type `usize` + //~| found type `&'static str` + //~| expected usize, found reference + let f = [0; -4_isize]; + //~^ ERROR mismatched types + //~| expected usize, found isize + let f = [0_usize; -1_isize]; + //~^ ERROR mismatched types + //~| expected usize, found isize + struct G { + g: (), + } + let g = [0; G { g: () }]; + //~^ ERROR mismatched types + //~| expected type `usize` + //~| found type `main::G` + //~| expected usize, found struct `main::G` +} diff --git a/src/test/ui/compile-fail-migration/repeat_count.stderr b/src/test/ui/compile-fail-migration/repeat_count.stderr new file mode 100644 index 00000000000..4852023ec8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/repeat_count.stderr @@ -0,0 +1,64 @@ +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/repeat_count.rs:15:17 + | +LL | let a = [0; n]; + | ^ non-constant value + +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:17:17 + | +LL | let b = [0; ()]; + | ^^ expected usize, found () + | + = note: expected type `usize` + found type `()` + +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:22:17 + | +LL | let c = [0; true]; + | ^^^^ expected usize, found bool + +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:25:17 + | +LL | let d = [0; 0.5]; + | ^^^ expected usize, found floating-point variable + | + = note: expected type `usize` + found type `{float}` + +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:30:17 + | +LL | let e = [0; "foo"]; + | ^^^^^ expected usize, found reference + | + = note: expected type `usize` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:35:17 + | +LL | let f = [0; -4_isize]; + | ^^^^^^^^ expected usize, found isize + +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:38:23 + | +LL | let f = [0_usize; -1_isize]; + | ^^^^^^^^ expected usize, found isize + +error[E0308]: mismatched types + --> $DIR/repeat_count.rs:44:17 + | +LL | let g = [0; G { g: () }]; + | ^^^^^^^^^^^ expected usize, found struct `main::G` + | + = note: expected type `usize` + found type `main::G` + +error: aborting due to 8 previous errors + +Some errors occurred: E0308, E0435. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/repr-align.rs b/src/test/ui/compile-fail-migration/repr-align.rs new file mode 100644 index 00000000000..9b0408de2a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-align.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![allow(dead_code)] + +#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer +struct A(i32); + +#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two +struct B(i32); + +#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29 +struct C(i32); + +#[repr(align(536870912))] // ok: this is the largest accepted alignment +struct D(i32); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/repr-align.stderr b/src/test/ui/compile-fail-migration/repr-align.stderr new file mode 100644 index 00000000000..2195789bd69 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-align.stderr @@ -0,0 +1,21 @@ +error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer + --> $DIR/repr-align.rs:12:8 + | +LL | #[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer + | ^^^^^^^^^^^ + +error[E0589]: invalid `repr(align)` attribute: not a power of two + --> $DIR/repr-align.rs:15:8 + | +LL | #[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two + | ^^^^^^^^^ + +error[E0589]: invalid `repr(align)` attribute: larger than 2^29 + --> $DIR/repr-align.rs:18:8 + | +LL | #[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29 + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0589`. diff --git a/src/test/ui/compile-fail-migration/repr-packed-contains-align.rs b/src/test/ui/compile-fail-migration/repr-packed-contains-align.rs new file mode 100644 index 00000000000..27890333a51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-packed-contains-align.rs @@ -0,0 +1,59 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![feature(untagged_unions)] +#![allow(dead_code)] + +#[repr(align(16))] +struct SA(i32); + +struct SB(SA); + +#[repr(align(16))] +union UA { + i: i32 +} + +union UB { + a: UA +} + +#[repr(packed)] +struct SC(SA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + +#[repr(packed)] +struct SD(SB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + +#[repr(packed)] +struct SE(UA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + +#[repr(packed)] +struct SF(UB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + +#[repr(packed)] +union UC { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + a: UA +} + +#[repr(packed)] +union UD { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + n: UB +} + +#[repr(packed)] +union UE { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + a: SA +} + +#[repr(packed)] +union UF { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + n: SB +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/repr-packed-contains-align.stderr b/src/test/ui/compile-fail-migration/repr-packed-contains-align.stderr new file mode 100644 index 00000000000..4558cf2e104 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-packed-contains-align.stderr @@ -0,0 +1,59 @@ +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:28:1 + | +LL | struct SC(SA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + | ^^^^^^^^^^^^^^ + +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:31:1 + | +LL | struct SD(SB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + | ^^^^^^^^^^^^^^ + +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:34:1 + | +LL | struct SE(UA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + | ^^^^^^^^^^^^^^ + +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:37:1 + | +LL | struct SF(UB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type + | ^^^^^^^^^^^^^^ + +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:40:1 + | +LL | / union UC { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type +LL | | a: UA +LL | | } + | |_^ + +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:45:1 + | +LL | / union UD { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type +LL | | n: UB +LL | | } + | |_^ + +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:50:1 + | +LL | / union UE { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type +LL | | a: SA +LL | | } + | |_^ + +error[E0588]: packed type cannot transitively contain a `[repr(align)]` type + --> $DIR/repr-packed-contains-align.rs:55:1 + | +LL | / union UF { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type +LL | | n: SB +LL | | } + | |_^ + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0588`. diff --git a/src/test/ui/compile-fail-migration/repr-transparent-other-items.rs b/src/test/ui/compile-fail-migration/repr-transparent-other-items.rs new file mode 100644 index 00000000000..685d62dc3a9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-transparent-other-items.rs @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// See also repr-transparent.rs + +#[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum +enum Void {} //~| ERROR should be applied to struct + +#[repr(transparent)] //~ ERROR should be applied to struct +enum FieldlessEnum { + Foo, + Bar, +} + +#[repr(transparent)] //~ ERROR should be applied to struct +enum Enum { + Foo(String), + Bar(u32), +} + +#[repr(transparent)] //~ ERROR should be applied to struct +union Foo { + u: u32, + s: i32 +} + +#[repr(transparent)] //~ ERROR should be applied to struct +fn cant_repr_this() {} + +#[repr(transparent)] //~ ERROR should be applied to struct +static CANT_REPR_THIS: u32 = 0; diff --git a/src/test/ui/compile-fail-migration/repr-transparent-other-items.stderr b/src/test/ui/compile-fail-migration/repr-transparent-other-items.stderr new file mode 100644 index 00000000000..e5889cf53e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-transparent-other-items.stderr @@ -0,0 +1,73 @@ +error[E0601]: `main` function not found in crate `repr_transparent_other_items` + | + = note: consider adding a `main` function to `$DIR/repr-transparent-other-items.rs` + +error[E0517]: attribute should be applied to struct + --> $DIR/repr-transparent-other-items.rs:13:8 + | +LL | #[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum + | ^^^^^^^^^^^ +LL | enum Void {} //~| ERROR should be applied to struct + | ------------ not a struct + +error[E0517]: attribute should be applied to struct + --> $DIR/repr-transparent-other-items.rs:16:8 + | +LL | #[repr(transparent)] //~ ERROR should be applied to struct + | ^^^^^^^^^^^ +LL | / enum FieldlessEnum { +LL | | Foo, +LL | | Bar, +LL | | } + | |_- not a struct + +error[E0517]: attribute should be applied to struct + --> $DIR/repr-transparent-other-items.rs:22:8 + | +LL | #[repr(transparent)] //~ ERROR should be applied to struct + | ^^^^^^^^^^^ +LL | / enum Enum { +LL | | Foo(String), +LL | | Bar(u32), +LL | | } + | |_- not a struct + +error[E0517]: attribute should be applied to struct + --> $DIR/repr-transparent-other-items.rs:28:8 + | +LL | #[repr(transparent)] //~ ERROR should be applied to struct + | ^^^^^^^^^^^ +LL | / union Foo { +LL | | u: u32, +LL | | s: i32 +LL | | } + | |_- not a struct + +error[E0517]: attribute should be applied to struct + --> $DIR/repr-transparent-other-items.rs:34:8 + | +LL | #[repr(transparent)] //~ ERROR should be applied to struct + | ^^^^^^^^^^^ +LL | fn cant_repr_this() {} + | ---------------------- not a struct + +error[E0517]: attribute should be applied to struct + --> $DIR/repr-transparent-other-items.rs:37:8 + | +LL | #[repr(transparent)] //~ ERROR should be applied to struct + | ^^^^^^^^^^^ +LL | static CANT_REPR_THIS: u32 = 0; + | ------------------------------- not a struct + +error[E0084]: unsupported representation for zero-variant enum + --> $DIR/repr-transparent-other-items.rs:13:1 + | +LL | #[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum + | ^^^^^^^^^^^^^^^^^^^^ +LL | enum Void {} //~| ERROR should be applied to struct + | ------------ zero-variant enum + +error: aborting due to 8 previous errors + +Some errors occurred: E0084, E0517, E0601. +For more information about an error, try `rustc --explain E0084`. diff --git a/src/test/ui/compile-fail-migration/repr-transparent-other-reprs.rs b/src/test/ui/compile-fail-migration/repr-transparent-other-reprs.rs new file mode 100644 index 00000000000..a391c0ae1f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-transparent-other-reprs.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_align, attr_literals)] + +// See also repr-transparent.rs + +#[repr(transparent, C)] //~ ERROR cannot have other repr +struct TransparentPlusC { + ptr: *const u8 +} + +#[repr(transparent, packed)] //~ ERROR cannot have other repr +struct TransparentPlusPacked(*const u8); + +#[repr(transparent, align(2))] //~ ERROR cannot have other repr +struct TransparentPlusAlign(u8); + +#[repr(transparent)] //~ ERROR cannot have other repr +#[repr(C)] +struct SeparateAttributes(*mut u8); diff --git a/src/test/ui/compile-fail-migration/repr-transparent-other-reprs.stderr b/src/test/ui/compile-fail-migration/repr-transparent-other-reprs.stderr new file mode 100644 index 00000000000..40f41c474db --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-transparent-other-reprs.stderr @@ -0,0 +1,34 @@ +error[E0601]: `main` function not found in crate `repr_transparent_other_reprs` + | + = note: consider adding a `main` function to `$DIR/repr-transparent-other-reprs.rs` + +error[E0692]: transparent struct cannot have other repr hints + --> $DIR/repr-transparent-other-reprs.rs:15:8 + | +LL | #[repr(transparent, C)] //~ ERROR cannot have other repr + | ^^^^^^^^^^^ ^ + +error[E0692]: transparent struct cannot have other repr hints + --> $DIR/repr-transparent-other-reprs.rs:20:8 + | +LL | #[repr(transparent, packed)] //~ ERROR cannot have other repr + | ^^^^^^^^^^^ ^^^^^^ + +error[E0692]: transparent struct cannot have other repr hints + --> $DIR/repr-transparent-other-reprs.rs:23:8 + | +LL | #[repr(transparent, align(2))] //~ ERROR cannot have other repr + | ^^^^^^^^^^^ ^^^^^^^^ + +error[E0692]: transparent struct cannot have other repr hints + --> $DIR/repr-transparent-other-reprs.rs:26:8 + | +LL | #[repr(transparent)] //~ ERROR cannot have other repr + | ^^^^^^^^^^^ +LL | #[repr(C)] + | ^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0601, E0692. +For more information about an error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/repr-transparent.rs b/src/test/ui/compile-fail-migration/repr-transparent.rs new file mode 100644 index 00000000000..4d8ec4cdb40 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-transparent.rs @@ -0,0 +1,50 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file tests repr(transparent)-related errors reported during typeck. Other errors +// that are reported earlier and therefore preempt these are tested in: +// - repr-transparent-other-reprs.rs +// - repr-transparent-other-items.rs + +#![feature(repr_align, attr_literals)] + +use std::marker::PhantomData; + +#[repr(transparent)] +struct NoFields; //~ ERROR needs exactly one non-zero-sized field + +#[repr(transparent)] +struct ContainsOnlyZst(()); //~ ERROR needs exactly one non-zero-sized field + +#[repr(transparent)] +struct ContainsOnlyZstArray([bool; 0]); //~ ERROR needs exactly one non-zero-sized field + +#[repr(transparent)] +struct ContainsMultipleZst(PhantomData<*const i32>, NoFields); +//~^ ERROR needs exactly one non-zero-sized field + +#[repr(transparent)] +struct MultipleNonZst(u8, u8); //~ ERROR needs exactly one non-zero-sized field + +trait Mirror { type It: ?Sized; } +impl Mirror for T { type It = Self; } + +#[repr(transparent)] +pub struct StructWithProjection(f32, ::It); +//~^ ERROR needs exactly one non-zero-sized field + +#[repr(transparent)] +struct NontrivialAlignZst(u32, [u16; 0]); //~ ERROR alignment larger than 1 + +#[repr(align(32))] +struct ZstAlign32(PhantomData); + +#[repr(transparent)] +struct GenericAlign(ZstAlign32, u32); //~ ERROR alignment larger than 1 diff --git a/src/test/ui/compile-fail-migration/repr-transparent.stderr b/src/test/ui/compile-fail-migration/repr-transparent.stderr new file mode 100644 index 00000000000..0f620880fa9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/repr-transparent.stderr @@ -0,0 +1,76 @@ +error[E0601]: `main` function not found in crate `repr_transparent` + | + = note: consider adding a `main` function to `$DIR/repr-transparent.rs` + +error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 0 + --> $DIR/repr-transparent.rs:21:1 + | +LL | struct NoFields; //~ ERROR needs exactly one non-zero-sized field + | ^^^^^^^^^^^^^^^^ + | + = note: non-zero-sized field + +error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 0 + --> $DIR/repr-transparent.rs:24:1 + | +LL | struct ContainsOnlyZst(()); //~ ERROR needs exactly one non-zero-sized field + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: non-zero-sized field + +error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 0 + --> $DIR/repr-transparent.rs:27:1 + | +LL | struct ContainsOnlyZstArray([bool; 0]); //~ ERROR needs exactly one non-zero-sized field + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: non-zero-sized field + +error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 0 + --> $DIR/repr-transparent.rs:30:1 + | +LL | struct ContainsMultipleZst(PhantomData<*const i32>, NoFields); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: non-zero-sized field + +error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 2 + --> $DIR/repr-transparent.rs:34:1 + | +LL | struct MultipleNonZst(u8, u8); //~ ERROR needs exactly one non-zero-sized field + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: non-zero-sized field + --> $DIR/repr-transparent.rs:34:23 + | +LL | struct MultipleNonZst(u8, u8); //~ ERROR needs exactly one non-zero-sized field + | ^^ ^^ + +error[E0690]: transparent struct needs exactly one non-zero-sized field, but has 2 + --> $DIR/repr-transparent.rs:40:1 + | +LL | pub struct StructWithProjection(f32, ::It); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: non-zero-sized field + --> $DIR/repr-transparent.rs:40:33 + | +LL | pub struct StructWithProjection(f32, ::It); + | ^^^ ^^^^^^^^^^^^^^^^^^^ + +error[E0691]: zero-sized field in transparent struct has alignment larger than 1 + --> $DIR/repr-transparent.rs:44:32 + | +LL | struct NontrivialAlignZst(u32, [u16; 0]); //~ ERROR alignment larger than 1 + | ^^^^^^^^ + +error[E0691]: zero-sized field in transparent struct has alignment larger than 1 + --> $DIR/repr-transparent.rs:50:24 + | +LL | struct GenericAlign(ZstAlign32, u32); //~ ERROR alignment larger than 1 + | ^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + +Some errors occurred: E0601, E0690, E0691. +For more information about an error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/required-lang-item.rs b/src/test/ui/compile-fail-migration/required-lang-item.rs new file mode 100644 index 00000000000..ce40702b3dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/required-lang-item.rs @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items, no_core)] +#![no_core] + +#[lang="copy"] pub trait Copy { } +#[lang="sized"] pub trait Sized { } + +// error-pattern:requires `start` lang_item + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/required-lang-item.stderr b/src/test/ui/compile-fail-migration/required-lang-item.stderr new file mode 100644 index 00000000000..83764a91ac7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/required-lang-item.stderr @@ -0,0 +1,4 @@ +error: requires `start` lang_item + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/reserved-attr-on-macro.rs b/src/test/ui/compile-fail-migration/reserved-attr-on-macro.rs new file mode 100644 index 00000000000..db8f82a70e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/reserved-attr-on-macro.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved +macro_rules! foo { + () => (()); +} + +fn main() { + foo!(); +} diff --git a/src/test/ui/compile-fail-migration/reserved-attr-on-macro.stderr b/src/test/ui/compile-fail-migration/reserved-attr-on-macro.stderr new file mode 100644 index 00000000000..e8bfcc04f48 --- /dev/null +++ b/src/test/ui/compile-fail-migration/reserved-attr-on-macro.stderr @@ -0,0 +1,11 @@ +error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642) + --> $DIR/reserved-attr-on-macro.rs:11:1 + | +LL | #[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(rustc_attrs)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/reserved-become.rs b/src/test/ui/compile-fail-migration/reserved-become.rs new file mode 100644 index 00000000000..bcda61e363d --- /dev/null +++ b/src/test/ui/compile-fail-migration/reserved-become.rs @@ -0,0 +1,14 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let become = 0; + //~^ ERROR expected pattern, found reserved keyword `become` +} diff --git a/src/test/ui/compile-fail-migration/reserved-become.stderr b/src/test/ui/compile-fail-migration/reserved-become.stderr new file mode 100644 index 00000000000..fa9a9601208 --- /dev/null +++ b/src/test/ui/compile-fail-migration/reserved-become.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `become` + --> $DIR/reserved-become.rs:12:9 + | +LL | let become = 0; + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/resolve-bad-import-prefix.rs b/src/test/ui/compile-fail-migration/resolve-bad-import-prefix.rs new file mode 100644 index 00000000000..370782fc7d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-bad-import-prefix.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m {} +enum E {} +struct S; +trait Tr {} + +use {}; // OK +use ::{}; // OK +use m::{}; // OK +use E::{}; // OK +use S::{}; //~ ERROR expected module or enum, found struct `S` +use Tr::{}; //~ ERROR expected module or enum, found trait `Tr` +use Nonexistent::{}; //~ ERROR cannot find module or enum `Nonexistent` in the crate root + +fn main () {} diff --git a/src/test/ui/compile-fail-migration/resolve-bad-import-prefix.stderr b/src/test/ui/compile-fail-migration/resolve-bad-import-prefix.stderr new file mode 100644 index 00000000000..76d0c035335 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-bad-import-prefix.stderr @@ -0,0 +1,24 @@ +error[E0577]: expected module or enum, found struct `S` + --> $DIR/resolve-bad-import-prefix.rs:20:5 + | +LL | use S::{}; //~ ERROR expected module or enum, found struct `S` + | -^^^^ + | | + | did you mean `E`? + +error[E0577]: expected module or enum, found trait `Tr` + --> $DIR/resolve-bad-import-prefix.rs:21:5 + | +LL | use Tr::{}; //~ ERROR expected module or enum, found trait `Tr` + | ^^^^^^ not a module or enum + +error[E0578]: cannot find module or enum `Nonexistent` in the crate root + --> $DIR/resolve-bad-import-prefix.rs:22:5 + | +LL | use Nonexistent::{}; //~ ERROR cannot find module or enum `Nonexistent` in the crate root + | ^^^^^^^^^^^ not found in the crate root + +error: aborting due to 3 previous errors + +Some errors occurred: E0577, E0578. +For more information about an error, try `rustc --explain E0577`. diff --git a/src/test/ui/compile-fail-migration/resolve-bad-visibility.rs b/src/test/ui/compile-fail-migration/resolve-bad-visibility.rs new file mode 100644 index 00000000000..420a45a2147 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-bad-visibility.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum E {} +trait Tr {} + +pub(in E) struct S; //~ ERROR expected module, found enum `E` +pub(in Tr) struct Z; //~ ERROR expected module, found trait `Tr` +pub(in std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules +pub(in nonexistent) struct G; //~ ERROR cannot find module `nonexistent` in the crate root +pub(in too_soon) struct H; //~ ERROR cannot find module `too_soon` in the crate root + +// Visibilities are resolved eagerly without waiting for modules becoming fully populated. +// Visibilities can only use ancestor modules legally which are always available in time, +// so the worst thing that can happen due to eager resolution is a suboptimal error message. +mod too_soon {} + +fn main () {} diff --git a/src/test/ui/compile-fail-migration/resolve-bad-visibility.stderr b/src/test/ui/compile-fail-migration/resolve-bad-visibility.stderr new file mode 100644 index 00000000000..aa4817163e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-bad-visibility.stderr @@ -0,0 +1,34 @@ +error: visibilities can only be restricted to ancestor modules + --> $DIR/resolve-bad-visibility.rs:16:8 + | +LL | pub(in std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules + | ^^^^^^^^ + +error[E0577]: expected module, found enum `E` + --> $DIR/resolve-bad-visibility.rs:14:8 + | +LL | pub(in E) struct S; //~ ERROR expected module, found enum `E` + | ^ not a module + +error[E0577]: expected module, found trait `Tr` + --> $DIR/resolve-bad-visibility.rs:15:8 + | +LL | pub(in Tr) struct Z; //~ ERROR expected module, found trait `Tr` + | ^^ not a module + +error[E0578]: cannot find module `nonexistent` in the crate root + --> $DIR/resolve-bad-visibility.rs:17:8 + | +LL | pub(in nonexistent) struct G; //~ ERROR cannot find module `nonexistent` in the crate root + | ^^^^^^^^^^^ not found in the crate root + +error[E0578]: cannot find module `too_soon` in the crate root + --> $DIR/resolve-bad-visibility.rs:18:8 + | +LL | pub(in too_soon) struct H; //~ ERROR cannot find module `too_soon` in the crate root + | ^^^^^^^^ not found in the crate root + +error: aborting due to 5 previous errors + +Some errors occurred: E0577, E0578. +For more information about an error, try `rustc --explain E0577`. diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.rs b/src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.rs new file mode 100644 index 00000000000..6a04a2c3704 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[allow(unused_extern_crates)] +extern crate std; +//~^ ERROR the name `std` is defined multiple times + +fn main(){} diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.stderr b/src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.stderr new file mode 100644 index 00000000000..5f21b4413e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-extern-crate-vs-extern-crate.stderr @@ -0,0 +1,15 @@ +error[E0259]: the name `std` is defined multiple times + --> $DIR/resolve-conflict-extern-crate-vs-extern-crate.rs:12:1 + | +LL | extern crate std; + | ^^^^^^^^^^^^^^^^^ `std` reimported here + | + = note: `std` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | extern crate std as other_std; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0259`. diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.rs b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.rs new file mode 100644 index 00000000000..91cf1d35954 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::slice as std; //~ ERROR the name `std` is defined multiple times + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.stderr b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.stderr new file mode 100644 index 00000000000..9978e75af30 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-extern-crate.stderr @@ -0,0 +1,15 @@ +error[E0254]: the name `std` is defined multiple times + --> $DIR/resolve-conflict-import-vs-extern-crate.rs:11:5 + | +LL | use std::slice as std; //~ ERROR the name `std` is defined multiple times + | ^^^^^^^^^^^^^^^^^ `std` reimported here + | + = note: `std` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | use std::slice as std as other_std; //~ ERROR the name `std` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0254`. diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.rs b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.rs new file mode 100644 index 00000000000..8db9023310e --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem::transmute; +use std::mem::transmute; +//~^ ERROR the name `transmute` is defined multiple times + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.stderr b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.stderr new file mode 100644 index 00000000000..80ccb9aa2b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-import-vs-import.stderr @@ -0,0 +1,17 @@ +error[E0252]: the name `transmute` is defined multiple times + --> $DIR/resolve-conflict-import-vs-import.rs:12:5 + | +LL | use std::mem::transmute; + | ------------------- previous import of the value `transmute` here +LL | use std::mem::transmute; + | ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here + | + = note: `transmute` must be defined only once in the value namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | use std::mem::transmute as other_transmute; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.rs b/src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.rs new file mode 100644 index 00000000000..b50a60d39c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn std() {} +mod std {} //~ ERROR the name `std` is defined multiple times + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.stderr b/src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.stderr new file mode 100644 index 00000000000..d9ad248c013 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-item-vs-extern-crate.stderr @@ -0,0 +1,15 @@ +error[E0260]: the name `std` is defined multiple times + --> $DIR/resolve-conflict-item-vs-extern-crate.rs:12:1 + | +LL | mod std {} //~ ERROR the name `std` is defined multiple times + | ^^^^^^^ `std` redefined here + | + = note: `std` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | as other_std// Copyright 2014 The Rust Project Developers. See the COPYRIGHT + | ^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0260`. diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.rs b/src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.rs new file mode 100644 index 00000000000..bbb6ee622b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::slice::Iter; + +struct Iter; +//~^ ERROR the name `Iter` is defined multiple times + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.stderr b/src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.stderr new file mode 100644 index 00000000000..1e8df8f8ea7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-conflict-type-vs-import.stderr @@ -0,0 +1,18 @@ +error[E0255]: the name `Iter` is defined multiple times + --> $DIR/resolve-conflict-type-vs-import.rs:13:1 + | +LL | use std::slice::Iter; + | ---------------- previous import of the type `Iter` here +LL | +LL | struct Iter; + | ^^^^^^^^^^^^ `Iter` redefined here + | + = note: `Iter` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | use std::slice::Iter as OtherIter; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0255`. diff --git a/src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.rs b/src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.rs new file mode 100644 index 00000000000..63d33a9e5fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.rs @@ -0,0 +1,50 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum opts { + a(isize), b(isize), c(isize) +} + +fn matcher1(x: opts) { + match x { + opts::a(ref i) | opts::b(i) => {} + //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm + //~^^ ERROR mismatched types + opts::c(_) => {} + } +} + +fn matcher2(x: opts) { + match x { + opts::a(ref i) | opts::b(i) => {} + //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm + //~^^ ERROR mismatched types + opts::c(_) => {} + } +} + +fn matcher4(x: opts) { + match x { + opts::a(ref mut i) | opts::b(ref i) => {} + //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm + //~^^ ERROR mismatched types + opts::c(_) => {} + } +} + + +fn matcher5(x: opts) { + match x { + opts::a(ref i) | opts::b(ref i) => {} + opts::c(_) => {} + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.stderr b/src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.stderr new file mode 100644 index 00000000000..e36eea26fcf --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-inconsistent-binding-mode.stderr @@ -0,0 +1,53 @@ +error[E0409]: variable `i` is bound in inconsistent ways within the same match arm + --> $DIR/resolve-inconsistent-binding-mode.rs:17:32 + | +LL | opts::a(ref i) | opts::b(i) => {} + | - ^ bound in different ways + | | + | first binding + +error[E0409]: variable `i` is bound in inconsistent ways within the same match arm + --> $DIR/resolve-inconsistent-binding-mode.rs:26:32 + | +LL | opts::a(ref i) | opts::b(i) => {} + | - ^ bound in different ways + | | + | first binding + +error[E0409]: variable `i` is bound in inconsistent ways within the same match arm + --> $DIR/resolve-inconsistent-binding-mode.rs:35:40 + | +LL | opts::a(ref mut i) | opts::b(ref i) => {} + | - first binding ^ bound in different ways + +error[E0308]: mismatched types + --> $DIR/resolve-inconsistent-binding-mode.rs:17:32 + | +LL | opts::a(ref i) | opts::b(i) => {} + | ^ expected &isize, found isize + | + = note: expected type `&isize` + found type `isize` + +error[E0308]: mismatched types + --> $DIR/resolve-inconsistent-binding-mode.rs:26:32 + | +LL | opts::a(ref i) | opts::b(i) => {} + | ^ expected &isize, found isize + | + = note: expected type `&isize` + found type `isize` + +error[E0308]: mismatched types + --> $DIR/resolve-inconsistent-binding-mode.rs:35:36 + | +LL | opts::a(ref mut i) | opts::b(ref i) => {} + | ^^^^^ types differ in mutability + | + = note: expected type `&mut isize` + found type `&isize` + +error: aborting due to 6 previous errors + +Some errors occurred: E0308, E0409. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/resolve-label.rs b/src/test/ui/compile-fail-migration/resolve-label.rs new file mode 100644 index 00000000000..6695e972f33 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-label.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() { + 'l: loop { + fn g() { + loop { + break 'l; //~ ERROR use of undeclared label + } + } + } + + loop { 'w: while break 'w { } } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/resolve-label.stderr b/src/test/ui/compile-fail-migration/resolve-label.stderr new file mode 100644 index 00000000000..a7b89752f5e --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-label.stderr @@ -0,0 +1,9 @@ +error[E0426]: use of undeclared label `'l` + --> $DIR/resolve-label.rs:15:23 + | +LL | break 'l; //~ ERROR use of undeclared label + | ^^ undeclared label `'l` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0426`. diff --git a/src/test/ui/compile-fail-migration/resolve-primitive-fallback.rs b/src/test/ui/compile-fail-migration/resolve-primitive-fallback.rs new file mode 100644 index 00000000000..c1584b0bdcd --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-primitive-fallback.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + // Make sure primitive type fallback doesn't work in value namespace + std::mem::size_of(u16); + //~^ ERROR expected value, found builtin type `u16` + //~| ERROR this function takes 0 parameters but 1 parameter was supplied + + // Make sure primitive type fallback doesn't work with global paths + let _: ::u8; + //~^ ERROR cannot find type `u8` in the crate root +} diff --git a/src/test/ui/compile-fail-migration/resolve-primitive-fallback.stderr b/src/test/ui/compile-fail-migration/resolve-primitive-fallback.stderr new file mode 100644 index 00000000000..2d852369afc --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-primitive-fallback.stderr @@ -0,0 +1,22 @@ +error[E0423]: expected value, found builtin type `u16` + --> $DIR/resolve-primitive-fallback.rs:13:23 + | +LL | std::mem::size_of(u16); + | ^^^ not a value + +error[E0412]: cannot find type `u8` in the crate root + --> $DIR/resolve-primitive-fallback.rs:18:14 + | +LL | let _: ::u8; + | ^^ not found in the crate root + +error[E0061]: this function takes 0 parameters but 1 parameter was supplied + --> $DIR/resolve-primitive-fallback.rs:13:5 + | +LL | std::mem::size_of(u16); + | ^^^^^^^^^^^^^^^^^^^^^^ expected 0 parameters + +error: aborting due to 3 previous errors + +Some errors occurred: E0061, E0412, E0423. +For more information about an error, try `rustc --explain E0061`. diff --git a/src/test/ui/compile-fail-migration/resolve-self-in-impl-2.rs b/src/test/ui/compile-fail-migration/resolve-self-in-impl-2.rs new file mode 100644 index 00000000000..adc208a0202 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-self-in-impl-2.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S(T); +trait Tr {} + +impl Self for S {} //~ ERROR expected trait, found self type `Self` +impl Self::N for S {} //~ ERROR cannot find trait `N` in `Self` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/resolve-self-in-impl-2.stderr b/src/test/ui/compile-fail-migration/resolve-self-in-impl-2.stderr new file mode 100644 index 00000000000..183b9b66327 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-self-in-impl-2.stderr @@ -0,0 +1,16 @@ +error[E0411]: expected trait, found self type `Self` + --> $DIR/resolve-self-in-impl-2.rs:14:6 + | +LL | impl Self for S {} //~ ERROR expected trait, found self type `Self` + | ^^^^ `Self` is only available in traits and impls + +error[E0405]: cannot find trait `N` in `Self` + --> $DIR/resolve-self-in-impl-2.rs:15:12 + | +LL | impl Self::N for S {} //~ ERROR cannot find trait `N` in `Self` + | ^ not found in `Self` + +error: aborting due to 2 previous errors + +Some errors occurred: E0405, E0411. +For more information about an error, try `rustc --explain E0405`. diff --git a/src/test/ui/compile-fail-migration/resolve-self-in-impl.rs b/src/test/ui/compile-fail-migration/resolve-self-in-impl.rs new file mode 100644 index 00000000000..2a894c57b8d --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-self-in-impl.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_type_defaults)] + +struct S(T); +trait Tr { + type A = (); +} + +impl Tr for S {} // OK +impl> Tr for S {} // OK +impl Tr for S where Self: Copy {} // OK +impl Tr for S where S: Copy {} // OK +impl Tr for S where Self::A: Copy {} // OK + +impl Tr for Self {} //~ ERROR cycle detected +impl Tr for S {} //~ ERROR cycle detected +impl Self {} //~ ERROR cycle detected +impl S {} //~ ERROR cycle detected +impl Tr for S {} //~ ERROR cycle detected + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/resolve-self-in-impl.stderr b/src/test/ui/compile-fail-migration/resolve-self-in-impl.stderr new file mode 100644 index 00000000000..3fa384808db --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-self-in-impl.stderr @@ -0,0 +1,43 @@ +error[E0391]: cycle detected when processing `` + --> $DIR/resolve-self-in-impl.rs:24:13 + | +LL | impl Tr for Self {} //~ ERROR cycle detected + | ^^^^ + | + = note: ...which again requires processing ``, completing the cycle + +error[E0391]: cycle detected when processing `` + --> $DIR/resolve-self-in-impl.rs:25:15 + | +LL | impl Tr for S {} //~ ERROR cycle detected + | ^^^^ + | + = note: ...which again requires processing ``, completing the cycle + +error[E0391]: cycle detected when processing `` + --> $DIR/resolve-self-in-impl.rs:26:6 + | +LL | impl Self {} //~ ERROR cycle detected + | ^^^^ + | + = note: ...which again requires processing ``, completing the cycle + +error[E0391]: cycle detected when processing `` + --> $DIR/resolve-self-in-impl.rs:27:8 + | +LL | impl S {} //~ ERROR cycle detected + | ^^^^ + | + = note: ...which again requires processing ``, completing the cycle + +error[E0391]: cycle detected when processing `` + --> $DIR/resolve-self-in-impl.rs:28:1 + | +LL | impl Tr for S {} //~ ERROR cycle detected + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which again requires processing ``, completing the cycle + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.rs b/src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.rs new file mode 100644 index 00000000000..a1572b85666 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.rs @@ -0,0 +1,45 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #14603: Check for references to type parameters from the +// outer scope (in this case, the trait) used on items in an inner +// scope (in this case, the enum). + +trait TraitA { + fn outer(&self) { + enum Foo { + Variance(A) + //~^ ERROR can't use type parameters from outer function + } + } +} + +trait TraitB { + fn outer(&self) { + struct Foo(A); + //~^ ERROR can't use type parameters from outer function + } +} + +trait TraitC { + fn outer(&self) { + struct Foo { a: A } + //~^ ERROR can't use type parameters from outer function + } +} + +trait TraitD { + fn outer(&self) { + fn foo(a: A) { } + //~^ ERROR can't use type parameters from outer function + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.stderr b/src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.stderr new file mode 100644 index 00000000000..73ee7102e6e --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-type-param-in-item-in-trait.stderr @@ -0,0 +1,45 @@ +error[E0401]: can't use type parameters from outer function + --> $DIR/resolve-type-param-in-item-in-trait.rs:18:22 + | +LL | trait TraitA { + | - type variable from outer function +LL | fn outer(&self) { + | ----- try adding a local type parameter in this method instead +LL | enum Foo { +LL | Variance(A) + | ^ use of type variable from outer function + +error[E0401]: can't use type parameters from outer function + --> $DIR/resolve-type-param-in-item-in-trait.rs:26:23 + | +LL | trait TraitB { + | - type variable from outer function +LL | fn outer(&self) { + | ----- try adding a local type parameter in this method instead +LL | struct Foo(A); + | ^ use of type variable from outer function + +error[E0401]: can't use type parameters from outer function + --> $DIR/resolve-type-param-in-item-in-trait.rs:33:28 + | +LL | trait TraitC { + | - type variable from outer function +LL | fn outer(&self) { + | ----- try adding a local type parameter in this method instead +LL | struct Foo { a: A } + | ^ use of type variable from outer function + +error[E0401]: can't use type parameters from outer function + --> $DIR/resolve-type-param-in-item-in-trait.rs:40:22 + | +LL | trait TraitD { + | - type variable from outer function +LL | fn outer(&self) { +LL | fn foo(a: A) { } + | ------ ^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `foo` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0401`. diff --git a/src/test/ui/compile-fail-migration/resolve-unknown-trait.rs b/src/test/ui/compile-fail-migration/resolve-unknown-trait.rs new file mode 100644 index 00000000000..9432e727fa5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-unknown-trait.rs @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +trait NewTrait : SomeNonExistentTrait {} +//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope + +impl SomeNonExistentTrait for isize {} +//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope + +fn f() {} +//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope diff --git a/src/test/ui/compile-fail-migration/resolve-unknown-trait.stderr b/src/test/ui/compile-fail-migration/resolve-unknown-trait.stderr new file mode 100644 index 00000000000..8a2d791654d --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-unknown-trait.stderr @@ -0,0 +1,26 @@ +error[E0405]: cannot find trait `SomeNonExistentTrait` in this scope + --> $DIR/resolve-unknown-trait.rs:12:18 + | +LL | trait NewTrait : SomeNonExistentTrait {} + | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0405]: cannot find trait `SomeNonExistentTrait` in this scope + --> $DIR/resolve-unknown-trait.rs:15:6 + | +LL | impl SomeNonExistentTrait for isize {} + | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0405]: cannot find trait `SomeNonExistentTrait` in this scope + --> $DIR/resolve-unknown-trait.rs:18:8 + | +LL | fn f() {} + | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0601]: `main` function not found in crate `resolve_unknown_trait` + | + = note: consider adding a `main` function to `$DIR/resolve-unknown-trait.rs` + +error: aborting due to 4 previous errors + +Some errors occurred: E0405, E0601. +For more information about an error, try `rustc --explain E0405`. diff --git a/src/test/ui/compile-fail-migration/resolve-variant-assoc-item.rs b/src/test/ui/compile-fail-migration/resolve-variant-assoc-item.rs new file mode 100644 index 00000000000..869eed5a8d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-variant-assoc-item.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum E { V } +use E::V; + +fn main() { + E::V::associated_item; //~ ERROR failed to resolve. Not a module `V` + V::associated_item; //~ ERROR failed to resolve. Not a module `V` +} diff --git a/src/test/ui/compile-fail-migration/resolve-variant-assoc-item.stderr b/src/test/ui/compile-fail-migration/resolve-variant-assoc-item.stderr new file mode 100644 index 00000000000..a80a7c39249 --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve-variant-assoc-item.stderr @@ -0,0 +1,15 @@ +error[E0433]: failed to resolve. Not a module `V` + --> $DIR/resolve-variant-assoc-item.rs:15:8 + | +LL | E::V::associated_item; //~ ERROR failed to resolve. Not a module `V` + | ^ Not a module `V` + +error[E0433]: failed to resolve. Not a module `V` + --> $DIR/resolve-variant-assoc-item.rs:16:5 + | +LL | V::associated_item; //~ ERROR failed to resolve. Not a module `V` + | ^ Not a module `V` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/resolve_self_super_hint.rs b/src/test/ui/compile-fail-migration/resolve_self_super_hint.rs new file mode 100644 index 00000000000..a89fd802baf --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve_self_super_hint.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(alloc)] +#![allow(unused_extern_crates)] + +mod a { + extern crate alloc; + use alloc::HashMap; + //~^ ERROR unresolved import `alloc` [E0432] + //~| Did you mean `self::alloc`? + mod b { + use alloc::HashMap; + //~^ ERROR unresolved import `alloc` [E0432] + //~| Did you mean `a::alloc`? + mod c { + use alloc::HashMap; + //~^ ERROR unresolved import `alloc` [E0432] + //~| Did you mean `a::alloc`? + mod d { + use alloc::HashMap; + //~^ ERROR unresolved import `alloc` [E0432] + //~| Did you mean `a::alloc`? + } + } + } +} diff --git a/src/test/ui/compile-fail-migration/resolve_self_super_hint.stderr b/src/test/ui/compile-fail-migration/resolve_self_super_hint.stderr new file mode 100644 index 00000000000..8538da06baf --- /dev/null +++ b/src/test/ui/compile-fail-migration/resolve_self_super_hint.stderr @@ -0,0 +1,32 @@ +error[E0432]: unresolved import `alloc` + --> $DIR/resolve_self_super_hint.rs:16:9 + | +LL | use alloc::HashMap; + | ^^^^^ Did you mean `self::alloc`? + +error[E0432]: unresolved import `alloc` + --> $DIR/resolve_self_super_hint.rs:20:13 + | +LL | use alloc::HashMap; + | ^^^^^ Did you mean `a::alloc`? + +error[E0432]: unresolved import `alloc` + --> $DIR/resolve_self_super_hint.rs:24:17 + | +LL | use alloc::HashMap; + | ^^^^^ Did you mean `a::alloc`? + +error[E0432]: unresolved import `alloc` + --> $DIR/resolve_self_super_hint.rs:28:21 + | +LL | use alloc::HashMap; + | ^^^^^ Did you mean `a::alloc`? + +error[E0601]: `main` function not found in crate `resolve_self_super_hint` + | + = note: consider adding a `main` function to `$DIR/resolve_self_super_hint.rs` + +error: aborting due to 5 previous errors + +Some errors occurred: E0432, E0601. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/ret-non-nil.rs b/src/test/ui/compile-fail-migration/ret-non-nil.rs new file mode 100644 index 00000000000..6be98fbd827 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ret-non-nil.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: `return;` in a function whose return type is not `()` + +fn f() { return; } + +fn g() -> isize { return; } + +fn main() { f(); g(); } diff --git a/src/test/ui/compile-fail-migration/ret-non-nil.stderr b/src/test/ui/compile-fail-migration/ret-non-nil.stderr new file mode 100644 index 00000000000..01f126bd11e --- /dev/null +++ b/src/test/ui/compile-fail-migration/ret-non-nil.stderr @@ -0,0 +1,9 @@ +error[E0069]: `return;` in a function whose return type is not `()` + --> $DIR/ret-non-nil.rs:15:19 + | +LL | fn g() -> isize { return; } + | ^^^^^^ return type is not () + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0069`. diff --git a/src/test/ui/compile-fail-migration/retslot-cast.rs b/src/test/ui/compile-fail-migration/retslot-cast.rs new file mode 100644 index 00000000000..c5e26a26744 --- /dev/null +++ b/src/test/ui/compile-fail-migration/retslot-cast.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(warnings)] + +pub fn fail(x: Option<&(Iterator+Send)>) + -> Option<&Iterator> { + // This call used to trigger an LLVM assertion because the return + // slot had type "Option<&Iterator>"* instead of + // "Option<&(Iterator+Send)>"* -- but this now yields a + // compilation error and I'm not sure how to create a comparable + // test. To ensure that this PARTICULAR failure doesn't occur + // again, though, I've left this test here, so if this ever starts + // to compile again, we can adjust the test appropriately (clearly + // it should never ICE...). -nmatsakis + inner(x) //~ ERROR mismatched types +} + +pub fn inner(x: Option<&(Iterator+Send)>) + -> Option<&(Iterator+Send)> { + x +} + +#[rustc_error] +fn main() {} diff --git a/src/test/ui/compile-fail-migration/retslot-cast.stderr b/src/test/ui/compile-fail-migration/retslot-cast.stderr new file mode 100644 index 00000000000..34f6e11f614 --- /dev/null +++ b/src/test/ui/compile-fail-migration/retslot-cast.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/retslot-cast.rs:24:5 + | +LL | inner(x) //~ ERROR mismatched types + | ^^^^^^^^ expected trait `std::iter::Iterator`, found trait `std::iter::Iterator + std::marker::Send` + | + = note: expected type `std::option::Option<&dyn std::iter::Iterator>` + found type `std::option::Option<&dyn std::iter::Iterator + std::marker::Send>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/return-from-diverging.rs b/src/test/ui/compile-fail-migration/return-from-diverging.rs new file mode 100644 index 00000000000..cec59faa918 --- /dev/null +++ b/src/test/ui/compile-fail-migration/return-from-diverging.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that return another type in place of ! raises a type mismatch. + +fn fail() -> ! { + return "wow"; //~ ERROR mismatched types +} + +fn main() { +} + diff --git a/src/test/ui/compile-fail-migration/return-from-diverging.stderr b/src/test/ui/compile-fail-migration/return-from-diverging.stderr new file mode 100644 index 00000000000..d965d734327 --- /dev/null +++ b/src/test/ui/compile-fail-migration/return-from-diverging.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/return-from-diverging.rs:14:12 + | +LL | return "wow"; //~ ERROR mismatched types + | ^^^^^ expected !, found reference + | + = note: expected type `!` + found type `&'static str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/return-unit-from-diverging.rs b/src/test/ui/compile-fail-migration/return-unit-from-diverging.rs new file mode 100644 index 00000000000..ae2a325b24a --- /dev/null +++ b/src/test/ui/compile-fail-migration/return-unit-from-diverging.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we get the usual error that we'd get for any other return type and not something about +// diverging functions not being able to return. + +fn fail() -> ! { + return; //~ ERROR in a function whose return type is not +} + +fn main() { +} + diff --git a/src/test/ui/compile-fail-migration/return-unit-from-diverging.stderr b/src/test/ui/compile-fail-migration/return-unit-from-diverging.stderr new file mode 100644 index 00000000000..38d4ca37366 --- /dev/null +++ b/src/test/ui/compile-fail-migration/return-unit-from-diverging.stderr @@ -0,0 +1,9 @@ +error[E0069]: `return;` in a function whose return type is not `()` + --> $DIR/return-unit-from-diverging.rs:15:5 + | +LL | return; //~ ERROR in a function whose return type is not + | ^^^^^^ return type is not () + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0069`. diff --git a/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.rs b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.rs new file mode 100644 index 00000000000..49f5621de1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() -> i32 { +//~^ ERROR `main` has invalid return type `i32` +//~| NOTE `main` can only return types that implement `std::process::Termination` +//~| HELP consider using `()`, or a `Result` + 0 +} diff --git a/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.stderr b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.stderr new file mode 100644 index 00000000000..6f780d1cf1d --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-main-i32.stderr @@ -0,0 +1,11 @@ +error[E0277]: `main` has invalid return type `i32` + --> $DIR/termination-trait-main-i32.rs:11:14 + | +LL | fn main() -> i32 { + | ^^^ `main` can only return types that implement `std::process::Termination` + | + = help: consider using `()`, or a `Result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.rs b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.rs new file mode 100644 index 00000000000..b5f5472b492 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct ReturnType {} + +fn main() -> ReturnType { //~ ERROR `main` has invalid return type `ReturnType` + ReturnType {} +} diff --git a/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr new file mode 100644 index 00000000000..e1b173725d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-1937-termination-trait/termination-trait-not-satisfied.stderr @@ -0,0 +1,11 @@ +error[E0277]: `main` has invalid return type `ReturnType` + --> $DIR/termination-trait-not-satisfied.rs:13:14 + | +LL | fn main() -> ReturnType { //~ ERROR `main` has invalid return type `ReturnType` + | ^^^^^^^^^^ `main` can only return types that implement `std::process::Termination` + | + = help: consider using `()`, or a `Result` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/enums.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/enums.rs new file mode 100644 index 00000000000..12d1bf9ea91 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/enums.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(non_exhaustive)] + +#[non_exhaustive] +pub enum NonExhaustiveEnum { + Unit, + Tuple(u32), + Struct { field: u32 } +} diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/structs.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/structs.rs new file mode 100644 index 00000000000..4d083cc5315 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/structs.rs @@ -0,0 +1,37 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(non_exhaustive)] + +#[non_exhaustive] +pub struct NormalStruct { + pub first_field: u16, + pub second_field: u16, +} + +#[non_exhaustive] +pub struct UnitStruct; + +#[non_exhaustive] +pub struct TupleStruct(pub u16, pub u16); + +#[derive(Debug)] +#[non_exhaustive] +pub struct FunctionalRecord { + pub first_field: u16, + pub second_field: u16, + pub third_field: bool +} + +impl Default for FunctionalRecord { + fn default() -> FunctionalRecord { + FunctionalRecord { first_field: 640, second_field: 480, third_field: false } + } +} diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/variants.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/variants.rs new file mode 100644 index 00000000000..d04c1073ad9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/auxiliary/variants.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(non_exhaustive)] + +pub enum NonExhaustiveVariants { + #[non_exhaustive] Unit, + #[non_exhaustive] Tuple(u32), + #[non_exhaustive] Struct { field: u32 } +} diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.rs new file mode 100644 index 00000000000..0c19210e4a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:enums.rs +extern crate enums; + +use enums::NonExhaustiveEnum; + +fn main() { + let enum_unit = NonExhaustiveEnum::Unit; + + match enum_unit { + //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] + NonExhaustiveEnum::Unit => "first", + NonExhaustiveEnum::Tuple(_) => "second", + NonExhaustiveEnum::Struct { .. } => "third" + }; +} diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.stderr b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.stderr new file mode 100644 index 00000000000..5276746734d --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/enum.stderr @@ -0,0 +1,9 @@ +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/enum.rs:19:11 + | +LL | match enum_unit { + | ^^^^^^^^^ pattern `_` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.rs new file mode 100644 index 00000000000..df4fe1e77e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.rs @@ -0,0 +1,28 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(non_exhaustive)] + +#[non_exhaustive(anything)] +//~^ ERROR attribute should be empty [E0702] +struct Foo; + +#[non_exhaustive] +//~^ ERROR attribute can only be applied to a struct or enum [E0701] +trait Bar { } + +#[non_exhaustive] +//~^ ERROR attribute can only be applied to a struct or enum [E0701] +union Baz { + f1: u16, + f2: u16 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.stderr b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.stderr new file mode 100644 index 00000000000..d75ad9ec264 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/invalid-attribute.stderr @@ -0,0 +1,34 @@ +error[E0702]: attribute should be empty + --> $DIR/invalid-attribute.rs:13:1 + | +LL | #[non_exhaustive(anything)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | //~^ ERROR attribute should be empty [E0702] +LL | struct Foo; + | ----------- not empty + +error[E0701]: attribute can only be applied to a struct or enum + --> $DIR/invalid-attribute.rs:17:1 + | +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ +LL | //~^ ERROR attribute can only be applied to a struct or enum [E0701] +LL | trait Bar { } + | ------------- not a struct or enum + +error[E0701]: attribute can only be applied to a struct or enum + --> $DIR/invalid-attribute.rs:21:1 + | +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ +LL | //~^ ERROR attribute can only be applied to a struct or enum [E0701] +LL | / union Baz { +LL | | f1: u16, +LL | | f2: u16 +LL | | } + | |_- not a struct or enum + +error: aborting due to 3 previous errors + +Some errors occurred: E0701, E0702. +For more information about an error, try `rustc --explain E0701`. diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.rs new file mode 100644 index 00000000000..74c9c7c61ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.rs @@ -0,0 +1,47 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:structs.rs +extern crate structs; + +use structs::{NormalStruct, UnitStruct, TupleStruct, FunctionalRecord}; + +fn main() { + let fr = FunctionalRecord { + //~^ ERROR cannot create non-exhaustive struct + first_field: 1920, + second_field: 1080, + ..FunctionalRecord::default() + }; + + let ns = NormalStruct { first_field: 640, second_field: 480 }; + //~^ ERROR cannot create non-exhaustive struct + + let NormalStruct { first_field, second_field } = ns; + //~^ ERROR `..` required with struct marked as non-exhaustive + + let ts = TupleStruct(640, 480); + //~^ ERROR expected function, found struct `TupleStruct` [E0423] + + let ts_explicit = structs::TupleStruct(640, 480); + //~^ ERROR tuple struct `TupleStruct` is private [E0603] + + let TupleStruct { 0: first_field, 1: second_field } = ts; + //~^ ERROR `..` required with struct marked as non-exhaustive + + let us = UnitStruct; + //~^ ERROR expected value, found struct `UnitStruct` [E0423] + + let us_explicit = structs::UnitStruct; + //~^ ERROR unit struct `UnitStruct` is private [E0603] + + let UnitStruct { } = us; + //~^ ERROR `..` required with struct marked as non-exhaustive +} diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.stderr b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.stderr new file mode 100644 index 00000000000..c0f7e278671 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/structs.stderr @@ -0,0 +1,64 @@ +error[E0423]: expected function, found struct `TupleStruct` + --> $DIR/structs.rs:30:14 + | +LL | let ts = TupleStruct(640, 480); + | ^^^^^^^^^^^ constructor is not visible here due to private fields + +error[E0423]: expected value, found struct `UnitStruct` + --> $DIR/structs.rs:39:14 + | +LL | let us = UnitStruct; + | ^^^^^^^^^^ constructor is not visible here due to private fields + +error[E0603]: tuple struct `TupleStruct` is private + --> $DIR/structs.rs:33:23 + | +LL | let ts_explicit = structs::TupleStruct(640, 480); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: unit struct `UnitStruct` is private + --> $DIR/structs.rs:42:23 + | +LL | let us_explicit = structs::UnitStruct; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0639]: cannot create non-exhaustive struct using struct expression + --> $DIR/structs.rs:17:14 + | +LL | let fr = FunctionalRecord { + | ______________^ +LL | | //~^ ERROR cannot create non-exhaustive struct +LL | | first_field: 1920, +LL | | second_field: 1080, +LL | | ..FunctionalRecord::default() +LL | | }; + | |_____^ + +error[E0639]: cannot create non-exhaustive struct using struct expression + --> $DIR/structs.rs:24:14 + | +LL | let ns = NormalStruct { first_field: 640, second_field: 480 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0638]: `..` required with struct marked as non-exhaustive + --> $DIR/structs.rs:27:9 + | +LL | let NormalStruct { first_field, second_field } = ns; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0638]: `..` required with struct marked as non-exhaustive + --> $DIR/structs.rs:36:9 + | +LL | let TupleStruct { 0: first_field, 1: second_field } = ts; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0638]: `..` required with struct marked as non-exhaustive + --> $DIR/structs.rs:45:9 + | +LL | let UnitStruct { } = us; + | ^^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + +Some errors occurred: E0423, E0603, E0638, E0639. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants.rs new file mode 100644 index 00000000000..d1b65ac1f3e --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants.rs @@ -0,0 +1,36 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:variants.rs +extern crate variants; + +use variants::NonExhaustiveVariants; + +/* + * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for + * variants. See issue #44109 and PR 45394. + */ +// ignore-test + +fn main() { + let variant_struct = NonExhaustiveVariants::Struct { field: 640 }; + //~^ ERROR cannot create non-exhaustive variant + + let variant_tuple = NonExhaustiveVariants::Tuple { 0: 640 }; + //~^ ERROR cannot create non-exhaustive variant + + match variant_struct { + NonExhaustiveVariants::Unit => "", + NonExhaustiveVariants::Tuple(fe_tpl) => "", + //~^ ERROR `..` required with variant marked as non-exhaustive + NonExhaustiveVariants::Struct { field } => "" + //~^ ERROR `..` required with variant marked as non-exhaustive + }; +} diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.rs b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.rs new file mode 100644 index 00000000000..f4e4b1bb84b --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(non_exhaustive)] + +/* + * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for + * variants. See issue #44109 and PR 45394. + */ + +pub enum NonExhaustiveVariants { + #[non_exhaustive] Unit, + //~^ ERROR #[non_exhaustive] is not yet supported on variants + #[non_exhaustive] Tuple(u32), + //~^ ERROR #[non_exhaustive] is not yet supported on variants + #[non_exhaustive] Struct { field: u32 } + //~^ ERROR #[non_exhaustive] is not yet supported on variants +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.stderr b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.stderr new file mode 100644 index 00000000000..1e4e0943a69 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2008-non-exhaustive/variants_create.stderr @@ -0,0 +1,20 @@ +error: #[non_exhaustive] is not yet supported on variants + --> $DIR/variants_create.rs:19:23 + | +LL | #[non_exhaustive] Unit, + | ^^^^ + +error: #[non_exhaustive] is not yet supported on variants + --> $DIR/variants_create.rs:21:23 + | +LL | #[non_exhaustive] Tuple(u32), + | ^^^^^^^^^^ + +error: #[non_exhaustive] is not yet supported on variants + --> $DIR/variants_create.rs:23:23 + | +LL | #[non_exhaustive] Struct { field: u32 } + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.rs b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.rs new file mode 100644 index 00000000000..65f11c063ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(crate_in_paths)] + +struct S; + +pub mod m { + fn f() { + let s = ::m::crate::S; //~ ERROR failed to resolve + let s2 = crate::S; // no error + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.stderr b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.stderr new file mode 100644 index 00000000000..f4d33e0b9db --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/crate-path-non-absolute.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. Could not find `crate` in `m` + --> $DIR/crate-path-non-absolute.rs:17:22 + | +LL | let s = ::m::crate::S; //~ ERROR failed to resolve + | ^^^^^ Could not find `crate` in `m` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.rs b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.rs new file mode 100644 index 00000000000..bdd03be4356 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(crate_in_paths)] + +fn main() { + let crate = 0; //~ ERROR failed to resolve. `crate` in paths can only be used in start position +} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr new file mode 100644 index 00000000000..e4d2db057f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-crate-paths/keyword-crate-as-identifier.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. `crate` in paths can only be used in start position + --> $DIR/keyword-crate-as-identifier.rs:14:9 + | +LL | let crate = 0; //~ ERROR failed to resolve. `crate` in paths can only be used in start position + | ^^^^^ `crate` in paths can only be used in start position + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs new file mode 100644 index 00000000000..c3da4a51872 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +pub struct S; + +#[derive(Debug)] +pub struct Z; diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.rs new file mode 100644 index 00000000000..826bf675bd6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 + +use xcrate::S; //~ ERROR can't find crate for `xcrate` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.stderr new file mode 100644 index 00000000000..27a69ec1b1f --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-1.stderr @@ -0,0 +1,9 @@ +error[E0463]: can't find crate for `xcrate` + --> $DIR/non-existent-1.rs:13:5 + | +LL | use xcrate::S; //~ ERROR can't find crate for `xcrate` + | ^^^^^^ can't find crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.rs new file mode 100644 index 00000000000..053bf92f4d1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 + +fn main() { + let s = ::xcrate::S; //~ ERROR can't find crate for `xcrate` +} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.stderr new file mode 100644 index 00000000000..eb96d5f05d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-2.stderr @@ -0,0 +1,9 @@ +error[E0463]: can't find crate for `xcrate` + --> $DIR/non-existent-2.rs:14:15 + | +LL | let s = ::xcrate::S; //~ ERROR can't find crate for `xcrate` + | ^^^^^^ can't find crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.rs new file mode 100644 index 00000000000..1b9e5a75e83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 + +use ycrate; //~ ERROR can't find crate for `ycrate` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.stderr new file mode 100644 index 00000000000..434bde79a83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/non-existent-3.stderr @@ -0,0 +1,9 @@ +error[E0463]: can't find crate for `ycrate` + --> $DIR/non-existent-3.rs:13:5 + | +LL | use ycrate; //~ ERROR can't find crate for `ycrate` + | ^^^^^^ can't find crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.rs new file mode 100644 index 00000000000..69fc4b4f7f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:xcrate.rs +// edition:2018 + +use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` +use *; //~ ERROR cannot glob-import all possible crates + +fn main() { + let s = ::xcrate; //~ ERROR expected value, found module `xcrate` + //~^ NOTE not a value +} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.stderr new file mode 100644 index 00000000000..02363a01e3c --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-absolute-paths/single-segment.stderr @@ -0,0 +1,22 @@ +error[E0432]: unresolved import `*` + --> $DIR/single-segment.rs:16:5 + | +LL | use *; //~ ERROR unresolved import `*` + | ^ cannot glob-import all possible crates + +error[E0432]: unresolved import `crate` + --> $DIR/single-segment.rs:14:5 + | +LL | use crate; //~ ERROR unresolved import `crate` + | ^^^^^ crate root imports need to be explicitly named: `use crate as name;` + +error[E0423]: expected value, found module `xcrate` + --> $DIR/single-segment.rs:20:13 + | +LL | let s = ::xcrate; //~ ERROR expected value, found module `xcrate` + | ^^^^^^^^ not a value + +error: aborting due to 3 previous errors + +Some errors occurred: E0423, E0432. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/auxiliary/xcrate.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/auxiliary/xcrate.rs new file mode 100644 index 00000000000..c3da4a51872 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/auxiliary/xcrate.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +pub struct S; + +#[derive(Debug)] +pub struct Z; diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.rs new file mode 100644 index 00000000000..7eba02ed444 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_in_paths)] + +use extern::xcrate::S; //~ ERROR can't find crate for `xcrate` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.stderr new file mode 100644 index 00000000000..c25698c395e --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-1.stderr @@ -0,0 +1,9 @@ +error[E0463]: can't find crate for `xcrate` + --> $DIR/non-existent-1.rs:13:13 + | +LL | use extern::xcrate::S; //~ ERROR can't find crate for `xcrate` + | ^^^^^^ can't find crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.rs new file mode 100644 index 00000000000..4d09a05253e --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_in_paths)] + +fn main() { + let s = extern::xcrate::S; //~ ERROR can't find crate for `xcrate` +} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.stderr new file mode 100644 index 00000000000..b7ca8890c19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-2.stderr @@ -0,0 +1,9 @@ +error[E0463]: can't find crate for `xcrate` + --> $DIR/non-existent-2.rs:14:21 + | +LL | let s = extern::xcrate::S; //~ ERROR can't find crate for `xcrate` + | ^^^^^^ can't find crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.rs new file mode 100644 index 00000000000..402d294b2e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_in_paths)] + +use extern::ycrate; //~ ERROR can't find crate for `ycrate` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.stderr new file mode 100644 index 00000000000..3dc93e2a426 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/non-existent-3.stderr @@ -0,0 +1,9 @@ +error[E0463]: can't find crate for `ycrate` + --> $DIR/non-existent-3.rs:13:5 + | +LL | use extern::ycrate; //~ ERROR can't find crate for `ycrate` + | ^^^^^^^^^^^^^^ can't find crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.rs b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.rs new file mode 100644 index 00000000000..017844a0252 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:xcrate.rs + +#![feature(extern_in_paths)] + +use extern; //~ ERROR unresolved import `extern` + //~^ NOTE no `extern` in the root +use extern::*; //~ ERROR cannot glob-import all possible crates + +fn main() { + let s = extern::xcrate; //~ ERROR expected value, found module `extern::xcrate` + //~^ NOTE not a value +} diff --git a/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.stderr b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.stderr new file mode 100644 index 00000000000..362f77effde --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc-2126-extern-in-paths/single-segment.stderr @@ -0,0 +1,22 @@ +error[E0432]: unresolved import `extern::*` + --> $DIR/single-segment.rs:17:5 + | +LL | use extern::*; //~ ERROR unresolved import `extern::*` + | ^^^^^^^^^ cannot glob-import all possible crates + +error[E0432]: unresolved import `extern` + --> $DIR/single-segment.rs:15:5 + | +LL | use extern; //~ ERROR unresolved import `extern` + | ^^^^^^ no `extern` in the root + +error[E0423]: expected value, found module `extern::xcrate` + --> $DIR/single-segment.rs:21:13 + | +LL | let s = extern::xcrate; //~ ERROR expected value, found module `extern::xcrate` + | ^^^^^^^^^^^^^^ not a value + +error: aborting due to 3 previous errors + +Some errors occurred: E0423, E0432. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/compile-fail-migration/rfc1445/feature-gate.no_gate.stderr b/src/test/ui/compile-fail-migration/rfc1445/feature-gate.no_gate.stderr new file mode 100644 index 00000000000..1141b79c7c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1445/feature-gate.no_gate.stderr @@ -0,0 +1,11 @@ +error[E0658]: the semantics of constant patterns is not yet settled (see issue #31434) + --> $DIR/feature-gate.rs:23:1 + | +LL | #[structural_match] //[no_gate]~ ERROR semantics of constant patterns is not yet settled + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(structural_match)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/rfc1445/feature-gate.rs b/src/test/ui/compile-fail-migration/rfc1445/feature-gate.rs new file mode 100644 index 00000000000..f729220eabb --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1445/feature-gate.rs @@ -0,0 +1,37 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that structural match is only permitted with a feature gate, +// and that if a feature gate is supplied, it permits the type to be +// used in a match. + +// revisions: with_gate no_gate + +// gate-test-structural_match + +#![allow(unused)] +#![feature(rustc_attrs)] +#![cfg_attr(with_gate, feature(structural_match))] + +#[structural_match] //[no_gate]~ ERROR semantics of constant patterns is not yet settled +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +#[rustc_error] +fn main() { //[with_gate]~ ERROR compilation successful + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} diff --git a/src/test/ui/compile-fail-migration/rfc1445/feature-gate.with_gate.stderr b/src/test/ui/compile-fail-migration/rfc1445/feature-gate.with_gate.stderr new file mode 100644 index 00000000000..87835162c93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1445/feature-gate.with_gate.stderr @@ -0,0 +1,14 @@ +error: compilation successful + --> $DIR/feature-gate.rs:31:1 + | +LL | / fn main() { //[with_gate]~ ERROR compilation successful +LL | | let y = Foo { x: 1 }; +LL | | match y { +LL | | FOO => { } +LL | | _ => { } +LL | | } +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.rs b/src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.rs new file mode 100644 index 00000000000..ca9af78dd99 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::f32; + +#[derive(PartialEq)] +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + _ => { } + } + + let x = 0.0; + match x { + f32::INFINITY => { } + //~^ WARNING floating-point types cannot be used in patterns + //~| WARNING will become a hard error in a future release + _ => { } + } +} diff --git a/src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.stderr b/src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.stderr new file mode 100644 index 00000000000..a2cb536b212 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1445/match-forbidden-without-eq.stderr @@ -0,0 +1,18 @@ +error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/match-forbidden-without-eq.rs:23:9 + | +LL | FOO => { } + | ^^^ + +warning: floating-point types cannot be used in patterns + --> $DIR/match-forbidden-without-eq.rs:30:9 + | +LL | f32::INFINITY => { } + | ^^^^^^^^^^^^^ + | + = note: #[warn(illegal_floating_point_literal_pattern)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41620 + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.rs b/src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.rs new file mode 100644 index 00000000000..e02f9153e7e --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.rs @@ -0,0 +1,31 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Eq)] +struct Foo { + x: u32 +} + +impl PartialEq for Foo { + fn eq(&self, _: &Foo) -> bool { + false // ha ha sucker! + } +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + _ => { } + } +} diff --git a/src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.stderr b/src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.stderr new file mode 100644 index 00000000000..60f3191cd27 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1445/match-requires-both-partialeq-and-eq.stderr @@ -0,0 +1,8 @@ +error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/match-requires-both-partialeq-and-eq.rs:27:9 + | +LL | FOO => { } + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rfc1623.rs b/src/test/ui/compile-fail-migration/rfc1623.rs new file mode 100644 index 00000000000..579fa378a1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1623.rs @@ -0,0 +1,102 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![allow(dead_code)] + +fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { + a +} + +// the boundaries of elision +static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = +//~^ ERROR missing lifetime specifier [E0106] + &(non_elidable as fn(&u8, &u8) -> &u8); + //~^ ERROR missing lifetime specifier [E0106] + +struct SomeStruct<'x, 'y, 'z: 'x> { + foo: &'x Foo<'z>, + bar: &'x Bar<'z>, + f: &'y for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>, +} + +fn id(t: T) -> T { + t +} + +static SOME_STRUCT: &SomeStruct = SomeStruct { + foo: &Foo { bools: &[false, true] }, + bar: &Bar { bools: &[true, true] }, + f: &id, +}; + +// very simple test for a 'static static with default lifetime +static STATIC_STR: &'static str = "&'static str"; +const CONST_STR: &'static str = "&'static str"; + +// this should be the same as without default: +static EXPLICIT_STATIC_STR: &'static str = "&'static str"; +const EXPLICIT_CONST_STR: &'static str = "&'static str"; + +// a function that elides to an unbound lifetime for both in- and output +fn id_u8_slice(arg: &[u8]) -> &[u8] { + arg +} + +// one with a function, argument elided +static STATIC_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); +const CONST_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); + +// this should be the same as without elision +static STATIC_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); +const CONST_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); + +// another function that elides, each to a different unbound lifetime +fn multi_args(a: &u8, b: &u8, c: &u8) {} + +static STATIC_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); +const CONST_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); + +struct Foo<'a> { + bools: &'a [bool], +} + +static STATIC_FOO: Foo<'static> = Foo { bools: &[true, false] }; +const CONST_FOO: Foo<'static> = Foo { bools: &[true, false] }; + +type Bar<'a> = Foo<'a>; + +static STATIC_BAR: Bar<'static> = Bar { bools: &[true, false] }; +const CONST_BAR: Bar<'static> = Bar { bools: &[true, false] }; + +type Baz<'a> = fn(&'a [u8]) -> Option; + +fn baz(e: &[u8]) -> Option { + e.first().map(|x| *x) +} + +static STATIC_BAZ: &'static Baz<'static> = &(baz as Baz); +const CONST_BAZ: &'static Baz<'static> = &(baz as Baz); + +static BYTES: &'static [u8] = &[1, 2, 3]; + +fn main() { + let x = &[1u8, 2, 3]; + let y = x; + + // this works, so lifetime < `'static` is valid + assert_eq!(Some(1), STATIC_BAZ(y)); + assert_eq!(Some(1), CONST_BAZ(y)); + + let y = &[1u8, 2, 3]; + + STATIC_BAZ(BYTES); // BYTES has static lifetime + CONST_BAZ(y); // interestingly this does not get reported +} diff --git a/src/test/ui/compile-fail-migration/rfc1623.stderr b/src/test/ui/compile-fail-migration/rfc1623.stderr new file mode 100644 index 00000000000..3815558fb25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1623.stderr @@ -0,0 +1,19 @@ +error[E0106]: missing lifetime specifier + --> $DIR/rfc1623.rs:17:42 + | +LL | static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = + | ^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 + +error[E0106]: missing lifetime specifier + --> $DIR/rfc1623.rs:19:39 + | +LL | &(non_elidable as fn(&u8, &u8) -> &u8); + | ^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.rs b/src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.rs new file mode 100644 index 00000000000..810efdedfd6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -l foo:bar +// error-pattern: renaming of the library `foo` was specified + +#![crate_type = "lib"] diff --git a/src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.stderr b/src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.stderr new file mode 100644 index 00000000000..30555e80944 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1717/missing-link-attr.stderr @@ -0,0 +1,4 @@ +error: renaming of the library `foo` was specified, however this crate contains no #[link(...)] attributes referencing this library. + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rfc1717/multiple-renames.rs b/src/test/ui/compile-fail-migration/rfc1717/multiple-renames.rs new file mode 100644 index 00000000000..e75c1a14b24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1717/multiple-renames.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -l foo:bar -l foo:baz +// error-pattern: multiple renamings were specified for library + +#![crate_type = "lib"] + +#[link(name = "foo")] +extern "C" {} diff --git a/src/test/ui/compile-fail-migration/rfc1717/multiple-renames.stderr b/src/test/ui/compile-fail-migration/rfc1717/multiple-renames.stderr new file mode 100644 index 00000000000..4e5a3647fa2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1717/multiple-renames.stderr @@ -0,0 +1,4 @@ +error: multiple renamings were specified for library `foo` . + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.rs b/src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.rs new file mode 100644 index 00000000000..ab8c238bc27 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -l foo: +// error-pattern: an empty renaming target was specified for library + +#![crate_type = "lib"] + +#[link(name = "foo")] +extern "C" {} diff --git a/src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.stderr b/src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.stderr new file mode 100644 index 00000000000..aca839d804f --- /dev/null +++ b/src/test/ui/compile-fail-migration/rfc1717/rename-to-empty.stderr @@ -0,0 +1,4 @@ +error: an empty renaming target was specified for library `foo` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rmeta-lib-pass.rs b/src/test/ui/compile-fail-migration/rmeta-lib-pass.rs new file mode 100644 index 00000000000..2df6a659724 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta-lib-pass.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --emit=metadata +// aux-build:rmeta_rlib.rs +// no-prefer-dynamic +// compile-pass + +// Check that building a metadata crate works with a dependent, rlib crate. +// This is a cfail test since there is no executable to run. + +extern crate rmeta_rlib; +use rmeta_rlib::Foo; + +pub fn main() { + let _ = Foo { field: 42 }; +} diff --git a/src/test/ui/compile-fail-migration/rmeta-pass.rs b/src/test/ui/compile-fail-migration/rmeta-pass.rs new file mode 100644 index 00000000000..6ee914c5e5b --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta-pass.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --emit=metadata +// aux-build:rmeta_meta.rs +// no-prefer-dynamic +// compile-pass + +// Check that building a metadata crate works with a dependent, metadata-only +// crate. +// This is a cfail test since there is no executable to run. + +extern crate rmeta_meta; +use rmeta_meta::Foo; + +pub fn main() { + let _ = Foo { field: 42 }; +} diff --git a/src/test/ui/compile-fail-migration/rmeta-priv-warn.rs b/src/test/ui/compile-fail-migration/rmeta-priv-warn.rs new file mode 100644 index 00000000000..bcf869c9432 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta-priv-warn.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --emit=metadata +// no-prefer-dynamic +// compile-pass + +#[deny(warnings)] + +// Test that we don't get warnings for non-pub main when only emitting metadata. +// (#38273) + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/rmeta.rs b/src/test/ui/compile-fail-migration/rmeta.rs new file mode 100644 index 00000000000..962fe9f66aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: --emit=metadata + +// Check that building a metadata crate finds an error. + +fn main() { + let _ = Foo; //~ ERROR cannot find value `Foo` in this scope +} diff --git a/src/test/ui/compile-fail-migration/rmeta.stderr b/src/test/ui/compile-fail-migration/rmeta.stderr new file mode 100644 index 00000000000..fa154f81b29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `Foo` in this scope + --> $DIR/rmeta.rs:17:13 + | +LL | let _ = Foo; //~ ERROR cannot find value `Foo` in this scope + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/rmeta_lib.rs b/src/test/ui/compile-fail-migration/rmeta_lib.rs new file mode 100644 index 00000000000..a61ff05e8c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta_lib.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:rmeta_meta.rs +// no-prefer-dynamic +// error-pattern: crate `rmeta_meta` required to be available in rlib format, but was not found + +// Check that building a non-metadata crate fails if a dependent crate is +// metadata-only. + +extern crate rmeta_meta; +use rmeta_meta::Foo; + +fn main() { + let _ = Foo { field: 42 }; +} diff --git a/src/test/ui/compile-fail-migration/rmeta_lib.stderr b/src/test/ui/compile-fail-migration/rmeta_lib.stderr new file mode 100644 index 00000000000..8a9179cca6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta_lib.stderr @@ -0,0 +1,4 @@ +error: crate `rmeta_meta` required to be available in rlib format, but was not found in this form + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rmeta_meta_main.rs b/src/test/ui/compile-fail-migration/rmeta_meta_main.rs new file mode 100644 index 00000000000..ffeb5bc3b85 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta_meta_main.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --emit=metadata +// aux-build:rmeta_meta.rs +// no-prefer-dynamic + +// Check that building a metadata crate finds an error with a dependent, +// metadata-only crate. + + +extern crate rmeta_meta; +use rmeta_meta::Foo; + +fn main() { + let _ = Foo { field2: 42 }; //~ ERROR struct `rmeta_meta::Foo` has no field named `field2` +} diff --git a/src/test/ui/compile-fail-migration/rmeta_meta_main.stderr b/src/test/ui/compile-fail-migration/rmeta_meta_main.stderr new file mode 100644 index 00000000000..f246a8b5f63 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rmeta_meta_main.stderr @@ -0,0 +1,9 @@ +error[E0560]: struct `rmeta_meta::Foo` has no field named `field2` + --> $DIR/rmeta_meta_main.rs:23:19 + | +LL | let _ = Foo { field2: 42 }; //~ ERROR struct `rmeta_meta::Foo` has no field named `field2` + | ^^^^^^ field does not exist - did you mean `field`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0560`. diff --git a/src/test/ui/compile-fail-migration/rust-unstable-column-gated.rs b/src/test/ui/compile-fail-migration/rust-unstable-column-gated.rs new file mode 100644 index 00000000000..abc92c86eec --- /dev/null +++ b/src/test/ui/compile-fail-migration/rust-unstable-column-gated.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("{}", __rust_unstable_column!()); + //~^ERROR the __rust_unstable_column macro is unstable +} diff --git a/src/test/ui/compile-fail-migration/rust-unstable-column-gated.stderr b/src/test/ui/compile-fail-migration/rust-unstable-column-gated.stderr new file mode 100644 index 00000000000..785fcd7af42 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rust-unstable-column-gated.stderr @@ -0,0 +1,8 @@ +error: the __rust_unstable_column macro is unstable + --> $DIR/rust-unstable-column-gated.rs:12:20 + | +LL | println!("{}", __rust_unstable_column!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rustc-args-required-const.rs b/src/test/ui/compile-fail-migration/rustc-args-required-const.rs new file mode 100644 index 00000000000..aac9299eaaf --- /dev/null +++ b/src/test/ui/compile-fail-migration/rustc-args-required-const.rs @@ -0,0 +1,36 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(attr_literals, rustc_attrs, const_fn)] + +#[rustc_args_required_const(0)] +fn foo(_a: i32) { +} + +#[rustc_args_required_const(1)] +fn bar(_a: i32, _b: i32) { +} + +const A: i32 = 3; + +const fn baz() -> i32 { + 3 +} + +fn main() { + foo(2); + foo(2 + 3); + foo(baz()); + let a = 4; + foo(A); + foo(a); //~ ERROR: argument 1 is required to be a constant + bar(a, 3); + bar(a, a); //~ ERROR: argument 2 is required to be a constant +} diff --git a/src/test/ui/compile-fail-migration/rustc-args-required-const.stderr b/src/test/ui/compile-fail-migration/rustc-args-required-const.stderr new file mode 100644 index 00000000000..07f2d880c82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rustc-args-required-const.stderr @@ -0,0 +1,14 @@ +error: argument 1 is required to be a constant + --> $DIR/rustc-args-required-const.rs:33:5 + | +LL | foo(a); //~ ERROR: argument 1 is required to be a constant + | ^^^^^^ + +error: argument 2 is required to be a constant + --> $DIR/rustc-args-required-const.rs:35:5 + | +LL | bar(a, a); //~ ERROR: argument 2 is required to be a constant + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/rustc-args-required-const2.rs b/src/test/ui/compile-fail-migration/rustc-args-required-const2.rs new file mode 100644 index 00000000000..aa63019307b --- /dev/null +++ b/src/test/ui/compile-fail-migration/rustc-args-required-const2.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(attr_literals, rustc_attrs, const_fn)] + +#[rustc_args_required_const(0)] +fn foo(_a: i32) { +} + +fn main() { + let a = foo; //~ ERROR: this function can only be invoked directly + a(2); +} diff --git a/src/test/ui/compile-fail-migration/rustc-args-required-const2.stderr b/src/test/ui/compile-fail-migration/rustc-args-required-const2.stderr new file mode 100644 index 00000000000..766f8adb0b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rustc-args-required-const2.stderr @@ -0,0 +1,8 @@ +error: this function can only be invoked directly, not through a function pointer + --> $DIR/rustc-args-required-const2.rs:18:13 + | +LL | let a = foo; //~ ERROR: this function can only be invoked directly + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/rustc-error.rs b/src/test/ui/compile-fail-migration/rustc-error.rs new file mode 100644 index 00000000000..82f32cbcd14 --- /dev/null +++ b/src/test/ui/compile-fail-migration/rustc-error.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +#[rustc_error] +fn main() { + //~^ ERROR compilation successful +} diff --git a/src/test/ui/compile-fail-migration/rustc-error.stderr b/src/test/ui/compile-fail-migration/rustc-error.stderr new file mode 100644 index 00000000000..7456d2af51f --- /dev/null +++ b/src/test/ui/compile-fail-migration/rustc-error.stderr @@ -0,0 +1,10 @@ +error: compilation successful + --> $DIR/rustc-error.rs:14:1 + | +LL | / fn main() { +LL | | //~^ ERROR compilation successful +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/safe-extern-statics-mut.rs b/src/test/ui/compile-fail-migration/safe-extern-statics-mut.rs new file mode 100644 index 00000000000..35ea6dd52c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/safe-extern-statics-mut.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:extern-statics.rs + +extern crate extern_statics; +use extern_statics::*; + +extern { + static mut B: u8; +} + +fn main() { + let b = B; //~ ERROR use of mutable static is unsafe + let rb = &B; //~ ERROR use of mutable static is unsafe + let xb = XB; //~ ERROR use of mutable static is unsafe + let xrb = &XB; //~ ERROR use of mutable static is unsafe +} diff --git a/src/test/ui/compile-fail-migration/safe-extern-statics-mut.stderr b/src/test/ui/compile-fail-migration/safe-extern-statics-mut.stderr new file mode 100644 index 00000000000..f48dce65afa --- /dev/null +++ b/src/test/ui/compile-fail-migration/safe-extern-statics-mut.stderr @@ -0,0 +1,35 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:21:13 + | +LL | let b = B; //~ ERROR use of mutable static is unsafe + | ^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:22:14 + | +LL | let rb = &B; //~ ERROR use of mutable static is unsafe + | ^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:23:14 + | +LL | let xb = XB; //~ ERROR use of mutable static is unsafe + | ^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/safe-extern-statics-mut.rs:24:15 + | +LL | let xrb = &XB; //~ ERROR use of mutable static is unsafe + | ^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/safe-extern-statics.rs b/src/test/ui/compile-fail-migration/safe-extern-statics.rs new file mode 100644 index 00000000000..83aa4b3316d --- /dev/null +++ b/src/test/ui/compile-fail-migration/safe-extern-statics.rs @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:extern-statics.rs + +#![allow(unused)] + +extern crate extern_statics; +use extern_statics::*; + +extern { + static A: u8; +} + +fn main() { + let a = A; //~ ERROR use of extern static is unsafe + //~^ WARN this was previously accepted by the compiler + let ra = &A; //~ ERROR use of extern static is unsafe + //~^ WARN this was previously accepted by the compiler + let xa = XA; //~ ERROR use of extern static is unsafe + //~^ WARN this was previously accepted by the compiler + let xra = &XA; //~ ERROR use of extern static is unsafe + //~^ WARN this was previously accepted by the compiler +} diff --git a/src/test/ui/compile-fail-migration/safe-extern-statics.stderr b/src/test/ui/compile-fail-migration/safe-extern-statics.stderr new file mode 100644 index 00000000000..657d57967bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/safe-extern-statics.stderr @@ -0,0 +1,43 @@ +error: use of extern static is unsafe and requires unsafe function or block (error E0133) + --> $DIR/safe-extern-statics.rs:23:13 + | +LL | let a = A; //~ ERROR use of extern static is unsafe + | ^ + | + = note: #[deny(safe_extern_statics)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36247 + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error: use of extern static is unsafe and requires unsafe function or block (error E0133) + --> $DIR/safe-extern-statics.rs:25:14 + | +LL | let ra = &A; //~ ERROR use of extern static is unsafe + | ^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36247 + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error: use of extern static is unsafe and requires unsafe function or block (error E0133) + --> $DIR/safe-extern-statics.rs:27:14 + | +LL | let xa = XA; //~ ERROR use of extern static is unsafe + | ^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36247 + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error: use of extern static is unsafe and requires unsafe function or block (error E0133) + --> $DIR/safe-extern-statics.rs:29:15 + | +LL | let xra = &XA; //~ ERROR use of extern static is unsafe + | ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36247 + = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/self-infer.rs b/src/test/ui/compile-fail-migration/self-infer.rs new file mode 100644 index 00000000000..fd011318a48 --- /dev/null +++ b/src/test/ui/compile-fail-migration/self-infer.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S; + +impl S { + fn f(self: _) {} //~ERROR the type placeholder `_` is not allowed within types on item sig + fn g(self: &_) {} //~ERROR the type placeholder `_` is not allowed within types on item sig +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/self-infer.stderr b/src/test/ui/compile-fail-migration/self-infer.stderr new file mode 100644 index 00000000000..642e0de5290 --- /dev/null +++ b/src/test/ui/compile-fail-migration/self-infer.stderr @@ -0,0 +1,15 @@ +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/self-infer.rs:14:16 + | +LL | fn f(self: _) {} //~ERROR the type placeholder `_` is not allowed within types on item sig + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/self-infer.rs:15:17 + | +LL | fn g(self: &_) {} //~ERROR the type placeholder `_` is not allowed within types on item sig + | ^ not allowed in type signatures + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0121`. diff --git a/src/test/ui/compile-fail-migration/self-vs-path-ambiguity.rs b/src/test/ui/compile-fail-migration/self-vs-path-ambiguity.rs new file mode 100644 index 00000000000..b2dba3bd61b --- /dev/null +++ b/src/test/ui/compile-fail-migration/self-vs-path-ambiguity.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that `self::foo` is parsed as a general pattern and not a self argument. + +struct S; + +impl S { + fn f(self::S: S) {} + fn g(&self::S: &S) {} + fn h(&mut self::S: &mut S) {} + fn i(&'a self::S: &S) {} //~ ERROR unexpected lifetime `'a` in pattern +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/self-vs-path-ambiguity.stderr b/src/test/ui/compile-fail-migration/self-vs-path-ambiguity.stderr new file mode 100644 index 00000000000..76517433170 --- /dev/null +++ b/src/test/ui/compile-fail-migration/self-vs-path-ambiguity.stderr @@ -0,0 +1,8 @@ +error: unexpected lifetime `'a` in pattern + --> $DIR/self-vs-path-ambiguity.rs:19:11 + | +LL | fn i(&'a self::S: &S) {} //~ ERROR unexpected lifetime `'a` in pattern + | ^^ unexpected lifetime + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/self_type_keyword-2.rs b/src/test/ui/compile-fail-migration/self_type_keyword-2.rs new file mode 100644 index 00000000000..8331ae0b307 --- /dev/null +++ b/src/test/ui/compile-fail-migration/self_type_keyword-2.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use self::Self as Foo; //~ ERROR unresolved import `self::Self` + +pub fn main() { + let Self = 5; + //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope + + match 15 { + Self => (), + //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope + Foo { x: Self } => (), + //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope + } +} diff --git a/src/test/ui/compile-fail-migration/self_type_keyword-2.stderr b/src/test/ui/compile-fail-migration/self_type_keyword-2.stderr new file mode 100644 index 00000000000..972e5bdddc6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/self_type_keyword-2.stderr @@ -0,0 +1,28 @@ +error[E0432]: unresolved import `self::Self` + --> $DIR/self_type_keyword-2.rs:11:5 + | +LL | use self::Self as Foo; //~ ERROR unresolved import `self::Self` + | ^^^^^^^^^^^^^^^^^ no `Self` in the root + +error[E0531]: cannot find unit struct/variant or constant `Self` in this scope + --> $DIR/self_type_keyword-2.rs:14:9 + | +LL | let Self = 5; + | ^^^^ not found in this scope + +error[E0531]: cannot find unit struct/variant or constant `Self` in this scope + --> $DIR/self_type_keyword-2.rs:18:9 + | +LL | Self => (), + | ^^^^ not found in this scope + +error[E0531]: cannot find unit struct/variant or constant `Self` in this scope + --> $DIR/self_type_keyword-2.rs:20:18 + | +LL | Foo { x: Self } => (), + | ^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors occurred: E0432, E0531. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/self_type_keyword.rs b/src/test/ui/compile-fail-migration/self_type_keyword.rs new file mode 100644 index 00000000000..20d2e2ca9cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/self_type_keyword.rs @@ -0,0 +1,51 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z continue-parse-after-error + +mod foo { + struct Self; + //~^ ERROR expected identifier, found keyword `Self` +} + +struct Bar<'Self>; +//~^ ERROR lifetimes cannot use keyword names + +struct Foo; + +pub fn main() { + match 15 { + ref Self => (), + //~^ ERROR expected identifier, found keyword `Self` + mut Self => (), + //~^ ERROR expected identifier, found keyword `Self` + ref mut Self => (), + //~^ ERROR expected identifier, found keyword `Self` + Self!() => (), + //~^ ERROR cannot find macro `Self!` in this scope + Foo { Self } => (), + //~^ ERROR expected identifier, found keyword `Self` + } +} + +mod m1 { + extern crate core as Self; + //~^ ERROR expected identifier, found keyword `Self` +} + +mod m2 { + use std::option::Option as Self; + //~^ ERROR expected identifier, found keyword `Self` +} + +mod m3 { + trait Self {} + //~^ ERROR expected identifier, found keyword `Self` +} diff --git a/src/test/ui/compile-fail-migration/self_type_keyword.stderr b/src/test/ui/compile-fail-migration/self_type_keyword.stderr new file mode 100644 index 00000000000..4a7b9a6ce2c --- /dev/null +++ b/src/test/ui/compile-fail-migration/self_type_keyword.stderr @@ -0,0 +1,62 @@ +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:14:10 + | +LL | struct Self; + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:25:13 + | +LL | ref Self => (), + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:27:13 + | +LL | mut Self => (), + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:29:17 + | +LL | ref mut Self => (), + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:33:15 + | +LL | Foo { Self } => (), + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:39:26 + | +LL | extern crate core as Self; + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:44:32 + | +LL | use std::option::Option as Self; + | ^^^^ expected identifier, found keyword + +error: expected identifier, found keyword `Self` + --> $DIR/self_type_keyword.rs:49:11 + | +LL | trait Self {} + | ^^^^ expected identifier, found keyword + +error: lifetimes cannot use keyword names + --> $DIR/self_type_keyword.rs:18:12 + | +LL | struct Bar<'Self>; + | ^^^^^ + +error: cannot find macro `Self!` in this scope + --> $DIR/self_type_keyword.rs:31:9 + | +LL | Self!() => (), + | ^^^^ + +error: aborting due to 10 previous errors + diff --git a/src/test/ui/compile-fail-migration/seq-args.rs b/src/test/ui/compile-fail-migration/seq-args.rs new file mode 100644 index 00000000000..44b049d6561 --- /dev/null +++ b/src/test/ui/compile-fail-migration/seq-args.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { +trait seq { } + +impl seq for Vec { //~ ERROR wrong number of type arguments + /* ... */ +} +impl seq for u32 { //~ ERROR wrong number of type arguments + /* Treat the integer as a sequence of bits */ +} + +} diff --git a/src/test/ui/compile-fail-migration/seq-args.stderr b/src/test/ui/compile-fail-migration/seq-args.stderr new file mode 100644 index 00000000000..dc9d0a7fc0b --- /dev/null +++ b/src/test/ui/compile-fail-migration/seq-args.stderr @@ -0,0 +1,15 @@ +error[E0244]: wrong number of type arguments: expected 0, found 1 + --> $DIR/seq-args.rs:14:9 + | +LL | impl seq for Vec { //~ ERROR wrong number of type arguments + | ^^^^^^ expected no type arguments + +error[E0244]: wrong number of type arguments: expected 0, found 1 + --> $DIR/seq-args.rs:17:6 + | +LL | impl seq for u32 { //~ ERROR wrong number of type arguments + | ^^^^^^^^^ expected no type arguments + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0244`. diff --git a/src/test/ui/compile-fail-migration/shadowed-trait-methods.rs b/src/test/ui/compile-fail-migration/shadowed-trait-methods.rs new file mode 100644 index 00000000000..3146017a0b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/shadowed-trait-methods.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that methods from shadowed traits cannot be used + +mod foo { + pub trait T { fn f(&self) {} } + impl T for () {} +} + +mod bar { pub use foo::T; } + +fn main() { + pub use bar::*; + struct T; + ().f() //~ ERROR no method +} diff --git a/src/test/ui/compile-fail-migration/shadowed-trait-methods.stderr b/src/test/ui/compile-fail-migration/shadowed-trait-methods.stderr new file mode 100644 index 00000000000..910f125a148 --- /dev/null +++ b/src/test/ui/compile-fail-migration/shadowed-trait-methods.stderr @@ -0,0 +1,15 @@ +error[E0599]: no method named `f` found for type `()` in the current scope + --> $DIR/shadowed-trait-methods.rs:23:8 + | +LL | ().f() //~ ERROR no method + | ^ + | + = 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 foo::T; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/shadowed-use-visibility.rs b/src/test/ui/compile-fail-migration/shadowed-use-visibility.rs new file mode 100644 index 00000000000..e7e57a73de0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/shadowed-use-visibility.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub fn f() {} + + use foo as bar; + pub use self::f as bar; +} + +mod bar { + use foo::bar::f as g; //~ ERROR module `bar` is private + + use foo as f; + pub use foo::*; +} + +use bar::f::f; //~ ERROR module `f` is private +fn main() {} diff --git a/src/test/ui/compile-fail-migration/shadowed-use-visibility.stderr b/src/test/ui/compile-fail-migration/shadowed-use-visibility.stderr new file mode 100644 index 00000000000..5764ed76ef4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/shadowed-use-visibility.stderr @@ -0,0 +1,15 @@ +error[E0603]: module `bar` is private + --> $DIR/shadowed-use-visibility.rs:19:9 + | +LL | use foo::bar::f as g; //~ ERROR module `bar` is private + | ^^^^^^^^^^^^^^^^ + +error[E0603]: module `f` is private + --> $DIR/shadowed-use-visibility.rs:25:5 + | +LL | use bar::f::f; //~ ERROR module `f` is private + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.rs b/src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.rs new file mode 100644 index 00000000000..e847d332416 --- /dev/null +++ b/src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for issue #14581. + +fn f((a, a): (isize, isize)) {} //~ ERROR identifier `a` is bound more than once + +fn main() { + let (a, a) = (1, 1); //~ ERROR identifier `a` is bound more than once +} diff --git a/src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.stderr b/src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.stderr new file mode 100644 index 00000000000..46722891476 --- /dev/null +++ b/src/test/ui/compile-fail-migration/shadowing-in-the-same-pattern.stderr @@ -0,0 +1,15 @@ +error[E0416]: identifier `a` is bound more than once in the same pattern + --> $DIR/shadowing-in-the-same-pattern.rs:13:10 + | +LL | fn f((a, a): (isize, isize)) {} //~ ERROR identifier `a` is bound more than once + | ^ used in a pattern more than once + +error[E0416]: identifier `a` is bound more than once in the same pattern + --> $DIR/shadowing-in-the-same-pattern.rs:16:13 + | +LL | let (a, a) = (1, 1); //~ ERROR identifier `a` is bound more than once + | ^ used in a pattern more than once + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0416`. diff --git a/src/test/ui/compile-fail-migration/shift-various-bad-types.rs b/src/test/ui/compile-fail-migration/shift-various-bad-types.rs new file mode 100644 index 00000000000..2d06161111e --- /dev/null +++ b/src/test/ui/compile-fail-migration/shift-various-bad-types.rs @@ -0,0 +1,41 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can do shifts by any integral type. + +struct Panolpy { + char: char, + str: &'static str, +} + +fn foo(p: &Panolpy) { + 22 >> p.char; + //~^ ERROR E0277 + + 22 >> p.str; + //~^ ERROR E0277 + + 22 >> p; + //~^ ERROR E0277 + + let x; + 22 >> x; // ambiguity error winds up being suppressed + + 22 >> 1; + // Integer literal types are OK + + // Type of the result follows the LHS, not the RHS: + let _: i32 = 22_i64 >> 1_i32; + //~^ ERROR mismatched types + //~| expected i32, found i64 +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/shift-various-bad-types.stderr b/src/test/ui/compile-fail-migration/shift-various-bad-types.stderr new file mode 100644 index 00000000000..7798b619cd9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/shift-various-bad-types.stderr @@ -0,0 +1,34 @@ +error[E0277]: no implementation for `{integer} >> char` + --> $DIR/shift-various-bad-types.rs:19:8 + | +LL | 22 >> p.char; + | ^^ no implementation for `{integer} >> char` + | + = help: the trait `std::ops::Shr` is not implemented for `{integer}` + +error[E0277]: no implementation for `{integer} >> &str` + --> $DIR/shift-various-bad-types.rs:22:8 + | +LL | 22 >> p.str; + | ^^ no implementation for `{integer} >> &str` + | + = help: the trait `std::ops::Shr<&str>` is not implemented for `{integer}` + +error[E0277]: no implementation for `{integer} >> &Panolpy` + --> $DIR/shift-various-bad-types.rs:25:8 + | +LL | 22 >> p; + | ^^ no implementation for `{integer} >> &Panolpy` + | + = help: the trait `std::ops::Shr<&Panolpy>` is not implemented for `{integer}` + +error[E0308]: mismatched types + --> $DIR/shift-various-bad-types.rs:35:18 + | +LL | let _: i32 = 22_i64 >> 1_i32; + | ^^^^^^^^^^^^^^^ expected i32, found i64 + +error: aborting due to 4 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.rs b/src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.rs new file mode 100644 index 00000000000..8c9a24f4e72 --- /dev/null +++ b/src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// should-fail-irrefutable_let_patterns +fn main() { + if let _ = 5 {} + //~^ ERROR irrefutable if-let pattern [E0162] +} diff --git a/src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.stderr b/src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.stderr new file mode 100644 index 00000000000..d8570ad4e83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/should-fail-no_gate_irrefutable_if_let_pattern.stderr @@ -0,0 +1,9 @@ +error[E0162]: irrefutable if-let pattern + --> $DIR/should-fail-no_gate_irrefutable_if_let_pattern.rs:13:12 + | +LL | if let _ = 5 {} + | ^ irrefutable pattern + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0162`. diff --git a/src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.rs b/src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.rs new file mode 100644 index 00000000000..6f95f10c0d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(irrefutable_let_patterns)] + +// should-fail-irrefutable_let_patterns_with_gate +fn main() { + if let _ = 5 {} + //~^ ERROR irrefutable if-let pattern [irrefutable_let_patterns] +} diff --git a/src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.stderr b/src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.stderr new file mode 100644 index 00000000000..9dc0d1968e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/should-fail-with_gate_irrefutable_pattern_deny.stderr @@ -0,0 +1,10 @@ +error: irrefutable if-let pattern + --> $DIR/should-fail-with_gate_irrefutable_pattern_deny.rs:15:5 + | +LL | if let _ = 5 {} + | ^^^^^^^^^^^^^^^ + | + = note: #[deny(irrefutable_let_patterns)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.rs new file mode 100644 index 00000000000..ef1f4d6f230 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.rs @@ -0,0 +1,68 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); +#[repr(simd)] +struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16); + +#[repr(simd)] +struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, + i8, i8, i8, i8, i8, i8, i8, i8); +#[repr(simd)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +struct f32x4(f32, f32, f32, f32); +#[repr(simd)] +struct i64x2(i64, i64); + +// correct signatures work well +mod right { + use {i16x8, u16x8}; + extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; + fn x86_mm_adds_epu16(x: u16x8, y: u16x8) -> u16x8; + } +} +// but incorrect ones don't. + +mod signedness { + use {i16x8, u16x8}; + // signedness matters + extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: u16x8, y: u16x8) -> u16x8; + //~^ ERROR intrinsic argument 1 has wrong type + //~^^ ERROR intrinsic argument 2 has wrong type + //~^^^ ERROR intrinsic return value has wrong type + fn x86_mm_adds_epu16(x: i16x8, y: i16x8) -> i16x8; + //~^ ERROR intrinsic argument 1 has wrong type + //~^^ ERROR intrinsic argument 2 has wrong type + //~^^^ ERROR intrinsic return value has wrong type + } +} +// as do lengths +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + //~^ ERROR intrinsic argument 1 has wrong type + //~^^ ERROR intrinsic argument 2 has wrong type + //~^^^ ERROR intrinsic return value has wrong type +} +// and so does int vs. float: +extern "platform-intrinsic" { + fn x86_mm_max_ps(x: i32x4, y: i32x4) -> i32x4; + //~^ ERROR intrinsic argument 1 has wrong type + //~^^ ERROR intrinsic argument 2 has wrong type + //~^^^ ERROR intrinsic return value has wrong type +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.stderr new file mode 100644 index 00000000000..4a8fd2d1bef --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-declaration-type.stderr @@ -0,0 +1,75 @@ +error[E0442]: intrinsic argument 1 has wrong type: found `u16`, expected `i16` + --> $DIR/simd-intrinsic-declaration-type.rs:42:9 + | +LL | fn x86_mm_adds_epi16(x: u16x8, y: u16x8) -> u16x8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 2 has wrong type: found `u16`, expected `i16` + --> $DIR/simd-intrinsic-declaration-type.rs:42:9 + | +LL | fn x86_mm_adds_epi16(x: u16x8, y: u16x8) -> u16x8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic return value has wrong type: found `u16`, expected `i16` + --> $DIR/simd-intrinsic-declaration-type.rs:42:9 + | +LL | fn x86_mm_adds_epi16(x: u16x8, y: u16x8) -> u16x8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 1 has wrong type: found `i16`, expected `u16` + --> $DIR/simd-intrinsic-declaration-type.rs:46:9 + | +LL | fn x86_mm_adds_epu16(x: i16x8, y: i16x8) -> i16x8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 2 has wrong type: found `i16`, expected `u16` + --> $DIR/simd-intrinsic-declaration-type.rs:46:9 + | +LL | fn x86_mm_adds_epu16(x: i16x8, y: i16x8) -> i16x8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic return value has wrong type: found `i16`, expected `u16` + --> $DIR/simd-intrinsic-declaration-type.rs:46:9 + | +LL | fn x86_mm_adds_epu16(x: i16x8, y: i16x8) -> i16x8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 1 has wrong type: found vector with length 16, expected length 8 + --> $DIR/simd-intrinsic-declaration-type.rs:54:5 + | +LL | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 2 has wrong type: found vector with length 4, expected length 8 + --> $DIR/simd-intrinsic-declaration-type.rs:54:5 + | +LL | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic return value has wrong type: found vector with length 2, expected length 8 + --> $DIR/simd-intrinsic-declaration-type.rs:54:5 + | +LL | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 1 has wrong type: found `i32`, expected `f32` + --> $DIR/simd-intrinsic-declaration-type.rs:61:5 + | +LL | fn x86_mm_max_ps(x: i32x4, y: i32x4) -> i32x4; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 2 has wrong type: found `i32`, expected `f32` + --> $DIR/simd-intrinsic-declaration-type.rs:61:5 + | +LL | fn x86_mm_max_ps(x: i32x4, y: i32x4) -> i32x4; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic return value has wrong type: found `i32`, expected `f32` + --> $DIR/simd-intrinsic-declaration-type.rs:61:5 + | +LL | fn x86_mm_max_ps(x: i32x4, y: i32x4) -> i32x4; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0442`. diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.rs new file mode 100644 index 00000000000..ee08ca05e80 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.rs @@ -0,0 +1,103 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct i32x4(pub i32, pub i32, pub i32, pub i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x4(pub u32, pub u32, pub u32, pub u32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +extern "platform-intrinsic" { + fn simd_add(x: T, y: T) -> T; + fn simd_sub(x: T, y: T) -> T; + fn simd_mul(x: T, y: T) -> T; + fn simd_div(x: T, y: T) -> T; + fn simd_rem(x: T, y: T) -> T; + fn simd_shl(x: T, y: T) -> T; + fn simd_shr(x: T, y: T) -> T; + fn simd_and(x: T, y: T) -> T; + fn simd_or(x: T, y: T) -> T; + fn simd_xor(x: T, y: T) -> T; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + let y = u32x4(0, 0, 0, 0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + unsafe { + simd_add(x, x); + simd_add(y, y); + simd_add(z, z); + simd_sub(x, x); + simd_sub(y, y); + simd_sub(z, z); + simd_mul(x, x); + simd_mul(y, y); + simd_mul(z, z); + simd_div(x, x); + simd_div(y, y); + simd_div(z, z); + simd_rem(x, x); + simd_rem(y, y); + simd_rem(z, z); + + simd_shl(x, x); + simd_shl(y, y); + simd_shr(x, x); + simd_shr(y, y); + simd_and(x, x); + simd_and(y, y); + simd_or(x, x); + simd_or(y, y); + simd_xor(x, x); + simd_xor(y, y); + + + simd_add(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_sub(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_mul(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_div(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shl(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shr(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_and(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_or(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_xor(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + + simd_shl(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_shr(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_and(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_or(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_xor(z, z); +//~^ ERROR unsupported operation on `f32x4` with element `f32` + } +} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.stderr new file mode 100644 index 00000000000..f81fa75c56b --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-arithmetic.stderr @@ -0,0 +1,87 @@ +error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:72:9 + | +LL | simd_add(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:74:9 + | +LL | simd_sub(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:76:9 + | +LL | simd_mul(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:78:9 + | +LL | simd_div(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:80:9 + | +LL | simd_shl(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:82:9 + | +LL | simd_shr(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:84:9 + | +LL | simd_and(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:86:9 + | +LL | simd_or(0, 0); + | ^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:88:9 + | +LL | simd_xor(0, 0); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:92:9 + | +LL | simd_shl(z, z); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:94:9 + | +LL | simd_shr(z, z); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:96:9 + | +LL | simd_and(z, z); + | ^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:98:9 + | +LL | simd_or(z, z); + | ^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/simd-intrinsic-generic-arithmetic.rs:100:9 + | +LL | simd_xor(z, z); + | ^^^^^^^^^^^^^^ + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.rs new file mode 100644 index 00000000000..4999b790b13 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.rs @@ -0,0 +1,51 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x8(i32, i32, i32, i32, + i32, i32, i32, i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x4(f32, f32, f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x8(f32, f32, f32, f32, + f32, f32, f32, f32); + + +extern "platform-intrinsic" { + fn simd_cast(x: T) -> U; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + + unsafe { + simd_cast::(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_cast::(0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_cast::(x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_cast::<_, i32x8>(x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 + } +} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.stderr new file mode 100644 index 00000000000..6ad5ac7dbfd --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-cast.stderr @@ -0,0 +1,27 @@ +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-cast.rs:42:9 + | +LL | simd_cast::(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-cast.rs:44:9 + | +LL | simd_cast::(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-cast.rs:46:9 + | +LL | simd_cast::(x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 + --> $DIR/simd-intrinsic-generic-cast.rs:48:9 + | +LL | simd_cast::<_, i32x8>(x); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.rs new file mode 100644 index 00000000000..617b03a8711 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.rs @@ -0,0 +1,75 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i16x8(i16, i16, i16, i16, + i16, i16, i16, i16); + +extern "platform-intrinsic" { + fn simd_eq(x: T, y: T) -> U; + fn simd_ne(x: T, y: T) -> U; + fn simd_lt(x: T, y: T) -> U; + fn simd_le(x: T, y: T) -> U; + fn simd_gt(x: T, y: T) -> U; + fn simd_ge(x: T, y: T) -> U; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + + unsafe { + simd_eq::(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_ne::(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_lt::(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_le::(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_gt::(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_ge::(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + simd_eq::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_ne::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_lt::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_le::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_gt::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + simd_ge::<_, i32>(x, x); + //~^ ERROR expected SIMD return type, found non-SIMD `i32` + + simd_eq::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_ne::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_lt::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_le::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_gt::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + simd_ge::<_, i16x8>(x, x); +//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + } +} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.stderr new file mode 100644 index 00000000000..06eb94a4f97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-comparison.stderr @@ -0,0 +1,111 @@ +error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:36:9 + | +LL | simd_eq::(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:38:9 + | +LL | simd_ne::(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:40:9 + | +LL | simd_lt::(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:42:9 + | +LL | simd_le::(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:44:9 + | +LL | simd_gt::(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:46:9 + | +LL | simd_ge::(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:49:9 + | +LL | simd_eq::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:51:9 + | +LL | simd_ne::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:53:9 + | +LL | simd_lt::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:55:9 + | +LL | simd_le::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:57:9 + | +LL | simd_gt::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD return type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-comparison.rs:59:9 + | +LL | simd_ge::<_, i32>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/simd-intrinsic-generic-comparison.rs:62:9 + | +LL | simd_eq::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/simd-intrinsic-generic-comparison.rs:64:9 + | +LL | simd_ne::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/simd-intrinsic-generic-comparison.rs:66:9 + | +LL | simd_lt::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/simd-intrinsic-generic-comparison.rs:68:9 + | +LL | simd_le::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/simd-intrinsic-generic-comparison.rs:70:9 + | +LL | simd_gt::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + --> $DIR/simd-intrinsic-generic-comparison.rs:72:9 + | +LL | simd_ge::<_, i16x8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 18 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.rs new file mode 100644 index 00000000000..78f7d42e25a --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.rs @@ -0,0 +1,97 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics, rustc_attrs)] + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x2(i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x3(i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct i32x8(i32, i32, i32, i32, + i32, i32, i32, i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x2(f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x3(f32, f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x4(f32, f32, f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] +struct f32x8(f32, f32, f32, f32, + f32, f32, f32, f32); + +extern "platform-intrinsic" { + fn simd_insert(x: T, idx: u32, y: E) -> T; + fn simd_extract(x: T, idx: u32) -> E; + + fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle3(x: T, y: T, idx: [u32; 3]) -> U; + fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; + fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; +} + +fn main() { + let x = i32x4(0, 0, 0, 0); + + unsafe { + simd_insert(0, 0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_insert(x, 0, 1.0); + //~^ ERROR expected inserted type `i32` (element of input `i32x4`), found `f64` + simd_extract::<_, f32>(x, 0); + //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32` + + simd_shuffle2::(0, 0, [0; 2]); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shuffle3::(0, 0, [0; 3]); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shuffle4::(0, 0, [0; 4]); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shuffle8::(0, 0, [0; 8]); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + simd_shuffle2::<_, f32x2>(x, x, [0; 2]); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + simd_shuffle3::<_, f32x3>(x, x, [0; 3]); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32` + simd_shuffle4::<_, f32x4>(x, x, [0; 4]); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` + simd_shuffle8::<_, f32x8>(x, x, [0; 8]); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` + + simd_shuffle2::<_, i32x8>(x, x, [0; 2]); + //~^ ERROR expected return type of length 2, found `i32x8` with length 8 + simd_shuffle3::<_, i32x4>(x, x, [0; 3]); + //~^ ERROR expected return type of length 3, found `i32x4` with length 4 + simd_shuffle4::<_, i32x3>(x, x, [0; 4]); + //~^ ERROR expected return type of length 4, found `i32x3` with length 3 + simd_shuffle8::<_, i32x2>(x, x, [0; 8]); + //~^ ERROR expected return type of length 8, found `i32x2` with length 2 + } +} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.stderr new file mode 100644 index 00000000000..5a2def2c8c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-elements.stderr @@ -0,0 +1,93 @@ +error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-elements.rs:63:9 + | +LL | simd_insert(0, 0, 0); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` + --> $DIR/simd-intrinsic-generic-elements.rs:65:9 + | +LL | simd_insert(x, 0, 1.0); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` + --> $DIR/simd-intrinsic-generic-elements.rs:67:9 + | +LL | simd_extract::<_, f32>(x, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-elements.rs:70:9 + | +LL | simd_shuffle2::(0, 0, [0; 2]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-elements.rs:72:9 + | +LL | simd_shuffle3::(0, 0, [0; 3]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-elements.rs:74:9 + | +LL | simd_shuffle4::(0, 0, [0; 4]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-elements.rs:76:9 + | +LL | simd_shuffle8::(0, 0, [0; 8]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + --> $DIR/simd-intrinsic-generic-elements.rs:79:9 + | +LL | simd_shuffle2::<_, f32x2>(x, x, [0; 2]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32` + --> $DIR/simd-intrinsic-generic-elements.rs:81:9 + | +LL | simd_shuffle3::<_, f32x3>(x, x, [0; 3]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` + --> $DIR/simd-intrinsic-generic-elements.rs:83:9 + | +LL | simd_shuffle4::<_, f32x4>(x, x, [0; 4]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` + --> $DIR/simd-intrinsic-generic-elements.rs:85:9 + | +LL | simd_shuffle8::<_, f32x8>(x, x, [0; 8]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return type of length 2, found `i32x8` with length 8 + --> $DIR/simd-intrinsic-generic-elements.rs:88:9 + | +LL | simd_shuffle2::<_, i32x8>(x, x, [0; 2]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected return type of length 3, found `i32x4` with length 4 + --> $DIR/simd-intrinsic-generic-elements.rs:90:9 + | +LL | simd_shuffle3::<_, i32x4>(x, x, [0; 3]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return type of length 4, found `i32x3` with length 3 + --> $DIR/simd-intrinsic-generic-elements.rs:92:9 + | +LL | simd_shuffle4::<_, i32x3>(x, x, [0; 4]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return type of length 8, found `i32x2` with length 2 + --> $DIR/simd-intrinsic-generic-elements.rs:94:9 + | +LL | simd_shuffle8::<_, i32x2>(x, x, [0; 8]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 15 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.rs new file mode 100644 index 00000000000..725960a866b --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.rs @@ -0,0 +1,81 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-emscripten + +// Test that the simd_reduce_{op} intrinsics produce ok-ish error +// messages when misused. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x4(pub u32, pub u32, pub u32, pub u32); + + +extern "platform-intrinsic" { + fn simd_reduce_add_ordered(x: T, y: U) -> U; + fn simd_reduce_mul_ordered(x: T, y: U) -> U; + fn simd_reduce_and(x: T) -> U; + fn simd_reduce_or(x: T) -> U; + fn simd_reduce_xor(x: T) -> U; + fn simd_reduce_all(x: T) -> bool; + fn simd_reduce_any(x: T) -> bool; +} + +fn main() { + let x = u32x4(0, 0, 0, 0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + unsafe { + simd_reduce_add_ordered(z, 0_f32); + simd_reduce_mul_ordered(z, 1_f32); + + simd_reduce_add_ordered(z, 2_f32); + //~^ ERROR accumulator of simd_reduce_add_ordered is not 0.0 + simd_reduce_mul_ordered(z, 3_f32); + //~^ ERROR accumulator of simd_reduce_mul_ordered is not 1.0 + + let _: f32 = simd_reduce_and(x); + //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` + let _: f32 = simd_reduce_or(x); + //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` + let _: f32 = simd_reduce_xor(x); + //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` + + let _: f32 = simd_reduce_and(z); + //~^ ERROR unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` + let _: f32 = simd_reduce_or(z); + //~^ ERROR unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` + let _: f32 = simd_reduce_xor(z); + //~^ ERROR unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` + + let _: bool = simd_reduce_all(z); + //~^ ERROR unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` + let _: bool = simd_reduce_any(z); + //~^ ERROR unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` + + foo(0_f32); + } +} + +#[inline(never)] +unsafe fn foo(x: f32) { + let z = f32x4(0.0, 0.0, 0.0, 0.0); + simd_reduce_add_ordered(z, x); + //~^ ERROR accumulator of simd_reduce_add_ordered is not a constant + simd_reduce_mul_ordered(z, x); + //~^ ERROR accumulator of simd_reduce_mul_ordered is not a constant +} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.stderr new file mode 100644 index 00000000000..47b1e9dac78 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-reduction.stderr @@ -0,0 +1,75 @@ +error[E0511]: invalid monomorphization of `simd_reduce_add_ordered` intrinsic: accumulator of simd_reduce_add_ordered is not 0.0 + --> $DIR/simd-intrinsic-generic-reduction.rs:46:9 + | +LL | simd_reduce_add_ordered(z, 2_f32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_mul_ordered` intrinsic: accumulator of simd_reduce_mul_ordered is not 1.0 + --> $DIR/simd-intrinsic-generic-reduction.rs:48:9 + | +LL | simd_reduce_mul_ordered(z, 3_f32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` + --> $DIR/simd-intrinsic-generic-reduction.rs:51:22 + | +LL | let _: f32 = simd_reduce_and(x); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` + --> $DIR/simd-intrinsic-generic-reduction.rs:53:22 + | +LL | let _: f32 = simd_reduce_or(x); + | ^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` + --> $DIR/simd-intrinsic-generic-reduction.rs:55:22 + | +LL | let _: f32 = simd_reduce_xor(x); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` + --> $DIR/simd-intrinsic-generic-reduction.rs:58:22 + | +LL | let _: f32 = simd_reduce_and(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` + --> $DIR/simd-intrinsic-generic-reduction.rs:60:22 + | +LL | let _: f32 = simd_reduce_or(z); + | ^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` + --> $DIR/simd-intrinsic-generic-reduction.rs:62:22 + | +LL | let _: f32 = simd_reduce_xor(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_all` intrinsic: unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` + --> $DIR/simd-intrinsic-generic-reduction.rs:65:23 + | +LL | let _: bool = simd_reduce_all(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_any` intrinsic: unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` + --> $DIR/simd-intrinsic-generic-reduction.rs:67:23 + | +LL | let _: bool = simd_reduce_any(z); + | ^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_add_ordered` intrinsic: accumulator of simd_reduce_add_ordered is not a constant + --> $DIR/simd-intrinsic-generic-reduction.rs:77:5 + | +LL | simd_reduce_add_ordered(z, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_reduce_mul_ordered` intrinsic: accumulator of simd_reduce_mul_ordered is not a constant + --> $DIR/simd-intrinsic-generic-reduction.rs:79:5 + | +LL | simd_reduce_mul_ordered(z, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.rs new file mode 100644 index 00000000000..d74d6815d5f --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.rs @@ -0,0 +1,56 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the simd_select intrinsic produces ok-ish error +// messages when misused. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +#[repr(simd)] +#[derive(Copy, Clone)] +pub struct u32x4(pub u32, pub u32, pub u32, pub u32); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq)] +struct b8x4(pub i8, pub i8, pub i8, pub i8); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq)] +struct b8x8(pub i8, pub i8, pub i8, pub i8, + pub i8, pub i8, pub i8, pub i8); + +extern "platform-intrinsic" { + fn simd_select(x: T, a: U, b: U) -> U; +} + +fn main() { + let m4 = b8x4(0, 0, 0, 0); + let m8 = b8x8(0, 0, 0, 0, 0, 0, 0, 0); + let x = u32x4(0, 0, 0, 0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + unsafe { + simd_select(m4, x, x); + + simd_select(m8, x, x); + //~^ ERROR mismatched lengths: mask length `8` != other vector length `4` + + simd_select(x, x, x); + //~^ ERROR mask element type is `u32`, expected `i_` + + simd_select(z, z, z); + //~^ ERROR mask element type is `f32`, expected `i_` + } +} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.stderr new file mode 100644 index 00000000000..61e42027039 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-generic-select.stderr @@ -0,0 +1,21 @@ +error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched lengths: mask length `8` != other vector length `4` + --> $DIR/simd-intrinsic-generic-select.rs:47:9 + | +LL | simd_select(m8, x, x); + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `u32`, expected `i_` + --> $DIR/simd-intrinsic-generic-select.rs:50:9 + | +LL | simd_select(x, x, x); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `f32`, expected `i_` + --> $DIR/simd-intrinsic-generic-select.rs:53:9 + | +LL | simd_select(z, z, z); + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.rs b/src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.rs new file mode 100644 index 00000000000..0d0bf240f72 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +struct A(i16, i16, i16, i16, i16, i16, i16, i16); +#[repr(simd)] +struct B(i16, i16, i16, i16, i16, i16, i16, i16); + +// each intrinsic definition has to use the same nominal type for any +// vector structure throughout that declaration (i.e. every instance +// of i16x8 in each `fn ...;` needs to be either A or B) + +extern "platform-intrinsic" { + fn x86_mm_adds_epi16(x: A, y: A) -> B; + //~^ ERROR intrinsic return value has wrong type: found `B`, expected `A` + fn x86_mm_subs_epi16(x: A, y: B) -> A; + //~^ ERROR intrinsic argument 2 has wrong type: found `B`, expected `A` + + // ok: + fn x86_mm_max_epi16(x: B, y: B) -> B; + fn x86_mm_min_epi16(x: A, y: A) -> A; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.stderr b/src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.stderr new file mode 100644 index 00000000000..0692aa7275b --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-intrinsic-single-nominal-type.stderr @@ -0,0 +1,15 @@ +error[E0443]: intrinsic return value has wrong type: found `B`, expected `A` which was used for this vector type previously in this signature + --> $DIR/simd-intrinsic-single-nominal-type.rs:23:5 + | +LL | fn x86_mm_adds_epi16(x: A, y: A) -> B; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0443]: intrinsic argument 2 has wrong type: found `B`, expected `A` which was used for this vector type previously in this signature + --> $DIR/simd-intrinsic-single-nominal-type.rs:25:5 + | +LL | fn x86_mm_subs_epi16(x: A, y: B) -> A; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0443`. diff --git a/src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.rs b/src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.rs new file mode 100644 index 00000000000..336855eb5e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics)] + +// error-pattern:monomorphising SIMD type `Simd2` with a non-machine element type `X` + +struct X(Vec); +#[repr(simd)] +struct Simd2(T, T); + +fn main() { + let _ = Simd2(X(vec![]), X(vec![])); +} diff --git a/src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.stderr b/src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.stderr new file mode 100644 index 00000000000..2a74506e80e --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-type-generic-monomorphisation.stderr @@ -0,0 +1,4 @@ +error: monomorphising SIMD type `Simd2` with a non-machine element type `X` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/simd-type.rs b/src/test/ui/compile-fail-migration/simd-type.rs new file mode 100644 index 00000000000..cde63aa0cd1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-type.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd)] + +#[repr(simd)] +struct empty; //~ ERROR SIMD vector cannot be empty + +#[repr(simd)] +struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous + +#[repr(simd)] +struct int4(isize, isize, isize, isize); //~ ERROR SIMD vector element type should be machine type + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/simd-type.stderr b/src/test/ui/compile-fail-migration/simd-type.stderr new file mode 100644 index 00000000000..5899f4aacc0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/simd-type.stderr @@ -0,0 +1,22 @@ +error[E0075]: SIMD vector cannot be empty + --> $DIR/simd-type.rs:14:1 + | +LL | struct empty; //~ ERROR SIMD vector cannot be empty + | ^^^^^^^^^^^^^ + +error[E0076]: SIMD vector should be homogeneous + --> $DIR/simd-type.rs:17:1 + | +LL | struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type + +error[E0077]: SIMD vector element type should be machine type + --> $DIR/simd-type.rs:20:1 + | +LL | struct int4(isize, isize, isize, isize); //~ ERROR SIMD vector element type should be machine type + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0075, E0076, E0077. +For more information about an error, try `rustc --explain E0075`. diff --git a/src/test/ui/compile-fail-migration/single-primitive-inherent-impl.rs b/src/test/ui/compile-fail-migration/single-primitive-inherent-impl.rs new file mode 100644 index 00000000000..0a0f9ce4bd1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/single-primitive-inherent-impl.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +#![crate_type = "lib"] +#![feature(lang_items)] +#![no_std] + +// OK +#[lang = "str_alloc"] +impl str {} + +impl str { +//~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive +} diff --git a/src/test/ui/compile-fail-migration/single-primitive-inherent-impl.stderr b/src/test/ui/compile-fail-migration/single-primitive-inherent-impl.stderr new file mode 100644 index 00000000000..b781ee866c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/single-primitive-inherent-impl.stderr @@ -0,0 +1,19 @@ +error[E0390]: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive + --> $DIR/single-primitive-inherent-impl.rs:21:1 + | +LL | / impl str { +LL | | //~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive +LL | | } + | |_^ + | +help: consider using a trait to implement these methods + --> $DIR/single-primitive-inherent-impl.rs:21:1 + | +LL | / impl str { +LL | | //~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0390`. diff --git a/src/test/ui/compile-fail-migration/sized-cycle-note.rs b/src/test/ui/compile-fail-migration/sized-cycle-note.rs new file mode 100644 index 00000000000..712b4ac22f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/sized-cycle-note.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test the error message resulting from a cycle in solving `Foo: +// Sized`. The specifics of the message will of course but the main +// thing we want to preserve is that: +// +// 1. the message should appear attached to one of the structs +// defined in this file; +// 2. it should elaborate the steps that led to the cycle. + +struct Baz { q: Option } +//~^ ERROR recursive type `Baz` has infinite size +struct Foo { q: Option } +//~^ ERROR recursive type `Foo` has infinite size + +impl Foo { fn bar(&self) {} } + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/sized-cycle-note.stderr b/src/test/ui/compile-fail-migration/sized-cycle-note.stderr new file mode 100644 index 00000000000..96657152038 --- /dev/null +++ b/src/test/ui/compile-fail-migration/sized-cycle-note.stderr @@ -0,0 +1,23 @@ +error[E0072]: recursive type `Baz` has infinite size + --> $DIR/sized-cycle-note.rs:19:1 + | +LL | struct Baz { q: Option } + | ^^^^^^^^^^ -------------- recursive without indirection + | | + | recursive type has infinite size + | + = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Baz` representable + +error[E0072]: recursive type `Foo` has infinite size + --> $DIR/sized-cycle-note.rs:21:1 + | +LL | struct Foo { q: Option } + | ^^^^^^^^^^ -------------- recursive without indirection + | | + | recursive type has infinite size + | + = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/compile-fail-migration/slice-2.rs b/src/test/ui/compile-fail-migration/slice-2.rs new file mode 100644 index 00000000000..44b9d94c566 --- /dev/null +++ b/src/test/ui/compile-fail-migration/slice-2.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that slicing syntax gives errors if we have not implemented the trait. + +struct Foo; + +fn main() { + let x = Foo; + &x[..]; //~ ERROR cannot index into a value of type `Foo` + &x[Foo..]; //~ ERROR cannot index into a value of type `Foo` + &x[..Foo]; //~ ERROR cannot index into a value of type `Foo` + &x[Foo..Foo]; //~ ERROR cannot index into a value of type `Foo` +} diff --git a/src/test/ui/compile-fail-migration/slice-2.stderr b/src/test/ui/compile-fail-migration/slice-2.stderr new file mode 100644 index 00000000000..e0f34daf513 --- /dev/null +++ b/src/test/ui/compile-fail-migration/slice-2.stderr @@ -0,0 +1,27 @@ +error[E0608]: cannot index into a value of type `Foo` + --> $DIR/slice-2.rs:17:6 + | +LL | &x[..]; //~ ERROR cannot index into a value of type `Foo` + | ^^^^^ + +error[E0608]: cannot index into a value of type `Foo` + --> $DIR/slice-2.rs:18:6 + | +LL | &x[Foo..]; //~ ERROR cannot index into a value of type `Foo` + | ^^^^^^^^ + +error[E0608]: cannot index into a value of type `Foo` + --> $DIR/slice-2.rs:19:6 + | +LL | &x[..Foo]; //~ ERROR cannot index into a value of type `Foo` + | ^^^^^^^^ + +error[E0608]: cannot index into a value of type `Foo` + --> $DIR/slice-2.rs:20:6 + | +LL | &x[Foo..Foo]; //~ ERROR cannot index into a value of type `Foo` + | ^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0608`. diff --git a/src/test/ui/compile-fail-migration/slice-mut-2.nll.stderr b/src/test/ui/compile-fail-migration/slice-mut-2.nll.stderr new file mode 100644 index 00000000000..98d9297e112 --- /dev/null +++ b/src/test/ui/compile-fail-migration/slice-mut-2.nll.stderr @@ -0,0 +1,12 @@ +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/slice-mut-2.rs:17:18 + | +LL | let x: &[isize] = &[1, 2, 3, 4, 5]; + | ---------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4, 5]` +... +LL | let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/slice-mut-2.rs b/src/test/ui/compile-fail-migration/slice-mut-2.rs new file mode 100644 index 00000000000..e20e968a012 --- /dev/null +++ b/src/test/ui/compile-fail-migration/slice-mut-2.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test mutability and slicing syntax. + +fn main() { + let x: &[isize] = &[1, 2, 3, 4, 5]; + // Can't mutably slice an immutable slice + let slice: &mut [isize] = &mut [0, 1]; + let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable +} diff --git a/src/test/ui/compile-fail-migration/slice-mut-2.stderr b/src/test/ui/compile-fail-migration/slice-mut-2.stderr new file mode 100644 index 00000000000..4483c6f1a8a --- /dev/null +++ b/src/test/ui/compile-fail-migration/slice-mut-2.stderr @@ -0,0 +1,9 @@ +error[E0596]: cannot borrow immutable borrowed content `*x` as mutable + --> $DIR/slice-mut-2.rs:17:18 + | +LL | let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable + | ^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/slice-mut.rs b/src/test/ui/compile-fail-migration/slice-mut.rs new file mode 100644 index 00000000000..bee3704a353 --- /dev/null +++ b/src/test/ui/compile-fail-migration/slice-mut.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test mutability and slicing syntax. + +fn main() { + let x: &[isize] = &[1, 2, 3, 4, 5]; + // Immutable slices are not mutable. + + let y: &mut[_] = &x[2..4]; + //~^ ERROR mismatched types + //~| expected type `&mut [_]` + //~| found type `&[isize]` + //~| types differ in mutability +} diff --git a/src/test/ui/compile-fail-migration/slice-mut.stderr b/src/test/ui/compile-fail-migration/slice-mut.stderr new file mode 100644 index 00000000000..59b70959d86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/slice-mut.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/slice-mut.rs:17:22 + | +LL | let y: &mut[_] = &x[2..4]; + | ^^^^^^^^ types differ in mutability + | + = note: expected type `&mut [_]` + found type `&[isize]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.rs b/src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.rs new file mode 100644 index 00000000000..2eba7c2e534 --- /dev/null +++ b/src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker; + +struct Foo(T, marker::PhantomData); + +fn main() { + match Foo(1.1, marker::PhantomData) { + 1 => {} + //~^ ERROR mismatched types + //~| expected type `Foo<{float}, _>` + //~| found type `{integer}` + //~| expected struct `Foo`, found integral variable + } + +} diff --git a/src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.stderr b/src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.stderr new file mode 100644 index 00000000000..463eb98b4ee --- /dev/null +++ b/src/test/ui/compile-fail-migration/slightly-nice-generic-literal-messages.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/slightly-nice-generic-literal-messages.rs:17:9 + | +LL | 1 => {} + | ^ expected struct `Foo`, found integral variable + | + = note: expected type `Foo<{float}, _>` + found type `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/specialization/README.md b/src/test/ui/compile-fail-migration/specialization/README.md new file mode 100644 index 00000000000..f2b4bf946c5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/README.md @@ -0,0 +1,21 @@ +This directory contains the test for incorrect usage of specialization that +should lead to compile failure. Those tests break down into a few categories: + +- Feature gating + - [On use of the `default` keyword](specialization-feature-gate-default.rs) + - [On overlapping impls](specialization-feature-gate-overlap.rs) + +- Overlap checking with specialization enabled + - [Basic overlap scenarios](specialization-overlap.rs) + - Includes purely structural overlap + - Includes purely trait-based overlap + - Includes mix + - [Overlap with differing polarity](specialization-overlap-negative.rs) + +- [Attempt to specialize without using `default`](specialization-no-default.rs) + +- [Attempt to change impl polarity in a specialization](specialization-polarity.rs) + +- Attempt to rely on projection of a `default` type + - [Rely on it externally in both generic and monomorphic contexts](specialization-default-projection.rs) + - [Rely on it both within an impl and outside it](specialization-default-types.rs) diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.rs b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.rs new file mode 100644 index 00000000000..5bab4c5438e --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that specialization must be ungated to use the `default` keyword + +trait Foo { + fn foo(&self); +} + +default impl Foo for T { //~ ERROR specialization is unstable + fn foo(&self) {} +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.stderr b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.stderr new file mode 100644 index 00000000000..d92466967e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-feature-gate-default.stderr @@ -0,0 +1,13 @@ +error[E0658]: specialization is unstable (see issue #31844) + --> $DIR/specialization-feature-gate-default.rs:17:1 + | +LL | / default impl Foo for T { //~ ERROR specialization is unstable +LL | | fn foo(&self) {} +LL | | } + | |_^ + | + = help: add #![feature(specialization)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.rs b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.rs new file mode 100644 index 00000000000..2874108157d --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.rs @@ -0,0 +1,95 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Check a number of scenarios in which one impl tries to override another, +// without correctly using `default`. + +//////////////////////////////////////////////////////////////////////////////// +// Test 1: one layer of specialization, multiple methods, missing `default` +//////////////////////////////////////////////////////////////////////////////// + +trait Foo { + fn foo(&self); + fn bar(&self); +} + +impl Foo for T { + fn foo(&self) {} + fn bar(&self) {} +} + +impl Foo for u8 {} +impl Foo for u16 { + fn foo(&self) {} //~ ERROR E0520 +} +impl Foo for u32 { + fn bar(&self) {} //~ ERROR E0520 +} + +//////////////////////////////////////////////////////////////////////////////// +// Test 2: one layer of specialization, missing `default` on associated type +//////////////////////////////////////////////////////////////////////////////// + +trait Bar { + type T; +} + +impl Bar for T { + type T = u8; +} + +impl Bar for u8 { + type T = (); //~ ERROR E0520 +} + +//////////////////////////////////////////////////////////////////////////////// +// Test 3a: multiple layers of specialization, missing interior `default` +//////////////////////////////////////////////////////////////////////////////// + +trait Baz { + fn baz(&self); +} + +default impl Baz for T { + fn baz(&self) {} +} + +impl Baz for T { + fn baz(&self) {} +} + +impl Baz for i32 { + fn baz(&self) {} //~ ERROR E0520 +} + +//////////////////////////////////////////////////////////////////////////////// +// Test 3b: multiple layers of specialization, missing interior `default`, +// redundant `default` in bottom layer. +//////////////////////////////////////////////////////////////////////////////// + +trait Redundant { + fn redundant(&self); +} + +default impl Redundant for T { + fn redundant(&self) {} +} + +impl Redundant for T { + fn redundant(&self) {} +} + +default impl Redundant for i32 { + fn redundant(&self) {} //~ ERROR E0520 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.stderr b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.stderr new file mode 100644 index 00000000000..98f5e6d619e --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-no-default.stderr @@ -0,0 +1,70 @@ +error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:32:5 + | +LL | / impl Foo for T { +LL | | fn foo(&self) {} +LL | | fn bar(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | fn foo(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^ cannot specialize default item `foo` + | + = note: to specialize, `foo` in the parent `impl` must be marked `default` + +error[E0520]: `bar` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:35:5 + | +LL | / impl Foo for T { +LL | | fn foo(&self) {} +LL | | fn bar(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | fn bar(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^ cannot specialize default item `bar` + | + = note: to specialize, `bar` in the parent `impl` must be marked `default` + +error[E0520]: `T` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:51:5 + | +LL | / impl Bar for T { +LL | | type T = u8; +LL | | } + | |_- parent `impl` is here +... +LL | type T = (); //~ ERROR E0520 + | ^^^^^^^^^^^^ cannot specialize default item `T` + | + = note: to specialize, `T` in the parent `impl` must be marked `default` + +error[E0520]: `baz` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:71:5 + | +LL | / impl Baz for T { +LL | | fn baz(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | fn baz(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^ cannot specialize default item `baz` + | + = note: to specialize, `baz` in the parent `impl` must be marked `default` + +error[E0520]: `redundant` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:92:5 + | +LL | / impl Redundant for T { +LL | | fn redundant(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | fn redundant(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant` + | + = note: to specialize, `redundant` in the parent `impl` must be marked `default` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0520`. diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.rs b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.rs new file mode 100644 index 00000000000..eacec2e40f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that default impls do not have to supply all items but regular impls do. + +#![feature(specialization)] + +trait Foo { + fn foo_one(&self) -> &'static str; + fn foo_two(&self) -> &'static str; +} + +struct MyStruct; + +default impl Foo for T { + fn foo_one(&self) -> &'static str { + "generic" + } +} + +impl Foo for MyStruct {} +//~^ ERROR not all trait items implemented, missing: `foo_two` [E0046] + +fn main() { + println!("{}", MyStruct.foo_one()); +} diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr new file mode 100644 index 00000000000..c3c2a9840ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-item-not-implemented.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `foo_two` + --> $DIR/specialization-trait-item-not-implemented.rs:28:1 + | +LL | fn foo_two(&self) -> &'static str; + | ---------------------------------- `foo_two` from trait +... +LL | impl Foo for MyStruct {} + | ^^^^^^^^^^^^^^^^^^^^^ missing `foo_two` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.rs b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.rs new file mode 100644 index 00000000000..04ddf9ebb17 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that: +// - default impls do not have to supply all items and +// - a default impl does not count as an impl (in this case, an incomplete default impl). + +#![feature(specialization)] + +trait Foo { + fn foo_one(&self) -> &'static str; + fn foo_two(&self) -> &'static str; +} + +struct MyStruct; + +default impl Foo for T { + fn foo_one(&self) -> &'static str { + "generic" + } +} + + +fn main() { + println!("{}", MyStruct.foo_one()); + //~^ ERROR no method named `foo_one` found for type `MyStruct` in the current scope +} diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.stderr b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.stderr new file mode 100644 index 00000000000..bc597e9f30c --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-trait-not-implemented.stderr @@ -0,0 +1,18 @@ +error[E0599]: no method named `foo_one` found for type `MyStruct` in the current scope + --> $DIR/specialization-trait-not-implemented.rs:32:29 + | +LL | struct MyStruct; + | ---------------- method `foo_one` not found for this +... +LL | println!("{}", MyStruct.foo_one()); + | ^^^^^^^ + | + = note: the method `foo_one` exists but the following trait bounds were not satisfied: + `MyStruct : Foo` + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `foo_one`, perhaps you need to implement it: + candidate #1: `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.rs b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.rs new file mode 100644 index 00000000000..445a59a373e --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that a default impl still has to have a WF trait ref. + +#![feature(specialization)] + +trait Foo<'a, T: Eq + 'a> { } + +default impl Foo<'static, U> for () {} +//~^ ERROR the trait bound `U: std::cmp::Eq` is not satisfied + +fn main(){} diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.stderr b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.stderr new file mode 100644 index 00000000000..a623e9708cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/specialization-wfcheck.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `U: std::cmp::Eq` is not satisfied + --> $DIR/specialization-wfcheck.rs:17:17 + | +LL | default impl Foo<'static, U> for () {} + | ^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `U` + | + = help: consider adding a `where U: std::cmp::Eq` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.rs b/src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.rs new file mode 100644 index 00000000000..26b8b737f34 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(specialization)] + +struct S; +struct Z; + +default impl S {} //~ ERROR inherent impls cannot be default + +default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be default +default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default + +trait Tr {} +default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits diff --git a/src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.stderr b/src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.stderr new file mode 100644 index 00000000000..54b92da7b21 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/defaultimpl/validation.stderr @@ -0,0 +1,34 @@ +error: inherent impls cannot be default + --> $DIR/validation.rs:17:1 + | +LL | default impl S {} //~ ERROR inherent impls cannot be default + | ^^^^^^^^^^^^^^^^^ + | + = note: only trait implementations may be annotated with default + +error[E0601]: `main` function not found in crate `validation` + | + = note: consider adding a `main` function to `$DIR/validation.rs` + +error: impls of auto traits cannot be default + --> $DIR/validation.rs:19:1 + | +LL | default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be default + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: impls of auto traits cannot be default + --> $DIR/validation.rs:20:1 + | +LL | default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) + --> $DIR/validation.rs:23:1 + | +LL | default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0192, E0601. +For more information about an error, try `rustc --explain E0192`. diff --git a/src/test/ui/compile-fail-migration/specialization/issue-52050.rs b/src/test/ui/compile-fail-migration/specialization/issue-52050.rs new file mode 100644 index 00000000000..70cdb4899c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/issue-52050.rs @@ -0,0 +1,42 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Regression test for #52050: when inserting the blanket impl `I` +// into the tree, we had to replace the child node for `Foo`, which +// led to the struture of the tree being messed up. + +use std::iter::Iterator; + +trait IntoPyDictPointer { } + +struct Foo { } + +impl Iterator for Foo { + type Item = (); + fn next(&mut self) -> Option<()> { + None + } +} + +impl IntoPyDictPointer for Foo { } + +impl IntoPyDictPointer for I +where + I: Iterator, +{ +} + +impl IntoPyDictPointer for () //~ ERROR conflicting implementations +{ +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/specialization/issue-52050.stderr b/src/test/ui/compile-fail-migration/specialization/issue-52050.stderr new file mode 100644 index 00000000000..eee571f8f46 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/issue-52050.stderr @@ -0,0 +1,18 @@ +error[E0119]: conflicting implementations of trait `IntoPyDictPointer` for type `()`: + --> $DIR/issue-52050.rs:38:1 + | +LL | / impl IntoPyDictPointer for I +LL | | where +LL | | I: Iterator, +LL | | { +LL | | } + | |_- first implementation here +LL | +LL | impl IntoPyDictPointer for () //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` + | + = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `()` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-default-projection.rs b/src/test/ui/compile-fail-migration/specialization/specialization-default-projection.rs new file mode 100644 index 00000000000..96cbd7a4852 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-default-projection.rs @@ -0,0 +1,46 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Make sure we can't project defaulted associated types + +trait Foo { + type Assoc; +} + +impl Foo for T { + default type Assoc = (); +} + +impl Foo for u8 { + type Assoc = String; +} + +fn generic() -> ::Assoc { + // `T` could be some downstream crate type that specializes (or, + // for that matter, `u8`). + + () //~ ERROR mismatched types +} + +fn monomorphic() -> () { + // Even though we know that `()` is not specialized in a + // downstream crate, typeck refuses to project here. + + generic::<()>() //~ ERROR mismatched types +} + +fn main() { + // No error here, we CAN project from `u8`, as there is no `default` + // in that impl. + let s: String = generic::(); + println!("{}", s); // bad news if this all compiles +} diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-default-projection.stderr b/src/test/ui/compile-fail-migration/specialization/specialization-default-projection.stderr new file mode 100644 index 00000000000..38b51394711 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-default-projection.stderr @@ -0,0 +1,29 @@ +error[E0308]: mismatched types + --> $DIR/specialization-default-projection.rs:31:5 + | +LL | fn generic() -> ::Assoc { + | ----------------- expected `::Assoc` because of return type +... +LL | () //~ ERROR mismatched types + | ^^ expected associated type, found () + | + = note: expected type `::Assoc` + found type `()` + +error[E0308]: mismatched types + --> $DIR/specialization-default-projection.rs:38:5 + | +LL | fn monomorphic() -> () { + | -- expected `()` because of return type +... +LL | generic::<()>() //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^- help: try adding a semicolon: `;` + | | + | expected (), found associated type + | + = note: expected type `()` + found type `<() as Foo>::Assoc` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-default-types.rs b/src/test/ui/compile-fail-migration/specialization/specialization-default-types.rs new file mode 100644 index 00000000000..18acecb4229 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-default-types.rs @@ -0,0 +1,45 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// It should not be possible to use the concrete value of a defaulted +// associated type in the impl defining it -- otherwise, what happens +// if it's overridden? + +#![feature(specialization)] + +trait Example { + type Output; + fn generate(self) -> Self::Output; +} + +impl Example for T { + default type Output = Box; + default fn generate(self) -> Self::Output { + Box::new(self) //~ ERROR mismatched types + } +} + +impl Example for bool { + type Output = bool; + fn generate(self) -> bool { self } +} + +fn trouble(t: T) -> Box { + Example::generate(t) //~ ERROR mismatched types +} + +fn weaponize() -> bool { + let b: Box = trouble(true); + *b +} + +fn main() { + weaponize(); +} diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-default-types.stderr b/src/test/ui/compile-fail-migration/specialization/specialization-default-types.stderr new file mode 100644 index 00000000000..a9abc1f6ab5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-default-types.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/specialization-default-types.rs:25:9 + | +LL | default fn generate(self) -> Self::Output { + | ------------ expected `::Output` because of return type +LL | Box::new(self) //~ ERROR mismatched types + | ^^^^^^^^^^^^^^ expected associated type, found struct `std::boxed::Box` + | + = note: expected type `::Output` + found type `std::boxed::Box` + +error[E0308]: mismatched types + --> $DIR/specialization-default-types.rs:35:5 + | +LL | fn trouble(t: T) -> Box { + | ------ expected `std::boxed::Box` because of return type +LL | Example::generate(t) //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ expected struct `std::boxed::Box`, found associated type + | + = note: expected type `std::boxed::Box` + found type `::Output` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-no-default.rs b/src/test/ui/compile-fail-migration/specialization/specialization-no-default.rs new file mode 100644 index 00000000000..96156168543 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-no-default.rs @@ -0,0 +1,95 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Check a number of scenarios in which one impl tries to override another, +// without correctly using `default`. + +//////////////////////////////////////////////////////////////////////////////// +// Test 1: one layer of specialization, multiple methods, missing `default` +//////////////////////////////////////////////////////////////////////////////// + +trait Foo { + fn foo(&self); + fn bar(&self); +} + +impl Foo for T { + fn foo(&self) {} + fn bar(&self) {} +} + +impl Foo for u8 {} +impl Foo for u16 { + fn foo(&self) {} //~ ERROR E0520 +} +impl Foo for u32 { + fn bar(&self) {} //~ ERROR E0520 +} + +//////////////////////////////////////////////////////////////////////////////// +// Test 2: one layer of specialization, missing `default` on associated type +//////////////////////////////////////////////////////////////////////////////// + +trait Bar { + type T; +} + +impl Bar for T { + type T = u8; +} + +impl Bar for u8 { + type T = (); //~ ERROR E0520 +} + +//////////////////////////////////////////////////////////////////////////////// +// Test 3a: multiple layers of specialization, missing interior `default` +//////////////////////////////////////////////////////////////////////////////// + +trait Baz { + fn baz(&self); +} + +impl Baz for T { + default fn baz(&self) {} +} + +impl Baz for T { + fn baz(&self) {} +} + +impl Baz for i32 { + fn baz(&self) {} //~ ERROR E0520 +} + +//////////////////////////////////////////////////////////////////////////////// +// Test 3b: multiple layers of specialization, missing interior `default`, +// redundant `default` in bottom layer. +//////////////////////////////////////////////////////////////////////////////// + +trait Redundant { + fn redundant(&self); +} + +impl Redundant for T { + default fn redundant(&self) {} +} + +impl Redundant for T { + fn redundant(&self) {} +} + +impl Redundant for i32 { + default fn redundant(&self) {} //~ ERROR E0520 +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-no-default.stderr b/src/test/ui/compile-fail-migration/specialization/specialization-no-default.stderr new file mode 100644 index 00000000000..880c2e5d6f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-no-default.stderr @@ -0,0 +1,70 @@ +error[E0520]: `foo` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:32:5 + | +LL | / impl Foo for T { +LL | | fn foo(&self) {} +LL | | fn bar(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | fn foo(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^ cannot specialize default item `foo` + | + = note: to specialize, `foo` in the parent `impl` must be marked `default` + +error[E0520]: `bar` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:35:5 + | +LL | / impl Foo for T { +LL | | fn foo(&self) {} +LL | | fn bar(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | fn bar(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^ cannot specialize default item `bar` + | + = note: to specialize, `bar` in the parent `impl` must be marked `default` + +error[E0520]: `T` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:51:5 + | +LL | / impl Bar for T { +LL | | type T = u8; +LL | | } + | |_- parent `impl` is here +... +LL | type T = (); //~ ERROR E0520 + | ^^^^^^^^^^^^ cannot specialize default item `T` + | + = note: to specialize, `T` in the parent `impl` must be marked `default` + +error[E0520]: `baz` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:71:5 + | +LL | / impl Baz for T { +LL | | fn baz(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | fn baz(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^ cannot specialize default item `baz` + | + = note: to specialize, `baz` in the parent `impl` must be marked `default` + +error[E0520]: `redundant` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/specialization-no-default.rs:92:5 + | +LL | / impl Redundant for T { +LL | | fn redundant(&self) {} +LL | | } + | |_- parent `impl` is here +... +LL | default fn redundant(&self) {} //~ ERROR E0520 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `redundant` + | + = note: to specialize, `redundant` in the parent `impl` must be marked `default` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0520`. diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.rs b/src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.rs new file mode 100644 index 00000000000..62a6d8d9b50 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(specialization)] + +trait MyTrait {} + +struct TestType(::std::marker::PhantomData); + +unsafe impl Send for TestType {} +impl !Send for TestType {} //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.stderr b/src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.stderr new file mode 100644 index 00000000000..2b85ba54e90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-overlap-negative.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: + --> $DIR/specialization-overlap-negative.rs:19:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------ first implementation here +LL | impl !Send for TestType {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-overlap.rs b/src/test/ui/compile-fail-migration/specialization/specialization-overlap.rs new file mode 100644 index 00000000000..ff12a82db5b --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-overlap.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +trait Foo { fn foo() {} } +impl Foo for T {} +impl Foo for Vec {} //~ ERROR E0119 + +trait Bar { fn bar() {} } +impl Bar for (T, u8) {} +impl Bar for (u8, T) {} //~ ERROR E0119 + +trait Baz { fn baz() {} } +impl Baz for u8 {} +impl Baz for T {} //~ ERROR E0119 + +trait Qux { fn qux() {} } +impl Qux for T {} +impl Qux for T {} //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-overlap.stderr b/src/test/ui/compile-fail-migration/specialization/specialization-overlap.stderr new file mode 100644 index 00000000000..6830b7de473 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-overlap.stderr @@ -0,0 +1,35 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `std::vec::Vec<_>`: + --> $DIR/specialization-overlap.rs:15:1 + | +LL | impl Foo for T {} + | ------------------------ first implementation here +LL | impl Foo for Vec {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::vec::Vec<_>` + +error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: + --> $DIR/specialization-overlap.rs:19:1 + | +LL | impl Bar for (T, u8) {} + | ----------------------- first implementation here +LL | impl Bar for (u8, T) {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` + +error[E0119]: conflicting implementations of trait `Baz` for type `u8`: + --> $DIR/specialization-overlap.rs:23:1 + | +LL | impl Baz for u8 {} + | --------------------- first implementation here +LL | impl Baz for T {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error[E0119]: conflicting implementations of trait `Qux`: + --> $DIR/specialization-overlap.rs:27:1 + | +LL | impl Qux for T {} + | ------------------------ first implementation here +LL | impl Qux for T {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-polarity.rs b/src/test/ui/compile-fail-migration/specialization/specialization-polarity.rs new file mode 100644 index 00000000000..b28a63c8293 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-polarity.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure specialization cannot change impl polarity + +#![feature(optin_builtin_traits)] +#![feature(specialization)] + +auto trait Foo {} + +impl Foo for T {} +impl !Foo for u8 {} //~ ERROR E0119 + +auto trait Bar {} + +impl !Bar for T {} +impl Bar for u8 {} //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/specialization/specialization-polarity.stderr b/src/test/ui/compile-fail-migration/specialization/specialization-polarity.stderr new file mode 100644 index 00000000000..a4627305885 --- /dev/null +++ b/src/test/ui/compile-fail-migration/specialization/specialization-polarity.stderr @@ -0,0 +1,19 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `u8`: + --> $DIR/specialization-polarity.rs:19:1 + | +LL | impl Foo for T {} + | ----------------- first implementation here +LL | impl !Foo for u8 {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error[E0119]: conflicting implementations of trait `Bar` for type `u8`: + --> $DIR/specialization-polarity.rs:24:1 + | +LL | impl !Bar for T {} + | ------------------ first implementation here +LL | impl Bar for u8 {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/stability-attribute-issue-43027.rs b/src/test/ui/compile-fail-migration/stability-attribute-issue-43027.rs new file mode 100644 index 00000000000..dac50db3fd9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-issue-43027.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(staged_api)] +#![stable(feature = "test", since = "0")] + +#[stable(feature = "test", since = "0")] +pub struct Reverse(pub T); //~ ERROR This node does not have a stability attribute + +fn main() { + // Make sure the field is used to fill the stability cache + Reverse(0).0; +} diff --git a/src/test/ui/compile-fail-migration/stability-attribute-issue-43027.stderr b/src/test/ui/compile-fail-migration/stability-attribute-issue-43027.stderr new file mode 100644 index 00000000000..bdfdd9ccc87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-issue-43027.stderr @@ -0,0 +1,8 @@ +error: This node does not have a stability attribute + --> $DIR/stability-attribute-issue-43027.rs:15:23 + | +LL | pub struct Reverse(pub T); //~ ERROR This node does not have a stability attribute + | ^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/stability-attribute-issue.rs b/src/test/ui/compile-fail-migration/stability-attribute-issue.rs new file mode 100644 index 00000000000..754c6f792f9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-issue.rs @@ -0,0 +1,24 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:stability_attribute_issue.rs +// ignore-tidy-linelength + +#![deny(deprecated)] + +extern crate stability_attribute_issue; +use stability_attribute_issue::*; + +fn main() { + unstable(); + //~^ ERROR use of unstable library feature 'unstable_test_feature' (see issue #1) + unstable_msg(); + //~^ ERROR use of unstable library feature 'unstable_test_feature': message (see issue #2) +} diff --git a/src/test/ui/compile-fail-migration/stability-attribute-issue.stderr b/src/test/ui/compile-fail-migration/stability-attribute-issue.stderr new file mode 100644 index 00000000000..15e91926a73 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-issue.stderr @@ -0,0 +1,19 @@ +error[E0658]: use of unstable library feature 'unstable_test_feature' (see issue #1) + --> $DIR/stability-attribute-issue.rs:20:5 + | +LL | unstable(); + | ^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error[E0658]: use of unstable library feature 'unstable_test_feature': message (see issue #2) + --> $DIR/stability-attribute-issue.rs:22:5 + | +LL | unstable_msg(); + | ^^^^^^^^^^^^ + | + = help: add #![feature(unstable_test_feature)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.rs b/src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.rs new file mode 100644 index 00000000000..512fb24a0c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-Zforce-unstable-if-unmarked + +#[unstable] //~ ERROR: stability attributes may not be used +#[stable] //~ ERROR: stability attributes may not be used +#[rustc_deprecated] //~ ERROR: stability attributes may not be used +fn main() { } diff --git a/src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.stderr b/src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.stderr new file mode 100644 index 00000000000..479f2ff5095 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-non-staged-force-unstable.stderr @@ -0,0 +1,20 @@ +error: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged-force-unstable.rs:13:1 + | +LL | #[unstable] //~ ERROR: stability attributes may not be used + | ^^^^^^^^^^^ + +error: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged-force-unstable.rs:14:1 + | +LL | #[stable] //~ ERROR: stability attributes may not be used + | ^^^^^^^^^ + +error: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged-force-unstable.rs:15:1 + | +LL | #[rustc_deprecated] //~ ERROR: stability attributes may not be used + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/stability-attribute-non-staged.rs b/src/test/ui/compile-fail-migration/stability-attribute-non-staged.rs new file mode 100644 index 00000000000..35256f21f92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-non-staged.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[unstable] //~ ERROR: stability attributes may not be used +#[stable] //~ ERROR: stability attributes may not be used +#[rustc_deprecated] //~ ERROR: stability attributes may not be used +fn main() { } diff --git a/src/test/ui/compile-fail-migration/stability-attribute-non-staged.stderr b/src/test/ui/compile-fail-migration/stability-attribute-non-staged.stderr new file mode 100644 index 00000000000..f2a9879bd10 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-non-staged.stderr @@ -0,0 +1,20 @@ +error: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged.rs:11:1 + | +LL | #[unstable] //~ ERROR: stability attributes may not be used + | ^^^^^^^^^^^ + +error: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged.rs:12:1 + | +LL | #[stable] //~ ERROR: stability attributes may not be used + | ^^^^^^^^^ + +error: stability attributes may not be used outside of the standard library + --> $DIR/stability-attribute-non-staged.rs:13:1 + | +LL | #[rustc_deprecated] //~ ERROR: stability attributes may not be used + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/stability-attribute-sanity-2.rs b/src/test/ui/compile-fail-migration/stability-attribute-sanity-2.rs new file mode 100644 index 00000000000..9c54315bfd0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-sanity-2.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// More checks that stability attributes are used correctly + +#![feature(staged_api)] + +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[stable(feature = "a", feature = "b", since = "1.0.0")] //~ ERROR multiple 'feature' items +fn f1() { } + +#[stable(feature = "a", sinse = "1.0.0")] //~ ERROR unknown meta item 'sinse' +fn f2() { } + +#[unstable(feature = "a", issue = "no")] //~ ERROR incorrect 'issue' +fn f3() { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/stability-attribute-sanity-2.stderr b/src/test/ui/compile-fail-migration/stability-attribute-sanity-2.stderr new file mode 100644 index 00000000000..a9d70e25302 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-sanity-2.stderr @@ -0,0 +1,22 @@ +error[E0538]: multiple 'feature' items + --> $DIR/stability-attribute-sanity-2.rs:17:25 + | +LL | #[stable(feature = "a", feature = "b", since = "1.0.0")] //~ ERROR multiple 'feature' items + | ^^^^^^^^^^^^^ + +error[E0541]: unknown meta item 'sinse' + --> $DIR/stability-attribute-sanity-2.rs:20:25 + | +LL | #[stable(feature = "a", sinse = "1.0.0")] //~ ERROR unknown meta item 'sinse' + | ^^^^^^^^^^^^^^^ expected one of `since`, `note` + +error[E0545]: incorrect 'issue' + --> $DIR/stability-attribute-sanity-2.rs:23:1 + | +LL | #[unstable(feature = "a", issue = "no")] //~ ERROR incorrect 'issue' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0538, E0541, E0545. +For more information about an error, try `rustc --explain E0538`. diff --git a/src/test/ui/compile-fail-migration/stability-attribute-sanity-3.rs b/src/test/ui/compile-fail-migration/stability-attribute-sanity-3.rs new file mode 100644 index 00000000000..d4821e009f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-sanity-3.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// More checks that stability attributes are used correctly + +#![feature(staged_api)] + +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[macro_export] +macro_rules! mac { //~ ERROR This node does not have a stability attribute + () => () +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/stability-attribute-sanity-3.stderr b/src/test/ui/compile-fail-migration/stability-attribute-sanity-3.stderr new file mode 100644 index 00000000000..b5b5847e8e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-sanity-3.stderr @@ -0,0 +1,10 @@ +error: This node does not have a stability attribute + --> $DIR/stability-attribute-sanity-3.rs:18:1 + | +LL | / macro_rules! mac { //~ ERROR This node does not have a stability attribute +LL | | () => () +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/stability-attribute-sanity.rs b/src/test/ui/compile-fail-migration/stability-attribute-sanity.rs new file mode 100644 index 00000000000..794ae1ca087 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-sanity.rs @@ -0,0 +1,101 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various checks that stability attributes are used correctly, per RFC 507 + +#![feature(const_fn, staged_api, rustc_const_unstable)] + +#![stable(feature = "rust1", since = "1.0.0")] + +mod bogus_attribute_types_1 { + #[stable(feature = "a", since = "b", reason)] //~ ERROR unknown meta item 'reason' [E0541] + fn f1() { } + + #[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539] + fn f2() { } + + #[stable(feature, since = "a")] //~ ERROR incorrect meta item [E0539] + fn f3() { } + + #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539] + fn f5() { } + + #[stable(feature(b), since = "a")] //~ ERROR incorrect meta item [E0539] + fn f6() { } +} + +mod bogus_attribute_types_2 { + #[unstable] //~ ERROR incorrect stability attribute type [E0548] + fn f1() { } + + #[unstable = "b"] //~ ERROR incorrect stability attribute type [E0548] + fn f2() { } + + #[stable] //~ ERROR incorrect stability attribute type [E0548] + fn f3() { } + + #[stable = "a"] //~ ERROR incorrect stability attribute type [E0548] + fn f4() { } + + #[stable(feature = "a", since = "b")] + #[rustc_deprecated] //~ ERROR incorrect stability attribute type [E0548] + fn f5() { } + + #[stable(feature = "a", since = "b")] + #[rustc_deprecated = "a"] //~ ERROR incorrect stability attribute type [E0548] + fn f6() { } +} + +mod missing_feature_names { + #[unstable(issue = "0")] //~ ERROR missing 'feature' [E0546] + fn f1() { } + + #[unstable(feature = "b")] //~ ERROR missing 'issue' [E0547] + fn f2() { } + + #[stable(since = "a")] //~ ERROR missing 'feature' [E0546] + fn f3() { } +} + +mod missing_version { + #[stable(feature = "a")] //~ ERROR missing 'since' [E0542] + fn f1() { } + + #[stable(feature = "a", since = "b")] + #[rustc_deprecated(reason = "a")] //~ ERROR missing 'since' [E0542] + fn f2() { } +} + +#[unstable(feature = "b", issue = "0")] +#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544] +fn multiple1() { } + +#[unstable(feature = "b", issue = "0")] +#[unstable(feature = "b", issue = "0")] //~ ERROR multiple stability levels [E0544] +fn multiple2() { } + +#[stable(feature = "a", since = "b")] +#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544] +fn multiple3() { } + +#[stable(feature = "a", since = "b")] +#[rustc_deprecated(since = "b", reason = "text")] +#[rustc_deprecated(since = "b", reason = "text")] +#[rustc_const_unstable(feature = "c")] +#[rustc_const_unstable(feature = "d")] +pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540] +//~^ ERROR Invalid stability or deprecation version found +//~| ERROR multiple rustc_const_unstable attributes + +#[rustc_deprecated(since = "a", reason = "text")] +fn deprecated_without_unstable_or_stable() { } +//~^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/stability-attribute-sanity.stderr b/src/test/ui/compile-fail-migration/stability-attribute-sanity.stderr new file mode 100644 index 00000000000..f9d301f643d --- /dev/null +++ b/src/test/ui/compile-fail-migration/stability-attribute-sanity.stderr @@ -0,0 +1,142 @@ +error[E0541]: unknown meta item 'reason' + --> $DIR/stability-attribute-sanity.rs:18:42 + | +LL | #[stable(feature = "a", since = "b", reason)] //~ ERROR unknown meta item 'reason' [E0541] + | ^^^^^^ expected one of `since`, `note` + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:21:29 + | +LL | #[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539] + | ^^^^^ + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:24:14 + | +LL | #[stable(feature, since = "a")] //~ ERROR incorrect meta item [E0539] + | ^^^^^^^ + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:27:29 + | +LL | #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539] + | ^^^^^^^^ + +error[E0539]: incorrect meta item + --> $DIR/stability-attribute-sanity.rs:30:14 + | +LL | #[stable(feature(b), since = "a")] //~ ERROR incorrect meta item [E0539] + | ^^^^^^^^^^ + +error[E0548]: incorrect stability attribute type + --> $DIR/stability-attribute-sanity.rs:35:5 + | +LL | #[unstable] //~ ERROR incorrect stability attribute type [E0548] + | ^^^^^^^^^^^ + +error[E0548]: incorrect stability attribute type + --> $DIR/stability-attribute-sanity.rs:38:5 + | +LL | #[unstable = "b"] //~ ERROR incorrect stability attribute type [E0548] + | ^^^^^^^^^^^^^^^^^ + +error[E0548]: incorrect stability attribute type + --> $DIR/stability-attribute-sanity.rs:41:5 + | +LL | #[stable] //~ ERROR incorrect stability attribute type [E0548] + | ^^^^^^^^^ + +error[E0548]: incorrect stability attribute type + --> $DIR/stability-attribute-sanity.rs:44:5 + | +LL | #[stable = "a"] //~ ERROR incorrect stability attribute type [E0548] + | ^^^^^^^^^^^^^^^ + +error[E0548]: incorrect stability attribute type + --> $DIR/stability-attribute-sanity.rs:48:5 + | +LL | #[rustc_deprecated] //~ ERROR incorrect stability attribute type [E0548] + | ^^^^^^^^^^^^^^^^^^^ + +error[E0548]: incorrect stability attribute type + --> $DIR/stability-attribute-sanity.rs:52:5 + | +LL | #[rustc_deprecated = "a"] //~ ERROR incorrect stability attribute type [E0548] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0546]: missing 'feature' + --> $DIR/stability-attribute-sanity.rs:57:5 + | +LL | #[unstable(issue = "0")] //~ ERROR missing 'feature' [E0546] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0547]: missing 'issue' + --> $DIR/stability-attribute-sanity.rs:60:5 + | +LL | #[unstable(feature = "b")] //~ ERROR missing 'issue' [E0547] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0546]: missing 'feature' + --> $DIR/stability-attribute-sanity.rs:63:5 + | +LL | #[stable(since = "a")] //~ ERROR missing 'feature' [E0546] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0542]: missing 'since' + --> $DIR/stability-attribute-sanity.rs:68:5 + | +LL | #[stable(feature = "a")] //~ ERROR missing 'since' [E0542] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0542]: missing 'since' + --> $DIR/stability-attribute-sanity.rs:72:5 + | +LL | #[rustc_deprecated(reason = "a")] //~ ERROR missing 'since' [E0542] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0544]: multiple stability levels + --> $DIR/stability-attribute-sanity.rs:77:1 + | +LL | #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0544]: multiple stability levels + --> $DIR/stability-attribute-sanity.rs:81:1 + | +LL | #[unstable(feature = "b", issue = "0")] //~ ERROR multiple stability levels [E0544] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0544]: multiple stability levels + --> $DIR/stability-attribute-sanity.rs:85:1 + | +LL | #[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0540]: multiple rustc_deprecated attributes + --> $DIR/stability-attribute-sanity.rs:93:1 + | +LL | pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0553]: multiple rustc_const_unstable attributes + --> $DIR/stability-attribute-sanity.rs:93:1 + | +LL | pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Invalid stability or deprecation version found + --> $DIR/stability-attribute-sanity.rs:93:1 + | +LL | pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0549]: rustc_deprecated attribute must be paired with either stable or unstable attribute + --> $DIR/stability-attribute-sanity.rs:98:1 + | +LL | fn deprecated_without_unstable_or_stable() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 23 previous errors + +Some errors occurred: E0539, E0540, E0541, E0542, E0544, E0546, E0547, E0548, E0549... +For more information about an error, try `rustc --explain E0539`. diff --git a/src/test/ui/compile-fail-migration/stable-features.rs b/src/test/ui/compile-fail-migration/stable-features.rs new file mode 100644 index 00000000000..32991dd6499 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stable-features.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Testing that the stable_features lint catches use of stable +// language and lib features. + +#![deny(stable_features)] + +#![feature(test_accepted_feature)] +//~^ ERROR the feature `test_accepted_feature` has been stable since 1.0.0 + +#![feature(rust1)] +//~^ ERROR the feature `rust1` has been stable since 1.0.0 + +fn main() { + let _foo: Vec<()> = Vec::new(); +} diff --git a/src/test/ui/compile-fail-migration/stable-features.stderr b/src/test/ui/compile-fail-migration/stable-features.stderr new file mode 100644 index 00000000000..53d642c07e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stable-features.stderr @@ -0,0 +1,20 @@ +error: the feature `test_accepted_feature` has been stable since 1.0.0 and no longer requires an attribute to enable + --> $DIR/stable-features.rs:16:12 + | +LL | #![feature(test_accepted_feature)] + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/stable-features.rs:14:9 + | +LL | #![deny(stable_features)] + | ^^^^^^^^^^^^^^^ + +error: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable + --> $DIR/stable-features.rs:19:12 + | +LL | #![feature(rust1)] + | ^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/static-closures.rs b/src/test/ui/compile-fail-migration/static-closures.rs new file mode 100644 index 00000000000..8593eb5333e --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-closures.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + static || {}; + //~^ ERROR closures cannot be static +} diff --git a/src/test/ui/compile-fail-migration/static-closures.stderr b/src/test/ui/compile-fail-migration/static-closures.stderr new file mode 100644 index 00000000000..761d8374bcc --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-closures.stderr @@ -0,0 +1,9 @@ +error[E0697]: closures cannot be static + --> $DIR/static-closures.rs:12:5 + | +LL | static || {}; + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0697`. diff --git a/src/test/ui/compile-fail-migration/static-drop-scope.rs b/src/test/ui/compile-fail-migration/static-drop-scope.rs new file mode 100644 index 00000000000..e22eb7e4484 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-drop-scope.rs @@ -0,0 +1,41 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_fn)] + +struct WithDtor; + +impl Drop for WithDtor { + fn drop(&mut self) {} +} + +static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); +//~^ ERROR destructors cannot be evaluated at compile-time +//~| ERROR borrowed value does not live long enoug + +const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); +//~^ ERROR destructors cannot be evaluated at compile-time +//~| ERROR borrowed value does not live long enoug + +static EARLY_DROP_S: i32 = (WithDtor, 0).1; +//~^ ERROR destructors cannot be evaluated at compile-time + +const EARLY_DROP_C: i32 = (WithDtor, 0).1; +//~^ ERROR destructors cannot be evaluated at compile-time + +const fn const_drop(_: T) {} +//~^ ERROR destructors cannot be evaluated at compile-time + +const fn const_drop2(x: T) { + (x, ()).1 + //~^ ERROR destructors cannot be evaluated at compile-time +} + +fn main () {} diff --git a/src/test/ui/compile-fail-migration/static-drop-scope.stderr b/src/test/ui/compile-fail-migration/static-drop-scope.stderr new file mode 100644 index 00000000000..ce158239370 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-drop-scope.stderr @@ -0,0 +1,60 @@ +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:19:60 + | +LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); + | ^^^^^^^^ statics cannot evaluate destructors + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-drop-scope.rs:19:60 + | +LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); + | ^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | + = note: borrowed value must be valid for the static lifetime... + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:23:59 + | +LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); + | ^^^^^^^^ constants cannot evaluate destructors + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-drop-scope.rs:23:59 + | +LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); + | ^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | + = note: borrowed value must be valid for the static lifetime... + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:27:28 + | +LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1; + | ^^^^^^^^^^^^^ statics cannot evaluate destructors + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:30:27 + | +LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1; + | ^^^^^^^^^^^^^ constants cannot evaluate destructors + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:33:24 + | +LL | const fn const_drop(_: T) {} + | ^ constant functions cannot evaluate destructors + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:37:5 + | +LL | (x, ()).1 + | ^^^^^^^ constant functions cannot evaluate destructors + +error: aborting due to 8 previous errors + +Some errors occurred: E0493, E0597. +For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/compile-fail-migration/static-items-cant-move.rs b/src/test/ui/compile-fail-migration/static-items-cant-move.rs new file mode 100644 index 00000000000..c8fddeb1214 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-items-cant-move.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Verifies that static items can't be moved + +struct B; + +struct Foo { + foo: isize, + b: B, +} + +static BAR: Foo = Foo { foo: 5, b: B }; + + +fn test(f: Foo) { + let _f = Foo{foo: 4, ..f}; +} + +fn main() { + test(BAR); //~ ERROR cannot move out of static item +} diff --git a/src/test/ui/compile-fail-migration/static-items-cant-move.stderr b/src/test/ui/compile-fail-migration/static-items-cant-move.stderr new file mode 100644 index 00000000000..254710b6b2e --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-items-cant-move.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of static item + --> $DIR/static-items-cant-move.rs:28:10 + | +LL | test(BAR); //~ ERROR cannot move out of static item + | ^^^ cannot move out of static item + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/static-lifetime-bound.nll.stderr b/src/test/ui/compile-fail-migration/static-lifetime-bound.nll.stderr new file mode 100644 index 00000000000..ad4d04343fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-lifetime-bound.nll.stderr @@ -0,0 +1,21 @@ +warning: unnecessary lifetime parameter `'a` + --> $DIR/static-lifetime-bound.rs:11:6 + | +LL | fn f<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a` + | ^^^^^^^^^^^ + | + = help: you can use the `'static` lifetime directly, in place of `'a` + +error[E0597]: `x` does not live long enough + --> $DIR/static-lifetime-bound.rs:15:7 + | +LL | f(&x); //~ERROR does not live long enough + | ^^ borrowed value does not live long enough +LL | } + | - `x` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/static-lifetime-bound.rs b/src/test/ui/compile-fail-migration/static-lifetime-bound.rs new file mode 100644 index 00000000000..38534ab0a36 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-lifetime-bound.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a` + +fn main() { + let x = 0; + f(&x); //~ERROR does not live long enough +} diff --git a/src/test/ui/compile-fail-migration/static-lifetime-bound.stderr b/src/test/ui/compile-fail-migration/static-lifetime-bound.stderr new file mode 100644 index 00000000000..0ee2b665cf1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-lifetime-bound.stderr @@ -0,0 +1,21 @@ +warning: unnecessary lifetime parameter `'a` + --> $DIR/static-lifetime-bound.rs:11:6 + | +LL | fn f<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a` + | ^^^^^^^^^^^ + | + = help: you can use the `'static` lifetime directly, in place of `'a` + +error[E0597]: `x` does not live long enough + --> $DIR/static-lifetime-bound.rs:15:8 + | +LL | f(&x); //~ERROR does not live long enough + | ^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/static-method-privacy.rs b/src/test/ui/compile-fail-migration/static-method-privacy.rs new file mode 100644 index 00000000000..5e175aa0fee --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-method-privacy.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { + pub struct S; + impl S { + fn new() -> S { S } + } +} + +fn main() { + let _ = a::S::new(); //~ ERROR method `new` is private +} diff --git a/src/test/ui/compile-fail-migration/static-method-privacy.stderr b/src/test/ui/compile-fail-migration/static-method-privacy.stderr new file mode 100644 index 00000000000..783b72c8ed2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-method-privacy.stderr @@ -0,0 +1,9 @@ +error[E0624]: method `new` is private + --> $DIR/static-method-privacy.rs:19:13 + | +LL | let _ = a::S::new(); //~ ERROR method `new` is private + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/static-mut-bad-types.rs b/src/test/ui/compile-fail-migration/static-mut-bad-types.rs new file mode 100644 index 00000000000..088c8ef3ab8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-bad-types.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static mut a: isize = 3; + +fn main() { + unsafe { + a = true; //~ ERROR: mismatched types + } +} diff --git a/src/test/ui/compile-fail-migration/static-mut-bad-types.stderr b/src/test/ui/compile-fail-migration/static-mut-bad-types.stderr new file mode 100644 index 00000000000..f8bee22b181 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-bad-types.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/static-mut-bad-types.rs:15:13 + | +LL | a = true; //~ ERROR: mismatched types + | ^^^^ expected isize, found bool + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.rs b/src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.rs new file mode 100644 index 00000000000..c6d744fa64d --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.rs @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + static mut a: i32; +} + +fn main() { + a += 3; //~ ERROR: requires unsafe + a = 4; //~ ERROR: requires unsafe + let _b = a; //~ ERROR: requires unsafe +} diff --git a/src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.stderr b/src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.stderr new file mode 100644 index 00000000000..01cbe784b45 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-foreign-requires-unsafe.stderr @@ -0,0 +1,27 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/static-mut-foreign-requires-unsafe.rs:16:5 + | +LL | a += 3; //~ ERROR: requires unsafe + | ^^^^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/static-mut-foreign-requires-unsafe.rs:17:5 + | +LL | a = 4; //~ ERROR: requires unsafe + | ^^^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/static-mut-foreign-requires-unsafe.rs:18:14 + | +LL | let _b = a; //~ ERROR: requires unsafe + | ^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/static-mut-not-constant.rs b/src/test/ui/compile-fail-migration/static-mut-not-constant.rs new file mode 100644 index 00000000000..7e6ced12fe6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-not-constant.rs @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +static mut a: Box = box 3; +//~^ ERROR allocations are not allowed in statics + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/static-mut-not-constant.stderr b/src/test/ui/compile-fail-migration/static-mut-not-constant.stderr new file mode 100644 index 00000000000..ad44121e763 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-not-constant.stderr @@ -0,0 +1,9 @@ +error[E0010]: allocations are not allowed in statics + --> $DIR/static-mut-not-constant.rs:13:28 + | +LL | static mut a: Box = box 3; + | ^^^^^ allocation not allowed in statics + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0010`. diff --git a/src/test/ui/compile-fail-migration/static-mut-not-pat.rs b/src/test/ui/compile-fail-migration/static-mut-not-pat.rs new file mode 100644 index 00000000000..351a47fdf39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-not-pat.rs @@ -0,0 +1,53 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Constants (static variables) can be used to match in patterns, but mutable +// statics cannot. This ensures that there's some form of error if this is +// attempted. + +static mut a: isize = 3; + +fn main() { + // If they can't be matched against, then it's possible to capture the same + // name as a variable, hence this should be an unreachable pattern situation + // instead of spitting out a custom error about some identifier collisions + // (we should allow shadowing) + match 4 { + a => {} //~ ERROR match bindings cannot shadow statics + _ => {} + } +} + +struct NewBool(bool); +enum Direction { + North, + East, + South, + West +} +const NEW_FALSE: NewBool = NewBool(false); +struct Foo { + bar: Option, + baz: NewBool +} + +static mut STATIC_MUT_FOO: Foo = Foo { bar: Some(Direction::West), baz: NEW_FALSE }; + +fn mutable_statics() { + match (Foo { bar: Some(Direction::North), baz: NewBool(true) }) { + Foo { bar: None, baz: NewBool(true) } => (), + STATIC_MUT_FOO => (), + //~^ ERROR match bindings cannot shadow statics + Foo { bar: Some(Direction::South), .. } => (), + Foo { bar: Some(EAST), .. } => (), + Foo { bar: Some(Direction::North), baz: NewBool(true) } => (), + Foo { bar: Some(EAST), baz: NewBool(false) } => () + } +} diff --git a/src/test/ui/compile-fail-migration/static-mut-not-pat.stderr b/src/test/ui/compile-fail-migration/static-mut-not-pat.stderr new file mode 100644 index 00000000000..123cf7b3ac6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-not-pat.stderr @@ -0,0 +1,21 @@ +error[E0530]: match bindings cannot shadow statics + --> $DIR/static-mut-not-pat.rs:23:9 + | +LL | static mut a: isize = 3; + | ------------------------ a static `a` is defined here +... +LL | a => {} //~ ERROR match bindings cannot shadow statics + | ^ cannot be named the same as a static + +error[E0530]: match bindings cannot shadow statics + --> $DIR/static-mut-not-pat.rs:46:9 + | +LL | static mut STATIC_MUT_FOO: Foo = Foo { bar: Some(Direction::West), baz: NEW_FALSE }; + | ------------------------------------------------------------------------------------ a static `STATIC_MUT_FOO` is defined here +... +LL | STATIC_MUT_FOO => (), + | ^^^^^^^^^^^^^^ cannot be named the same as a static + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0530`. diff --git a/src/test/ui/compile-fail-migration/static-mut-requires-unsafe.rs b/src/test/ui/compile-fail-migration/static-mut-requires-unsafe.rs new file mode 100644 index 00000000000..f6ad46a0527 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-requires-unsafe.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static mut a: isize = 3; + +fn main() { + a += 3; //~ ERROR: requires unsafe + a = 4; //~ ERROR: requires unsafe + let _b = a; //~ ERROR: requires unsafe +} diff --git a/src/test/ui/compile-fail-migration/static-mut-requires-unsafe.stderr b/src/test/ui/compile-fail-migration/static-mut-requires-unsafe.stderr new file mode 100644 index 00000000000..310da8f67f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-mut-requires-unsafe.stderr @@ -0,0 +1,27 @@ +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/static-mut-requires-unsafe.rs:14:5 + | +LL | a += 3; //~ ERROR: requires unsafe + | ^^^^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/static-mut-requires-unsafe.rs:15:5 + | +LL | a = 4; //~ ERROR: requires unsafe + | ^^^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/static-mut-requires-unsafe.rs:16:14 + | +LL | let _b = a; //~ ERROR: requires unsafe + | ^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/static-priv-by-default.rs b/src/test/ui/compile-fail-migration/static-priv-by-default.rs new file mode 100644 index 00000000000..14299a9b639 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-priv-by-default.rs @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:static_priv_by_default.rs + +extern crate static_priv_by_default; + +mod child { + pub mod childs_child { + static private: isize = 0; + pub static public: isize = 0; + } +} + +fn foo(_: isize) {} + +fn full_ref() { + foo(static_priv_by_default::private); //~ ERROR: static `private` is private + foo(static_priv_by_default::public); + foo(child::childs_child::private); //~ ERROR: static `private` is private + foo(child::childs_child::public); +} + +fn medium_ref() { + use child::childs_child; + foo(childs_child::private); //~ ERROR: static `private` is private + foo(childs_child::public); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/static-priv-by-default.stderr b/src/test/ui/compile-fail-migration/static-priv-by-default.stderr new file mode 100644 index 00000000000..4e47f7d8c97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-priv-by-default.stderr @@ -0,0 +1,21 @@ +error[E0603]: static `private` is private + --> $DIR/static-priv-by-default.rs:25:9 + | +LL | foo(static_priv_by_default::private); //~ ERROR: static `private` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: static `private` is private + --> $DIR/static-priv-by-default.rs:27:9 + | +LL | foo(child::childs_child::private); //~ ERROR: static `private` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: static `private` is private + --> $DIR/static-priv-by-default.rs:33:9 + | +LL | foo(childs_child::private); //~ ERROR: static `private` is private + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/static-priv-by-default2.rs b/src/test/ui/compile-fail-migration/static-priv-by-default2.rs new file mode 100644 index 00000000000..577e4f7542d --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-priv-by-default2.rs @@ -0,0 +1,40 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:static_priv_by_default.rs + +extern crate static_priv_by_default; + +mod child { + pub mod childs_child { + static private: isize = 0; + pub static public: isize = 0; + } +} + +fn foo(_: T) {} + +fn test1() { + use child::childs_child::private; + //~^ ERROR: static `private` is private + use child::childs_child::public; + + foo(private); +} + +fn test2() { + use static_priv_by_default::private; + //~^ ERROR: static `private` is private + use static_priv_by_default::public; + + foo(private); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/static-priv-by-default2.stderr b/src/test/ui/compile-fail-migration/static-priv-by-default2.stderr new file mode 100644 index 00000000000..0f749b0e4f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-priv-by-default2.stderr @@ -0,0 +1,15 @@ +error[E0603]: static `private` is private + --> $DIR/static-priv-by-default2.rs:25:9 + | +LL | use child::childs_child::private; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: static `private` is private + --> $DIR/static-priv-by-default2.rs:33:9 + | +LL | use static_priv_by_default::private; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/static-reference-to-fn-1.rs b/src/test/ui/compile-fail-migration/static-reference-to-fn-1.rs new file mode 100644 index 00000000000..cf8ee1ecb41 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-reference-to-fn-1.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct A<'a> { + func: &'a fn() -> Option +} + +impl<'a> A<'a> { + fn call(&self) -> Option { + (*self.func)() + } +} + +fn foo() -> Option { + None +} + +fn create() -> A<'static> { + A { + func: &foo, //~ ERROR mismatched types + } +} + +fn main() { + let a = create(); + a.call(); +} diff --git a/src/test/ui/compile-fail-migration/static-reference-to-fn-1.stderr b/src/test/ui/compile-fail-migration/static-reference-to-fn-1.stderr new file mode 100644 index 00000000000..609319f3b78 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-reference-to-fn-1.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/static-reference-to-fn-1.rs:27:15 + | +LL | func: &foo, //~ ERROR mismatched types + | ^^^^ expected fn pointer, found fn item + | + = note: expected type `&fn() -> std::option::Option` + found type `&fn() -> std::option::Option {foo}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/static-reference-to-fn-2.nll.stderr b/src/test/ui/compile-fail-migration/static-reference-to-fn-2.nll.stderr new file mode 100644 index 00000000000..9ef94189e90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-reference-to-fn-2.nll.stderr @@ -0,0 +1,68 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:28:22 + | +LL | self_.statefn = &id(state2 as StateMachineFunc); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 27:1... + --> $DIR/static-reference-to-fn-2.rs:27:1 + | +LL | / fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { +LL | | self_.statefn = &id(state2 as StateMachineFunc); +LL | | //~^ ERROR borrowed value does not live long enough +LL | | return Some("state1"); +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:34:22 + | +LL | self_.statefn = &id(state3 as StateMachineFunc); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 33:1... + --> $DIR/static-reference-to-fn-2.rs:33:1 + | +LL | / fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { +LL | | self_.statefn = &id(state3 as StateMachineFunc); +LL | | //~^ ERROR borrowed value does not live long enough +LL | | return Some("state2"); +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:40:22 + | +LL | self_.statefn = &id(finished as StateMachineFunc); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 39:1... + --> $DIR/static-reference-to-fn-2.rs:39:1 + | +LL | / fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { +LL | | self_.statefn = &id(finished as StateMachineFunc); +LL | | //~^ ERROR borrowed value does not live long enough +LL | | return Some("state3"); +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:51:19 + | +LL | statefn: &id(state1 as StateMachineFunc) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/static-reference-to-fn-2.rs b/src/test/ui/compile-fail-migration/static-reference-to-fn-2.rs new file mode 100644 index 00000000000..8d9f442b81d --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-reference-to-fn-2.rs @@ -0,0 +1,64 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn id(x: T) -> T { x } + +struct StateMachineIter<'a> { + statefn: &'a StateMachineFunc<'a> +} + +type StateMachineFunc<'a> = fn(&mut StateMachineIter<'a>) -> Option<&'static str>; + +impl<'a> Iterator for StateMachineIter<'a> { + type Item = &'static str; + + fn next(&mut self) -> Option<&'static str> { + return (*self.statefn)(self); + } +} + +fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { + self_.statefn = &id(state2 as StateMachineFunc); + //~^ ERROR borrowed value does not live long enough + return Some("state1"); +} + +fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { + self_.statefn = &id(state3 as StateMachineFunc); + //~^ ERROR borrowed value does not live long enough + return Some("state2"); +} + +fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { + self_.statefn = &id(finished as StateMachineFunc); + //~^ ERROR borrowed value does not live long enough + return Some("state3"); +} + +fn finished(_: &mut StateMachineIter) -> Option<(&'static str)> { + return None; +} + +fn state_iter() -> StateMachineIter<'static> { + StateMachineIter { + statefn: &id(state1 as StateMachineFunc) + //~^ ERROR borrowed value does not live long enough + } +} + + +fn main() { + let mut it = state_iter(); + println!("{:?}",it.next()); + println!("{:?}",it.next()); + println!("{:?}",it.next()); + println!("{:?}",it.next()); + println!("{:?}",it.next()); +} diff --git a/src/test/ui/compile-fail-migration/static-reference-to-fn-2.stderr b/src/test/ui/compile-fail-migration/static-reference-to-fn-2.stderr new file mode 100644 index 00000000000..a01ab4cef81 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-reference-to-fn-2.stderr @@ -0,0 +1,71 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:28:22 + | +LL | self_.statefn = &id(state2 as StateMachineFunc); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 27:1... + --> $DIR/static-reference-to-fn-2.rs:27:1 + | +LL | / fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { +LL | | self_.statefn = &id(state2 as StateMachineFunc); +LL | | //~^ ERROR borrowed value does not live long enough +LL | | return Some("state1"); +LL | | } + | |_^ + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:34:22 + | +LL | self_.statefn = &id(state3 as StateMachineFunc); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 33:1... + --> $DIR/static-reference-to-fn-2.rs:33:1 + | +LL | / fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { +LL | | self_.statefn = &id(state3 as StateMachineFunc); +LL | | //~^ ERROR borrowed value does not live long enough +LL | | return Some("state2"); +LL | | } + | |_^ + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:40:22 + | +LL | self_.statefn = &id(finished as StateMachineFunc); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here + | | + | temporary value does not live long enough + | +note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 39:1... + --> $DIR/static-reference-to-fn-2.rs:39:1 + | +LL | / fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { +LL | | self_.statefn = &id(finished as StateMachineFunc); +LL | | //~^ ERROR borrowed value does not live long enough +LL | | return Some("state3"); +LL | | } + | |_^ + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/static-reference-to-fn-2.rs:51:19 + | +LL | statefn: &id(state1 as StateMachineFunc) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/static-region-bound.rs b/src/test/ui/compile-fail-migration/static-region-bound.rs new file mode 100644 index 00000000000..90ed401659c --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-region-bound.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn id(x: T) -> T { x } + +fn f(_: T) {} + +fn main() { + let x: Box<_> = box 3; + f(x); + let x = &id(3); //~ ERROR borrowed value does not live long enough + f(x); +} diff --git a/src/test/ui/compile-fail-migration/static-region-bound.stderr b/src/test/ui/compile-fail-migration/static-region-bound.stderr new file mode 100644 index 00000000000..ee3398b96d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-region-bound.stderr @@ -0,0 +1,14 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/static-region-bound.rs:20:14 + | +LL | let x = &id(3); //~ ERROR borrowed value does not live long enough + | ^^^^^ temporary value does not live long enough +LL | f(x); +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.rs b/src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.rs new file mode 100644 index 00000000000..a533a5bd54d --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.rs @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() -> isize { 23 } + +static a: [isize; 2] = [foo(); 2]; +//~^ ERROR: E0015 + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.stderr b/src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.stderr new file mode 100644 index 00000000000..27d1b41ed0b --- /dev/null +++ b/src/test/ui/compile-fail-migration/static-vec-repeat-not-constant.stderr @@ -0,0 +1,9 @@ +error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants + --> $DIR/static-vec-repeat-not-constant.rs:13:25 + | +LL | static a: [isize; 2] = [foo(); 2]; + | ^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/compile-fail-migration/staticness-mismatch.rs b/src/test/ui/compile-fail-migration/staticness-mismatch.rs new file mode 100644 index 00000000000..2dfc9b79ee2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/staticness-mismatch.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait foo { + fn dummy(&self) { } + fn bar(); +} + +impl foo for isize { + fn bar(&self) {} + //~^ ERROR method `bar` has a `&self` declaration in the impl, but not in the trait +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/staticness-mismatch.stderr b/src/test/ui/compile-fail-migration/staticness-mismatch.stderr new file mode 100644 index 00000000000..31c06ae8a88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/staticness-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0185]: method `bar` has a `&self` declaration in the impl, but not in the trait + --> $DIR/staticness-mismatch.rs:17:5 + | +LL | fn bar(); + | --------- trait method declared without `&self` +... +LL | fn bar(&self) {} + | ^^^^^^^^^^^^^ `&self` used in impl + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0185`. diff --git a/src/test/ui/compile-fail-migration/std-uncopyable-atomics.rs b/src/test/ui/compile-fail-migration/std-uncopyable-atomics.rs new file mode 100644 index 00000000000..35877db610e --- /dev/null +++ b/src/test/ui/compile-fail-migration/std-uncopyable-atomics.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #8380 + + +use std::sync::atomic::*; +use std::ptr; + +fn main() { + let x = AtomicBool::new(false); + let x = *&x; //~ ERROR: cannot move out of borrowed content + let x = AtomicIsize::new(0); + let x = *&x; //~ ERROR: cannot move out of borrowed content + let x = AtomicUsize::new(0); + let x = *&x; //~ ERROR: cannot move out of borrowed content + let x: AtomicPtr = AtomicPtr::new(ptr::null_mut()); + let x = *&x; //~ ERROR: cannot move out of borrowed content +} diff --git a/src/test/ui/compile-fail-migration/std-uncopyable-atomics.stderr b/src/test/ui/compile-fail-migration/std-uncopyable-atomics.stderr new file mode 100644 index 00000000000..4452bfa95d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/std-uncopyable-atomics.stderr @@ -0,0 +1,39 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/std-uncopyable-atomics.rs:19:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&*&x` + +error[E0507]: cannot move out of borrowed content + --> $DIR/std-uncopyable-atomics.rs:21:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&*&x` + +error[E0507]: cannot move out of borrowed content + --> $DIR/std-uncopyable-atomics.rs:23:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&*&x` + +error[E0507]: cannot move out of borrowed content + --> $DIR/std-uncopyable-atomics.rs:25:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&*&x` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.rs b/src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.rs new file mode 100644 index 00000000000..896817bb858 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.rs @@ -0,0 +1,150 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(custom_attribute)] + +macro_rules! stmt_mac { + () => { + fn b() {} + } +} + +fn main() { + #[attr] + fn a() {} + + #[attr] //~ ERROR attributes on expressions are experimental + { + + } + + #[attr] + 5; + + #[attr] + stmt_mac!(); +} + +// Check that cfg works right + +#[cfg(unset)] +fn c() { + #[attr] + 5; +} + +#[cfg(not(unset))] +fn j() { + #[attr] + 5; +} + +#[cfg_attr(not(unset), cfg(unset))] +fn d() { + #[attr] + 8; +} + +#[cfg_attr(not(unset), cfg(not(unset)))] +fn i() { + #[attr] + 8; +} + +// check that macro expansion and cfg works right + +macro_rules! item_mac { + ($e:ident) => { + fn $e() { + #[attr] + 42; + + #[cfg(unset)] + fn f() { + #[attr] + 5; + } + + #[cfg(not(unset))] + fn k() { + #[attr] + 5; + } + + #[cfg_attr(not(unset), cfg(unset))] + fn g() { + #[attr] + 8; + } + + #[cfg_attr(not(unset), cfg(not(unset)))] + fn h() { + #[attr] + 8; + } + + } + } +} + +item_mac!(e); + +// check that the gate visitor works right: + +extern { + #[cfg(unset)] + fn x(a: [u8; #[attr] 5]); + fn y(a: [u8; #[attr] 5]); //~ ERROR 15701 +} + +struct Foo; +impl Foo { + #[cfg(unset)] + const X: u8 = #[attr] 5; + const Y: u8 = #[attr] 5; //~ ERROR 15701 +} + +trait Bar { + #[cfg(unset)] + const X: [u8; #[attr] 5]; + const Y: [u8; #[attr] 5]; //~ ERROR 15701 +} + +struct Joyce { + #[cfg(unset)] + field: [u8; #[attr] 5], + field2: [u8; #[attr] 5] //~ ERROR 15701 +} + +struct Walky( + #[cfg(unset)] [u8; #[attr] 5], + [u8; #[attr] 5] //~ ERROR 15701 +); + +enum Mike { + Happy( + #[cfg(unset)] [u8; #[attr] 5], + [u8; #[attr] 5] //~ ERROR 15701 + ), + Angry { + #[cfg(unset)] + field: [u8; #[attr] 5], + field2: [u8; #[attr] 5] //~ ERROR 15701 + } +} + +fn pat() { + match 5 { + #[cfg(unset)] + 5 => #[attr] (), + 6 => #[attr] (), //~ ERROR 15701 + _ => (), + } +} diff --git a/src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.stderr b/src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.stderr new file mode 100644 index 00000000000..1168c5a8223 --- /dev/null +++ b/src/test/ui/compile-fail-migration/stmt_expr_attrs_no_feature.stderr @@ -0,0 +1,67 @@ +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:104:18 + | +LL | fn y(a: [u8; #[attr] 5]); //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:111:19 + | +LL | const Y: u8 = #[attr] 5; //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:117:19 + | +LL | const Y: [u8; #[attr] 5]; //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:123:18 + | +LL | field2: [u8; #[attr] 5] //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:128:10 + | +LL | [u8; #[attr] 5] //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:134:14 + | +LL | [u8; #[attr] 5] //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:139:22 + | +LL | field2: [u8; #[attr] 5] //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error[E0658]: attributes on expressions are experimental. (see issue #15701) + --> $DIR/stmt_expr_attrs_no_feature.rs:147:14 + | +LL | 6 => #[attr] (), //~ ERROR 15701 + | ^^^^^^^ + | + = help: add #![feature(stmt_expr_attributes)] to the crate attributes to enable + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/str-idx.rs b/src/test/ui/compile-fail-migration/str-idx.rs new file mode 100644 index 00000000000..b5f1ffb977e --- /dev/null +++ b/src/test/ui/compile-fail-migration/str-idx.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + let s: &str = "hello"; + let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` +} diff --git a/src/test/ui/compile-fail-migration/str-idx.stderr b/src/test/ui/compile-fail-migration/str-idx.stderr new file mode 100644 index 00000000000..496187c92f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/str-idx.stderr @@ -0,0 +1,11 @@ +error[E0277]: the type `str` cannot be indexed by `{integer}` + --> $DIR/str-idx.rs:13:17 + | +LL | let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` + | ^^^^ `str` cannot be indexed by `{integer}` + | + = help: the trait `std::ops::Index<{integer}>` 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/compile-fail-migration/str-mut-idx.rs b/src/test/ui/compile-fail-migration/str-mut-idx.rs new file mode 100644 index 00000000000..136bfaefa71 --- /dev/null +++ b/src/test/ui/compile-fail-migration/str-mut-idx.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn bot() -> T { loop {} } + +fn mutate(s: &mut str) { + s[1..2] = bot(); + //~^ ERROR the size for values of type + //~| ERROR the size for values of type + s[1usize] = bot(); + //~^ ERROR the type `str` cannot be mutably indexed by `usize` +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/str-mut-idx.stderr b/src/test/ui/compile-fail-migration/str-mut-idx.stderr new file mode 100644 index 00000000000..a80c7e57431 --- /dev/null +++ b/src/test/ui/compile-fail-migration/str-mut-idx.stderr @@ -0,0 +1,35 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/str-mut-idx.rs:14:15 + | +LL | s[1..2] = bot(); + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit +note: required by `bot` + --> $DIR/str-mut-idx.rs:11:1 + | +LL | fn bot() -> T { loop {} } + | ^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/str-mut-idx.rs:14:5 + | +LL | s[1..2] = bot(); + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit + = note: the left-hand-side of an assignment must have a statically known size + +error[E0277]: the type `str` cannot be mutably indexed by `usize` + --> $DIR/str-mut-idx.rs:17:5 + | +LL | s[1usize] = bot(); + | ^^^^^^^^^ `str` cannot be mutably indexed by `usize` + | + = help: the trait `std::ops::IndexMut` is not implemented for `str` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/struct-base-wrong-type-2.rs b/src/test/ui/compile-fail-migration/struct-base-wrong-type-2.rs new file mode 100644 index 00000000000..7e5510edb2c --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-base-wrong-type-2.rs @@ -0,0 +1,29 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that `base` in `Fru { field: expr, ..base }` must have right type. +// +// See also struct-base-wrong-type.rs, which tests same condition +// within a const expression. + +struct Foo { a: isize, b: isize } +struct Bar { x: isize } + +fn main() { + let b = Bar { x: 5 }; + let f = Foo { a: 2, ..b }; //~ ERROR mismatched types + //~| expected type `Foo` + //~| found type `Bar` + //~| expected struct `Foo`, found struct `Bar` + let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types + //~| expected type `Foo` + //~| found type `{integer}` + //~| expected struct `Foo`, found integral variable +} diff --git a/src/test/ui/compile-fail-migration/struct-base-wrong-type-2.stderr b/src/test/ui/compile-fail-migration/struct-base-wrong-type-2.stderr new file mode 100644 index 00000000000..aab5ed0a74a --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-base-wrong-type-2.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/struct-base-wrong-type-2.rs:21:27 + | +LL | let f = Foo { a: 2, ..b }; //~ ERROR mismatched types + | ^ expected struct `Foo`, found struct `Bar` + | + = note: expected type `Foo` + found type `Bar` + +error[E0308]: mismatched types + --> $DIR/struct-base-wrong-type-2.rs:25:34 + | +LL | let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types + | ^ expected struct `Foo`, found integral variable + | + = note: expected type `Foo` + found type `{integer}` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/struct-base-wrong-type.rs b/src/test/ui/compile-fail-migration/struct-base-wrong-type.rs new file mode 100644 index 00000000000..3703b15d4db --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-base-wrong-type.rs @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that `base` in `Fru { field: expr, ..base }` must have right type. +// +// See also struct-base-wrong-type-2.rs, which tests same condition +// within a function body. + +struct Foo { a: isize, b: isize } +struct Bar { x: isize } + +static bar: Bar = Bar { x: 5 }; +static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types + //~| expected type `Foo` + //~| found type `Bar` + //~| expected struct `Foo`, found struct `Bar` +static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types + //~| expected type `Foo` + //~| found type `{integer}` + //~| expected struct `Foo`, found integral variable + +fn main() { + let b = Bar { x: 5 }; + // errors below are no longer caught since error above causes + // compilation to abort before we bother checking function bodies. + // See also struct-base-wrong-type-2.rs, which checks that we + // would catch these errors eventually. + let f = Foo { a: 2, ..b }; + let f__isize = Foo { a: 2, ..4 }; +} diff --git a/src/test/ui/compile-fail-migration/struct-base-wrong-type.stderr b/src/test/ui/compile-fail-migration/struct-base-wrong-type.stderr new file mode 100644 index 00000000000..2c87f52ee04 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-base-wrong-type.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/struct-base-wrong-type.rs:20:33 + | +LL | static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types + | ^^^ expected struct `Foo`, found struct `Bar` + | + = note: expected type `Foo` + found type `Bar` + +error[E0308]: mismatched types + --> $DIR/struct-base-wrong-type.rs:24:35 + | +LL | static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types + | ^ expected struct `Foo`, found integral variable + | + = note: expected type `Foo` + found type `{integer}` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/struct-field-cfg.rs b/src/test/ui/compile-fail-migration/struct-field-cfg.rs new file mode 100644 index 00000000000..974d500d9cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-field-cfg.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + present: (), +} + +fn main() { + let foo = Foo { #[cfg(all())] present: () }; + let _ = Foo { #[cfg(any())] present: () }; + //~^ ERROR missing field `present` in initializer of `Foo` + let _ = Foo { present: (), #[cfg(any())] absent: () }; + let _ = Foo { present: (), #[cfg(all())] absent: () }; + //~^ ERROR struct `Foo` has no field named `absent` + let Foo { #[cfg(all())] present: () } = foo; + let Foo { #[cfg(any())] present: () } = foo; + //~^ ERROR pattern does not mention field `present` + let Foo { present: (), #[cfg(any())] absent: () } = foo; + let Foo { present: (), #[cfg(all())] absent: () } = foo; + //~^ ERROR struct `Foo` does not have a field named `absent` +} diff --git a/src/test/ui/compile-fail-migration/struct-field-cfg.stderr b/src/test/ui/compile-fail-migration/struct-field-cfg.stderr new file mode 100644 index 00000000000..db4790659c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-field-cfg.stderr @@ -0,0 +1,30 @@ +error[E0063]: missing field `present` in initializer of `Foo` + --> $DIR/struct-field-cfg.rs:17:13 + | +LL | let _ = Foo { #[cfg(any())] present: () }; + | ^^^ missing `present` + +error[E0560]: struct `Foo` has no field named `absent` + --> $DIR/struct-field-cfg.rs:20:46 + | +LL | let _ = Foo { present: (), #[cfg(all())] absent: () }; + | ^^^^^^ `Foo` does not have this field + | + = note: available fields are: `present` + +error[E0027]: pattern does not mention field `present` + --> $DIR/struct-field-cfg.rs:23:9 + | +LL | let Foo { #[cfg(any())] present: () } = foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `present` + +error[E0026]: struct `Foo` does not have a field named `absent` + --> $DIR/struct-field-cfg.rs:26:42 + | +LL | let Foo { present: (), #[cfg(all())] absent: () } = foo; + | ^^^^^^^^^^ struct `Foo` does not have this field + +error: aborting due to 4 previous errors + +Some errors occurred: E0026, E0027, E0063, E0560. +For more information about an error, try `rustc --explain E0026`. diff --git a/src/test/ui/compile-fail-migration/struct-field-privacy.rs b/src/test/ui/compile-fail-migration/struct-field-privacy.rs new file mode 100644 index 00000000000..f487ef62aa4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-field-privacy.rs @@ -0,0 +1,48 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:struct_field_privacy.rs + +extern crate struct_field_privacy as xc; + +struct A { + a: isize, +} + +mod inner { + pub struct A { + a: isize, + pub b: isize, + } + pub struct B { + pub a: isize, + b: isize, + } + pub struct Z(pub isize, isize); +} + +fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B, z: inner::Z) { + a.a; + b.a; //~ ERROR: field `a` of struct `inner::A` is private + b.b; + c.a; + c.b; //~ ERROR: field `b` of struct `inner::B` is private + + d.a; //~ ERROR: field `a` of struct `xc::A` is private + d.b; + + e.a; + e.b; //~ ERROR: field `b` of struct `xc::B` is private + + z.0; + z.1; //~ ERROR: field `1` of struct `inner::Z` is private +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/struct-field-privacy.stderr b/src/test/ui/compile-fail-migration/struct-field-privacy.stderr new file mode 100644 index 00000000000..ad3ee12637a --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-field-privacy.stderr @@ -0,0 +1,33 @@ +error[E0616]: field `a` of struct `inner::A` is private + --> $DIR/struct-field-privacy.rs:33:5 + | +LL | b.a; //~ ERROR: field `a` of struct `inner::A` is private + | ^^^ + +error[E0616]: field `b` of struct `inner::B` is private + --> $DIR/struct-field-privacy.rs:36:5 + | +LL | c.b; //~ ERROR: field `b` of struct `inner::B` is private + | ^^^ + +error[E0616]: field `a` of struct `xc::A` is private + --> $DIR/struct-field-privacy.rs:38:5 + | +LL | d.a; //~ ERROR: field `a` of struct `xc::A` is private + | ^^^ + +error[E0616]: field `b` of struct `xc::B` is private + --> $DIR/struct-field-privacy.rs:42:5 + | +LL | e.b; //~ ERROR: field `b` of struct `xc::B` is private + | ^^^ + +error[E0616]: field `1` of struct `inner::Z` is private + --> $DIR/struct-field-privacy.rs:45:5 + | +LL | z.1; //~ ERROR: field `1` of struct `inner::Z` is private + | ^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0616`. diff --git a/src/test/ui/compile-fail-migration/struct-fields-dupe.rs b/src/test/ui/compile-fail-migration/struct-fields-dupe.rs new file mode 100644 index 00000000000..578091f5e9a --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-dupe.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct BuildData { + foo: isize, +} + +fn main() { + let foo = BuildData { + foo: 0, + foo: 0 //~ ERROR field `foo` specified more than once + }; +} diff --git a/src/test/ui/compile-fail-migration/struct-fields-dupe.stderr b/src/test/ui/compile-fail-migration/struct-fields-dupe.stderr new file mode 100644 index 00000000000..fa2079317e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-dupe.stderr @@ -0,0 +1,11 @@ +error[E0062]: field `foo` specified more than once + --> $DIR/struct-fields-dupe.rs:18:9 + | +LL | foo: 0, + | ------ first use of `foo` +LL | foo: 0 //~ ERROR field `foo` specified more than once + | ^^^ used more than once + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0062`. diff --git a/src/test/ui/compile-fail-migration/struct-fields-missing.rs b/src/test/ui/compile-fail-migration/struct-fields-missing.rs new file mode 100644 index 00000000000..d5ab13affaf --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-missing.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct BuildData { + foo: isize, + bar: Box, +} + +fn main() { + let foo = BuildData { //~ ERROR missing field `bar` in initializer of `BuildData` + foo: 0 + }; +} diff --git a/src/test/ui/compile-fail-migration/struct-fields-missing.stderr b/src/test/ui/compile-fail-migration/struct-fields-missing.stderr new file mode 100644 index 00000000000..606288ef277 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-missing.stderr @@ -0,0 +1,9 @@ +error[E0063]: missing field `bar` in initializer of `BuildData` + --> $DIR/struct-fields-missing.rs:18:15 + | +LL | let foo = BuildData { //~ ERROR missing field `bar` in initializer of `BuildData` + | ^^^^^^^^^ missing `bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0063`. diff --git a/src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.rs b/src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.rs new file mode 100644 index 00000000000..984f337fb3d --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + x: i32, + y: i32 +} + +fn main() { + let x = 0; + let foo = Foo { + x, + y //~ ERROR cannot find value `y` in this scope + }; +} diff --git a/src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.stderr b/src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.stderr new file mode 100644 index 00000000000..f66ac96e0b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-shorthand-unresolved.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `y` in this scope + --> $DIR/struct-fields-shorthand-unresolved.rs:20:9 + | +LL | y //~ ERROR cannot find value `y` in this scope + | ^ did you mean `x`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/struct-fields-shorthand.rs b/src/test/ui/compile-fail-migration/struct-fields-shorthand.rs new file mode 100644 index 00000000000..e46ae73f1a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-shorthand.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + x: i32, + y: i32 +} + +fn main() { + let (x, y, z) = (0, 1, 2); + let foo = Foo { + x, y, z //~ ERROR struct `Foo` has no field named `z` + }; +} + diff --git a/src/test/ui/compile-fail-migration/struct-fields-shorthand.stderr b/src/test/ui/compile-fail-migration/struct-fields-shorthand.stderr new file mode 100644 index 00000000000..a65a9c86581 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-shorthand.stderr @@ -0,0 +1,11 @@ +error[E0560]: struct `Foo` has no field named `z` + --> $DIR/struct-fields-shorthand.rs:19:15 + | +LL | x, y, z //~ ERROR struct `Foo` has no field named `z` + | ^ `Foo` does not have this field + | + = note: available fields are: `x`, `y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0560`. diff --git a/src/test/ui/compile-fail-migration/struct-fields-typo.rs b/src/test/ui/compile-fail-migration/struct-fields-typo.rs new file mode 100644 index 00000000000..0e30c1e86e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-typo.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct BuildData { + foo: isize, + bar: f32 +} + +fn main() { + let foo = BuildData { + foo: 0, + bar: 0.5, + }; + let x = foo.baa;//~ no field `baa` on type `BuildData` + //~^ did you mean `bar`? + println!("{}", x); +} diff --git a/src/test/ui/compile-fail-migration/struct-fields-typo.stderr b/src/test/ui/compile-fail-migration/struct-fields-typo.stderr new file mode 100644 index 00000000000..9f2f97a6c09 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-fields-typo.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `baa` on type `BuildData` + --> $DIR/struct-fields-typo.rs:21:17 + | +LL | let x = foo.baa;//~ no field `baa` on type `BuildData` + | ^^^ did you mean `bar`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.rs b/src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.rs new file mode 100644 index 00000000000..a14e43f4c94 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum A { + B { x: Option }, + C +} + +fn main() { + let x = A::B { x: Some(3) }; + match x { //~ ERROR non-exhaustive patterns + A::C => {} + A::B { x: None } => {} + } +} diff --git a/src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.stderr b/src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.stderr new file mode 100644 index 00000000000..56dbf0c93ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-like-enum-nonexhaustive.stderr @@ -0,0 +1,9 @@ +error[E0004]: non-exhaustive patterns: `B { x: Some(_) }` not covered + --> $DIR/struct-like-enum-nonexhaustive.rs:18:11 + | +LL | match x { //~ ERROR non-exhaustive patterns + | ^ pattern `B { x: Some(_) }` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/struct-pat-derived-error.rs b/src/test/ui/compile-fail-migration/struct-pat-derived-error.rs new file mode 100644 index 00000000000..d3130c4e831 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-pat-derived-error.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct a { + b: usize, + c: usize +} + +impl a { + fn foo(&self) { + let a { x, y } = self.d; //~ ERROR no field `d` on type `&a` + //~^ ERROR struct `a` does not have fields named `x`, `y` + //~| ERROR pattern does not mention fields `b`, `c` + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/struct-pat-derived-error.stderr b/src/test/ui/compile-fail-migration/struct-pat-derived-error.stderr new file mode 100644 index 00000000000..68b71efc106 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-pat-derived-error.stderr @@ -0,0 +1,22 @@ +error[E0609]: no field `d` on type `&a` + --> $DIR/struct-pat-derived-error.rs:18:31 + | +LL | let a { x, y } = self.d; //~ ERROR no field `d` on type `&a` + | ^ + +error[E0026]: struct `a` does not have fields named `x`, `y` + --> $DIR/struct-pat-derived-error.rs:18:17 + | +LL | let a { x, y } = self.d; //~ ERROR no field `d` on type `&a` + | ^ ^ struct `a` does not have these fields + +error[E0027]: pattern does not mention fields `b`, `c` + --> $DIR/struct-pat-derived-error.rs:18:13 + | +LL | let a { x, y } = self.d; //~ ERROR no field `d` on type `&a` + | ^^^^^^^^^^ missing fields `b`, `c` + +error: aborting due to 3 previous errors + +Some errors occurred: E0026, E0027, E0609. +For more information about an error, try `rustc --explain E0026`. diff --git a/src/test/ui/compile-fail-migration/struct-path-alias-bounds.rs b/src/test/ui/compile-fail-migration/struct-path-alias-bounds.rs new file mode 100644 index 00000000000..1b6e51e3703 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-path-alias-bounds.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// issue #36286 + +struct S { a: T } + +struct NoClone; +type A = S; + +fn main() { + let s = A { a: NoClone }; + //~^ ERROR the trait bound `NoClone: std::clone::Clone` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/struct-path-alias-bounds.stderr b/src/test/ui/compile-fail-migration/struct-path-alias-bounds.stderr new file mode 100644 index 00000000000..f8e2fe1410f --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-path-alias-bounds.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `NoClone: std::clone::Clone` is not satisfied + --> $DIR/struct-path-alias-bounds.rs:19:13 + | +LL | let s = A { a: NoClone }; + | ^ the trait `std::clone::Clone` is not implemented for `NoClone` + | +note: required by `S` + --> $DIR/struct-path-alias-bounds.rs:13:1 + | +LL | struct S { a: T } + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/struct-path-associated-type.rs b/src/test/ui/compile-fail-migration/struct-path-associated-type.rs new file mode 100644 index 00000000000..660ac44ce0b --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-path-associated-type.rs @@ -0,0 +1,48 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S; + +trait Tr { + type A; +} + +impl Tr for S { + type A = S; +} + +fn f() { + let s = T::A {}; + //~^ ERROR expected struct, variant or union type, found associated type + let z = T::A:: {}; + //~^ ERROR expected struct, variant or union type, found associated type + //~| ERROR type parameters are not allowed on this type + match S { + T::A {} => {} + //~^ ERROR expected struct, variant or union type, found associated type + } +} + +fn g>() { + let s = T::A {}; // OK + let z = T::A:: {}; //~ ERROR type parameters are not allowed on this type + match S { + T::A {} => {} // OK + } +} + +fn main() { + let s = S::A {}; //~ ERROR ambiguous associated type + let z = S::A:: {}; //~ ERROR ambiguous associated type + //~^ ERROR type parameters are not allowed on this type + match S { + S::A {} => {} //~ ERROR ambiguous associated type + } +} diff --git a/src/test/ui/compile-fail-migration/struct-path-associated-type.stderr b/src/test/ui/compile-fail-migration/struct-path-associated-type.stderr new file mode 100644 index 00000000000..1364b2a6b0c --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-path-associated-type.stderr @@ -0,0 +1,64 @@ +error[E0071]: expected struct, variant or union type, found associated type + --> $DIR/struct-path-associated-type.rs:22:13 + | +LL | let s = T::A {}; + | ^^^^ not a struct + +error[E0109]: type parameters are not allowed on this type + --> $DIR/struct-path-associated-type.rs:24:20 + | +LL | let z = T::A:: {}; + | ^^ type parameter not allowed + +error[E0071]: expected struct, variant or union type, found associated type + --> $DIR/struct-path-associated-type.rs:24:13 + | +LL | let z = T::A:: {}; + | ^^^^^^^^^^ not a struct + +error[E0071]: expected struct, variant or union type, found associated type + --> $DIR/struct-path-associated-type.rs:28:9 + | +LL | T::A {} => {} + | ^^^^ not a struct + +error[E0109]: type parameters are not allowed on this type + --> $DIR/struct-path-associated-type.rs:35:20 + | +LL | let z = T::A:: {}; //~ ERROR type parameters are not allowed on this type + | ^^ type parameter not allowed + +error[E0223]: ambiguous associated type + --> $DIR/struct-path-associated-type.rs:42:13 + | +LL | let s = S::A {}; //~ ERROR ambiguous associated type + | ^^^^ ambiguous associated type + | + = note: specify the type using the syntax `::A` + +error[E0109]: type parameters are not allowed on this type + --> $DIR/struct-path-associated-type.rs:43:20 + | +LL | let z = S::A:: {}; //~ ERROR ambiguous associated type + | ^^ type parameter not allowed + +error[E0223]: ambiguous associated type + --> $DIR/struct-path-associated-type.rs:43:13 + | +LL | let z = S::A:: {}; //~ ERROR ambiguous associated type + | ^^^^^^^^^^ ambiguous associated type + | + = note: specify the type using the syntax `::A` + +error[E0223]: ambiguous associated type + --> $DIR/struct-path-associated-type.rs:46:9 + | +LL | S::A {} => {} //~ ERROR ambiguous associated type + | ^^^^ ambiguous associated type + | + = note: specify the type using the syntax `::A` + +error: aborting due to 9 previous errors + +Some errors occurred: E0071, E0109, E0223. +For more information about an error, try `rustc --explain E0071`. diff --git a/src/test/ui/compile-fail-migration/struct-path-self.rs b/src/test/ui/compile-fail-migration/struct-path-self.rs new file mode 100644 index 00000000000..067d6ac22dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-path-self.rs @@ -0,0 +1,47 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S; + +trait Tr { + fn f() { + let s = Self {}; + //~^ ERROR expected struct, variant or union type, found Self + let z = Self:: {}; + //~^ ERROR expected struct, variant or union type, found Self + //~| ERROR type parameters are not allowed on this type + match s { + Self { .. } => {} + //~^ ERROR expected struct, variant or union type, found Self + } + } +} + +impl Tr for S { + fn f() { + let s = Self {}; // OK + let z = Self:: {}; //~ ERROR type parameters are not allowed on this type + match s { + Self { .. } => {} // OK + } + } +} + +impl S { + fn g() { + let s = Self {}; // OK + let z = Self:: {}; //~ ERROR type parameters are not allowed on this type + match s { + Self { .. } => {} // OK + } + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/struct-path-self.stderr b/src/test/ui/compile-fail-migration/struct-path-self.stderr new file mode 100644 index 00000000000..1b5506072e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-path-self.stderr @@ -0,0 +1,40 @@ +error[E0071]: expected struct, variant or union type, found Self + --> $DIR/struct-path-self.rs:15:17 + | +LL | let s = Self {}; + | ^^^^ not a struct + +error[E0109]: type parameters are not allowed on this type + --> $DIR/struct-path-self.rs:17:24 + | +LL | let z = Self:: {}; + | ^^ type parameter not allowed + +error[E0071]: expected struct, variant or union type, found Self + --> $DIR/struct-path-self.rs:17:17 + | +LL | let z = Self:: {}; + | ^^^^^^^^^^ not a struct + +error[E0071]: expected struct, variant or union type, found Self + --> $DIR/struct-path-self.rs:21:13 + | +LL | Self { .. } => {} + | ^^^^ not a struct + +error[E0109]: type parameters are not allowed on this type + --> $DIR/struct-path-self.rs:30:24 + | +LL | let z = Self:: {}; //~ ERROR type parameters are not allowed on this type + | ^^ type parameter not allowed + +error[E0109]: type parameters are not allowed on this type + --> $DIR/struct-path-self.rs:40:24 + | +LL | let z = Self:: {}; //~ ERROR type parameters are not allowed on this type + | ^^ type parameter not allowed + +error: aborting due to 6 previous errors + +Some errors occurred: E0071, E0109. +For more information about an error, try `rustc --explain E0071`. diff --git a/src/test/ui/compile-fail-migration/struct-pattern-match-useless.rs b/src/test/ui/compile-fail-migration/struct-pattern-match-useless.rs new file mode 100644 index 00000000000..dda30141b4a --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-pattern-match-useless.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unreachable_patterns)] + +struct Foo { + x: isize, + y: isize, +} + +pub fn main() { + let a = Foo { x: 1, y: 2 }; + match a { + Foo { x: _x, y: _y } => (), + Foo { .. } => () //~ ERROR unreachable pattern + } + +} diff --git a/src/test/ui/compile-fail-migration/struct-pattern-match-useless.stderr b/src/test/ui/compile-fail-migration/struct-pattern-match-useless.stderr new file mode 100644 index 00000000000..60f17d1d906 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-pattern-match-useless.stderr @@ -0,0 +1,14 @@ +error: unreachable pattern + --> $DIR/struct-pattern-match-useless.rs:22:9 + | +LL | Foo { .. } => () //~ ERROR unreachable pattern + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/struct-pattern-match-useless.rs:11:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/struct-variant-privacy-xc.rs b/src/test/ui/compile-fail-migration/struct-variant-privacy-xc.rs new file mode 100644 index 00000000000..8507acd26ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-variant-privacy-xc.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:struct_variant_privacy.rs +extern crate struct_variant_privacy; + +fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private + match b { + struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/struct-variant-privacy-xc.stderr b/src/test/ui/compile-fail-migration/struct-variant-privacy-xc.stderr new file mode 100644 index 00000000000..731d23e6a97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-variant-privacy-xc.stderr @@ -0,0 +1,15 @@ +error[E0603]: enum `Bar` is private + --> $DIR/struct-variant-privacy-xc.rs:14:9 + | +LL | fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: enum `Bar` is private + --> $DIR/struct-variant-privacy-xc.rs:16:9 + | +LL | struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/struct-variant-privacy.rs b/src/test/ui/compile-fail-migration/struct-variant-privacy.rs new file mode 100644 index 00000000000..7de4ca62555 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-variant-privacy.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +mod foo { + enum Bar { + Baz { a: isize } + } +} + +fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private + match b { + foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/struct-variant-privacy.stderr b/src/test/ui/compile-fail-migration/struct-variant-privacy.stderr new file mode 100644 index 00000000000..a82ac8ab318 --- /dev/null +++ b/src/test/ui/compile-fail-migration/struct-variant-privacy.stderr @@ -0,0 +1,15 @@ +error[E0603]: enum `Bar` is private + --> $DIR/struct-variant-privacy.rs:16:9 + | +LL | fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private + | ^^^^^^^^ + +error[E0603]: enum `Bar` is private + --> $DIR/struct-variant-privacy.rs:18:9 + | +LL | foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.rs b/src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.rs new file mode 100644 index 00000000000..87fc5ba93ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.rs @@ -0,0 +1,83 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Point { + x: T, + y: T, +} + +type PointF = Point; + +struct Pair { + x: T, + y: U, +} + +type PairF = Pair; + +fn main() { + let pt = PointF { + x: 1, + //~^ ERROR mismatched types + //~| expected f32, found integral variable + y: 2, + //~^ ERROR mismatched types + //~| expected f32, found integral variable + }; + + let pt2 = Point:: { + x: 3, + //~^ ERROR mismatched types + //~| expected f32, found integral variable + y: 4, + //~^ ERROR mismatched types + //~| expected f32, found integral variable + }; + + let pair = PairF { + x: 5, + //~^ ERROR mismatched types + //~| expected f32, found integral variable + y: 6, + }; + + let pair2 = PairF:: { + x: 7, + //~^ ERROR mismatched types + //~| expected f32, found integral variable + y: 8, + }; + + let pt3 = PointF:: { //~ ERROR wrong number of type arguments + x: 9, //~ ERROR mismatched types + y: 10, //~ ERROR mismatched types + }; + + match (Point { x: 1, y: 2 }) { + PointF:: { .. } => {} //~ ERROR wrong number of type arguments + //~^ ERROR mismatched types + } + + match (Point { x: 1, y: 2 }) { + PointF { .. } => {} //~ ERROR mismatched types + } + + match (Point { x: 1.0, y: 2.0 }) { + PointF { .. } => {} // ok + } + + match (Pair { x: 1, y: 2 }) { + PairF:: { .. } => {} //~ ERROR mismatched types + } + + match (Pair { x: 1.0, y: 2 }) { + PairF:: { .. } => {} // ok + } +} diff --git a/src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.stderr b/src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.stderr new file mode 100644 index 00000000000..85de419bfc0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/structure-constructor-type-mismatch.stderr @@ -0,0 +1,115 @@ +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:27:12 + | +LL | x: 1, + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:30:12 + | +LL | y: 2, + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:36:12 + | +LL | x: 3, + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:39:12 + | +LL | y: 4, + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:45:12 + | +LL | x: 5, + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:52:12 + | +LL | x: 7, + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0244]: wrong number of type arguments: expected 0, found 1 + --> $DIR/structure-constructor-type-mismatch.rs:58:15 + | +LL | let pt3 = PointF:: { //~ ERROR wrong number of type arguments + | ^^^^^^^^^^^^^ expected no type arguments + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:59:12 + | +LL | x: 9, //~ ERROR mismatched types + | ^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:60:12 + | +LL | y: 10, //~ ERROR mismatched types + | ^^ expected f32, found integral variable + | + = note: expected type `f32` + found type `{integer}` + +error[E0244]: wrong number of type arguments: expected 0, found 1 + --> $DIR/structure-constructor-type-mismatch.rs:64:9 + | +LL | PointF:: { .. } => {} //~ ERROR wrong number of type arguments + | ^^^^^^^^^^^^^ expected no type arguments + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:64:9 + | +LL | PointF:: { .. } => {} //~ ERROR wrong number of type arguments + | ^^^^^^^^^^^^^^^^^^^^ expected integral variable, found f32 + | + = note: expected type `Point<{integer}>` + found type `Point` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:69:9 + | +LL | PointF { .. } => {} //~ ERROR mismatched types + | ^^^^^^^^^^^^^ expected integral variable, found f32 + | + = note: expected type `Point<{integer}>` + found type `Point` + +error[E0308]: mismatched types + --> $DIR/structure-constructor-type-mismatch.rs:77:9 + | +LL | PairF:: { .. } => {} //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^ expected integral variable, found f32 + | + = note: expected type `Pair<{integer}, {integer}>` + found type `Pair` + +error: aborting due to 13 previous errors + +Some errors occurred: E0244, E0308. +For more information about an error, try `rustc --explain E0244`. diff --git a/src/test/ui/compile-fail-migration/substs-ppaux.normal.stderr b/src/test/ui/compile-fail-migration/substs-ppaux.normal.stderr new file mode 100644 index 00000000000..3eb15a08eae --- /dev/null +++ b/src/test/ui/compile-fail-migration/substs-ppaux.normal.stderr @@ -0,0 +1,55 @@ +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:25:17 + | +LL | let x: () = >::bar::<'static, char>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {>::bar::<'static, char>}` + +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:34:17 + | +LL | let x: () = >::bar::<'static, char>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {>::bar::<'static, char>}` + +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:42:17 + | +LL | let x: () = >::baz; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {>::baz}` + +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:50:17 + | +LL | let x: () = foo::<'static>; + | ^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {foo::<'static>}` + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/substs-ppaux.rs:58:5 + | +LL | >::bar; + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit + = note: required because of the requirements on the impl of `Foo<'_, '_, u8>` for `str` +note: required by `Foo::bar` + --> $DIR/substs-ppaux.rs:16:5 + | +LL | fn bar<'a, T>() where T: 'a {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/substs-ppaux.rs b/src/test/ui/compile-fail-migration/substs-ppaux.rs new file mode 100644 index 00000000000..d0e9a7f4a40 --- /dev/null +++ b/src/test/ui/compile-fail-migration/substs-ppaux.rs @@ -0,0 +1,61 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// revisions: verbose normal +// +//[verbose] compile-flags: -Z verbose + +trait Foo<'b, 'c, S=u32> { + fn bar<'a, T>() where T: 'a {} + fn baz() {} +} + +impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} + +fn main() {} + +fn foo<'z>() where &'z (): Sized { + let x: () = >::bar::<'static, char>; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected type `()` + //[verbose]~| found type `fn() {>::bar::}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected type `()` + //[normal]~| found type `fn() {>::bar::<'static, char>}` + + + let x: () = >::bar::<'static, char>; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected type `()` + //[verbose]~| found type `fn() {>::bar::}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected type `()` + //[normal]~| found type `fn() {>::bar::<'static, char>}` + + let x: () = >::baz; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected type `()` + //[verbose]~| found type `fn() {>::baz}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected type `()` + //[normal]~| found type `fn() {>::baz}` + + let x: () = foo::<'static>; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected type `()` + //[verbose]~| found type `fn() {foo::}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected type `()` + //[normal]~| found type `fn() {foo::<'static>}` + + >::bar; + //[verbose]~^ ERROR the size for values of type + //[normal]~^^ ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/substs-ppaux.verbose.stderr b/src/test/ui/compile-fail-migration/substs-ppaux.verbose.stderr new file mode 100644 index 00000000000..a417c0d8970 --- /dev/null +++ b/src/test/ui/compile-fail-migration/substs-ppaux.verbose.stderr @@ -0,0 +1,55 @@ +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:25:17 + | +LL | let x: () = >::bar::<'static, char>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {>::bar::}` + +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:34:17 + | +LL | let x: () = >::bar::<'static, char>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {>::bar::}` + +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:42:17 + | +LL | let x: () = >::baz; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {>::baz}` + +error[E0308]: mismatched types + --> $DIR/substs-ppaux.rs:50:17 + | +LL | let x: () = foo::<'static>; + | ^^^^^^^^^^^^^^ expected (), found fn item + | + = note: expected type `()` + found type `fn() {foo::}` + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/substs-ppaux.rs:58:5 + | +LL | >::bar; + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit + = note: required because of the requirements on the impl of `Foo<'_#0r, '_#1r, u8>` for `str` +note: required by `Foo::bar` + --> $DIR/substs-ppaux.rs:16:5 + | +LL | fn bar<'a, T>() where T: 'a {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/suffixed-literal-meta.rs b/src/test/ui/compile-fail-migration/suffixed-literal-meta.rs new file mode 100644 index 00000000000..bf55b7bdcb1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/suffixed-literal-meta.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(attr_literals)] + +#[path = 1usize] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1u8] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1u16] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1u32] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1u64] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1isize] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1i8] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1i16] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1i32] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1i64] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes +#[path = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes +fn main() { } diff --git a/src/test/ui/compile-fail-migration/suffixed-literal-meta.stderr b/src/test/ui/compile-fail-migration/suffixed-literal-meta.stderr new file mode 100644 index 00000000000..6d88ab1df16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/suffixed-literal-meta.stderr @@ -0,0 +1,98 @@ +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:13:10 + | +LL | #[path = 1usize] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:14:10 + | +LL | #[path = 1u8] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:15:10 + | +LL | #[path = 1u16] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:16:10 + | +LL | #[path = 1u32] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:17:10 + | +LL | #[path = 1u64] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:18:10 + | +LL | #[path = 1isize] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:19:10 + | +LL | #[path = 1i8] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:20:10 + | +LL | #[path = 1i16] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:21:10 + | +LL | #[path = 1i32] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:22:10 + | +LL | #[path = 1i64] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:23:10 + | +LL | #[path = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: suffixed literals are not allowed in attributes + --> $DIR/suffixed-literal-meta.rs:24:10 + | +LL | #[path = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes + | ^^^^^^ + | + = help: instead of using a suffixed literal (1u8, 1.0f32, etc.), use an unsuffixed version (1, 1.0, etc.). + +error: aborting due to 12 previous errors + diff --git a/src/test/ui/compile-fail-migration/super-at-top-level.rs b/src/test/ui/compile-fail-migration/super-at-top-level.rs new file mode 100644 index 00000000000..c607711c44f --- /dev/null +++ b/src/test/ui/compile-fail-migration/super-at-top-level.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::f; //~ ERROR There are too many initial `super`s + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/super-at-top-level.stderr b/src/test/ui/compile-fail-migration/super-at-top-level.stderr new file mode 100644 index 00000000000..b4af73055a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/super-at-top-level.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. There are too many initial `super`s. + --> $DIR/super-at-top-level.rs:11:5 + | +LL | use super::f; //~ ERROR There are too many initial `super`s + | ^^^^^ There are too many initial `super`s. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/suppressed-error.rs b/src/test/ui/compile-fail-migration/suppressed-error.rs new file mode 100644 index 00000000000..9a4a52ced20 --- /dev/null +++ b/src/test/ui/compile-fail-migration/suppressed-error.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let (x, y) = (); +//~^ ERROR mismatched types +//~| expected type `()` +//~| found type `(_, _)` +//~| expected (), found tuple + return x; +} diff --git a/src/test/ui/compile-fail-migration/suppressed-error.stderr b/src/test/ui/compile-fail-migration/suppressed-error.stderr new file mode 100644 index 00000000000..d17e7cb6891 --- /dev/null +++ b/src/test/ui/compile-fail-migration/suppressed-error.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/suppressed-error.rs:12:9 + | +LL | let (x, y) = (); + | ^^^^^^ expected (), found tuple + | + = note: expected type `()` + found type `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/symbol-names/basic.rs b/src/test/ui/compile-fail-migration/symbol-names/basic.rs new file mode 100644 index 00000000000..0095774fcb8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/symbol-names/basic.rs @@ -0,0 +1,16 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +#[rustc_symbol_name] //~ ERROR _ZN5basic4main +#[rustc_item_path] //~ ERROR item-path(main) +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/symbol-names/basic.stderr b/src/test/ui/compile-fail-migration/symbol-names/basic.stderr new file mode 100644 index 00000000000..eeeb1b5e34d --- /dev/null +++ b/src/test/ui/compile-fail-migration/symbol-names/basic.stderr @@ -0,0 +1,14 @@ +error: symbol-name(_ZN5basic4main17h2138d548fb9814b6E) + --> $DIR/basic.rs:13:1 + | +LL | #[rustc_symbol_name] //~ ERROR _ZN5basic4main + | ^^^^^^^^^^^^^^^^^^^^ + +error: item-path(main) + --> $DIR/basic.rs:14:1 + | +LL | #[rustc_item_path] //~ ERROR item-path(main) + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/symbol-names/impl1.rs b/src/test/ui/compile-fail-migration/symbol-names/impl1.rs new file mode 100644 index 00000000000..93fa48b880f --- /dev/null +++ b/src/test/ui/compile-fail-migration/symbol-names/impl1.rs @@ -0,0 +1,35 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod foo { + pub struct Foo { x: u32 } + + impl Foo { + #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar + #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar) + fn bar() { } + } +} + +mod bar { + use foo::Foo; + + impl Foo { + #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz + #[rustc_item_path] //~ ERROR item-path(bar::::baz) + fn baz() { } + } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/symbol-names/impl1.stderr b/src/test/ui/compile-fail-migration/symbol-names/impl1.stderr new file mode 100644 index 00000000000..edce6929695 --- /dev/null +++ b/src/test/ui/compile-fail-migration/symbol-names/impl1.stderr @@ -0,0 +1,26 @@ +error: symbol-name(_ZN5impl13foo3Foo3bar17h8da62e6147ff602fE) + --> $DIR/impl1.rs:18:9 + | +LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar + | ^^^^^^^^^^^^^^^^^^^^ + +error: item-path(foo::Foo::bar) + --> $DIR/impl1.rs:19:9 + | +LL | #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar) + | ^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h374cb8f6185db9b4E) + --> $DIR/impl1.rs:28:9 + | +LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz + | ^^^^^^^^^^^^^^^^^^^^ + +error: item-path(bar::::baz) + --> $DIR/impl1.rs:29:9 + | +LL | #[rustc_item_path] //~ ERROR item-path(bar::::baz) + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/syntax-extension-minor.rs b/src/test/ui/compile-fail-migration/syntax-extension-minor.rs new file mode 100644 index 00000000000..96adfea43f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/syntax-extension-minor.rs @@ -0,0 +1,24 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(concat_idents)] + +pub fn main() { + struct Foo; + let _: concat_idents!(F, oo) = Foo; // Test that `concat_idents!` can be used in type positions + + let asdf_fdsa = "<.<".to_string(); + // this now fails (correctly, I claim) because hygiene prevents + // the assembled identifier from being a reference to the binding. + assert!(concat_idents!(asd, f_f, dsa) == "<.<".to_string()); + //~^ ERROR cannot find value `asdf_fdsa` in this scope + + assert_eq!(stringify!(use_mention_distinction), "use_mention_distinction"); +} diff --git a/src/test/ui/compile-fail-migration/syntax-extension-minor.stderr b/src/test/ui/compile-fail-migration/syntax-extension-minor.stderr new file mode 100644 index 00000000000..7df1f303146 --- /dev/null +++ b/src/test/ui/compile-fail-migration/syntax-extension-minor.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `asdf_fdsa` in this scope + --> $DIR/syntax-extension-minor.rs:20:13 + | +LL | assert!(concat_idents!(asd, f_f, dsa) == "<.<".to_string()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.rs b/src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.rs new file mode 100644 index 00000000000..8d5e89cc66f --- /dev/null +++ b/src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker::Send; + +struct TestType; + +trait TestTrait {} + +impl !Send for TestType {} +//~^ ERROR negative trait bounds + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.stderr b/src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.stderr new file mode 100644 index 00000000000..eebd018b887 --- /dev/null +++ b/src/test/ui/compile-fail-migration/syntax-trait-polarity-feature-gate.stderr @@ -0,0 +1,11 @@ +error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now (see issue #13231) + --> $DIR/syntax-trait-polarity-feature-gate.rs:17:1 + | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(optin_builtin_traits)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/syntax-trait-polarity.rs b/src/test/ui/compile-fail-migration/syntax-trait-polarity.rs new file mode 100644 index 00000000000..1a5d058cb9a --- /dev/null +++ b/src/test/ui/compile-fail-migration/syntax-trait-polarity.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +use std::marker::Send; + +struct TestType; + +impl !TestType {} +//~^ ERROR inherent impls cannot be negative + +trait TestTrait {} + +unsafe impl !Send for TestType {} +//~^ ERROR negative impls cannot be unsafe +impl !TestTrait for TestType {} +//~^ ERROR negative impls are only allowed for auto traits + +struct TestType2(T); + +impl !TestType2 {} +//~^ ERROR inherent impls cannot be negative + +unsafe impl !Send for TestType2 {} +//~^ ERROR negative impls cannot be unsafe +impl !TestTrait for TestType2 {} +//~^ ERROR negative impls are only allowed for auto traits + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/syntax-trait-polarity.stderr b/src/test/ui/compile-fail-migration/syntax-trait-polarity.stderr new file mode 100644 index 00000000000..724ac60ed91 --- /dev/null +++ b/src/test/ui/compile-fail-migration/syntax-trait-polarity.stderr @@ -0,0 +1,40 @@ +error: inherent impls cannot be negative + --> $DIR/syntax-trait-polarity.rs:17:1 + | +LL | impl !TestType {} + | ^^^^^^^^^^^^^^^^^ + +error[E0198]: negative impls cannot be unsafe + --> $DIR/syntax-trait-polarity.rs:22:1 + | +LL | unsafe impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: inherent impls cannot be negative + --> $DIR/syntax-trait-polarity.rs:29:1 + | +LL | impl !TestType2 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0198]: negative impls cannot be unsafe + --> $DIR/syntax-trait-polarity.rs:32:1 + | +LL | unsafe impl !Send for TestType2 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) + --> $DIR/syntax-trait-polarity.rs:24:1 + | +LL | impl !TestTrait for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) + --> $DIR/syntax-trait-polarity.rs:34:1 + | +LL | impl !TestTrait for TestType2 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +Some errors occurred: E0192, E0198. +For more information about an error, try `rustc --explain E0192`. diff --git a/src/test/ui/compile-fail-migration/synthetic-param.rs b/src/test/ui/compile-fail-migration/synthetic-param.rs new file mode 100644 index 00000000000..337cae1369e --- /dev/null +++ b/src/test/ui/compile-fail-migration/synthetic-param.rs @@ -0,0 +1,38 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +fn func<#[rustc_synthetic] T>(_: T) {} + +struct Foo; + +impl Foo { + pub fn func<#[rustc_synthetic] T>(_: T) {} +} + +struct Bar { + t: S +} + +impl Bar { + pub fn func<#[rustc_synthetic] T>(_: T) {} +} + +fn main() { + func::(42); //~ ERROR cannot provide explicit type parameters + func(42); // Ok + + Foo::func::(42); //~ ERROR cannot provide explicit type parameters + Foo::func(42); // Ok + + Bar::::func::(42); //~ ERROR cannot provide explicit type parameters + Bar::::func(42); // Ok +} diff --git a/src/test/ui/compile-fail-migration/synthetic-param.stderr b/src/test/ui/compile-fail-migration/synthetic-param.stderr new file mode 100644 index 00000000000..2711f6f8bdc --- /dev/null +++ b/src/test/ui/compile-fail-migration/synthetic-param.stderr @@ -0,0 +1,21 @@ +error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position. + --> $DIR/synthetic-param.rs:30:5 + | +LL | func::(42); //~ ERROR cannot provide explicit type parameters + | ^^^^^^^^^^ + +error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position. + --> $DIR/synthetic-param.rs:33:5 + | +LL | Foo::func::(42); //~ ERROR cannot provide explicit type parameters + | ^^^^^^^^^^^^^^^ + +error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position. + --> $DIR/synthetic-param.rs:36:5 + | +LL | Bar::::func::(42); //~ ERROR cannot provide explicit type parameters + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0632`. diff --git a/src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.rs b/src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.rs new file mode 100644 index 00000000000..8f420f1ce4b --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #876 + +#![no_implicit_prelude] +use std::vec::Vec; + +fn last(v: Vec<&T> ) -> std::option::Option { + panic!(); +} + +fn main() { + let y; + let x : char = last(y); + //~^ ERROR mismatched types + //~| expected type `char` + //~| found type `std::option::Option<_>` + //~| expected char, found enum `std::option::Option` +} diff --git a/src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.stderr b/src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.stderr new file mode 100644 index 00000000000..b9580eafc33 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-that-dare-not-speak-its-name.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/tag-that-dare-not-speak-its-name.rs:22:20 + | +LL | let x : char = last(y); + | ^^^^^^^ expected char, found enum `std::option::Option` + | + = note: expected type `char` + found type `std::option::Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/tag-type-args.rs b/src/test/ui/compile-fail-migration/tag-type-args.rs new file mode 100644 index 00000000000..5785a13b006 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-type-args.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:wrong number of type arguments + +enum quux { bar } + +fn foo(c: quux) { assert!((false)); } + +fn main() { panic!(); } diff --git a/src/test/ui/compile-fail-migration/tag-type-args.stderr b/src/test/ui/compile-fail-migration/tag-type-args.stderr new file mode 100644 index 00000000000..1431ee9cc86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-type-args.stderr @@ -0,0 +1,9 @@ +error[E0243]: wrong number of type arguments: expected 1, found 0 + --> $DIR/tag-type-args.rs:15:11 + | +LL | fn foo(c: quux) { assert!((false)); } + | ^^^^ expected 1 type argument + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0243`. diff --git a/src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.rs b/src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.rs new file mode 100644 index 00000000000..220537633ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum non_nullary { + nullary, + other(isize), +} + +fn main() { + let v = non_nullary::nullary; + let val = v as isize; //~ ERROR non-primitive cast: `non_nullary` as `isize` [E0605] +} diff --git a/src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.stderr b/src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.stderr new file mode 100644 index 00000000000..1e64c74d121 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-variant-cast-non-nullary.stderr @@ -0,0 +1,11 @@ +error[E0605]: non-primitive cast: `non_nullary` as `isize` + --> $DIR/tag-variant-cast-non-nullary.rs:18:15 + | +LL | let val = v as isize; //~ ERROR non-primitive cast: `non_nullary` as `isize` [E0605] + | ^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/tag-variant-disr-dup.rs b/src/test/ui/compile-fail-migration/tag-variant-disr-dup.rs new file mode 100644 index 00000000000..5da5bb85409 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-variant-disr-dup.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//error-pattern:discriminant value + +// black and white have the same discriminator value ... + +enum color { + red = 0xff0000, + green = 0x00ff00, + blue = 0x0000ff, + black = 0x000000, + white = 0x000000, +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/tag-variant-disr-dup.stderr b/src/test/ui/compile-fail-migration/tag-variant-disr-dup.stderr new file mode 100644 index 00000000000..de5a0fac54f --- /dev/null +++ b/src/test/ui/compile-fail-migration/tag-variant-disr-dup.stderr @@ -0,0 +1,11 @@ +error[E0081]: discriminant value `0` already exists + --> $DIR/tag-variant-disr-dup.rs:20:13 + | +LL | black = 0x000000, + | -------- first use of `0` +LL | white = 0x000000, + | ^^^^^^^^ enum already has `0` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0081`. diff --git a/src/test/ui/compile-fail-migration/tail-typeck.rs b/src/test/ui/compile-fail-migration/tail-typeck.rs new file mode 100644 index 00000000000..5c1270aa0e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tail-typeck.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types + +fn f() -> isize { return g(); } + +fn g() -> usize { return 0; } + +fn main() { let y = f(); } diff --git a/src/test/ui/compile-fail-migration/tail-typeck.stderr b/src/test/ui/compile-fail-migration/tail-typeck.stderr new file mode 100644 index 00000000000..302bd6aa2d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tail-typeck.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/tail-typeck.rs:13:26 + | +LL | fn f() -> isize { return g(); } + | ^^^ expected isize, found usize + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/terr-in-field.rs b/src/test/ui/compile-fail-migration/terr-in-field.rs new file mode 100644 index 00000000000..4a21e133981 --- /dev/null +++ b/src/test/ui/compile-fail-migration/terr-in-field.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct foo { + a: isize, + b: isize, +} + +struct bar { + a: isize, + b: usize, +} + +fn want_foo(f: foo) {} +fn have_bar(b: bar) { + want_foo(b); //~ ERROR mismatched types + //~| expected type `foo` + //~| found type `bar` + //~| expected struct `foo`, found struct `bar` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/terr-in-field.stderr b/src/test/ui/compile-fail-migration/terr-in-field.stderr new file mode 100644 index 00000000000..5d06eef90be --- /dev/null +++ b/src/test/ui/compile-fail-migration/terr-in-field.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/terr-in-field.rs:23:14 + | +LL | want_foo(b); //~ ERROR mismatched types + | ^ expected struct `foo`, found struct `bar` + | + = note: expected type `foo` + found type `bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/terr-sorts.rs b/src/test/ui/compile-fail-migration/terr-sorts.rs new file mode 100644 index 00000000000..fd92a26d0fc --- /dev/null +++ b/src/test/ui/compile-fail-migration/terr-sorts.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct foo { + a: isize, + b: isize, +} + +type bar = Box; + +fn want_foo(f: foo) {} +fn have_bar(b: bar) { + want_foo(b); //~ ERROR mismatched types + //~| expected type `foo` + //~| found type `std::boxed::Box` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/terr-sorts.stderr b/src/test/ui/compile-fail-migration/terr-sorts.stderr new file mode 100644 index 00000000000..a16216c842e --- /dev/null +++ b/src/test/ui/compile-fail-migration/terr-sorts.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/terr-sorts.rs:21:14 + | +LL | want_foo(b); //~ ERROR mismatched types + | ^ expected struct `foo`, found struct `std::boxed::Box` + | + = note: expected type `foo` + found type `std::boxed::Box` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/test-cfg.rs b/src/test/ui/compile-fail-migration/test-cfg.rs new file mode 100644 index 00000000000..71cae0b6df9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/test-cfg.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --cfg foo + +#[cfg(all(foo, bar))] // foo AND bar +fn foo() {} + +fn main() { + foo(); //~ ERROR cannot find function `foo` in this scope +} diff --git a/src/test/ui/compile-fail-migration/test-cfg.stderr b/src/test/ui/compile-fail-migration/test-cfg.stderr new file mode 100644 index 00000000000..1db6d5eccbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/test-cfg.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `foo` in this scope + --> $DIR/test-cfg.rs:17:5 + | +LL | foo(); //~ ERROR cannot find function `foo` in this scope + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/test-warns-dead-code.rs b/src/test/ui/compile-fail-migration/test-warns-dead-code.rs new file mode 100644 index 00000000000..0e25f1e965a --- /dev/null +++ b/src/test/ui/compile-fail-migration/test-warns-dead-code.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --test + +#![deny(dead_code)] + +fn dead() {} //~ error: function is never used: `dead` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/test-warns-dead-code.stderr b/src/test/ui/compile-fail-migration/test-warns-dead-code.stderr new file mode 100644 index 00000000000..46ff31c65d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/test-warns-dead-code.stderr @@ -0,0 +1,14 @@ +error: function is never used: `dead` + --> $DIR/test-warns-dead-code.rs:15:1 + | +LL | fn dead() {} //~ error: function is never used: `dead` + | ^^^^^^^^^ + | +note: lint level defined here + --> $DIR/test-warns-dead-code.rs:13:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/thread-local-in-ctfe.nll.stderr b/src/test/ui/compile-fail-migration/thread-local-in-ctfe.nll.stderr new file mode 100644 index 00000000000..6784a83cc76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/thread-local-in-ctfe.nll.stderr @@ -0,0 +1,54 @@ +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:16:17 + | +LL | static B: u32 = A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:19:18 + | +LL | static C: &u32 = &A; + | ^^ + +error[E0597]: `A` does not live long enough + --> $DIR/thread-local-in-ctfe.rs:19:18 + | +LL | static C: &u32 = &A; + | ^^- `A` dropped here while still borrowed + | | + | borrowed value does not live long enough + | + = note: borrowed value must be valid for the static lifetime... + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:22:16 + | +LL | const D: u32 = A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:25:17 + | +LL | const E: &u32 = &A; + | ^^ + +error[E0597]: `A` does not live long enough + --> $DIR/thread-local-in-ctfe.rs:25:17 + | +LL | const E: &u32 = &A; + | ^^- `A` dropped here while still borrowed + | | + | borrowed value does not live long enough + | + = note: borrowed value must be valid for the static lifetime... + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:29:5 + | +LL | A + | ^ + +error: aborting due to 7 previous errors + +Some errors occurred: E0597, E0625. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/thread-local-in-ctfe.rs b/src/test/ui/compile-fail-migration/thread-local-in-ctfe.rs new file mode 100644 index 00000000000..62e26f28b06 --- /dev/null +++ b/src/test/ui/compile-fail-migration/thread-local-in-ctfe.rs @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_fn, thread_local)] + +#[thread_local] +static A: u32 = 1; + +static B: u32 = A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +static C: &u32 = &A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +const D: u32 = A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +const E: &u32 = &A; +//~^ ERROR thread-local statics cannot be accessed at compile-time + +const fn f() -> u32 { + A + //~^ ERROR thread-local statics cannot be accessed at compile-time +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/thread-local-in-ctfe.stderr b/src/test/ui/compile-fail-migration/thread-local-in-ctfe.stderr new file mode 100644 index 00000000000..76079d9a9ee --- /dev/null +++ b/src/test/ui/compile-fail-migration/thread-local-in-ctfe.stderr @@ -0,0 +1,33 @@ +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:16:17 + | +LL | static B: u32 = A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:19:18 + | +LL | static C: &u32 = &A; + | ^^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:22:16 + | +LL | const D: u32 = A; + | ^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:25:17 + | +LL | const E: &u32 = &A; + | ^^ + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-in-ctfe.rs:29:5 + | +LL | A + | ^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0625`. diff --git a/src/test/ui/compile-fail-migration/tool_lints.rs b/src/test/ui/compile-fail-migration/tool_lints.rs new file mode 100644 index 00000000000..ea1efab4cb6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tool_lints.rs @@ -0,0 +1,18 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Don't allow tool_lints, which aren't scoped + +#![feature(tool_lints)] +#![deny(unknown_lints)] + +#![deny(clippy)] //~ ERROR: unknown lint: `clippy` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/tool_lints.stderr b/src/test/ui/compile-fail-migration/tool_lints.stderr new file mode 100644 index 00000000000..4ee285e5ea4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tool_lints.stderr @@ -0,0 +1,14 @@ +error: unknown lint: `clippy` + --> $DIR/tool_lints.rs:16:9 + | +LL | #![deny(clippy)] //~ ERROR: unknown lint: `clippy` + | ^^^^^^ + | +note: lint level defined here + --> $DIR/tool_lints.rs:14:9 + | +LL | #![deny(unknown_lints)] + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/trace_macros-format.rs b/src/test/ui/compile-fail-migration/trace_macros-format.rs new file mode 100644 index 00000000000..95cb17c215b --- /dev/null +++ b/src/test/ui/compile-fail-migration/trace_macros-format.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(trace_macros)] + +fn main() { + trace_macros!(); //~ ERROR trace_macros! accepts only `true` or `false` + trace_macros!(1); //~ ERROR trace_macros! accepts only `true` or `false` + trace_macros!(ident); //~ ERROR trace_macros! accepts only `true` or `false` + trace_macros!(for); //~ ERROR trace_macros! accepts only `true` or `false` + trace_macros!(true,); //~ ERROR trace_macros! accepts only `true` or `false` + trace_macros!(false 1); //~ ERROR trace_macros! accepts only `true` or `false` + + + // should be fine: + macro_rules! expando { + ($x: ident) => { trace_macros!($x) } + } + + expando!(true); +} diff --git a/src/test/ui/compile-fail-migration/trace_macros-format.stderr b/src/test/ui/compile-fail-migration/trace_macros-format.stderr new file mode 100644 index 00000000000..8dad041e9fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/trace_macros-format.stderr @@ -0,0 +1,38 @@ +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-format.rs:14:5 + | +LL | trace_macros!(); //~ ERROR trace_macros! accepts only `true` or `false` + | ^^^^^^^^^^^^^^^^ + +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-format.rs:15:5 + | +LL | trace_macros!(1); //~ ERROR trace_macros! accepts only `true` or `false` + | ^^^^^^^^^^^^^^^^^ + +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-format.rs:16:5 + | +LL | trace_macros!(ident); //~ ERROR trace_macros! accepts only `true` or `false` + | ^^^^^^^^^^^^^^^^^^^^^ + +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-format.rs:17:5 + | +LL | trace_macros!(for); //~ ERROR trace_macros! accepts only `true` or `false` + | ^^^^^^^^^^^^^^^^^^^ + +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-format.rs:18:5 + | +LL | trace_macros!(true,); //~ ERROR trace_macros! accepts only `true` or `false` + | ^^^^^^^^^^^^^^^^^^^^^ + +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-format.rs:19:5 + | +LL | trace_macros!(false 1); //~ ERROR trace_macros! accepts only `true` or `false` + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/compile-fail-migration/trace_macros-gate.rs b/src/test/ui/compile-fail-migration/trace_macros-gate.rs new file mode 100644 index 00000000000..d4a7c4ed0e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trace_macros-gate.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the trace_macros feature gate is on. + +fn main() { + trace_macros!(); //~ ERROR `trace_macros` is not stable + trace_macros!(1); //~ ERROR `trace_macros` is not stable + trace_macros!(ident); //~ ERROR `trace_macros` is not stable + trace_macros!(for); //~ ERROR `trace_macros` is not stable + trace_macros!(true,); //~ ERROR `trace_macros` is not stable + trace_macros!(false 1); //~ ERROR `trace_macros` is not stable + + // Errors are signalled early for the above, before expansion. + // See trace_macros-gate2 and trace_macros-gate3. for examples + // of the below being caught. + + macro_rules! expando { + ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable + } + + expando!(true); +} diff --git a/src/test/ui/compile-fail-migration/trace_macros-gate.stderr b/src/test/ui/compile-fail-migration/trace_macros-gate.stderr new file mode 100644 index 00000000000..ed92e1227ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/trace_macros-gate.stderr @@ -0,0 +1,62 @@ +error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) + --> $DIR/trace_macros-gate.rs:14:5 + | +LL | trace_macros!(); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trace_macros)] to the crate attributes to enable + +error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) + --> $DIR/trace_macros-gate.rs:15:5 + | +LL | trace_macros!(1); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trace_macros)] to the crate attributes to enable + +error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) + --> $DIR/trace_macros-gate.rs:16:5 + | +LL | trace_macros!(ident); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trace_macros)] to the crate attributes to enable + +error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) + --> $DIR/trace_macros-gate.rs:17:5 + | +LL | trace_macros!(for); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trace_macros)] to the crate attributes to enable + +error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) + --> $DIR/trace_macros-gate.rs:18:5 + | +LL | trace_macros!(true,); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trace_macros)] to the crate attributes to enable + +error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) + --> $DIR/trace_macros-gate.rs:19:5 + | +LL | trace_macros!(false 1); //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trace_macros)] to the crate attributes to enable + +error[E0658]: `trace_macros` is not stable enough for use and is subject to change (see issue #29598) + --> $DIR/trace_macros-gate.rs:26:26 + | +LL | ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable + | ^^^^^^^^^^^^^^^^^ +... +LL | expando!(true); + | --------------- in this macro invocation + | + = help: add #![feature(trace_macros)] to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/trait-alias.rs b/src/test/ui/compile-fail-migration/trait-alias.rs new file mode 100644 index 00000000000..7aca227a76c --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-alias.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// gate-test-trait_alias + +trait Alias1 = Default where T: Clone; // ok + //~^ERROR trait aliases are not yet fully implemented +trait Alias2 = Default; + //~^ERROR type parameters on the left side of a trait alias cannot be bounded + //~^^ERROR type parameters on the left side of a trait alias cannot have defaults + //~^^^ERROR trait aliases are not yet fully implemented + +impl Alias1 { //~ERROR expected type, found trait alias +} + +impl Alias1 for () { //~ERROR expected trait, found trait alias +} + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/trait-alias.stderr b/src/test/ui/compile-fail-migration/trait-alias.stderr new file mode 100644 index 00000000000..75fd4a9d9af --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-alias.stderr @@ -0,0 +1,44 @@ +error: type parameters on the left side of a trait alias cannot be bounded + --> $DIR/trait-alias.rs:15:14 + | +LL | trait Alias2 = Default; + | ^ + +error: type parameters on the left side of a trait alias cannot have defaults + --> $DIR/trait-alias.rs:15:14 + | +LL | trait Alias2 = Default; + | ^ + +error[E0573]: expected type, found trait alias `Alias1` + --> $DIR/trait-alias.rs:20:6 + | +LL | impl Alias1 { //~ERROR expected type, found trait alias + | ^^^^^^ not a type + +error[E0404]: expected trait, found trait alias `Alias1` + --> $DIR/trait-alias.rs:23:6 + | +LL | impl Alias1 for () { //~ERROR expected trait, found trait alias + | ^^^^^^ not a trait + +error[E0658]: trait aliases are not yet fully implemented (see issue #41517) + --> $DIR/trait-alias.rs:13:1 + | +LL | trait Alias1 = Default where T: Clone; // ok + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trait_alias)] to the crate attributes to enable + +error[E0658]: trait aliases are not yet fully implemented (see issue #41517) + --> $DIR/trait-alias.rs:15:1 + | +LL | trait Alias2 = Default; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(trait_alias)] to the crate attributes to enable + +error: aborting due to 6 previous errors + +Some errors occurred: E0404, E0573, E0658. +For more information about an error, try `rustc --explain E0404`. diff --git a/src/test/ui/compile-fail-migration/trait-as-struct-constructor.rs b/src/test/ui/compile-fail-migration/trait-as-struct-constructor.rs new file mode 100644 index 00000000000..49d58580da5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-as-struct-constructor.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait TraitNotAStruct {} + +fn main() { + TraitNotAStruct{ value: 0 }; + //~^ ERROR expected struct, variant or union type, found trait `TraitNotAStruct` +} diff --git a/src/test/ui/compile-fail-migration/trait-as-struct-constructor.stderr b/src/test/ui/compile-fail-migration/trait-as-struct-constructor.stderr new file mode 100644 index 00000000000..ecb4e5d44c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-as-struct-constructor.stderr @@ -0,0 +1,9 @@ +error[E0574]: expected struct, variant or union type, found trait `TraitNotAStruct` + --> $DIR/trait-as-struct-constructor.rs:14: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/compile-fail-migration/trait-bounds-not-on-bare-trait.rs b/src/test/ui/compile-fail-migration/trait-bounds-not-on-bare-trait.rs new file mode 100644 index 00000000000..9c38d8a9e2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-not-on-bare-trait.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +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 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/compile-fail-migration/trait-bounds-not-on-bare-trait.stderr new file mode 100644 index 00000000000..31a36fdc132 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-not-on-bare-trait.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `(dyn Foo + std::marker::Send + 'static)` cannot be known at compilation time + --> $DIR/trait-bounds-not-on-bare-trait.rs:17:8 + | +LL | fn foo(_x: Foo + Send) { + | ^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + std::marker::Send + 'static)` + = note: to learn more, visit + = note: all local variables must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.rs b/src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.rs new file mode 100644 index 00000000000..76bbca60658 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.rs @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(bare_trait_objects)] + +struct Foo; + +fn foo(_x: Box) { } //~ ERROR expected trait, found struct `Foo` + +type A = Box>; //~ ERROR expected trait, found struct `Vec` + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.stderr b/src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.stderr new file mode 100644 index 00000000000..929a1bfaa15 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-not-on-struct.stderr @@ -0,0 +1,15 @@ +error[E0404]: expected trait, found struct `Foo` + --> $DIR/trait-bounds-not-on-struct.rs:15:16 + | +LL | fn foo(_x: Box) { } //~ ERROR expected trait, found struct `Foo` + | ^^^ not a trait + +error[E0404]: expected trait, found struct `Vec` + --> $DIR/trait-bounds-not-on-struct.rs:17:21 + | +LL | type A = Box>; //~ ERROR expected trait, found struct `Vec` + | ^^^^^^ not a trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0404`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.rs b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.rs new file mode 100644 index 00000000000..6a271a7b749 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait {} + +struct Foo { + x: T, +} + +enum Bar { + ABar(isize), + BBar(T), + CBar(usize), +} + +fn explode(x: Foo) {} +//~^ ERROR E0277 + +fn kaboom(y: Bar) {} +//~^ ERROR E0277 + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.stderr b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.stderr new file mode 100644 index 00000000000..6dd4d1fca86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-fns.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `u32: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:23:1 + | +LL | fn explode(x: Foo) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u32` + | +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:13:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `f32: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:26:1 + | +LL | fn kaboom(y: Bar) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `f32` + | +note: required by `Bar` + --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:17:1 + | +LL | enum Bar { + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.rs b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.rs new file mode 100644 index 00000000000..77abe6f7f74 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait {} + +struct Foo { + x: T, +} + +enum Bar { + ABar(isize), + BBar(T), + CBar(usize), +} + +trait PolyTrait +{ + fn whatever(&self, t: T) {} +} + +struct Struct; + +impl PolyTrait> for Struct { +//~^ ERROR E0277 +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.stderr b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.stderr new file mode 100644 index 00000000000..6f917706873 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-in-impls.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `u16: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-in-impls.rs:30:6 + | +LL | impl PolyTrait> for Struct { + | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u16` + | +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums-in-impls.rs:13:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.rs b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.rs new file mode 100644 index 00000000000..9e680d17fb9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait { + fn dummy(&self) { } +} + +struct Foo { + x: T, +} + +fn main() { + let foo = Foo { + //~^ ERROR E0277 + x: 3 + }; + + let baz: Foo = loop { }; + //~^ ERROR E0277 +} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.stderr b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.stderr new file mode 100644 index 00000000000..cdaa12428ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-locals.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `usize: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:25:14 + | +LL | let baz: Foo = loop { }; + | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` + | +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:15:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `{integer}: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:20:15 + | +LL | let foo = Foo { + | ^^^ the trait `Trait` is not implemented for `{integer}` + | +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:15:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.rs b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.rs new file mode 100644 index 00000000000..2b59fdcae35 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait { + fn dummy(&self) { } +} + +struct Foo { + x: T, +} + +static X: Foo = Foo { +//~^ ERROR E0277 + x: 1, +}; + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.stderr b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.stderr new file mode 100644 index 00000000000..28d4257a9fb --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-static.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `usize: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-static.rs:19:1 + | +LL | / static X: Foo = Foo { +LL | | //~^ ERROR E0277 +LL | | x: 1, +LL | | }; + | |__^ the trait `Trait` is not implemented for `usize` + | +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums-static.rs:15:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.rs b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.rs new file mode 100644 index 00000000000..975de00d02a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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) {} +//~^ ERROR E0277 + +fn kaboom(y: Bar) {} +//~^ ERROR E0277 + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.stderr b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.stderr new file mode 100644 index 00000000000..b798ccfc7a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `usize: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-xc.rs:17:1 + | +LL | fn explode(x: Foo) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `usize` + | + = note: required by `trait_bounds_on_structs_and_enums_xc::Foo` + +error[E0277]: the trait bound `f32: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-xc.rs:20:1 + | +LL | fn kaboom(y: Bar) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `f32` + | + = note: required by `trait_bounds_on_structs_and_enums_xc::Bar` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.rs b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.rs new file mode 100644 index 00000000000..515684bcf42 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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 = return; + //~^ ERROR E0277 + let _ = bar; +} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.stderr b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.stderr new file mode 100644 index 00000000000..0b0bd4f6ab1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums-xc1.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `f64: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-xc1.rs:22:14 + | +LL | let bar: Bar = return; + | ^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `f64` + | + = note: required by `trait_bounds_on_structs_and_enums_xc::Bar` + +error[E0277]: the trait bound `{integer}: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums-xc1.rs:18:15 + | +LL | let foo = Foo { + | ^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `{integer}` + | + = note: required by `trait_bounds_on_structs_and_enums_xc::Foo` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.rs b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.rs new file mode 100644 index 00000000000..24e2418e8d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.rs @@ -0,0 +1,53 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait {} + +struct Foo { + x: T, +} + +enum Bar { + ABar(isize), + BBar(T), + CBar(usize), +} + +impl Foo { +//~^ ERROR `T: Trait` is not satisfied + fn uhoh() {} +} + +struct Baz { + a: Foo, //~ ERROR E0277 +} + +enum Boo { + Quux(Bar), //~ ERROR E0277 +} + +struct Badness { + b: Foo, //~ ERROR E0277 +} + +enum MoreBadness { + EvenMoreBadness(Bar), //~ ERROR E0277 +} + +struct TupleLike( + Foo, //~ ERROR E0277 +); + +enum Enum { + DictionaryLike { field: Bar }, //~ ERROR E0277 +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.stderr b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.stderr new file mode 100644 index 00000000000..5686e62c8b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-on-structs-and-enums.stderr @@ -0,0 +1,90 @@ +error[E0277]: the trait bound `T: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums.rs:23:9 + | +LL | impl Foo { + | ^^^^^^ the trait `Trait` is not implemented for `T` + | + = help: consider adding a `where T: Trait` bound +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums.rs:13:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `isize: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums.rs:29:5 + | +LL | a: Foo, //~ ERROR E0277 + | ^^^^^^^^^^^^^ the trait `Trait` is not implemented for `isize` + | +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums.rs:13:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `usize: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums.rs:33:10 + | +LL | Quux(Bar), //~ ERROR E0277 + | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` + | +note: required by `Bar` + --> $DIR/trait-bounds-on-structs-and-enums.rs:17:1 + | +LL | enum Bar { + | ^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `U: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums.rs:37:5 + | +LL | b: Foo, //~ ERROR E0277 + | ^^^^^^^^^ the trait `Trait` is not implemented for `U` + | + = help: consider adding a `where U: Trait` bound +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums.rs:13:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `V: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums.rs:41:21 + | +LL | EvenMoreBadness(Bar), //~ ERROR E0277 + | ^^^^^^ the trait `Trait` is not implemented for `V` + | + = help: consider adding a `where V: Trait` bound +note: required by `Bar` + --> $DIR/trait-bounds-on-structs-and-enums.rs:17:1 + | +LL | enum Bar { + | ^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `i32: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums.rs:45:5 + | +LL | Foo, //~ ERROR E0277 + | ^^^^^^^^ the trait `Trait` is not implemented for `i32` + | +note: required by `Foo` + --> $DIR/trait-bounds-on-structs-and-enums.rs:13:1 + | +LL | struct Foo { + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `u8: Trait` is not satisfied + --> $DIR/trait-bounds-on-structs-and-enums.rs:49:22 + | +LL | DictionaryLike { field: Bar }, //~ ERROR E0277 + | ^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u8` + | +note: required by `Bar` + --> $DIR/trait-bounds-on-structs-and-enums.rs:17:1 + | +LL | enum Bar { + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-bounds-sugar.rs b/src/test/ui/compile-fail-migration/trait-bounds-sugar.rs new file mode 100644 index 00000000000..0a36fcbed69 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-sugar.rs @@ -0,0 +1,29 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests for "default" bounds inferred for traits with no bounds list. + +trait Foo {} + +fn a(_x: Box) { +} + +fn b(_x: &'static (Foo+'static)) { +} + +fn c(x: Box) { + a(x); //~ ERROR mismatched types +} + +fn d(x: &'static (Foo+Sync)) { + b(x); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/trait-bounds-sugar.stderr b/src/test/ui/compile-fail-migration/trait-bounds-sugar.stderr new file mode 100644 index 00000000000..bd899e06545 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-bounds-sugar.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/trait-bounds-sugar.rs:22:7 + | +LL | a(x); //~ ERROR mismatched types + | ^ expected trait `Foo + std::marker::Send`, found trait `Foo + std::marker::Sync` + | + = note: expected type `std::boxed::Box<(dyn Foo + std::marker::Send + 'static)>` + found type `std::boxed::Box<(dyn Foo + std::marker::Sync + 'static)>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/trait-coercion-generic-bad.rs b/src/test/ui/compile-fail-migration/trait-coercion-generic-bad.rs new file mode 100644 index 00000000000..3839e90ed9f --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-coercion-generic-bad.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Struct { + person: &'static str +} + +trait Trait { + 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> = Box::new(Struct { person: "Fred" }); + //~^ ERROR `Struct: Trait` is not satisfied + s.f(1); +} diff --git a/src/test/ui/compile-fail-migration/trait-coercion-generic-bad.stderr b/src/test/ui/compile-fail-migration/trait-coercion-generic-bad.stderr new file mode 100644 index 00000000000..a186877e57b --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-coercion-generic-bad.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `Struct: Trait` is not satisfied + --> $DIR/trait-coercion-generic-bad.rs:26:32 + | +LL | let s: Box> = Box::new(Struct { person: "Fred" }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `Struct` + | + = help: the following implementations were found: + > + = note: required for the cast to the object type `dyn Trait` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.nll.stderr b/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.nll.stderr new file mode 100644 index 00000000000..c6a7482c29f --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: `person` does not live long enough + --> $DIR/trait-coercion-generic-regions.rs:27:24 + | +LL | let person: &str = &person; //~ ERROR `person` does not live long enough + | ^^^^^^^ borrowed value does not live long enough +LL | let s: Box> = Box::new(Struct { person: person }); +LL | } + | - `person` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.rs b/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.rs new file mode 100644 index 00000000000..18d3ded77f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.rs @@ -0,0 +1,29 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Struct { + person: &'static str +} + +trait Trait { + 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> = Box::new(Struct { person: person }); +} diff --git a/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.stderr b/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.stderr new file mode 100644 index 00000000000..8eaf7e9c1ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-coercion-generic-regions.stderr @@ -0,0 +1,14 @@ +error[E0597]: `person` does not live long enough + --> $DIR/trait-coercion-generic-regions.rs:27:25 + | +LL | let person: &str = &person; //~ ERROR `person` does not live long enough + | ^^^^^^ borrowed value does not live long enough +LL | let s: Box> = Box::new(Struct { person: person }); +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/trait-impl-1.rs b/src/test/ui/compile-fail-migration/trait-impl-1.rs new file mode 100644 index 00000000000..e682d3c81e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-1.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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> T+'a { + fn foo(&self) {} +} + +impl T for i32 {} + +fn main() { + let x = &42i32; + x.foo(); //~ERROR: no method named `foo` found for type `&i32` in the current scope +} diff --git a/src/test/ui/compile-fail-migration/trait-impl-1.stderr b/src/test/ui/compile-fail-migration/trait-impl-1.stderr new file mode 100644 index 00000000000..b8033900505 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-1.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `foo` found for type `&i32` in the current scope + --> $DIR/trait-impl-1.rs:25:7 + | +LL | x.foo(); //~ERROR: no method named `foo` found for type `&i32` in the current scope + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/trait-impl-can-not-have-untraitful-items.rs b/src/test/ui/compile-fail-migration/trait-impl-can-not-have-untraitful-items.rs new file mode 100644 index 00000000000..cc143a6209d --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-can-not-have-untraitful-items.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +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/compile-fail-migration/trait-impl-can-not-have-untraitful-items.stderr b/src/test/ui/compile-fail-migration/trait-impl-can-not-have-untraitful-items.stderr new file mode 100644 index 00000000000..e23225bc124 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-can-not-have-untraitful-items.stderr @@ -0,0 +1,22 @@ +error[E0438]: const `BAR` is not a member of trait `A` + --> $DIR/trait-impl-can-not-have-untraitful-items.rs:15:5 + | +LL | const BAR: () = (); //~ ERROR const `BAR` is not a member of trait `A` + | ^^^^^^^^^^^^^^^^^^^ 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:16:5 + | +LL | type Baz = (); //~ ERROR type `Baz` is not a member of trait `A` + | ^^^^^^^^^^^^^^ 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:17:5 + | +LL | fn foo(&self) { } //~ ERROR method `foo` is not a member of trait `A` + | ^^^^^^^^^^^^^^^^^ not a member of trait `A` + +error: aborting due to 3 previous errors + +Some errors occurred: E0407, E0437, E0438. +For more information about an error, try `rustc --explain E0407`. diff --git a/src/test/ui/compile-fail-migration/trait-impl-different-num-params.rs b/src/test/ui/compile-fail-migration/trait-impl-different-num-params.rs new file mode 100644 index 00000000000..647dd4e05fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-different-num-params.rs @@ -0,0 +1,22 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +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/compile-fail-migration/trait-impl-different-num-params.stderr b/src/test/ui/compile-fail-migration/trait-impl-different-num-params.stderr new file mode 100644 index 00000000000..c3bbf99b06a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-different-num-params.stderr @@ -0,0 +1,12 @@ +error[E0050]: method `bar` has 1 parameter but the declaration in trait `foo::bar` has 2 + --> $DIR/trait-impl-different-num-params.rs:15: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/compile-fail-migration/trait-impl-for-module.rs b/src/test/ui/compile-fail-migration/trait-impl-for-module.rs new file mode 100644 index 00000000000..1fe8f6294da --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-for-module.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod a { +} + +trait A { +} + +impl A for a { //~ ERROR expected type, found module +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/trait-impl-for-module.stderr b/src/test/ui/compile-fail-migration/trait-impl-for-module.stderr new file mode 100644 index 00000000000..62ae84da99e --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-for-module.stderr @@ -0,0 +1,9 @@ +error[E0573]: expected type, found module `a` + --> $DIR/trait-impl-for-module.rs:17:12 + | +LL | impl A for a { //~ ERROR expected type, found module + | ^ did you mean `A`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/compile-fail-migration/trait-impl-method-mismatch.rs b/src/test/ui/compile-fail-migration/trait-impl-method-mismatch.rs new file mode 100644 index 00000000000..a05e007d6b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-method-mismatch.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +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 type `fn + //~| found type `unsafe fn +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/trait-impl-method-mismatch.stderr b/src/test/ui/compile-fail-migration/trait-impl-method-mismatch.stderr new file mode 100644 index 00000000000..526a37f7651 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-method-mismatch.stderr @@ -0,0 +1,15 @@ +error[E0053]: method `jumbo` has an incompatible type for trait + --> $DIR/trait-impl-method-mismatch.rs:18: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 type `fn(&usize, &usize) -> usize` + found type `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/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs b/src/test/ui/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs new file mode 100644 index 00000000000..44c53e70f86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs @@ -0,0 +1,41 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr b/src/test/ui/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr new file mode 100644 index 00000000000..6a97a4eccbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-impl-of-supertrait-has-wrong-lifetime-parameters.stderr @@ -0,0 +1,23 @@ +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:34:13 + | +LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> { //~ ERROR cannot infer an appropriate lifetime + | ^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the impl at 34:6... + --> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:34:6 + | +LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> { //~ ERROR cannot infer an appropriate lifetime + | ^^ +note: ...but the lifetime must also be valid for the lifetime 'b as defined on the impl at 34:9... + --> $DIR/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs:34:9 + | +LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> { //~ ERROR cannot infer an appropriate lifetime + | ^^ + = note: ...so that the types are compatible: + 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/compile-fail-migration/trait-item-privacy.rs b/src/test/ui/compile-fail-migration/trait-item-privacy.rs new file mode 100644 index 00000000000..f8e4f0d596e --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-item-privacy.rs @@ -0,0 +1,146 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![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 for type `S` in the current scope + S.b(); //~ ERROR no method named `b` found for type `S` in the current scope + S.c(); // OK + // a, b, c are resolved as inherent items, their traits don't need to be in scope + let c = &S as &C; + c.a(); //~ ERROR method `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 for type `S` + S::b(&S); + //~^ ERROR no function or associated item named `b` found for type `S` + 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 method `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 for type `S` in the current scope + S::B; //~ ERROR no associated item named `B` found for type `S` in the current scope + 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 + //~| ERROR the trait bound `dyn assoc_const::C: assoc_const::A` is not satisfied + C::B; // ERROR the trait `assoc_const::C` cannot be made into an object + //~^ ERROR the trait bound `dyn assoc_const::C: assoc_const::B` is not satisfied + C::C; // OK +} + +fn check_assoc_ty() { + // 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 _: assoc_ty::B< + B = u8, // OK + >; + let _: C< + A = u8, //~ ERROR associated type `A` is private + B = u8, // OK + C = u8, // OK + >; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/trait-item-privacy.stderr b/src/test/ui/compile-fail-migration/trait-item-privacy.stderr new file mode 100644 index 00000000000..a3747bcee5d --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-item-privacy.stderr @@ -0,0 +1,176 @@ +error[E0599]: no method named `a` found for type `S` in the current scope + --> $DIR/trait-item-privacy.rs:77:7 + | +LL | struct S; + | --------- method `a` not found for this +... +LL | S.a(); //~ ERROR no method named `a` found for type `S` in the current scope + | ^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `a`, perhaps you need to implement it: + candidate #1: `method::A` + +error[E0599]: no method named `b` found for type `S` in the current scope + --> $DIR/trait-item-privacy.rs:78:7 + | +LL | struct S; + | --------- method `b` not found for this +... +LL | S.b(); //~ ERROR no method named `b` found for type `S` in the current scope + | ^ + | + = 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]: method `a` is private + --> $DIR/trait-item-privacy.rs:82:7 + | +LL | c.a(); //~ ERROR method `a` is private + | ^ + +error[E0599]: no function or associated item named `a` found for type `S` in the current scope + --> $DIR/trait-item-privacy.rs:88:5 + | +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: the following trait defines an item `a`, perhaps you need to implement it: + candidate #1: `method::A` + +error[E0599]: no function or associated item named `b` found for type `S` in the current scope + --> $DIR/trait-item-privacy.rs:90:5 + | +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]: method `a` is private + --> $DIR/trait-item-privacy.rs:94:5 + | +LL | C::a(&S); //~ ERROR method `a` is private + | ^^^^ + +error[E0599]: no associated item named `A` found for type `S` in the current scope + --> $DIR/trait-item-privacy.rs:107:5 + | +LL | struct S; + | --------- associated item `A` not found for this +... +LL | S::A; //~ ERROR no associated item named `A` found for type `S` in the current scope + | ^^^^ associated item not found in `S` + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `A`, perhaps you need to implement it: + candidate #1: `assoc_const::A` + +error[E0599]: no associated item named `B` found for type `S` in the current scope + --> $DIR/trait-item-privacy.rs:108:5 + | +LL | struct S; + | --------- associated item `B` not found for this +... +LL | S::B; //~ ERROR no associated item named `B` found for type `S` in the current scope + | ^^^^ 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:111:5 + | +LL | C::A; //~ ERROR associated constant `A` is private + | ^^^^ + +error[E0277]: the trait bound `dyn assoc_const::C: assoc_const::A` is not satisfied + --> $DIR/trait-item-privacy.rs:111:5 + | +LL | C::A; //~ ERROR associated constant `A` is private + | ^^^^ the trait `assoc_const::A` is not implemented for `dyn assoc_const::C` + | +note: required by `assoc_const::A::A` + --> $DIR/trait-item-privacy.rs:35:9 + | +LL | const A: u8 = 0; + | ^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `dyn assoc_const::C: assoc_const::B` is not satisfied + --> $DIR/trait-item-privacy.rs:114:5 + | +LL | C::B; // ERROR the trait `assoc_const::C` cannot be made into an object + | ^^^^ the trait `assoc_const::B` is not implemented for `dyn assoc_const::C` + | +note: required by `assoc_const::B::B` + --> $DIR/trait-item-privacy.rs:39:9 + | +LL | const B: u8 = 0; + | ^^^^^^^^^^^^^^^^ + +error[E0038]: the trait `assoc_const::C` cannot be made into an object + --> $DIR/trait-item-privacy.rs:111:5 + | +LL | C::A; //~ ERROR associated constant `A` is private + | ^^^^ the trait `assoc_const::C` cannot be made into an object + | + = note: the trait cannot contain associated consts like `C` + = note: the trait cannot contain associated consts like `B` + = note: the trait cannot contain associated consts like `A` + +error[E0223]: ambiguous associated type + --> $DIR/trait-item-privacy.rs:127:12 + | +LL | let _: S::A; //~ ERROR ambiguous associated type + | ^^^^ ambiguous associated type + | + = note: specify the type using the syntax `::A` + +error[E0223]: ambiguous associated type + --> $DIR/trait-item-privacy.rs:128:12 + | +LL | let _: S::B; //~ ERROR ambiguous associated type + | ^^^^ ambiguous associated type + | + = note: specify the type using the syntax `::B` + +error[E0223]: ambiguous associated type + --> $DIR/trait-item-privacy.rs:129:12 + | +LL | let _: S::C; //~ ERROR ambiguous associated type + | ^^^^ ambiguous associated type + | + = note: specify the type using the syntax `::C` + +error: associated type `A` is private + --> $DIR/trait-item-privacy.rs:131:12 + | +LL | let _: T::A; //~ ERROR associated type `A` is private + | ^^^^ + +error: associated type `A` is private + --> $DIR/trait-item-privacy.rs:140:9 + | +LL | A = u8, //~ ERROR associated type `A` is private + | ^^^^^^ + +error: aborting due to 17 previous errors + +Some errors occurred: E0038, E0223, E0277, E0599, E0624. +For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/trait-matching-lifetimes.rs b/src/test/ui/compile-fail-migration/trait-matching-lifetimes.rs new file mode 100644 index 00000000000..5ab80065572 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-matching-lifetimes.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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/compile-fail-migration/trait-matching-lifetimes.stderr b/src/test/ui/compile-fail-migration/trait-matching-lifetimes.stderr new file mode 100644 index 00000000000..8f27947ff2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-matching-lifetimes.stderr @@ -0,0 +1,41 @@ +error[E0308]: method not compatible with trait + --> $DIR/trait-matching-lifetimes.rs:24:5 + | +LL | fn foo(x: Foo<'b,'a>) { + | ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `fn(Foo<'a, 'b>)` + found type `fn(Foo<'b, 'a>)` +note: the lifetime 'b as defined on the impl at 23:9... + --> $DIR/trait-matching-lifetimes.rs:23:9 + | +LL | impl<'a,'b> Tr for Foo<'a,'b> { + | ^^ +note: ...does not necessarily outlive the lifetime 'a as defined on the impl at 23:6 + --> $DIR/trait-matching-lifetimes.rs:23:6 + | +LL | impl<'a,'b> Tr for Foo<'a,'b> { + | ^^ + +error[E0308]: method not compatible with trait + --> $DIR/trait-matching-lifetimes.rs:24:5 + | +LL | fn foo(x: Foo<'b,'a>) { + | ^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `fn(Foo<'a, 'b>)` + found type `fn(Foo<'b, 'a>)` +note: the lifetime 'a as defined on the impl at 23:6... + --> $DIR/trait-matching-lifetimes.rs:23:6 + | +LL | impl<'a,'b> Tr for Foo<'a,'b> { + | ^^ +note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 23:9 + --> $DIR/trait-matching-lifetimes.rs:23: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/compile-fail-migration/trait-object-macro-matcher.rs b/src/test/ui/compile-fail-migration/trait-object-macro-matcher.rs new file mode 100644 index 00000000000..8497a699e97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-macro-matcher.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// `ty` matcher accepts trait object types + +macro_rules! m { + ($t: ty) => ( let _: $t; ) +} + +fn main() { + m!(Copy + Send + 'static); //~ ERROR the trait `std::marker::Copy` cannot be made into an object + m!('static + Send); + m!('static +); //~ ERROR at least one non-builtin trait is required for an object type +} diff --git a/src/test/ui/compile-fail-migration/trait-object-macro-matcher.stderr b/src/test/ui/compile-fail-migration/trait-object-macro-matcher.stderr new file mode 100644 index 00000000000..05511b554cc --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-macro-matcher.stderr @@ -0,0 +1,18 @@ +error[E0224]: at least one non-builtin trait is required for an object type + --> $DIR/trait-object-macro-matcher.rs:20:8 + | +LL | m!('static +); //~ ERROR at least one non-builtin trait is required for an object type + | ^^^^^^^^^ + +error[E0038]: the trait `std::marker::Copy` cannot be made into an object + --> $DIR/trait-object-macro-matcher.rs:18:8 + | +LL | m!(Copy + Send + 'static); //~ ERROR the trait `std::marker::Copy` cannot be made into an object + | ^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` cannot be made into an object + | + = note: the trait cannot require that `Self : Sized` + +error: aborting due to 2 previous errors + +Some errors occurred: E0038, E0224. +For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/trait-object-safety.rs b/src/test/ui/compile-fail-migration/trait-object-safety.rs new file mode 100644 index 00000000000..baf239f5956 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-safety.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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 _: &Tr = &St; //~ ERROR E0038 + //~^ ERROR E0038 +} diff --git a/src/test/ui/compile-fail-migration/trait-object-safety.stderr b/src/test/ui/compile-fail-migration/trait-object-safety.stderr new file mode 100644 index 00000000000..be0440db4da --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-safety.stderr @@ -0,0 +1,20 @@ +error[E0038]: the trait `Tr` cannot be made into an object + --> $DIR/trait-object-safety.rs:25:18 + | +LL | let _: &Tr = &St; //~ ERROR E0038 + | ^^^ the trait `Tr` cannot be made into an object + | + = note: method `foo` has no receiver + = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Tr>` for `&St` + +error[E0038]: the trait `Tr` cannot be made into an object + --> $DIR/trait-object-safety.rs:25:12 + | +LL | let _: &Tr = &St; //~ ERROR E0038 + | ^^^ the trait `Tr` cannot be made into an object + | + = note: method `foo` has no receiver + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.rs b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.rs new file mode 100644 index 00000000000..9801cac4714 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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. + +// compile-flags: -Z continue-parse-after-error + +// `'static` is a lifetime, `'static +` is a type, `'a` is a type +fn g() where + 'static: 'static, + 'static +: 'static + Copy, + //~^ ERROR at least one non-builtin trait is required for an object type +{} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.stderr b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.stderr new file mode 100644 index 00000000000..db38aca2383 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime-2.stderr @@ -0,0 +1,9 @@ +error[E0224]: at least one non-builtin trait is required for an object type + --> $DIR/trait-object-vs-lifetime-2.rs:19:5 + | +LL | '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/compile-fail-migration/trait-object-vs-lifetime.rs b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime.rs new file mode 100644 index 00000000000..a70141edc29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime.rs @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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. + +// compile-flags: -Z continue-parse-after-error + +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, 'static +>; + //~^ at least one non-builtin trait is required for an object type + let _: S<'static, 'static>; + //~^ ERROR wrong number of lifetime parameters: expected 1, found 2 + //~| ERROR wrong number of type arguments: expected 1, found 0 + let _: S<'static +, 'static>; + //~^ ERROR lifetime parameters must be declared prior to type parameters + //~| ERROR at least one non-builtin trait is required for an object type +} diff --git a/src/test/ui/compile-fail-migration/trait-object-vs-lifetime.stderr b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime.stderr new file mode 100644 index 00000000000..d875e7d4845 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-object-vs-lifetime.stderr @@ -0,0 +1,34 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/trait-object-vs-lifetime.rs:26:25 + | +LL | let _: S<'static +, 'static>; + | ^^^^^^^ + +error[E0224]: at least one non-builtin trait is required for an object type + --> $DIR/trait-object-vs-lifetime.rs:21:23 + | +LL | let _: S<'static, 'static +>; + | ^^^^^^^^^ + +error[E0107]: wrong number of lifetime parameters: expected 1, found 2 + --> $DIR/trait-object-vs-lifetime.rs:23:12 + | +LL | let _: S<'static, 'static>; + | ^^^^^^^^^^^^^^^^^^^ unexpected lifetime parameter + +error[E0243]: wrong number of type arguments: expected 1, found 0 + --> $DIR/trait-object-vs-lifetime.rs:23:12 + | +LL | let _: S<'static, 'static>; + | ^^^^^^^^^^^^^^^^^^^ expected 1 type argument + +error[E0224]: at least one non-builtin trait is required for an object type + --> $DIR/trait-object-vs-lifetime.rs:26:14 + | +LL | let _: S<'static +, 'static>; + | ^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0107, E0224, E0243. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/compile-fail-migration/trait-or-new-type-instead.rs b/src/test/ui/compile-fail-migration/trait-or-new-type-instead.rs new file mode 100644 index 00000000000..b1e4d06affe --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-or-new-type-instead.rs @@ -0,0 +1,16 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +impl Option { +//~^ ERROR cannot define inherent `impl` for a type outside of the crate where the type is defined + pub fn foo(&self) { } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/trait-or-new-type-instead.stderr b/src/test/ui/compile-fail-migration/trait-or-new-type-instead.stderr new file mode 100644 index 00000000000..1b4d173c312 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-or-new-type-instead.stderr @@ -0,0 +1,14 @@ +error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined + --> $DIR/trait-or-new-type-instead.rs:11:1 + | +LL | / impl Option { +LL | | //~^ ERROR cannot define inherent `impl` for a type outside of the crate where the type is defined +LL | | pub fn foo(&self) { } +LL | | } + | |_^ impl for type defined outside of crate. + | + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0116`. diff --git a/src/test/ui/compile-fail-migration/trait-privacy.rs b/src/test/ui/compile-fail-migration/trait-privacy.rs new file mode 100644 index 00000000000..5f9e8ba6c0a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-privacy.rs @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs, get_type_id)] +#![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.get_type_id(); // Regression test for #21670 +} + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/trait-privacy.stderr b/src/test/ui/compile-fail-migration/trait-privacy.stderr new file mode 100644 index 00000000000..d38e869df8f --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-privacy.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/trait-privacy.rs:35:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.rs b/src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.rs new file mode 100644 index 00000000000..1f57c4cf93a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #12402 Operator overloading only considers the method name, not which trait is implemented + +trait MyMul { + fn mul(&self, rhs: &Rhs) -> Res; +} + +fn foo>(a: &T, b: f64) -> f64 { + a * b //~ ERROR binary operation `*` cannot be applied to type `&T` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.stderr b/src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.stderr new file mode 100644 index 00000000000..ba20eae56c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-resolution-in-overloaded-op.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `*` cannot be applied to type `&T` + --> $DIR/trait-resolution-in-overloaded-op.rs:18:5 + | +LL | a * b //~ ERROR binary operation `*` cannot be applied to type `&T` + | ^^^^^ + | + = note: an implementation of `std::ops::Mul` might be missing for `&T` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/trait-safety-inherent-impl.rs b/src/test/ui/compile-fail-migration/trait-safety-inherent-impl.rs new file mode 100644 index 00000000000..059fdc100c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-safety-inherent-impl.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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/compile-fail-migration/trait-safety-inherent-impl.stderr b/src/test/ui/compile-fail-migration/trait-safety-inherent-impl.stderr new file mode 100644 index 00000000000..5154a591c4c --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-safety-inherent-impl.stderr @@ -0,0 +1,11 @@ +error[E0197]: inherent impls cannot be unsafe + --> $DIR/trait-safety-inherent-impl.rs:15:1 + | +LL | / unsafe impl SomeStruct { //~ ERROR inherent impls cannot be unsafe +LL | | fn foo(self) { } +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0197`. diff --git a/src/test/ui/compile-fail-migration/trait-safety-trait-impl-cc.rs b/src/test/ui/compile-fail-migration/trait-safety-trait-impl-cc.rs new file mode 100644 index 00000000000..f30c8f521bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-safety-trait-impl-cc.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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/compile-fail-migration/trait-safety-trait-impl-cc.stderr b/src/test/ui/compile-fail-migration/trait-safety-trait-impl-cc.stderr new file mode 100644 index 00000000000..0611d2da02a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-safety-trait-impl-cc.stderr @@ -0,0 +1,13 @@ +error[E0200]: the trait `lib::Foo` requires an `unsafe impl` declaration + --> $DIR/trait-safety-trait-impl-cc.rs:19:1 + | +LL | / impl lib::Foo for Bar { //~ ERROR requires an `unsafe impl` declaration +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/compile-fail-migration/trait-safety-trait-impl.rs b/src/test/ui/compile-fail-migration/trait-safety-trait-impl.rs new file mode 100644 index 00000000000..e846b660c2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-safety-trait-impl.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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/compile-fail-migration/trait-safety-trait-impl.stderr b/src/test/ui/compile-fail-migration/trait-safety-trait-impl.stderr new file mode 100644 index 00000000000..137e9f7c043 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-safety-trait-impl.stderr @@ -0,0 +1,16 @@ +error[E0200]: the trait `UnsafeTrait` requires an `unsafe impl` declaration + --> $DIR/trait-safety-trait-impl.rs:24:1 + | +LL | impl UnsafeTrait for u16 { } //~ ERROR requires an `unsafe impl` declaration + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0199]: implementing the trait `SafeTrait` is not unsafe + --> $DIR/trait-safety-trait-impl.rs:26:1 + | +LL | unsafe impl SafeTrait for u32 { } //~ ERROR the trait `SafeTrait` is not unsafe + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0199, E0200. +For more information about an error, try `rustc --explain E0199`. diff --git a/src/test/ui/compile-fail-migration/trait-static-method-generic-inference.rs b/src/test/ui/compile-fail-migration/trait-static-method-generic-inference.rs new file mode 100644 index 00000000000..0e357d9d4d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-static-method-generic-inference.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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 { + fn new() -> T; + fn dummy(&self) { } + } + + pub struct Foo { + dummy: (), + } + + impl HasNew for Foo { + fn new() -> Foo { + Foo { dummy: () } + } + } +} + +pub fn foo() { + let _f: base::Foo = base::HasNew::new(); + //~^ ERROR type annotations required +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/trait-static-method-generic-inference.stderr b/src/test/ui/compile-fail-migration/trait-static-method-generic-inference.stderr new file mode 100644 index 00000000000..a903bd998f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-static-method-generic-inference.stderr @@ -0,0 +1,15 @@ +error[E0283]: type annotations required: cannot resolve `_: base::HasNew` + --> $DIR/trait-static-method-generic-inference.rs:34:25 + | +LL | let _f: base::Foo = base::HasNew::new(); + | ^^^^^^^^^^^^^^^^^ + | +note: required by `base::HasNew::new` + --> $DIR/trait-static-method-generic-inference.rs:18:9 + | +LL | fn new() -> T; + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/src/test/ui/compile-fail-migration/trait-test-2.rs b/src/test/ui/compile-fail-migration/trait-test-2.rs new file mode 100644 index 00000000000..b08aab6da85 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-test-2.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +trait bar { fn dup(&self) -> Self; fn blah(&self); } +impl bar for i32 { fn dup(&self) -> i32 { *self } fn blah(&self) {} } +impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah(&self) {} } + +fn main() { + 10.dup::(); //~ ERROR expected at most 0 type parameters, found 1 type parameter + 10.blah::(); //~ ERROR expected at most 1 type parameter, found 2 type parameters + (box 10 as Box).dup(); + //~^ ERROR E0038 + //~| ERROR E0038 + //~| ERROR E0277 +} diff --git a/src/test/ui/compile-fail-migration/trait-test-2.stderr b/src/test/ui/compile-fail-migration/trait-test-2.stderr new file mode 100644 index 00000000000..58e91447963 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-test-2.stderr @@ -0,0 +1,41 @@ +error[E0087]: too many type parameters provided: expected at most 0 type parameters, found 1 type parameter + --> $DIR/trait-test-2.rs:18:14 + | +LL | 10.dup::(); //~ ERROR expected at most 0 type parameters, found 1 type parameter + | ^^^ expected 0 type parameters + +error[E0087]: too many type parameters provided: expected at most 1 type parameter, found 2 type parameters + --> $DIR/trait-test-2.rs:19:20 + | +LL | 10.blah::(); //~ ERROR expected at most 1 type parameter, found 2 type parameters + | ^^^ expected 1 type parameter + +error[E0277]: the trait bound `dyn bar: bar` is not satisfied + --> $DIR/trait-test-2.rs:20:26 + | +LL | (box 10 as Box).dup(); + | ^^^ the trait `bar` is not implemented for `dyn bar` + +error[E0038]: the trait `bar` cannot be made into an object + --> $DIR/trait-test-2.rs:20:16 + | +LL | (box 10 as Box).dup(); + | ^^^^^^^^ the trait `bar` cannot be made into an object + | + = note: method `dup` references the `Self` type in its arguments or return type + = note: method `blah` has generic type parameters + +error[E0038]: the trait `bar` cannot be made into an object + --> $DIR/trait-test-2.rs:20:6 + | +LL | (box 10 as Box).dup(); + | ^^^^^^ the trait `bar` cannot be made into an object + | + = note: method `dup` references the `Self` type in its arguments or return type + = note: method `blah` has generic type parameters + = note: required because of the requirements on the impl of `std::ops::CoerceUnsized>` for `std::boxed::Box<{integer}>` + +error: aborting due to 5 previous errors + +Some errors occurred: E0038, E0087, E0277. +For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/trait-test.rs b/src/test/ui/compile-fail-migration/trait-test.rs new file mode 100644 index 00000000000..d53e353d9d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-test.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait foo { fn foo(&self); } + +impl isize for usize { fn foo(&self) {} } //~ ERROR trait + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/trait-test.stderr b/src/test/ui/compile-fail-migration/trait-test.stderr new file mode 100644 index 00000000000..89dbb3dee87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/trait-test.stderr @@ -0,0 +1,9 @@ +error[E0404]: expected trait, found builtin type `isize` + --> $DIR/trait-test.rs:13:6 + | +LL | impl isize for usize { fn foo(&self) {} } //~ ERROR trait + | ^^^^^ 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/compile-fail-migration/traits-assoc-type-in-supertrait-bad.rs b/src/test/ui/compile-fail-migration/traits-assoc-type-in-supertrait-bad.rs new file mode 100644 index 00000000000..971869ba85b --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-assoc-type-in-supertrait-bad.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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::Key> { + type Key; +} + +impl Foo for IntoIter { //~ ERROR type mismatch + type Key = u32; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/traits-assoc-type-in-supertrait-bad.stderr b/src/test/ui/compile-fail-migration/traits-assoc-type-in-supertrait-bad.stderr new file mode 100644 index 00000000000..bf5e8a77f83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-assoc-type-in-supertrait-bad.stderr @@ -0,0 +1,12 @@ +error[E0271]: type mismatch resolving ` as std::iter::Iterator>::Item == u32` + --> $DIR/traits-assoc-type-in-supertrait-bad.rs:21:6 + | +LL | impl Foo for IntoIter { //~ ERROR type mismatch + | ^^^ expected i32, found u32 + | + = note: expected type `i32` + found type `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.rs b/src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.rs new file mode 100644 index 00000000000..777746a189c --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #33344, initial version. This example allowed +// arbitrary trait bounds to be synthesized. + +trait Tweedledum: IntoIterator {} +trait Tweedledee: IntoIterator {} + +impl Tweedledee for T {} +impl Tweedledum for T {} + +trait Combo: IntoIterator {} +impl Combo for T {} + +fn is_ee(t: T) { + t.into_iter(); +} + +fn main() { + is_ee(4); + //~^ ERROR overflow evaluating the requirement `{integer}: Tweedle +} diff --git a/src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.stderr b/src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.stderr new file mode 100644 index 00000000000..7eabb00935c --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-simultaneous.stderr @@ -0,0 +1,16 @@ +error[E0275]: overflow evaluating the requirement `{integer}: Tweedledum` + --> $DIR/traits-inductive-overflow-simultaneous.rs:28:5 + | +LL | is_ee(4); + | ^^^^^ + | + = note: required because of the requirements on the impl of `Combo` for `{integer}` +note: required by `is_ee` + --> $DIR/traits-inductive-overflow-simultaneous.rs:23:1 + | +LL | fn is_ee(t: T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.rs b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.rs new file mode 100644 index 00000000000..59d5dc6c58b --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// OIBIT-based version of #29859, supertrait version. Test that using +// a simple OIBIT `..` impl alone still doesn't allow arbitrary bounds +// to be synthesized. + +#![feature(optin_builtin_traits)] + +auto trait Magic: Copy {} //~ ERROR E0568 + +fn copy(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/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.stderr b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.stderr new file mode 100644 index 00000000000..5438cc54dc6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait-oibit.stderr @@ -0,0 +1,23 @@ +error[E0568]: auto traits cannot have super traits + --> $DIR/traits-inductive-overflow-supertrait-oibit.rs:17:1 + | +LL | auto trait Magic: Copy {} //~ ERROR E0568 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `NoClone: std::marker::Copy` is not satisfied + --> $DIR/traits-inductive-overflow-supertrait-oibit.rs:25:18 + | +LL | let (a, b) = copy(NoClone); //~ ERROR + | ^^^^ the trait `std::marker::Copy` is not implemented for `NoClone` + | + = note: required because of the requirements on the impl of `Magic` for `NoClone` +note: required by `copy` + --> $DIR/traits-inductive-overflow-supertrait-oibit.rs:19:1 + | +LL | fn copy(x: T) -> (T, T) { (x, x) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0277, E0568. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait.rs b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait.rs new file mode 100644 index 00000000000..c717ae9639f --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #29859, supertrait version. This example +// allowed arbitrary trait bounds to be synthesized. + +trait Magic: Copy {} +impl Magic for T {} + +fn copy(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/compile-fail-migration/traits-inductive-overflow-supertrait.stderr b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait.stderr new file mode 100644 index 00000000000..6f0929d696f --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-supertrait.stderr @@ -0,0 +1,16 @@ +error[E0275]: overflow evaluating the requirement `NoClone: Magic` + --> $DIR/traits-inductive-overflow-supertrait.rs:23:18 + | +LL | let (a, b) = copy(NoClone); //~ ERROR E0275 + | ^^^^ + | + = note: required because of the requirements on the impl of `Magic` for `NoClone` +note: required by `copy` + --> $DIR/traits-inductive-overflow-supertrait.rs:17:1 + | +LL | fn copy(x: T) -> (T, T) { (x, x) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.rs b/src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.rs new file mode 100644 index 00000000000..c622dca2b4d --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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 Magic for T { + type X = Self; +} + +fn check() {} + +fn wizard() { check::<::X>(); } + +fn main() { + wizard::<*mut ()>(); //~ ERROR E0275 + // check::<*mut ()>(); +} diff --git a/src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.stderr b/src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.stderr new file mode 100644 index 00000000000..900ed1b2e8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-inductive-overflow-two-traits.stderr @@ -0,0 +1,15 @@ +error[E0275]: overflow evaluating the requirement `*mut (): Magic` + --> $DIR/traits-inductive-overflow-two-traits.rs:29:5 + | +LL | wizard::<*mut ()>(); //~ ERROR E0275 + | ^^^^^^^^^^^^^^^^^ + | +note: required by `wizard` + --> $DIR/traits-inductive-overflow-two-traits.rs:26:1 + | +LL | fn wizard() { check::<::X>(); } + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/src/test/ui/compile-fail-migration/traits-issue-23003-overflow.rs b/src/test/ui/compile-fail-migration/traits-issue-23003-overflow.rs new file mode 100644 index 00000000000..80d2884ee60 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-issue-23003-overflow.rs @@ -0,0 +1,39 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +use std::marker::PhantomData; + +trait Async { + type Cancel; +} + +struct Receipt { + marker: PhantomData, +} + +struct Complete { + core: Option, +} + +impl Async for Complete { + type Cancel = Receipt>>; +} + +fn foo(_: Receipt>) { } + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/traits-issue-23003-overflow.stderr b/src/test/ui/compile-fail-migration/traits-issue-23003-overflow.stderr new file mode 100644 index 00000000000..3c26e426a4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-issue-23003-overflow.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/traits-issue-23003-overflow.rs:39:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/traits-multidispatch-bad.rs b/src/test/ui/compile-fail-migration/traits-multidispatch-bad.rs new file mode 100644 index 00000000000..392eccf0f31 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-multidispatch-bad.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we detect an illegal combination of types. + +trait Convert { + fn convert(&self) -> Target; +} + +impl Convert for i32 { + fn convert(&self) -> u32 { + *self as u32 + } +} + +fn test(_: T, _: U) +where T : Convert +{ +} + +fn a() { + test(22i32, 44i32); //~ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/traits-multidispatch-bad.stderr b/src/test/ui/compile-fail-migration/traits-multidispatch-bad.stderr new file mode 100644 index 00000000000..6068edea585 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-multidispatch-bad.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/traits-multidispatch-bad.rs:29:17 + | +LL | test(22i32, 44i32); //~ ERROR mismatched types + | ^^^^^ expected u32, found i32 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/traits-negative-impls.rs b/src/test/ui/compile-fail-migration/traits-negative-impls.rs new file mode 100644 index 00000000000..a272686c535 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-negative-impls.rs @@ -0,0 +1,78 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The dummy functions are used to avoid adding new cfail files. +// What happens is that the compiler attempts to squash duplicates and some +// errors are not reported. This way, we make sure that, for each function, different +// typeck phases are involved and all errors are reported. + +#![feature(optin_builtin_traits)] + +use std::marker::Send; + +struct Outer(T); + +struct Outer2(T); + +unsafe impl Sync for Outer2 {} + +fn is_send(_: T) {} +fn is_sync(_: T) {} + +fn dummy() { + struct TestType; + impl !Send for TestType {} + + Outer(TestType); + //~^ ERROR `dummy::TestType` cannot be sent between threads safely + //~| ERROR `dummy::TestType` cannot be sent between threads safely +} + +fn dummy1b() { + struct TestType; + impl !Send for TestType {} + + is_send(TestType); + //~^ ERROR `dummy1b::TestType` cannot be sent between threads safely +} + +fn dummy1c() { + struct TestType; + impl !Send for TestType {} + + is_send((8, TestType)); + //~^ ERROR `dummy1c::TestType` cannot be sent between threads safely +} + +fn dummy2() { + struct TestType; + impl !Send for TestType {} + + is_send(Box::new(TestType)); + //~^ ERROR `dummy2::TestType` cannot be sent between threads safely +} + +fn dummy3() { + struct TestType; + impl !Send for TestType {} + + is_send(Box::new(Outer2(TestType))); + //~^ ERROR `dummy3::TestType` cannot be sent between threads safely +} + +fn main() { + struct TestType; + impl !Send for TestType {} + + // This will complain about a missing Send impl because `Sync` is implement *just* + // for T that are `Send`. Look at #20366 and #19950 + is_sync(Outer2(TestType)); + //~^ ERROR `main::TestType` cannot be sent between threads safely +} diff --git a/src/test/ui/compile-fail-migration/traits-negative-impls.stderr b/src/test/ui/compile-fail-migration/traits-negative-impls.stderr new file mode 100644 index 00000000000..0d10f4863d3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-negative-impls.stderr @@ -0,0 +1,101 @@ +error[E0277]: `dummy::TestType` cannot be sent between threads safely + --> $DIR/traits-negative-impls.rs:33:5 + | +LL | Outer(TestType); + | ^^^^^ `dummy::TestType` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `dummy::TestType` +note: required by `Outer` + --> $DIR/traits-negative-impls.rs:20:1 + | +LL | struct Outer(T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `dummy::TestType` cannot be sent between threads safely + --> $DIR/traits-negative-impls.rs:33:5 + | +LL | Outer(TestType); + | ^^^^^^^^^^^^^^^ `dummy::TestType` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `dummy::TestType` +note: required by `Outer` + --> $DIR/traits-negative-impls.rs:20:1 + | +LL | struct Outer(T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `dummy1b::TestType` cannot be sent between threads safely + --> $DIR/traits-negative-impls.rs:42:5 + | +LL | is_send(TestType); + | ^^^^^^^ `dummy1b::TestType` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `dummy1b::TestType` +note: required by `is_send` + --> $DIR/traits-negative-impls.rs:26:1 + | +LL | fn is_send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `dummy1c::TestType` cannot be sent between threads safely + --> $DIR/traits-negative-impls.rs:50:5 + | +LL | is_send((8, TestType)); + | ^^^^^^^ `dummy1c::TestType` cannot be sent between threads safely + | + = help: within `({integer}, dummy1c::TestType)`, the trait `std::marker::Send` is not implemented for `dummy1c::TestType` + = note: required because it appears within the type `({integer}, dummy1c::TestType)` +note: required by `is_send` + --> $DIR/traits-negative-impls.rs:26:1 + | +LL | fn is_send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `dummy2::TestType` cannot be sent between threads safely + --> $DIR/traits-negative-impls.rs:58:5 + | +LL | is_send(Box::new(TestType)); + | ^^^^^^^ `dummy2::TestType` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `dummy2::TestType` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique` + = note: required because it appears within the type `std::boxed::Box` +note: required by `is_send` + --> $DIR/traits-negative-impls.rs:26:1 + | +LL | fn is_send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `dummy3::TestType` cannot be sent between threads safely + --> $DIR/traits-negative-impls.rs:66:5 + | +LL | is_send(Box::new(Outer2(TestType))); + | ^^^^^^^ `dummy3::TestType` cannot be sent between threads safely + | + = help: within `Outer2`, the trait `std::marker::Send` is not implemented for `dummy3::TestType` + = note: required because it appears within the type `Outer2` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique>` + = note: required because it appears within the type `std::boxed::Box>` +note: required by `is_send` + --> $DIR/traits-negative-impls.rs:26:1 + | +LL | fn is_send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `main::TestType` cannot be sent between threads safely + --> $DIR/traits-negative-impls.rs:76:5 + | +LL | is_sync(Outer2(TestType)); + | ^^^^^^^ `main::TestType` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `main::TestType` + = note: required because of the requirements on the impl of `std::marker::Sync` for `Outer2` +note: required by `is_sync` + --> $DIR/traits-negative-impls.rs:27:1 + | +LL | fn is_sync(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.rs b/src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.rs new file mode 100644 index 00000000000..559871af72e --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.rs @@ -0,0 +1,53 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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 { + fn same_as(&self, t: T) -> bool; +} + +trait CompareToInts : CompareTo + CompareTo { +} + +impl CompareTo for i64 { + fn same_as(&self, t: i64) -> bool { *self == t } +} + +impl CompareTo for i64 { + fn same_as(&self, t: u64) -> bool { *self == (t as i64) } +} + +impl CompareToInts for i64 { } + +fn with_obj(c: &CompareToInts) -> bool { + c.same_as(22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied +} + +fn with_trait(c: &C) -> bool { + c.same_as(22) //~ ERROR `C: CompareTo` is not satisfied +} + +fn with_ufcs1(c: &C) -> bool { + CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied +} + +fn with_ufcs2(c: &C) -> bool { + CompareTo::same_as(c, 22) //~ ERROR `C: CompareTo` is not satisfied +} + +fn main() { + assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64: CompareTo` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.stderr b/src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.stderr new file mode 100644 index 00000000000..87d3c8117d3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/traits-repeated-supertrait-ambig.stderr @@ -0,0 +1,52 @@ +error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfied + --> $DIR/traits-repeated-supertrait-ambig.rs:36:7 + | +LL | c.same_as(22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied + | ^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` + +error[E0277]: the trait bound `C: CompareTo` is not satisfied + --> $DIR/traits-repeated-supertrait-ambig.rs:40:7 + | +LL | c.same_as(22) //~ ERROR `C: CompareTo` is not satisfied + | ^^^^^^^ the trait `CompareTo` is not implemented for `C` + | + = help: consider adding a `where C: CompareTo` bound + +error[E0277]: the trait bound `dyn CompareToInts: CompareTo` is not satisfied + --> $DIR/traits-repeated-supertrait-ambig.rs:44:5 + | +LL | CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `dyn CompareToInts` + | +note: required by `CompareTo::same_as` + --> $DIR/traits-repeated-supertrait-ambig.rs:19:5 + | +LL | fn same_as(&self, t: T) -> bool; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `C: CompareTo` is not satisfied + --> $DIR/traits-repeated-supertrait-ambig.rs:48:5 + | +LL | CompareTo::same_as(c, 22) //~ ERROR `C: CompareTo` is not satisfied + | ^^^^^^^^^^^^^^^^^^ the trait `CompareTo` is not implemented for `C` + | + = help: consider adding a `where C: CompareTo` bound +note: required by `CompareTo::same_as` + --> $DIR/traits-repeated-supertrait-ambig.rs:19:5 + | +LL | fn same_as(&self, t: T) -> bool; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `i64: CompareTo` is not satisfied + --> $DIR/traits-repeated-supertrait-ambig.rs:52:23 + | +LL | assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64: CompareTo` is not satisfied + | ^^^^^^^ the trait `CompareTo` is not implemented for `i64` + | + = help: the following implementations were found: + > + > + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/transmute-different-sizes.rs b/src/test/ui/compile-fail-migration/transmute-different-sizes.rs new file mode 100644 index 00000000000..113e2ed4c80 --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-different-sizes.rs @@ -0,0 +1,39 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that `transmute` cannot be called on types of different size. + +#![allow(warnings)] +#![feature(specialization)] + +use std::mem::transmute; + +unsafe fn f() { + let _: i8 = transmute(16i16); + //~^ ERROR transmute called with types of different sizes +} + +unsafe fn g(x: &T) { + let _: i8 = transmute(x); + //~^ ERROR transmute called with types of different sizes +} + +trait Specializable { type Output; } + +impl Specializable for T { + default type Output = u16; +} + +unsafe fn specializable(x: u16) -> ::Output { + transmute(x) + //~^ ERROR transmute called with types of different sizes +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/transmute-different-sizes.stderr b/src/test/ui/compile-fail-migration/transmute-different-sizes.stderr new file mode 100644 index 00000000000..e33e0e93fd1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-different-sizes.stderr @@ -0,0 +1,30 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-different-sizes.rs:19:17 + | +LL | let _: i8 = transmute(16i16); + | ^^^^^^^^^ + | + = note: source type: i16 (16 bits) + = note: target type: i8 (8 bits) + +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-different-sizes.rs:24:17 + | +LL | let _: i8 = transmute(x); + | ^^^^^^^^^ + | + = note: source type: &T (64 bits) + = note: target type: i8 (8 bits) + +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-different-sizes.rs:35:5 + | +LL | transmute(x) + | ^^^^^^^^^ + | + = note: source type: u16 (16 bits) + = note: target type: ::Output (this type's size can vary) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/compile-fail-migration/transmute-fat-pointers.rs b/src/test/ui/compile-fail-migration/transmute-fat-pointers.rs new file mode 100644 index 00000000000..59027fc7787 --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-fat-pointers.rs @@ -0,0 +1,41 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that are conservative around thin/fat pointer mismatches. + +#![allow(dead_code)] + +use std::mem::transmute; + +fn a(x: &[T]) -> &U { + unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes +} + +fn b(x: &T) -> &U { + unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes +} + +fn c(x: &T) -> &U { + unsafe { transmute(x) } +} + +fn d(x: &[T]) -> &[U] { + unsafe { transmute(x) } +} + +fn e(x: &T) -> &U { + unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes +} + +fn f(x: &T) -> &U { + unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/transmute-fat-pointers.stderr b/src/test/ui/compile-fail-migration/transmute-fat-pointers.stderr new file mode 100644 index 00000000000..e5d9459e3ec --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-fat-pointers.stderr @@ -0,0 +1,39 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-fat-pointers.rs:18:14 + | +LL | unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes + | ^^^^^^^^^ + | + = note: source type: &[T] (128 bits) + = note: target type: &U (pointer to U) + +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-fat-pointers.rs:22:14 + | +LL | unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes + | ^^^^^^^^^ + | + = note: source type: &T (pointer to T) + = note: target type: &U (pointer to U) + +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-fat-pointers.rs:34:14 + | +LL | unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes + | ^^^^^^^^^ + | + = note: source type: &T (pointer to T) + = note: target type: &U (64 bits) + +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-fat-pointers.rs:38:14 + | +LL | unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes + | ^^^^^^^^^ + | + = note: source type: &T (64 bits) + = note: target type: &U (pointer to U) + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/compile-fail-migration/transmute-impl.rs b/src/test/ui/compile-fail-migration/transmute-impl.rs new file mode 100644 index 00000000000..2f8f9e46e1a --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-impl.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that are conservative around thin/fat pointer mismatches. + +#![allow(dead_code)] + +use std::mem::transmute; + +struct Foo { + t: Box +} + +impl Foo { + fn m(x: &T) -> &isize where T : Sized { + // OK here, because T : Sized is in scope. + unsafe { transmute(x) } + } + + fn n(x: &T) -> &isize { + // Not OK here, because T : Sized is not in scope. + unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/transmute-impl.stderr b/src/test/ui/compile-fail-migration/transmute-impl.stderr new file mode 100644 index 00000000000..f435e28976b --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-impl.stderr @@ -0,0 +1,12 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/transmute-impl.rs:29:18 + | +LL | unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes + | ^^^^^^^^^ + | + = note: source type: &T (pointer to T) + = note: target type: &isize (64 bits) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0512`. diff --git a/src/test/ui/compile-fail-migration/transmute-imut-to-mut.rs b/src/test/ui/compile-fail-migration/transmute-imut-to-mut.rs new file mode 100644 index 00000000000..62db4c5d366 --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-imut-to-mut.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that transmuting from &T to &mut T is Undefined Behavior. + +use std::mem::transmute; + +fn main() { + let _a: &mut u8 = unsafe { transmute(&1u8) }; + //~^ ERROR mutating transmuted &mut T from &T may cause undefined behavior +} + diff --git a/src/test/ui/compile-fail-migration/transmute-imut-to-mut.stderr b/src/test/ui/compile-fail-migration/transmute-imut-to-mut.stderr new file mode 100644 index 00000000000..4434e35af7f --- /dev/null +++ b/src/test/ui/compile-fail-migration/transmute-imut-to-mut.stderr @@ -0,0 +1,10 @@ +error: mutating transmuted &mut T from &T may cause undefined behavior, consider instead using an UnsafeCell + --> $DIR/transmute-imut-to-mut.rs:16:32 + | +LL | let _a: &mut u8 = unsafe { transmute(&1u8) }; + | ^^^^^^^^^ + | + = note: #[deny(mutable_transmutes)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/trivial_casts.rs b/src/test/ui/compile-fail-migration/trivial_casts.rs new file mode 100644 index 00000000000..3f2bd2ffabf --- /dev/null +++ b/src/test/ui/compile-fail-migration/trivial_casts.rs @@ -0,0 +1,95 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test the trivial_casts and trivial_numeric_casts lints. For each error we also +// check that the cast can be done using just coercion. + +#![deny(trivial_casts, trivial_numeric_casts)] + +trait Foo { + fn foo(&self) {} +} + +pub struct Bar; + +impl Foo for Bar {} + +pub fn main() { + // Numeric + let _ = 42_i32 as i32; //~ ERROR trivial numeric cast: `i32` as `i32` + let _: i32 = 42_i32; + + let _ = 42_u8 as u8; //~ ERROR trivial numeric cast: `u8` as `u8` + let _: u8 = 42_u8; + + // & to * pointers + let x: &u32 = &42; + let _ = x as *const u32; //~ERROR trivial cast: `&u32` as `*const u32` + let _: *const u32 = x; + + let x: &mut u32 = &mut 42; + let _ = x as *mut u32; //~ERROR trivial cast: `&mut u32` as `*mut u32` + let _: *mut u32 = x; + + // unsize array + let x: &[u32; 3] = &[42, 43, 44]; + let _ = x as &[u32]; //~ERROR trivial cast: `&[u32; 3]` as `&[u32]` + let _ = x as *const [u32]; //~ERROR trivial cast: `&[u32; 3]` as `*const [u32]` + let _: &[u32] = x; + let _: *const [u32] = x; + + let x: &mut [u32; 3] = &mut [42, 43, 44]; + let _ = x as &mut [u32]; //~ERROR trivial cast: `&mut [u32; 3]` as `&mut [u32]` + let _ = x as *mut [u32]; //~ERROR trivial cast: `&mut [u32; 3]` as `*mut [u32]` + let _: &mut [u32] = x; + let _: *mut [u32] = x; + + let x: Box<[u32; 3]> = Box::new([42, 43, 44]); + let _ = x as Box<[u32]>; + //~^ ERROR trivial cast: `std::boxed::Box<[u32; 3]>` as `std::boxed::Box<[u32]>` + let x: Box<[u32; 3]> = Box::new([42, 43, 44]); + let _: Box<[u32]> = x; + + // unsize trait + let x: &Bar = &Bar; + let _ = x as &Foo; //~ERROR trivial cast: `&Bar` as `&dyn Foo` + let _ = x as *const Foo; //~ERROR trivial cast: `&Bar` as `*const dyn Foo` + let _: &Foo = x; + let _: *const Foo = x; + + let x: &mut Bar = &mut Bar; + let _ = x as &mut Foo; //~ERROR trivial cast: `&mut Bar` as `&mut dyn Foo` + let _ = x as *mut Foo; //~ERROR trivial cast: `&mut Bar` as `*mut dyn Foo` + let _: &mut Foo = x; + let _: *mut Foo = x; + + let x: Box = Box::new(Bar); + let _ = x as Box; //~ERROR `std::boxed::Box` as `std::boxed::Box` + let x: Box = Box::new(Bar); + let _: Box = x; + + // functions + fn baz(_x: i32) {} + let _ = &baz as &Fn(i32); //~ERROR `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` + let _: &Fn(i32) = &baz; + let x = |_x: i32| {}; + let _ = &x as &Fn(i32); //~ERROR trivial cast + let _: &Fn(i32) = &x; +} + +// subtyping +pub fn test_subtyping<'a, 'b: 'a>(a: &'a Bar, b: &'b Bar) { + let _ = a as &'a Bar; //~ERROR trivial cast + let _: &'a Bar = a; + let _ = b as &'a Bar; //~ERROR trivial cast + let _: &'a Bar = b; + let _ = b as &'b Bar; //~ERROR trivial cast + let _: &'b Bar = b; +} diff --git a/src/test/ui/compile-fail-migration/trivial_casts.stderr b/src/test/ui/compile-fail-migration/trivial_casts.stderr new file mode 100644 index 00000000000..dc2a6a058bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/trivial_casts.stderr @@ -0,0 +1,164 @@ +error: trivial numeric cast: `i32` as `i32` + --> $DIR/trivial_casts.rs:26:13 + | +LL | let _ = 42_i32 as i32; //~ ERROR trivial numeric cast: `i32` as `i32` + | ^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/trivial_casts.rs:14:24 + | +LL | #![deny(trivial_casts, trivial_numeric_casts)] + | ^^^^^^^^^^^^^^^^^^^^^ + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial numeric cast: `u8` as `u8` + --> $DIR/trivial_casts.rs:29:13 + | +LL | let _ = 42_u8 as u8; //~ ERROR trivial numeric cast: `u8` as `u8` + | ^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&u32` as `*const u32` + --> $DIR/trivial_casts.rs:34:13 + | +LL | let _ = x as *const u32; //~ERROR trivial cast: `&u32` as `*const u32` + | ^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/trivial_casts.rs:14:9 + | +LL | #![deny(trivial_casts, trivial_numeric_casts)] + | ^^^^^^^^^^^^^ + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&mut u32` as `*mut u32` + --> $DIR/trivial_casts.rs:38:13 + | +LL | let _ = x as *mut u32; //~ERROR trivial cast: `&mut u32` as `*mut u32` + | ^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&[u32; 3]` as `&[u32]` + --> $DIR/trivial_casts.rs:43:13 + | +LL | let _ = x as &[u32]; //~ERROR trivial cast: `&[u32; 3]` as `&[u32]` + | ^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&[u32; 3]` as `*const [u32]` + --> $DIR/trivial_casts.rs:44:13 + | +LL | let _ = x as *const [u32]; //~ERROR trivial cast: `&[u32; 3]` as `*const [u32]` + | ^^^^^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&mut [u32; 3]` as `&mut [u32]` + --> $DIR/trivial_casts.rs:49:13 + | +LL | let _ = x as &mut [u32]; //~ERROR trivial cast: `&mut [u32; 3]` as `&mut [u32]` + | ^^^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&mut [u32; 3]` as `*mut [u32]` + --> $DIR/trivial_casts.rs:50:13 + | +LL | let _ = x as *mut [u32]; //~ERROR trivial cast: `&mut [u32; 3]` as `*mut [u32]` + | ^^^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `std::boxed::Box<[u32; 3]>` as `std::boxed::Box<[u32]>` + --> $DIR/trivial_casts.rs:55:13 + | +LL | let _ = x as Box<[u32]>; + | ^^^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&Bar` as `&dyn Foo` + --> $DIR/trivial_casts.rs:62:13 + | +LL | let _ = x as &Foo; //~ERROR trivial cast: `&Bar` as `&dyn Foo` + | ^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&Bar` as `*const dyn Foo` + --> $DIR/trivial_casts.rs:63:13 + | +LL | let _ = x as *const Foo; //~ERROR trivial cast: `&Bar` as `*const dyn Foo` + | ^^^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&mut Bar` as `&mut dyn Foo` + --> $DIR/trivial_casts.rs:68:13 + | +LL | let _ = x as &mut Foo; //~ERROR trivial cast: `&mut Bar` as `&mut dyn Foo` + | ^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&mut Bar` as `*mut dyn Foo` + --> $DIR/trivial_casts.rs:69:13 + | +LL | let _ = x as *mut Foo; //~ERROR trivial cast: `&mut Bar` as `*mut dyn Foo` + | ^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `std::boxed::Box` as `std::boxed::Box` + --> $DIR/trivial_casts.rs:74:13 + | +LL | let _ = x as Box; //~ERROR `std::boxed::Box` as `std::boxed::Box` + | ^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` + --> $DIR/trivial_casts.rs:80:13 + | +LL | let _ = &baz as &Fn(i32); //~ERROR `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` + | ^^^^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&[closure@$DIR/trivial_casts.rs:82:13: 82:25]` as `&dyn std::ops::Fn(i32)` + --> $DIR/trivial_casts.rs:83:13 + | +LL | let _ = &x as &Fn(i32); //~ERROR trivial cast + | ^^^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&'a Bar` as `&'a Bar` + --> $DIR/trivial_casts.rs:89:13 + | +LL | let _ = a as &'a Bar; //~ERROR trivial cast + | ^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&'b Bar` as `&'a Bar` + --> $DIR/trivial_casts.rs:91:13 + | +LL | let _ = b as &'a Bar; //~ERROR trivial cast + | ^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: trivial cast: `&'b Bar` as `&'b Bar` + --> $DIR/trivial_casts.rs:93:13 + | +LL | let _ = b as &'b Bar; //~ERROR trivial cast + | ^^^^^^^^^^^^ + | + = help: cast can be replaced by coercion; this might require a temporary variable + +error: aborting due to 19 previous errors + diff --git a/src/test/ui/compile-fail-migration/tuple-arity-mismatch.rs b/src/test/ui/compile-fail-migration/tuple-arity-mismatch.rs new file mode 100644 index 00000000000..a71f4410294 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-arity-mismatch.rs @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #6155 + +fn first((value, _): (isize, f64)) -> isize { value } + +fn main() { + let y = first ((1,2.0,3)); + //~^ ERROR mismatched types + //~| expected type `(isize, f64)` + //~| found type `(isize, f64, {integer})` + //~| expected a tuple with 2 elements, found one with 3 elements + + let y = first ((1,)); + //~^ ERROR mismatched types + //~| expected type `(isize, f64)` + //~| found type `(isize,)` + //~| expected a tuple with 2 elements, found one with 1 elements +} diff --git a/src/test/ui/compile-fail-migration/tuple-arity-mismatch.stderr b/src/test/ui/compile-fail-migration/tuple-arity-mismatch.stderr new file mode 100644 index 00000000000..574a1f0a5c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-arity-mismatch.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/tuple-arity-mismatch.rs:16:20 + | +LL | let y = first ((1,2.0,3)); + | ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements + | + = note: expected type `(isize, f64)` + found type `(isize, f64, {integer})` + +error[E0308]: mismatched types + --> $DIR/tuple-arity-mismatch.rs:22:20 + | +LL | let y = first ((1,)); + | ^^^^ expected a tuple with 2 elements, found one with 1 elements + | + = note: expected type `(isize, f64)` + found type `(isize,)` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/tuple-index-not-tuple.rs b/src/test/ui/compile-fail-migration/tuple-index-not-tuple.rs new file mode 100644 index 00000000000..471104d6872 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-index-not-tuple.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Point { x: isize, y: isize } +struct Empty; + +fn main() { + let origin = Point { x: 0, y: 0 }; + origin.0; + //~^ ERROR no field `0` on type `Point` + Empty.0; + //~^ ERROR no field `0` on type `Empty` +} diff --git a/src/test/ui/compile-fail-migration/tuple-index-not-tuple.stderr b/src/test/ui/compile-fail-migration/tuple-index-not-tuple.stderr new file mode 100644 index 00000000000..fa0d0b4172b --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-index-not-tuple.stderr @@ -0,0 +1,15 @@ +error[E0609]: no field `0` on type `Point` + --> $DIR/tuple-index-not-tuple.rs:16:12 + | +LL | origin.0; + | ^ did you mean `x`? + +error[E0609]: no field `0` on type `Empty` + --> $DIR/tuple-index-not-tuple.rs:18:11 + | +LL | Empty.0; + | ^ unknown field + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.rs b/src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.rs new file mode 100644 index 00000000000..35b843676b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Point(i32, i32); + +fn main() { + let origin = Point(0, 0); + origin.0; + origin.1; + origin.2; + //~^ ERROR no field `2` on type `Point` + let tuple = (0, 0); + tuple.0; + tuple.1; + tuple.2; + //~^ ERROR no field `2` on type `({integer}, {integer})` +} diff --git a/src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.stderr b/src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.stderr new file mode 100644 index 00000000000..068e83ab091 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-index-out-of-bounds.stderr @@ -0,0 +1,15 @@ +error[E0609]: no field `2` on type `Point` + --> $DIR/tuple-index-out-of-bounds.rs:17:12 + | +LL | origin.2; + | ^ did you mean `0`? + +error[E0609]: no field `2` on type `({integer}, {integer})` + --> $DIR/tuple-index-out-of-bounds.rs:22:11 + | +LL | tuple.2; + | ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.rs b/src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.rs new file mode 100644 index 00000000000..e4fda6dd534 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo(isize, isize); + +fn main() { + let x = Foo(1, 2); + match x { //~ ERROR non-exhaustive + Foo(1, b) => println!("{}", b), + Foo(2, b) => println!("{}", b) + } +} diff --git a/src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.stderr b/src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.stderr new file mode 100644 index 00000000000..ee274bedbb8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tuple-struct-nonexhaustive.stderr @@ -0,0 +1,9 @@ +error[E0004]: non-exhaustive patterns: `Foo(_, _)` not covered + --> $DIR/tuple-struct-nonexhaustive.rs:15:11 + | +LL | match x { //~ ERROR non-exhaustive + | ^ pattern `Foo(_, _)` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.rs b/src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.rs new file mode 100644 index 00000000000..dadf7eb91d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = 3; + let y: i32 = 3; + + fn identity_u8(n: u8) -> u8 { n } + fn identity_u16(n: u16) -> u16 { n } + + identity_u8(x); // after this, `x` is assumed to have type `u8` + identity_u16(x); + //~^ ERROR mismatched types + //~| expected u16, found u8 + identity_u16(y); + //~^ ERROR mismatched types + //~| expected u16, found i32 + + let a = 3; + + fn identity_i(n: isize) -> isize { n } + + identity_i(a); // ok + identity_u16(a); + //~^ ERROR mismatched types + //~| expected u16, found isize +} diff --git a/src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.stderr b/src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.stderr new file mode 100644 index 00000000000..d315f9b87f9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/tutorial-suffix-inference-test.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/tutorial-suffix-inference-test.rs:19:18 + | +LL | identity_u16(x); + | ^ expected u16, found u8 +help: you can cast an `u8` to `u16`, which will zero-extend the source value + | +LL | identity_u16(x.into()); + | ^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/tutorial-suffix-inference-test.rs:22:18 + | +LL | identity_u16(y); + | ^ expected u16, found i32 + +error[E0308]: mismatched types + --> $DIR/tutorial-suffix-inference-test.rs:31:18 + | +LL | identity_u16(a); + | ^ expected u16, found isize + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-arg-out-of-scope.rs b/src/test/ui/compile-fail-migration/type-arg-out-of-scope.rs new file mode 100644 index 00000000000..04cd961e97f --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-arg-out-of-scope.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:can't use type parameters from outer function +fn foo(x: T) { + fn bar(f: Box T>) { } +} +fn main() { foo(1); } diff --git a/src/test/ui/compile-fail-migration/type-arg-out-of-scope.stderr b/src/test/ui/compile-fail-migration/type-arg-out-of-scope.stderr new file mode 100644 index 00000000000..20bf303129f --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-arg-out-of-scope.stderr @@ -0,0 +1,23 @@ +error[E0401]: can't use type parameters from outer function + --> $DIR/type-arg-out-of-scope.rs:13:25 + | +LL | fn foo(x: T) { + | - type variable from outer function +LL | fn bar(f: Box T>) { } + | --- ^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `bar` + +error[E0401]: can't use type parameters from outer function + --> $DIR/type-arg-out-of-scope.rs:13:31 + | +LL | fn foo(x: T) { + | - type variable from outer function +LL | fn bar(f: Box T>) { } + | --- ^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `bar` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0401`. diff --git a/src/test/ui/compile-fail-migration/type-ascription-precedence.rs b/src/test/ui/compile-fail-migration/type-ascription-precedence.rs new file mode 100644 index 00000000000..bb7a8bc3ddf --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-ascription-precedence.rs @@ -0,0 +1,64 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Operator precedence of type ascription +// Type ascription has very high precedence, the same as operator `as` + +#![feature(type_ascription)] + +use std::ops::*; + +struct S; +struct Z; + +impl Add for S { + type Output = S; + fn add(self, _rhs: Z) -> S { panic!() } +} +impl Mul for S { + type Output = S; + fn mul(self, _rhs: Z) -> S { panic!() } +} +impl Neg for S { + type Output = Z; + fn neg(self) -> Z { panic!() } +} +impl Deref for S { + type Target = Z; + fn deref(&self) -> &Z { panic!() } +} + +fn main() { + &S: &S; // OK + (&S): &S; // OK + &(S: &S); //~ ERROR mismatched types + + *S: Z; // OK + (*S): Z; // OK + *(S: Z); //~ ERROR mismatched types + //~^ ERROR type `Z` cannot be dereferenced + + -S: Z; // OK + (-S): Z; // OK + -(S: Z); //~ ERROR mismatched types + //~^ ERROR cannot apply unary operator `-` to type `Z` + + S + Z: Z; // OK + S + (Z: Z); // OK + (S + Z): Z; //~ ERROR mismatched types + + S * Z: Z; // OK + S * (Z: Z); // OK + (S * Z): Z; //~ ERROR mismatched types + + S .. S: S; // OK + S .. (S: S); // OK + (S .. S): S; //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/type-ascription-precedence.stderr b/src/test/ui/compile-fail-migration/type-ascription-precedence.stderr new file mode 100644 index 00000000000..252b5231220 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-ascription-precedence.stderr @@ -0,0 +1,72 @@ +error[E0308]: mismatched types + --> $DIR/type-ascription-precedence.rs:41:7 + | +LL | &(S: &S); //~ ERROR mismatched types + | ^ expected &S, found struct `S` + | + = note: expected type `&S` + found type `S` + +error[E0308]: mismatched types + --> $DIR/type-ascription-precedence.rs:45:7 + | +LL | *(S: Z); //~ ERROR mismatched types + | ^ expected struct `Z`, found struct `S` + | + = note: expected type `Z` + found type `S` + +error[E0614]: type `Z` cannot be dereferenced + --> $DIR/type-ascription-precedence.rs:45:5 + | +LL | *(S: Z); //~ ERROR mismatched types + | ^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/type-ascription-precedence.rs:50:7 + | +LL | -(S: Z); //~ ERROR mismatched types + | ^ expected struct `Z`, found struct `S` + | + = note: expected type `Z` + found type `S` + +error[E0600]: cannot apply unary operator `-` to type `Z` + --> $DIR/type-ascription-precedence.rs:50:5 + | +LL | -(S: Z); //~ ERROR mismatched types + | ^^^^^^^ cannot apply unary operator `-` + | + = note: an implementation of `std::ops::Neg` might be missing for `Z` + +error[E0308]: mismatched types + --> $DIR/type-ascription-precedence.rs:55:5 + | +LL | (S + Z): Z; //~ ERROR mismatched types + | ^^^^^^^ expected struct `Z`, found struct `S` + | + = note: expected type `Z` + found type `S` + +error[E0308]: mismatched types + --> $DIR/type-ascription-precedence.rs:59:5 + | +LL | (S * Z): Z; //~ ERROR mismatched types + | ^^^^^^^ expected struct `Z`, found struct `S` + | + = note: expected type `Z` + found type `S` + +error[E0308]: mismatched types + --> $DIR/type-ascription-precedence.rs:63:5 + | +LL | (S .. S): S; //~ ERROR mismatched types + | ^^^^^^^^ expected struct `S`, found struct `std::ops::Range` + | + = note: expected type `S` + found type `std::ops::Range` + +error: aborting due to 8 previous errors + +Some errors occurred: E0308, E0600, E0614. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-ascription-soundness.rs b/src/test/ui/compile-fail-migration/type-ascription-soundness.rs new file mode 100644 index 00000000000..2d882e87ab8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-ascription-soundness.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Type ascription doesn't lead to unsoundness + +#![feature(type_ascription)] + +fn main() { + let arr = &[1u8, 2, 3]; + let ref x = arr: &[u8]; //~ ERROR mismatched types + let ref mut x = arr: &[u8]; //~ ERROR mismatched types + match arr: &[u8] { //~ ERROR mismatched types + ref x => {} + } + let _len = (arr: &[u8]).len(); //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/type-ascription-soundness.stderr b/src/test/ui/compile-fail-migration/type-ascription-soundness.stderr new file mode 100644 index 00000000000..3dcd6ff49b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-ascription-soundness.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/type-ascription-soundness.rs:17:17 + | +LL | let ref x = arr: &[u8]; //~ ERROR mismatched types + | ^^^ expected slice, found array of 3 elements + | + = note: expected type `&[u8]` + found type `&[u8; 3]` + +error[E0308]: mismatched types + --> $DIR/type-ascription-soundness.rs:18:21 + | +LL | let ref mut x = arr: &[u8]; //~ ERROR mismatched types + | ^^^ expected slice, found array of 3 elements + | + = note: expected type `&[u8]` + found type `&[u8; 3]` + +error[E0308]: mismatched types + --> $DIR/type-ascription-soundness.rs:19:11 + | +LL | match arr: &[u8] { //~ ERROR mismatched types + | ^^^ expected slice, found array of 3 elements + | + = note: expected type `&[u8]` + found type `&[u8; 3]` + +error[E0308]: mismatched types + --> $DIR/type-ascription-soundness.rs:22:17 + | +LL | let _len = (arr: &[u8]).len(); //~ ERROR mismatched types + | ^^^ expected slice, found array of 3 elements + | + = note: expected type `&[u8]` + found type `&[u8; 3]` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-mismatch-multiple.rs b/src/test/ui/compile-fail-migration/type-mismatch-multiple.rs new file mode 100644 index 00000000000..9359c035956 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-mismatch-multiple.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checking that the compiler reports multiple type errors at once + +fn main() { let a: bool = 1; let b: i32 = true; } +//~^ ERROR mismatched types +//~| expected type `bool` +//~| found type `{integer}` +//~| expected bool, found integral variable +//~| ERROR mismatched types +//~| expected i32, found bool + diff --git a/src/test/ui/compile-fail-migration/type-mismatch-multiple.stderr b/src/test/ui/compile-fail-migration/type-mismatch-multiple.stderr new file mode 100644 index 00000000000..b9721a5edfa --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-mismatch-multiple.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/type-mismatch-multiple.rs:13:27 + | +LL | fn main() { let a: bool = 1; let b: i32 = true; } + | ^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/type-mismatch-multiple.rs:13:43 + | +LL | fn main() { let a: bool = 1; let b: i32 = true; } + | ^^^^ expected i32, found bool + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.rs b/src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.rs new file mode 100644 index 00000000000..7e93f626cfc --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:crate_a1.rs +// aux-build:crate_a2.rs + +// This tests the extra note reported when a type error deals with +// seemingly identical types. +// The main use case of this error is when there are two crates +// (generally different versions of the same crate) with the same name +// causing a type mismatch. Here, we simulate that error using block-scoped +// aliased `extern crate` declarations. + +fn main() { + let foo2 = {extern crate crate_a2 as a; a::Foo}; + let bar2 = {extern crate crate_a2 as a; a::bar()}; + { + extern crate crate_a1 as a; + a::try_foo(foo2); + //~^ ERROR mismatched types + //~| Perhaps two different versions of crate `crate_a1` + //~| expected struct `main::a::Foo` + //~| expected type `main::a::Foo` + //~| found type `main::a::Foo` + a::try_bar(bar2); + //~^ ERROR mismatched types + //~| Perhaps two different versions of crate `crate_a1` + //~| expected trait `main::a::Bar` + //~| expected type `std::boxed::Box<(dyn main::a::Bar + 'static)>` + //~| found type `std::boxed::Box` + } +} diff --git a/src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.stderr b/src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.stderr new file mode 100644 index 00000000000..c6860926056 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-mismatch-same-crate-name.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/type-mismatch-same-crate-name.rs:26:20 + | +LL | a::try_foo(foo2); + | ^^^^ expected struct `main::a::Foo`, found a different struct `main::a::Foo` + | + = note: expected type `main::a::Foo` (struct `main::a::Foo`) + found type `main::a::Foo` (struct `main::a::Foo`) +note: Perhaps two different versions of crate `crate_a1` are being used? + --> $DIR/type-mismatch-same-crate-name.rs:26:20 + | +LL | a::try_foo(foo2); + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/type-mismatch-same-crate-name.rs:32:20 + | +LL | a::try_bar(bar2); + | ^^^^ expected trait `main::a::Bar`, found a different trait `main::a::Bar` + | + = note: expected type `std::boxed::Box<(dyn main::a::Bar + 'static)>` + found type `std::boxed::Box` +note: Perhaps two different versions of crate `crate_a1` are being used? + --> $DIR/type-mismatch-same-crate-name.rs:32:20 + | +LL | a::try_bar(bar2); + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.rs b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.rs new file mode 100644 index 00000000000..08988353886 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a default that references `Self` which is then used in an +// object type. Issue #18956. In this case, the value is supplied by +// the user, but pretty-printing the type during the error message +// caused an ICE. + +trait MyAdd { fn add(&self, other: &Rhs) -> Self; } + +impl MyAdd for i32 { + fn add(&self, other: &i32) -> i32 { *self + *other } +} + +fn main() { + let x: i32 = 5; + let y = x as MyAdd; + //~^ ERROR E0038 + //~| ERROR cast to unsized type: `i32` as `dyn MyAdd` +} diff --git a/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.stderr b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.stderr new file mode 100644 index 00000000000..f02bf0533a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self-ppaux.stderr @@ -0,0 +1,24 @@ +error[E0620]: cast to unsized type: `i32` as `dyn MyAdd` + --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:24:13 + | +LL | let y = x as MyAdd; + | ^^^^^^^^^^^^^^^ + | +help: consider using a box or reference as appropriate + --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:24:13 + | +LL | let y = x as MyAdd; + | ^ + +error[E0038]: the trait `MyAdd` cannot be made into an object + --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:24:18 + | +LL | let y = x as MyAdd; + | ^^^^^^^^^^ the trait `MyAdd` cannot be made into an object + | + = note: method `add` references the `Self` type in its arguments or return type + +error: aborting due to 2 previous errors + +Some errors occurred: E0038, E0620. +For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.rs b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.rs new file mode 100644 index 00000000000..9982d485024 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test a default that references `Self` which is then used in an object type. +// Issue #18956. + +#![feature(default_type_params)] + +trait Foo { + fn method(&self); +} + +fn foo(x: &Foo) { } +//~^ ERROR the type parameter `T` must be explicitly specified + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.stderr b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.stderr new file mode 100644 index 00000000000..e163253bdf9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-parameter-defaults-referencing-Self.stderr @@ -0,0 +1,11 @@ +error[E0393]: the type parameter `T` must be explicitly specified + --> $DIR/type-parameter-defaults-referencing-Self.rs:20:12 + | +LL | fn foo(x: &Foo) { } + | ^^^ missing reference to `T` + | + = note: because of the default `Self` reference, type parameters must be specified on object types + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0393`. diff --git a/src/test/ui/compile-fail-migration/type-parameter-names.rs b/src/test/ui/compile-fail-migration/type-parameter-names.rs new file mode 100644 index 00000000000..11a2fc2665c --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-parameter-names.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we print out the names of type parameters correctly in +// our error messages. + +fn foo(x: Foo) -> Bar { + x +//~^ ERROR mismatched types +//~| expected type `Bar` +//~| found type `Foo` +//~| expected type parameter, found a different type parameter +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/type-parameter-names.stderr b/src/test/ui/compile-fail-migration/type-parameter-names.stderr new file mode 100644 index 00000000000..8e3d39357ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-parameter-names.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/type-parameter-names.rs:15:5 + | +LL | fn foo(x: Foo) -> Bar { + | --- expected `Bar` because of return type +LL | x + | ^ expected type parameter, found a different type parameter + | + = note: expected type `Bar` + found type `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.rs b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.rs new file mode 100644 index 00000000000..26eac6adde2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Add; + +trait BrokenAdd: Copy + Add { + fn broken_add(&self, rhs: T) -> Self { + *self + rhs //~ ERROR mismatched types + //~| expected type `Self` + //~| found type `T` + //~| expected Self, found type parameter + } +} + +impl> BrokenAdd for T {} + +pub fn main() { + let foo: u8 = 0; + let x: u8 = foo.broken_add("hello darkness my old friend".to_string()); + println!("{}", x); +} diff --git a/src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.stderr b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.stderr new file mode 100644 index 00000000000..31f332f6095 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-1.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/type-params-in-different-spaces-1.rs:15:17 + | +LL | *self + rhs //~ ERROR mismatched types + | ^^^ expected Self, found type parameter + | + = note: expected type `Self` + found type `T` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.rs b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.rs new file mode 100644 index 00000000000..7de061eaf07 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test static calls to make sure that we align the Self and input +// type parameters on a trait correctly. + +trait Tr : Sized { + fn op(_: T) -> Self; +} + +trait A: Tr { + fn test(u: U) -> Self { + Tr::op(u) //~ ERROR E0277 + } +} + +trait B: Tr { + fn test(u: U) -> Self { + Tr::op(u) //~ ERROR E0277 + } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.stderr b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.stderr new file mode 100644 index 00000000000..af18185dd24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-2.stderr @@ -0,0 +1,29 @@ +error[E0277]: the trait bound `Self: Tr` is not satisfied + --> $DIR/type-params-in-different-spaces-2.rs:20:9 + | +LL | Tr::op(u) //~ ERROR E0277 + | ^^^^^^ the trait `Tr` is not implemented for `Self` + | + = help: consider adding a `where Self: Tr` bound +note: required by `Tr::op` + --> $DIR/type-params-in-different-spaces-2.rs:15:5 + | +LL | fn op(_: T) -> Self; + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `Self: Tr` is not satisfied + --> $DIR/type-params-in-different-spaces-2.rs:26:9 + | +LL | Tr::op(u) //~ ERROR E0277 + | ^^^^^^ the trait `Tr` is not implemented for `Self` + | + = help: consider adding a `where Self: Tr` bound +note: required by `Tr::op` + --> $DIR/type-params-in-different-spaces-2.rs:15:5 + | +LL | fn op(_: T) -> Self; + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.rs b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.rs new file mode 100644 index 00000000000..3ad1e9ab538 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Tr : Sized { + fn test(u: X) -> Self { + u //~ ERROR mismatched types + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.stderr b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.stderr new file mode 100644 index 00000000000..e1b4cbb2ab3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-params-in-different-spaces-3.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/type-params-in-different-spaces-3.rs:13:9 + | +LL | fn test(u: X) -> Self { + | ---- expected `Self` because of return type +LL | u //~ ERROR mismatched types + | ^ expected Self, found type parameter + | + = note: expected type `Self` + found type `X` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type-path-err-node-types.rs b/src/test/ui/compile-fail-migration/type-path-err-node-types.rs new file mode 100644 index 00000000000..7ef099d0410 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-path-err-node-types.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Type arguments in unresolved entities (reporting errors before type checking) +// should have their types recorded. + +trait Tr {} + +fn local_type() { + let _: Nonexistent; //~ ERROR cannot find type `Nonexistent` in this scope +} + +fn ufcs_trait() { + >::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent` +} + +fn ufcs_item() { + NonExistent::Assoc::; //~ ERROR undeclared type or module `NonExistent` +} + +fn method() { + nonexistent.nonexistent::(); //~ ERROR cannot find value `nonexistent` +} + +fn closure() { + let _ = |a, b: _| -> _ { 0 }; // OK +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/type-path-err-node-types.stderr b/src/test/ui/compile-fail-migration/type-path-err-node-types.stderr new file mode 100644 index 00000000000..c28b30b5456 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-path-err-node-types.stderr @@ -0,0 +1,28 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `NonExistent` + --> $DIR/type-path-err-node-types.rs:25:5 + | +LL | NonExistent::Assoc::; //~ ERROR undeclared type or module `NonExistent` + | ^^^^^^^^^^^ Use of undeclared type or module `NonExistent` + +error[E0412]: cannot find type `Nonexistent` in this scope + --> $DIR/type-path-err-node-types.rs:17:12 + | +LL | let _: Nonexistent; //~ ERROR cannot find type `Nonexistent` in this scope + | ^^^^^^^^^^^ not found in this scope + +error[E0576]: cannot find method or associated constant `nonexistent` in trait `Tr` + --> $DIR/type-path-err-node-types.rs:21:21 + | +LL | >::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent` + | ^^^^^^^^^^^ not found in `Tr` + +error[E0425]: cannot find value `nonexistent` in this scope + --> $DIR/type-path-err-node-types.rs:29:5 + | +LL | nonexistent.nonexistent::(); //~ ERROR cannot find value `nonexistent` + | ^^^^^^^^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors occurred: E0412, E0425, E0433, E0576. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/compile-fail-migration/type-shadow.rs b/src/test/ui/compile-fail-migration/type-shadow.rs new file mode 100644 index 00000000000..6d8c0fe22bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-shadow.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + type X = isize; + type Y = X; + if true { + type X = &'static str; + let y: Y = "hello"; //~ ERROR mismatched types + } +} diff --git a/src/test/ui/compile-fail-migration/type-shadow.stderr b/src/test/ui/compile-fail-migration/type-shadow.stderr new file mode 100644 index 00000000000..29e6e4352e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type-shadow.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/type-shadow.rs:16:20 + | +LL | let y: Y = "hello"; //~ ERROR mismatched types + | ^^^^^^^ expected isize, found reference + | + = note: expected type `isize` + found type `&'static str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/type_length_limit.rs b/src/test/ui/compile-fail-migration/type_length_limit.rs new file mode 100644 index 00000000000..d283f392d76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type_length_limit.rs @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: reached the type-length limit while instantiating + +// Test that the type length limit can be changed. + +#![allow(dead_code)] +#![type_length_limit="256"] + +macro_rules! link { + ($id:ident, $t:ty) => { + pub type $id = ($t, $t, $t); + } +} + +link! { A, B } +link! { B, C } +link! { C, D } +link! { D, E } +link! { E, F } +link! { F, G } + +pub struct G; + +fn main() { + drop::>(None); +} diff --git a/src/test/ui/compile-fail-migration/type_length_limit.stderr b/src/test/ui/compile-fail-migration/type_length_limit.stderr new file mode 100644 index 00000000000..910eca07594 --- /dev/null +++ b/src/test/ui/compile-fail-migration/type_length_limit.stderr @@ -0,0 +1,6 @@ +error: reached the type-length limit while instantiating `std::mem::drop:: or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +auto trait Magic : Sized where Option : Magic {} //~ ERROR E0568 +impl Magic for T {} + +fn copy(x: T) -> (T, T) { (x, x) } + +#[derive(Debug)] +struct NoClone; + +fn main() { + let (a, b) = copy(NoClone); + println!("{:?} {:?}", a, b); +} diff --git a/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits-2.stderr b/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits-2.stderr new file mode 100644 index 00000000000..8fff0e2bb1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits-2.stderr @@ -0,0 +1,9 @@ +error[E0568]: auto traits cannot have super traits + --> $DIR/typeck-auto-trait-no-supertraits-2.rs:13:1 + | +LL | auto trait Magic : Sized where Option : Magic {} //~ ERROR E0568 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0568`. diff --git a/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.rs b/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.rs new file mode 100644 index 00000000000..c8cf96f52fc --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.rs @@ -0,0 +1,48 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test is for #29859, we need to ensure auto traits, +// (also known previously as default traits), do not have +// supertraits. Since the compiler synthesizes these +// instances on demand, we are essentially enabling +// users to write axioms if we view trait selection, +// as a proof system. +// +// For example the below test allows us to add the rule: +// forall (T : Type), T : Copy +// +// Providing a copy instance for *any* type, which +// is most definitely unsound. Imagine copying a +// type that contains a mutable reference, enabling +// mutable aliasing. +// +// You can imagine an even more dangerous test, +// which currently compiles on nightly. +// +// fn main() { +// let mut i = 10; +// let (a, b) = copy(&mut i); +// println!("{:?} {:?}", a, b); +// } + +#![feature(optin_builtin_traits)] + +auto trait Magic: Copy {} //~ ERROR E0568 +impl Magic for T {} + +fn copy(x: T) -> (T, T) { (x, x) } + +#[derive(Debug)] +struct NoClone; + +fn main() { + let (a, b) = copy(NoClone); + println!("{:?} {:?}", a, b); +} diff --git a/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.stderr b/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.stderr new file mode 100644 index 00000000000..26542286807 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-auto-trait-no-supertraits.stderr @@ -0,0 +1,9 @@ +error[E0568]: auto traits cannot have super traits + --> $DIR/typeck-auto-trait-no-supertraits.rs:37:1 + | +LL | auto trait Magic: Copy {} //~ ERROR E0568 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0568`. diff --git a/src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.rs b/src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.rs new file mode 100644 index 00000000000..3f8b8f49cb3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x : i16 = 22; + ((&x) as *const i16) as f32; + //~^ ERROR casting `*const i16` as `f32` is invalid +} diff --git a/src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.stderr b/src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.stderr new file mode 100644 index 00000000000..437675ccb06 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-cast-pointer-to-float.stderr @@ -0,0 +1,9 @@ +error[E0606]: casting `*const i16` as `f32` is invalid + --> $DIR/typeck-cast-pointer-to-float.rs:13:5 + | +LL | ((&x) as *const i16) as f32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.rs new file mode 100644 index 00000000000..f8342c333a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we do not consider associated types to be sendable without +// some applicable trait bound (and we don't ICE). + +trait Trait { + type AssocType; + fn dummy(&self) { } +} +fn bar() { + is_send::(); //~ ERROR E0277 +} + +fn is_send() { +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.stderr new file mode 100644 index 00000000000..ad47fcdb042 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-assoc-type.stderr @@ -0,0 +1,17 @@ +error[E0277]: `::AssocType` cannot be sent between threads safely + --> $DIR/typeck-default-trait-impl-assoc-type.rs:19:5 + | +LL | is_send::(); //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^^^ `::AssocType` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `::AssocType` + = help: consider adding a `where ::AssocType: std::marker::Send` bound +note: required by `is_send` + --> $DIR/typeck-default-trait-impl-assoc-type.rs:22:1 + | +LL | fn is_send() { + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.rs new file mode 100644 index 00000000000..6e7c9afb674 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +auto trait MyTrait {} + +struct MyS; + +struct MyS2; + +impl !MyTrait for MyS2 {} + +fn is_mytrait() {} + +fn main() { + is_mytrait::(); + + is_mytrait::<(MyS2, MyS)>(); + //~^ ERROR `MyS2: MyTrait` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.stderr new file mode 100644 index 00000000000..a52628e233c --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types-2.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied in `(MyS2, MyS)` + --> $DIR/typeck-default-trait-impl-constituent-types-2.rs:26:5 + | +LL | is_mytrait::<(MyS2, MyS)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `(MyS2, MyS)`, the trait `MyTrait` is not implemented for `MyS2` + | + = help: the following implementations were found: + + = note: required because it appears within the type `(MyS2, MyS)` +note: required by `is_mytrait` + --> $DIR/typeck-default-trait-impl-constituent-types-2.rs:21:1 + | +LL | fn is_mytrait() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.rs new file mode 100644 index 00000000000..4660ecf4fb4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +auto trait MyTrait {} + +impl !MyTrait for *mut T {} + +struct MyS; + +struct MyS2; + +impl !MyTrait for MyS2 {} + +struct MyS3; + +fn is_mytrait() {} + +fn main() { + is_mytrait::(); + + is_mytrait::(); + //~^ ERROR `MyS2: MyTrait` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.stderr new file mode 100644 index 00000000000..2e382dd05cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-constituent-types.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied + --> $DIR/typeck-default-trait-impl-constituent-types.rs:30:5 + | +LL | is_mytrait::(); + | ^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `MyS2` + | + = help: the following implementations were found: + +note: required by `is_mytrait` + --> $DIR/typeck-default-trait-impl-constituent-types.rs:25:1 + | +LL | fn is_mytrait() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.rs new file mode 100644 index 00000000000..b918b0dde47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:tdticc_coherence_lib.rs + +// Test that we do not consider associated types to be sendable without +// some applicable trait bound (and we don't ICE). + +#![feature(optin_builtin_traits)] + +extern crate tdticc_coherence_lib as lib; + +use lib::DefaultedTrait; + +struct A; +impl DefaultedTrait for (A,) { } //~ ERROR E0117 + +struct B; +impl !DefaultedTrait for (B,) { } //~ ERROR E0117 + +struct C; +struct D(T); +impl DefaultedTrait for Box { } //~ ERROR E0321 +impl DefaultedTrait for lib::Something { } //~ ERROR E0117 +impl DefaultedTrait for D { } // OK + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.stderr new file mode 100644 index 00000000000..6efb7f39f3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-cross-crate-coherence.stderr @@ -0,0 +1,37 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:23:1 + | +LL | impl DefaultedTrait for (A,) { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:26:1 + | +LL | impl !DefaultedTrait for (B,) { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0321]: cross-crate traits with a default impl, like `lib::DefaultedTrait`, can only be implemented for a struct/enum type defined in the current crate + --> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:30:1 + | +LL | impl DefaultedTrait for Box { } //~ ERROR E0321 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait for type in another crate + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/typeck-default-trait-impl-cross-crate-coherence.rs:31:1 + | +LL | impl DefaultedTrait for lib::Something { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 4 previous errors + +Some errors occurred: E0117, E0321. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.rs new file mode 100644 index 00000000000..65438e5df8e --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +struct MySendable { + t: *mut u8 +} + +unsafe impl Send for MySendable {} + +struct MyNotSendable { + t: *mut u8 +} + +impl !Send for MyNotSendable {} + +fn is_send() {} + +fn main() { + is_send::(); + is_send::(); + //~^ ERROR `MyNotSendable` cannot be sent between threads safely +} diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.stderr new file mode 100644 index 00000000000..8dc7df90355 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-send.stderr @@ -0,0 +1,16 @@ +error[E0277]: `MyNotSendable` cannot be sent between threads safely + --> $DIR/typeck-default-trait-impl-negation-send.rs:29:5 + | +LL | is_send::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ `MyNotSendable` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `MyNotSendable` +note: required by `is_send` + --> $DIR/typeck-default-trait-impl-negation-send.rs:25:1 + | +LL | fn is_send() {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.rs new file mode 100644 index 00000000000..c829ba3dcc3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.rs @@ -0,0 +1,53 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +#![feature(optin_builtin_traits)] + +struct Managed; +impl !Send for Managed {} +impl !Sync for Managed {} + +use std::cell::UnsafeCell; + +struct MySync { + t: *mut u8 +} + +unsafe impl Sync for MySync {} + +struct MyNotSync { + t: *mut u8 +} + +impl !Sync for MyNotSync {} + +struct MyTypeWUnsafe { + t: UnsafeCell +} + +struct MyTypeManaged { + t: Managed +} + +fn is_sync() {} + +fn main() { + is_sync::(); + is_sync::(); + //~^ ERROR `MyNotSync` cannot be shared between threads safely [E0277] + + is_sync::(); + //~^ ERROR `std::cell::UnsafeCell` cannot be shared between threads safely [E0277] + + is_sync::(); + //~^ ERROR `Managed` cannot be shared between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.stderr new file mode 100644 index 00000000000..b0fe2c599be --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation-sync.stderr @@ -0,0 +1,44 @@ +error[E0277]: `MyNotSync` cannot be shared between threads safely + --> $DIR/typeck-default-trait-impl-negation-sync.rs:45:5 + | +LL | is_sync::(); + | ^^^^^^^^^^^^^^^^^^^^ `MyNotSync` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `MyNotSync` +note: required by `is_sync` + --> $DIR/typeck-default-trait-impl-negation-sync.rs:41:1 + | +LL | fn is_sync() {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::cell::UnsafeCell` cannot be shared between threads safely + --> $DIR/typeck-default-trait-impl-negation-sync.rs:48:5 + | +LL | is_sync::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell` cannot be shared between threads safely + | + = help: within `MyTypeWUnsafe`, the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `MyTypeWUnsafe` +note: required by `is_sync` + --> $DIR/typeck-default-trait-impl-negation-sync.rs:41:1 + | +LL | fn is_sync() {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `Managed` cannot be shared between threads safely + --> $DIR/typeck-default-trait-impl-negation-sync.rs:51:5 + | +LL | is_sync::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ `Managed` cannot be shared between threads safely + | + = help: within `MyTypeManaged`, the trait `std::marker::Sync` is not implemented for `Managed` + = note: required because it appears within the type `MyTypeManaged` +note: required by `is_sync` + --> $DIR/typeck-default-trait-impl-negation-sync.rs:41:1 + | +LL | fn is_sync() {} + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.rs new file mode 100644 index 00000000000..b28cdd8aa24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.rs @@ -0,0 +1,38 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +auto trait MyTrait {} + +unsafe auto trait MyUnsafeTrait {} + +struct ThisImplsTrait; + +impl !MyUnsafeTrait for ThisImplsTrait {} + + +struct ThisImplsUnsafeTrait; + +impl !MyTrait for ThisImplsUnsafeTrait {} + +fn is_my_trait() {} +fn is_my_unsafe_trait() {} + +fn main() { + is_my_trait::(); + is_my_trait::(); + //~^ ERROR `ThisImplsUnsafeTrait: MyTrait` is not satisfied + + is_my_unsafe_trait::(); + //~^ ERROR `ThisImplsTrait: MyUnsafeTrait` is not satisfied + + is_my_unsafe_trait::(); +} diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.stderr new file mode 100644 index 00000000000..4427955c4b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-negation.stderr @@ -0,0 +1,31 @@ +error[E0277]: the trait bound `ThisImplsUnsafeTrait: MyTrait` is not satisfied + --> $DIR/typeck-default-trait-impl-negation.rs:31:5 + | +LL | is_my_trait::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `ThisImplsUnsafeTrait` + | + = help: the following implementations were found: + +note: required by `is_my_trait` + --> $DIR/typeck-default-trait-impl-negation.rs:26:1 + | +LL | fn is_my_trait() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `ThisImplsTrait: MyUnsafeTrait` is not satisfied + --> $DIR/typeck-default-trait-impl-negation.rs:34:5 + | +LL | is_my_unsafe_trait::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyUnsafeTrait` is not implemented for `ThisImplsTrait` + | + = help: the following implementations were found: + +note: required by `is_my_unsafe_trait` + --> $DIR/typeck-default-trait-impl-negation.rs:27:1 + | +LL | fn is_my_unsafe_trait() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.rs new file mode 100644 index 00000000000..d63d70bad22 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that declaring that `&T` is `Defaulted` if `T:Signed` implies +// that other `&T` is NOT `Defaulted` if `T:Signed` does not hold. In +// other words, the auto impl only applies if there are no existing +// impls whose types unify. + +#![feature(optin_builtin_traits)] + +auto trait Defaulted { } +impl<'a,T:Signed> Defaulted for &'a T { } +impl<'a,T:Signed> Defaulted for &'a mut T { } +fn is_defaulted() { } + +trait Signed { } +impl Signed for i32 { } + +fn main() { + is_defaulted::<&'static i32>(); + is_defaulted::<&'static u32>(); + //~^ ERROR `u32: Signed` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.stderr new file mode 100644 index 00000000000..0ab5eaaa34f --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-precedence.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `u32: Signed` is not satisfied + --> $DIR/typeck-default-trait-impl-precedence.rs:28:5 + | +LL | is_defaulted::<&'static u32>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Signed` is not implemented for `u32` + | + = note: required because of the requirements on the impl of `Defaulted` for `&'static u32` +note: required by `is_defaulted` + --> $DIR/typeck-default-trait-impl-precedence.rs:21:1 + | +LL | fn is_defaulted() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.rs b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.rs new file mode 100644 index 00000000000..0c548b3bd99 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we do not consider parameter types to be sendable without +// an explicit trait bound. + +fn foo() { + is_send::() //~ ERROR E0277 +} + +fn is_send() { +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.stderr b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.stderr new file mode 100644 index 00000000000..82f31176f3e --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-default-trait-impl-send-param.stderr @@ -0,0 +1,17 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/typeck-default-trait-impl-send-param.rs:15:5 + | +LL | is_send::() //~ ERROR E0277 + | ^^^^^^^^^^^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound +note: required by `is_send` + --> $DIR/typeck-default-trait-impl-send-param.rs:18:1 + | +LL | fn is_send() { + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.rs b/src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.rs new file mode 100644 index 00000000000..d6d8fb6235d --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +struct TestType; + +trait TestTrait { + fn dummy(&self) { } +} + +impl !TestTrait for TestType {} +//~^ ERROR negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.stderr b/src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.stderr new file mode 100644 index 00000000000..6ae323aedfe --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-negative-impls-builtin.stderr @@ -0,0 +1,9 @@ +error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) + --> $DIR/typeck-negative-impls-builtin.rs:19:1 + | +LL | impl !TestTrait for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0192`. diff --git a/src/test/ui/compile-fail-migration/typeck-unsafe-always-share.rs b/src/test/ui/compile-fail-migration/typeck-unsafe-always-share.rs new file mode 100644 index 00000000000..fcfc8574b21 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-unsafe-always-share.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Verify that UnsafeCell is *always* !Sync regardless if `T` is sync. + +#![feature(optin_builtin_traits)] + +use std::cell::UnsafeCell; +use std::marker::Sync; + +struct MySync { + u: UnsafeCell +} + +struct NoSync; +impl !Sync for NoSync {} + +fn test(s: T) {} + +fn main() { + let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0)}); + test(us); + //~^ ERROR `std::cell::UnsafeCell>` cannot be shared between threads safely + + let uns = UnsafeCell::new(NoSync); + test(uns); + //~^ ERROR `std::cell::UnsafeCell` cannot be shared between threads safely [E0277] + + let ms = MySync{u: uns}; + test(ms); + //~^ ERROR `std::cell::UnsafeCell` cannot be shared between threads safely [E0277] + + test(NoSync); + //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] +} diff --git a/src/test/ui/compile-fail-migration/typeck-unsafe-always-share.stderr b/src/test/ui/compile-fail-migration/typeck-unsafe-always-share.stderr new file mode 100644 index 00000000000..57c4bdf0ad2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck-unsafe-always-share.stderr @@ -0,0 +1,56 @@ +error[E0277]: `std::cell::UnsafeCell>` cannot be shared between threads safely + --> $DIR/typeck-unsafe-always-share.rs:29:5 + | +LL | test(us); + | ^^^^ `std::cell::UnsafeCell>` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell>` +note: required by `test` + --> $DIR/typeck-unsafe-always-share.rs:25:1 + | +LL | fn test(s: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::cell::UnsafeCell` cannot be shared between threads safely + --> $DIR/typeck-unsafe-always-share.rs:33:5 + | +LL | test(uns); + | ^^^^ `std::cell::UnsafeCell` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell` +note: required by `test` + --> $DIR/typeck-unsafe-always-share.rs:25:1 + | +LL | fn test(s: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::cell::UnsafeCell` cannot be shared between threads safely + --> $DIR/typeck-unsafe-always-share.rs:37:5 + | +LL | test(ms); + | ^^^^ `std::cell::UnsafeCell` cannot be shared between threads safely + | + = help: within `MySync`, the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell` + = note: required because it appears within the type `MySync` +note: required by `test` + --> $DIR/typeck-unsafe-always-share.rs:25:1 + | +LL | fn test(s: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `NoSync` cannot be shared between threads safely + --> $DIR/typeck-unsafe-always-share.rs:40:5 + | +LL | test(NoSync); + | ^^^^ `NoSync` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `NoSync` +note: required by `test` + --> $DIR/typeck-unsafe-always-share.rs:25:1 + | +LL | fn test(s: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.rs b/src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.rs new file mode 100644 index 00000000000..91e3c38322e --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test checks that genuine type errors with partial +// type hints are understandable. + +use std::marker::PhantomData; + +struct Foo(PhantomData); +struct Bar(PhantomData); + +pub fn main() { +} + +fn test1() { + let x: Foo<_> = Bar::(PhantomData); + //~^ ERROR mismatched types + //~| expected type `Foo<_>` + //~| found type `Bar` + //~| expected struct `Foo`, found struct `Bar` + let y: Foo = x; +} + +fn test2() { + let x: Foo<_> = Bar::(PhantomData); + //~^ ERROR mismatched types + //~| expected type `Foo<_>` + //~| found type `Bar` + //~| expected struct `Foo`, found struct `Bar` +} diff --git a/src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.stderr b/src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.stderr new file mode 100644 index 00000000000..6a762353819 --- /dev/null +++ b/src/test/ui/compile-fail-migration/typeck_type_placeholder_mismatch.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/typeck_type_placeholder_mismatch.rs:23:21 + | +LL | let x: Foo<_> = Bar::(PhantomData); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found struct `Bar` + | + = note: expected type `Foo<_>` + found type `Bar` + +error[E0308]: mismatched types + --> $DIR/typeck_type_placeholder_mismatch.rs:32:21 + | +LL | let x: Foo<_> = Bar::(PhantomData); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Foo`, found struct `Bar` + | + = note: expected type `Foo<_>` + found type `Bar` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.rs b/src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.rs new file mode 100644 index 00000000000..a0d1f2dc331 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.rs @@ -0,0 +1,69 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct Foo { + f: isize, +} + +impl Foo { + fn foo(self: isize, x: isize) -> isize { + //~^ ERROR invalid `self` type + self.f + x + } +} + +struct Bar { + f: T, +} + +impl Bar { + fn foo(self: Bar, x: isize) -> isize { + //~^ ERROR invalid `self` type + x + } + fn bar(self: &Bar, x: isize) -> isize { + //~^ ERROR invalid `self` type + x + } +} + +trait SomeTrait { + fn dummy1(&self); + fn dummy2(&self); + fn dummy3(&self); +} + +impl<'a, T> SomeTrait for &'a Bar { + fn dummy1(self: &&'a Bar) { } + fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver + //~^ ERROR mismatched method receiver + fn dummy3(self: &&Bar) {} + //~^ ERROR mismatched method receiver + //~| expected type `&'a Bar` + //~| found type `&Bar` + //~| lifetime mismatch + //~| ERROR mismatched method receiver + //~| expected type `&'a Bar` + //~| found type `&Bar` + //~| lifetime mismatch +} + +fn main() { + let foo = box Foo { + f: 1, + }; + println!("{}", foo.foo(2)); + let bar = box Bar { + f: 1, + }; + println!("{} {}", bar.foo(2), bar.bar(2)); +} diff --git a/src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.stderr b/src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.stderr new file mode 100644 index 00000000000..fce74605cad --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-explicit-self-bad.stderr @@ -0,0 +1,107 @@ +error[E0307]: invalid `self` type: isize + --> $DIR/ufcs-explicit-self-bad.rs:18:18 + | +LL | fn foo(self: isize, x: isize) -> isize { + | ^^^^^ + | + = note: type must be `Foo` or a type that dereferences to it + = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box` + +error[E0307]: invalid `self` type: Bar + --> $DIR/ufcs-explicit-self-bad.rs:29:18 + | +LL | fn foo(self: Bar, x: isize) -> isize { + | ^^^^^^^^^^ + | + = note: type must be `Bar` or a type that dereferences to it + = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box` + +error[E0307]: invalid `self` type: &Bar + --> $DIR/ufcs-explicit-self-bad.rs:33:18 + | +LL | fn bar(self: &Bar, x: isize) -> isize { + | ^^^^^^^^^^^ + | + = note: type must be `Bar` or a type that dereferences to it + = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box` + +error[E0308]: mismatched method receiver + --> $DIR/ufcs-explicit-self-bad.rs:47:21 + | +LL | fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver + | ^^^^^^^ lifetime mismatch + | + = note: expected type `&'a Bar` + found type `&Bar` +note: the anonymous lifetime #1 defined on the method body at 47:5... + --> $DIR/ufcs-explicit-self-bad.rs:47:5 + | +LL | fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...does not necessarily outlive the lifetime 'a as defined on the impl at 45:6 + --> $DIR/ufcs-explicit-self-bad.rs:45:6 + | +LL | impl<'a, T> SomeTrait for &'a Bar { + | ^^ + +error[E0308]: mismatched method receiver + --> $DIR/ufcs-explicit-self-bad.rs:47:21 + | +LL | fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver + | ^^^^^^^ lifetime mismatch + | + = note: expected type `&'a Bar` + found type `&Bar` +note: the lifetime 'a as defined on the impl at 45:6... + --> $DIR/ufcs-explicit-self-bad.rs:45:6 + | +LL | impl<'a, T> SomeTrait for &'a Bar { + | ^^ +note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 47:5 + --> $DIR/ufcs-explicit-self-bad.rs:47:5 + | +LL | fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched method receiver + --> $DIR/ufcs-explicit-self-bad.rs:49:21 + | +LL | fn dummy3(self: &&Bar) {} + | ^^^^^^^^ lifetime mismatch + | + = note: expected type `&'a Bar` + found type `&Bar` +note: the anonymous lifetime #2 defined on the method body at 49:5... + --> $DIR/ufcs-explicit-self-bad.rs:49:5 + | +LL | fn dummy3(self: &&Bar) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...does not necessarily outlive the lifetime 'a as defined on the impl at 45:6 + --> $DIR/ufcs-explicit-self-bad.rs:45:6 + | +LL | impl<'a, T> SomeTrait for &'a Bar { + | ^^ + +error[E0308]: mismatched method receiver + --> $DIR/ufcs-explicit-self-bad.rs:49:21 + | +LL | fn dummy3(self: &&Bar) {} + | ^^^^^^^^ lifetime mismatch + | + = note: expected type `&'a Bar` + found type `&Bar` +note: the lifetime 'a as defined on the impl at 45:6... + --> $DIR/ufcs-explicit-self-bad.rs:45:6 + | +LL | impl<'a, T> SomeTrait for &'a Bar { + | ^^ +note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 49:5 + --> $DIR/ufcs-explicit-self-bad.rs:49:5 + | +LL | fn dummy3(self: &&Bar) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors + +Some errors occurred: E0307, E0308. +For more information about an error, try `rustc --explain E0307`. diff --git a/src/test/ui/compile-fail-migration/ufcs-partially-resolved.rs b/src/test/ui/compile-fail-migration/ufcs-partially-resolved.rs new file mode 100644 index 00000000000..f7120ddb114 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-partially-resolved.rs @@ -0,0 +1,66 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_type_defaults)] + +trait Tr { + type Y = u16; + fn Y() {} +} +impl Tr for u8 {} + +trait Dr { + type X = u16; + fn Z() {} +} +impl Dr for u8 {} + +enum E { Y } +type A = u32; + +fn main() { + let _: ::N; //~ ERROR cannot find associated type `N` in trait `Tr` + let _: ::N; //~ ERROR cannot find associated type `N` in enum `E` + let _: ::N; //~ ERROR cannot find associated type `N` in `A` + ::N; //~ ERROR cannot find method or associated constant `N` in trait `Tr` + ::N; //~ ERROR cannot find method or associated constant `N` in enum `E` + ::N; //~ ERROR cannot find method or associated constant `N` in `A` + let _: ::Y; // OK + let _: ::Y; //~ ERROR expected associated type, found variant `E::Y` + ::Y; // OK + ::Y; //~ ERROR expected method or associated constant, found unit variant `E::Y` + + let _: ::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` + let _: ::N::NN; //~ ERROR cannot find associated type `N` in enum `E` + let _: ::N::NN; //~ ERROR cannot find associated type `N` in `A` + ::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` + ::N::NN; //~ ERROR cannot find associated type `N` in enum `E` + ::N::NN; //~ ERROR cannot find associated type `N` in `A` + let _: ::Y::NN; //~ ERROR ambiguous associated type + let _: ::Y::NN; //~ ERROR expected associated type, found variant `E::Y` + ::Y::NN; //~ ERROR no associated item named `NN` found for type `::Y` + ::Y::NN; //~ ERROR expected associated type, found variant `E::Y` + + let _: ::NN; //~ ERROR cannot find associated type `NN` in `Tr::N` + let _: ::NN; //~ ERROR cannot find associated type `NN` in `E::N` + let _: ::NN; //~ ERROR cannot find associated type `NN` in `A::N` + ::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::N` + ::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N` + ::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N` + let _: ::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y` + let _: ::NN; //~ ERROR failed to resolve. Not a module `Y` + ::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y` + ::NN; //~ ERROR failed to resolve. Not a module `Y` + + let _: ::Z; //~ ERROR expected associated type, found method `Dr::Z` + ::X; //~ ERROR expected method or associated constant, found associated type `Dr::X` + let _: ::Z::N; //~ ERROR expected associated type, found method `Dr::Z` + ::X::N; //~ ERROR no associated item named `N` found for type `::X` +} diff --git a/src/test/ui/compile-fail-migration/ufcs-partially-resolved.stderr b/src/test/ui/compile-fail-migration/ufcs-partially-resolved.stderr new file mode 100644 index 00000000000..5de8fb158b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-partially-resolved.stderr @@ -0,0 +1,206 @@ +error[E0433]: failed to resolve. Not a module `Y` + --> $DIR/ufcs-partially-resolved.rs:58:22 + | +LL | let _: ::NN; //~ ERROR failed to resolve. Not a module `Y` + | ^ Not a module `Y` + +error[E0433]: failed to resolve. Not a module `Y` + --> $DIR/ufcs-partially-resolved.rs:60:15 + | +LL | ::NN; //~ ERROR failed to resolve. Not a module `Y` + | ^ Not a module `Y` + +error[E0576]: cannot find associated type `N` in trait `Tr` + --> $DIR/ufcs-partially-resolved.rs:29:24 + | +LL | let _: ::N; //~ ERROR cannot find associated type `N` in trait `Tr` + | ^ did you mean `Y`? + +error[E0576]: cannot find associated type `N` in enum `E` + --> $DIR/ufcs-partially-resolved.rs:30:23 + | +LL | let _: ::N; //~ ERROR cannot find associated type `N` in enum `E` + | ^ not found in `E` + +error[E0576]: cannot find associated type `N` in `A` + --> $DIR/ufcs-partially-resolved.rs:31:23 + | +LL | let _: ::N; //~ ERROR cannot find associated type `N` in `A` + | ^ not found in `A` + +error[E0576]: cannot find method or associated constant `N` in trait `Tr` + --> $DIR/ufcs-partially-resolved.rs:32:17 + | +LL | ::N; //~ ERROR cannot find method or associated constant `N` in trait `Tr` + | ^ did you mean `Y`? + +error[E0576]: cannot find method or associated constant `N` in enum `E` + --> $DIR/ufcs-partially-resolved.rs:33:16 + | +LL | ::N; //~ ERROR cannot find method or associated constant `N` in enum `E` + | ^ not found in `E` + +error[E0576]: cannot find method or associated constant `N` in `A` + --> $DIR/ufcs-partially-resolved.rs:34:16 + | +LL | ::N; //~ ERROR cannot find method or associated constant `N` in `A` + | ^ not found in `A` + +error[E0575]: expected associated type, found variant `E::Y` + --> $DIR/ufcs-partially-resolved.rs:36:12 + | +LL | let _: ::Y; //~ ERROR expected associated type, found variant `E::Y` + | ^^^^^^^^^^^^ not a associated type + +error[E0575]: expected method or associated constant, found unit variant `E::Y` + --> $DIR/ufcs-partially-resolved.rs:38:5 + | +LL | ::Y; //~ ERROR expected method or associated constant, found unit variant `E::Y` + | ^^^^^^^^^^^^ not a method or associated constant + +error[E0576]: cannot find associated type `N` in trait `Tr` + --> $DIR/ufcs-partially-resolved.rs:40:24 + | +LL | let _: ::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` + | ^ did you mean `Y`? + +error[E0576]: cannot find associated type `N` in enum `E` + --> $DIR/ufcs-partially-resolved.rs:41:23 + | +LL | let _: ::N::NN; //~ ERROR cannot find associated type `N` in enum `E` + | ^ not found in `E` + +error[E0576]: cannot find associated type `N` in `A` + --> $DIR/ufcs-partially-resolved.rs:42:23 + | +LL | let _: ::N::NN; //~ ERROR cannot find associated type `N` in `A` + | ^ not found in `A` + +error[E0576]: cannot find associated type `N` in trait `Tr` + --> $DIR/ufcs-partially-resolved.rs:43:17 + | +LL | ::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` + | ^ did you mean `Y`? + +error[E0576]: cannot find associated type `N` in enum `E` + --> $DIR/ufcs-partially-resolved.rs:44:16 + | +LL | ::N::NN; //~ ERROR cannot find associated type `N` in enum `E` + | ^ not found in `E` + +error[E0576]: cannot find associated type `N` in `A` + --> $DIR/ufcs-partially-resolved.rs:45:16 + | +LL | ::N::NN; //~ ERROR cannot find associated type `N` in `A` + | ^ not found in `A` + +error[E0575]: expected associated type, found variant `E::Y` + --> $DIR/ufcs-partially-resolved.rs:47:12 + | +LL | let _: ::Y::NN; //~ ERROR expected associated type, found variant `E::Y` + | ^^^^^^^^^^^^^^^^ not a associated type + +error[E0575]: expected associated type, found variant `E::Y` + --> $DIR/ufcs-partially-resolved.rs:49:5 + | +LL | ::Y::NN; //~ ERROR expected associated type, found variant `E::Y` + | ^^^^^^^^^^^^^^^^ not a associated type + +error[E0576]: cannot find associated type `NN` in `Tr::N` + --> $DIR/ufcs-partially-resolved.rs:51:27 + | +LL | let _: ::NN; //~ ERROR cannot find associated type `NN` in `Tr::N` + | ^^ not found in `Tr::N` + +error[E0576]: cannot find associated type `NN` in `E::N` + --> $DIR/ufcs-partially-resolved.rs:52:26 + | +LL | let _: ::NN; //~ ERROR cannot find associated type `NN` in `E::N` + | ^^ not found in `E::N` + +error[E0576]: cannot find associated type `NN` in `A::N` + --> $DIR/ufcs-partially-resolved.rs:53:26 + | +LL | let _: ::NN; //~ ERROR cannot find associated type `NN` in `A::N` + | ^^ not found in `A::N` + +error[E0576]: cannot find method or associated constant `NN` in `Tr::N` + --> $DIR/ufcs-partially-resolved.rs:54:20 + | +LL | ::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::N` + | ^^ not found in `Tr::N` + +error[E0576]: cannot find method or associated constant `NN` in `E::N` + --> $DIR/ufcs-partially-resolved.rs:55:19 + | +LL | ::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N` + | ^^ not found in `E::N` + +error[E0576]: cannot find method or associated constant `NN` in `A::N` + --> $DIR/ufcs-partially-resolved.rs:56:19 + | +LL | ::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N` + | ^^ not found in `A::N` + +error[E0576]: cannot find associated type `NN` in `Tr::Y` + --> $DIR/ufcs-partially-resolved.rs:57:27 + | +LL | let _: ::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y` + | ^^ not found in `Tr::Y` + +error[E0576]: cannot find method or associated constant `NN` in `Tr::Y` + --> $DIR/ufcs-partially-resolved.rs:59:20 + | +LL | ::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y` + | ^^ not found in `Tr::Y` + +error[E0575]: expected associated type, found method `Dr::Z` + --> $DIR/ufcs-partially-resolved.rs:62:12 + | +LL | let _: ::Z; //~ ERROR expected associated type, found method `Dr::Z` + | ^^^^^^^^^^^^- + | | + | did you mean `X`? + +error[E0575]: expected method or associated constant, found associated type `Dr::X` + --> $DIR/ufcs-partially-resolved.rs:63:5 + | +LL | ::X; //~ ERROR expected method or associated constant, found associated type `Dr::X` + | ^^^^^^^^^^^^- + | | + | did you mean `Z`? + | + = note: can't use a type alias as a constructor + +error[E0575]: expected associated type, found method `Dr::Z` + --> $DIR/ufcs-partially-resolved.rs:64:12 + | +LL | let _: ::Z::N; //~ ERROR expected associated type, found method `Dr::Z` + | ^^^^^^^^^^^^-^^^ + | | + | did you mean `X`? + +error[E0223]: ambiguous associated type + --> $DIR/ufcs-partially-resolved.rs:46:12 + | +LL | let _: ::Y::NN; //~ ERROR ambiguous associated type + | ^^^^^^^^^^^^^^^^^ ambiguous associated type + | + = note: specify the type using the syntax `<::Y as Trait>::NN` + +error[E0599]: no associated item named `NN` found for type `::Y` in the current scope + --> $DIR/ufcs-partially-resolved.rs:48:5 + | +LL | ::Y::NN; //~ ERROR no associated item named `NN` found for type `::Y` + | ^^^^^^^^^^^^^^^^^ associated item not found in `::Y` + +error[E0599]: no associated item named `N` found for type `::X` in the current scope + --> $DIR/ufcs-partially-resolved.rs:65:5 + | +LL | ::X::N; //~ ERROR no associated item named `N` found for type `::X` + | ^^^^^^^^^^^^^^^^ associated item not found in `::X` + +error: aborting due to 32 previous errors + +Some errors occurred: E0223, E0433, E0575, E0576, E0599. +For more information about an error, try `rustc --explain E0223`. diff --git a/src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.rs b/src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.rs new file mode 100644 index 00000000000..5c108e05216 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::borrow::Cow; + +pub trait IntoCow<'a, B: ?Sized> where B: ToOwned { + fn into_cow(self) -> Cow<'a, B>; +} + +impl<'a> IntoCow<'a, str> for String { + fn into_cow(self) -> Cow<'a, str> { + Cow::Owned(self) + } +} + +fn main() { + ::into_cow("foo".to_string()); + //~^ ERROR too few type parameters provided: expected 1 type parameter +} diff --git a/src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.stderr b/src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.stderr new file mode 100644 index 00000000000..6c752dba6b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-qpath-missing-params.stderr @@ -0,0 +1,9 @@ +error[E0089]: too few type parameters provided: expected 1 type parameter, found 0 type parameters + --> $DIR/ufcs-qpath-missing-params.rs:24:5 + | +LL | ::into_cow("foo".to_string()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0089`. diff --git a/src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.rs b/src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.rs new file mode 100644 index 00000000000..caf510071bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Add; + +fn main() { + >::add(1, 2); + //~^ ERROR cannot add `u32` to `i32` + >::add(1u32, 2); + //~^ ERROR mismatched types + >::add(1, 2u32); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.stderr b/src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.stderr new file mode 100644 index 00000000000..f4222631872 --- /dev/null +++ b/src/test/ui/compile-fail-migration/ufcs-qpath-self-mismatch.stderr @@ -0,0 +1,24 @@ +error[E0277]: cannot add `u32` to `i32` + --> $DIR/ufcs-qpath-self-mismatch.rs:14:5 + | +LL | >::add(1, 2); + | ^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32` + | + = help: the trait `std::ops::Add` is not implemented for `i32` + +error[E0308]: mismatched types + --> $DIR/ufcs-qpath-self-mismatch.rs:16:28 + | +LL | >::add(1u32, 2); + | ^^^^ expected i32, found u32 + +error[E0308]: mismatched types + --> $DIR/ufcs-qpath-self-mismatch.rs:18:31 + | +LL | >::add(1, 2u32); + | ^^^^ expected i32, found u32 + +error: aborting due to 3 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.rs b/src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.rs new file mode 100644 index 00000000000..3a3ea058b4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that parenthetical notation is feature-gated except with the +// `Fn` traits. + +use std::marker; + +trait Foo { + type Output; + + fn dummy(&self, a: A) { } +} + +fn main() { + let x: Box; + //~^ ERROR parenthetical notation is only stable when used with `Fn`-family + + // No errors with these: + let x: Box; + let x: Box; + let x: Box; +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.stderr new file mode 100644 index 00000000000..aea57d9cb4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-feature-gate.stderr @@ -0,0 +1,11 @@ +error[E0658]: parenthetical notation is only stable when used with `Fn`-family traits (see issue #29625) + --> $DIR/unboxed-closure-feature-gate.rs:23:16 + | +LL | let x: Box; + | ^^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.nll.stderr new file mode 100644 index 00000000000..e74c66c27b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.nll.stderr @@ -0,0 +1,27 @@ +error[E0507]: cannot move out of captured variable in an `Fn` closure + --> $DIR/unboxed-closure-illegal-move.rs:25:31 + | +LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured variable in an `Fn` closure + +error[E0507]: cannot move out of captured variable in an `FnMut` closure + --> $DIR/unboxed-closure-illegal-move.rs:29:35 + | +LL | let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured variable in an `FnMut` closure + +error[E0507]: cannot move out of captured variable in an `Fn` closure + --> $DIR/unboxed-closure-illegal-move.rs:38:36 + | +LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured variable in an `Fn` closure + +error[E0507]: cannot move out of captured variable in an `FnMut` closure + --> $DIR/unboxed-closure-illegal-move.rs:42:40 + | +LL | let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured variable in an `FnMut` closure + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.rs b/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.rs new file mode 100644 index 00000000000..427be560760 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.rs @@ -0,0 +1,48 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +// Tests that we can't move out of an unboxed closure environment +// if the upvar is captured by ref or the closure takes self by +// reference. + +fn to_fn>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } +fn to_fn_once>(f: F) -> F { f } + +fn main() { + // By-ref cases + { + let x = Box::new(0); + let f = to_fn(|| drop(x)); //~ ERROR cannot move + } + { + let x = Box::new(0); + let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move + } + { + let x = Box::new(0); + let f = to_fn_once(|| drop(x)); // OK -- FnOnce + } + // By-value cases + { + let x = Box::new(0); + let f = to_fn(move || drop(x)); //~ ERROR cannot move + } + { + let x = Box::new(0); + let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move + } + { + let x = Box::new(0); + let f = to_fn_once(move || drop(x)); // this one is ok + } +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.stderr new file mode 100644 index 00000000000..7ff4c1c03ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-illegal-move.stderr @@ -0,0 +1,35 @@ +error[E0507]: cannot move out of captured outer variable in an `Fn` closure + --> $DIR/unboxed-closure-illegal-move.rs:25:31 + | +LL | let x = Box::new(0); + | - captured outer variable +LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured outer variable in an `Fn` closure + +error[E0507]: cannot move out of captured outer variable in an `FnMut` closure + --> $DIR/unboxed-closure-illegal-move.rs:29:35 + | +LL | let x = Box::new(0); + | - captured outer variable +LL | let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured outer variable in an `FnMut` closure + +error[E0507]: cannot move out of captured outer variable in an `Fn` closure + --> $DIR/unboxed-closure-illegal-move.rs:38:36 + | +LL | let x = Box::new(0); + | - captured outer variable +LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured outer variable in an `Fn` closure + +error[E0507]: cannot move out of captured outer variable in an `FnMut` closure + --> $DIR/unboxed-closure-illegal-move.rs:42:40 + | +LL | let x = Box::new(0); + | - captured outer variable +LL | let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move + | ^ cannot move out of captured outer variable in an `FnMut` closure + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.nll.stderr new file mode 100644 index 00000000000..084d7ff3bcd --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.nll.stderr @@ -0,0 +1,75 @@ +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:19:13 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +LL | move || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:20:17 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +LL | move || x = 1; //~ ERROR cannot assign +LL | move || set(&mut x); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:21:13 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | move || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:22:17 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | move || set(&mut x); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:23:8 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:25:12 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || set(&mut x); //~ ERROR cannot assign + | ^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:26:8 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || x = 1; //~ ERROR cannot assign + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:28:12 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || set(&mut x); //~ ERROR cannot assign + | ^^^^^^ cannot borrow as mutable + +error: aborting due to 8 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.rs b/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.rs new file mode 100644 index 00000000000..2d998374229 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that even unboxed closures that are capable of mutating their +// environment cannot mutate captured variables that have not been +// declared mutable (#18335) + +fn set(x: &mut usize) { *x = 0; } + +fn main() { + let x = 0; + move || x = 1; //~ ERROR cannot assign + move || set(&mut x); //~ ERROR cannot borrow + move || x = 1; //~ ERROR cannot assign + move || set(&mut x); //~ ERROR cannot borrow + || x = 1; //~ ERROR cannot assign + // FIXME: this should be `cannot borrow` (issue #18330) + || set(&mut x); //~ ERROR cannot assign + || x = 1; //~ ERROR cannot assign + // FIXME: this should be `cannot borrow` (issue #18330) + || set(&mut x); //~ ERROR cannot assign +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.stderr new file mode 100644 index 00000000000..02fbb5f17ee --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-immutable-capture.stderr @@ -0,0 +1,69 @@ +error[E0595]: closure cannot assign to immutable local variable `x` + --> $DIR/unboxed-closure-immutable-capture.rs:23:5 + | +LL | let x = 0; + | - consider changing this to `mut x` +... +LL | || x = 1; //~ ERROR cannot assign + | ^^ cannot borrow mutably + +error[E0595]: closure cannot assign to immutable local variable `x` + --> $DIR/unboxed-closure-immutable-capture.rs:25:5 + | +LL | let x = 0; + | - consider changing this to `mut x` +... +LL | || set(&mut x); //~ ERROR cannot assign + | ^^ cannot borrow mutably + +error[E0595]: closure cannot assign to immutable local variable `x` + --> $DIR/unboxed-closure-immutable-capture.rs:26:5 + | +LL | let x = 0; + | - consider changing this to `mut x` +... +LL | || x = 1; //~ ERROR cannot assign + | ^^ cannot borrow mutably + +error[E0595]: closure cannot assign to immutable local variable `x` + --> $DIR/unboxed-closure-immutable-capture.rs:28:5 + | +LL | let x = 0; + | - consider changing this to `mut x` +... +LL | || set(&mut x); //~ ERROR cannot assign + | ^^ cannot borrow mutably + +error[E0594]: cannot assign to captured outer variable in an `FnMut` closure + --> $DIR/unboxed-closure-immutable-capture.rs:19:13 + | +LL | let x = 0; + | - help: consider making `x` mutable: `mut x` +LL | move || x = 1; //~ ERROR cannot assign + | ^^^^^ + +error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:20:22 + | +LL | move || set(&mut x); //~ ERROR cannot borrow + | ^ + +error[E0594]: cannot assign to captured outer variable in an `FnMut` closure + --> $DIR/unboxed-closure-immutable-capture.rs:21:13 + | +LL | let x = 0; + | - help: consider making `x` mutable: `mut x` +... +LL | move || x = 1; //~ ERROR cannot assign + | ^^^^^ + +error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:22:22 + | +LL | move || set(&mut x); //~ ERROR cannot borrow + | ^ + +error: aborting due to 8 previous errors + +Some errors occurred: E0594, E0595, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-region.rs b/src/test/ui/compile-fail-migration/unboxed-closure-region.rs new file mode 100644 index 00000000000..1c86dda3378 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-region.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an unboxed closure that captures a free variable by +// reference cannot escape the region of that variable. +fn main() { + let _f = { + let x = 0; + || x //~ ERROR `x` does not live long enough + }; +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-region.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-region.stderr new file mode 100644 index 00000000000..946a52c4673 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-region.stderr @@ -0,0 +1,15 @@ +error[E0597]: `x` does not live long enough + --> $DIR/unboxed-closure-region.rs:16:12 + | +LL | || x //~ ERROR `x` does not live long enough + | -- ^ borrowed value does not live long enough + | | + | capture occurs here +LL | }; + | - borrowed value only lives until here +LL | } + | - borrowed value needs to live until here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.rs new file mode 100644 index 00000000000..849f7e0573c --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test interaction between unboxed closure sugar and default type +// parameters (should be exactly as if angle brackets were used). + +#![feature(unboxed_closures)] +#![allow(dead_code)] + +trait Foo { + type Output; + fn dummy(&self, t: T, v: V); +} + +trait Eq { fn same_types(&self, x: &X) -> bool { true } } +impl Eq for X { } +fn eq() where A : Eq { } + +fn test<'a,'b>() { + // Parens are equivalent to omitting default in angle. + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + + // In angle version, we supply something other than the default + eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); + //~^ ERROR E0277 + + // Supply default explicitly. + eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >(); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.stderr new file mode 100644 index 00000000000..fccf295b72c --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-default.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `dyn Foo<(isize,), isize, Output=()>: Eq>` is not satisfied + --> $DIR/unboxed-closure-sugar-default.rs:31:5 + | +LL | eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq>` is not implemented for `dyn Foo<(isize,), isize, Output=()>` + | +note: required by `eq` + --> $DIR/unboxed-closure-sugar-default.rs:24:1 + | +LL | fn eq() where A : Eq { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.rs new file mode 100644 index 00000000000..0cf44a2ca61 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.rs @@ -0,0 +1,58 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the unboxed closure sugar can be used with an arbitrary +// struct type and that it is equivalent to the same syntax using +// angle brackets. This test covers only simple types and in +// particular doesn't test bound regions. + +#![feature(unboxed_closures)] +#![allow(dead_code)] + +trait Foo { + type Output; + fn dummy(&self, t: T, u: Self::Output); +} + +trait Eq { } +impl Eq for X { } +fn eq>() { } + +fn test<'a,'b>() { + // No errors expected: + eq::< Foo<(),Output=()>, Foo() >(); + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >(); + eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >(); + eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >(); + + // Test that anonymous regions in `()` form are equivalent + // to fresh bound regions, and that we can intermingle + // named and anonymous as we choose: + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + for<'x> Foo(&'x isize,&usize) -> usize >(); + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + for<'y> Foo(&isize,&'y usize) -> usize >(); + eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + Foo(&isize,&usize) -> usize >(); + + // lifetime elision + eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>, + Foo(&isize) -> &isize >(); + + // Errors expected: + eq::< Foo<(),Output=()>, + Foo(char) >(); + //~^^ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.stderr new file mode 100644 index 00000000000..7d687a55df9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-equiv.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `dyn Foo<(char,), Output=()>: Eq>` is not satisfied + --> $DIR/unboxed-closure-sugar-equiv.rs:53:5 + | +LL | / eq::< Foo<(),Output=()>, +LL | | Foo(char) >(); + | |___________________________________________________________________^ the trait `Eq>` is not implemented for `dyn Foo<(char,), Output=()>` + | +note: required by `eq` + --> $DIR/unboxed-closure-sugar-equiv.rs:26:1 + | +LL | fn eq>() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.rs new file mode 100644 index 00000000000..a6f59b78823 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the unboxed closure sugar can be used with an arbitrary +// struct type and that it is equivalent to the same syntax using +// angle brackets. This test covers only simple types and in +// particular doesn't test bound regions. + +#![feature(unboxed_closures)] +#![allow(dead_code)] + +use std::marker; + +trait Foo { + type Output; + fn dummy(&self, t: T); +} + +trait Eq { } +impl Eq for X { } +fn eq>() { } + +fn main() { + eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>, + Foo(&isize) -> &isize >(); + eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, + Foo(&isize) -> (&isize, &isize) >(); + + let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.stderr new file mode 100644 index 00000000000..fa74e6e6607 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-lifetime-elision.stderr @@ -0,0 +1,11 @@ +error[E0106]: missing lifetime specifier + --> $DIR/unboxed-closure-sugar-lifetime-elision.rs:36:35 + | +LL | let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier + | ^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.rs new file mode 100644 index 00000000000..ed27a4d0b2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// Test that the `Fn` traits require `()` form without a feature gate. + +fn bar1(x: &Fn<(), Output=()>) { + //~^ ERROR of `Fn`-family traits' type parameters is subject to change +} + +fn bar2(x: &T) where T: Fn<()> { + //~^ ERROR of `Fn`-family traits' type parameters is subject to change +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.stderr new file mode 100644 index 00000000000..bda88f4e4d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-not-used-on-fn.stderr @@ -0,0 +1,19 @@ +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:14:13 + | +LL | fn bar1(x: &Fn<(), Output=()>) { + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:18:28 + | +LL | fn bar2(x: &T) where T: Fn<()> { + | ^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.rs new file mode 100644 index 00000000000..18a1185d695 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.rs @@ -0,0 +1,46 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test interaction between unboxed closure sugar and region +// parameters (should be exactly as if angle brackets were used +// and regions omitted). + +#![feature(unboxed_closures)] +#![allow(dead_code)] + +use std::marker; + +trait Foo<'a,T> { + type Output; + fn dummy(&'a self) -> &'a (T,Self::Output); +} + +trait Eq { fn is_of_eq_type(&self, x: &X) -> bool { true } } +impl Eq for X { } +fn eq>() { } + +fn same_type>(a: A, b: B) { } + +fn test<'a,'b>() { + // Parens are equivalent to omitting default in angle. + eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + + // Here we specify 'static explicitly in angle-bracket version. + // Parenthesized winds up getting inferred. + eq::< Foo<'static, (isize,),Output=()>, Foo(isize) >(); +} + +fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { +//~^ ERROR wrong number of lifetime parameters: expected 1, found 0 + // Here, the omitted lifetimes are expanded to distinct things. + same_type(x, y) +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.stderr new file mode 100644 index 00000000000..663034ba143 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-region.stderr @@ -0,0 +1,9 @@ +error[E0107]: wrong number of lifetime parameters: expected 1, found 0 + --> $DIR/unboxed-closure-sugar-region.rs:40:43 + | +LL | fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { + | ^^^^^^^^^^ expected 1 lifetime parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.rs new file mode 100644 index 00000000000..3f88f16d2c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// Test that parentheses form doesn't work with struct types appearing in local variables. + +struct Bar { + f: A +} + +fn bar() { + let x: Box = panic!(); + //~^ ERROR parenthesized parameters may only be used with a trait +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.stderr new file mode 100644 index 00000000000..1ca99680b53 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-1.stderr @@ -0,0 +1,9 @@ +error[E0214]: parenthesized parameters may only be used with a trait + --> $DIR/unboxed-closure-sugar-used-on-struct-1.rs:19:19 + | +LL | let x: Box = panic!(); + | ^^ only traits may use parentheses + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0214`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.rs new file mode 100644 index 00000000000..42fffe546c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that parentheses form parses in expression paths. + +struct Bar { + f: A, r: R +} + +impl Bar { + fn new() -> Bar { panic!() } +} + +fn bar() { + let b = Bar::::new(); // OK + + let b = Bar::(isize, usize)::new(); // OK too (for the parser) + //~^ ERROR parenthesized parameters may only be used with a trait +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.stderr new file mode 100644 index 00000000000..d6c08a70565 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct-3.stderr @@ -0,0 +1,9 @@ +error[E0214]: parenthesized parameters may only be used with a trait + --> $DIR/unboxed-closure-sugar-used-on-struct-3.rs:24:16 + | +LL | let b = Bar::(isize, usize)::new(); // OK too (for the parser) + | ^^^^^^^^^^^^^^^^ only traits may use parentheses + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0214`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.rs new file mode 100644 index 00000000000..5fcde4facbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that parentheses form doesn't work with struct types appearing in argument types. + +struct Bar { + f: A +} + +fn foo(b: Box) { + //~^ ERROR parenthesized parameters may only be used with a trait + //~| ERROR the type placeholder `_` is not allowed within types on item signatures +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.stderr new file mode 100644 index 00000000000..954ec4d63a6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-used-on-struct.stderr @@ -0,0 +1,16 @@ +error[E0214]: parenthesized parameters may only be used with a trait + --> $DIR/unboxed-closure-sugar-used-on-struct.rs:17:18 + | +LL | fn foo(b: Box) { + | ^^ only traits may use parentheses + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/unboxed-closure-sugar-used-on-struct.rs:17:15 + | +LL | fn foo(b: Box) { + | ^^^^^ not allowed in type signatures + +error: aborting due to 2 previous errors + +Some errors occurred: E0121, E0214. +For more information about an error, try `rustc --explain E0121`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs new file mode 100644 index 00000000000..bb7e02d0d8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +trait One { fn foo(&self) -> A; } + +fn foo(_: &One()) //~ ERROR associated type `Output` not found for `One<()>` +{} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr new file mode 100644 index 00000000000..e7476f0fa6d --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr @@ -0,0 +1,9 @@ +error[E0220]: associated type `Output` not found for `One<()>` + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:15:15 + | +LL | fn foo(_: &One()) //~ ERROR associated type `Output` not found for `One<()>` + | ^^ associated type `Output` not found + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0220`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs new file mode 100644 index 00000000000..20fdd52b82a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +trait Three { fn dummy(&self) -> (A,B,C); } + +fn foo(_: &Three()) +//~^ ERROR wrong number of type arguments +//~| ERROR associated type `Output` not found +{} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr new file mode 100644 index 00000000000..feac4274357 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr @@ -0,0 +1,16 @@ +error[E0243]: wrong number of type arguments: expected 3, found 1 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:15:12 + | +LL | fn foo(_: &Three()) + | ^^^^^^^ expected 3 type arguments + +error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>` + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:15:17 + | +LL | fn foo(_: &Three()) + | ^^ associated type `Output` not found + +error: aborting due to 2 previous errors + +Some errors occurred: E0220, E0243. +For more information about an error, try `rustc --explain E0220`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.rs b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.rs new file mode 100644 index 00000000000..027fa6b0fe3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +trait Zero { fn dummy(&self); } + +fn foo(_: Zero()) + //~^ ERROR wrong number of type arguments + //~| ERROR associated type `Output` not found for `Zero` +{} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr new file mode 100644 index 00000000000..457bea046c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr @@ -0,0 +1,16 @@ +error[E0244]: wrong number of type arguments: expected 0, found 1 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:15:11 + | +LL | fn foo(_: Zero()) + | ^^^^^^ expected no type arguments + +error[E0220]: associated type `Output` not found for `Zero` + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:15:15 + | +LL | fn foo(_: Zero()) + | ^^ associated type `Output` not found + +error: aborting due to 2 previous errors + +Some errors occurred: E0220, E0244. +For more information about an error, try `rustc --explain E0220`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.rs b/src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.rs new file mode 100644 index 00000000000..ad7e6784a0a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an unboxed closure that mutates a free variable will +// cause borrow conflicts. + +fn main() { + let mut x = 0; + let f = || x += 1; + let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.stderr new file mode 100644 index 00000000000..cd62d77caed --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-borrow-conflict.stderr @@ -0,0 +1,11 @@ +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/unboxed-closures-borrow-conflict.rs:17:9 + | +LL | let f = || x += 1; + | -- borrow of `x` occurs here +LL | let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed + | ^^ use of borrowed `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.nll.stderr new file mode 100644 index 00000000000..a4527e79392 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.nll.stderr @@ -0,0 +1,66 @@ +error[E0597]: `factorial` does not live long enough + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:25:17 + | +LL | let f = |x: u32| -> u32 { + | --------------- value captured here +LL | let g = factorial.as_ref().unwrap(); + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `factorial` dropped here while still borrowed + | borrow later used here, when `factorial` is dropped + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0506]: cannot assign to `factorial` because it is borrowed + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:30:5 + | +LL | let f = |x: u32| -> u32 { + | --------------- borrow of `factorial` occurs here +LL | let g = factorial.as_ref().unwrap(); + | --------- borrow occurs due to use in closure +... +LL | factorial = Some(Box::new(f)); + | ^^^^^^^^^ + | | + | assignment to borrowed `factorial` occurs here + | borrow later used here + +error[E0597]: `factorial` does not live long enough + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:38:17 + | +LL | let f = |x: u32| -> u32 { + | --------------- value captured here +LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` +LL | let g = factorial.as_ref().unwrap(); + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `factorial` dropped here while still borrowed + | borrow later used here, when `factorial` is dropped + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0506]: cannot assign to `factorial` because it is borrowed + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:42:5 + | +LL | let f = |x: u32| -> u32 { + | --------------- borrow of `factorial` occurs here +LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` +LL | let g = factorial.as_ref().unwrap(); + | --------- borrow occurs due to use in closure +... +LL | factorial = Some(Box::new(f)); + | ^^^^^^^^^ + | | + | assignment to borrowed `factorial` occurs here + | borrow later used here + +error: aborting due to 4 previous errors + +Some errors occurred: E0506, E0597. +For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.rs b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.rs new file mode 100644 index 00000000000..ce60521034e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.rs @@ -0,0 +1,45 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various unsuccessful attempts to put the unboxed closure kind +// inference into an awkward position that might require fixed point +// iteration (basically where inferring the kind of a closure `c` +// would require knowing the kind of `c`). I currently believe this is +// impossible. + +fn a() { + // This case of recursion wouldn't even require fixed-point + // iteration, but it still doesn't work. The weird structure with + // the `Option` is to avoid giving any useful hints about the `Fn` + // kind via the expected type. + let mut factorial: Option u32>> = None; + + let f = |x: u32| -> u32 { + let g = factorial.as_ref().unwrap(); + //~^ ERROR `factorial` does not live long enough + if x == 0 {1} else {x * g(x-1)} + }; + + factorial = Some(Box::new(f)); +} + +fn b() { + let mut factorial: Option u32 + 'static>> = None; + + let f = |x: u32| -> u32 { + //~^ ERROR closure may outlive the current function, but it borrows `factorial` + let g = factorial.as_ref().unwrap(); + if x == 0 {1} else {x * g(x-1)} + }; + + factorial = Some(Box::new(f)); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.stderr new file mode 100644 index 00000000000..8390e9f0f95 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-1.stderr @@ -0,0 +1,30 @@ +error[E0597]: `factorial` does not live long enough + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:25:17 + | +LL | let f = |x: u32| -> u32 { + | --------------- capture occurs here +LL | let g = factorial.as_ref().unwrap(); + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - borrowed value dropped before borrower + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0373]: closure may outlive the current function, but it borrows `factorial`, which is owned by the current function + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:36:13 + | +LL | let f = |x: u32| -> u32 { + | ^^^^^^^^^^^^^^^ may outlive borrowed value `factorial` +LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` +LL | let g = factorial.as_ref().unwrap(); + | --------- `factorial` is borrowed here +help: to force the closure to take ownership of `factorial` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |x: u32| -> u32 { + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0373, E0597. +For more information about an error, try `rustc --explain E0373`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.rs b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.rs new file mode 100644 index 00000000000..8f5bf827fcf --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.rs @@ -0,0 +1,39 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various unsuccessful attempts to put the unboxed closure kind +// inference into an awkward position that might require fixed point +// iteration (basically where inferring the kind of a closure `c` +// would require knowing the kind of `c`). I currently believe this is +// impossible. + +fn a() { + let mut closure0 = None; + let vec = vec![1, 2, 3]; + + loop { + { + let closure1 = || { + match closure0.take() { + Some(c) => { + return c(); + //~^ ERROR type annotations needed + } + None => { } + } + }; + closure1(); + } + + closure0 = || vec; + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.stderr new file mode 100644 index 00000000000..fd6858cf7bf --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-failed-recursive-fn-2.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed + --> $DIR/unboxed-closures-failed-recursive-fn-2.rs:26:32 + | +LL | let mut closure0 = None; + | ------------ consider giving `closure0` a type +... +LL | return c(); + | ^^^ cannot infer type + | + = note: type must be known at this point + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.rs b/src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.rs new file mode 100644 index 00000000000..2e865b2aac8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks that the Fn trait hierarchy rules do not permit +// Fn to be used where FnMut is implemented. + +#![feature(fn_traits, unboxed_closures)] +#![feature(overloaded_calls)] + +use std::ops::{Fn,FnMut,FnOnce}; + +struct S; + +impl FnMut<(isize,)> for S { + extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize { + x * x + } +} + +impl FnOnce<(isize,)> for S { + type Output = isize; + + extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) } +} + +fn call_itisize>(f: &F, x: isize) -> isize { + f.call((x,)) +} + +fn main() { + let x = call_it(&S, 22); + //~^ ERROR E0277 +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.stderr new file mode 100644 index 00000000000..95aa3f15b76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-fnmut-as-fn.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `S: std::ops::Fn<(isize,)>` is not satisfied + --> $DIR/unboxed-closures-fnmut-as-fn.rs:38:13 + | +LL | let x = call_it(&S, 22); + | ^^^^^^^ the trait `std::ops::Fn<(isize,)>` is not implemented for `S` + | +note: required by `call_it` + --> $DIR/unboxed-closures-fnmut-as-fn.rs:33:1 + | +LL | fn call_itisize>(f: &F, x: isize) -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr new file mode 100644 index 00000000000..a113c1ae27f --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:27:15 + | +LL | x.set(y); //~ ERROR E0312 + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:27:9 + | +LL | doit(0, &|x, y| { + | - - has type `&'1 i32` + | | + | has type `&std::cell::Cell<&'2 i32>` +LL | x.set(y); //~ ERROR E0312 + | ^^^^^^^^ argument requires that `'1` must outlive `'2` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.rs b/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.rs new file mode 100644 index 00000000000..bfb24c58722 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(fn_traits)] + +// That a closure whose expected argument types include two distinct +// bound regions. + +use std::cell::Cell; + +fn doit(val: T, f: &F) + where F : Fn(&Cell<&T>, &T) +{ + let x = Cell::new(&val); + f.call((&x,&val)) +} + +pub fn main() { + doit(0, &|x, y| { + x.set(y); //~ ERROR E0312 + }); +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.stderr new file mode 100644 index 00000000000..7e59347155b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-argument-types-two-region-pointers.stderr @@ -0,0 +1,26 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:27:15 + | +LL | x.set(y); //~ ERROR E0312 + | ^ + | +note: ...the reference is valid for the anonymous lifetime #3 defined on the body at 26:14... + --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:26:14 + | +LL | doit(0, &|x, y| { + | ______________^ +LL | | x.set(y); //~ ERROR E0312 +LL | | }); + | |_____^ +note: ...but the borrowed content is only valid for the anonymous lifetime #4 defined on the body at 26:14 + --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:26:14 + | +LL | doit(0, &|x, y| { + | ______________^ +LL | | x.set(y); //~ ERROR E0312 +LL | | }); + | |_____^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr new file mode 100644 index 00000000000..718c3a19938 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr @@ -0,0 +1,21 @@ +error[E0596]: cannot borrow `tick1` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:27:9 + | +LL | let tick1 = || { + | ----- help: consider changing this to be mutable: `mut tick1` +... +LL | tick1(); + | ^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `tick2` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:30:5 + | +LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` + | ----- help: consider changing this to be mutable: `mut tick2` +... +LL | tick2(); //~ ERROR cannot borrow + | ^^^^^ cannot borrow as mutable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs new file mode 100644 index 00000000000..7c5ea031596 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnMut`). + +fn main() { + let mut counter = 0; + + // Here this must be inferred to FnMut so that it can mutate counter, + // but we forgot the mut. + let tick1 = || { + counter += 1; + }; + + // In turn, tick2 must be inferred to FnMut so that it can call + // tick1, but we forgot the mut. The error message we currently + // get seems... suboptimal. + let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` + tick1(); + }; + + tick2(); //~ ERROR cannot borrow +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr new file mode 100644 index 00000000000..bb2ffcd21b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr @@ -0,0 +1,22 @@ +error[E0595]: closure cannot assign to immutable local variable `tick1` + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:26:17 + | +LL | let tick1 = || { + | ----- consider changing this to `mut tick1` +... +LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` + | ^^ cannot borrow mutably + +error[E0596]: cannot borrow immutable local variable `tick2` as mutable + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:30:5 + | +LL | let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` + | ----- consider changing this to `mut tick2` +... +LL | tick2(); //~ ERROR cannot borrow + | ^^^^^ cannot borrow mutably + +error: aborting due to 2 previous errors + +Some errors occurred: E0595, E0596. +For more information about an error, try `rustc --explain E0595`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.nll.stderr new file mode 100644 index 00000000000..c57f97652b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:17:5 + | +LL | let tick = || counter += 1; + | ---- help: consider changing this to be mutable: `mut tick` +LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + | ^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.rs b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.rs new file mode 100644 index 00000000000..9e4ed307996 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnMut`). + +fn main() { + let mut counter = 0; + let tick = || counter += 1; + tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.stderr new file mode 100644 index 00000000000..22e11b6977c --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-missing-mut.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable local variable `tick` as mutable + --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:17:5 + | +LL | let tick = || counter += 1; + | ---- consider changing this to `mut tick` +LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + | ^^^^ cannot borrow mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr new file mode 100644 index 00000000000..a26dc08e54a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:17:5 + | +LL | let tick = move || counter += 1; + | ---- help: consider changing this to be mutable: `mut tick` +LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + | ^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.rs b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.rs new file mode 100644 index 00000000000..de17d25b4c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnMut`). + +fn main() { + let mut counter = 0; + let tick = move || counter += 1; + tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.stderr new file mode 100644 index 00000000000..f9fd6c21b70 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnmut-move-missing-mut.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable local variable `tick` as mutable + --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:17:5 + | +LL | let tick = move || counter += 1; + | ---- consider changing this to `mut tick` +LL | tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + | ^^^^ cannot borrow mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.nll.stderr new file mode 100644 index 00000000000..f4756696b6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.nll.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `tick` + --> $DIR/unboxed-closures-infer-fnonce-call-twice.rs:20:5 + | +LL | tick(); + | ---- value moved here +LL | tick(); //~ ERROR use of moved value: `tick` + | ^^^^ value used here after move + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.rs b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.rs new file mode 100644 index 00000000000..0050fbdde26 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnMut`). + +use std::mem; + +fn main() { + let mut counter: Vec = Vec::new(); + let tick = || mem::drop(counter); + tick(); + tick(); //~ ERROR use of moved value: `tick` +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.stderr new file mode 100644 index 00000000000..c713b3dd8fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-call-twice.stderr @@ -0,0 +1,17 @@ +error[E0382]: use of moved value: `tick` + --> $DIR/unboxed-closures-infer-fnonce-call-twice.rs:20:5 + | +LL | tick(); + | ---- value moved here +LL | tick(); //~ ERROR use of moved value: `tick` + | ^^^^ value used here after move + | +note: closure cannot be invoked more than once because it moves the variable `counter` out of its environment + --> $DIR/unboxed-closures-infer-fnonce-call-twice.rs:18:29 + | +LL | let tick = || mem::drop(counter); + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr new file mode 100644 index 00000000000..95ed6736278 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `tick` + --> $DIR/unboxed-closures-infer-fnonce-move-call-twice.rs:20:5 + | +LL | tick(); + | ---- value moved here +LL | tick(); //~ ERROR use of moved value: `tick` + | ^^^^ value used here after move + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.rs b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.rs new file mode 100644 index 00000000000..f9709b8c596 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnMut`). + +use std::mem; + +fn main() { + let mut counter: Vec = Vec::new(); + let tick = move || mem::drop(counter); + tick(); + tick(); //~ ERROR use of moved value: `tick` +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.stderr new file mode 100644 index 00000000000..a9006318cd8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-infer-fnonce-move-call-twice.stderr @@ -0,0 +1,17 @@ +error[E0382]: use of moved value: `tick` + --> $DIR/unboxed-closures-infer-fnonce-move-call-twice.rs:20:5 + | +LL | tick(); + | ---- value moved here +LL | tick(); //~ ERROR use of moved value: `tick` + | ^^^^ value used here after move + | +note: closure cannot be invoked more than once because it moves the variable `counter` out of its environment + --> $DIR/unboxed-closures-infer-fnonce-move-call-twice.rs:18:34 + | +LL | let tick = move || mem::drop(counter); + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.nll.stderr new file mode 100644 index 00000000000..f765f207303 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.nll.stderr @@ -0,0 +1,45 @@ +error[E0594]: cannot assign to `n`, as it is not declared as mutable + --> $DIR/unboxed-closures-mutate-upvar.rs:25:9 + | +LL | let n = 0; + | - help: consider changing this to be mutable: `mut n` +LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign +LL | n += 1; + | ^^^^^^ cannot assign + +error[E0594]: cannot assign to `n`, as it is not declared as mutable + --> $DIR/unboxed-closures-mutate-upvar.rs:42:9 + | +LL | let n = 0; + | - help: consider changing this to be mutable: `mut n` +... +LL | n += 1; //~ ERROR cannot assign + | ^^^^^^ cannot assign + +error[E0594]: cannot assign to `n`, as it is not declared as mutable + --> $DIR/unboxed-closures-mutate-upvar.rs:56:9 + | +LL | let n = 0; + | - help: consider changing this to be mutable: `mut n` +LL | let mut f = to_fn(move || { +LL | n += 1; //~ ERROR cannot assign + | ^^^^^^ cannot assign + +error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure + --> $DIR/unboxed-closures-mutate-upvar.rs:63:9 + | +LL | n += 1; //~ ERROR cannot assign + | ^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/unboxed-closures-mutate-upvar.rs:62:23 + | +LL | let mut f = to_fn(move || { + | _______________________^ +LL | | n += 1; //~ ERROR cannot assign +LL | | }); + | |_____^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.rs b/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.rs new file mode 100644 index 00000000000..35052ec0bd5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.rs @@ -0,0 +1,67 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we cannot mutate an outer variable that is not declared +// as `mut` through a closure. Also test that we CAN mutate a moved copy, +// unless this is a `Fn` closure. Issue #16749. + +#![feature(unboxed_closures)] + +use std::mem; + +fn to_fn>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } + +fn a() { + let n = 0; + let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign + n += 1; + }); +} + +fn b() { + let mut n = 0; + let mut f = to_fn_mut(|| { + n += 1; // OK + }); +} + +fn c() { + let n = 0; + let mut f = to_fn_mut(move || { + // If we just did a straight-forward desugaring, this would + // compile, but we do something a bit more subtle, and hence + // we get an error. + n += 1; //~ ERROR cannot assign + }); +} + +fn d() { + let mut n = 0; + let mut f = to_fn_mut(move || { + n += 1; // OK + }); +} + +fn e() { + let n = 0; + let mut f = to_fn(move || { + n += 1; //~ ERROR cannot assign + }); +} + +fn f() { + let mut n = 0; + let mut f = to_fn(move || { + n += 1; //~ ERROR cannot assign + }); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.stderr new file mode 100644 index 00000000000..1164a864b6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-mutate-upvar.stderr @@ -0,0 +1,53 @@ +error[E0595]: closure cannot assign to immutable local variable `n` + --> $DIR/unboxed-closures-mutate-upvar.rs:24:27 + | +LL | let n = 0; + | - consider changing this to `mut n` +LL | let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign + | ^^ cannot borrow mutably + +error[E0594]: cannot assign to captured outer variable in an `FnMut` closure + --> $DIR/unboxed-closures-mutate-upvar.rs:42:9 + | +LL | let n = 0; + | - help: consider making `n` mutable: `mut n` +... +LL | n += 1; //~ ERROR cannot assign + | ^^^^^^ + +error[E0594]: cannot assign to captured outer variable in an `Fn` closure + --> $DIR/unboxed-closures-mutate-upvar.rs:56:9 + | +LL | n += 1; //~ ERROR cannot assign + | ^^^^^^ + | + = note: `Fn` closures cannot capture their enclosing environment for modifications +help: consider changing this closure to take self by mutable reference + --> $DIR/unboxed-closures-mutate-upvar.rs:55:23 + | +LL | let mut f = to_fn(move || { + | _______________________^ +LL | | n += 1; //~ ERROR cannot assign +LL | | }); + | |_____^ + +error[E0594]: cannot assign to captured outer variable in an `Fn` closure + --> $DIR/unboxed-closures-mutate-upvar.rs:63:9 + | +LL | n += 1; //~ ERROR cannot assign + | ^^^^^^ + | + = note: `Fn` closures cannot capture their enclosing environment for modifications +help: consider changing this closure to take self by mutable reference + --> $DIR/unboxed-closures-mutate-upvar.rs:62:23 + | +LL | let mut f = to_fn(move || { + | _______________________^ +LL | | n += 1; //~ ERROR cannot assign +LL | | }); + | |_____^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0594, E0595. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr new file mode 100644 index 00000000000..be18e7cee91 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr @@ -0,0 +1,20 @@ +error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:24:9 + | +LL | counter += 1; + | ^^^^^^^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:23:10 + | +LL | call(|| { + | __________^ +LL | | counter += 1; +LL | | //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure +LL | | //[mir]~^^ ERROR cannot assign to `counter` +LL | | }); + | |_____^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr new file mode 100644 index 00000000000..756bf06440c --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr @@ -0,0 +1,20 @@ +error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:24:9 + | +LL | counter += 1; + | ^^^^^^^^^^^^ + | +help: consider changing this closure to take self by mutable reference + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:23:10 + | +LL | call(|| { + | __________^ +LL | | counter += 1; +LL | | //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure +LL | | //[mir]~^^ ERROR cannot assign to `counter` +LL | | }); + | |_____^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0387`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr new file mode 100644 index 00000000000..be18e7cee91 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr @@ -0,0 +1,20 @@ +error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:24:9 + | +LL | counter += 1; + | ^^^^^^^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:23:10 + | +LL | call(|| { + | __________^ +LL | | counter += 1; +LL | | //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure +LL | | //[mir]~^^ ERROR cannot assign to `counter` +LL | | }); + | |_____^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.rs b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.rs new file mode 100644 index 00000000000..f20719ec7fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-mutated-upvar-from-fn-closure.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Test that a by-ref `FnMut` closure gets an error when it tries to +// mutate a value. + +fn call(f: F) where F : Fn() { + f(); +} + +fn main() { + let mut counter = 0; + call(|| { + counter += 1; + //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure + //[mir]~^^ ERROR cannot assign to `counter` + }); +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr new file mode 100644 index 00000000000..e2747e1bb62 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr @@ -0,0 +1,13 @@ +error[E0499]: cannot borrow `*self` as mutable more than once at a time + --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:32:21 + | +LL | (self.func)(self, arg) + | ------------^^^^------ + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + | borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.rs b/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.rs new file mode 100644 index 00000000000..433c0c839c5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.rs @@ -0,0 +1,53 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(core, fn_traits, unboxed_closures)] + +use std::marker::PhantomData; + +// An erroneous variant of `run-pass/unboxed_closures-infer-recursive-fn.rs` +// where we attempt to perform mutation in the recursive function. This fails to compile +// because it winds up requiring `FnMut` which enforces linearity. + +struct YCombinator { + func: F, + marker: PhantomData<(A,R)>, +} + +impl YCombinator { + fn new(f: F) -> YCombinator { + YCombinator { func: f, marker: PhantomData } + } +} + +impl R, A) -> R> FnMut<(A,)> for YCombinator { + extern "rust-call" fn call_mut(&mut self, (arg,): (A,)) -> R { + (self.func)(self, arg) + //~^ ERROR cannot borrow `*self` as mutable more than once at a time + } +} + +impl R, A) -> R> FnOnce<(A,)> for YCombinator { + type Output = R; + extern "rust-call" fn call_once(mut self, args: (A,)) -> R { + self.call_mut(args) + } +} + +fn main() { + let mut counter = 0; + let factorial = |recur: &mut FnMut(u32) -> u32, arg: u32| -> u32 { + counter += 1; + if arg == 0 {1} else {arg * recur(arg-1)} + }; + let mut factorial: YCombinator<_,u32,u32> = YCombinator::new(factorial); + let mut r = factorial(10); + assert_eq!(3628800, r); +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.stderr new file mode 100644 index 00000000000..eec48dd78b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-recursive-fn-using-fn-mut.stderr @@ -0,0 +1,12 @@ +error[E0499]: cannot borrow `*self` as mutable more than once at a time + --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:32:21 + | +LL | (self.func)(self, arg) + | ----------- ^^^^ - first borrow ends here + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.rs b/src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.rs new file mode 100644 index 00000000000..1c133fbfcdb --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +fn to_fn_mut>(f: F) -> F { f } + +fn main() { + let mut_ = to_fn_mut(|x| x); + mut_.call((0, )); //~ ERROR no method named `call` found +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.stderr new file mode 100644 index 00000000000..53386f0e68e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-static-call-wrong-trait.stderr @@ -0,0 +1,11 @@ +error[E0599]: no method named `call` found for type `[closure@$DIR/unboxed-closures-static-call-wrong-trait.rs:16:26: 16:31]` in the current scope + --> $DIR/unboxed-closures-static-call-wrong-trait.rs:17:10 + | +LL | mut_.call((0, )); //~ ERROR no method named `call` found + | ^^^^ + | + = note: mut_ is a function, perhaps you wish to call it + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.rs b/src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.rs new file mode 100644 index 00000000000..dba4c8cc2e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::FnMut; + +pub fn main() { + let mut f = |x: isize, y: isize| -> isize { x + y }; + let z = f(1_usize, 2); //~ ERROR mismatched types + println!("{}", z); +} diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.stderr new file mode 100644 index 00000000000..7e11130573b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-type-mismatch.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/unboxed-closures-type-mismatch.rs:15:15 + | +LL | let z = f(1_usize, 2); //~ ERROR mismatched types + | ^^^^^^^ expected isize, found usize + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.rs b/src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.rs new file mode 100644 index 00000000000..5ba93bf483f --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that unsafe extern fn pointers do not implement any Fn traits. + +use std::ops::{Fn,FnMut,FnOnce}; + +unsafe fn square(x: &isize) -> isize { (*x) * (*x) } + +fn call_itisize>(_: &F, _: isize) -> isize { 0 } +fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } +fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } + +fn a() { + let x = call_it(&square, 22); + //~^ ERROR E0277 +} + +fn b() { + let y = call_it_mut(&mut square, 22); + //~^ ERROR E0277 +} + +fn c() { + let z = call_it_once(square, 22); + //~^ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.stderr new file mode 100644 index 00000000000..16b2b11ad7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-unsafe-extern-fn.stderr @@ -0,0 +1,39 @@ +error[E0277]: the trait bound `for<'r> for<'s> unsafe fn(&'s isize) -> isize {square}: std::ops::Fn<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-unsafe-extern-fn.rs:22:13 + | +LL | let x = call_it(&square, 22); + | ^^^^^^^ the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` + | +note: required by `call_it` + --> $DIR/unboxed-closures-unsafe-extern-fn.rs:17:1 + | +LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `for<'r> for<'s> unsafe fn(&'s isize) -> isize {square}: std::ops::FnMut<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-unsafe-extern-fn.rs:27:13 + | +LL | let y = call_it_mut(&mut square, 22); + | ^^^^^^^^^^^ the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` + | +note: required by `call_it_mut` + --> $DIR/unboxed-closures-unsafe-extern-fn.rs:18:1 + | +LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `for<'r> for<'s> unsafe fn(&'s isize) -> isize {square}: std::ops::FnOnce<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-unsafe-extern-fn.rs:32:13 + | +LL | let z = call_it_once(square, 22); + | ^^^^^^^^^^^^ the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `for<'r> unsafe fn(&'r isize) -> isize {square}` + | +note: required by `call_it_once` + --> $DIR/unboxed-closures-unsafe-extern-fn.rs:19:1 + | +LL | fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.rs b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.rs new file mode 100644 index 00000000000..ff06f7c559b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that unsafe extern fn pointers do not implement any Fn traits. + +use std::ops::{Fn,FnMut,FnOnce}; + +extern "C" fn square(x: &isize) -> isize { (*x) * (*x) } + +fn call_itisize>(_: &F, _: isize) -> isize { 0 } +fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } +fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } + +fn a() { + let x = call_it(&square, 22); + //~^ ERROR E0277 +} + +fn b() { + let y = call_it_mut(&mut square, 22); + //~^ ERROR E0277 +} + +fn c() { + let z = call_it_once(square, 22); + //~^ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.stderr new file mode 100644 index 00000000000..6e5e1b928a2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-abi.stderr @@ -0,0 +1,39 @@ +error[E0277]: the trait bound `for<'r> for<'s> extern "C" fn(&'s isize) -> isize {square}: std::ops::Fn<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-wrong-abi.rs:22:13 + | +LL | let x = call_it(&square, 22); + | ^^^^^^^ the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` + | +note: required by `call_it` + --> $DIR/unboxed-closures-wrong-abi.rs:17:1 + | +LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `for<'r> for<'s> extern "C" fn(&'s isize) -> isize {square}: std::ops::FnMut<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-wrong-abi.rs:27:13 + | +LL | let y = call_it_mut(&mut square, 22); + | ^^^^^^^^^^^ the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` + | +note: required by `call_it_mut` + --> $DIR/unboxed-closures-wrong-abi.rs:18:1 + | +LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `for<'r> for<'s> extern "C" fn(&'s isize) -> isize {square}: std::ops::FnOnce<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-wrong-abi.rs:32:13 + | +LL | let z = call_it_once(square, 22); + | ^^^^^^^^^^^^ the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `for<'r> extern "C" fn(&'r isize) -> isize {square}` + | +note: required by `call_it_once` + --> $DIR/unboxed-closures-wrong-abi.rs:19:1 + | +LL | fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.rs b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.rs new file mode 100644 index 00000000000..d77750d2a04 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that unsafe extern fn pointers do not implement any Fn traits. + +use std::ops::{Fn,FnMut,FnOnce}; + +unsafe fn square(x: isize) -> isize { x * x } +// note: argument type here is `isize`, not `&isize` + +fn call_itisize>(_: &F, _: isize) -> isize { 0 } +fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } +fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } + +fn a() { + let x = call_it(&square, 22); + //~^ ERROR E0277 +} + +fn b() { + let y = call_it_mut(&mut square, 22); + //~^ ERROR E0277 +} + +fn c() { + let z = call_it_once(square, 22); + //~^ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.stderr b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.stderr new file mode 100644 index 00000000000..5c2e73f5716 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unboxed-closures-wrong-arg-type-extern-fn.stderr @@ -0,0 +1,39 @@ +error[E0277]: the trait bound `for<'r> unsafe fn(isize) -> isize {square}: std::ops::Fn<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:23:13 + | +LL | let x = call_it(&square, 22); + | ^^^^^^^ the trait `for<'r> std::ops::Fn<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` + | +note: required by `call_it` + --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:18:1 + | +LL | fn call_itisize>(_: &F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `for<'r> unsafe fn(isize) -> isize {square}: std::ops::FnMut<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:28:13 + | +LL | let y = call_it_mut(&mut square, 22); + | ^^^^^^^^^^^ the trait `for<'r> std::ops::FnMut<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` + | +note: required by `call_it_mut` + --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:19:1 + | +LL | fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `for<'r> unsafe fn(isize) -> isize {square}: std::ops::FnOnce<(&'r isize,)>` is not satisfied + --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:33:13 + | +LL | let z = call_it_once(square, 22); + | ^^^^^^^^^^^^ the trait `for<'r> std::ops::FnOnce<(&'r isize,)>` is not implemented for `unsafe fn(isize) -> isize {square}` + | +note: required by `call_it_once` + --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:20:1 + | +LL | fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/underscore-lifetime-binders.rs b/src/test/ui/compile-fail-migration/underscore-lifetime-binders.rs new file mode 100644 index 00000000000..6a6698957d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/underscore-lifetime-binders.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<'a>(&'a u8); +struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier + +impl Foo<'_> { //~ ERROR missing lifetime specifier + fn x() {} +} + +fn foo<'_> //~ ERROR invalid lifetime parameter name: `'_` +(_: Foo<'_>) {} + +trait Meh<'a> {} +impl<'a> Meh<'a> for u8 {} + +fn meh() -> Box Meh<'_>> //~ ERROR invalid lifetime parameter name: `'_` +//~^ ERROR missing lifetime specifier +{ + Box::new(5u8) +} + +fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } //~ ERROR missing lifetime specifier + +fn main() { + let x = 5; + foo(Foo(&x)); + let _ = meh(); +} diff --git a/src/test/ui/compile-fail-migration/underscore-lifetime-binders.stderr b/src/test/ui/compile-fail-migration/underscore-lifetime-binders.stderr new file mode 100644 index 00000000000..4917c2795e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/underscore-lifetime-binders.stderr @@ -0,0 +1,45 @@ +error[E0106]: missing lifetime specifier + --> $DIR/underscore-lifetime-binders.rs:12:17 + | +LL | struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter + +error[E0106]: missing lifetime specifier + --> $DIR/underscore-lifetime-binders.rs:14:10 + | +LL | impl Foo<'_> { //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter + +error[E0262]: invalid lifetime parameter name: `'_` + --> $DIR/underscore-lifetime-binders.rs:18:8 + | +LL | fn foo<'_> //~ ERROR invalid lifetime parameter name: `'_` + | ^^ '_ is a reserved lifetime name + +error[E0262]: invalid lifetime parameter name: `'_` + --> $DIR/underscore-lifetime-binders.rs:24:21 + | +LL | fn meh() -> Box Meh<'_>> //~ ERROR invalid lifetime parameter name: `'_` + | ^^ '_ is a reserved lifetime name + +error[E0106]: missing lifetime specifier + --> $DIR/underscore-lifetime-binders.rs:24:29 + | +LL | fn meh() -> Box Meh<'_>> //~ ERROR invalid lifetime parameter name: `'_` + | ^^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from + = help: consider giving it a 'static lifetime + +error[E0106]: missing lifetime specifier + --> $DIR/underscore-lifetime-binders.rs:30:35 + | +LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `_` or `y` + +error: aborting due to 6 previous errors + +Some errors occurred: E0106, E0262. +For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.nll.stderr b/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.nll.stderr new file mode 100644 index 00000000000..eef04cbf351 --- /dev/null +++ b/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/underscore-lifetime-elison-mismatch.rs:11:49 + | +LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/underscore-lifetime-elison-mismatch.rs:11:42 + | +LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch + | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` + | | | + | | let's call the lifetime of this reference `'1` + | let's call the lifetime of this reference `'2` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.rs b/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.rs new file mode 100644 index 00000000000..b36c8eb324e --- /dev/null +++ b/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.stderr b/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.stderr new file mode 100644 index 00000000000..0847ea362c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/underscore-lifetime-elison-mismatch.stderr @@ -0,0 +1,11 @@ +error[E0623]: lifetime mismatch + --> $DIR/underscore-lifetime-elison-mismatch.rs:11:49 + | +LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch + | ------ ------ ^ ...but data from `y` flows into `x` here + | | + | these two types are declared with different lifetimes... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/uninhabited-enum-cast.rs b/src/test/ui/compile-fail-migration/uninhabited-enum-cast.rs new file mode 100644 index 00000000000..2a5d25e6b98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-enum-cast.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum E {} + +fn f(e: E) { + println!("{}", (e as isize).to_string()); //~ ERROR non-primitive cast +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/uninhabited-enum-cast.stderr b/src/test/ui/compile-fail-migration/uninhabited-enum-cast.stderr new file mode 100644 index 00000000000..058f8fba77c --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-enum-cast.stderr @@ -0,0 +1,11 @@ +error[E0605]: non-primitive cast: `E` as `isize` + --> $DIR/uninhabited-enum-cast.rs:14:20 + | +LL | println!("{}", (e as isize).to_string()); //~ ERROR non-primitive cast + | ^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/uninhabited-irrefutable.rs b/src/test/ui/compile-fail-migration/uninhabited-irrefutable.rs new file mode 100644 index 00000000000..05a97b855e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-irrefutable.rs @@ -0,0 +1,39 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] +#![feature(exhaustive_patterns)] + +mod foo { + pub struct SecretlyEmpty { + _priv: !, + } + + pub struct NotSoSecretlyEmpty { + pub _pub: !, + } +} + +struct NotSoSecretlyEmpty { + _priv: !, +} + +enum Foo { + A(foo::SecretlyEmpty), + B(foo::NotSoSecretlyEmpty), + C(NotSoSecretlyEmpty), + D(u32), +} + +fn main() { + let x: Foo = Foo::D(123); + let Foo::D(_y) = x; //~ ERROR refutable pattern in local binding: `A(_)` not covered +} + diff --git a/src/test/ui/compile-fail-migration/uninhabited-irrefutable.stderr b/src/test/ui/compile-fail-migration/uninhabited-irrefutable.stderr new file mode 100644 index 00000000000..e14ca626222 --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-irrefutable.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in local binding: `A(_)` not covered + --> $DIR/uninhabited-irrefutable.rs:37:9 + | +LL | let Foo::D(_y) = x; //~ ERROR refutable pattern in local binding: `A(_)` not covered + | ^^^^^^^^^^ pattern `A(_)` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.rs b/src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.rs new file mode 100644 index 00000000000..1d3f8ff12d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.rs @@ -0,0 +1,44 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Void {} + +fn main() { + let x: Result = Ok(23); + let _ = match x { //~ ERROR non-exhaustive + Ok(n) => n, + }; + + let x: &Void = unsafe { std::mem::uninitialized() }; + let _ = match x {}; //~ ERROR non-exhaustive + + let x: (Void,) = unsafe { std::mem::uninitialized() }; + let _ = match x {}; //~ ERROR non-exhaustive + + let x: [Void; 1] = unsafe { std::mem::uninitialized() }; + let _ = match x {}; //~ ERROR non-exhaustive + + let x: &[Void] = unsafe { std::mem::uninitialized() }; + let _ = match x { //~ ERROR non-exhaustive + &[] => (), + }; + + let x: Void = unsafe { std::mem::uninitialized() }; + let _ = match x {}; // okay + + let x: Result = Ok(23); + let _ = match x { //~ ERROR non-exhaustive + Ok(x) => x, + }; + + let x: Result = Ok(23); + let Ok(x) = x; + //~^ ERROR refutable +} diff --git a/src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.stderr b/src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.stderr new file mode 100644 index 00000000000..d86ebda027e --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-matches-feature-gated.stderr @@ -0,0 +1,64 @@ +error[E0004]: non-exhaustive patterns: `Err(_)` not covered + --> $DIR/uninhabited-matches-feature-gated.rs:15:19 + | +LL | let _ = match x { //~ ERROR non-exhaustive + | ^ pattern `Err(_)` not covered + +error[E0004]: non-exhaustive patterns: type &Void is non-empty + --> $DIR/uninhabited-matches-feature-gated.rs:20:19 + | +LL | let _ = match x {}; //~ ERROR non-exhaustive + | ^ + | +help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. + --> $DIR/uninhabited-matches-feature-gated.rs:20:19 + | +LL | let _ = match x {}; //~ ERROR non-exhaustive + | ^ + +error[E0004]: non-exhaustive patterns: type (Void,) is non-empty + --> $DIR/uninhabited-matches-feature-gated.rs:23:19 + | +LL | let _ = match x {}; //~ ERROR non-exhaustive + | ^ + | +help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. + --> $DIR/uninhabited-matches-feature-gated.rs:23:19 + | +LL | let _ = match x {}; //~ ERROR non-exhaustive + | ^ + +error[E0004]: non-exhaustive patterns: type [Void; 1] is non-empty + --> $DIR/uninhabited-matches-feature-gated.rs:26:19 + | +LL | let _ = match x {}; //~ ERROR non-exhaustive + | ^ + | +help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. + --> $DIR/uninhabited-matches-feature-gated.rs:26:19 + | +LL | let _ = match x {}; //~ ERROR non-exhaustive + | ^ + +error[E0004]: non-exhaustive patterns: `&[_]` not covered + --> $DIR/uninhabited-matches-feature-gated.rs:29:19 + | +LL | let _ = match x { //~ ERROR non-exhaustive + | ^ pattern `&[_]` not covered + +error[E0004]: non-exhaustive patterns: `Err(_)` not covered + --> $DIR/uninhabited-matches-feature-gated.rs:37:19 + | +LL | let _ = match x { //~ ERROR non-exhaustive + | ^ pattern `Err(_)` not covered + +error[E0005]: refutable pattern in local binding: `Err(_)` not covered + --> $DIR/uninhabited-matches-feature-gated.rs:42:9 + | +LL | let Ok(x) = x; + | ^^^^^ pattern `Err(_)` not covered + +error: aborting due to 7 previous errors + +Some errors occurred: E0004, E0005. +For more information about an error, try `rustc --explain E0004`. diff --git a/src/test/ui/compile-fail-migration/uninhabited-patterns.rs b/src/test/ui/compile-fail-migration/uninhabited-patterns.rs new file mode 100644 index 00000000000..2cf4b78bdff --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-patterns.rs @@ -0,0 +1,58 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_patterns)] +#![feature(box_syntax)] +#![feature(never_type)] +#![feature(exhaustive_patterns)] +#![feature(slice_patterns)] +#![deny(unreachable_patterns)] + +mod foo { + pub struct SecretlyEmpty { + _priv: !, + } +} + +struct NotSoSecretlyEmpty { + _priv: !, +} + +fn foo() -> Option { + None +} + +fn main() { + let x: &[!] = &[]; + + match x { + &[] => (), + &[..] => (), //~ ERROR unreachable pattern + }; + + let x: Result, &[Result]> = Err(&[]); + match x { + Ok(box _) => (), //~ ERROR unreachable pattern + Err(&[]) => (), + Err(&[..]) => (), //~ ERROR unreachable pattern + } + + let x: Result> = Err(Err(123)); + match x { + Ok(_y) => (), + Err(Err(_y)) => (), + Err(Ok(_y)) => (), //~ ERROR unreachable pattern + } + + while let Some(_y) = foo() { + //~^ ERROR unreachable pattern + } +} + diff --git a/src/test/ui/compile-fail-migration/uninhabited-patterns.stderr b/src/test/ui/compile-fail-migration/uninhabited-patterns.stderr new file mode 100644 index 00000000000..f11ff7c13b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/uninhabited-patterns.stderr @@ -0,0 +1,38 @@ +error: unreachable pattern + --> $DIR/uninhabited-patterns.rs:37:9 + | +LL | &[..] => (), //~ ERROR unreachable pattern + | ^^^^^ + | +note: lint level defined here + --> $DIR/uninhabited-patterns.rs:16:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/uninhabited-patterns.rs:42:9 + | +LL | Ok(box _) => (), //~ ERROR unreachable pattern + | ^^^^^^^^^ + +error: unreachable pattern + --> $DIR/uninhabited-patterns.rs:44:9 + | +LL | Err(&[..]) => (), //~ ERROR unreachable pattern + | ^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/uninhabited-patterns.rs:51:9 + | +LL | Err(Ok(_y)) => (), //~ ERROR unreachable pattern + | ^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/uninhabited-patterns.rs:54:15 + | +LL | while let Some(_y) = foo() { + | ^^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/union-ub-fat-ptr.rs b/src/test/ui/compile-fail-migration/union-ub-fat-ptr.rs new file mode 100644 index 00000000000..935e69d2e22 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union-ub-fat-ptr.rs @@ -0,0 +1,89 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[repr(C)] +#[derive(Copy, Clone)] +struct SliceRepr { + ptr: *const u8, + len: usize, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct BadSliceRepr { + ptr: *const u8, + len: &'static u8, +} + +union SliceTransmute { + repr: SliceRepr, + bad: BadSliceRepr, + slice: &'static [u8], + str: &'static str, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct DynRepr { + ptr: *const u8, + vtable: *const u8, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct DynRepr2 { + ptr: *const u8, + vtable: *const u64, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct BadDynRepr { + ptr: *const u8, + vtable: usize, +} + +union DynTransmute { + repr: DynRepr, + repr2: DynRepr2, + bad: BadDynRepr, + rust: &'static Trait, +} + +trait Trait {} + +// OK +const A: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.str}; +// should lint +const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; +// bad +const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; +//~^ ERROR this constant likely exhibits undefined behavior + +// OK +const A2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.slice}; +// should lint +const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; +// bad +const C2: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; +//~^ ERROR this constant likely exhibits undefined behavior + +// bad +const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; +//~^ ERROR this constant likely exhibits undefined behavior +// bad +const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; +//~^ ERROR this constant likely exhibits undefined behavior +// bad +const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; +//~^ ERROR this constant likely exhibits undefined behavior + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/union-ub-fat-ptr.stderr b/src/test/ui/compile-fail-migration/union-ub-fat-ptr.stderr new file mode 100644 index 00000000000..f8877e35f7a --- /dev/null +++ b/src/test/ui/compile-fail-migration/union-ub-fat-ptr.stderr @@ -0,0 +1,43 @@ +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:67:1 + | +LL | const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered length is not a valid integer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:75:1 + | +LL | const C2: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered length is not a valid integer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:79:1 + | +LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tried to access memory with alignment 1, but alignment 8 is required + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:82:1 + | +LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access at offset 16, outside bounds of allocation 56 which has size 8 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:85:1 + | +LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered vtable address is not a pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.nll.stderr b/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.nll.stderr new file mode 100644 index 00000000000..1ca2a56e757 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.nll.stderr @@ -0,0 +1,33 @@ +error[E0382]: use of moved value: `u.y` + --> $DIR/union-borrow-move-parent-sibling.rs:29:13 + | +LL | let a = u.x.0; + | ----- value moved here +LL | let a = u.y; //~ ERROR use of moved value: `u.y` + | ^^^ value used here after move + | + = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.y` + --> $DIR/union-borrow-move-parent-sibling.rs:41:13 + | +LL | let a = (u.x.0).0; + | --------- value moved here +LL | let a = u.y; //~ ERROR use of moved value: `u.y` + | ^^^ value used here after move + | + = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.x` + --> $DIR/union-borrow-move-parent-sibling.rs:53:13 + | +LL | let a = *u.y; + | ---- value moved here +LL | let a = u.x; //~ ERROR use of moved value: `u.x` + | ^^^ value used here after move + | + = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.rs b/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.rs new file mode 100644 index 00000000000..5f504feabb2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.rs @@ -0,0 +1,57 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] +#![allow(unused)] + +#[allow(unions_with_drop_fields)] +union U { + x: ((Vec, Vec), Vec), + y: Box>, +} + +unsafe fn parent_sibling_borrow() { + let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + let a = &mut u.x.0; + let a = &u.y; //~ ERROR cannot borrow `u.y` +} + +unsafe fn parent_sibling_move() { + let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + let a = u.x.0; + let a = u.y; //~ ERROR use of moved value: `u.y` +} + +unsafe fn grandparent_sibling_borrow() { + let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + let a = &mut (u.x.0).0; + let a = &u.y; //~ ERROR cannot borrow `u.y` +} + +unsafe fn grandparent_sibling_move() { + let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + let a = (u.x.0).0; + let a = u.y; //~ ERROR use of moved value: `u.y` +} + +unsafe fn deref_sibling_borrow() { + let mut u = U { y: Box::default() }; + let a = &mut *u.y; + let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) +} + +unsafe fn deref_sibling_move() { + let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + let a = *u.y; + let a = u.x; //~ ERROR use of moved value: `u.x` +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.stderr b/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.stderr new file mode 100644 index 00000000000..d855435416e --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-borrow-move-parent-sibling.stderr @@ -0,0 +1,64 @@ +error[E0502]: cannot borrow `u.y` as immutable because `u.x.0` is also borrowed as mutable + --> $DIR/union-borrow-move-parent-sibling.rs:23:14 + | +LL | let a = &mut u.x.0; + | ----- mutable borrow occurs here +LL | let a = &u.y; //~ ERROR cannot borrow `u.y` + | ^^^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0382]: use of moved value: `u.y` + --> $DIR/union-borrow-move-parent-sibling.rs:29:9 + | +LL | let a = u.x.0; + | - value moved here +LL | let a = u.y; //~ ERROR use of moved value: `u.y` + | ^ value used here after move + | + = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait + +error[E0502]: cannot borrow `u.y` as immutable because `u.x.0.0` is also borrowed as mutable + --> $DIR/union-borrow-move-parent-sibling.rs:35:14 + | +LL | let a = &mut (u.x.0).0; + | --------- mutable borrow occurs here +LL | let a = &u.y; //~ ERROR cannot borrow `u.y` + | ^^^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0382]: use of moved value: `u.y` + --> $DIR/union-borrow-move-parent-sibling.rs:41:9 + | +LL | let a = (u.x.0).0; + | - value moved here +LL | let a = u.y; //~ ERROR use of moved value: `u.y` + | ^ value used here after move + | + = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait + +error[E0502]: cannot borrow `u` (via `u.x`) as immutable because `u` is also borrowed as mutable (via `*u.y`) + --> $DIR/union-borrow-move-parent-sibling.rs:47:14 + | +LL | let a = &mut *u.y; + | ---- mutable borrow occurs here (via `*u.y`) +LL | let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) + | ^^^ immutable borrow occurs here (via `u.x`) +LL | } + | - mutable borrow ends here + +error[E0382]: use of moved value: `u.x` + --> $DIR/union-borrow-move-parent-sibling.rs:53:9 + | +LL | let a = *u.y; + | - value moved here +LL | let a = u.x; //~ ERROR use of moved value: `u.x` + | ^ value used here after move + | + = note: move occurs because `u.x` has type `[type error]`, which does not implement the `Copy` trait + +error: aborting due to 6 previous errors + +Some errors occurred: E0382, E0502. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/union/union-const-pat.rs b/src/test/ui/compile-fail-migration/union/union-const-pat.rs new file mode 100644 index 00000000000..5f75e3cc4a2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-const-pat.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +union U { + a: usize, + b: usize, +} + +const C: U = U { a: 10 }; + +fn main() { + match C { + C => {} //~ ERROR cannot use unions in constant patterns + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/union/union-const-pat.stderr b/src/test/ui/compile-fail-migration/union/union-const-pat.stderr new file mode 100644 index 00000000000..2d9c9a5e520 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-const-pat.stderr @@ -0,0 +1,8 @@ +error: cannot use unions in constant patterns + --> $DIR/union-const-pat.rs:20:9 + | +LL | C => {} //~ ERROR cannot use unions in constant patterns + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/union/union-copy.rs b/src/test/ui/compile-fail-migration/union/union-copy.rs new file mode 100644 index 00000000000..9014b3f2956 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-copy.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] + +#[derive(Clone)] +union U { + a: u8 +} + +#[derive(Clone)] +union W { + a: String +} + +impl Copy for U {} // OK +impl Copy for W {} //~ ERROR the trait `Copy` may not be implemented for this type + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-copy.stderr b/src/test/ui/compile-fail-migration/union/union-copy.stderr new file mode 100644 index 00000000000..05da9e90af7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-copy.stderr @@ -0,0 +1,12 @@ +error[E0204]: the trait `Copy` may not be implemented for this type + --> $DIR/union-copy.rs:24:6 + | +LL | a: String + | --------- this field does not implement `Copy` +... +LL | impl Copy for W {} //~ ERROR the trait `Copy` may not be implemented for this type + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0204`. diff --git a/src/test/ui/compile-fail-migration/union/union-derive-clone.rs b/src/test/ui/compile-fail-migration/union/union-derive-clone.rs new file mode 100644 index 00000000000..6e226d7d79f --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-derive-clone.rs @@ -0,0 +1,41 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] + +#[derive(Clone)] //~ ERROR the trait bound `U1: std::marker::Copy` is not satisfied +union U1 { + a: u8, +} + +#[derive(Clone)] +union U2 { + a: u8, // OK +} + +impl Copy for U2 {} + +#[derive(Clone, Copy)] +union U3 { + a: u8, // OK +} + +#[derive(Clone, Copy)] +union U4 { + a: T, // OK +} + +#[derive(Clone)] +struct CloneNoCopy; + +fn main() { + let u = U4 { a: CloneNoCopy }; + let w = u.clone(); //~ ERROR no method named `clone` found for type `U4` +} diff --git a/src/test/ui/compile-fail-migration/union/union-derive-clone.stderr b/src/test/ui/compile-fail-migration/union/union-derive-clone.stderr new file mode 100644 index 00000000000..e9a92b4452a --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-derive-clone.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `U1: std::marker::Copy` is not satisfied + --> $DIR/union-derive-clone.rs:13:10 + | +LL | #[derive(Clone)] //~ ERROR the trait bound `U1: std::marker::Copy` is not satisfied + | ^^^^^ the trait `std::marker::Copy` is not implemented for `U1` + | + = note: required by `std::clone::AssertParamIsCopy` + +error[E0599]: no method named `clone` found for type `U4` in the current scope + --> $DIR/union-derive-clone.rs:40:15 + | +LL | union U4 { + | ----------- method `clone` not found for this +... +LL | let w = u.clone(); //~ ERROR no method named `clone` found for type `U4` + | ^^^^^ + | + = note: the method `clone` exists but the following trait bounds were not satisfied: + `U4 : std::clone::Clone` + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `std::clone::Clone` + +error: aborting due to 2 previous errors + +Some errors occurred: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/union/union-derive.rs b/src/test/ui/compile-fail-migration/union/union-derive.rs new file mode 100644 index 00000000000..ffd290fb073 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-derive.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Most traits cannot be derived for unions. + +#[derive( + PartialEq, //~ ERROR this trait cannot be derived for unions + PartialOrd, //~ ERROR this trait cannot be derived for unions + Ord, //~ ERROR this trait cannot be derived for unions + Hash, //~ ERROR this trait cannot be derived for unions + Default, //~ ERROR this trait cannot be derived for unions + Debug, //~ ERROR this trait cannot be derived for unions +)] +union U { + a: u8, + b: u16, +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-derive.stderr b/src/test/ui/compile-fail-migration/union/union-derive.stderr new file mode 100644 index 00000000000..e8e11e832d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-derive.stderr @@ -0,0 +1,38 @@ +error: this trait cannot be derived for unions + --> $DIR/union-derive.rs:19:5 + | +LL | Debug, //~ ERROR this trait cannot be derived for unions + | ^^^^^ + +error: this trait cannot be derived for unions + --> $DIR/union-derive.rs:18:5 + | +LL | Default, //~ ERROR this trait cannot be derived for unions + | ^^^^^^^ + +error: this trait cannot be derived for unions + --> $DIR/union-derive.rs:17:5 + | +LL | Hash, //~ ERROR this trait cannot be derived for unions + | ^^^^ + +error: this trait cannot be derived for unions + --> $DIR/union-derive.rs:16:5 + | +LL | Ord, //~ ERROR this trait cannot be derived for unions + | ^^^ + +error: this trait cannot be derived for unions + --> $DIR/union-derive.rs:15:5 + | +LL | PartialOrd, //~ ERROR this trait cannot be derived for unions + | ^^^^^^^^^^ + +error: this trait cannot be derived for unions + --> $DIR/union-derive.rs:14:5 + | +LL | PartialEq, //~ ERROR this trait cannot be derived for unions + | ^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/compile-fail-migration/union/union-empty.rs b/src/test/ui/compile-fail-migration/union/union-empty.rs new file mode 100644 index 00000000000..1f499c49a68 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-empty.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +union U {} //~ ERROR unions cannot have zero fields + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-empty.stderr b/src/test/ui/compile-fail-migration/union/union-empty.stderr new file mode 100644 index 00000000000..5abe45814ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-empty.stderr @@ -0,0 +1,8 @@ +error: unions cannot have zero fields + --> $DIR/union-empty.rs:11:1 + | +LL | union U {} //~ ERROR unions cannot have zero fields + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/union/union-generic.rs b/src/test/ui/compile-fail-migration/union/union-generic.rs new file mode 100644 index 00000000000..8bd422b42d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-generic.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::rc::Rc; + +union U { + a: T +} + +fn main() { + let u = U { a: Rc::new(0u32) }; + //~^ ERROR the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied + let u = U::> { a: Default::default() }; + //~^ ERROR the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/union/union-generic.stderr b/src/test/ui/compile-fail-migration/union/union-generic.stderr new file mode 100644 index 00000000000..dbfffa005fb --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-generic.stderr @@ -0,0 +1,27 @@ +error[E0277]: the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied + --> $DIR/union-generic.rs:18:13 + | +LL | let u = U { a: Rc::new(0u32) }; + | ^ the trait `std::marker::Copy` is not implemented for `std::rc::Rc` + | +note: required by `U` + --> $DIR/union-generic.rs:13:1 + | +LL | union U { + | ^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied + --> $DIR/union-generic.rs:20:13 + | +LL | let u = U::> { a: Default::default() }; + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::rc::Rc` + | +note: required by `U` + --> $DIR/union-generic.rs:13:1 + | +LL | union U { + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/union/union-lint-dead-code.rs b/src/test/ui/compile-fail-migration/union/union-lint-dead-code.rs new file mode 100644 index 00000000000..a64187c5f23 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-lint-dead-code.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(dead_code)] + +union Foo { + x: usize, + b: bool, //~ ERROR: field is never used + _unused: u16, +} + +fn field_read(f: Foo) -> usize { + unsafe { f.x } +} + +fn main() { + let _ = field_read(Foo { x: 2 }); +} diff --git a/src/test/ui/compile-fail-migration/union/union-lint-dead-code.stderr b/src/test/ui/compile-fail-migration/union/union-lint-dead-code.stderr new file mode 100644 index 00000000000..2cd3aab8c29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-lint-dead-code.stderr @@ -0,0 +1,14 @@ +error: field is never used: `b` + --> $DIR/union-lint-dead-code.rs:15:5 + | +LL | b: bool, //~ ERROR: field is never used + | ^^^^^^^ + | +note: lint level defined here + --> $DIR/union-lint-dead-code.rs:11:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/union/union-nonrepresentable.rs b/src/test/ui/compile-fail-migration/union/union-nonrepresentable.rs new file mode 100644 index 00000000000..cb4683c2a0e --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-nonrepresentable.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] + +union U { //~ ERROR recursive type `U` has infinite size + a: u8, + b: U, +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-nonrepresentable.stderr b/src/test/ui/compile-fail-migration/union/union-nonrepresentable.stderr new file mode 100644 index 00000000000..17d78ea4c2b --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-nonrepresentable.stderr @@ -0,0 +1,14 @@ +error[E0072]: recursive type `U` has infinite size + --> $DIR/union-nonrepresentable.rs:13:1 + | +LL | union U { //~ ERROR recursive type `U` has infinite size + | ^^^^^^^ recursive type has infinite size +LL | a: u8, +LL | b: U, + | ---- recursive without indirection + | + = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `U` representable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/src/test/ui/compile-fail-migration/union/union-repr-c.rs b/src/test/ui/compile-fail-migration/union/union-repr-c.rs new file mode 100644 index 00000000000..36c42ce1104 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-repr-c.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +#![deny(improper_ctypes)] + +#[repr(C)] +union U { + a: u8, +} + +union W { + a: u8, +} + +extern "C" { + static FOREIGN1: U; // OK + static FOREIGN2: W; //~ ERROR union has unspecified layout +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-repr-c.stderr b/src/test/ui/compile-fail-migration/union/union-repr-c.stderr new file mode 100644 index 00000000000..ddf50049192 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-repr-c.stderr @@ -0,0 +1,22 @@ +error: `extern` block uses type `W` which is not FFI-safe: this union has unspecified layout + --> $DIR/union-repr-c.rs:25:22 + | +LL | static FOREIGN2: W; //~ ERROR union has unspecified layout + | ^ + | +note: lint level defined here + --> $DIR/union-repr-c.rs:12:9 + | +LL | #![deny(improper_ctypes)] + | ^^^^^^^^^^^^^^^ + = help: consider adding a #[repr(C)] attribute to this union +note: type defined here + --> $DIR/union-repr-c.rs:19:1 + | +LL | / union W { +LL | | a: u8, +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/union/union-unsafe.rs b/src/test/ui/compile-fail-migration/union/union-unsafe.rs new file mode 100644 index 00000000000..d993816e6f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-unsafe.rs @@ -0,0 +1,55 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] + +union U1 { + a: u8 +} + +union U2 { + a: String +} + +union U3 { + a: T +} + +union U4 { + a: T +} + +fn generic_noncopy() { + let mut u3 = U3 { a: T::default() }; + u3.a = T::default(); //~ ERROR assignment to non-`Copy` union field is unsafe +} + +fn generic_copy() { + let mut u3 = U3 { a: T::default() }; + u3.a = T::default(); // OK + let mut u4 = U4 { a: T::default() }; + u4.a = T::default(); // OK +} + +fn main() { + let mut u1 = U1 { a: 10 }; // OK + let a = u1.a; //~ ERROR access to union field is unsafe + u1.a = 11; // OK + let U1 { a } = u1; //~ ERROR access to union field is unsafe + if let U1 { a: 12 } = u1 {} //~ ERROR access to union field is unsafe + // let U1 { .. } = u1; // OK + + let mut u2 = U2 { a: String::from("old") }; // OK + u2.a = String::from("new"); //~ ERROR assignment to non-`Copy` union field is unsafe + let mut u3 = U3 { a: 0 }; // OK + u3.a = 1; // OK + let mut u3 = U3 { a: String::from("old") }; // OK + u3.a = String::from("new"); //~ ERROR assignment to non-`Copy` union field is unsafe +} diff --git a/src/test/ui/compile-fail-migration/union/union-unsafe.stderr b/src/test/ui/compile-fail-migration/union/union-unsafe.stderr new file mode 100644 index 00000000000..a0b3d98f7a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-unsafe.stderr @@ -0,0 +1,51 @@ +error[E0133]: assignment to non-`Copy` union field is unsafe and requires unsafe function or block + --> $DIR/union-unsafe.rs:31:5 + | +LL | u3.a = T::default(); //~ ERROR assignment to non-`Copy` union field is unsafe + | ^^^^ assignment to non-`Copy` union field + | + = note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/union-unsafe.rs:43:13 + | +LL | let a = u1.a; //~ ERROR access to union field is unsafe + | ^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/union-unsafe.rs:45:14 + | +LL | let U1 { a } = u1; //~ ERROR access to union field is unsafe + | ^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/union-unsafe.rs:46:20 + | +LL | if let U1 { a: 12 } = u1 {} //~ ERROR access to union field is unsafe + | ^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: assignment to non-`Copy` union field is unsafe and requires unsafe function or block + --> $DIR/union-unsafe.rs:50:5 + | +LL | u2.a = String::from("new"); //~ ERROR assignment to non-`Copy` union field is unsafe + | ^^^^ assignment to non-`Copy` union field + | + = note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized + +error[E0133]: assignment to non-`Copy` union field is unsafe and requires unsafe function or block + --> $DIR/union-unsafe.rs:54:5 + | +LL | u3.a = String::from("new"); //~ ERROR assignment to non-`Copy` union field is unsafe + | ^^^^ assignment to non-`Copy` union field + | + = note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/union/union-unsized.rs b/src/test/ui/compile-fail-migration/union/union-unsized.rs new file mode 100644 index 00000000000..d79c2ed710e --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-unsized.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] + +union U { + a: str, + //~^ ERROR the size for values of type + + b: u8, +} + +union W { + a: u8, + b: str, + //~^ ERROR the size for values of type +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-unsized.stderr b/src/test/ui/compile-fail-migration/union/union-unsized.stderr new file mode 100644 index 00000000000..f23dc315425 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-unsized.stderr @@ -0,0 +1,23 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/union-unsized.rs:14:5 + | +LL | a: str, + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit + = note: no field of a union may have a dynamically sized type + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/union-unsized.rs:22:5 + | +LL | b: str, + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit + = note: no field of a union may have a dynamically sized type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.rs b/src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.rs new file mode 100644 index 00000000000..87a72efbe08 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.rs @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] +#![allow(dead_code)] +#![deny(unions_with_drop_fields)] + +union U { + a: u8, // OK +} + +union W { + a: String, //~ ERROR union contains a field with possibly non-trivial drop code + b: String, // OK, only one field is reported +} + +struct S(String); + +// `S` doesn't implement `Drop` trait, but still has non-trivial destructor +union Y { + a: S, //~ ERROR union contains a field with possibly non-trivial drop code +} + +// We don't know if `T` is trivially-destructable or not until trans +union J { + a: T, //~ ERROR union contains a field with possibly non-trivial drop code +} + +union H { + a: T, // OK, `T` is `Copy`, no destructor +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.stderr b/src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.stderr new file mode 100644 index 00000000000..2d3d539cda5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/union/union-with-drop-fields-lint.stderr @@ -0,0 +1,26 @@ +error: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union + --> $DIR/union-with-drop-fields-lint.rs:20:5 + | +LL | a: String, //~ ERROR union contains a field with possibly non-trivial drop code + | ^^^^^^^^^ + | +note: lint level defined here + --> $DIR/union-with-drop-fields-lint.rs:13:9 + | +LL | #![deny(unions_with_drop_fields)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union + --> $DIR/union-with-drop-fields-lint.rs:28:5 + | +LL | a: S, //~ ERROR union contains a field with possibly non-trivial drop code + | ^^^^ + +error: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union + --> $DIR/union-with-drop-fields-lint.rs:33:5 + | +LL | a: T, //~ ERROR union contains a field with possibly non-trivial drop code + | ^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/unique-object-noncopyable.rs b/src/test/ui/compile-fail-migration/unique-object-noncopyable.rs new file mode 100644 index 00000000000..c44718c4fc9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unique-object-noncopyable.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +trait Foo { + fn f(&self); +} + +struct Bar { + x: isize, +} + +impl Drop for Bar { + fn drop(&mut self) {} +} + +impl Foo for Bar { + fn f(&self) { + println!("hi"); + } +} + +fn main() { + let x = box Bar { x: 10 }; + let y: Box = x as Box; + let _z = y.clone(); //~ ERROR no method named `clone` found +} diff --git a/src/test/ui/compile-fail-migration/unique-object-noncopyable.stderr b/src/test/ui/compile-fail-migration/unique-object-noncopyable.stderr new file mode 100644 index 00000000000..777b9f19bad --- /dev/null +++ b/src/test/ui/compile-fail-migration/unique-object-noncopyable.stderr @@ -0,0 +1,15 @@ +error[E0599]: no method named `clone` found for type `std::boxed::Box` in the current scope + --> $DIR/unique-object-noncopyable.rs:34:16 + | +LL | let _z = y.clone(); //~ ERROR no method named `clone` found + | ^^^^^ + | + = note: the method `clone` exists but the following trait bounds were not satisfied: + `std::boxed::Box : std::clone::Clone` + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `std::clone::Clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/unique-pinned-nocopy.rs b/src/test/ui/compile-fail-migration/unique-pinned-nocopy.rs new file mode 100644 index 00000000000..c09feec1d4a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unique-pinned-nocopy.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +struct r { + b: bool, +} + +impl Drop for r { + fn drop(&mut self) {} +} + +fn main() { + let i = Box::new(r { b: true }); + let _j = i.clone(); //~ ERROR no method named `clone` found + println!("{:?}", i); +} diff --git a/src/test/ui/compile-fail-migration/unique-pinned-nocopy.stderr b/src/test/ui/compile-fail-migration/unique-pinned-nocopy.stderr new file mode 100644 index 00000000000..ddc676601fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/unique-pinned-nocopy.stderr @@ -0,0 +1,15 @@ +error[E0599]: no method named `clone` found for type `std::boxed::Box` in the current scope + --> $DIR/unique-pinned-nocopy.rs:22:16 + | +LL | let _j = i.clone(); //~ ERROR no method named `clone` found + | ^^^^^ + | + = note: the method `clone` exists but the following trait bounds were not satisfied: + `std::boxed::Box : std::clone::Clone` + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `clone`, perhaps you need to implement it: + candidate #1: `std::clone::Clone` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/unknown-lint-tool-name.rs b/src/test/ui/compile-fail-migration/unknown-lint-tool-name.rs new file mode 100644 index 00000000000..78b736edceb --- /dev/null +++ b/src/test/ui/compile-fail-migration/unknown-lint-tool-name.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(tool_lints)] + +#![deny(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` + +#[allow(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unknown-lint-tool-name.stderr b/src/test/ui/compile-fail-migration/unknown-lint-tool-name.stderr new file mode 100644 index 00000000000..29c3a642d87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unknown-lint-tool-name.stderr @@ -0,0 +1,15 @@ +error[E0710]: an unknown tool name found in scoped lint: `foo::bar` + --> $DIR/unknown-lint-tool-name.rs:13:9 + | +LL | #![deny(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` + | ^^^ + +error[E0710]: an unknown tool name found in scoped lint: `foo::bar` + --> $DIR/unknown-lint-tool-name.rs:15:9 + | +LL | #[allow(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` + | ^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0710`. diff --git a/src/test/ui/compile-fail-migration/unknown-tool-name.rs b/src/test/ui/compile-fail-migration/unknown-tool-name.rs new file mode 100644 index 00000000000..99c336c28cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/unknown-tool-name.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(proc_macro_path_invoc)] + +#[foo::bar] //~ ERROR failed to resolve. Use of undeclared type or module `foo` +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unknown-tool-name.stderr b/src/test/ui/compile-fail-migration/unknown-tool-name.stderr new file mode 100644 index 00000000000..151f957ac56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unknown-tool-name.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `foo` + --> $DIR/unknown-tool-name.rs:13:3 + | +LL | #[foo::bar] //~ ERROR failed to resolve. Use of undeclared type or module `foo` + | ^^^ Use of undeclared type or module `foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/unop-move-semantics.nll.stderr b/src/test/ui/compile-fail-migration/unop-move-semantics.nll.stderr new file mode 100644 index 00000000000..111940aab2c --- /dev/null +++ b/src/test/ui/compile-fail-migration/unop-move-semantics.nll.stderr @@ -0,0 +1,27 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/unop-move-semantics.rs:18:5 + | +LL | !x; + | - value moved here +LL | +LL | x.clone(); //~ ERROR: use of moved value + | ^ value borrowed here after move + | + = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of borrowed content + --> $DIR/unop-move-semantics.rs:34:6 + | +LL | !*m; //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/unop-move-semantics.rs:36:6 + | +LL | !*n; //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error: aborting due to 3 previous errors + +Some errors occurred: E0382, E0507. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/unop-move-semantics.rs b/src/test/ui/compile-fail-migration/unop-move-semantics.rs new file mode 100644 index 00000000000..94656667598 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unop-move-semantics.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that move restrictions are enforced on overloaded unary operations + +use std::ops::Not; + +fn move_then_borrow + Clone>(x: T) { + !x; + + x.clone(); //~ ERROR: use of moved value +} + +fn move_borrowed>(x: T, mut y: T) { + let m = &x; + let n = &mut y; + + !x; //~ ERROR: cannot move out of `x` because it is borrowed + + !y; //~ ERROR: cannot move out of `y` because it is borrowed +} + +fn illegal_dereference>(mut x: T, y: T) { + let m = &mut x; + let n = &y; + + !*m; //~ ERROR: cannot move out of borrowed content + + !*n; //~ ERROR: cannot move out of borrowed content +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unop-move-semantics.stderr b/src/test/ui/compile-fail-migration/unop-move-semantics.stderr new file mode 100644 index 00000000000..42d17e54aa2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unop-move-semantics.stderr @@ -0,0 +1,45 @@ +error[E0382]: use of moved value: `x` + --> $DIR/unop-move-semantics.rs:18:5 + | +LL | !x; + | - value moved here +LL | +LL | x.clone(); //~ ERROR: use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/unop-move-semantics.rs:25:6 + | +LL | let m = &x; + | - borrow of `x` occurs here +... +LL | !x; //~ ERROR: cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here + +error[E0505]: cannot move out of `y` because it is borrowed + --> $DIR/unop-move-semantics.rs:27:6 + | +LL | let n = &mut y; + | - borrow of `y` occurs here +... +LL | !y; //~ ERROR: cannot move out of `y` because it is borrowed + | ^ move out of `y` occurs here + +error[E0507]: cannot move out of borrowed content + --> $DIR/unop-move-semantics.rs:34:6 + | +LL | !*m; //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/unop-move-semantics.rs:36:6 + | +LL | !*n; //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error: aborting due to 5 previous errors + +Some errors occurred: E0382, E0505, E0507. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/unop-neg-bool.rs b/src/test/ui/compile-fail-migration/unop-neg-bool.rs new file mode 100644 index 00000000000..316e17c54ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/unop-neg-bool.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + -true; //~ ERROR cannot apply unary operator `-` to type `bool` +} diff --git a/src/test/ui/compile-fail-migration/unop-neg-bool.stderr b/src/test/ui/compile-fail-migration/unop-neg-bool.stderr new file mode 100644 index 00000000000..8ffb71ec4ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/unop-neg-bool.stderr @@ -0,0 +1,11 @@ +error[E0600]: cannot apply unary operator `-` to type `bool` + --> $DIR/unop-neg-bool.rs:12:5 + | +LL | -true; //~ ERROR cannot apply unary operator `-` to type `bool` + | ^^^^^ cannot apply unary operator `-` + | + = note: an implementation of `std::ops::Neg` might be missing for `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0600`. diff --git a/src/test/ui/compile-fail-migration/unreachable-arm.rs b/src/test/ui/compile-fail-migration/unreachable-arm.rs new file mode 100644 index 00000000000..df827d2c784 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-arm.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_patterns)] +#![feature(box_syntax)] +#![allow(dead_code)] +#![deny(unreachable_patterns)] + +enum Foo { A(Box, isize), B(usize), } + +fn main() { + match Foo::B(1) { + Foo::B(_) | Foo::A(box _, 1) => { } + Foo::A(_, 1) => { } //~ ERROR unreachable pattern + _ => { } + } +} + diff --git a/src/test/ui/compile-fail-migration/unreachable-arm.stderr b/src/test/ui/compile-fail-migration/unreachable-arm.stderr new file mode 100644 index 00000000000..6bd3f281ea9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-arm.stderr @@ -0,0 +1,14 @@ +error: unreachable pattern + --> $DIR/unreachable-arm.rs:21:9 + | +LL | Foo::A(_, 1) => { } //~ ERROR unreachable pattern + | ^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/unreachable-arm.rs:14:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unreachable-code.rs b/src/test/ui/compile-fail-migration/unreachable-code.rs new file mode 100644 index 00000000000..dd08eed5df9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-code.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unreachable_code)] +#![allow(unused_variables)] + +fn main() { + loop{} + + let a = 3; //~ ERROR: unreachable statement +} diff --git a/src/test/ui/compile-fail-migration/unreachable-code.stderr b/src/test/ui/compile-fail-migration/unreachable-code.stderr new file mode 100644 index 00000000000..0c5d94c6502 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-code.stderr @@ -0,0 +1,14 @@ +error: unreachable statement + --> $DIR/unreachable-code.rs:17:3 + | +LL | let a = 3; //~ ERROR: unreachable statement + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/unreachable-code.rs:11:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unreachable-in-call.rs b/src/test/ui/compile-fail-migration/unreachable-in-call.rs new file mode 100644 index 00000000000..72462468432 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-in-call.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![deny(unreachable_code)] + +fn diverge() -> ! { panic!() } + +fn get_u8() -> u8 { + 1 +} +fn call(_: u8, _: u8) { + +} +fn diverge_first() { + call(diverge(), + get_u8()); //~ ERROR unreachable expression +} +fn diverge_second() { + call( //~ ERROR unreachable expression + get_u8(), + diverge()); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unreachable-in-call.stderr b/src/test/ui/compile-fail-migration/unreachable-in-call.stderr new file mode 100644 index 00000000000..215829af443 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-in-call.stderr @@ -0,0 +1,22 @@ +error: unreachable expression + --> $DIR/unreachable-in-call.rs:24:10 + | +LL | get_u8()); //~ ERROR unreachable expression + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/unreachable-in-call.rs:12:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + +error: unreachable expression + --> $DIR/unreachable-in-call.rs:27:5 + | +LL | / call( //~ ERROR unreachable expression +LL | | get_u8(), +LL | | diverge()); + | |__________________^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/unreachable-loop-patterns.rs b/src/test/ui/compile-fail-migration/unreachable-loop-patterns.rs new file mode 100644 index 00000000000..cfd829e416e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-loop-patterns.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] +#![feature(exhaustive_patterns)] +#![deny(unreachable_patterns)] + +fn main() { + let x: &[!] = &[]; + + for _ in x {} + //~^ ERROR unreachable pattern +} + diff --git a/src/test/ui/compile-fail-migration/unreachable-loop-patterns.stderr b/src/test/ui/compile-fail-migration/unreachable-loop-patterns.stderr new file mode 100644 index 00000000000..724a92b0947 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-loop-patterns.stderr @@ -0,0 +1,14 @@ +error: unreachable pattern + --> $DIR/unreachable-loop-patterns.rs:18:9 + | +LL | for _ in x {} + | ^ + | +note: lint level defined here + --> $DIR/unreachable-loop-patterns.rs:13:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unreachable-try-pattern.rs b/src/test/ui/compile-fail-migration/unreachable-try-pattern.rs new file mode 100644 index 00000000000..df340095bb4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-try-pattern.rs @@ -0,0 +1,52 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] +#![feature(exhaustive_patterns, rustc_attrs)] +#![warn(unreachable_code)] +#![warn(unreachable_patterns)] + +enum Void {} + +impl From for i32 { + fn from(v: Void) -> i32 { + match v {} + } +} + +fn bar(x: Result) -> Result { + x? +} + +fn foo(x: Result) -> Result { + let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?; + //~^ WARN unreachable pattern + //~| WARN unreachable expression + Ok(y) +} + +fn qux(x: Result) -> Result { + Ok(x?) +} + +fn vom(x: Result) -> Result { + let y = (match x { Ok(n) => Ok(n), Err(e) => Err(e) })?; + //~^ WARN unreachable pattern + Ok(y) +} + +#[rustc_error] +fn main() { //~ ERROR: compilation successful + let _ = bar(Err(123)); + let _ = foo(Err(123)); + let _ = qux(Ok(123)); + let _ = vom(Ok(123)); +} + diff --git a/src/test/ui/compile-fail-migration/unreachable-try-pattern.stderr b/src/test/ui/compile-fail-migration/unreachable-try-pattern.stderr new file mode 100644 index 00000000000..a8a0ed3d03b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-try-pattern.stderr @@ -0,0 +1,43 @@ +warning: unreachable expression + --> $DIR/unreachable-try-pattern.rs:29:36 + | +LL | let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?; + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/unreachable-try-pattern.rs:13:9 + | +LL | #![warn(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + +warning: unreachable pattern + --> $DIR/unreachable-try-pattern.rs:29:24 + | +LL | let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?; + | ^^^^^ + | +note: lint level defined here + --> $DIR/unreachable-try-pattern.rs:14:9 + | +LL | #![warn(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +warning: unreachable pattern + --> $DIR/unreachable-try-pattern.rs:40:40 + | +LL | let y = (match x { Ok(n) => Ok(n), Err(e) => Err(e) })?; + | ^^^^^^ + +error: compilation successful + --> $DIR/unreachable-try-pattern.rs:46:1 + | +LL | / fn main() { //~ ERROR: compilation successful +LL | | let _ = bar(Err(123)); +LL | | let _ = foo(Err(123)); +LL | | let _ = qux(Ok(123)); +LL | | let _ = vom(Ok(123)); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unreachable-variant.rs b/src/test/ui/compile-fail-migration/unreachable-variant.rs new file mode 100644 index 00000000000..5983c83f8b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-variant.rs @@ -0,0 +1,17 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:unreachable_variant.rs + +extern crate unreachable_variant as other; + +fn main() { + let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private +} diff --git a/src/test/ui/compile-fail-migration/unreachable-variant.stderr b/src/test/ui/compile-fail-migration/unreachable-variant.stderr new file mode 100644 index 00000000000..fff77586549 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unreachable-variant.stderr @@ -0,0 +1,9 @@ +error[E0603]: module `super_sekrit` is private + --> $DIR/unreachable-variant.rs:16:14 + | +LL | let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.rs b/src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.rs new file mode 100644 index 00000000000..714b73ec739 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.rs @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate core; +use core; +//~^ ERROR the name `core` is defined multiple times + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.stderr b/src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.stderr new file mode 100644 index 00000000000..4e3ea573d27 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unresolved-extern-mod-suggestion.stderr @@ -0,0 +1,17 @@ +error[E0254]: the name `core` is defined multiple times + --> $DIR/unresolved-extern-mod-suggestion.rs:12:5 + | +LL | extern crate core; + | ------------------ previous import of the extern crate `core` here +LL | use core; + | ^^^^ `core` reimported here + | + = note: `core` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | use core as other_core; + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0254`. diff --git a/src/test/ui/compile-fail-migration/unresolved-import-recovery.rs b/src/test/ui/compile-fail-migration/unresolved-import-recovery.rs new file mode 100644 index 00000000000..8173f69191d --- /dev/null +++ b/src/test/ui/compile-fail-migration/unresolved-import-recovery.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that unresolved imports do not create additional errors and ICEs + +mod m { + pub use unresolved; //~ ERROR unresolved import `unresolved` + + fn f() { + let unresolved = 0; // OK + } +} + +fn main() { + match 0u8 { + m::unresolved => {} // OK + m::unresolved(..) => {} // OK + m::unresolved{..} => {} // OK + } +} diff --git a/src/test/ui/compile-fail-migration/unresolved-import-recovery.stderr b/src/test/ui/compile-fail-migration/unresolved-import-recovery.stderr new file mode 100644 index 00000000000..d4304195eb1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unresolved-import-recovery.stderr @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `unresolved` + --> $DIR/unresolved-import-recovery.rs:14:13 + | +LL | pub use unresolved; //~ ERROR unresolved import `unresolved` + | ^^^^^^^^^^ no `unresolved` in the root + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/unresolved-import.rs b/src/test/ui/compile-fail-migration/unresolved-import.rs new file mode 100644 index 00000000000..a3eeb6de96b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unresolved-import.rs @@ -0,0 +1,57 @@ +// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +use foo::bar; //~ ERROR unresolved import `foo` [E0432] + //~^ Maybe a missing `extern crate foo;`? + +use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432] + //~^ no `Baz` in `bar`. Did you mean to use `Bar`? + +use food::baz; //~ ERROR unresolved import `food::baz` + //~^ no `baz` in `food`. Did you mean to use `bag`? + +use food::{beens as Foo}; //~ ERROR unresolved import `food::beens` [E0432] + //~^ no `beens` in `food`. Did you mean to use `beans`? + +mod bar { + pub struct Bar; +} + +mod food { + pub use self::zug::baz::{self as bag, foobar as beans}; + + mod zug { + pub mod baz { + pub struct foobar; + } + } +} + +mod m { + enum MyEnum { + MyVariant + } + + use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432] + //~^ Did you mean `self::MyEnum`? +} + +mod items { + enum Enum { + Variant + } + + use Enum::*; //~ ERROR unresolved import `Enum` [E0432] + //~^ Did you mean `self::Enum`? + + fn item() {} +} diff --git a/src/test/ui/compile-fail-migration/unresolved-import.stderr b/src/test/ui/compile-fail-migration/unresolved-import.stderr new file mode 100644 index 00000000000..1e663cde48a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unresolved-import.stderr @@ -0,0 +1,44 @@ +error[E0432]: unresolved import `foo` + --> $DIR/unresolved-import.rs:13:5 + | +LL | use foo::bar; //~ ERROR unresolved import `foo` [E0432] + | ^^^ Maybe a missing `extern crate foo;`? + +error[E0432]: unresolved import `bar::Baz` + --> $DIR/unresolved-import.rs:16:5 + | +LL | use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432] + | ^^^^^^^^^^^^^ no `Baz` in `bar`. Did you mean to use `Bar`? + +error[E0432]: unresolved import `food::baz` + --> $DIR/unresolved-import.rs:19:5 + | +LL | use food::baz; //~ ERROR unresolved import `food::baz` + | ^^^^^^^^^ no `baz` in `food`. Did you mean to use `bag`? + +error[E0432]: unresolved import `food::beens` + --> $DIR/unresolved-import.rs:22:12 + | +LL | use food::{beens as Foo}; //~ ERROR unresolved import `food::beens` [E0432] + | ^^^^^^^^^^^^ no `beens` in `food`. Did you mean to use `beans`? + +error[E0432]: unresolved import `MyEnum` + --> $DIR/unresolved-import.rs:44:9 + | +LL | use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432] + | ^^^^^^ Did you mean `self::MyEnum`? + +error[E0432]: unresolved import `Enum` + --> $DIR/unresolved-import.rs:53:9 + | +LL | use Enum::*; //~ ERROR unresolved import `Enum` [E0432] + | ^^^^ Did you mean `self::Enum`? + +error[E0601]: `main` function not found in crate `unresolved_import` + | + = note: consider adding a `main` function to `$DIR/unresolved-import.rs` + +error: aborting due to 7 previous errors + +Some errors occurred: E0432, E0601. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.rs b/src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.rs new file mode 100644 index 00000000000..484a8979d71 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// issue #12418 + +#![deny(unused_unsafe)] + +fn main() { + unsafe { println!("foo"); } //~ ERROR unnecessary `unsafe` +} diff --git a/src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.stderr b/src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.stderr new file mode 100644 index 00000000000..849630ac34e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-around-compiler-generated-unsafe.stderr @@ -0,0 +1,14 @@ +error: unnecessary `unsafe` block + --> $DIR/unsafe-around-compiler-generated-unsafe.rs:16:5 + | +LL | unsafe { println!("foo"); } //~ ERROR unnecessary `unsafe` + | ^^^^^^ unnecessary `unsafe` block + | +note: lint level defined here + --> $DIR/unsafe-around-compiler-generated-unsafe.rs:13:9 + | +LL | #![deny(unused_unsafe)] + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.rs b/src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.rs new file mode 100644 index 00000000000..baf2002a94f --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.rs @@ -0,0 +1,19 @@ + +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn f(p: *mut u8) { + *p = 0; //~ ERROR dereference of raw pointer is unsafe + return; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.stderr b/src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.stderr new file mode 100644 index 00000000000..e98600a8f2f --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-assign-deref-ptr.stderr @@ -0,0 +1,11 @@ +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-assign-deref-ptr.rs:14:5 + | +LL | *p = 0; //~ ERROR dereference of raw pointer is unsafe + | ^^^^^^ 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/compile-fail-migration/unsafe-fn-autoderef.rs b/src/test/ui/compile-fail-migration/unsafe-fn-autoderef.rs new file mode 100644 index 00000000000..15b304c69ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-autoderef.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Rec { + f: isize +} + +fn f(p: *const Rec) -> isize { + + // Test that * ptrs do not autoderef. There is a deeper reason for + // prohibiting this, beyond making unsafe things annoying (which doesn't + // actually seem desirable to me). The deeper reason is that if you + // have a type like: + // + // enum foo = *foo; + // + // you end up with an infinite auto-deref chain, which is + // currently impossible (in all other cases, infinite auto-derefs + // are prohibited by various checks, such as that the enum is + // instantiable and so forth). + + return p.f; //~ ERROR no field `f` on type `*const Rec` +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-autoderef.stderr b/src/test/ui/compile-fail-migration/unsafe-fn-autoderef.stderr new file mode 100644 index 00000000000..13fcbb347c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-autoderef.stderr @@ -0,0 +1,9 @@ +error[E0609]: no field `f` on type `*const Rec` + --> $DIR/unsafe-fn-autoderef.rs:29:14 + | +LL | return p.f; //~ ERROR no field `f` on type `*const Rec` + | ^ help: `p` is a native pointer; try dereferencing it: `(*p).f` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.rs b/src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.rs new file mode 100644 index 00000000000..46f28da43d0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +unsafe fn f() { return; } + +fn main() { + f(); //~ ERROR call to unsafe function is unsafe +} diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.stderr b/src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.stderr new file mode 100644 index 00000000000..a781347040e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-called-from-safe.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-called-from-safe.rs:15:5 + | +LL | f(); //~ ERROR call to unsafe function is unsafe + | ^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.rs b/src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.rs new file mode 100644 index 00000000000..8e3ce8ff9b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn f(p: *const u8) -> u8 { + return *p; //~ ERROR dereference of raw pointer is unsafe +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.stderr b/src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.stderr new file mode 100644 index 00000000000..885f6e446fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-deref-ptr.stderr @@ -0,0 +1,11 @@ +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-deref-ptr.rs:13:12 + | +LL | return *p; //~ ERROR dereference of raw pointer is unsafe + | ^^ 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/compile-fail-migration/unsafe-fn-used-as-value.rs b/src/test/ui/compile-fail-migration/unsafe-fn-used-as-value.rs new file mode 100644 index 00000000000..f09a0c7107a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-used-as-value.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +unsafe fn f() { return; } + +fn main() { + let x = f; + x(); //~ ERROR call to unsafe function is unsafe +} diff --git a/src/test/ui/compile-fail-migration/unsafe-fn-used-as-value.stderr b/src/test/ui/compile-fail-migration/unsafe-fn-used-as-value.stderr new file mode 100644 index 00000000000..7f8af300be5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-fn-used-as-value.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-used-as-value.rs:16:5 + | +LL | x(); //~ ERROR call to unsafe function is unsafe + | ^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/compile-fail-migration/unsafe-move-val-init.rs b/src/test/ui/compile-fail-migration/unsafe-move-val-init.rs new file mode 100644 index 00000000000..b4e425e7bbf --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-move-val-init.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(core_intrinsics)] + +use std::intrinsics; + +// `move_val_init` has an odd desugaring, check that it is still treated +// as unsafe. +fn main() { + intrinsics::move_val_init(1 as *mut u32, 1); + //~^ ERROR dereference of raw pointer is unsafe +} diff --git a/src/test/ui/compile-fail-migration/unsafe-move-val-init.stderr b/src/test/ui/compile-fail-migration/unsafe-move-val-init.stderr new file mode 100644 index 00000000000..be92623b5d0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-move-val-init.stderr @@ -0,0 +1,11 @@ +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-move-val-init.rs:18:5 + | +LL | intrinsics::move_val_init(1 as *mut u32, 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/compile-fail-migration/unsafe-subtyping.rs b/src/test/ui/compile-fail-migration/unsafe-subtyping.rs new file mode 100644 index 00000000000..f4867636819 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-subtyping.rs @@ -0,0 +1,21 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that safe fns are not a subtype of unsafe fns. + +fn foo(x: Option) -> Option { + x //~ ERROR mismatched types +} + +fn bar(x: fn(i32)) -> unsafe fn(i32) { + x // OK, coercion! +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsafe-subtyping.stderr b/src/test/ui/compile-fail-migration/unsafe-subtyping.stderr new file mode 100644 index 00000000000..645f2a7939e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-subtyping.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/unsafe-subtyping.rs:14:5 + | +LL | fn foo(x: Option) -> Option { + | ---------------------- expected `std::option::Option` because of return type +LL | x //~ ERROR mismatched types + | ^ expected unsafe fn, found normal fn + | + = note: expected type `std::option::Option` + found type `std::option::Option` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/unsafe-trait-impl.rs b/src/test/ui/compile-fail-migration/unsafe-trait-impl.rs new file mode 100644 index 00000000000..fb4652affd0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-trait-impl.rs @@ -0,0 +1,24 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that safe fns are not a subtype of unsafe fns. + +trait Foo { + unsafe fn len(&self) -> u32; +} + +impl Foo for u32 { + fn len(&self) -> u32 { *self } + //~^ ERROR method `len` has an incompatible type for trait + //~| expected type `unsafe fn(&u32) -> u32` + //~| found type `fn(&u32) -> u32` +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsafe-trait-impl.stderr b/src/test/ui/compile-fail-migration/unsafe-trait-impl.stderr new file mode 100644 index 00000000000..ae47d6c1627 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsafe-trait-impl.stderr @@ -0,0 +1,15 @@ +error[E0053]: method `len` has an incompatible type for trait + --> $DIR/unsafe-trait-impl.rs:18:5 + | +LL | unsafe fn len(&self) -> u32; + | ---------------------------- type in trait +... +LL | fn len(&self) -> u32 { *self } + | ^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found normal fn + | + = note: expected type `unsafe fn(&u32) -> u32` + found type `fn(&u32) -> u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/src/test/ui/compile-fail-migration/unsized-bare-typaram.rs b/src/test/ui/compile-fail-migration/unsized-bare-typaram.rs new file mode 100644 index 00000000000..498bdded350 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-bare-typaram.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn bar() { } +fn foo() { bar::() } +//~^ ERROR the size for values of type +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsized-bare-typaram.stderr b/src/test/ui/compile-fail-migration/unsized-bare-typaram.stderr new file mode 100644 index 00000000000..884d7acff03 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-bare-typaram.stderr @@ -0,0 +1,18 @@ +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unsized-bare-typaram.rs:12:23 + | +LL | fn foo() { bar::() } + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `T` + = note: to learn more, visit + = help: consider adding a `where T: std::marker::Sized` bound +note: required by `bar` + --> $DIR/unsized-bare-typaram.rs:11:1 + | +LL | fn bar() { } + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized-enum.rs b/src/test/ui/compile-fail-migration/unsized-enum.rs new file mode 100644 index 00000000000..4a6a5557c95 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-enum.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn is_sized() { } +fn not_sized() { } + +enum Foo { FooSome(U), FooNone } +fn foo1() { not_sized::>() } // Hunky dory. +fn foo2() { not_sized::>() } +//~^ ERROR the size for values of type +// +// Not OK: `T` is not sized. + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsized-enum.stderr b/src/test/ui/compile-fail-migration/unsized-enum.stderr new file mode 100644 index 00000000000..7e965fbda52 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-enum.stderr @@ -0,0 +1,18 @@ +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unsized-enum.rs:17:36 + | +LL | fn foo2() { not_sized::>() } + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `T` + = note: to learn more, visit + = help: consider adding a `where T: std::marker::Sized` bound +note: required by `Foo` + --> $DIR/unsized-enum.rs:15:1 + | +LL | enum Foo { FooSome(U), FooNone } + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.rs b/src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.rs new file mode 100644 index 00000000000..a679bf77015 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test sized-ness checking in substitution in impls. + +// impl - struct + +struct S5(Y); + +impl S5 { + //~^ ERROR the size for values of type +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.stderr b/src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.stderr new file mode 100644 index 00000000000..e89a3bffe9a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-inherent-impl-self-type.stderr @@ -0,0 +1,18 @@ +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized-inherent-impl-self-type.rs:17:17 + | +LL | impl S5 { + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound +note: required by `S5` + --> $DIR/unsized-inherent-impl-self-type.rs:15:1 + | +LL | struct S5(Y); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized-struct.rs b/src/test/ui/compile-fail-migration/unsized-struct.rs new file mode 100644 index 00000000000..f2c63455c51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-struct.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn is_sized() { } +fn not_sized() { } + +struct Foo { data: T } +fn foo1() { not_sized::>() } // Hunky dory. +fn foo2() { not_sized::>() } +//~^ ERROR the size for values of type +// +// Not OK: `T` is not sized. + +struct Bar { data: T } +fn bar1() { not_sized::>() } +fn bar2() { is_sized::>() } +//~^ ERROR the size for values of type +// +// Not OK: `Bar` is not sized, but it should be. + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsized-struct.stderr b/src/test/ui/compile-fail-migration/unsized-struct.stderr new file mode 100644 index 00000000000..7a089b76a44 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-struct.stderr @@ -0,0 +1,34 @@ +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unsized-struct.rs:17:36 + | +LL | fn foo2() { not_sized::>() } + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `T` + = note: to learn more, visit + = help: consider adding a `where T: std::marker::Sized` bound +note: required by `Foo` + --> $DIR/unsized-struct.rs:15:1 + | +LL | struct Foo { data: T } + | ^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unsized-struct.rs:24:24 + | +LL | fn bar2() { is_sized::>() } + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `Bar`, the trait `std::marker::Sized` is not implemented for `T` + = note: to learn more, visit + = help: consider adding a `where T: std::marker::Sized` bound + = note: required because it appears within the type `Bar` +note: required by `is_sized` + --> $DIR/unsized-struct.rs:12:1 + | +LL | fn is_sized() { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.rs b/src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.rs new file mode 100644 index 00000000000..5c0b8f12402 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test sized-ness checking in substitution in impls. + +// impl - struct +trait T3 { + fn foo(&self, z: &Z); +} + +struct S5(Y); + +impl T3 for S5 { + //~^ ERROR the size for values of type +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.stderr b/src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.stderr new file mode 100644 index 00000000000..4bb9bd48358 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-trait-impl-self-type.stderr @@ -0,0 +1,18 @@ +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized-trait-impl-self-type.rs:20:17 + | +LL | impl T3 for S5 { + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound +note: required by `S5` + --> $DIR/unsized-trait-impl-self-type.rs:18:1 + | +LL | struct S5(Y); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.rs b/src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.rs new file mode 100644 index 00000000000..875a52e11c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test sized-ness checking in substitution in impls. + +// impl - unbounded +trait T2 { + fn foo(&self, z: Z); +} +struct S4(Box); +impl T2 for S4 { + //~^ ERROR the size for values of type +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.stderr b/src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.stderr new file mode 100644 index 00000000000..b4369755a0e --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized-trait-impl-trait-arg.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized-trait-impl-trait-arg.rs:18:17 + | +LL | impl T2 for S4 { + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized3.rs b/src/test/ui/compile-fail-migration/unsized3.rs new file mode 100644 index 00000000000..2e346e473ca --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized3.rs @@ -0,0 +1,61 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test sized-ness checking in substitution within fn bodies.. + +use std::marker; + +// Unbounded. +fn f1(x: &X) { + f2::(x); + //~^ ERROR the size for values of type +} +fn f2(x: &X) { +} + +// Bounded. +trait T { + fn foo(&self) { } +} +fn f3(x: &X) { + f4::(x); + //~^ ERROR the size for values of type +} +fn f4(x: &X) { +} + +fn f5(x: &Y) {} +fn f6(x: &X) {} + +// Test with unsized struct. +struct S { + x: X, +} + +fn f8(x1: &S, x2: &S) { + f5(x1); + //~^ ERROR the size for values of type + f6(x2); // ok +} + +// Test some tuples. +fn f9(x1: Box>) { + f5(&(*x1, 34)); + //~^ ERROR the size for values of type +} + +fn f10(x1: Box>) { + f5(&(32, *x1)); + //~^ ERROR the size for values of type + //~| ERROR the size for values of type +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/unsized3.stderr b/src/test/ui/compile-fail-migration/unsized3.stderr new file mode 100644 index 00000000000..3e01248d7d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized3.stderr @@ -0,0 +1,91 @@ +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized3.rs:17:5 + | +LL | f2::(x); + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound +note: required by `f2` + --> $DIR/unsized3.rs:20:1 + | +LL | fn f2(x: &X) { + | ^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized3.rs:28:5 + | +LL | f4::(x); + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound +note: required by `f4` + --> $DIR/unsized3.rs:31:1 + | +LL | fn f4(x: &X) { + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized3.rs:43:5 + | +LL | f5(x1); + | ^^ doesn't have a size known at compile-time + | + = help: within `S`, the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: required because it appears within the type `S` +note: required by `f5` + --> $DIR/unsized3.rs:34:1 + | +LL | fn f5(x: &Y) {} + | ^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized3.rs:50:5 + | +LL | f5(&(*x1, 34)); + | ^^ doesn't have a size known at compile-time + | + = help: within `S`, the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: required because it appears within the type `S` + = note: only the last element of a tuple may have a dynamically sized type + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized3.rs:55:9 + | +LL | f5(&(32, *x1)); + | ^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `({integer}, S)`, the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: required because it appears within the type `S` + = note: required because it appears within the type `({integer}, S)` + = note: tuples must have a statically known size to be initialized + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized3.rs:55:5 + | +LL | f5(&(32, *x1)); + | ^^ doesn't have a size known at compile-time + | + = help: within `({integer}, S)`, the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: required because it appears within the type `S` + = note: required because it appears within the type `({integer}, S)` +note: required by `f5` + --> $DIR/unsized3.rs:34:1 + | +LL | fn f5(x: &Y) {} + | ^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized5.rs b/src/test/ui/compile-fail-migration/unsized5.rs new file mode 100644 index 00000000000..a50786e306a --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized5.rs @@ -0,0 +1,44 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test `?Sized` types not allowed in fields (except the last one). + +struct S1 { + f1: X, + //~^ ERROR the size for values of type + f2: isize, +} +struct S2 { + f: isize, + g: X, + //~^ ERROR the size for values of type + h: isize, +} +struct S3 { + f: str, + //~^ ERROR the size for values of type + g: [usize] +} +struct S4 { + f: [u8], + //~^ ERROR the size for values of type + g: usize +} +enum E { + V1(X, isize), + //~^ ERROR the size for values of type +} +enum F { + V2{f1: X, f: isize}, + //~^ ERROR the size for values of type +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/unsized5.stderr b/src/test/ui/compile-fail-migration/unsized5.stderr new file mode 100644 index 00000000000..fa93ec236a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized5.stderr @@ -0,0 +1,67 @@ +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized5.rs:14:5 + | +LL | f1: X, + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: only the last field of a struct may have a dynamically sized type + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized5.rs:20:5 + | +LL | g: X, + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: only the last field of a struct may have a dynamically sized type + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/unsized5.rs:25:5 + | +LL | f: str, + | ^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: to learn more, visit + = note: only the last field of a struct may have a dynamically sized type + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized5.rs:30:5 + | +LL | f: [u8], + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `[u8]` + = note: to learn more, visit + = note: only the last field of a struct may have a dynamically sized type + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized5.rs:35:8 + | +LL | V1(X, isize), + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: no field of an enum variant may have a dynamically sized type + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized5.rs:39:8 + | +LL | V2{f1: X, f: isize}, + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: no field of an enum variant may have a dynamically sized type + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized6.rs b/src/test/ui/compile-fail-migration/unsized6.rs new file mode 100644 index 00000000000..1a57f2caf8d --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized6.rs @@ -0,0 +1,54 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test `?Sized` local variables. + +trait T {} + +fn f1(x: &X) { + let _: W; // <-- this is OK, no bindings created, no initializer. + let _: (isize, (X, isize)); + //~^ ERROR the size for values of type + let y: Y; + //~^ ERROR the size for values of type + let y: (isize, (Z, usize)); + //~^ ERROR the size for values of type +} +fn f2(x: &X) { + let y: X; + //~^ ERROR the size for values of type + let y: (isize, (Y, isize)); + //~^ ERROR the size for values of type +} + +fn f3(x1: Box, x2: Box, x3: Box) { + let y: X = *x1; + //~^ ERROR the size for values of type + let y = *x2; + //~^ ERROR the size for values of type + let (y, z) = (*x3, 4); + //~^ ERROR the size for values of type +} +fn f4(x1: Box, x2: Box, x3: Box) { + let y: X = *x1; + //~^ ERROR the size for values of type + let y = *x2; + //~^ ERROR the size for values of type + let (y, z) = (*x3, 4); + //~^ ERROR the size for values of type +} + +fn g1(x: X) {} +//~^ ERROR the size for values of type +fn g2(x: X) {} +//~^ ERROR the size for values of type + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/unsized6.stderr b/src/test/ui/compile-fail-migration/unsized6.stderr new file mode 100644 index 00000000000..9f53369b12f --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized6.stderr @@ -0,0 +1,146 @@ +error[E0277]: the size for values of type `Y` cannot be known at compilation time + --> $DIR/unsized6.rs:19:9 + | +LL | let y: Y; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `Y` + = note: to learn more, visit + = help: consider adding a `where Y: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:17:12 + | +LL | let _: (isize, (X, isize)); + | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: only the last element of a tuple may have a dynamically sized type + +error[E0277]: the size for values of type `Z` cannot be known at compilation time + --> $DIR/unsized6.rs:21:12 + | +LL | let y: (isize, (Z, usize)); + | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `Z` + = note: to learn more, visit + = help: consider adding a `where Z: std::marker::Sized` bound + = note: only the last element of a tuple may have a dynamically sized type + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:25:9 + | +LL | let y: X; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `Y` cannot be known at compilation time + --> $DIR/unsized6.rs:27:12 + | +LL | let y: (isize, (Y, isize)); + | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `Y` + = note: to learn more, visit + = help: consider adding a `where Y: std::marker::Sized` bound + = note: only the last element of a tuple may have a dynamically sized type + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:32:9 + | +LL | let y: X = *x1; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:34:9 + | +LL | let y = *x2; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:36:10 + | +LL | let (y, z) = (*x3, 4); + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:40:9 + | +LL | let y: X = *x1; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:42:9 + | +LL | let y = *x2; + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:44:10 + | +LL | let (y, z) = (*x3, 4); + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:48:18 + | +LL | fn g1(x: X) {} + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized6.rs:50:22 + | +LL | fn g2(x: X) {} + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error: aborting due to 13 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unsized7.rs b/src/test/ui/compile-fail-migration/unsized7.rs new file mode 100644 index 00000000000..07b4ae4c394 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized7.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test sized-ness checking in substitution in impls. + +trait T {} + +// I would like these to fail eventually. +// impl - bounded +trait T1 { + fn dummy(&self) -> Z; +} + +struct S3(Box); +impl T1 for S3 { + //~^ ERROR the size for values of type +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unsized7.stderr b/src/test/ui/compile-fail-migration/unsized7.stderr new file mode 100644 index 00000000000..c5539d8d319 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsized7.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `X` cannot be known at compilation time + --> $DIR/unsized7.rs:22:21 + | +LL | impl T1 for S3 { + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `X` + = note: to learn more, visit + = help: consider adding a `where X: std::marker::Sized` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.rs b/src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.rs new file mode 100644 index 00000000000..cf8f3e91602 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.rs @@ -0,0 +1,30 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo { + fn foo(&self); +} + +pub trait Bar { + fn foo(&self); +} + +fn main() { + let a = Foo::lol(); + //~^ ERROR no function or associated item named + let b = Foo::<_>::lol(); + //~^ ERROR no function or associated item named + let c = Bar::lol(); + //~^ ERROR no function or associated item named + let d = Bar::::lol(); + //~^ ERROR no function or associated item named + let e = Bar::::lol(); + //~^ ERROR must be explicitly specified +} diff --git a/src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.stderr b/src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.stderr new file mode 100644 index 00000000000..c036540068b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unspecified-self-in-trait-ref.stderr @@ -0,0 +1,36 @@ +error[E0599]: no function or associated item named `lol` found for type `dyn Foo<_>` in the current scope + --> $DIR/unspecified-self-in-trait-ref.rs:20:13 + | +LL | let a = Foo::lol(); + | ^^^^^^^^ function or associated item not found in `dyn Foo<_>` + +error[E0599]: no function or associated item named `lol` found for type `dyn Foo<_>` in the current scope + --> $DIR/unspecified-self-in-trait-ref.rs:22:13 + | +LL | let b = Foo::<_>::lol(); + | ^^^^^^^^^^^^^ function or associated item not found in `dyn Foo<_>` + +error[E0599]: no function or associated item named `lol` found for type `dyn Bar<_, _>` in the current scope + --> $DIR/unspecified-self-in-trait-ref.rs:24:13 + | +LL | let c = Bar::lol(); + | ^^^^^^^^ function or associated item not found in `dyn Bar<_, _>` + +error[E0599]: no function or associated item named `lol` found for type `dyn Bar` in the current scope + --> $DIR/unspecified-self-in-trait-ref.rs:26:13 + | +LL | let d = Bar::::lol(); + | ^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `dyn Bar` + +error[E0393]: the type parameter `A` must be explicitly specified + --> $DIR/unspecified-self-in-trait-ref.rs:28:13 + | +LL | let e = Bar::::lol(); + | ^^^^^^^^^^^^^^^^^ missing reference to `A` + | + = note: because of the default `Self` reference, type parameters must be specified on object types + +error: aborting due to 5 previous errors + +Some errors occurred: E0393, E0599. +For more information about an error, try `rustc --explain E0393`. diff --git a/src/test/ui/compile-fail-migration/unsupported-cast.rs b/src/test/ui/compile-fail-migration/unsupported-cast.rs new file mode 100644 index 00000000000..5137663a269 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsupported-cast.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:casting + +struct A; + +fn main() { + println!("{:?}", 1.0 as *const A); // Can't cast float to foreign. +} diff --git a/src/test/ui/compile-fail-migration/unsupported-cast.stderr b/src/test/ui/compile-fail-migration/unsupported-cast.stderr new file mode 100644 index 00000000000..4babc01ad7f --- /dev/null +++ b/src/test/ui/compile-fail-migration/unsupported-cast.stderr @@ -0,0 +1,9 @@ +error[E0606]: casting `f64` as `*const A` is invalid + --> $DIR/unsupported-cast.rs:16:20 + | +LL | println!("{:?}", 1.0 as *const A); // Can't cast float to foreign. + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/compile-fail-migration/unused-attr.rs b/src/test/ui/compile-fail-migration/unused-attr.rs new file mode 100644 index 00000000000..e20d03478ec --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-attr.rs @@ -0,0 +1,60 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_attributes)] +#![allow(dead_code, unused_imports, unused_extern_crates)] +#![feature(custom_attribute)] + +#![foo] //~ ERROR unused attribute + +#[foo] //~ ERROR unused attribute +extern crate core; + +#[foo] //~ ERROR unused attribute +use std::collections; + +#[foo] //~ ERROR unused attribute +extern "C" { + #[foo] //~ ERROR unused attribute + fn foo(); +} + +#[foo] //~ ERROR unused attribute +mod foo { + #[foo] //~ ERROR unused attribute + pub enum Foo { + #[foo] //~ ERROR unused attribute + Bar, + } +} + +#[foo] //~ ERROR unused attribute +fn bar(f: foo::Foo) { + match f { + #[foo] //~ ERROR unused attribute + foo::Foo::Bar => {} + } +} + +#[foo] //~ ERROR unused attribute +struct Foo { + #[foo] //~ ERROR unused attribute + a: isize +} + +#[foo] //~ ERROR unused attribute +trait Baz { + #[foo] //~ ERROR unused attribute + fn blah(&self); + #[foo] //~ ERROR unused attribute + fn blah2(&self) {} +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unused-attr.stderr b/src/test/ui/compile-fail-migration/unused-attr.stderr new file mode 100644 index 00000000000..7265dd3c63f --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-attr.stderr @@ -0,0 +1,98 @@ +error: unused attribute + --> $DIR/unused-attr.rs:17:1 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + | +note: lint level defined here + --> $DIR/unused-attr.rs:11:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:20:1 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:25:5 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:23:1 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:33:9 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:31:5 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:29:1 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:41:9 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:38:1 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:48:5 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:46:1 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:54:5 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:56:5 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:52:1 + | +LL | #[foo] //~ ERROR unused attribute + | ^^^^^^ + +error: unused attribute + --> $DIR/unused-attr.rs:15:1 + | +LL | #![foo] //~ ERROR unused attribute + | ^^^^^^^ + +error: aborting due to 15 previous errors + diff --git a/src/test/ui/compile-fail-migration/unused-macro-rules.rs b/src/test/ui/compile-fail-migration/unused-macro-rules.rs new file mode 100644 index 00000000000..5e401c09bda --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro-rules.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_macros)] + +// Most simple case +macro_rules! unused { //~ ERROR: unused macro definition + () => {}; +} + +// Test macros created by macros +macro_rules! create_macro { + () => { + macro_rules! m { //~ ERROR: unused macro definition + () => {}; + } + }; +} +create_macro!(); + +#[allow(unused_macros)] +mod bar { + // Test that putting the #[deny] close to the macro's definition + // works. + + #[deny(unused_macros)] + macro_rules! unused { //~ ERROR: unused macro definition + () => {}; + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unused-macro-rules.stderr b/src/test/ui/compile-fail-migration/unused-macro-rules.stderr new file mode 100644 index 00000000000..8ced41022f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro-rules.stderr @@ -0,0 +1,41 @@ +error: unused macro definition + --> $DIR/unused-macro-rules.rs:14:1 + | +LL | / macro_rules! unused { //~ ERROR: unused macro definition +LL | | () => {}; +LL | | } + | |_^ + | +note: lint level defined here + --> $DIR/unused-macro-rules.rs:11:9 + | +LL | #![deny(unused_macros)] + | ^^^^^^^^^^^^^ + +error: unused macro definition + --> $DIR/unused-macro-rules.rs:21:9 + | +LL | / macro_rules! m { //~ ERROR: unused macro definition +LL | | () => {}; +LL | | } + | |_________^ +... +LL | create_macro!(); + | ---------------- in this macro invocation + +error: unused macro definition + --> $DIR/unused-macro-rules.rs:34:5 + | +LL | / macro_rules! unused { //~ ERROR: unused macro definition +LL | | () => {}; +LL | | } + | |_____^ + | +note: lint level defined here + --> $DIR/unused-macro-rules.rs:33:12 + | +LL | #[deny(unused_macros)] + | ^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.rs b/src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.rs new file mode 100644 index 00000000000..28a69e6f9e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_macros)] + +// Issue #21370 + +macro_rules! test { + ($wrong:t_ty) => () //~ ERROR invalid fragment specifier `t_ty` +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.stderr b/src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.stderr new file mode 100644 index 00000000000..88435878905 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro-with-bad-frag-spec.stderr @@ -0,0 +1,10 @@ +error: invalid fragment specifier `t_ty` + --> $DIR/unused-macro-with-bad-frag-spec.rs:16:6 + | +LL | ($wrong:t_ty) => () //~ ERROR invalid fragment specifier `t_ty` + | ^^^^^^^^^^^ + | + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.rs b/src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.rs new file mode 100644 index 00000000000..dda0d3fc955 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_macros)] + +macro_rules! test { + ($e:expr +) => () //~ ERROR not allowed for `expr` fragments +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.stderr b/src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.stderr new file mode 100644 index 00000000000..8efb191c7c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro-with-follow-violation.stderr @@ -0,0 +1,8 @@ +error: `$e:expr` is followed by `+`, which is not allowed for `expr` fragments + --> $DIR/unused-macro-with-follow-violation.rs:14:14 + | +LL | ($e:expr +) => () //~ ERROR not allowed for `expr` fragments + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unused-macro.rs b/src/test/ui/compile-fail-migration/unused-macro.rs new file mode 100644 index 00000000000..9e32f01724d --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(decl_macro)] +#![deny(unused_macros)] + +// Most simple case +macro unused { //~ ERROR: unused macro definition + () => {} +} + +#[allow(unused_macros)] +mod bar { + // Test that putting the #[deny] close to the macro's definition + // works. + + #[deny(unused_macros)] + macro unused { //~ ERROR: unused macro definition + () => {} + } +} + +mod boo { + pub(crate) macro unused { //~ ERROR: unused macro definition + () => {} + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/unused-macro.stderr b/src/test/ui/compile-fail-migration/unused-macro.stderr new file mode 100644 index 00000000000..3e1c1164d5b --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-macro.stderr @@ -0,0 +1,38 @@ +error: unused macro definition + --> $DIR/unused-macro.rs:15:1 + | +LL | / macro unused { //~ ERROR: unused macro definition +LL | | () => {} +LL | | } + | |_^ + | +note: lint level defined here + --> $DIR/unused-macro.rs:12:9 + | +LL | #![deny(unused_macros)] + | ^^^^^^^^^^^^^ + +error: unused macro definition + --> $DIR/unused-macro.rs:25:5 + | +LL | / macro unused { //~ ERROR: unused macro definition +LL | | () => {} +LL | | } + | |_____^ + | +note: lint level defined here + --> $DIR/unused-macro.rs:24:12 + | +LL | #[deny(unused_macros)] + | ^^^^^^^^^^^^^ + +error: unused macro definition + --> $DIR/unused-macro.rs:31:5 + | +LL | / pub(crate) macro unused { //~ ERROR: unused macro definition +LL | | () => {} +LL | | } + | |_____^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.rs b/src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.rs new file mode 100644 index 00000000000..d4dc58864ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![forbid(unused_mut)] + +fn main() { + let mut x = 1; + //~^ ERROR: variable does not need to be mutable + move|| { println!("{}", x); }; +} diff --git a/src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.stderr b/src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.stderr new file mode 100644 index 00000000000..ae976d85bde --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-mut-warning-captured-var.stderr @@ -0,0 +1,16 @@ +error: variable does not need to be mutable + --> $DIR/unused-mut-warning-captured-var.rs:14:9 + | +LL | let mut x = 1; + | ----^ + | | + | help: remove this `mut` + | +note: lint level defined here + --> $DIR/unused-mut-warning-captured-var.rs:11:11 + | +LL | #![forbid(unused_mut)] + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/unused-result.rs b/src/test/ui/compile-fail-migration/unused-result.rs new file mode 100644 index 00000000000..363ab6220bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-result.rs @@ -0,0 +1,52 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![deny(unused_results, unused_must_use)] +//~^ NOTE: lint level defined here +//~| NOTE: lint level defined here + +#[must_use] +enum MustUse { Test } + +#[must_use = "some message"] +enum MustUseMsg { Test2 } + +fn foo() -> T { panic!() } + +fn bar() -> isize { return foo::(); } +fn baz() -> MustUse { return foo::(); } +fn qux() -> MustUseMsg { return foo::(); } + +#[allow(unused_results)] +fn test() { + foo::(); + foo::(); //~ ERROR: unused `MustUse` which must be used + foo::(); //~ ERROR: unused `MustUseMsg` which must be used + //~^ NOTE: some message +} + +#[allow(unused_results, unused_must_use)] +fn test2() { + foo::(); + foo::(); + foo::(); +} + +fn main() { + foo::(); //~ ERROR: unused result + foo::(); //~ ERROR: unused `MustUse` which must be used + foo::(); //~ ERROR: unused `MustUseMsg` which must be used + //~^ NOTE: some message + + let _ = foo::(); + let _ = foo::(); + let _ = foo::(); +} diff --git a/src/test/ui/compile-fail-migration/unused-result.stderr b/src/test/ui/compile-fail-migration/unused-result.stderr new file mode 100644 index 00000000000..e6ca7b8fab8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/unused-result.stderr @@ -0,0 +1,48 @@ +error: unused `MustUse` which must be used + --> $DIR/unused-result.rs:31:5 + | +LL | foo::(); //~ ERROR: unused `MustUse` which must be used + | ^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/unused-result.rs:12:25 + | +LL | #![deny(unused_results, unused_must_use)] + | ^^^^^^^^^^^^^^^ + +error: unused `MustUseMsg` which must be used + --> $DIR/unused-result.rs:32:5 + | +LL | foo::(); //~ ERROR: unused `MustUseMsg` which must be used + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: some message + +error: unused result + --> $DIR/unused-result.rs:44:5 + | +LL | foo::(); //~ ERROR: unused result + | ^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/unused-result.rs:12:9 + | +LL | #![deny(unused_results, unused_must_use)] + | ^^^^^^^^^^^^^^ + +error: unused `MustUse` which must be used + --> $DIR/unused-result.rs:45:5 + | +LL | foo::(); //~ ERROR: unused `MustUse` which must be used + | ^^^^^^^^^^^^^^^^^ + +error: unused `MustUseMsg` which must be used + --> $DIR/unused-result.rs:46:5 + | +LL | foo::(); //~ ERROR: unused `MustUseMsg` which must be used + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: some message + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/use-after-move-based-on-type.nll.stderr b/src/test/ui/compile-fail-migration/use-after-move-based-on-type.nll.stderr new file mode 100644 index 00000000000..a18c25cbb55 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-based-on-type.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/use-after-move-based-on-type.rs:14:20 + | +LL | let _y = x; + | - value moved here +LL | println!("{}", x); //~ ERROR use of moved value + | ^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/use-after-move-based-on-type.rs b/src/test/ui/compile-fail-migration/use-after-move-based-on-type.rs new file mode 100644 index 00000000000..e2167ca446f --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-based-on-type.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x = "Hello!".to_string(); + let _y = x; + println!("{}", x); //~ ERROR use of moved value +} diff --git a/src/test/ui/compile-fail-migration/use-after-move-based-on-type.stderr b/src/test/ui/compile-fail-migration/use-after-move-based-on-type.stderr new file mode 100644 index 00000000000..510cc708bed --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-based-on-type.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `x` + --> $DIR/use-after-move-based-on-type.rs:14:20 + | +LL | let _y = x; + | -- value moved here +LL | println!("{}", x); //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.nll.stderr b/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.nll.stderr new file mode 100644 index 00000000000..23753506368 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: borrow of moved value: `n` + --> $DIR/use-after-move-implicity-coerced-object.rs:38:13 + | +LL | l.push(n); + | - value moved here +LL | let x = n.to_string(); + | ^ value borrowed here after move + | + = note: move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.rs b/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.rs new file mode 100644 index 00000000000..addc5721752 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +use std::fmt; + +struct Number { + n: i64 +} + +impl fmt::Display for Number { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.n) + } +} + +struct List { + list: Vec> } + +impl List { + fn push(&mut self, n: Box) { + self.list.push(n); + } +} + +fn main() { + let n: Box<_> = box Number { n: 42 }; + let mut l: Box<_> = box List { list: Vec::new() }; + l.push(n); + let x = n.to_string(); + //~^ ERROR: use of moved value: `n` +} diff --git a/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.stderr b/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.stderr new file mode 100644 index 00000000000..ab7494702d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-implicity-coerced-object.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `n` + --> $DIR/use-after-move-implicity-coerced-object.rs:38:13 + | +LL | l.push(n); + | - value moved here +LL | let x = n.to_string(); + | ^ value used here after move + | + = note: move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.rs b/src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.rs new file mode 100644 index 00000000000..810fc68a0f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S { + x: isize, +} + +impl Drop for S { + fn drop(&mut self) {} +} + +impl S { + pub fn foo(self) -> isize { + self.bar(); + return self.x; //~ ERROR use of moved value: `self.x` + } + + pub fn bar(self) {} +} + +fn main() { + let x = S { x: 1 }; + println!("{}", x.foo()); +} diff --git a/src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.stderr b/src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.stderr new file mode 100644 index 00000000000..60cd142799e --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-self-based-on-type.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `self.x` + --> $DIR/use-after-move-self-based-on-type.rs:22:16 + | +LL | self.bar(); + | ---- value moved here +LL | return self.x; //~ ERROR use of moved value: `self.x` + | ^^^^^^ value used here after move + | + = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/use-after-move-self.nll.stderr b/src/test/ui/compile-fail-migration/use-after-move-self.nll.stderr new file mode 100644 index 00000000000..3b19e96d12c --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-self.nll.stderr @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `*self.x` + --> $DIR/use-after-move-self.rs:20:16 + | +LL | self.bar(); + | ---- value moved here +LL | return *self.x; //~ ERROR use of moved value: `*self.x` + | ^^^^^^^ value used here after move + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/use-after-move-self.rs b/src/test/ui/compile-fail-migration/use-after-move-self.rs new file mode 100644 index 00000000000..e9ffb26aba5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-self.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct S { + x: Box, +} + +impl S { + pub fn foo(self) -> isize { + self.bar(); + return *self.x; //~ ERROR use of moved value: `*self.x` + } + + pub fn bar(self) {} +} + +fn main() { + let x = S { x: box 1 }; + println!("{}", x.foo()); +} diff --git a/src/test/ui/compile-fail-migration/use-after-move-self.stderr b/src/test/ui/compile-fail-migration/use-after-move-self.stderr new file mode 100644 index 00000000000..7273602aadc --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-after-move-self.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `*self.x` + --> $DIR/use-after-move-self.rs:20:16 + | +LL | self.bar(); + | ---- value moved here +LL | return *self.x; //~ ERROR use of moved value: `*self.x` + | ^^^^^^^ value used here after move + | + = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/use-from-trait-xc.rs b/src/test/ui/compile-fail-migration/use-from-trait-xc.rs new file mode 100644 index 00000000000..3848b6814d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-from-trait-xc.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:use_from_trait_xc.rs + +extern crate use_from_trait_xc; + +use use_from_trait_xc::Trait::foo; +//~^ ERROR `foo` is not directly importable + +use use_from_trait_xc::Trait::Assoc; +//~^ ERROR `Assoc` is not directly importable + +use use_from_trait_xc::Trait::CONST; +//~^ ERROR `CONST` is not directly importable + +use use_from_trait_xc::Foo::new; //~ ERROR struct `Foo` is private +//~^ ERROR unresolved import `use_from_trait_xc::Foo` + +use use_from_trait_xc::Foo::C; //~ ERROR struct `Foo` is private +//~^ ERROR unresolved import `use_from_trait_xc::Foo` + +use use_from_trait_xc::Bar::new as bnew; +//~^ ERROR unresolved import `use_from_trait_xc::Bar` + +use use_from_trait_xc::Baz::new as baznew; +//~^ ERROR unresolved import `use_from_trait_xc::Baz::new` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-from-trait-xc.stderr b/src/test/ui/compile-fail-migration/use-from-trait-xc.stderr new file mode 100644 index 00000000000..130aca8162a --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-from-trait-xc.stderr @@ -0,0 +1,58 @@ +error[E0253]: `foo` is not directly importable + --> $DIR/use-from-trait-xc.rs:15:5 + | +LL | use use_from_trait_xc::Trait::foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly + +error[E0253]: `Assoc` is not directly importable + --> $DIR/use-from-trait-xc.rs:18:5 + | +LL | use use_from_trait_xc::Trait::Assoc; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly + +error[E0253]: `CONST` is not directly importable + --> $DIR/use-from-trait-xc.rs:21:5 + | +LL | use use_from_trait_xc::Trait::CONST; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly + +error[E0432]: unresolved import `use_from_trait_xc::Foo` + --> $DIR/use-from-trait-xc.rs:24:24 + | +LL | use use_from_trait_xc::Foo::new; //~ ERROR struct `Foo` is private + | ^^^ Not a module `Foo` + +error[E0432]: unresolved import `use_from_trait_xc::Foo` + --> $DIR/use-from-trait-xc.rs:27:24 + | +LL | use use_from_trait_xc::Foo::C; //~ ERROR struct `Foo` is private + | ^^^ Not a module `Foo` + +error[E0432]: unresolved import `use_from_trait_xc::Bar` + --> $DIR/use-from-trait-xc.rs:30:24 + | +LL | use use_from_trait_xc::Bar::new as bnew; + | ^^^ Not a module `Bar` + +error[E0432]: unresolved import `use_from_trait_xc::Baz::new` + --> $DIR/use-from-trait-xc.rs:33:5 + | +LL | use use_from_trait_xc::Baz::new as baznew; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `new` in `Baz` + +error[E0603]: struct `Foo` is private + --> $DIR/use-from-trait-xc.rs:24:5 + | +LL | use use_from_trait_xc::Foo::new; //~ ERROR struct `Foo` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: struct `Foo` is private + --> $DIR/use-from-trait-xc.rs:27:5 + | +LL | use use_from_trait_xc::Foo::C; //~ ERROR struct `Foo` is private + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + +Some errors occurred: E0253, E0432, E0603. +For more information about an error, try `rustc --explain E0253`. diff --git a/src/test/ui/compile-fail-migration/use-from-trait.rs b/src/test/ui/compile-fail-migration/use-from-trait.rs new file mode 100644 index 00000000000..29db949acd0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-from-trait.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +use Trait::foo; +//~^ ERROR `foo` is not directly importable +use Trait::Assoc; +//~^ ERROR `Assoc` is not directly importable +use Trait::C; +//~^ ERROR `C` is not directly importable + +use Foo::new; +//~^ ERROR unresolved import `Foo` [E0432] +//~| Not a module `Foo` + +use Foo::C2; +//~^ ERROR unresolved import `Foo` [E0432] +//~| Not a module `Foo` + +pub trait Trait { + fn foo(); + type Assoc; + const C: u32; +} + +struct Foo; + +impl Foo { + fn new() {} + const C2: u32 = 0; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-from-trait.stderr b/src/test/ui/compile-fail-migration/use-from-trait.stderr new file mode 100644 index 00000000000..b43a32988ca --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-from-trait.stderr @@ -0,0 +1,34 @@ +error[E0253]: `foo` is not directly importable + --> $DIR/use-from-trait.rs:12:5 + | +LL | use Trait::foo; + | ^^^^^^^^^^ cannot be imported directly + +error[E0253]: `Assoc` is not directly importable + --> $DIR/use-from-trait.rs:14:5 + | +LL | use Trait::Assoc; + | ^^^^^^^^^^^^ cannot be imported directly + +error[E0253]: `C` is not directly importable + --> $DIR/use-from-trait.rs:16:5 + | +LL | use Trait::C; + | ^^^^^^^^ cannot be imported directly + +error[E0432]: unresolved import `Foo` + --> $DIR/use-from-trait.rs:19:5 + | +LL | use Foo::new; + | ^^^ Not a module `Foo` + +error[E0432]: unresolved import `Foo` + --> $DIR/use-from-trait.rs:23:5 + | +LL | use Foo::C2; + | ^^^ Not a module `Foo` + +error: aborting due to 5 previous errors + +Some errors occurred: E0253, E0432. +For more information about an error, try `rustc --explain E0253`. diff --git a/src/test/ui/compile-fail-migration/use-keyword.rs b/src/test/ui/compile-fail-migration/use-keyword.rs new file mode 100644 index 00000000000..aff54f18c19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-keyword.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that imports with nakes super and self don't fail during parsing +// FIXME: this shouldn't fail during name resolution either + +mod a { + mod b { + use self as A; + //~^ ERROR `self` imports are only allowed within a { } list + use super as B; + //~^ ERROR unresolved import `super` [E0432] + //~| no `super` in the root + use super::{self as C}; + //~^ ERROR unresolved import `super` [E0432] + //~| no `super` in the root + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-keyword.stderr b/src/test/ui/compile-fail-migration/use-keyword.stderr new file mode 100644 index 00000000000..11893bce5c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-keyword.stderr @@ -0,0 +1,22 @@ +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-keyword.rs:16:13 + | +LL | use self as A; + | ^^^^^^^^^ + +error[E0432]: unresolved import `super` + --> $DIR/use-keyword.rs:18:13 + | +LL | use super as B; + | ^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-keyword.rs:21:21 + | +LL | use super::{self as C}; + | ^^^^^^^^^ no `super` in the root + +error: aborting due to 3 previous errors + +Some errors occurred: E0429, E0432. +For more information about an error, try `rustc --explain E0429`. diff --git a/src/test/ui/compile-fail-migration/use-meta-mismatch.rs b/src/test/ui/compile-fail-migration/use-meta-mismatch.rs new file mode 100644 index 00000000000..6b7b9c89149 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-meta-mismatch.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:can't find crate for `extra` + +extern crate fake_crate as extra; + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/use-meta-mismatch.stderr b/src/test/ui/compile-fail-migration/use-meta-mismatch.stderr new file mode 100644 index 00000000000..063de29510e --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-meta-mismatch.stderr @@ -0,0 +1,9 @@ +error[E0463]: can't find crate for `extra` + --> $DIR/use-meta-mismatch.rs:13:1 + | +LL | extern crate fake_crate as extra; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/compile-fail-migration/use-mod-2.rs b/src/test/ui/compile-fail-migration/use-mod-2.rs new file mode 100644 index 00000000000..5f8842a521a --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-mod-2.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + use self::{self}; + //~^ ERROR unresolved import `self` [E0432] + //~| no `self` in the root + + use super::{self}; + //~^ ERROR unresolved import `super` [E0432] + //~| no `super` in the root +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-mod-2.stderr b/src/test/ui/compile-fail-migration/use-mod-2.stderr new file mode 100644 index 00000000000..f343dc2b31d --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-mod-2.stderr @@ -0,0 +1,15 @@ +error[E0432]: unresolved import `self` + --> $DIR/use-mod-2.rs:12:16 + | +LL | use self::{self}; + | ^^^^ no `self` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-mod-2.rs:16:17 + | +LL | use super::{self}; + | ^^^^ no `super` in the root + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/use-mod-3.rs b/src/test/ui/compile-fail-migration/use-mod-3.rs new file mode 100644 index 00000000000..cce500800ca --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-mod-3.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use foo::bar::{ + self //~ ERROR module `bar` is private +}; +use foo::bar::{ + Bar //~ ERROR module `bar` is private +}; + +mod foo { + mod bar { pub type Bar = isize; } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-mod-3.stderr b/src/test/ui/compile-fail-migration/use-mod-3.stderr new file mode 100644 index 00000000000..61923984641 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-mod-3.stderr @@ -0,0 +1,15 @@ +error[E0603]: module `bar` is private + --> $DIR/use-mod-3.rs:12:5 + | +LL | self //~ ERROR module `bar` is private + | ^^^^ + +error[E0603]: module `bar` is private + --> $DIR/use-mod-3.rs:15:5 + | +LL | Bar //~ ERROR module `bar` is private + | ^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/use-mod-4.rs b/src/test/ui/compile-fail-migration/use-mod-4.rs new file mode 100644 index 00000000000..275e5ff1da6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-mod-4.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use foo::self; //~ ERROR unresolved import `foo` +//~^ ERROR `self` imports are only allowed within a { } list + +use std::mem::self; +//~^ ERROR `self` imports are only allowed within a { } list + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-mod-4.stderr b/src/test/ui/compile-fail-migration/use-mod-4.stderr new file mode 100644 index 00000000000..9a6d608faac --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-mod-4.stderr @@ -0,0 +1,22 @@ +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-mod-4.rs:11:5 + | +LL | use foo::self; //~ ERROR unresolved import `foo` + | ^^^^^^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-mod-4.rs:14:5 + | +LL | use std::mem::self; + | ^^^^^^^^^^^^^^ + +error[E0432]: unresolved import `foo` + --> $DIR/use-mod-4.rs:11:5 + | +LL | use foo::self; //~ ERROR unresolved import `foo` + | ^^^ Maybe a missing `extern crate foo;`? + +error: aborting due to 3 previous errors + +Some errors occurred: E0429, E0432. +For more information about an error, try `rustc --explain E0429`. diff --git a/src/test/ui/compile-fail-migration/use-paths-as-items.rs b/src/test/ui/compile-fail-migration/use-paths-as-items.rs new file mode 100644 index 00000000000..db69bb33ae2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-paths-as-items.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Each path node in a `use` declaration must be treated as an item. If not, the following code +// will trigger an ICE. +// +// Related issue: #25763 + +use std::{mem, ptr}; +use std::mem; //~ ERROR the name `mem` is defined multiple times + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-paths-as-items.stderr b/src/test/ui/compile-fail-migration/use-paths-as-items.stderr new file mode 100644 index 00000000000..200cefc23af --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-paths-as-items.stderr @@ -0,0 +1,17 @@ +error[E0252]: the name `mem` is defined multiple times + --> $DIR/use-paths-as-items.rs:17:5 + | +LL | use std::{mem, ptr}; + | --- previous import of the module `mem` here +LL | use std::mem; //~ ERROR the name `mem` is defined multiple times + | ^^^^^^^^ `mem` reimported here + | + = note: `mem` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | use std::mem as other_mem; //~ ERROR the name `mem` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff --git a/src/test/ui/compile-fail-migration/use-self-type.rs b/src/test/ui/compile-fail-migration/use-self-type.rs new file mode 100644 index 00000000000..6b5286bf0a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-self-type.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S; + +impl S { + fn f() {} + fn g() { + use Self::f; //~ ERROR unresolved import + pub(in Self::f) struct Z; //~ ERROR Use of undeclared type or module `Self` + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/use-self-type.stderr b/src/test/ui/compile-fail-migration/use-self-type.stderr new file mode 100644 index 00000000000..1a3bf5a9e88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-self-type.stderr @@ -0,0 +1,16 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `Self` + --> $DIR/use-self-type.rs:17:16 + | +LL | pub(in Self::f) struct Z; //~ ERROR Use of undeclared type or module `Self` + | ^^^^ Use of undeclared type or module `Self` + +error[E0432]: unresolved import + --> $DIR/use-self-type.rs:16:13 + | +LL | use Self::f; //~ ERROR unresolved import + | ^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/compile-fail-migration/use-super-global-path.rs b/src/test/ui/compile-fail-migration/use-super-global-path.rs new file mode 100644 index 00000000000..fc1a72f6f2b --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-super-global-path.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +struct S; +struct Z; + +mod foo { + use ::super::{S, Z}; //~ ERROR global paths cannot start with `super` + + pub fn g() { + use ::super::main; //~ ERROR global paths cannot start with `super` + main(); //~ ERROR cannot find function `main` in this scope + } +} + +fn main() { foo::g(); } diff --git a/src/test/ui/compile-fail-migration/use-super-global-path.stderr b/src/test/ui/compile-fail-migration/use-super-global-path.stderr new file mode 100644 index 00000000000..4730653dbf9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/use-super-global-path.stderr @@ -0,0 +1,26 @@ +error[E0433]: failed to resolve. global paths cannot start with `super` + --> $DIR/use-super-global-path.rs:17:11 + | +LL | use ::super::{S, Z}; //~ ERROR global paths cannot start with `super` + | ^^^^^ global paths cannot start with `super` + +error[E0433]: failed to resolve. global paths cannot start with `super` + --> $DIR/use-super-global-path.rs:20:15 + | +LL | use ::super::main; //~ ERROR global paths cannot start with `super` + | ^^^^^ global paths cannot start with `super` + +error[E0425]: cannot find function `main` in this scope + --> $DIR/use-super-global-path.rs:21:9 + | +LL | main(); //~ ERROR cannot find function `main` in this scope + | ^^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use main; + | + +error: aborting due to 3 previous errors + +Some errors occurred: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/used.rs b/src/test/ui/compile-fail-migration/used.rs new file mode 100644 index 00000000000..f170d9c25f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/used.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(used)] + +#[used] +static FOO: u32 = 0; // OK + +#[used] //~ ERROR attribute must be applied to a `static` variable +fn foo() {} + +#[used] //~ ERROR attribute must be applied to a `static` variable +struct Foo {} + +#[used] //~ ERROR attribute must be applied to a `static` variable +trait Bar {} + +#[used] //~ ERROR attribute must be applied to a `static` variable +impl Bar for Foo {} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/used.stderr b/src/test/ui/compile-fail-migration/used.stderr new file mode 100644 index 00000000000..b8d0f42c3a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/used.stderr @@ -0,0 +1,26 @@ +error: attribute must be applied to a `static` variable + --> $DIR/used.rs:16:1 + | +LL | #[used] //~ ERROR attribute must be applied to a `static` variable + | ^^^^^^^ + +error: attribute must be applied to a `static` variable + --> $DIR/used.rs:19:1 + | +LL | #[used] //~ ERROR attribute must be applied to a `static` variable + | ^^^^^^^ + +error: attribute must be applied to a `static` variable + --> $DIR/used.rs:22:1 + | +LL | #[used] //~ ERROR attribute must be applied to a `static` variable + | ^^^^^^^ + +error: attribute must be applied to a `static` variable + --> $DIR/used.rs:25:1 + | +LL | #[used] //~ ERROR attribute must be applied to a `static` variable + | ^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/useless-pub.rs b/src/test/ui/compile-fail-migration/useless-pub.rs new file mode 100644 index 00000000000..064062df753 --- /dev/null +++ b/src/test/ui/compile-fail-migration/useless-pub.rs @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct A { pub i: isize } + +pub trait E { + fn foo(&self); +} + +impl E for A { + pub fn foo(&self) {} //~ ERROR: unnecessary visibility qualifier +} + +enum Foo { + V1 { pub f: i32 }, //~ ERROR unnecessary visibility qualifier + V2(pub i32), //~ ERROR unnecessary visibility qualifier +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/useless-pub.stderr b/src/test/ui/compile-fail-migration/useless-pub.stderr new file mode 100644 index 00000000000..7e36bf2667e --- /dev/null +++ b/src/test/ui/compile-fail-migration/useless-pub.stderr @@ -0,0 +1,21 @@ +error[E0449]: unnecessary visibility qualifier + --> $DIR/useless-pub.rs:18:5 + | +LL | pub fn foo(&self) {} //~ ERROR: unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/useless-pub.rs:22:10 + | +LL | V1 { pub f: i32 }, //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error[E0449]: unnecessary visibility qualifier + --> $DIR/useless-pub.rs:23:8 + | +LL | V2(pub i32), //~ ERROR unnecessary visibility qualifier + | ^^^ `pub` not permitted here because it's implied + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0449`. diff --git a/src/test/ui/compile-fail-migration/useless_comment.rs b/src/test/ui/compile-fail-migration/useless_comment.rs new file mode 100644 index 00000000000..645514971da --- /dev/null +++ b/src/test/ui/compile-fail-migration/useless_comment.rs @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(unused_doc_comments)] + +fn foo() { + /// a //~ ERROR doc comment not used by rustdoc + let x = 12; + + /// b //~ doc comment not used by rustdoc + match x { + /// c //~ ERROR doc comment not used by rustdoc + 1 => {}, + _ => {} + } + + /// foo //~ ERROR doc comment not used by rustdoc + unsafe {} +} + +fn main() { + foo(); +} diff --git a/src/test/ui/compile-fail-migration/useless_comment.stderr b/src/test/ui/compile-fail-migration/useless_comment.stderr new file mode 100644 index 00000000000..78c6787c88e --- /dev/null +++ b/src/test/ui/compile-fail-migration/useless_comment.stderr @@ -0,0 +1,32 @@ +error: doc comment not used by rustdoc + --> $DIR/useless_comment.rs:14:5 + | +LL | /// a //~ ERROR doc comment not used by rustdoc + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/useless_comment.rs:11:9 + | +LL | #![deny(unused_doc_comments)] + | ^^^^^^^^^^^^^^^^^^^ + +error: doc comment not used by rustdoc + --> $DIR/useless_comment.rs:17:5 + | +LL | /// b //~ doc comment not used by rustdoc + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: doc comment not used by rustdoc + --> $DIR/useless_comment.rs:19:9 + | +LL | /// c //~ ERROR doc comment not used by rustdoc + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: doc comment not used by rustdoc + --> $DIR/useless_comment.rs:24:5 + | +LL | /// foo //~ ERROR doc comment not used by rustdoc + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/user-defined-macro-rules.rs b/src/test/ui/compile-fail-migration/user-defined-macro-rules.rs new file mode 100644 index 00000000000..02e1a585fa8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/user-defined-macro-rules.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_macros)] + +macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules` diff --git a/src/test/ui/compile-fail-migration/user-defined-macro-rules.stderr b/src/test/ui/compile-fail-migration/user-defined-macro-rules.stderr new file mode 100644 index 00000000000..3359aa4bcd7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/user-defined-macro-rules.stderr @@ -0,0 +1,13 @@ +error: user-defined macros may not be named `macro_rules` + --> $DIR/user-defined-macro-rules.rs:13:1 + | +LL | macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0601]: `main` function not found in crate `user_defined_macro_rules` + | + = note: consider adding a `main` function to `$DIR/user-defined-macro-rules.rs` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/utf8_idents.rs b/src/test/ui/compile-fail-migration/utf8_idents.rs new file mode 100644 index 00000000000..8594c35f8dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/utf8_idents.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// + +fn foo< + 'β, //~ ERROR non-ascii idents are not fully supported + γ //~ ERROR non-ascii idents are not fully supported +>() {} + +struct X { + δ: usize //~ ERROR non-ascii idents are not fully supported +} + +pub fn main() { + let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported +} diff --git a/src/test/ui/compile-fail-migration/utf8_idents.stderr b/src/test/ui/compile-fail-migration/utf8_idents.stderr new file mode 100644 index 00000000000..42ee13e0511 --- /dev/null +++ b/src/test/ui/compile-fail-migration/utf8_idents.stderr @@ -0,0 +1,35 @@ +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) + --> $DIR/utf8_idents.rs:13:5 + | +LL | 'β, //~ ERROR non-ascii idents are not fully supported + | ^^ + | + = help: add #![feature(non_ascii_idents)] to the crate attributes to enable + +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) + --> $DIR/utf8_idents.rs:14:5 + | +LL | γ //~ ERROR non-ascii idents are not fully supported + | ^ + | + = help: add #![feature(non_ascii_idents)] to the crate attributes to enable + +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) + --> $DIR/utf8_idents.rs:18:5 + | +LL | δ: usize //~ ERROR non-ascii idents are not fully supported + | ^ + | + = help: add #![feature(non_ascii_idents)] to the crate attributes to enable + +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) + --> $DIR/utf8_idents.rs:22:9 + | +LL | let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported + | ^ + | + = help: add #![feature(non_ascii_idents)] to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/variadic-ffi-2.rs b/src/test/ui/compile-fail-migration/variadic-ffi-2.rs new file mode 100644 index 00000000000..ec5669f6392 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variadic-ffi-2.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-arm stdcall isn't suppported + +fn baz(f: extern "stdcall" fn(usize, ...)) { + //~^ ERROR: variadic function must have C or cdecl calling convention + f(22, 44); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variadic-ffi-2.stderr b/src/test/ui/compile-fail-migration/variadic-ffi-2.stderr new file mode 100644 index 00000000000..9af7b5bf753 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variadic-ffi-2.stderr @@ -0,0 +1,9 @@ +error[E0045]: variadic function must have C or cdecl calling convention + --> $DIR/variadic-ffi-2.rs:13:11 + | +LL | fn baz(f: extern "stdcall" fn(usize, ...)) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0045`. diff --git a/src/test/ui/compile-fail-migration/variadic-ffi.rs b/src/test/ui/compile-fail-migration/variadic-ffi.rs new file mode 100644 index 00000000000..f245306f4d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variadic-ffi.rs @@ -0,0 +1,41 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-arm stdcall isn't suppported +// ignore-aarch64 stdcall isn't suppported + +extern "stdcall" { + fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling +} + +extern { + fn foo(f: isize, x: u8, ...); +} + +extern "C" fn bar(f: isize, x: u8) {} + +fn main() { + // errors below are no longer checked because error above aborts + // compilation; see variadic-ffi-3.rs for corresponding test. + unsafe { + foo(); + foo(1); + + let x: unsafe extern "C" fn(f: isize, x: u8) = foo; + let y: extern "C" fn(f: isize, x: u8, ...) = bar; + + foo(1, 2, 3f32); + foo(1, 2, true); + foo(1, 2, 1i8); + foo(1, 2, 1u8); + foo(1, 2, 1i16); + foo(1, 2, 1u16); + } +} diff --git a/src/test/ui/compile-fail-migration/variadic-ffi.stderr b/src/test/ui/compile-fail-migration/variadic-ffi.stderr new file mode 100644 index 00000000000..0d0462b709d --- /dev/null +++ b/src/test/ui/compile-fail-migration/variadic-ffi.stderr @@ -0,0 +1,9 @@ +error[E0045]: variadic function must have C or cdecl calling convention + --> $DIR/variadic-ffi.rs:15:5 + | +LL | fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0045`. diff --git a/src/test/ui/compile-fail-migration/variance-associated-types.rs b/src/test/ui/compile-fail-migration/variance-associated-types.rs new file mode 100644 index 00000000000..7dbfc6ac125 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-associated-types.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the variance computation considers types/regions that +// appear in projections to be invariant. + +#![feature(rustc_attrs)] + +trait Trait<'a> { + type Type; + + fn method(&'a self) { } +} + +#[rustc_variance] +struct Foo<'a, T : Trait<'a>> { //~ ERROR [-, +] + field: (T, &'a ()) +} + +#[rustc_variance] +struct Bar<'a, T : Trait<'a>> { //~ ERROR [o, o] + field: >::Type +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-associated-types.stderr b/src/test/ui/compile-fail-migration/variance-associated-types.stderr new file mode 100644 index 00000000000..03ea1e625f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-associated-types.stderr @@ -0,0 +1,19 @@ +error[E0208]: [-, +] + --> $DIR/variance-associated-types.rs:23:1 + | +LL | / struct Foo<'a, T : Trait<'a>> { //~ ERROR [-, +] +LL | | field: (T, &'a ()) +LL | | } + | |_^ + +error[E0208]: [o, o] + --> $DIR/variance-associated-types.rs:28:1 + | +LL | / struct Bar<'a, T : Trait<'a>> { //~ ERROR [o, o] +LL | | field: >::Type +LL | | } + | |_^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-btree-invariant-types.nll.stderr b/src/test/ui/compile-fail-migration/variance-btree-invariant-types.nll.stderr new file mode 100644 index 00000000000..33230c26b8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-btree-invariant-types.nll.stderr @@ -0,0 +1,178 @@ +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:16:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:19:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:22:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:25:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:30:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:34:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:38:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:42:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:47:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:51:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:55:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-btree-invariant-types.rs:59:5 + | +LL | v //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:16:5 + | +LL | fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> { + | ---- lifetime `'new` defined here +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:19:5 + | +LL | fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> { + | ---- lifetime `'new` defined here +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:22:5 + | +LL | fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> { + | ---- lifetime `'new` defined here +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:25:5 + | +LL | fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> { + | ---- lifetime `'new` defined here +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:30:5 + | +LL | fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>) + | ---- lifetime `'new` defined here +LL | -> OccupiedEntry<'a, &'new (), ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:34:5 + | +LL | fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>) + | ---- lifetime `'new` defined here +LL | -> OccupiedEntry<'a, (), &'new ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:38:5 + | +LL | fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>) + | ---- lifetime `'new` defined here +LL | -> OccupiedEntry<'a, &'static (), ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:42:5 + | +LL | fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>) + | ---- lifetime `'new` defined here +LL | -> OccupiedEntry<'a, (), &'static ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:47:5 + | +LL | fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>) + | ---- lifetime `'new` defined here +LL | -> VacantEntry<'a, &'new (), ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:51:5 + | +LL | fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>) + | ---- lifetime `'new` defined here +LL | -> VacantEntry<'a, (), &'new ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:55:5 + | +LL | fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>) + | ---- lifetime `'new` defined here +LL | -> VacantEntry<'a, &'static (), ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/variance-btree-invariant-types.rs:59:5 + | +LL | fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>) + | ---- lifetime `'new` defined here +LL | -> VacantEntry<'a, (), &'static ()> { +LL | v //~ ERROR mismatched types + | ^ return requires that `'new` must outlive `'static` + +error: aborting due to 12 previous errors + diff --git a/src/test/ui/compile-fail-migration/variance-btree-invariant-types.rs b/src/test/ui/compile-fail-migration/variance-btree-invariant-types.rs new file mode 100644 index 00000000000..e9607de00a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-btree-invariant-types.rs @@ -0,0 +1,63 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +use std::collections::btree_map::{IterMut, OccupiedEntry, VacantEntry}; + +fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> { + v //~ ERROR mismatched types +} +fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> { + v //~ ERROR mismatched types +} +fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> { + v //~ ERROR mismatched types +} +fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> { + v //~ ERROR mismatched types +} + +fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>) + -> OccupiedEntry<'a, &'new (), ()> { + v //~ ERROR mismatched types +} +fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>) + -> OccupiedEntry<'a, (), &'new ()> { + v //~ ERROR mismatched types +} +fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>) + -> OccupiedEntry<'a, &'static (), ()> { + v //~ ERROR mismatched types +} +fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>) + -> OccupiedEntry<'a, (), &'static ()> { + v //~ ERROR mismatched types +} + +fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>) + -> VacantEntry<'a, &'new (), ()> { + v //~ ERROR mismatched types +} +fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>) + -> VacantEntry<'a, (), &'new ()> { + v //~ ERROR mismatched types +} +fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>) + -> VacantEntry<'a, &'static (), ()> { + v //~ ERROR mismatched types +} +fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>) + -> VacantEntry<'a, (), &'static ()> { + v //~ ERROR mismatched types +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-btree-invariant-types.stderr b/src/test/ui/compile-fail-migration/variance-btree-invariant-types.stderr new file mode 100644 index 00000000000..96f76fa5c2d --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-btree-invariant-types.stderr @@ -0,0 +1,183 @@ +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:16:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::IterMut<'_, &'new (), _>` + found type `std::collections::btree_map::IterMut<'_, &'static (), _>` +note: the lifetime 'new as defined on the function body at 15:21... + --> $DIR/variance-btree-invariant-types.rs:15:21 + | +LL | fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> { + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:19:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::IterMut<'_, _, &'new ()>` + found type `std::collections::btree_map::IterMut<'_, _, &'static ()>` +note: the lifetime 'new as defined on the function body at 18:21... + --> $DIR/variance-btree-invariant-types.rs:18:21 + | +LL | fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> { + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:22:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::IterMut<'_, &'static (), _>` + found type `std::collections::btree_map::IterMut<'_, &'new (), _>` +note: the lifetime 'new as defined on the function body at 21:24... + --> $DIR/variance-btree-invariant-types.rs:21:24 + | +LL | fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> { + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:25:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::IterMut<'_, _, &'static ()>` + found type `std::collections::btree_map::IterMut<'_, _, &'new ()>` +note: the lifetime 'new as defined on the function body at 24:24... + --> $DIR/variance-btree-invariant-types.rs:24:24 + | +LL | fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> { + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:30:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::OccupiedEntry<'_, &'new (), _>` + found type `std::collections::btree_map::OccupiedEntry<'_, &'static (), _>` +note: the lifetime 'new as defined on the function body at 28:20... + --> $DIR/variance-btree-invariant-types.rs:28:20 + | +LL | fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:34:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::OccupiedEntry<'_, _, &'new ()>` + found type `std::collections::btree_map::OccupiedEntry<'_, _, &'static ()>` +note: the lifetime 'new as defined on the function body at 32:20... + --> $DIR/variance-btree-invariant-types.rs:32:20 + | +LL | fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:38:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::OccupiedEntry<'_, &'static (), _>` + found type `std::collections::btree_map::OccupiedEntry<'_, &'new (), _>` +note: the lifetime 'new as defined on the function body at 36:23... + --> $DIR/variance-btree-invariant-types.rs:36:23 + | +LL | fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:42:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::OccupiedEntry<'_, _, &'static ()>` + found type `std::collections::btree_map::OccupiedEntry<'_, _, &'new ()>` +note: the lifetime 'new as defined on the function body at 40:23... + --> $DIR/variance-btree-invariant-types.rs:40:23 + | +LL | fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:47:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::VacantEntry<'_, &'new (), _>` + found type `std::collections::btree_map::VacantEntry<'_, &'static (), _>` +note: the lifetime 'new as defined on the function body at 45:20... + --> $DIR/variance-btree-invariant-types.rs:45:20 + | +LL | fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:51:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::VacantEntry<'_, _, &'new ()>` + found type `std::collections::btree_map::VacantEntry<'_, _, &'static ()>` +note: the lifetime 'new as defined on the function body at 49:20... + --> $DIR/variance-btree-invariant-types.rs:49:20 + | +LL | fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:55:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::VacantEntry<'_, &'static (), _>` + found type `std::collections::btree_map::VacantEntry<'_, &'new (), _>` +note: the lifetime 'new as defined on the function body at 53:23... + --> $DIR/variance-btree-invariant-types.rs:53:23 + | +LL | fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error[E0308]: mismatched types + --> $DIR/variance-btree-invariant-types.rs:59:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `std::collections::btree_map::VacantEntry<'_, _, &'static ()>` + found type `std::collections::btree_map::VacantEntry<'_, _, &'new ()>` +note: the lifetime 'new as defined on the function body at 57:23... + --> $DIR/variance-btree-invariant-types.rs:57:23 + | +LL | fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>) + | ^^^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-cell-is-invariant.rs b/src/test/ui/compile-fail-migration/variance-cell-is-invariant.rs new file mode 100644 index 00000000000..1ddbcf4ab84 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-cell-is-invariant.rs @@ -0,0 +1,28 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that Cell is considered invariant with respect to its +// type. + +use std::cell::Cell; + +struct Foo<'a> { + x: Cell>, +} + +fn use_<'short,'long>(c: Foo<'short>, + s: &'short isize, + l: &'long isize, + _where:Option<&'short &'long ()>) { + let _: Foo<'long> = c; //~ ERROR E0623 +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/variance-cell-is-invariant.stderr b/src/test/ui/compile-fail-migration/variance-cell-is-invariant.stderr new file mode 100644 index 00000000000..86f5c1176d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-cell-is-invariant.stderr @@ -0,0 +1,15 @@ +error[E0623]: lifetime mismatch + --> $DIR/variance-cell-is-invariant.rs:24:25 + | +LL | fn use_<'short,'long>(c: Foo<'short>, + | ----------- these two types are declared with different lifetimes... +LL | s: &'short isize, +LL | l: &'long isize, + | ------------ +LL | _where:Option<&'short &'long ()>) { +LL | let _: Foo<'long> = c; //~ ERROR E0623 + | ^ ...but data from `c` flows into `l` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.nll.stderr b/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.nll.stderr new file mode 100644 index 00000000000..67d43dd5070 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.nll.stderr @@ -0,0 +1,36 @@ +warning: not reporting region error due to nll + --> $DIR/variance-contravariant-arg-object.rs:24:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-contravariant-arg-object.rs:32:5 + | +LL | v //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/variance-contravariant-arg-object.rs:24:5 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ cast requires that `'min` must outlive `'max` + +error: unsatisfied lifetime constraints + --> $DIR/variance-contravariant-arg-object.rs:32:5 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ cast requires that `'min` must outlive `'max` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.rs b/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.rs new file mode 100644 index 00000000000..1795ac95358 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// Test that even when `T` is only used in contravariant position, it +// is treated as invariant. + +trait Get : 'static { + fn get(&self, t: T); +} + +fn get_min_from_max<'min, 'max>(v: Box>) + -> Box> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>(v: Box>) + -> Box> + where 'max : 'min +{ + // Previously OK: + v //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.stderr b/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.stderr new file mode 100644 index 00000000000..aeed03733f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-contravariant-arg-object.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-contravariant-arg-object.rs:24:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `dyn Get<&'min i32>` + found type `dyn Get<&'max i32>` +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-contravariant-arg-object.rs:20:21 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-contravariant-arg-object.rs:20:27 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-contravariant-arg-object.rs:32:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `dyn Get<&'max i32>` + found type `dyn Get<&'min i32>` +note: the lifetime 'min as defined on the function body at 27:21... + --> $DIR/variance-contravariant-arg-object.rs:27:21 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 27:27 + --> $DIR/variance-contravariant-arg-object.rs:27:27 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.rs b/src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.rs new file mode 100644 index 00000000000..9b6e3c9de3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.rs @@ -0,0 +1,36 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// Test that even when `T` is only used in contravariant position, it +// is treated as invariant. + +trait Get { + fn get(&self, t: T); +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : Get<&'max i32> +{ + impls_get::() //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : Get<&'min i32> +{ + // Previously OK, but now an error because traits are invariant: + + impls_get::() //~ ERROR mismatched types +} + +fn impls_get() where G : Get { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.stderr b/src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.stderr new file mode 100644 index 00000000000..2895a9511ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-contravariant-arg-trait-match.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-contravariant-arg-trait-match.rs:23:5 + | +LL | impls_get::() //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get<&'min i32>` + found type `Get<&'max i32>` +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-contravariant-arg-trait-match.rs:20:21 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-contravariant-arg-trait-match.rs:20:27 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-contravariant-arg-trait-match.rs:31:5 + | +LL | impls_get::() //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get<&'max i32>` + found type `Get<&'min i32>` +note: the lifetime 'min as defined on the function body at 26:21... + --> $DIR/variance-contravariant-arg-trait-match.rs:26:21 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 26:27 + --> $DIR/variance-contravariant-arg-trait-match.rs:26:27 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.rs b/src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.rs new file mode 100644 index 00000000000..6d9d1e61fed --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.rs @@ -0,0 +1,37 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// Test that even when `Self` is only used in contravariant position, it +// is treated as invariant. + +trait Get { + fn get(&self); +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : 'max, &'max G : Get +{ + impls_get::<&'min G>(); //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : 'max, &'min G : Get +{ + // Previously OK, but now error because traits are invariant with + // respect to all inputs. + + impls_get::<&'max G>(); //~ ERROR mismatched types +} + +fn impls_get() where G : Get { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.stderr b/src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.stderr new file mode 100644 index 00000000000..bc3f274a861 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-contravariant-self-trait-match.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-contravariant-self-trait-match.rs:23:5 + | +LL | impls_get::<&'min G>(); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get` + found type `Get` +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-contravariant-self-trait-match.rs:20:21 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-contravariant-self-trait-match.rs:20:27 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-contravariant-self-trait-match.rs:32:5 + | +LL | impls_get::<&'max G>(); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get` + found type `Get` +note: the lifetime 'min as defined on the function body at 26:21... + --> $DIR/variance-contravariant-self-trait-match.rs:26:21 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 26:27 + --> $DIR/variance-contravariant-self-trait-match.rs:26:27 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-covariant-arg-object.nll.stderr b/src/test/ui/compile-fail-migration/variance-covariant-arg-object.nll.stderr new file mode 100644 index 00000000000..55413e57a94 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-covariant-arg-object.nll.stderr @@ -0,0 +1,36 @@ +warning: not reporting region error due to nll + --> $DIR/variance-covariant-arg-object.rs:25:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-covariant-arg-object.rs:32:5 + | +LL | v //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/variance-covariant-arg-object.rs:25:5 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ cast requires that `'min` must outlive `'max` + +error: unsatisfied lifetime constraints + --> $DIR/variance-covariant-arg-object.rs:32:5 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ cast requires that `'min` must outlive `'max` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/variance-covariant-arg-object.rs b/src/test/ui/compile-fail-migration/variance-covariant-arg-object.rs new file mode 100644 index 00000000000..ad059a467f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-covariant-arg-object.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// Test that even when `T` is only used in covariant position, it +// is treated as invariant. + +trait Get : 'static { + fn get(&self) -> T; +} + +fn get_min_from_max<'min, 'max>(v: Box>) + -> Box> + where 'max : 'min +{ + // Previously OK, now an error as traits are invariant. + v //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>(v: Box>) + -> Box> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-covariant-arg-object.stderr b/src/test/ui/compile-fail-migration/variance-covariant-arg-object.stderr new file mode 100644 index 00000000000..074ef658419 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-covariant-arg-object.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-covariant-arg-object.rs:25:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `dyn Get<&'min i32>` + found type `dyn Get<&'max i32>` +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-covariant-arg-object.rs:20:21 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-covariant-arg-object.rs:20:27 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-covariant-arg-object.rs:32:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `dyn Get<&'max i32>` + found type `dyn Get<&'min i32>` +note: the lifetime 'min as defined on the function body at 28:21... + --> $DIR/variance-covariant-arg-object.rs:28:21 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 28:27 + --> $DIR/variance-covariant-arg-object.rs:28:27 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.rs b/src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.rs new file mode 100644 index 00000000000..c42a845b3b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// Test that even when `T` is only used in covariant position, it +// is treated as invariant. + +trait Get { + fn get(&self) -> T; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : Get<&'max i32> +{ + // Previously OK, now an error as traits are invariant. + impls_get::() //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : Get<&'min i32> +{ + impls_get::() //~ ERROR mismatched types +} + +fn impls_get() where G : Get { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.stderr b/src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.stderr new file mode 100644 index 00000000000..7692a6646f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-covariant-arg-trait-match.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-covariant-arg-trait-match.rs:24:5 + | +LL | impls_get::() //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get<&'min i32>` + found type `Get<&'max i32>` +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-covariant-arg-trait-match.rs:20:21 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-covariant-arg-trait-match.rs:20:27 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-covariant-arg-trait-match.rs:30:5 + | +LL | impls_get::() //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get<&'max i32>` + found type `Get<&'min i32>` +note: the lifetime 'min as defined on the function body at 27:21... + --> $DIR/variance-covariant-arg-trait-match.rs:27:21 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 27:27 + --> $DIR/variance-covariant-arg-trait-match.rs:27:27 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.rs b/src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.rs new file mode 100644 index 00000000000..25148dfc020 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// Test that even when `Self` is only used in covariant position, it +// is treated as invariant. + +trait Get { + fn get() -> Self; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : 'max, &'max G : Get +{ + // Previously OK, now an error as traits are invariant. + impls_get::<&'min G>(); //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : 'max, &'min G : Get +{ + impls_get::<&'max G>(); //~ ERROR mismatched types +} + +fn impls_get() where G : Get { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.stderr b/src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.stderr new file mode 100644 index 00000000000..aa82b69bbbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-covariant-self-trait-match.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-covariant-self-trait-match.rs:24:5 + | +LL | impls_get::<&'min G>(); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get` + found type `Get` +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-covariant-self-trait-match.rs:20:21 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-covariant-self-trait-match.rs:20:27 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-covariant-self-trait-match.rs:30:5 + | +LL | impls_get::<&'max G>(); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get` + found type `Get` +note: the lifetime 'min as defined on the function body at 27:21... + --> $DIR/variance-covariant-self-trait-match.rs:27:21 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 27:27 + --> $DIR/variance-covariant-self-trait-match.rs:27:27 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-invariant-arg-object.nll.stderr b/src/test/ui/compile-fail-migration/variance-invariant-arg-object.nll.stderr new file mode 100644 index 00000000000..f9097519246 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-invariant-arg-object.nll.stderr @@ -0,0 +1,36 @@ +warning: not reporting region error due to nll + --> $DIR/variance-invariant-arg-object.rs:21:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-invariant-arg-object.rs:28:5 + | +LL | v //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/variance-invariant-arg-object.rs:21:5 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ cast requires that `'min` must outlive `'max` + +error: unsatisfied lifetime constraints + --> $DIR/variance-invariant-arg-object.rs:28:5 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ cast requires that `'min` must outlive `'max` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/variance-invariant-arg-object.rs b/src/test/ui/compile-fail-migration/variance-invariant-arg-object.rs new file mode 100644 index 00000000000..9edb510b826 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-invariant-arg-object.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +trait Get : 'static { + fn get(&self, t: T) -> T; +} + +fn get_min_from_max<'min, 'max>(v: Box>) + -> Box> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>(v: Box>) + -> Box> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-invariant-arg-object.stderr b/src/test/ui/compile-fail-migration/variance-invariant-arg-object.stderr new file mode 100644 index 00000000000..3283ae67e51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-invariant-arg-object.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-invariant-arg-object.rs:21:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `dyn Get<&'min i32>` + found type `dyn Get<&'max i32>` +note: the lifetime 'min as defined on the function body at 17:21... + --> $DIR/variance-invariant-arg-object.rs:17:21 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 17:27 + --> $DIR/variance-invariant-arg-object.rs:17:27 + | +LL | fn get_min_from_max<'min, 'max>(v: Box>) + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-invariant-arg-object.rs:28:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `dyn Get<&'max i32>` + found type `dyn Get<&'min i32>` +note: the lifetime 'min as defined on the function body at 24:21... + --> $DIR/variance-invariant-arg-object.rs:24:21 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 24:27 + --> $DIR/variance-invariant-arg-object.rs:24:27 + | +LL | fn get_max_from_min<'min, 'max, G>(v: Box>) + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.rs b/src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.rs new file mode 100644 index 00000000000..45fed0b083d --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +trait Get { + fn get(&self, t: T) -> T; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, G : Get<&'max i32> +{ + impls_get::() //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, G : Get<&'min i32> +{ + impls_get::() //~ ERROR mismatched types +} + +fn impls_get() where G : Get { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.stderr b/src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.stderr new file mode 100644 index 00000000000..fc0d5e486de --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-invariant-arg-trait-match.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-invariant-arg-trait-match.rs:20:5 + | +LL | impls_get::() //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get<&'min i32>` + found type `Get<&'max i32>` +note: the lifetime 'min as defined on the function body at 17:21... + --> $DIR/variance-invariant-arg-trait-match.rs:17:21 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 17:27 + --> $DIR/variance-invariant-arg-trait-match.rs:17:27 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-invariant-arg-trait-match.rs:26:5 + | +LL | impls_get::() //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get<&'max i32>` + found type `Get<&'min i32>` +note: the lifetime 'min as defined on the function body at 23:21... + --> $DIR/variance-invariant-arg-trait-match.rs:23:21 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 23:27 + --> $DIR/variance-invariant-arg-trait-match.rs:23:27 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.rs b/src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.rs new file mode 100644 index 00000000000..fe61dee23bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +trait Get { + fn get(&self) -> Self; +} + +fn get_min_from_max<'min, 'max, G>() + where 'max : 'min, &'max G : Get, G : 'max +{ + impls_get::<&'min G>(); //~ ERROR mismatched types +} + +fn get_max_from_min<'min, 'max, G>() + where 'max : 'min, &'min G : Get, G : 'min +{ + impls_get::<&'max G>(); //~ ERROR mismatched types +} + +fn impls_get() where G : Get { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.stderr b/src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.stderr new file mode 100644 index 00000000000..b34f027e895 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-invariant-self-trait-match.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-invariant-self-trait-match.rs:20:5 + | +LL | impls_get::<&'min G>(); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get` + found type `Get` +note: the lifetime 'min as defined on the function body at 17:21... + --> $DIR/variance-invariant-self-trait-match.rs:17:21 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 17:27 + --> $DIR/variance-invariant-self-trait-match.rs:17:27 + | +LL | fn get_min_from_max<'min, 'max, G>() + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-invariant-self-trait-match.rs:26:5 + | +LL | impls_get::<&'max G>(); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Get` + found type `Get` +note: the lifetime 'min as defined on the function body at 23:21... + --> $DIR/variance-invariant-self-trait-match.rs:23:21 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 23:27 + --> $DIR/variance-invariant-self-trait-match.rs:23:27 + | +LL | fn get_max_from_min<'min, 'max, G>() + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-issue-20533.nll.stderr b/src/test/ui/compile-fail-migration/variance-issue-20533.nll.stderr new file mode 100644 index 00000000000..f9e2ae89a9d --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-issue-20533.nll.stderr @@ -0,0 +1,33 @@ +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/variance-issue-20533.rs:38:14 + | +LL | let x = foo(&a); + | -- borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` + | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here + +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/variance-issue-20533.rs:44:14 + | +LL | let x = bar(&a); + | -- borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` + | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here + +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/variance-issue-20533.rs:50:14 + | +LL | let x = baz(&a); + | -- borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` + | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/variance-issue-20533.rs b/src/test/ui/compile-fail-migration/variance-issue-20533.rs new file mode 100644 index 00000000000..60690012485 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-issue-20533.rs @@ -0,0 +1,53 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #20533. At some point, only 1 out of the +// 3 errors below were being reported. + +use std::marker::PhantomData; + +fn foo<'a, T>(_x: &'a T) -> PhantomData<&'a ()> { + PhantomData +} + +struct Wrap(T); + +fn bar<'a, T>(_x: &'a T) -> Wrap> { + Wrap(PhantomData) +} + +struct Baked<'a>(PhantomData<&'a ()>); + +fn baz<'a, T>(_x: &'a T) -> Baked<'a> { + Baked(PhantomData) +} + +struct AffineU32(u32); + +fn main() { + { + let a = AffineU32(1); + let x = foo(&a); + drop(a); //~ ERROR cannot move out of `a` + drop(x); + } + { + let a = AffineU32(1); + let x = bar(&a); + drop(a); //~ ERROR cannot move out of `a` + drop(x); + } + { + let a = AffineU32(1); + let x = baz(&a); + drop(a); //~ ERROR cannot move out of `a` + drop(x); + } +} diff --git a/src/test/ui/compile-fail-migration/variance-issue-20533.stderr b/src/test/ui/compile-fail-migration/variance-issue-20533.stderr new file mode 100644 index 00000000000..680dea2447f --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-issue-20533.stderr @@ -0,0 +1,27 @@ +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/variance-issue-20533.rs:38:14 + | +LL | let x = foo(&a); + | - borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` + | ^ move out of `a` occurs here + +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/variance-issue-20533.rs:44:14 + | +LL | let x = bar(&a); + | - borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` + | ^ move out of `a` occurs here + +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/variance-issue-20533.rs:50:14 + | +LL | let x = baz(&a); + | - borrow of `a` occurs here +LL | drop(a); //~ ERROR cannot move out of `a` + | ^ move out of `a` occurs here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/variance-object-types.rs b/src/test/ui/compile-fail-migration/variance-object-types.rs new file mode 100644 index 00000000000..1f54771e367 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-object-types.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that Cell is considered invariant with respect to its +// type. + +#![feature(rustc_attrs)] + +use std::cell::Cell; + +// For better or worse, associated types are invariant, and hence we +// get an invariant result for `'a`. +#[rustc_variance] +struct Foo<'a> { //~ ERROR [o] + x: Box &'a i32 + 'static> +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/variance-object-types.stderr b/src/test/ui/compile-fail-migration/variance-object-types.stderr new file mode 100644 index 00000000000..9a1c9965de3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-object-types.stderr @@ -0,0 +1,11 @@ +error[E0208]: [o] + --> $DIR/variance-object-types.rs:21:1 + | +LL | / struct Foo<'a> { //~ ERROR [o] +LL | | x: Box &'a i32 + 'static> +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-regions-direct.rs b/src/test/ui/compile-fail-migration/variance-regions-direct.rs new file mode 100644 index 00000000000..cd047cc580f --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-direct.rs @@ -0,0 +1,75 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we correctly infer variance for region parameters in +// various self-contained types. + +#![feature(rustc_attrs)] + +// Regions that just appear in normal spots are contravariant: + +#[rustc_variance] +struct Test2<'a, 'b, 'c> { //~ ERROR [-, -, -] + x: &'a isize, + y: &'b [isize], + c: &'c str +} + +// Those same annotations in function arguments become covariant: + +#[rustc_variance] +struct Test3<'a, 'b, 'c> { //~ ERROR [+, +, +] + x: extern "Rust" fn(&'a isize), + y: extern "Rust" fn(&'b [isize]), + c: extern "Rust" fn(&'c str), +} + +// Mutability induces invariance: + +#[rustc_variance] +struct Test4<'a, 'b:'a> { //~ ERROR [-, o] + x: &'a mut &'b isize, +} + +// Mutability induces invariance, even when in a +// contravariant context: + +#[rustc_variance] +struct Test5<'a, 'b:'a> { //~ ERROR [+, o] + x: extern "Rust" fn(&'a mut &'b isize), +} + +// Invariance is a trap from which NO ONE CAN ESCAPE. +// In other words, even though the `&'b isize` occurs in +// an argument list (which is contravariant), that +// argument list occurs in an invariant context. + +#[rustc_variance] +struct Test6<'a, 'b:'a> { //~ ERROR [-, o] + x: &'a mut extern "Rust" fn(&'b isize), +} + +// No uses at all is bivariant: + +#[rustc_variance] +struct Test7<'a> { //~ ERROR [*] + x: isize +} + +// Try enums too. + +#[rustc_variance] +enum Test8<'a, 'b, 'c:'b> { //~ ERROR [+, -, o] + Test8A(extern "Rust" fn(&'a isize)), + Test8B(&'b [isize]), + Test8C(&'b mut &'c str), +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variance-regions-direct.stderr b/src/test/ui/compile-fail-migration/variance-regions-direct.stderr new file mode 100644 index 00000000000..81cb929c63b --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-direct.stderr @@ -0,0 +1,65 @@ +error[E0208]: [-, -, -] + --> $DIR/variance-regions-direct.rs:19:1 + | +LL | / struct Test2<'a, 'b, 'c> { //~ ERROR [-, -, -] +LL | | x: &'a isize, +LL | | y: &'b [isize], +LL | | c: &'c str +LL | | } + | |_^ + +error[E0208]: [+, +, +] + --> $DIR/variance-regions-direct.rs:28:1 + | +LL | / struct Test3<'a, 'b, 'c> { //~ ERROR [+, +, +] +LL | | x: extern "Rust" fn(&'a isize), +LL | | y: extern "Rust" fn(&'b [isize]), +LL | | c: extern "Rust" fn(&'c str), +LL | | } + | |_^ + +error[E0208]: [-, o] + --> $DIR/variance-regions-direct.rs:37:1 + | +LL | / struct Test4<'a, 'b:'a> { //~ ERROR [-, o] +LL | | x: &'a mut &'b isize, +LL | | } + | |_^ + +error[E0208]: [+, o] + --> $DIR/variance-regions-direct.rs:45:1 + | +LL | / struct Test5<'a, 'b:'a> { //~ ERROR [+, o] +LL | | x: extern "Rust" fn(&'a mut &'b isize), +LL | | } + | |_^ + +error[E0208]: [-, o] + --> $DIR/variance-regions-direct.rs:55:1 + | +LL | / struct Test6<'a, 'b:'a> { //~ ERROR [-, o] +LL | | x: &'a mut extern "Rust" fn(&'b isize), +LL | | } + | |_^ + +error[E0208]: [*] + --> $DIR/variance-regions-direct.rs:62:1 + | +LL | / struct Test7<'a> { //~ ERROR [*] +LL | | x: isize +LL | | } + | |_^ + +error[E0208]: [+, -, o] + --> $DIR/variance-regions-direct.rs:69:1 + | +LL | / enum Test8<'a, 'b, 'c:'b> { //~ ERROR [+, -, o] +LL | | Test8A(extern "Rust" fn(&'a isize)), +LL | | Test8B(&'b [isize]), +LL | | Test8C(&'b mut &'c str), +LL | | } + | |_^ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-regions-indirect.rs b/src/test/ui/compile-fail-migration/variance-regions-indirect.rs new file mode 100644 index 00000000000..60d4d73fe88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-indirect.rs @@ -0,0 +1,44 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we correctly infer variance for region parameters in +// case that involve multiple intricate types. +// Try enums too. + +#![feature(rustc_attrs)] + +#[rustc_variance] +enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR [+, -, o, *] + Test8A(extern "Rust" fn(&'a isize)), + Test8B(&'b [isize]), + Test8C(&'b mut &'c str), +} + +#[rustc_variance] +struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR [*, o, -, +] + f: Base<'z, 'y, 'x, 'w> +} + +#[rustc_variance] // Combine - and + to yield o +struct Derived2<'a, 'b:'a, 'c> { //~ ERROR [o, o, *] + f: Base<'a, 'a, 'b, 'c> +} + +#[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here) +struct Derived3<'a:'b, 'b, 'c> { //~ ERROR [o, -, *] + f: Base<'a, 'b, 'a, 'c> +} + +#[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here) +struct Derived4<'a, 'b, 'c:'b> { //~ ERROR [+, -, o] + f: Base<'a, 'b, 'c, 'a> +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variance-regions-indirect.stderr b/src/test/ui/compile-fail-migration/variance-regions-indirect.stderr new file mode 100644 index 00000000000..edf39537ff6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-indirect.stderr @@ -0,0 +1,45 @@ +error[E0208]: [+, -, o, *] + --> $DIR/variance-regions-indirect.rs:18:1 + | +LL | / enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR [+, -, o, *] +LL | | Test8A(extern "Rust" fn(&'a isize)), +LL | | Test8B(&'b [isize]), +LL | | Test8C(&'b mut &'c str), +LL | | } + | |_^ + +error[E0208]: [*, o, -, +] + --> $DIR/variance-regions-indirect.rs:25:1 + | +LL | / struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR [*, o, -, +] +LL | | f: Base<'z, 'y, 'x, 'w> +LL | | } + | |_^ + +error[E0208]: [o, o, *] + --> $DIR/variance-regions-indirect.rs:30:1 + | +LL | / struct Derived2<'a, 'b:'a, 'c> { //~ ERROR [o, o, *] +LL | | f: Base<'a, 'a, 'b, 'c> +LL | | } + | |_^ + +error[E0208]: [o, -, *] + --> $DIR/variance-regions-indirect.rs:35:1 + | +LL | / struct Derived3<'a:'b, 'b, 'c> { //~ ERROR [o, -, *] +LL | | f: Base<'a, 'b, 'a, 'c> +LL | | } + | |_^ + +error[E0208]: [+, -, o] + --> $DIR/variance-regions-indirect.rs:40:1 + | +LL | / struct Derived4<'a, 'b, 'c:'b> { //~ ERROR [+, -, o] +LL | | f: Base<'a, 'b, 'c, 'a> +LL | | } + | |_^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-regions-unused-direct.rs b/src/test/ui/compile-fail-migration/variance-regions-unused-direct.rs new file mode 100644 index 00000000000..037fff72c80 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-unused-direct.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that disallow lifetime parameters that are unused. + +use std::marker; + +struct Bivariant<'a>; //~ ERROR parameter `'a` is never used + +struct Struct<'a, 'd> { //~ ERROR parameter `'d` is never used + field: &'a [i32] +} + +trait Trait<'a, 'd> { // OK on traits + fn method(&'a self); +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variance-regions-unused-direct.stderr b/src/test/ui/compile-fail-migration/variance-regions-unused-direct.stderr new file mode 100644 index 00000000000..e3d02c649dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-unused-direct.stderr @@ -0,0 +1,19 @@ +error[E0392]: parameter `'a` is never used + --> $DIR/variance-regions-unused-direct.rs:15:18 + | +LL | struct Bivariant<'a>; //~ ERROR parameter `'a` is never used + | ^^ unused type parameter + | + = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + +error[E0392]: parameter `'d` is never used + --> $DIR/variance-regions-unused-direct.rs:17:19 + | +LL | struct Struct<'a, 'd> { //~ ERROR parameter `'d` is never used + | ^^ unused type parameter + | + = help: consider removing `'d` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/compile-fail-migration/variance-regions-unused-indirect.rs b/src/test/ui/compile-fail-migration/variance-regions-unused-indirect.rs new file mode 100644 index 00000000000..2d234ed7b57 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-unused-indirect.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that disallow lifetime parameters that are unused. + +enum Foo<'a> { //~ ERROR parameter `'a` is never used + Foo1(Bar<'a>) +} + +enum Bar<'a> { //~ ERROR parameter `'a` is never used + Bar1(Foo<'a>) +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variance-regions-unused-indirect.stderr b/src/test/ui/compile-fail-migration/variance-regions-unused-indirect.stderr new file mode 100644 index 00000000000..f3eee86d5ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-regions-unused-indirect.stderr @@ -0,0 +1,19 @@ +error[E0392]: parameter `'a` is never used + --> $DIR/variance-regions-unused-indirect.rs:13:10 + | +LL | enum Foo<'a> { //~ ERROR parameter `'a` is never used + | ^^ unused type parameter + | + = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + +error[E0392]: parameter `'a` is never used + --> $DIR/variance-regions-unused-indirect.rs:17:10 + | +LL | enum Bar<'a> { //~ ERROR parameter `'a` is never used + | ^^ unused type parameter + | + = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/compile-fail-migration/variance-trait-bounds.rs b/src/test/ui/compile-fail-migration/variance-trait-bounds.rs new file mode 100644 index 00000000000..ff446f175b7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-trait-bounds.rs @@ -0,0 +1,45 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +// Check that bounds on type parameters (other than `Self`) do not +// influence variance. + +trait Getter { + fn get(&self) -> T; +} + +trait Setter { + fn get(&self, _: T); +} + +#[rustc_variance] +struct TestStruct> { //~ ERROR [+, +] + t: T, u: U +} + +#[rustc_variance] +enum TestEnum> { //~ ERROR [*, +] + Foo(T) +} + +#[rustc_variance] +struct TestContraStruct> { //~ ERROR [*, +] + t: T +} + +#[rustc_variance] +struct TestBox+Setter> { //~ ERROR [*, +] + t: T +} + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-trait-bounds.stderr b/src/test/ui/compile-fail-migration/variance-trait-bounds.stderr new file mode 100644 index 00000000000..1c82ed772e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-trait-bounds.stderr @@ -0,0 +1,35 @@ +error[E0208]: [+, +] + --> $DIR/variance-trait-bounds.rs:26:1 + | +LL | / struct TestStruct> { //~ ERROR [+, +] +LL | | t: T, u: U +LL | | } + | |_^ + +error[E0208]: [*, +] + --> $DIR/variance-trait-bounds.rs:31:1 + | +LL | / enum TestEnum> { //~ ERROR [*, +] +LL | | Foo(T) +LL | | } + | |_^ + +error[E0208]: [*, +] + --> $DIR/variance-trait-bounds.rs:36:1 + | +LL | / struct TestContraStruct> { //~ ERROR [*, +] +LL | | t: T +LL | | } + | |_^ + +error[E0208]: [*, +] + --> $DIR/variance-trait-bounds.rs:41:1 + | +LL | / struct TestBox+Setter> { //~ ERROR [*, +] +LL | | t: T +LL | | } + | |_^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-trait-matching.nll.stderr b/src/test/ui/compile-fail-migration/variance-trait-matching.nll.stderr new file mode 100644 index 00000000000..baf75b73463 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-trait-matching.nll.stderr @@ -0,0 +1,30 @@ +warning: not reporting region error due to nll + --> $DIR/variance-trait-matching.rs:34:10 + | +LL | pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] + | ^^^ + +warning: not reporting region error due to nll + --> $DIR/variance-trait-matching.rs:34:5 + | +LL | pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] + | ^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/variance-trait-matching.rs:34:5 + | +LL | pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] + | ^^^^ + +error[E0621]: explicit lifetime required in the type of `get` + --> $DIR/variance-trait-matching.rs:34:5 + | +LL | fn get<'a, G>(get: &G) -> i32 + | -- help: add explicit lifetime `'a` to the type of `get`: `&'a G` +... +LL | pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] + | ^^^^^^^^^^^^^^ lifetime `'a` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/variance-trait-matching.rs b/src/test/ui/compile-fail-migration/variance-trait-matching.rs new file mode 100644 index 00000000000..bc9eab2be82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-trait-matching.rs @@ -0,0 +1,48 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +// Get is covariant in T +trait Get { + fn get(&self) -> T; +} + +struct Cloner { + t: T +} + +impl Get for Cloner { + fn get(&self) -> T { + self.t.clone() + } +} + +fn get<'a, G>(get: &G) -> i32 + where G : Get<&'a i32> +{ + // This fails to type-check because, without variance, we can't + // use `G : Get<&'a i32>` as evidence that `G : Get<&'b i32>`, + // even if `'a : 'b`. + pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] +} + +fn pick<'b, G>(get: &'b G, if_odd: &'b i32) -> i32 + where G : Get<&'b i32> +{ + let v = *get.get(); + if v % 2 != 0 { v } else { *if_odd } +} + +fn main() { + let x = Cloner { t: &23 }; + let y = get(&x); + assert_eq!(y, 23); +} diff --git a/src/test/ui/compile-fail-migration/variance-trait-matching.stderr b/src/test/ui/compile-fail-migration/variance-trait-matching.stderr new file mode 100644 index 00000000000..645d0ffd311 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-trait-matching.stderr @@ -0,0 +1,12 @@ +error[E0621]: explicit lifetime required in the type of `get` + --> $DIR/variance-trait-matching.rs:34:5 + | +LL | fn get<'a, G>(get: &G) -> i32 + | -- help: add explicit lifetime `'a` to the type of `get`: `&'a G` +... +LL | pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] + | ^^^^ lifetime `'a` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/variance-trait-object-bound.rs b/src/test/ui/compile-fail-migration/variance-trait-object-bound.rs new file mode 100644 index 00000000000..b120588ecab --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-trait-object-bound.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks that regions which appear in a trait object type are +// observed by the variance inference algorithm (and hence +// `TOption` is contavariant w/r/t `'a` and not bivariant). +// +// Issue #18262. + +#![feature(rustc_attrs)] + +use std::mem; + +trait T { fn foo(&self); } + +#[rustc_variance] +struct TOption<'a> { //~ ERROR [-] + v: Option>, +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-trait-object-bound.stderr b/src/test/ui/compile-fail-migration/variance-trait-object-bound.stderr new file mode 100644 index 00000000000..b44fa940ed3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-trait-object-bound.stderr @@ -0,0 +1,11 @@ +error[E0208]: [-] + --> $DIR/variance-trait-object-bound.rs:24:1 + | +LL | / struct TOption<'a> { //~ ERROR [-] +LL | | v: Option>, +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-types-bounds.rs b/src/test/ui/compile-fail-migration/variance-types-bounds.rs new file mode 100644 index 00000000000..5075dd2ceed --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-types-bounds.rs @@ -0,0 +1,53 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we correctly infer variance for type parameters in +// various types and traits. + +#![feature(rustc_attrs)] + +#[rustc_variance] +struct TestImm { //~ ERROR [+, +] + x: A, + y: B, +} + +#[rustc_variance] +struct TestMut { //~ ERROR [+, o] + x: A, + y: &'static mut B, +} + +#[rustc_variance] +struct TestIndirect { //~ ERROR [+, o] + m: TestMut +} + +#[rustc_variance] +struct TestIndirect2 { //~ ERROR [o, o] + n: TestMut, + m: TestMut +} + +trait Getter { + fn get(&self) -> A; +} + +trait Setter { + fn set(&mut self, a: A); +} + +#[rustc_variance] +struct TestObject { //~ ERROR [o, o] + n: Box+Send>, + m: Box+Send>, +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variance-types-bounds.stderr b/src/test/ui/compile-fail-migration/variance-types-bounds.stderr new file mode 100644 index 00000000000..e4b0887912b --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-types-bounds.stderr @@ -0,0 +1,47 @@ +error[E0208]: [+, +] + --> $DIR/variance-types-bounds.rs:17:1 + | +LL | / struct TestImm { //~ ERROR [+, +] +LL | | x: A, +LL | | y: B, +LL | | } + | |_^ + +error[E0208]: [+, o] + --> $DIR/variance-types-bounds.rs:23:1 + | +LL | / struct TestMut { //~ ERROR [+, o] +LL | | x: A, +LL | | y: &'static mut B, +LL | | } + | |_^ + +error[E0208]: [+, o] + --> $DIR/variance-types-bounds.rs:29:1 + | +LL | / struct TestIndirect { //~ ERROR [+, o] +LL | | m: TestMut +LL | | } + | |_^ + +error[E0208]: [o, o] + --> $DIR/variance-types-bounds.rs:34:1 + | +LL | / struct TestIndirect2 { //~ ERROR [o, o] +LL | | n: TestMut, +LL | | m: TestMut +LL | | } + | |_^ + +error[E0208]: [o, o] + --> $DIR/variance-types-bounds.rs:48:1 + | +LL | / struct TestObject { //~ ERROR [o, o] +LL | | n: Box+Send>, +LL | | m: Box+Send>, +LL | | } + | |_^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-types.rs b/src/test/ui/compile-fail-migration/variance-types.rs new file mode 100644 index 00000000000..7667972c9d2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-types.rs @@ -0,0 +1,51 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +use std::cell::Cell; + +// Check that a type parameter which is only used in a trait bound is +// not considered bivariant. + +#[rustc_variance] +struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR [-, o, o] + t: &'a mut (A,B) +} + +#[rustc_variance] +struct InvariantCell { //~ ERROR [o] + t: Cell +} + +#[rustc_variance] +struct InvariantIndirect { //~ ERROR [o] + t: InvariantCell +} + +#[rustc_variance] +struct Covariant { //~ ERROR [+] + t: A, u: fn() -> A +} + +#[rustc_variance] +struct Contravariant { //~ ERROR [-] + t: fn(A) +} + +#[rustc_variance] +enum Enum { //~ ERROR [+, -, o] + Foo(Covariant), + Bar(Contravariant), + Zed(Covariant,Contravariant) +} + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-types.stderr b/src/test/ui/compile-fail-migration/variance-types.stderr new file mode 100644 index 00000000000..59975fa7a7e --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-types.stderr @@ -0,0 +1,53 @@ +error[E0208]: [-, o, o] + --> $DIR/variance-types.rs:20:1 + | +LL | / struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR [-, o, o] +LL | | t: &'a mut (A,B) +LL | | } + | |_^ + +error[E0208]: [o] + --> $DIR/variance-types.rs:25:1 + | +LL | / struct InvariantCell { //~ ERROR [o] +LL | | t: Cell +LL | | } + | |_^ + +error[E0208]: [o] + --> $DIR/variance-types.rs:30:1 + | +LL | / struct InvariantIndirect { //~ ERROR [o] +LL | | t: InvariantCell +LL | | } + | |_^ + +error[E0208]: [+] + --> $DIR/variance-types.rs:35:1 + | +LL | / struct Covariant { //~ ERROR [+] +LL | | t: A, u: fn() -> A +LL | | } + | |_^ + +error[E0208]: [-] + --> $DIR/variance-types.rs:40:1 + | +LL | / struct Contravariant { //~ ERROR [-] +LL | | t: fn(A) +LL | | } + | |_^ + +error[E0208]: [+, -, o] + --> $DIR/variance-types.rs:45:1 + | +LL | / enum Enum { //~ ERROR [+, -, o] +LL | | Foo(Covariant), +LL | | Bar(Contravariant), +LL | | Zed(Covariant,Contravariant) +LL | | } + | |_^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0208`. diff --git a/src/test/ui/compile-fail-migration/variance-unused-region-param.rs b/src/test/ui/compile-fail-migration/variance-unused-region-param.rs new file mode 100644 index 00000000000..407282e5ce0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-unused-region-param.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we report an error for unused type parameters in types. + +struct SomeStruct<'a> { x: u32 } //~ ERROR parameter `'a` is never used +enum SomeEnum<'a> { Nothing } //~ ERROR parameter `'a` is never used +trait SomeTrait<'a> { fn foo(&self); } // OK on traits. + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variance-unused-region-param.stderr b/src/test/ui/compile-fail-migration/variance-unused-region-param.stderr new file mode 100644 index 00000000000..354fcf373a6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-unused-region-param.stderr @@ -0,0 +1,19 @@ +error[E0392]: parameter `'a` is never used + --> $DIR/variance-unused-region-param.rs:13:19 + | +LL | struct SomeStruct<'a> { x: u32 } //~ ERROR parameter `'a` is never used + | ^^ unused type parameter + | + = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + +error[E0392]: parameter `'a` is never used + --> $DIR/variance-unused-region-param.rs:14:15 + | +LL | enum SomeEnum<'a> { Nothing } //~ ERROR parameter `'a` is never used + | ^^ unused type parameter + | + = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.nll.stderr b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.nll.stderr new file mode 100644 index 00000000000..5189945982d --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.nll.stderr @@ -0,0 +1,19 @@ +warning: not reporting region error due to nll + --> $DIR/variance-use-contravariant-struct-1.rs:22:5 + | +LL | v //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/variance-use-contravariant-struct-1.rs:22:5 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ return requires that `'min` must outlive `'max` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.rs b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.rs new file mode 100644 index 00000000000..d2fd2978750 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test various uses of structs with distint variances to make sure +// they permit lifetimes to be approximated as expected. + +#![feature(rustc_attrs)] + +struct SomeStruct(fn(T)); + +fn foo<'min,'max>(v: SomeStruct<&'max ()>) + -> SomeStruct<&'min ()> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.stderr b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.stderr new file mode 100644 index 00000000000..48e0d380c66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-1.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/variance-use-contravariant-struct-1.rs:22:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `SomeStruct<&'min ()>` + found type `SomeStruct<&'max ()>` +note: the lifetime 'min as defined on the function body at 18:8... + --> $DIR/variance-use-contravariant-struct-1.rs:18:8 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 18:13 + --> $DIR/variance-use-contravariant-struct-1.rs:18:13 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.rs b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.rs new file mode 100644 index 00000000000..b38fd0e9ffc --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test various uses of structs with distint variances to make sure +// they permit lifetimes to be approximated as expected. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +struct SomeStruct(fn(T)); + +fn bar<'min,'max>(v: SomeStruct<&'min ()>) + -> SomeStruct<&'max ()> + where 'max : 'min +{ + v +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.stderr b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.stderr new file mode 100644 index 00000000000..e3663eb0345 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-contravariant-struct-2.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/variance-use-contravariant-struct-2.rs:27:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.nll.stderr b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.nll.stderr new file mode 100644 index 00000000000..8c47513a587 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.nll.stderr @@ -0,0 +1,19 @@ +warning: not reporting region error due to nll + --> $DIR/variance-use-covariant-struct-1.rs:20:5 + | +LL | v //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/variance-use-covariant-struct-1.rs:20:5 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'min ()>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ return requires that `'min` must outlive `'max` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.rs b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.rs new file mode 100644 index 00000000000..2631cfc05e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a covariant struct does not permit the lifetime of a +// reference to be enlarged. + +struct SomeStruct(T); + +fn foo<'min,'max>(v: SomeStruct<&'min ()>) + -> SomeStruct<&'max ()> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.stderr b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.stderr new file mode 100644 index 00000000000..947abe24b55 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-1.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/variance-use-covariant-struct-1.rs:20:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `SomeStruct<&'max ()>` + found type `SomeStruct<&'min ()>` +note: the lifetime 'min as defined on the function body at 16:8... + --> $DIR/variance-use-covariant-struct-1.rs:16:8 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'min ()>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 16:13 + --> $DIR/variance-use-covariant-struct-1.rs:16:13 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'min ()>) + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.rs b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.rs new file mode 100644 index 00000000000..d8e1a5f5f1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a covariant struct permits the lifetime of a reference to +// be shortened. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +struct SomeStruct(T); + +fn foo<'min,'max>(v: SomeStruct<&'max ()>) + -> SomeStruct<&'min ()> + where 'max : 'min +{ + v +} + +#[rustc_error] fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.stderr b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.stderr new file mode 100644 index 00000000000..9c3a1cf1cc2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-covariant-struct-2.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/variance-use-covariant-struct-2.rs:26:16 + | +LL | #[rustc_error] fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.nll.stderr b/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.nll.stderr new file mode 100644 index 00000000000..6553efdbd62 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.nll.stderr @@ -0,0 +1,36 @@ +warning: not reporting region error due to nll + --> $DIR/variance-use-invariant-struct-1.rs:22:5 + | +LL | v //~ ERROR mismatched types + | ^ + +warning: not reporting region error due to nll + --> $DIR/variance-use-invariant-struct-1.rs:29:5 + | +LL | v //~ ERROR mismatched types + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/variance-use-invariant-struct-1.rs:22:5 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ return requires that `'min` must outlive `'max` + +error: unsatisfied lifetime constraints + --> $DIR/variance-use-invariant-struct-1.rs:29:5 + | +LL | fn bar<'min,'max>(v: SomeStruct<&'min ()>) + | ---- ---- lifetime `'max` defined here + | | + | lifetime `'min` defined here +... +LL | v //~ ERROR mismatched types + | ^ return requires that `'min` must outlive `'max` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.rs b/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.rs new file mode 100644 index 00000000000..c89436b2094 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test various uses of structs with distint variances to make sure +// they permit lifetimes to be approximated as expected. + +#![feature(rustc_attrs)] + +struct SomeStruct(*mut T); + +fn foo<'min,'max>(v: SomeStruct<&'max ()>) + -> SomeStruct<&'min ()> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +fn bar<'min,'max>(v: SomeStruct<&'min ()>) + -> SomeStruct<&'max ()> + where 'max : 'min +{ + v //~ ERROR mismatched types +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.stderr b/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.stderr new file mode 100644 index 00000000000..30da7e38c57 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variance-use-invariant-struct-1.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/variance-use-invariant-struct-1.rs:22:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `SomeStruct<&'min ()>` + found type `SomeStruct<&'max ()>` +note: the lifetime 'min as defined on the function body at 18:8... + --> $DIR/variance-use-invariant-struct-1.rs:18:8 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 18:13 + --> $DIR/variance-use-invariant-struct-1.rs:18:13 + | +LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/variance-use-invariant-struct-1.rs:29:5 + | +LL | v //~ ERROR mismatched types + | ^ lifetime mismatch + | + = note: expected type `SomeStruct<&'max ()>` + found type `SomeStruct<&'min ()>` +note: the lifetime 'min as defined on the function body at 25:8... + --> $DIR/variance-use-invariant-struct-1.rs:25:8 + | +LL | fn bar<'min,'max>(v: SomeStruct<&'min ()>) + | ^^^^ +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 25:13 + --> $DIR/variance-use-invariant-struct-1.rs:25:13 + | +LL | fn bar<'min,'max>(v: SomeStruct<&'min ()>) + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/variant-namespacing.rs b/src/test/ui/compile-fail-migration/variant-namespacing.rs new file mode 100644 index 00000000000..58bfd91550e --- /dev/null +++ b/src/test/ui/compile-fail-migration/variant-namespacing.rs @@ -0,0 +1,43 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:variant-namespacing.rs + +enum E { + Struct { a: u8 }, + Tuple(u8), + Unit, +} + +type Struct = u8; +type Tuple = u8; +type Unit = u8; +type XStruct = u8; +type XTuple = u8; +type XUnit = u8; + +const Struct: u8 = 0; +const Tuple: u8 = 0; +const Unit: u8 = 0; +const XStruct: u8 = 0; +const XTuple: u8 = 0; +const XUnit: u8 = 0; + +extern crate variant_namespacing; +pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; +//~^ ERROR the name `XStruct` is defined multiple times +//~| ERROR the name `XTuple` is defined multiple times +//~| ERROR the name `XUnit` is defined multiple times +pub use E::{Struct, Tuple, Unit}; +//~^ ERROR the name `Struct` is defined multiple times +//~| ERROR the name `Tuple` is defined multiple times +//~| ERROR the name `Unit` is defined multiple times + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variant-namespacing.stderr b/src/test/ui/compile-fail-migration/variant-namespacing.stderr new file mode 100644 index 00000000000..322ea617f34 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variant-namespacing.stderr @@ -0,0 +1,93 @@ +error[E0255]: the name `XStruct` is defined multiple times + --> $DIR/variant-namespacing.rs:34:35 + | +LL | type XStruct = u8; + | ------------------ previous definition of the type `XStruct` here +... +LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; + | ^^^^^^^ `XStruct` reimported here + | + = note: `XStruct` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | pub use variant_namespacing::XE::{XStruct as OtherXStruct, XTuple, XUnit}; + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0255]: the name `XTuple` is defined multiple times + --> $DIR/variant-namespacing.rs:34:44 + | +LL | type XTuple = u8; + | ----------------- previous definition of the type `XTuple` here +... +LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; + | ^^^^^^ `XTuple` reimported here + | + = note: `XTuple` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | pub use variant_namespacing::XE::{XStruct, XTuple as OtherXTuple, XUnit}; + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0255]: the name `XUnit` is defined multiple times + --> $DIR/variant-namespacing.rs:34:52 + | +LL | type XUnit = u8; + | ---------------- previous definition of the type `XUnit` here +... +LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; + | ^^^^^ `XUnit` reimported here + | + = note: `XUnit` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit as OtherXUnit}; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0255]: the name `Struct` is defined multiple times + --> $DIR/variant-namespacing.rs:38:13 + | +LL | type Struct = u8; + | ----------------- previous definition of the type `Struct` here +... +LL | pub use E::{Struct, Tuple, Unit}; + | ^^^^^^ `Struct` reimported here + | + = note: `Struct` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | pub use E::{Struct as OtherStruct, Tuple, Unit}; + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0255]: the name `Tuple` is defined multiple times + --> $DIR/variant-namespacing.rs:38:21 + | +LL | type Tuple = u8; + | ---------------- previous definition of the type `Tuple` here +... +LL | pub use E::{Struct, Tuple, Unit}; + | ^^^^^ `Tuple` reimported here + | + = note: `Tuple` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | pub use E::{Struct, Tuple as OtherTuple, Unit}; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0255]: the name `Unit` is defined multiple times + --> $DIR/variant-namespacing.rs:38:28 + | +LL | type Unit = u8; + | --------------- previous definition of the type `Unit` here +... +LL | pub use E::{Struct, Tuple, Unit}; + | ^^^^ `Unit` reimported here + | + = note: `Unit` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | pub use E::{Struct, Tuple, Unit as OtherUnit}; + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0255`. diff --git a/src/test/ui/compile-fail-migration/variant-size-differences.rs b/src/test/ui/compile-fail-migration/variant-size-differences.rs new file mode 100644 index 00000000000..f2cffeefe90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variant-size-differences.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(variant_size_differences)] + +enum _En { + V0(u8), + VBig([u8; 1024]), //~ ERROR variant is more than three times larger +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variant-size-differences.stderr b/src/test/ui/compile-fail-migration/variant-size-differences.stderr new file mode 100644 index 00000000000..a41a5c17ea3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variant-size-differences.stderr @@ -0,0 +1,14 @@ +error: enum variant is more than three times larger (1024 bytes) than the next largest + --> $DIR/variant-size-differences.rs:15:5 + | +LL | VBig([u8; 1024]), //~ ERROR variant is more than three times larger + | ^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/variant-size-differences.rs:11:9 + | +LL | #![deny(variant_size_differences)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/variant-used-as-type.rs b/src/test/ui/compile-fail-migration/variant-used-as-type.rs new file mode 100644 index 00000000000..c889b7d28f8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variant-used-as-type.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test error message when enum variants are used as types + + +// issue 21225 +enum Ty { + A, + B(Ty::A), + //~^ ERROR expected type, found variant `Ty::A` +} + + +// issue 19197 +enum E { + A +} + +impl E::A {} +//~^ ERROR expected type, found variant `E::A` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/variant-used-as-type.stderr b/src/test/ui/compile-fail-migration/variant-used-as-type.stderr new file mode 100644 index 00000000000..972fe8a8a61 --- /dev/null +++ b/src/test/ui/compile-fail-migration/variant-used-as-type.stderr @@ -0,0 +1,31 @@ +error[E0573]: expected type, found variant `Ty::A` + --> $DIR/variant-used-as-type.rs:17:7 + | +LL | B(Ty::A), + | ^^^^^ not a type +help: you can try using the variant's enum + | +LL | B(Ty), + | ^^ +help: you can try using the variant's enum + | +LL | B(E), + | ^ + +error[E0573]: expected type, found variant `E::A` + --> $DIR/variant-used-as-type.rs:27:6 + | +LL | impl E::A {} + | ^^^^ not a type +help: you can try using the variant's enum + | +LL | impl Ty {} + | ^^ +help: you can try using the variant's enum + | +LL | impl E {} + | ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0573`. diff --git a/src/test/ui/compile-fail-migration/vec-macro-with-comma-only.rs b/src/test/ui/compile-fail-migration/vec-macro-with-comma-only.rs new file mode 100644 index 00000000000..c79e67a3768 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vec-macro-with-comma-only.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + vec![,]; //~ ERROR no rules expected the token `,` +} diff --git a/src/test/ui/compile-fail-migration/vec-macro-with-comma-only.stderr b/src/test/ui/compile-fail-migration/vec-macro-with-comma-only.stderr new file mode 100644 index 00000000000..f5341ccc312 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vec-macro-with-comma-only.stderr @@ -0,0 +1,8 @@ +error: no rules expected the token `,` + --> $DIR/vec-macro-with-comma-only.rs:12:10 + | +LL | vec![,]; //~ ERROR no rules expected the token `,` + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.nll.stderr b/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.nll.stderr new file mode 100644 index 00000000000..fd7843f39bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.nll.stderr @@ -0,0 +1,14 @@ +error[E0499]: cannot borrow `xs` as mutable more than once at a time + --> $DIR/vec-mut-iter-borrow.rs:15:9 + | +LL | for x in &mut xs { + | ------- + | | + | first mutable borrow occurs here + | borrow used here in later iteration of loop +LL | xs.push(1) //~ ERROR cannot borrow `xs` + | ^^ second mutable borrow occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.rs b/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.rs new file mode 100644 index 00000000000..571634e3992 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let mut xs: Vec = vec![]; + + for x in &mut xs { + xs.push(1) //~ ERROR cannot borrow `xs` + } +} diff --git a/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.stderr b/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.stderr new file mode 100644 index 00000000000..18fdf2c6867 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vec-mut-iter-borrow.stderr @@ -0,0 +1,14 @@ +error[E0499]: cannot borrow `xs` as mutable more than once at a time + --> $DIR/vec-mut-iter-borrow.rs:15:9 + | +LL | for x in &mut xs { + | -- + | || + | |first borrow ends here + | first mutable borrow occurs here +LL | xs.push(1) //~ ERROR cannot borrow `xs` + | ^^ second mutable borrow occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/vec-res-add.rs b/src/test/ui/compile-fail-migration/vec-res-add.rs new file mode 100644 index 00000000000..27f6fc51164 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vec-res-add.rs @@ -0,0 +1,29 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +struct r { + i:isize +} + +fn r(i:isize) -> r { r { i: i } } + +impl Drop for r { + fn drop(&mut self) {} +} + +fn main() { + // This can't make sense as it would copy the classes + let i = vec![r(0)]; + let j = vec![r(1)]; + let k = i + j; + //~^ ERROR binary operation `+` cannot be applied to type + println!("{:?}", j); +} diff --git a/src/test/ui/compile-fail-migration/vec-res-add.stderr b/src/test/ui/compile-fail-migration/vec-res-add.stderr new file mode 100644 index 00000000000..62d3f046c96 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vec-res-add.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `+` cannot be applied to type `std::vec::Vec` + --> $DIR/vec-res-add.rs:26:13 + | +LL | let k = i + j; + | ^^^^^ + | + = note: an implementation of `std::ops::Add` might be missing for `std::vec::Vec` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/vector-cast-weirdness.rs b/src/test/ui/compile-fail-migration/vector-cast-weirdness.rs new file mode 100644 index 00000000000..26c59c440d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vector-cast-weirdness.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #14893. Tests that casts from vectors don't behave strangely in the +// presence of the `_` type shorthand notation. +// Update: after a change to the way casts are done, we have more type information +// around and so the errors here are no longer exactly the same. + +struct X { + y: [u8; 2], +} + +fn main() { + let x1 = X { y: [0, 0] }; + + // No longer a type mismatch - the `_` can be fully resolved by type inference. + let p1: *const u8 = &x1.y as *const _; + let t1: *const [u8; 2] = &x1.y as *const _; + let h1: *const [u8; 2] = &x1.y as *const [u8; 2]; + + let mut x1 = X { y: [0, 0] }; + + // This is still an error since we don't allow casts from &mut [T; n] to *mut T. + let p1: *mut u8 = &mut x1.y as *mut _; //~ ERROR casting + let t1: *mut [u8; 2] = &mut x1.y as *mut _; + let h1: *mut [u8; 2] = &mut x1.y as *mut [u8; 2]; +} diff --git a/src/test/ui/compile-fail-migration/vector-cast-weirdness.stderr b/src/test/ui/compile-fail-migration/vector-cast-weirdness.stderr new file mode 100644 index 00000000000..a096fee16b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vector-cast-weirdness.stderr @@ -0,0 +1,9 @@ +error[E0606]: casting `&mut [u8; 2]` as `*mut u8` is invalid + --> $DIR/vector-cast-weirdness.rs:31:23 + | +LL | let p1: *mut u8 = &mut x1.y as *mut _; //~ ERROR casting + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/compile-fail-migration/vtable-res-trait-param.rs b/src/test/ui/compile-fail-migration/vtable-res-trait-param.rs new file mode 100644 index 00000000000..8b3e9369ece --- /dev/null +++ b/src/test/ui/compile-fail-migration/vtable-res-trait-param.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait TraitA { + fn method_a(&self) -> isize; +} + +trait TraitB { + fn gimme_an_a(&self, a: A) -> isize; +} + +impl TraitB for isize { + fn gimme_an_a(&self, a: A) -> isize { + a.method_a() + *self + } +} + +fn call_it(b: B) -> isize { + let y = 4; + b.gimme_an_a(y) //~ ERROR `{integer}: TraitA` is not satisfied +} + +fn main() { + let x = 3; + assert_eq!(call_it(x), 22); +} diff --git a/src/test/ui/compile-fail-migration/vtable-res-trait-param.stderr b/src/test/ui/compile-fail-migration/vtable-res-trait-param.stderr new file mode 100644 index 00000000000..0d0e8202623 --- /dev/null +++ b/src/test/ui/compile-fail-migration/vtable-res-trait-param.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `{integer}: TraitA` is not satisfied + --> $DIR/vtable-res-trait-param.rs:27:7 + | +LL | b.gimme_an_a(y) //~ ERROR `{integer}: TraitA` is not satisfied + | ^^^^^^^^^^ the trait `TraitA` is not implemented for `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/walk-struct-literal-with.nll.stderr b/src/test/ui/compile-fail-migration/walk-struct-literal-with.nll.stderr new file mode 100644 index 00000000000..668473882ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/walk-struct-literal-with.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: borrow of moved value: `start.test` + --> $DIR/walk-struct-literal-with.rs:26:20 + | +LL | let end = Mine{other_val:1, ..start.make_string_bar()}; + | ----- value moved here +LL | println!("{}", start.test); //~ ERROR use of moved value: `start.test` + | ^^^^^^^^^^ value borrowed here after move + | + = note: move occurs because `start` has type `Mine`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/walk-struct-literal-with.rs b/src/test/ui/compile-fail-migration/walk-struct-literal-with.rs new file mode 100644 index 00000000000..10503084b9d --- /dev/null +++ b/src/test/ui/compile-fail-migration/walk-struct-literal-with.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Mine{ + test: String, + other_val: isize +} + +impl Mine{ + fn make_string_bar(mut self) -> Mine{ + self.test = "Bar".to_string(); + self + } +} + +fn main(){ + let start = Mine{test:"Foo".to_string(), other_val:0}; + let end = Mine{other_val:1, ..start.make_string_bar()}; + println!("{}", start.test); //~ ERROR use of moved value: `start.test` +} diff --git a/src/test/ui/compile-fail-migration/walk-struct-literal-with.stderr b/src/test/ui/compile-fail-migration/walk-struct-literal-with.stderr new file mode 100644 index 00000000000..751e41f5ce9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/walk-struct-literal-with.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `start.test` + --> $DIR/walk-struct-literal-with.rs:26:20 + | +LL | let end = Mine{other_val:1, ..start.make_string_bar()}; + | ----- value moved here +LL | println!("{}", start.test); //~ ERROR use of moved value: `start.test` + | ^^^^^^^^^^ value used here after move + | + = note: move occurs because `start` has type `Mine`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/warn-path-statement.rs b/src/test/ui/compile-fail-migration/warn-path-statement.rs new file mode 100644 index 00000000000..892d82d0934 --- /dev/null +++ b/src/test/ui/compile-fail-migration/warn-path-statement.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -D path-statements +fn main() { + + let x = 10; + x; //~ ERROR path statement with no effect +} diff --git a/src/test/ui/compile-fail-migration/warn-path-statement.stderr b/src/test/ui/compile-fail-migration/warn-path-statement.stderr new file mode 100644 index 00000000000..44b194bc62d --- /dev/null +++ b/src/test/ui/compile-fail-migration/warn-path-statement.stderr @@ -0,0 +1,10 @@ +error: path statement with no effect + --> $DIR/warn-path-statement.rs:15:5 + | +LL | x; //~ ERROR path statement with no effect + | ^^ + | + = note: requested on the command line with `-D path-statements` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/weak-lang-item.rs b/src/test/ui/compile-fail-migration/weak-lang-item.rs new file mode 100644 index 00000000000..42972c40674 --- /dev/null +++ b/src/test/ui/compile-fail-migration/weak-lang-item.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:weak-lang-items.rs +// error-pattern: `#[panic_implementation]` function required, but not found +// error-pattern: language item required, but not found: `eh_personality` +// ignore-wasm32-bare compiled with panic=abort, personality not required + +#![no_std] + +extern crate core; +extern crate weak_lang_items; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/weak-lang-item.stderr b/src/test/ui/compile-fail-migration/weak-lang-item.stderr new file mode 100644 index 00000000000..e85b777b203 --- /dev/null +++ b/src/test/ui/compile-fail-migration/weak-lang-item.stderr @@ -0,0 +1,19 @@ +error[E0259]: the name `core` is defined multiple times + --> $DIR/weak-lang-item.rs:18:1 + | +LL | extern crate core; + | ^^^^^^^^^^^^^^^^^^ `core` reimported here + | + = note: `core` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +LL | extern crate core as other_core; + | + +error: `#[panic_implementation]` function required, but not found + +error: language item required, but not found: `eh_personality` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0259`. diff --git a/src/test/ui/compile-fail-migration/wf-array-elem-sized.rs b/src/test/ui/compile-fail-migration/wf-array-elem-sized.rs new file mode 100644 index 00000000000..946341a1a75 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-array-elem-sized.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that array elemen types must be Sized. Issue #25692. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct Foo { + foo: [[u8]], //~ ERROR E0277 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-array-elem-sized.stderr b/src/test/ui/compile-fail-migration/wf-array-elem-sized.stderr new file mode 100644 index 00000000000..dc1391469e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-array-elem-sized.stderr @@ -0,0 +1,13 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-array-elem-sized.rs:17:5 + | +LL | foo: [[u8]], //~ ERROR E0277 + | ^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `[u8]` + = note: to learn more, visit + = note: slice and array elements must have `Sized` type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-const-type.rs b/src/test/ui/compile-fail-migration/wf-const-type.rs new file mode 100644 index 00000000000..c3015afd8dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-const-type.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check the types of constants are well-formed. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct IsCopy { t: T } +struct NotCopy; + +const FOO: IsCopy> = IsCopy { t: None }; +//~^ ERROR E0277 + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-const-type.stderr b/src/test/ui/compile-fail-migration/wf-const-type.stderr new file mode 100644 index 00000000000..1c07824ef77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-const-type.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied + --> $DIR/wf-const-type.rs:20:1 + | +LL | const FOO: IsCopy> = IsCopy { t: None }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` + | + = note: required because of the requirements on the impl of `std::marker::Copy` for `std::option::Option` +note: required by `IsCopy` + --> $DIR/wf-const-type.rs:17:1 + | +LL | struct IsCopy { t: T } + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-enum-bound.rs b/src/test/ui/compile-fail-migration/wf-enum-bound.rs new file mode 100644 index 00000000000..e3e79fdd940 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-enum-bound.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check enum bounds for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +enum SomeEnum //~ ERROR E0277 + where T: ExtraCopy +{ + SomeVariant(T,U) +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-enum-bound.stderr b/src/test/ui/compile-fail-migration/wf-enum-bound.stderr new file mode 100644 index 00000000000..3313eb20508 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-enum-bound.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied + --> $DIR/wf-enum-bound.rs:19:1 + | +LL | / enum SomeEnum //~ ERROR E0277 +LL | | where T: ExtraCopy +LL | | { +LL | | SomeVariant(T,U) +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `U` + | + = help: consider adding a `where U: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-enum-bound.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.rs b/src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.rs new file mode 100644 index 00000000000..5eb53e7edde --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check struct fields for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct IsCopy { + value: T +} + +enum AnotherEnum { + AnotherVariant { + f: IsCopy //~ ERROR E0277 + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.stderr b/src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.stderr new file mode 100644 index 00000000000..86a605f073c --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-enum-fields-struct-variant.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied + --> $DIR/wf-enum-fields-struct-variant.rs:23:9 + | +LL | f: IsCopy //~ ERROR E0277 + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` + | + = help: consider adding a `where A: std::marker::Copy` bound +note: required by `IsCopy` + --> $DIR/wf-enum-fields-struct-variant.rs:17:1 + | +LL | struct IsCopy { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-enum-fields.rs b/src/test/ui/compile-fail-migration/wf-enum-fields.rs new file mode 100644 index 00000000000..76ad40f8457 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-enum-fields.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check struct fields for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct IsCopy { + value: T +} + +enum SomeEnum { + SomeVariant(IsCopy) //~ ERROR E0277 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-enum-fields.stderr b/src/test/ui/compile-fail-migration/wf-enum-fields.stderr new file mode 100644 index 00000000000..5aa263f389a --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-enum-fields.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied + --> $DIR/wf-enum-fields.rs:22:17 + | +LL | SomeVariant(IsCopy) //~ ERROR E0277 + | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` + | + = help: consider adding a `where A: std::marker::Copy` bound +note: required by `IsCopy` + --> $DIR/wf-enum-fields.rs:17:1 + | +LL | struct IsCopy { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-fn-where-clause.rs b/src/test/ui/compile-fail-migration/wf-fn-where-clause.rs new file mode 100644 index 00000000000..3ed9e5d9f1e --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-fn-where-clause.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check where-clauses on fn items. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +fn foo() where T: ExtraCopy //~ ERROR E0277 +{ +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-fn-where-clause.stderr b/src/test/ui/compile-fail-migration/wf-fn-where-clause.stderr new file mode 100644 index 00000000000..5f0f982577e --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-fn-where-clause.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied + --> $DIR/wf-fn-where-clause.rs:19:1 + | +LL | / fn foo() where T: ExtraCopy //~ ERROR E0277 +LL | | { +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `U` + | + = help: consider adding a `where U: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-fn-where-clause.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-impl-associated-type-region.rs b/src/test/ui/compile-fail-migration/wf-impl-associated-type-region.rs new file mode 100644 index 00000000000..a319b676eeb --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-impl-associated-type-region.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we require that associated types in an impl are well-formed. + +#![feature(rustc_attrs)] + +pub trait Foo<'a> { + type Bar; +} + +impl<'a, T> Foo<'a> for T { + type Bar = &'a T; //~ ERROR E0309 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-impl-associated-type-region.stderr b/src/test/ui/compile-fail-migration/wf-impl-associated-type-region.stderr new file mode 100644 index 00000000000..f238b3c0d13 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-impl-associated-type-region.stderr @@ -0,0 +1,17 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/wf-impl-associated-type-region.rs:20:5 + | +LL | impl<'a, T> Foo<'a> for T { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Bar = &'a T; //~ ERROR E0309 + | ^^^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/wf-impl-associated-type-region.rs:20:5 + | +LL | type Bar = &'a T; //~ ERROR E0309 + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.rs b/src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.rs new file mode 100644 index 00000000000..1e82f609d2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we require that associated types in an impl are well-formed. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +pub trait MyHash { } + +pub struct MySet { + data: Vec +} + +pub trait Foo { + type Bar; +} + +impl Foo for T { + type Bar = MySet; + //~^ ERROR the trait bound `T: MyHash` is not satisfied +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.stderr b/src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.stderr new file mode 100644 index 00000000000..595c5b4d8fd --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-impl-associated-type-trait.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `T: MyHash` is not satisfied + --> $DIR/wf-impl-associated-type-trait.rs:27:5 + | +LL | type Bar = MySet; + | ^^^^^^^^^^^^^^^^^^^^ the trait `MyHash` is not implemented for `T` + | + = help: consider adding a `where T: MyHash` bound +note: required by `MySet` + --> $DIR/wf-impl-associated-type-trait.rs:18:1 + | +LL | pub struct MySet { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-arg.rs b/src/test/ui/compile-fail-migration/wf-in-fn-arg.rs new file mode 100644 index 00000000000..e302cac0006 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-arg.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions also for argument types in fn items. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct MustBeCopy { + t: T +} + +fn bar(_: &MustBeCopy) //~ ERROR E0277 +{ +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-arg.stderr b/src/test/ui/compile-fail-migration/wf-in-fn-arg.stderr new file mode 100644 index 00000000000..f82bc1674df --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-arg.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/wf-in-fn-arg.rs:20:1 + | +LL | / fn bar(_: &MustBeCopy) //~ ERROR E0277 +LL | | { +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `MustBeCopy` + --> $DIR/wf-in-fn-arg.rs:16:1 + | +LL | struct MustBeCopy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-ret.rs b/src/test/ui/compile-fail-migration/wf-in-fn-ret.rs new file mode 100644 index 00000000000..719bc9282ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-ret.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions also for return types in fn items. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct MustBeCopy { + t: T +} + +fn bar() -> MustBeCopy //~ ERROR E0277 +{ +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-ret.stderr b/src/test/ui/compile-fail-migration/wf-in-fn-ret.stderr new file mode 100644 index 00000000000..357199c4e31 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-ret.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/wf-in-fn-ret.rs:20:1 + | +LL | / fn bar() -> MustBeCopy //~ ERROR E0277 +LL | | { +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `MustBeCopy` + --> $DIR/wf-in-fn-ret.rs:16:1 + | +LL | struct MustBeCopy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-type-arg.rs b/src/test/ui/compile-fail-migration/wf-in-fn-type-arg.rs new file mode 100644 index 00000000000..08ee0e954ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-type-arg.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions also for types in fns. + +struct MustBeCopy { + t: T +} + +struct Bar { + // needs T: Copy + x: fn(MustBeCopy) //~ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-type-arg.stderr b/src/test/ui/compile-fail-migration/wf-in-fn-type-arg.stderr new file mode 100644 index 00000000000..7e3d22b262c --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-type-arg.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/wf-in-fn-type-arg.rs:19:5 + | +LL | x: fn(MustBeCopy) //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `MustBeCopy` + --> $DIR/wf-in-fn-type-arg.rs:13:1 + | +LL | struct MustBeCopy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-type-ret.rs b/src/test/ui/compile-fail-migration/wf-in-fn-type-ret.rs new file mode 100644 index 00000000000..6942f786060 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-type-ret.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions also for types in fns. + +struct MustBeCopy { + t: T +} + +struct Foo { + // needs T: 'static + x: fn() -> MustBeCopy //~ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-type-ret.stderr b/src/test/ui/compile-fail-migration/wf-in-fn-type-ret.stderr new file mode 100644 index 00000000000..5d592532d28 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-type-ret.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/wf-in-fn-type-ret.rs:19:5 + | +LL | x: fn() -> MustBeCopy //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `MustBeCopy` + --> $DIR/wf-in-fn-type-ret.rs:13:1 + | +LL | struct MustBeCopy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-type-static.rs b/src/test/ui/compile-fail-migration/wf-in-fn-type-static.rs new file mode 100644 index 00000000000..8e3bca09758 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-type-static.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions related to regions also for +// types in fns. + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +struct MustBeCopy { + t: T +} + +struct Foo { + // needs T: 'static + x: fn() -> &'static T //~ ERROR E0310 +} + +struct Bar { + // needs T: Copy + x: fn(&'static T) //~ ERROR E0310 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-type-static.stderr b/src/test/ui/compile-fail-migration/wf-in-fn-type-static.stderr new file mode 100644 index 00000000000..0013331f010 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-type-static.stderr @@ -0,0 +1,33 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/wf-in-fn-type-static.rs:23:5 + | +LL | struct Foo { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // needs T: 'static +LL | x: fn() -> &'static T //~ ERROR E0310 + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'static T` does not outlive the data it points at + --> $DIR/wf-in-fn-type-static.rs:23:5 + | +LL | x: fn() -> &'static T //~ ERROR E0310 + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/wf-in-fn-type-static.rs:28:5 + | +LL | struct Bar { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // needs T: Copy +LL | x: fn(&'static T) //~ ERROR E0310 + | ^^^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'static T` does not outlive the data it points at + --> $DIR/wf-in-fn-type-static.rs:28:5 + | +LL | x: fn(&'static T) //~ ERROR E0310 + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-where-clause.rs b/src/test/ui/compile-fail-migration/wf-in-fn-where-clause.rs new file mode 100644 index 00000000000..c2f66a2a460 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-where-clause.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions also for where clauses in fn items. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait MustBeCopy { +} + +fn bar() //~ ERROR E0277 + where T: MustBeCopy +{ +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-fn-where-clause.stderr b/src/test/ui/compile-fail-migration/wf-in-fn-where-clause.stderr new file mode 100644 index 00000000000..76693eace2f --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-fn-where-clause.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied + --> $DIR/wf-in-fn-where-clause.rs:19:1 + | +LL | / fn bar() //~ ERROR E0277 +LL | | where T: MustBeCopy +LL | | { +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `U` + | + = help: consider adding a `where U: std::marker::Copy` bound +note: required by `MustBeCopy` + --> $DIR/wf-in-fn-where-clause.rs:16:1 + | +LL | trait MustBeCopy { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-in-obj-type-static.rs b/src/test/ui/compile-fail-migration/wf-in-obj-type-static.rs new file mode 100644 index 00000000000..11535fb9f9e --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-obj-type-static.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions also for types in fns. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait Object { } + +struct MustBeCopy { + t: T +} + +struct Foo { + // needs T: 'static + x: Object<&'static T> //~ ERROR E0310 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-obj-type-static.stderr b/src/test/ui/compile-fail-migration/wf-in-obj-type-static.stderr new file mode 100644 index 00000000000..5cbb4be7e92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-obj-type-static.stderr @@ -0,0 +1,18 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/wf-in-obj-type-static.rs:24:5 + | +LL | struct Foo { + | - help: consider adding an explicit lifetime bound `T: 'static`... +LL | // needs T: 'static +LL | x: Object<&'static T> //~ ERROR E0310 + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'static T` does not outlive the data it points at + --> $DIR/wf-in-obj-type-static.rs:24:5 + | +LL | x: Object<&'static T> //~ ERROR E0310 + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/wf-in-obj-type-trait.rs b/src/test/ui/compile-fail-migration/wf-in-obj-type-trait.rs new file mode 100644 index 00000000000..add48219c1d --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-obj-type-trait.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we enforce WF conditions also for types in fns. + +trait Object { } + +struct MustBeCopy { + t: T +} + +struct Bar { + // needs T: Copy + x: Object> //~ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-in-obj-type-trait.stderr b/src/test/ui/compile-fail-migration/wf-in-obj-type-trait.stderr new file mode 100644 index 00000000000..93af991cc93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-in-obj-type-trait.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/wf-in-obj-type-trait.rs:21:5 + | +LL | x: Object> //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `MustBeCopy` + --> $DIR/wf-in-obj-type-trait.rs:15:1 + | +LL | struct MustBeCopy { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.rs b/src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.rs new file mode 100644 index 00000000000..78e12c47e24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check where-clauses on inherent impl methods. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +struct Foo(T,U); + +impl Foo { + fn foo(self) where T: ExtraCopy //~ ERROR E0277 + {} +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.stderr b/src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.stderr new file mode 100644 index 00000000000..25ec4195ab1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-inherent-impl-method-where-clause.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied + --> $DIR/wf-inherent-impl-method-where-clause.rs:22:5 + | +LL | / fn foo(self) where T: ExtraCopy //~ ERROR E0277 +LL | | {} + | |______^ the trait `std::marker::Copy` is not implemented for `U` + | + = help: consider adding a `where U: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-inherent-impl-method-where-clause.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.rs b/src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.rs new file mode 100644 index 00000000000..7edbb11e245 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check where-clauses on inherent impls. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +struct Foo(T,U); + +impl Foo where T: ExtraCopy //~ ERROR E0277 +{ +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.stderr b/src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.stderr new file mode 100644 index 00000000000..3c5c557db42 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-inherent-impl-where-clause.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied + --> $DIR/wf-inherent-impl-where-clause.rs:21:1 + | +LL | / impl Foo where T: ExtraCopy //~ ERROR E0277 +LL | | { +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `U` + | + = help: consider adding a `where U: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-inherent-impl-where-clause.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.nll.stderr b/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.nll.stderr new file mode 100644 index 00000000000..48a68bf5749 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.nll.stderr @@ -0,0 +1,111 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:32:31 + | +LL | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough + | ^^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 30:1... + --> $DIR/wf-misc-methods-issue-28609.rs:30:1 + | +LL | / fn return_dangling_pointer_inherent(s: S2) -> &u32 { +LL | | let s = s; +LL | | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough +LL | | } + | |_^ + +error[E0597]: `four` does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:45:19 + | +LL | s.bomb = Some(&four); //~ ERROR does not live long enough + | ^^^^^ borrowed value does not live long enough +LL | &s +LL | } + | - `four` dropped here while still borrowed + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 42:1... + --> $DIR/wf-misc-methods-issue-28609.rs:42:1 + | +LL | / fn return_dangling_pointer_coerce(s: S2) -> &u32 { +LL | | let four = 4; +LL | | let mut s = s; +LL | | s.bomb = Some(&four); //~ ERROR does not live long enough +LL | | &s +LL | | } + | |_^ + +error[E0597]: `four` does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:52:19 + | +LL | s.bomb = Some(&four); //~ ERROR does not live long enough + | ^^^^^ borrowed value does not live long enough +LL | &*s +LL | } + | - `four` dropped here while still borrowed + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 49:1... + --> $DIR/wf-misc-methods-issue-28609.rs:49:1 + | +LL | / fn return_dangling_pointer_unary_op(s: S2) -> &u32 { +LL | | let four = 4; +LL | | let mut s = s; +LL | | s.bomb = Some(&four); //~ ERROR does not live long enough +LL | | &*s +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:63:15 + | +LL | s << &mut 3 //~ ERROR does not live long enough + | ^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 61:1... + --> $DIR/wf-misc-methods-issue-28609.rs:61:1 + | +LL | / fn return_dangling_pointer_binary_op(s: S2) -> &u32 { +LL | | let s = s; +LL | | s << &mut 3 //~ ERROR does not live long enough +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:68:16 + | +LL | s.shl(&mut 3) //~ ERROR does not live long enough + | ^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 66:1... + --> $DIR/wf-misc-methods-issue-28609.rs:66:1 + | +LL | / fn return_dangling_pointer_method(s: S2) -> &u32 { +LL | | let s = s; +LL | | s.shl(&mut 3) //~ ERROR does not live long enough +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:73:21 + | +LL | S2::shl(s, &mut 3) //~ ERROR does not live long enough + | ^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 71:1... + --> $DIR/wf-misc-methods-issue-28609.rs:71:1 + | +LL | / fn return_dangling_pointer_ufcs(s: S2) -> &u32 { +LL | | let s = s; +LL | | S2::shl(s, &mut 3) //~ ERROR does not live long enough +LL | | } + | |_^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.rs b/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.rs new file mode 100644 index 00000000000..055c86a03a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.rs @@ -0,0 +1,84 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// check that misc. method calls are well-formed + +use std::marker::PhantomData; +use std::ops::{Deref, Shl}; + +#[derive(Copy, Clone)] +struct S<'a, 'b: 'a> { + marker: PhantomData<&'a &'b ()>, + bomb: Option<&'b u32> +} + +type S2<'a> = S<'a, 'a>; + +impl<'a, 'b> S<'a, 'b> { + fn transmute_inherent(&self, a: &'b u32) -> &'a u32 { + a + } +} + +fn return_dangling_pointer_inherent(s: S2) -> &u32 { + let s = s; + s.transmute_inherent(&mut 42) //~ ERROR does not live long enough +} + +impl<'a, 'b> Deref for S<'a, 'b> { + type Target = &'a u32; + fn deref(&self) -> &&'a u32 { + self.bomb.as_ref().unwrap() + } +} + +fn return_dangling_pointer_coerce(s: S2) -> &u32 { + let four = 4; + let mut s = s; + s.bomb = Some(&four); //~ ERROR does not live long enough + &s +} + +fn return_dangling_pointer_unary_op(s: S2) -> &u32 { + let four = 4; + let mut s = s; + s.bomb = Some(&four); //~ ERROR does not live long enough + &*s +} + +impl<'a, 'b> Shl<&'b u32> for S<'a, 'b> { + type Output = &'a u32; + fn shl(self, t: &'b u32) -> &'a u32 { t } +} + +fn return_dangling_pointer_binary_op(s: S2) -> &u32 { + let s = s; + s << &mut 3 //~ ERROR does not live long enough +} + +fn return_dangling_pointer_method(s: S2) -> &u32 { + let s = s; + s.shl(&mut 3) //~ ERROR does not live long enough +} + +fn return_dangling_pointer_ufcs(s: S2) -> &u32 { + let s = s; + S2::shl(s, &mut 3) //~ ERROR does not live long enough +} + +fn main() { + let s = S { marker: PhantomData, bomb: None }; + let _inherent_dp = return_dangling_pointer_inherent(s); + let _coerce_dp = return_dangling_pointer_coerce(s); + let _unary_dp = return_dangling_pointer_unary_op(s); + let _binary_dp = return_dangling_pointer_binary_op(s); + let _method_dp = return_dangling_pointer_method(s); + let _ufcs_dp = return_dangling_pointer_ufcs(s); +} diff --git a/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.stderr b/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.stderr new file mode 100644 index 00000000000..352697e6f94 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-misc-methods-issue-28609.stderr @@ -0,0 +1,111 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:32:31 + | +LL | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough + | ^^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 30:1... + --> $DIR/wf-misc-methods-issue-28609.rs:30:1 + | +LL | / fn return_dangling_pointer_inherent(s: S2) -> &u32 { +LL | | let s = s; +LL | | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough +LL | | } + | |_^ + +error[E0597]: `four` does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:45:20 + | +LL | s.bomb = Some(&four); //~ ERROR does not live long enough + | ^^^^ borrowed value does not live long enough +LL | &s +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 42:1... + --> $DIR/wf-misc-methods-issue-28609.rs:42:1 + | +LL | / fn return_dangling_pointer_coerce(s: S2) -> &u32 { +LL | | let four = 4; +LL | | let mut s = s; +LL | | s.bomb = Some(&four); //~ ERROR does not live long enough +LL | | &s +LL | | } + | |_^ + +error[E0597]: `four` does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:52:20 + | +LL | s.bomb = Some(&four); //~ ERROR does not live long enough + | ^^^^ borrowed value does not live long enough +LL | &*s +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 49:1... + --> $DIR/wf-misc-methods-issue-28609.rs:49:1 + | +LL | / fn return_dangling_pointer_unary_op(s: S2) -> &u32 { +LL | | let four = 4; +LL | | let mut s = s; +LL | | s.bomb = Some(&four); //~ ERROR does not live long enough +LL | | &*s +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:63:15 + | +LL | s << &mut 3 //~ ERROR does not live long enough + | ^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 61:1... + --> $DIR/wf-misc-methods-issue-28609.rs:61:1 + | +LL | / fn return_dangling_pointer_binary_op(s: S2) -> &u32 { +LL | | let s = s; +LL | | s << &mut 3 //~ ERROR does not live long enough +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:68:16 + | +LL | s.shl(&mut 3) //~ ERROR does not live long enough + | ^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 66:1... + --> $DIR/wf-misc-methods-issue-28609.rs:66:1 + | +LL | / fn return_dangling_pointer_method(s: S2) -> &u32 { +LL | | let s = s; +LL | | s.shl(&mut 3) //~ ERROR does not live long enough +LL | | } + | |_^ + +error[E0597]: borrowed value does not live long enough + --> $DIR/wf-misc-methods-issue-28609.rs:73:21 + | +LL | S2::shl(s, &mut 3) //~ ERROR does not live long enough + | ^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 71:1... + --> $DIR/wf-misc-methods-issue-28609.rs:71:1 + | +LL | / fn return_dangling_pointer_ufcs(s: S2) -> &u32 { +LL | | let s = s; +LL | | S2::shl(s, &mut 3) //~ ERROR does not live long enough +LL | | } + | |_^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/wf-object-safe.rs b/src/test/ui/compile-fail-migration/wf-object-safe.rs new file mode 100644 index 00000000000..92c0a8c5be8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-object-safe.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that object-safe traits are not WF when used as object types. +// Issue #21953. + +trait A { + fn foo(&self, _x: &Self); +} + +fn main() { + let _x: &A; //~ ERROR E0038 +} diff --git a/src/test/ui/compile-fail-migration/wf-object-safe.stderr b/src/test/ui/compile-fail-migration/wf-object-safe.stderr new file mode 100644 index 00000000000..3d42c52136b --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-object-safe.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `A` cannot be made into an object + --> $DIR/wf-object-safe.rs:19:13 + | +LL | let _x: &A; //~ ERROR E0038 + | ^^ the trait `A` cannot be made into an object + | + = note: method `foo` references the `Self` type in its arguments or return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.rs b/src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.rs new file mode 100644 index 00000000000..c11b2e4c544 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that an appearance of `T` in fn args or in a trait object must +// still meet the outlives bounds. Since this is a new requirement, +// this is currently only a warning, not a hard error. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait Trait { } + +struct Foo<'a,T> { + f: &'a fn(T), + //~^ ERROR E0309 +} + +struct Bar<'a,T> { + f: &'a Trait, + //~^ ERROR E0309 +} + +#[rustc_error] +fn main() { } + diff --git a/src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.stderr new file mode 100644 index 00000000000..9a8c63126f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-outlives-ty-in-fn-or-trait.stderr @@ -0,0 +1,31 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:21:5 + | +LL | struct Foo<'a,T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | f: &'a fn(T), + | ^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a fn(T)` does not outlive the data it points at + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:21:5 + | +LL | f: &'a fn(T), + | ^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 + | +LL | struct Bar<'a,T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | f: &'a Trait, + | ^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a (dyn Trait + 'a)` does not outlive the data it points at + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 + | +LL | f: &'a Trait, + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/wf-static-method.nll.stderr b/src/test/ui/compile-fail-migration/wf-static-method.nll.stderr new file mode 100644 index 00000000000..77896ff2ece --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-static-method.nll.stderr @@ -0,0 +1,54 @@ +warning: not reporting region error due to nll + --> $DIR/wf-static-method.rs:27:9 + | +LL | u //~ ERROR E0312 + | ^ + +warning: not reporting region error due to nll + --> $DIR/wf-static-method.rs:36:18 + | +LL | let me = Self::make_me(); //~ ERROR lifetime bound not satisfied + | ^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/wf-static-method.rs:43:9 + | +LL | u //~ ERROR E0312 + | ^ + +warning: not reporting region error due to nll + --> $DIR/wf-static-method.rs:51:5 + | +LL | <()>::static_evil(b) //~ ERROR cannot infer an appropriate lifetime + | ^^^^^^^^^^^^^^^^^ + +warning: not reporting region error due to nll + --> $DIR/wf-static-method.rs:55:5 + | +LL | ::static_evil(b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/wf-static-method.rs:27:9 + | +LL | impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | u //~ ERROR E0312 + | ^ return requires that `'b` must outlive `'a` + +error: unsatisfied lifetime constraints + --> $DIR/wf-static-method.rs:43:9 + | +LL | impl<'a, 'b> Evil<'a, 'b> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | fn inherent_evil(u: &'b u32) -> &'a u32 { +LL | u //~ ERROR E0312 + | ^ return requires that `'b` must outlive `'a` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/wf-static-method.rs b/src/test/ui/compile-fail-migration/wf-static-method.rs new file mode 100644 index 00000000000..e99957c7914 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-static-method.rs @@ -0,0 +1,64 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// check that static methods don't get to assume their trait-ref +// is well-formed. +// FIXME(#27579): this is just a bug. However, our checking with +// static inherent methods isn't quite working - need to +// fix that before removing the check. + +trait Foo<'a, 'b, T>: Sized { + fn make_me() -> Self { loop {} } + fn static_evil(u: &'b u32) -> &'a u32; +} + +struct Evil<'a, 'b: 'a>(Option<&'a &'b ()>); + +impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { + fn make_me() -> Self { } + fn static_evil(u: &'b u32) -> &'a u32 { + u //~ ERROR E0312 + } +} + +struct IndirectEvil<'a, 'b: 'a>(Option<&'a &'b ()>); + +impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { + fn make_me() -> Self { IndirectEvil(None) } + fn static_evil(u: &'b u32) -> &'a u32 { + let me = Self::make_me(); //~ ERROR lifetime bound not satisfied + loop {} // (`me` could be used for the lifetime transmute). + } +} + +impl<'a, 'b> Evil<'a, 'b> { + fn inherent_evil(u: &'b u32) -> &'a u32 { + u //~ ERROR E0312 + } +} + +// while static methods don't get to *assume* this, we still +// *check* that they hold. + +fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { + <()>::static_evil(b) //~ ERROR cannot infer an appropriate lifetime +} + +fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + ::static_evil(b) + //~^ ERROR cannot infer an appropriate lifetime +} + +fn inherent_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + ::inherent_evil(b) // bug? shouldn't this be an error +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/wf-static-method.stderr b/src/test/ui/compile-fail-migration/wf-static-method.stderr new file mode 100644 index 00000000000..0de2d8e6ca0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-static-method.stderr @@ -0,0 +1,109 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/wf-static-method.rs:27:9 + | +LL | u //~ ERROR E0312 + | ^ + | +note: ...the reference is valid for the lifetime 'a as defined on the impl at 24:6... + --> $DIR/wf-static-method.rs:24:6 + | +LL | impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { + | ^^ +note: ...but the borrowed content is only valid for the lifetime 'b as defined on the impl at 24:10 + --> $DIR/wf-static-method.rs:24:10 + | +LL | impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { + | ^^ + +error[E0478]: lifetime bound not satisfied + --> $DIR/wf-static-method.rs:36:18 + | +LL | let me = Self::make_me(); //~ ERROR lifetime bound not satisfied + | ^^^^^^^^^^^^^ + | +note: lifetime parameter instantiated with the lifetime 'b as defined on the impl at 33:10 + --> $DIR/wf-static-method.rs:33:10 + | +LL | impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { + | ^^ +note: but lifetime parameter must outlive the lifetime 'a as defined on the impl at 33:6 + --> $DIR/wf-static-method.rs:33:6 + | +LL | impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { + | ^^ + +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/wf-static-method.rs:43:9 + | +LL | u //~ ERROR E0312 + | ^ + | +note: ...the reference is valid for the lifetime 'a as defined on the impl at 41:6... + --> $DIR/wf-static-method.rs:41:6 + | +LL | impl<'a, 'b> Evil<'a, 'b> { + | ^^ +note: ...but the borrowed content is only valid for the lifetime 'b as defined on the impl at 41:10 + --> $DIR/wf-static-method.rs:41:10 + | +LL | impl<'a, 'b> Evil<'a, 'b> { + | ^^ + +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements + --> $DIR/wf-static-method.rs:51:5 + | +LL | <()>::static_evil(b) //~ ERROR cannot infer an appropriate lifetime + | ^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'b as defined on the function body at 50:13... + --> $DIR/wf-static-method.rs:50:13 + | +LL | fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/wf-static-method.rs:51:23 + | +LL | <()>::static_evil(b) //~ ERROR cannot infer an appropriate lifetime + | ^ +note: but, the lifetime must be valid for the lifetime 'a as defined on the function body at 50:9... + --> $DIR/wf-static-method.rs:50:9 + | +LL | fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/wf-static-method.rs:51:5 + | +LL | <()>::static_evil(b) //~ ERROR cannot infer an appropriate lifetime + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements + --> $DIR/wf-static-method.rs:55:5 + | +LL | ::static_evil(b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'b as defined on the function body at 54:22... + --> $DIR/wf-static-method.rs:54:22 + | +LL | fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/wf-static-method.rs:55:33 + | +LL | ::static_evil(b) + | ^ +note: but, the lifetime must be valid for the lifetime 'a as defined on the function body at 54:18... + --> $DIR/wf-static-method.rs:54:18 + | +LL | fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/wf-static-method.rs:55:5 + | +LL | ::static_evil(b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0312, E0478, E0495. +For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/compile-fail-migration/wf-static-type.rs b/src/test/ui/compile-fail-migration/wf-static-type.rs new file mode 100644 index 00000000000..ba02c5dca3e --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-static-type.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check the types of statics are well-formed. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct IsCopy { t: T } +struct NotCopy; + +static FOO: IsCopy> = IsCopy { t: None }; +//~^ ERROR E0277 + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-static-type.stderr b/src/test/ui/compile-fail-migration/wf-static-type.stderr new file mode 100644 index 00000000000..f76444cfe1f --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-static-type.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied + --> $DIR/wf-static-type.rs:20:1 + | +LL | static FOO: IsCopy> = IsCopy { t: None }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` + | + = note: required because of the requirements on the impl of `std::marker::Copy` for `std::option::Option` +note: required by `IsCopy` + --> $DIR/wf-static-type.rs:17:1 + | +LL | struct IsCopy { t: T } + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-struct-bound.rs b/src/test/ui/compile-fail-migration/wf-struct-bound.rs new file mode 100644 index 00000000000..e263b251aa3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-struct-bound.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check struct bounds for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +struct SomeStruct //~ ERROR E0277 + where T: ExtraCopy +{ + data: (T,U) +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-struct-bound.stderr b/src/test/ui/compile-fail-migration/wf-struct-bound.stderr new file mode 100644 index 00000000000..397d8609ceb --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-struct-bound.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied + --> $DIR/wf-struct-bound.rs:19:1 + | +LL | / struct SomeStruct //~ ERROR E0277 +LL | | where T: ExtraCopy +LL | | { +LL | | data: (T,U) +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `U` + | + = help: consider adding a `where U: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-struct-bound.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-struct-field.rs b/src/test/ui/compile-fail-migration/wf-struct-field.rs new file mode 100644 index 00000000000..8a631a6c335 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-struct-field.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check struct fields for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct IsCopy { + value: T +} + +struct SomeStruct { + data: IsCopy //~ ERROR E0277 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-struct-field.stderr b/src/test/ui/compile-fail-migration/wf-struct-field.stderr new file mode 100644 index 00000000000..48a03c71d7d --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-struct-field.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied + --> $DIR/wf-struct-field.rs:22:5 + | +LL | data: IsCopy //~ ERROR E0277 + | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` + | + = help: consider adding a `where A: std::marker::Copy` bound +note: required by `IsCopy` + --> $DIR/wf-struct-field.rs:17:1 + | +LL | struct IsCopy { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.rs b/src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.rs new file mode 100644 index 00000000000..8420edd66a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check associated type bounds for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +trait SomeTrait { //~ ERROR E0277 + type Type1: ExtraCopy; +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.stderr b/src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.stderr new file mode 100644 index 00000000000..f09ba381db1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-associated-type-bound.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/wf-trait-associated-type-bound.rs:19:1 + | +LL | / trait SomeTrait { //~ ERROR E0277 +LL | | type Type1: ExtraCopy; +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-trait-associated-type-bound.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-associated-type-region.rs b/src/test/ui/compile-fail-migration/wf-trait-associated-type-region.rs new file mode 100644 index 00000000000..95d9ffdf9d3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-associated-type-region.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check associated type default values for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait SomeTrait<'a> { + type Type1; + type Type2 = &'a Self::Type1; + //~^ ERROR E0309 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-associated-type-region.stderr b/src/test/ui/compile-fail-migration/wf-trait-associated-type-region.stderr new file mode 100644 index 00000000000..26d56f7e964 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-associated-type-region.stderr @@ -0,0 +1,16 @@ +error[E0309]: the associated type `>::Type1` may not live long enough + --> $DIR/wf-trait-associated-type-region.rs:19:5 + | +LL | type Type2 = &'a Self::Type1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `>::Type1: 'a`... +note: ...so that the reference type `&'a >::Type1` does not outlive the data it points at + --> $DIR/wf-trait-associated-type-region.rs:19:5 + | +LL | type Type2 = &'a Self::Type1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.rs b/src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.rs new file mode 100644 index 00000000000..902cbe2676b --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check associated type default values for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +struct IsCopy { x: T } + +trait SomeTrait { + type Type1; + type Type2 = IsCopy; + //~^ ERROR E0277 +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.stderr b/src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.stderr new file mode 100644 index 00000000000..6bfca64c443 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-associated-type-trait.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `::Type1: std::marker::Copy` is not satisfied + --> $DIR/wf-trait-associated-type-trait.rs:21:5 + | +LL | type Type2 = IsCopy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `::Type1` + | + = help: consider adding a `where ::Type1: std::marker::Copy` bound +note: required by `IsCopy` + --> $DIR/wf-trait-associated-type-trait.rs:17:1 + | +LL | struct IsCopy { x: T } + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-bound.rs b/src/test/ui/compile-fail-migration/wf-trait-bound.rs new file mode 100644 index 00000000000..ca15a6ab648 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-bound.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check supertrait bounds for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +trait SomeTrait //~ ERROR E0277 + where T: ExtraCopy +{ +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-bound.stderr b/src/test/ui/compile-fail-migration/wf-trait-bound.stderr new file mode 100644 index 00000000000..4c21959d9f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-bound.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied + --> $DIR/wf-trait-bound.rs:19:1 + | +LL | / trait SomeTrait //~ ERROR E0277 +LL | | where T: ExtraCopy +LL | | { +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `U` + | + = help: consider adding a `where U: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-trait-bound.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.rs b/src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.rs new file mode 100644 index 00000000000..453aa2428ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we test WF conditions for fn arguments. Because the +// current code is so goofy, this is only a warning for now. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +struct Bar { value: Box } + +trait Foo { + fn bar(&self, x: &Bar) { + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.stderr b/src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.stderr new file mode 100644 index 00000000000..5754fd77b72 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-default-fn-arg.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied + --> $DIR/wf-trait-default-fn-arg.rs:21:5 + | +LL | / fn bar(&self, x: &Bar) { +LL | | //~^ ERROR E0277 +LL | | // +LL | | // Here, Eq ought to be implemented. +LL | | } + | |_____^ the trait `std::cmp::Eq` is not implemented for `Self` + | + = help: consider adding a `where Self: std::cmp::Eq` bound +note: required by `Bar` + --> $DIR/wf-trait-default-fn-arg.rs:18:1 + | +LL | struct Bar { value: Box } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.rs b/src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.rs new file mode 100644 index 00000000000..d94708d3e06 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we test WF conditions for fn arguments. Because the +// current code is so goofy, this is only a warning for now. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +struct Bar { value: Box } + +trait Foo { + fn bar(&self) -> Bar { + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. + loop { } + } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.stderr b/src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.stderr new file mode 100644 index 00000000000..28d690b1b05 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-default-fn-ret.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied + --> $DIR/wf-trait-default-fn-ret.rs:21:5 + | +LL | / fn bar(&self) -> Bar { +LL | | //~^ ERROR E0277 +LL | | // +LL | | // Here, Eq ought to be implemented. +LL | | loop { } +LL | | } + | |_____^ the trait `std::cmp::Eq` is not implemented for `Self` + | + = help: consider adding a `where Self: std::cmp::Eq` bound +note: required by `Bar` + --> $DIR/wf-trait-default-fn-ret.rs:18:1 + | +LL | struct Bar { value: Box } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.rs b/src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.rs new file mode 100644 index 00000000000..29c85250583 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we test WF conditions for fn arguments. Because the +// current code is so goofy, this is only a warning for now. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +trait Bar { } + +trait Foo { + fn bar(&self) where A: Bar { + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.stderr b/src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.stderr new file mode 100644 index 00000000000..c135f199a26 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-default-fn-where-clause.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied + --> $DIR/wf-trait-default-fn-where-clause.rs:21:5 + | +LL | / fn bar(&self) where A: Bar { +LL | | //~^ ERROR E0277 +LL | | // +LL | | // Here, Eq ought to be implemented. +LL | | } + | |_____^ the trait `std::cmp::Eq` is not implemented for `Self` + | + = help: consider adding a `where Self: std::cmp::Eq` bound +note: required by `Bar` + --> $DIR/wf-trait-default-fn-where-clause.rs:18:1 + | +LL | trait Bar { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-fn-arg.rs b/src/test/ui/compile-fail-migration/wf-trait-fn-arg.rs new file mode 100644 index 00000000000..d88e36faeec --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-fn-arg.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we test WF conditions for fn arguments in a trait definition. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +struct Bar { value: Box } + +trait Foo { + fn bar(&self, x: &Bar); + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-fn-arg.stderr b/src/test/ui/compile-fail-migration/wf-trait-fn-arg.stderr new file mode 100644 index 00000000000..6d624fc62ff --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-fn-arg.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied + --> $DIR/wf-trait-fn-arg.rs:20:5 + | +LL | fn bar(&self, x: &Bar); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self` + | + = help: consider adding a `where Self: std::cmp::Eq` bound +note: required by `Bar` + --> $DIR/wf-trait-fn-arg.rs:17:1 + | +LL | struct Bar { value: Box } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-fn-ret.rs b/src/test/ui/compile-fail-migration/wf-trait-fn-ret.rs new file mode 100644 index 00000000000..c368ff9a4a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-fn-ret.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we test WF conditions for fn return types in a trait definition. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +struct Bar { value: Box } + +trait Foo { + fn bar(&self) -> &Bar; + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-fn-ret.stderr b/src/test/ui/compile-fail-migration/wf-trait-fn-ret.stderr new file mode 100644 index 00000000000..dca26a63079 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-fn-ret.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied + --> $DIR/wf-trait-fn-ret.rs:20:5 + | +LL | fn bar(&self) -> &Bar; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self` + | + = help: consider adding a `where Self: std::cmp::Eq` bound +note: required by `Bar` + --> $DIR/wf-trait-fn-ret.rs:17:1 + | +LL | struct Bar { value: Box } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.rs b/src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.rs new file mode 100644 index 00000000000..f46a54504a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we test WF conditions for fn where clauses in a trait definition. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![allow(unused_variables)] + +struct Bar { value: Box } + +trait Foo { + fn bar(&self) where Self: Sized, Bar: Copy; + //~^ ERROR E0277 + // + // Here, Eq ought to be implemented. +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.stderr b/src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.stderr new file mode 100644 index 00000000000..887f60935b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-fn-where-clause.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied + --> $DIR/wf-trait-fn-where-clause.rs:20:5 + | +LL | fn bar(&self) where Self: Sized, Bar: Copy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Self` + | + = help: consider adding a `where Self: std::cmp::Eq` bound +note: required by `Bar` + --> $DIR/wf-trait-fn-where-clause.rs:17:1 + | +LL | struct Bar { value: Box } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/wf-trait-superbound.rs b/src/test/ui/compile-fail-migration/wf-trait-superbound.rs new file mode 100644 index 00000000000..ea8b2fdf3a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-superbound.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we check supertrait bounds for WFedness. + +#![feature(associated_type_defaults)] +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait ExtraCopy { } + +trait SomeTrait: ExtraCopy { //~ ERROR E0277 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wf-trait-superbound.stderr b/src/test/ui/compile-fail-migration/wf-trait-superbound.stderr new file mode 100644 index 00000000000..ac58dc7496e --- /dev/null +++ b/src/test/ui/compile-fail-migration/wf-trait-superbound.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/wf-trait-superbound.rs:19:1 + | +LL | / trait SomeTrait: ExtraCopy { //~ ERROR E0277 +LL | | } + | |_^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `ExtraCopy` + --> $DIR/wf-trait-superbound.rs:17:1 + | +LL | trait ExtraCopy { } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.rs b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.rs new file mode 100644 index 00000000000..458ee669424 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn require_copy(x: T) {} + +struct Foo { x: T } + +// Ensure constraints are only attached to methods locally +impl Foo { + fn needs_copy(self) where T: Copy { + require_copy(self.x); + + } + + fn fails_copy(self) { + require_copy(self.x); + //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.stderr b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.stderr new file mode 100644 index 00000000000..0d6906a85d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-inherent-impl.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/where-clause-constraints-are-local-for-inherent-impl.rs:23:9 + | +LL | require_copy(self.x); + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `require_copy` + --> $DIR/where-clause-constraints-are-local-for-inherent-impl.rs:11:1 + | +LL | fn require_copy(x: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.rs b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.rs new file mode 100644 index 00000000000..b3f99f2ae25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn require_copy(x: T) {} + +struct Bar { x: T } + +trait Foo { + fn needs_copy(self) where T: Copy; + fn fails_copy(self); +} + +// Ensure constraints are only attached to methods locally +impl Foo for Bar { + fn needs_copy(self) where T: Copy { + require_copy(self.x); + + } + + fn fails_copy(self) { + require_copy(self.x); + //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.stderr b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.stderr new file mode 100644 index 00000000000..976cca7b895 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clause-constraints-are-local-for-trait-impl.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied + --> $DIR/where-clause-constraints-are-local-for-trait-impl.rs:28:9 + | +LL | require_copy(self.x); + | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` + | + = help: consider adding a `where T: std::marker::Copy` bound +note: required by `require_copy` + --> $DIR/where-clause-constraints-are-local-for-trait-impl.rs:11:1 + | +LL | fn require_copy(x: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/where-clause-method-substituion.rs b/src/test/ui/compile-fail-migration/where-clause-method-substituion.rs new file mode 100644 index 00000000000..05a58daf906 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clause-method-substituion.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + fn dummy(&self, t: T) { } +} + +trait Bar { + fn method(&self) where A: Foo; +} + +struct S; +struct X; + +// Remove this impl causing the below resolution to fail // impl Foo for X {} + +impl Bar for isize { + fn method(&self) where X: Foo { + } +} + +fn main() { + 1.method::(); + //~^ ERROR the trait bound `X: Foo` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/where-clause-method-substituion.stderr b/src/test/ui/compile-fail-migration/where-clause-method-substituion.stderr new file mode 100644 index 00000000000..5cd4c395869 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clause-method-substituion.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `X: Foo` is not satisfied + --> $DIR/where-clause-method-substituion.rs:30:7 + | +LL | 1.method::(); + | ^^^^^^ the trait `Foo` is not implemented for `X` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.rs b/src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.rs new file mode 100644 index 00000000000..1ac03330afd --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a where clause attached to a method allows us to add +// additional constraints to a parameter out of scope. + +struct Foo { + value: T +} + +struct Bar; // does not implement Eq + +impl Foo { + fn equals(&self, u: &Foo) -> bool where T : Eq { + self.value == u.value + } +} + +fn main() { + let x = Foo { value: Bar }; + x.equals(&x); + //~^ ERROR `Bar: std::cmp::Eq` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.stderr b/src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.stderr new file mode 100644 index 00000000000..eeb0b51b80a --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clauses-method-unsatisfied.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `Bar: std::cmp::Eq` is not satisfied + --> $DIR/where-clauses-method-unsatisfied.rs:28:7 + | +LL | x.equals(&x); + | ^^^^^^ the trait `std::cmp::Eq` is not implemented for `Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/where-clauses-unsatisfied.rs b/src/test/ui/compile-fail-migration/where-clauses-unsatisfied.rs new file mode 100644 index 00000000000..ffc39008c4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clauses-unsatisfied.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn equal(a: &T, b: &T) -> bool where T : Eq { a == b } + +struct Struct; + +fn main() { + drop(equal(&Struct, &Struct)) + //~^ ERROR the trait bound `Struct: std::cmp::Eq` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/where-clauses-unsatisfied.stderr b/src/test/ui/compile-fail-migration/where-clauses-unsatisfied.stderr new file mode 100644 index 00000000000..dd042599382 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-clauses-unsatisfied.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Struct: std::cmp::Eq` is not satisfied + --> $DIR/where-clauses-unsatisfied.rs:16:10 + | +LL | drop(equal(&Struct, &Struct)) + | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Struct` + | +note: required by `equal` + --> $DIR/where-clauses-unsatisfied.rs:11:1 + | +LL | fn equal(a: &T, b: &T) -> bool where T : Eq { a == b } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/where-equality-constraints.rs b/src/test/ui/compile-fail-migration/where-equality-constraints.rs new file mode 100644 index 00000000000..e449a736c75 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-equality-constraints.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() where u8 = u16 {} +//~^ ERROR equality constraints are not yet supported in where clauses +fn g() where for<'a> &'static (u8,) == u16, {} +//~^ ERROR equality constraints are not yet supported in where clauses + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/where-equality-constraints.stderr b/src/test/ui/compile-fail-migration/where-equality-constraints.stderr new file mode 100644 index 00000000000..f2bcfacc452 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-equality-constraints.stderr @@ -0,0 +1,14 @@ +error: equality constraints are not yet supported in where clauses (#20041) + --> $DIR/where-equality-constraints.rs:11:14 + | +LL | fn f() where u8 = u16 {} + | ^^^^^^^^ + +error: equality constraints are not yet supported in where clauses (#20041) + --> $DIR/where-equality-constraints.rs:13:14 + | +LL | fn g() where for<'a> &'static (u8,) == u16, {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/where-for-self-2.rs b/src/test/ui/compile-fail-migration/where-for-self-2.rs new file mode 100644 index 00000000000..bf8fc292173 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-for-self-2.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can quantify lifetimes outside a constraint (i.e., including +// the self type) in a where clause. Specifically, test that implementing for a +// specific lifetime is not enough to satisify the `for<'a> ...` constraint, which +// should require *all* lifetimes. + +static X: &'static u32 = &42; + +trait Bar { + fn bar(&self); +} + +impl Bar for &'static u32 { + fn bar(&self) {} +} + +fn foo(x: &T) + where for<'a> &'a T: Bar +{} + +fn main() { + foo(&X); + //~^ error: `for<'a> &'a _: Bar` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/where-for-self-2.stderr b/src/test/ui/compile-fail-migration/where-for-self-2.stderr new file mode 100644 index 00000000000..d234c718215 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-for-self-2.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `for<'a> &'a _: Bar` is not satisfied + --> $DIR/where-for-self-2.rs:31:5 + | +LL | foo(&X); + | ^^^ the trait `for<'a> Bar` is not implemented for `&'a _` + | + = help: the following implementations were found: + <&'static u32 as Bar> +note: required by `foo` + --> $DIR/where-for-self-2.rs:26:1 + | +LL | / fn foo(x: &T) +LL | | where for<'a> &'a T: Bar +LL | | {} + | |__^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/where-for-self.rs b/src/test/ui/compile-fail-migration/where-for-self.rs new file mode 100644 index 00000000000..8f447face4e --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-for-self.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can quantify lifetimes outside a constraint (i.e., including +// the self type) in a where clause. Specifically, test that we cannot nest +// quantification in constraints (to be clear, there is no reason this should not +// we're testing we don't crash or do something stupid). + +trait Bar<'a> { + fn bar(&self); +} + +impl<'a, 'b> Bar<'b> for &'a u32 { + fn bar(&self) {} +} + +fn foo(x: &T) + where for<'a> &'a T: for<'b> Bar<'b> + //~^ error: nested quantification of lifetimes +{} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/where-for-self.stderr b/src/test/ui/compile-fail-migration/where-for-self.stderr new file mode 100644 index 00000000000..89c0bd023c3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-for-self.stderr @@ -0,0 +1,9 @@ +error[E0316]: nested quantification of lifetimes + --> $DIR/where-for-self.rs:25:26 + | +LL | where for<'a> &'a T: for<'b> Bar<'b> + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0316`. diff --git a/src/test/ui/compile-fail-migration/where-lifetime-resolution.rs b/src/test/ui/compile-fail-migration/where-lifetime-resolution.rs new file mode 100644 index 00000000000..1204cc0df47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-lifetime-resolution.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait1<'a> {} +trait Trait2<'a, 'b> {} + +fn f() where + for<'a> Trait1<'a>: Trait1<'a>, // OK + (for<'a> Trait1<'a>): Trait1<'a>, + //~^ ERROR use of undeclared lifetime name `'a` + for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + //~^ ERROR use of undeclared lifetime name `'b` + //~| ERROR nested quantification of lifetimes +{} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/where-lifetime-resolution.stderr b/src/test/ui/compile-fail-migration/where-lifetime-resolution.stderr new file mode 100644 index 00000000000..a6fc1b25962 --- /dev/null +++ b/src/test/ui/compile-fail-migration/where-lifetime-resolution.stderr @@ -0,0 +1,22 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/where-lifetime-resolution.rs:16:34 + | +LL | (for<'a> Trait1<'a>): Trait1<'a>, + | ^^ undeclared lifetime + +error[E0316]: nested quantification of lifetimes + --> $DIR/where-lifetime-resolution.rs:18:13 + | +LL | for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/where-lifetime-resolution.rs:18:48 + | +LL | for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + | ^^ undeclared lifetime + +error: aborting due to 3 previous errors + +Some errors occurred: E0261, E0316. +For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/compile-fail-migration/while-let.rs b/src/test/ui/compile-fail-migration/while-let.rs new file mode 100644 index 00000000000..a70dcccd4e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/while-let.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn macros() { + macro_rules! foo{ + ($p:pat, $e:expr, $b:block) => {{ + while let $p = $e $b + }} + } + macro_rules! bar{ + ($p:pat, $e:expr, $b:block) => {{ + foo!($p, $e, $b) + }} + } + + foo!(a, 1, { //~ ERROR irrefutable while-let + println!("irrefutable pattern"); + }); + bar!(a, 1, { //~ ERROR irrefutable while-let + println!("irrefutable pattern"); + }); +} + +pub fn main() { + while let a = 1 { //~ ERROR irrefutable while-let + println!("irrefutable pattern"); + } +} diff --git a/src/test/ui/compile-fail-migration/while-let.stderr b/src/test/ui/compile-fail-migration/while-let.stderr new file mode 100644 index 00000000000..de4d8be212e --- /dev/null +++ b/src/test/ui/compile-fail-migration/while-let.stderr @@ -0,0 +1,21 @@ +error[E0165]: irrefutable while-let pattern + --> $DIR/while-let.rs:23:10 + | +LL | foo!(a, 1, { //~ ERROR irrefutable while-let + | ^ irrefutable pattern + +error[E0165]: irrefutable while-let pattern + --> $DIR/while-let.rs:26:10 + | +LL | bar!(a, 1, { //~ ERROR irrefutable while-let + | ^ irrefutable pattern + +error[E0165]: irrefutable while-let pattern + --> $DIR/while-let.rs:32:15 + | +LL | while let a = 1 { //~ ERROR irrefutable while-let + | ^ irrefutable pattern + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0165`. diff --git a/src/test/ui/compile-fail-migration/while-type-error.rs b/src/test/ui/compile-fail-migration/while-type-error.rs new file mode 100644 index 00000000000..ecab746373a --- /dev/null +++ b/src/test/ui/compile-fail-migration/while-type-error.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types + +fn main() { while main { } } diff --git a/src/test/ui/compile-fail-migration/while-type-error.stderr b/src/test/ui/compile-fail-migration/while-type-error.stderr new file mode 100644 index 00000000000..cfc3f3e257e --- /dev/null +++ b/src/test/ui/compile-fail-migration/while-type-error.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/while-type-error.rs:13:19 + | +LL | fn main() { while main { } } + | ^^^^ expected bool, found fn item + | + = note: expected type `bool` + found type `fn() {main}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/windows-subsystem-invalid.rs b/src/test/ui/compile-fail-migration/windows-subsystem-invalid.rs new file mode 100644 index 00000000000..7772cfd6a2c --- /dev/null +++ b/src/test/ui/compile-fail-migration/windows-subsystem-invalid.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: invalid windows subsystem `wrong`, only `windows` and `console` are allowed + +#![windows_subsystem = "wrong"] + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/windows-subsystem-invalid.stderr b/src/test/ui/compile-fail-migration/windows-subsystem-invalid.stderr new file mode 100644 index 00000000000..0cb843cf0f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/windows-subsystem-invalid.stderr @@ -0,0 +1,4 @@ +error: invalid windows subsystem `wrong`, only `windows` and `console` are allowed + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/write-to-static-mut-in-static.rs b/src/test/ui/compile-fail-migration/write-to-static-mut-in-static.rs new file mode 100644 index 00000000000..1ea74f73723 --- /dev/null +++ b/src/test/ui/compile-fail-migration/write-to-static-mut-in-static.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_let)] + +pub static mut A: u32 = 0; +pub static mut B: () = unsafe { A = 1; }; +//~^ ERROR statements in statics are unstable + +pub static mut C: u32 = unsafe { C = 1; 0 }; +//~^ ERROR statements in statics are unstable + +pub static D: u32 = D; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/write-to-static-mut-in-static.stderr b/src/test/ui/compile-fail-migration/write-to-static-mut-in-static.stderr new file mode 100644 index 00000000000..f07d240746f --- /dev/null +++ b/src/test/ui/compile-fail-migration/write-to-static-mut-in-static.stderr @@ -0,0 +1,19 @@ +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/write-to-static-mut-in-static.rs:14:33 + | +LL | pub static mut B: () = unsafe { A = 1; }; + | ^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error[E0658]: statements in statics are unstable (see issue #48821) + --> $DIR/write-to-static-mut-in-static.rs:17:34 + | +LL | pub static mut C: u32 = unsafe { C = 1; 0 }; + | ^^^^^ + | + = help: add #![feature(const_let)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/writing-to-immutable-vec.nll.stderr b/src/test/ui/compile-fail-migration/writing-to-immutable-vec.nll.stderr new file mode 100644 index 00000000000..96899276b97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/writing-to-immutable-vec.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable + --> $DIR/writing-to-immutable-vec.rs:14:5 + | +LL | let v: Vec = vec![1, 2, 3]; + | - help: consider changing this to be mutable: `mut v` +LL | v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable + | ^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/writing-to-immutable-vec.rs b/src/test/ui/compile-fail-migration/writing-to-immutable-vec.rs new file mode 100644 index 00000000000..f289b85992e --- /dev/null +++ b/src/test/ui/compile-fail-migration/writing-to-immutable-vec.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn main() { + let v: Vec = vec![1, 2, 3]; + v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable +} diff --git a/src/test/ui/compile-fail-migration/writing-to-immutable-vec.stderr b/src/test/ui/compile-fail-migration/writing-to-immutable-vec.stderr new file mode 100644 index 00000000000..07e17797139 --- /dev/null +++ b/src/test/ui/compile-fail-migration/writing-to-immutable-vec.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable local variable `v` as mutable + --> $DIR/writing-to-immutable-vec.rs:14:5 + | +LL | let v: Vec = vec![1, 2, 3]; + | - consider changing this to `mut v` +LL | v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable + | ^ cannot borrow mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/wrong-mul-method-signature.rs b/src/test/ui/compile-fail-migration/wrong-mul-method-signature.rs new file mode 100644 index 00000000000..069fd2dec99 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wrong-mul-method-signature.rs @@ -0,0 +1,79 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test is to make sure we don't just ICE if the trait +// method for an operator is not implemented properly. +// (In this case the mul method should take &f64 and not f64) +// See: #11450 + +use std::ops::Mul; + +struct Vec1 { + x: f64 +} + +// Expecting value in input signature +impl Mul for Vec1 { + type Output = Vec1; + + fn mul(self, s: &f64) -> Vec1 { + //~^ ERROR method `mul` has an incompatible type for trait + Vec1 { + x: self.x * *s + } + } +} + +struct Vec2 { + x: f64, + y: f64 +} + +// Wrong type parameter ordering +impl Mul for Vec2 { + type Output = f64; + + fn mul(self, s: f64) -> Vec2 { + //~^ ERROR method `mul` has an incompatible type for trait + Vec2 { + x: self.x * s, + y: self.y * s + } + } +} + +struct Vec3 { + x: f64, + y: f64, + z: f64 +} + +// Unexpected return type +impl Mul for Vec3 { + type Output = i32; + + fn mul(self, s: f64) -> f64 { + //~^ ERROR method `mul` has an incompatible type for trait + s + } +} + +pub fn main() { + // Check that the usage goes from the trait declaration: + + let x: Vec1 = Vec1 { x: 1.0 } * 2.0; // this is OK + + let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order + // (we no longer signal a compile error here, since the + // error in the trait signature will cause compilation to + // abort before we bother looking at function bodies.) + + let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0; +} diff --git a/src/test/ui/compile-fail-migration/wrong-mul-method-signature.stderr b/src/test/ui/compile-fail-migration/wrong-mul-method-signature.stderr new file mode 100644 index 00000000000..7c4d22c7cca --- /dev/null +++ b/src/test/ui/compile-fail-migration/wrong-mul-method-signature.stderr @@ -0,0 +1,30 @@ +error[E0053]: method `mul` has an incompatible type for trait + --> $DIR/wrong-mul-method-signature.rs:26:5 + | +LL | fn mul(self, s: &f64) -> Vec1 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found &f64 + | + = note: expected type `fn(Vec1, f64) -> Vec1` + found type `fn(Vec1, &f64) -> Vec1` + +error[E0053]: method `mul` has an incompatible type for trait + --> $DIR/wrong-mul-method-signature.rs:43:5 + | +LL | fn mul(self, s: f64) -> Vec2 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Vec2`, found f64 + | + = note: expected type `fn(Vec2, Vec2) -> f64` + found type `fn(Vec2, f64) -> Vec2` + +error[E0053]: method `mul` has an incompatible type for trait + --> $DIR/wrong-mul-method-signature.rs:62:5 + | +LL | fn mul(self, s: f64) -> f64 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found f64 + | + = note: expected type `fn(Vec3, f64) -> i32` + found type `fn(Vec3, f64) -> f64` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/src/test/ui/compile-fail-migration/wrong-ret-type.rs b/src/test/ui/compile-fail-migration/wrong-ret-type.rs new file mode 100644 index 00000000000..6db11fcffd2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wrong-ret-type.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: mismatched types +fn mk_int() -> usize { let i: isize = 3; return i; } +fn main() { } diff --git a/src/test/ui/compile-fail-migration/wrong-ret-type.stderr b/src/test/ui/compile-fail-migration/wrong-ret-type.stderr new file mode 100644 index 00000000000..4ff6f707603 --- /dev/null +++ b/src/test/ui/compile-fail-migration/wrong-ret-type.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/wrong-ret-type.rs:12:49 + | +LL | fn mk_int() -> usize { let i: isize = 3; return i; } + | ^ expected usize, found isize + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/xc-private-method.rs b/src/test/ui/compile-fail-migration/xc-private-method.rs new file mode 100644 index 00000000000..edc0e31040d --- /dev/null +++ b/src/test/ui/compile-fail-migration/xc-private-method.rs @@ -0,0 +1,21 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:xc_private_method_lib.rs + +extern crate xc_private_method_lib; + +fn main() { + let _ = xc_private_method_lib::Struct::static_meth_struct(); + //~^ ERROR: method `static_meth_struct` is private + + let _ = xc_private_method_lib::Enum::static_meth_enum(); + //~^ ERROR: method `static_meth_enum` is private +} diff --git a/src/test/ui/compile-fail-migration/xc-private-method.stderr b/src/test/ui/compile-fail-migration/xc-private-method.stderr new file mode 100644 index 00000000000..35078e73d46 --- /dev/null +++ b/src/test/ui/compile-fail-migration/xc-private-method.stderr @@ -0,0 +1,15 @@ +error[E0624]: method `static_meth_struct` is private + --> $DIR/xc-private-method.rs:16:13 + | +LL | let _ = xc_private_method_lib::Struct::static_meth_struct(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0624]: method `static_meth_enum` is private + --> $DIR/xc-private-method.rs:19:13 + | +LL | let _ = xc_private_method_lib::Enum::static_meth_enum(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/xc-private-method2.rs b/src/test/ui/compile-fail-migration/xc-private-method2.rs new file mode 100644 index 00000000000..26e055d7cbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/xc-private-method2.rs @@ -0,0 +1,21 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:xc_private_method_lib.rs + +extern crate xc_private_method_lib; + +fn main() { + let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); + //~^ ERROR method `meth_struct` is private + + let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum(); + //~^ ERROR method `meth_enum` is private +} diff --git a/src/test/ui/compile-fail-migration/xc-private-method2.stderr b/src/test/ui/compile-fail-migration/xc-private-method2.stderr new file mode 100644 index 00000000000..d671aa35817 --- /dev/null +++ b/src/test/ui/compile-fail-migration/xc-private-method2.stderr @@ -0,0 +1,15 @@ +error[E0624]: method `meth_struct` is private + --> $DIR/xc-private-method2.rs:16:52 + | +LL | let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); + | ^^^^^^^^^^^ + +error[E0624]: method `meth_enum` is private + --> $DIR/xc-private-method2.rs:19:55 + | +LL | let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum(); + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/xcrate-private-by-default.rs b/src/test/ui/compile-fail-migration/xcrate-private-by-default.rs new file mode 100644 index 00000000000..7dd4d970945 --- /dev/null +++ b/src/test/ui/compile-fail-migration/xcrate-private-by-default.rs @@ -0,0 +1,55 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:static_priv_by_default.rs + +extern crate static_priv_by_default; + +fn foo() {} + +fn main() { + // Actual public items should be public + static_priv_by_default::a; + static_priv_by_default::b; + static_priv_by_default::c; + foo::(); + foo::(); + + // publicly re-exported items should be available + static_priv_by_default::bar::e; + static_priv_by_default::bar::f; + static_priv_by_default::bar::g; + foo::(); + foo::(); + + // private items at the top should be inaccessible + static_priv_by_default::j; + //~^ ERROR: static `j` is private + static_priv_by_default::k; + //~^ ERROR: function `k` is private + static_priv_by_default::l; + //~^ ERROR: struct `l` is private + foo::(); + //~^ ERROR: enum `m` is private + foo::(); + //~^ ERROR: type alias `n` is private + + // public items in a private mod should be inaccessible + static_priv_by_default::foo::a; + //~^ ERROR: module `foo` is private + static_priv_by_default::foo::b; + //~^ ERROR: module `foo` is private + static_priv_by_default::foo::c; + //~^ ERROR: module `foo` is private + foo::(); + //~^ ERROR: module `foo` is private + foo::(); + //~^ ERROR: module `foo` is private +} diff --git a/src/test/ui/compile-fail-migration/xcrate-private-by-default.stderr b/src/test/ui/compile-fail-migration/xcrate-private-by-default.stderr new file mode 100644 index 00000000000..c4560b9ca77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/xcrate-private-by-default.stderr @@ -0,0 +1,63 @@ +error[E0603]: static `j` is private + --> $DIR/xcrate-private-by-default.rs:33:5 + | +LL | static_priv_by_default::j; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: function `k` is private + --> $DIR/xcrate-private-by-default.rs:35:5 + | +LL | static_priv_by_default::k; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: unit struct `l` is private + --> $DIR/xcrate-private-by-default.rs:37:5 + | +LL | static_priv_by_default::l; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: enum `m` is private + --> $DIR/xcrate-private-by-default.rs:39:11 + | +LL | foo::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: type alias `n` is private + --> $DIR/xcrate-private-by-default.rs:41:11 + | +LL | foo::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `foo` is private + --> $DIR/xcrate-private-by-default.rs:45:5 + | +LL | static_priv_by_default::foo::a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `foo` is private + --> $DIR/xcrate-private-by-default.rs:47:5 + | +LL | static_priv_by_default::foo::b; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `foo` is private + --> $DIR/xcrate-private-by-default.rs:49:5 + | +LL | static_priv_by_default::foo::c; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `foo` is private + --> $DIR/xcrate-private-by-default.rs:51:11 + | +LL | foo::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0603]: module `foo` is private + --> $DIR/xcrate-private-by-default.rs:53:11 + | +LL | foo::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/compile-fail-migration/xcrate-unit-struct.rs b/src/test/ui/compile-fail-migration/xcrate-unit-struct.rs new file mode 100644 index 00000000000..04af7133000 --- /dev/null +++ b/src/test/ui/compile-fail-migration/xcrate-unit-struct.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:xcrate_unit_struct.rs + +// Make sure that when we have cross-crate unit structs we don't accidentally +// make values out of cross-crate structs that aren't unit. + +extern crate xcrate_unit_struct; + +fn main() { + let _ = xcrate_unit_struct::StructWithFields; + //~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithFields` + let _ = xcrate_unit_struct::Struct; +} diff --git a/src/test/ui/compile-fail-migration/xcrate-unit-struct.stderr b/src/test/ui/compile-fail-migration/xcrate-unit-struct.stderr new file mode 100644 index 00000000000..9ee4cb3ba17 --- /dev/null +++ b/src/test/ui/compile-fail-migration/xcrate-unit-struct.stderr @@ -0,0 +1,9 @@ +error[E0423]: expected value, found struct `xcrate_unit_struct::StructWithFields` + --> $DIR/xcrate-unit-struct.rs:19:13 + | +LL | let _ = xcrate_unit_struct::StructWithFields; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ did you mean `xcrate_unit_struct::StructWithFields { /* fields */ }`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0423`. -- cgit 1.4.1-3-g733a5

{} - -pub trait Bar { - type Output: 'static; -} - -impl Foo for i32 { } - -impl Foo for A { } - -impl Bar for i32 { - type Output = u32; -} - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/coherence-tuple-conflict.rs b/src/test/compile-fail/coherence-tuple-conflict.rs deleted file mode 100644 index 7807f93df1a..00000000000 --- a/src/test/compile-fail/coherence-tuple-conflict.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; -use std::default::Default; - -// Test that a blank impl for all T conflicts with an impl for some -// specific T. - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for (T,T) { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for (A,B) { //~ ERROR E0119 - fn get(&self) -> usize { self.dummy } -} - -fn main() { } diff --git a/src/test/compile-fail/coherence-vec-local-2.rs b/src/test/compile-fail/coherence-vec-local-2.rs deleted file mode 100644 index 196c2f4ee3c..00000000000 --- a/src/test/compile-fail/coherence-vec-local-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a local, generic type appearing within a -// *non-fundamental* remote type like `Vec` is not considered local. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Local(T); - -impl Remote for Vec> { } //~ ERROR E0210 - -fn main() { } diff --git a/src/test/compile-fail/coherence-vec-local.rs b/src/test/compile-fail/coherence-vec-local.rs deleted file mode 100644 index 49822dcfcb3..00000000000 --- a/src/test/compile-fail/coherence-vec-local.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a local type (with no type parameters) appearing within a -// *non-fundamental* remote type like `Vec` is not considered local. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Local; - -impl Remote for Vec { } //~ ERROR E0117 - -fn main() { } diff --git a/src/test/compile-fail/coherence_copy_like_err_fundamental_struct.rs b/src/test/compile-fail/coherence_copy_like_err_fundamental_struct.rs deleted file mode 100644 index 9fbb7aa4cb1..00000000000 --- a/src/test/compile-fail/coherence_copy_like_err_fundamental_struct.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// `MyFundamentalStruct` is declared fundamental, so we can test that -// -// MyFundamentalStruct: !MyTrait -// -// Huzzah. -impl MyTrait for lib::MyFundamentalStruct { } - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/coherence_copy_like_err_fundamental_struct_ref.rs b/src/test/compile-fail/coherence_copy_like_err_fundamental_struct_ref.rs deleted file mode 100644 index 2f6dca4f3c2..00000000000 --- a/src/test/compile-fail/coherence_copy_like_err_fundamental_struct_ref.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// `MyFundamentalStruct` is declared fundamental, so we can test that -// -// MyFundamentalStruct<&MyTrait>: !MyTrait -// -// Huzzah. -impl<'a> MyTrait for lib::MyFundamentalStruct<&'a MyType> { } - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/coherence_copy_like_err_fundamental_struct_tuple.rs b/src/test/compile-fail/coherence_copy_like_err_fundamental_struct_tuple.rs deleted file mode 100644 index f424e887201..00000000000 --- a/src/test/compile-fail/coherence_copy_like_err_fundamental_struct_tuple.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(rustc_attrs)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } - -impl MyTrait for T { } - -// Tuples are not fundamental. -impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/coherence_copy_like_err_struct.rs b/src/test/compile-fail/coherence_copy_like_err_struct.rs deleted file mode 100644 index 04262e65c5a..00000000000 --- a/src/test/compile-fail/coherence_copy_like_err_struct.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_copy_like_lib.rs - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// `MyStruct` is not declared fundamental, therefore this would -// require that -// -// MyStruct: !MyTrait -// -// which we cannot approve. -impl MyTrait for lib::MyStruct { } //~ ERROR E0119 - -fn main() { } diff --git a/src/test/compile-fail/coherence_copy_like_err_tuple.rs b/src/test/compile-fail/coherence_copy_like_err_tuple.rs deleted file mode 100644 index 378a70864f0..00000000000 --- a/src/test/compile-fail/coherence_copy_like_err_tuple.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// Tuples are not fundamental, therefore this would require that -// -// (MyType,): !MyTrait -// -// which we cannot approve. -impl MyTrait for (MyType,) { } //~ ERROR E0119 - -fn main() { } diff --git a/src/test/compile-fail/coherence_inherent.rs b/src/test/compile-fail/coherence_inherent.rs deleted file mode 100644 index 087b8c14e35..00000000000 --- a/src/test/compile-fail/coherence_inherent.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that methods that implement a trait cannot be invoked -// unless the trait is imported. - -mod Lib { - pub trait TheTrait { - fn the_fn(&self); - } - - pub struct TheStruct; - - impl TheTrait for TheStruct { - fn the_fn(&self) {} - } -} - -mod Import { - // Trait is in scope here: - use Lib::TheStruct; - use Lib::TheTrait; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); - } -} - -mod NoImport { - // Trait is not in scope here: - use Lib::TheStruct; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found - } -} - -fn main() {} diff --git a/src/test/compile-fail/coherence_inherent_cc.rs b/src/test/compile-fail/coherence_inherent_cc.rs deleted file mode 100644 index 442c4c89de4..00000000000 --- a/src/test/compile-fail/coherence_inherent_cc.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_inherent_cc_lib.rs - -// Tests that methods that implement a trait cannot be invoked -// unless the trait is imported. - -extern crate coherence_inherent_cc_lib; - -mod Import { - // Trait is in scope here: - use coherence_inherent_cc_lib::TheStruct; - use coherence_inherent_cc_lib::TheTrait; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); - } -} - -mod NoImport { - // Trait is not in scope here: - use coherence_inherent_cc_lib::TheStruct; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found - } -} - -fn main() {} diff --git a/src/test/compile-fail/coherence_local.rs b/src/test/compile-fail/coherence_local.rs deleted file mode 100644 index 551577b6b4e..00000000000 --- a/src/test/compile-fail/coherence_local.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// These are all legal because they are all fundamental types: - -impl lib::MyCopy for MyType { } -impl<'a> lib::MyCopy for &'a MyType { } -impl<'a> lib::MyCopy for &'a Box { } -impl lib::MyCopy for Box { } -impl lib::MyCopy for lib::MyFundamentalStruct { } -impl lib::MyCopy for lib::MyFundamentalStruct> { } - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/coherence_local_err_struct.rs b/src/test/compile-fail/coherence_local_err_struct.rs deleted file mode 100644 index 01f4c1cd8a5..00000000000 --- a/src/test/compile-fail/coherence_local_err_struct.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// These are all legal because they are all fundamental types: - -// MyStruct is not fundamental. -impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/coherence_local_err_tuple.rs b/src/test/compile-fail/coherence_local_err_tuple.rs deleted file mode 100644 index 590f68cee59..00000000000 --- a/src/test/compile-fail/coherence_local_err_tuple.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// These are all legal because they are all fundamental types: - -// Tuples are not fundamental, so this is not a local impl. -impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/coherence_local_ref.rs b/src/test/compile-fail/coherence_local_ref.rs deleted file mode 100644 index f6e1aab5976..00000000000 --- a/src/test/compile-fail/coherence_local_ref.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// naturally, legal -impl lib::MyCopy for MyType { } - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/compile_error_macro.rs b/src/test/compile-fail/compile_error_macro.rs deleted file mode 100644 index e9c5993098c..00000000000 --- a/src/test/compile-fail/compile_error_macro.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - compile_error!("a very descriptive error message"); //~ ERROR: a very descriptive error message -} diff --git a/src/test/compile-fail/concat.rs b/src/test/compile-fail/concat.rs deleted file mode 100644 index e29c6ac5d5e..00000000000 --- a/src/test/compile-fail/concat.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - concat!(b'f'); //~ ERROR: cannot concatenate a byte string literal - concat!(b"foo"); //~ ERROR: cannot concatenate a byte string literal - concat!(foo); //~ ERROR: expected a literal - concat!(foo()); //~ ERROR: expected a literal -} diff --git a/src/test/compile-fail/conflicting-repr-hints.rs b/src/test/compile-fail/conflicting-repr-hints.rs deleted file mode 100644 index 426f60c6b09..00000000000 --- a/src/test/compile-fail/conflicting-repr-hints.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![feature(repr_packed)] - -#[repr(C)] -enum A { A } - -#[repr(u64)] -enum B { B } - -#[repr(C, u64)] //~ WARNING conflicting representation hints -enum C { C } - -#[repr(u32, u64)] //~ WARNING conflicting representation hints -enum D { D } - -#[repr(C, packed)] -struct E(i32); - -#[repr(packed, align(8))] -struct F(i32); //~ ERROR type has conflicting packed and align representation hints - -#[repr(packed)] -#[repr(align(8))] -struct G(i32); //~ ERROR type has conflicting packed and align representation hints - -#[repr(align(8))] -#[repr(packed)] -struct H(i32); //~ ERROR type has conflicting packed and align representation hints - -#[repr(packed, packed(2))] -struct I(i32); //~ ERROR type has conflicting packed representation hints - -#[repr(packed(2))] -#[repr(packed)] -struct J(i32); //~ ERROR type has conflicting packed representation hints - -#[repr(packed, packed(1))] -struct K(i32); - -#[repr(packed, align(8))] -union X { //~ ERROR type has conflicting packed and align representation hints - i: i32 -} - -#[repr(packed)] -#[repr(align(8))] -union Y { //~ ERROR type has conflicting packed and align representation hints - i: i32 -} - -#[repr(align(8))] -#[repr(packed)] -union Z { //~ ERROR type has conflicting packed and align representation hints - i: i32 -} - -fn main() {} diff --git a/src/test/compile-fail/conservative_impl_trait.rs b/src/test/compile-fail/conservative_impl_trait.rs deleted file mode 100644 index 30895bce357..00000000000 --- a/src/test/compile-fail/conservative_impl_trait.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// #39872, #39553 - -fn will_ice(something: &u32) -> impl Iterator { - //~^ ERROR the trait bound `(): std::iter::Iterator` is not satisfied [E0277] -} - -fn main() {} diff --git a/src/test/compile-fail/const-array-oob-arith.rs b/src/test/compile-fail/const-array-oob-arith.rs deleted file mode 100644 index 9c07abdc36d..00000000000 --- a/src/test/compile-fail/const-array-oob-arith.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(const_indexing)] - -const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; -const IDX: usize = 3; -const VAL: i32 = ARR[IDX]; -const BONG: [i32; (ARR[0] - 41) as usize] = [5]; -const BLUB: [i32; (ARR[0] - 40) as usize] = [5]; //~ ERROR: mismatched types -const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99]; //~ ERROR: mismatched types - -fn main() { - let _ = VAL; -} diff --git a/src/test/compile-fail/const-array-oob.rs b/src/test/compile-fail/const-array-oob.rs deleted file mode 100644 index 22a3c5ceeb7..00000000000 --- a/src/test/compile-fail/const-array-oob.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#![feature(const_indexing)] - -const FOO: [usize; 3] = [1, 2, 3]; -const BAR: usize = FOO[5]; // no error, because the error below occurs before regular const eval - -const BLUB: [u32; FOO[4]] = [5, 6]; -//~^ ERROR could not evaluate constant expression [E0080] -//~| index out of bounds: the len is 3 but the index is 4 - -fn main() { - let _ = BAR; -} diff --git a/src/test/compile-fail/const-block-non-item-statement-2.rs b/src/test/compile-fail/const-block-non-item-statement-2.rs deleted file mode 100644 index f80d55cb342..00000000000 --- a/src/test/compile-fail/const-block-non-item-statement-2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -const A: usize = { 1; 2 }; -//~^ ERROR statements in constants are unstable - -const B: usize = { { } 2 }; -//~^ ERROR statements in constants are unstable - -macro_rules! foo { - () => (()) //~ ERROR statements in constants are unstable -} -const C: usize = { foo!(); 2 }; - -const D: usize = { let x = 4; 2 }; -//~^ ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable -//~| ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable - -pub fn main() {} diff --git a/src/test/compile-fail/const-block-non-item-statement-3.rs b/src/test/compile-fail/const-block-non-item-statement-3.rs deleted file mode 100644 index cfa4b778dde..00000000000 --- a/src/test/compile-fail/const-block-non-item-statement-3.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -type Array = [u32; { let x = 2; 5 }]; -//~^ ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable -//~| ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable - -pub fn main() {} diff --git a/src/test/compile-fail/const-block-non-item-statement.rs b/src/test/compile-fail/const-block-non-item-statement.rs deleted file mode 100644 index f974a24c26f..00000000000 --- a/src/test/compile-fail/const-block-non-item-statement.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Foo { - Bar = { let x = 1; 3 } - //~^ ERROR let bindings in constants are unstable - //~| ERROR statements in constants are unstable - //~| ERROR let bindings in constants are unstable - //~| ERROR statements in constants are unstable -} - -pub fn main() {} diff --git a/src/test/compile-fail/const-call.rs b/src/test/compile-fail/const-call.rs deleted file mode 100644 index 02264228a6b..00000000000 --- a/src/test/compile-fail/const-call.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f(x: usize) -> usize { - x -} - -fn main() { - let _ = [0; f(2)]; - //~^ ERROR calls in constants are limited to constant functions - //~| E0080 -} diff --git a/src/test/compile-fail/const-cast-different-types.rs b/src/test/compile-fail/const-cast-different-types.rs deleted file mode 100644 index 397804566b4..00000000000 --- a/src/test/compile-fail/const-cast-different-types.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static a: &'static str = "foo"; -static b: *const u8 = a as *const u8; //~ ERROR casting -static c: *const u8 = &a as *const u8; //~ ERROR casting - -fn main() { -} diff --git a/src/test/compile-fail/const-cast-wrong-type.rs b/src/test/compile-fail/const-cast-wrong-type.rs deleted file mode 100644 index b3597441834..00000000000 --- a/src/test/compile-fail/const-cast-wrong-type.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static a: [u8; 3] = ['h' as u8, 'i' as u8, 0 as u8]; -static b: *const i8 = &a as *const i8; //~ ERROR mismatched types - -fn main() { -} diff --git a/src/test/compile-fail/const-err-early.rs b/src/test/compile-fail/const-err-early.rs deleted file mode 100644 index 39b1b342eac..00000000000 --- a/src/test/compile-fail/const-err-early.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(const_err)] - -pub const A: i8 = -std::i8::MIN; //~ ERROR const_err -pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err -pub const C: u8 = 200u8 * 4; //~ ERROR const_err -pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err -pub const E: u8 = [5u8][1]; //~ ERROR const_err - -fn main() { - let _a = A; - let _b = B; - let _c = C; - let _d = D; - let _e = E; - let _e = [6u8][1]; -} diff --git a/src/test/compile-fail/const-err-multi.rs b/src/test/compile-fail/const-err-multi.rs deleted file mode 100644 index f2ee8a7078c..00000000000 --- a/src/test/compile-fail/const-err-multi.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(const_err)] - -pub const A: i8 = -std::i8::MIN; -//~^ ERROR this constant cannot be used -pub const B: i8 = A; -//~^ ERROR const_err -//~| ERROR const_err -pub const C: u8 = A as u8; -//~^ ERROR const_err -//~| ERROR const_err -pub const D: i8 = 50 - A; -//~^ ERROR const_err -//~| ERROR const_err - -fn main() { - let _ = (A, B, C, D); -} diff --git a/src/test/compile-fail/const-err.rs b/src/test/compile-fail/const-err.rs deleted file mode 100644 index 8683f6a0231..00000000000 --- a/src/test/compile-fail/const-err.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Zforce-overflow-checks=on - -// these errors are not actually "const_err", they occur in codegen/consts -// and are unconditional warnings that can't be denied or allowed - -#![allow(exceeding_bitshifts)] -#![allow(const_err)] - -fn black_box(_: T) { - unimplemented!() -} - -// Make sure that the two uses get two errors. -const FOO: u8 = [5u8][1]; -//~^ ERROR constant evaluation error -//~| index out of bounds: the len is 1 but the index is 1 - -fn main() { - black_box((FOO, FOO)); - //~^ ERROR referenced constant has errors - //~| ERROR could not evaluate constant -} diff --git a/src/test/compile-fail/const-err2.rs b/src/test/compile-fail/const-err2.rs deleted file mode 100644 index 9a5cb5a4a83..00000000000 --- a/src/test/compile-fail/const-err2.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// needed because negating int::MIN will behave differently between -// optimized compilation and unoptimized compilation and thus would -// lead to different lints being emitted -// compile-flags: -O - -#![feature(rustc_attrs)] -#![allow(exceeding_bitshifts)] -#![deny(const_err)] - -fn black_box(_: T) { - unimplemented!() -} - -fn main() { - let a = -std::i8::MIN; - //~^ ERROR const_err - let b = 200u8 + 200u8 + 200u8; - //~^ ERROR const_err - let c = 200u8 * 4; - //~^ ERROR const_err - let d = 42u8 - (42u8 + 1); - //~^ ERROR const_err - let _e = [5u8][1]; - //~^ ERROR const_err - black_box(a); - black_box(b); - black_box(c); - black_box(d); -} diff --git a/src/test/compile-fail/const-err3.rs b/src/test/compile-fail/const-err3.rs deleted file mode 100644 index f5e43b57e77..00000000000 --- a/src/test/compile-fail/const-err3.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![deny(const_err)] - -fn black_box(_: T) { - unimplemented!() -} - -fn main() { - let b = 200u8 + 200u8 + 200u8; - //~^ ERROR const_err - let c = 200u8 * 4; - //~^ ERROR const_err - let d = 42u8 - (42u8 + 1); - //~^ ERROR const_err - let _e = [5u8][1]; - //~^ ERROR const_err - black_box(b); - black_box(c); - black_box(d); -} diff --git a/src/test/compile-fail/const-err4.rs b/src/test/compile-fail/const-err4.rs deleted file mode 100644 index 10376d57809..00000000000 --- a/src/test/compile-fail/const-err4.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Copy, Clone)] -union Foo { - a: isize, - b: (), -} - -enum Bar { - Boo = [unsafe { Foo { b: () }.a }; 4][3], - //~^ ERROR could not evaluate enum discriminant -} - -fn main() { - assert_ne!(Bar::Boo as isize, 0); -} diff --git a/src/test/compile-fail/const-eval-overflow-3.rs b/src/test/compile-fail/const-eval-overflow-3.rs deleted file mode 100644 index d930cb77047..00000000000 --- a/src/test/compile-fail/const-eval-overflow-3.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Evaluation of constants in array-elem count goes through different -// compiler control-flow paths. -// -// This test is checking the count in an array expression. - -// FIXME (#23926): the error output is not consistent between a -// self-hosted and a cross-compiled setup; therefore resorting to -// error-pattern for now. - -// error-pattern: attempt to add with overflow - -#![allow(unused_imports)] - -use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - -const A_I8_I - : [u32; (i8::MAX as usize) + 1] - = [0; (i8::MAX + 1) as usize]; - -fn main() { - foo(&A_I8_I[..]); -} - -fn foo(x: T) { - println!("{:?}", x); -} diff --git a/src/test/compile-fail/const-eval-overflow-3b.rs b/src/test/compile-fail/const-eval-overflow-3b.rs deleted file mode 100644 index 719b21000f7..00000000000 --- a/src/test/compile-fail/const-eval-overflow-3b.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Evaluation of constants in array-elem count goes through different -// compiler control-flow paths. -// -// This test is checking the count in an array expression. -// -// This is a variation of another such test, but in this case the -// types for the left- and right-hand sides of the addition do not -// match (as well as overflow). - -// FIXME (#23926): the error output is not consistent between a -// self-hosted and a cross-compiled setup; therefore resorting to -// error-pattern for now. - -// error-pattern: mismatched types - -#![allow(unused_imports)] - -use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - -const A_I8_I - : [u32; (i8::MAX as usize) + 1] - = [0; (i8::MAX + 1u8) as usize]; - -fn main() { - foo(&A_I8_I[..]); -} - -fn foo(x: T) { - println!("{:?}", x); -} - diff --git a/src/test/compile-fail/const-eval-overflow-4b.rs b/src/test/compile-fail/const-eval-overflow-4b.rs deleted file mode 100644 index 6028df18839..00000000000 --- a/src/test/compile-fail/const-eval-overflow-4b.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Evaluation of constants in array-elem count goes through different -// compiler control-flow paths. -// -// This test is checking the count in an array type. - -#![allow(unused_imports)] - -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - -const A_I8_T - : [u32; (i8::MAX as i8 + 1u8) as usize] - //~^ ERROR mismatched types - //~| expected i8, found u8 - //~| ERROR cannot add `u8` to `i8` - = [0; (i8::MAX as usize) + 1]; - - -const A_CHAR_USIZE - : [u32; 5u8 as char as usize] - = [0; 5]; - - -const A_BAD_CHAR_USIZE - : [u32; 5i8 as char as usize] - //~^ ERROR only `u8` can be cast as `char`, not `i8` - = [0; 5]; - -fn main() {} diff --git a/src/test/compile-fail/const-eval-overflow2.rs b/src/test/compile-fail/const-eval-overflow2.rs deleted file mode 100644 index 88fc5182775..00000000000 --- a/src/test/compile-fail/const-eval-overflow2.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_imports)] - -// Note: the relevant lint pass here runs before some of the constant -// evaluation below (e.g. that performed by codegen and llvm), so if you -// change this warn to a deny, then the compiler will exit before -// those errors are detected. - -#![deny(const_err)] - -use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - -const VALS_I8: (i8,) = - //~^ ERROR this constant cannot be used - ( - i8::MIN - 1, - ); - -const VALS_I16: (i16,) = - //~^ ERROR this constant cannot be used - ( - i16::MIN - 1, - ); - -const VALS_I32: (i32,) = - //~^ ERROR this constant cannot be used - ( - i32::MIN - 1, - ); - -const VALS_I64: (i64,) = - //~^ ERROR this constant cannot be used - ( - i64::MIN - 1, - ); - -const VALS_U8: (u8,) = - //~^ ERROR this constant cannot be used - ( - u8::MIN - 1, - ); - -const VALS_U16: (u16,) = ( - //~^ ERROR this constant cannot be used - u16::MIN - 1, - ); - -const VALS_U32: (u32,) = ( - //~^ ERROR this constant cannot be used - u32::MIN - 1, - ); - -const VALS_U64: (u64,) = - //~^ ERROR this constant cannot be used - ( - u64::MIN - 1, - ); - -fn main() { - foo(VALS_I8); - foo(VALS_I16); - foo(VALS_I32); - foo(VALS_I64); - - foo(VALS_U8); - foo(VALS_U16); - foo(VALS_U32); - foo(VALS_U64); -} - -fn foo(_: T) { -} diff --git a/src/test/compile-fail/const-eval-overflow2b.rs b/src/test/compile-fail/const-eval-overflow2b.rs deleted file mode 100644 index 1878daea931..00000000000 --- a/src/test/compile-fail/const-eval-overflow2b.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_imports)] - -// Note: the relevant lint pass here runs before some of the constant -// evaluation below (e.g. that performed by codegen and llvm), so if you -// change this warn to a deny, then the compiler will exit before -// those errors are detected. - -#![deny(const_err)] - -use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - -const VALS_I8: (i8,) = - //~^ ERROR this constant cannot be used - ( - i8::MAX + 1, - ); - -const VALS_I16: (i16,) = - //~^ ERROR this constant cannot be used - ( - i16::MAX + 1, - ); - -const VALS_I32: (i32,) = - //~^ ERROR this constant cannot be used - ( - i32::MAX + 1, - ); - -const VALS_I64: (i64,) = - //~^ ERROR this constant cannot be used - ( - i64::MAX + 1, - ); - -const VALS_U8: (u8,) = - //~^ ERROR this constant cannot be used - ( - u8::MAX + 1, - ); - -const VALS_U16: (u16,) = ( - //~^ ERROR this constant cannot be used - u16::MAX + 1, - ); - -const VALS_U32: (u32,) = ( - //~^ ERROR this constant cannot be used - u32::MAX + 1, - ); - -const VALS_U64: (u64,) = - //~^ ERROR this constant cannot be used - ( - u64::MAX + 1, - ); - -fn main() { - foo(VALS_I8); - foo(VALS_I16); - foo(VALS_I32); - foo(VALS_I64); - - foo(VALS_U8); - foo(VALS_U16); - foo(VALS_U32); - foo(VALS_U64); -} - -fn foo(_: T) { -} diff --git a/src/test/compile-fail/const-eval-overflow2c.rs b/src/test/compile-fail/const-eval-overflow2c.rs deleted file mode 100644 index f3d28295bf8..00000000000 --- a/src/test/compile-fail/const-eval-overflow2c.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_imports)] - -// Note: the relevant lint pass here runs before some of the constant -// evaluation below (e.g. that performed by codegen and llvm), so if you -// change this warn to a deny, then the compiler will exit before -// those errors are detected. - -#![deny(const_err)] - -use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - -const VALS_I8: (i8,) = - //~^ ERROR this constant cannot be used - ( - i8::MIN * 2, - ); - -const VALS_I16: (i16,) = - //~^ ERROR this constant cannot be used - ( - i16::MIN * 2, - ); - -const VALS_I32: (i32,) = - //~^ ERROR this constant cannot be used - ( - i32::MIN * 2, - ); - -const VALS_I64: (i64,) = - //~^ ERROR this constant cannot be used - ( - i64::MIN * 2, - ); - -const VALS_U8: (u8,) = - //~^ ERROR this constant cannot be used - ( - u8::MAX * 2, - ); - -const VALS_U16: (u16,) = ( - //~^ ERROR this constant cannot be used - u16::MAX * 2, - ); - -const VALS_U32: (u32,) = ( - //~^ ERROR this constant cannot be used - u32::MAX * 2, - ); - -const VALS_U64: (u64,) = - //~^ ERROR this constant cannot be used - ( - u64::MAX * 2, - ); - -fn main() { - foo(VALS_I8); - foo(VALS_I16); - foo(VALS_I32); - foo(VALS_I64); - - foo(VALS_U8); - foo(VALS_U16); - foo(VALS_U32); - foo(VALS_U64); -} - -fn foo(_: T) { -} diff --git a/src/test/compile-fail/const-fn-destructuring-arg.rs b/src/test/compile-fail/const-fn-destructuring-arg.rs deleted file mode 100644 index fce1688716d..00000000000 --- a/src/test/compile-fail/const-fn-destructuring-arg.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// test that certain things are disallowed in constant functions - -#![feature(const_fn)] - -// no destructuring -const fn i(( - a, - //~^ ERROR arguments of constant functions can only be immutable by-value bindings - b - //~^ ERROR arguments of constant functions can only be immutable by-value bindings - ): (u32, u32)) -> u32 { - a + b - //~^ ERROR let bindings in constant functions are unstable - //~| ERROR let bindings in constant functions are unstable -} - -fn main() {} diff --git a/src/test/compile-fail/const-fn-not-safe-for-const.rs b/src/test/compile-fail/const-fn-not-safe-for-const.rs deleted file mode 100644 index 341cc7bb491..00000000000 --- a/src/test/compile-fail/const-fn-not-safe-for-const.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can't call random fns in a const fn or do other bad things. - -#![feature(const_fn)] - -use std::mem::transmute; - -fn random() -> u32 { 0 } - -const fn sub(x: &u32) -> usize { - unsafe { transmute(x) } //~ ERROR E0015 -} - -const fn sub1() -> u32 { - random() //~ ERROR E0015 -} - -static Y: u32 = 0; - -const fn get_Y() -> u32 { - Y - //~^ ERROR E0013 -} - -const fn get_Y_addr() -> &'static u32 { - &Y - //~^ ERROR E0013 -} - -const fn get() -> u32 { - let x = 22; - //~^ ERROR let bindings in constant functions are unstable - //~| ERROR statements in constant functions are unstable - let y = 44; - //~^ ERROR let bindings in constant functions are unstable - //~| ERROR statements in constant functions are unstable - x + y - //~^ ERROR let bindings in constant functions are unstable - //~| ERROR let bindings in constant functions are unstable -} - -fn main() {} diff --git a/src/test/compile-fail/const-fn-stability-calls-3.rs b/src/test/compile-fail/const-fn-stability-calls-3.rs deleted file mode 100644 index 0f413b0bbc1..00000000000 --- a/src/test/compile-fail/const-fn-stability-calls-3.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test use of const fn from another crate without a feature gate. - -#![feature(rustc_attrs)] -#![allow(unused_variables)] - -// aux-build:const_fn_lib.rs - -extern crate const_fn_lib; - -use const_fn_lib::foo; - -#[rustc_error] -fn main() { //~ ERROR compilation successful - let x = foo(); // use outside a constant is ok -} diff --git a/src/test/compile-fail/const-integer-bool-ops.rs b/src/test/compile-fail/const-integer-bool-ops.rs deleted file mode 100644 index 29bc665a22e..00000000000 --- a/src/test/compile-fail/const-integer-bool-ops.rs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -const X: usize = 42 && 39; -//~^ ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected usize, found bool -const ARR: [i32; X] = [99; 34]; - -const X1: usize = 42 || 39; -//~^ ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected usize, found bool -const ARR1: [i32; X1] = [99; 47]; - -const X2: usize = -42 || -39; -//~^ ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected usize, found bool -const ARR2: [i32; X2] = [99; 18446744073709551607]; - -const X3: usize = -42 && -39; -//~^ ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected usize, found bool -const ARR3: [i32; X3] = [99; 6]; - -const Y: usize = 42.0 == 42.0; -//~^ ERROR mismatched types -//~| expected usize, found bool -const ARRR: [i32; Y] = [99; 1]; - -const Y1: usize = 42.0 >= 42.0; -//~^ ERROR mismatched types -//~| expected usize, found bool -const ARRR1: [i32; Y1] = [99; 1]; - -const Y2: usize = 42.0 <= 42.0; -//~^ ERROR mismatched types -//~| expected usize, found bool -const ARRR2: [i32; Y2] = [99; 1]; - -const Y3: usize = 42.0 > 42.0; -//~^ ERROR mismatched types -//~| expected usize, found bool -const ARRR3: [i32; Y3] = [99; 0]; - -const Y4: usize = 42.0 < 42.0; -//~^ ERROR mismatched types -//~| expected usize, found bool -const ARRR4: [i32; Y4] = [99; 0]; - -const Y5: usize = 42.0 != 42.0; -//~^ ERROR mismatched types -//~| expected usize, found bool -const ARRR5: [i32; Y5] = [99; 0]; - -fn main() { - let _ = ARR; - let _ = ARRR; - let _ = ARRR1; - let _ = ARRR2; - let _ = ARRR3; - let _ = ARRR4; - let _ = ARRR5; -} diff --git a/src/test/compile-fail/const-len-underflow-subspans.rs b/src/test/compile-fail/const-len-underflow-subspans.rs deleted file mode 100644 index 054c272a3d3..00000000000 --- a/src/test/compile-fail/const-len-underflow-subspans.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that a constant-evaluation underflow highlights the correct -// spot (where the underflow occurred). - -const ONE: usize = 1; -const TWO: usize = 2; - -fn main() { - let a: [i8; ONE - TWO] = unimplemented!(); - //~^ ERROR could not evaluate constant expression - //~| attempt to subtract with overflow -} diff --git a/src/test/compile-fail/const-match-check.rs b/src/test/compile-fail/const-match-check.rs deleted file mode 100644 index 304eef7847c..00000000000 --- a/src/test/compile-fail/const-match-check.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: matchck eval1 eval2 - -#[cfg(matchck)] -const X: i32 = { let 0 = 0; 0 }; -//[matchck]~^ ERROR refutable pattern in local binding - -#[cfg(matchck)] -static Y: i32 = { let 0 = 0; 0 }; -//[matchck]~^ ERROR refutable pattern in local binding - -#[cfg(matchck)] -trait Bar { - const X: i32 = { let 0 = 0; 0 }; - //[matchck]~^ ERROR refutable pattern in local binding -} - -#[cfg(matchck)] -impl Bar for () { - const X: i32 = { let 0 = 0; 0 }; - //[matchck]~^ ERROR refutable pattern in local binding -} - -#[cfg(eval1)] -enum Foo { - A = { let 0 = 0; 0 }, - //[eval1]~^ ERROR refutable pattern in local binding -} - -fn main() { - #[cfg(eval2)] - let x: [i32; { let 0 = 0; 0 }] = []; - //[eval2]~^ ERROR refutable pattern in local binding -} diff --git a/src/test/compile-fail/const-match-pattern-arm.rs b/src/test/compile-fail/const-match-pattern-arm.rs deleted file mode 100644 index bc944948f3d..00000000000 --- a/src/test/compile-fail/const-match-pattern-arm.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(warnings)] - -const x: bool = match Some(true) { - Some(value) => true, - //~^ ERROR: constant contains unimplemented expression type [E0019] - _ => false -}; - -const y: bool = { - match Some(true) { - Some(value) => true, - //~^ ERROR: constant contains unimplemented expression type [E0019] - _ => false - } -}; - -fn main() {} diff --git a/src/test/compile-fail/const-size_of-cycle.rs b/src/test/compile-fail/const-size_of-cycle.rs deleted file mode 100644 index fed8e1885de..00000000000 --- a/src/test/compile-fail/const-size_of-cycle.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: cycle detected - -#![feature(const_fn)] - -struct Foo { - bytes: [u8; std::mem::size_of::()] -} - -fn main() {} diff --git a/src/test/compile-fail/const-slice-oob.rs b/src/test/compile-fail/const-slice-oob.rs deleted file mode 100644 index 6d51ff30998..00000000000 --- a/src/test/compile-fail/const-slice-oob.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[deny(const_err)] - -const FOO: &'static[u32] = &[1, 2, 3]; -const BAR: u32 = FOO[5]; -//~^ index out of bounds: the len is 3 but the index is 5 -//~| ERROR this constant cannot be used - -fn main() { - let _ = BAR; -} diff --git a/src/test/compile-fail/const-tup-index-span.rs b/src/test/compile-fail/const-tup-index-span.rs deleted file mode 100644 index b42c440f87d..00000000000 --- a/src/test/compile-fail/const-tup-index-span.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test spans of errors - -const TUP: (usize,) = 5usize << 64; -//~^ ERROR mismatched types -//~| expected tuple, found usize -const ARR: [i32; TUP.0] = []; - -fn main() { -} diff --git a/src/test/compile-fail/const-typeid-of.rs b/src/test/compile-fail/const-typeid-of.rs deleted file mode 100644 index 401125cef09..00000000000 --- a/src/test/compile-fail/const-typeid-of.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::any::TypeId; - -struct A; - -fn main() { - const A_ID: TypeId = TypeId::of::(); - //~^ ERROR `std::any::TypeId::of` is not yet stable as a const fn -} diff --git a/src/test/compile-fail/constructor-lifetime-args.rs b/src/test/compile-fail/constructor-lifetime-args.rs deleted file mode 100644 index 50db9707355..00000000000 --- a/src/test/compile-fail/constructor-lifetime-args.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// All lifetime parameters in struct constructors are currently considered early bound, -// i.e. `S::` is interpreted kinda like an associated item `S::::ctor`. -// This behavior is a bit weird, because if equivalent constructor were written manually -// it would get late bound lifetime parameters. -// Variant constructors behave in the same way, lifetime parameters are considered -// belonging to the enum and being early bound. -// https://github.com/rust-lang/rust/issues/30904 - -struct S<'a, 'b>(&'a u8, &'b u8); -enum E<'a, 'b> { - V(&'a u8), - U(&'b u8), -} - -fn main() { - S(&0, &0); // OK - S::<'static>(&0, &0); - //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter - S::<'static, 'static, 'static>(&0, &0); - //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters - E::V(&0); // OK - E::V::<'static>(&0); - //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter - E::V::<'static, 'static, 'static>(&0); - //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters -} diff --git a/src/test/compile-fail/copy-a-resource.rs b/src/test/compile-fail/copy-a-resource.rs deleted file mode 100644 index 70633c92e64..00000000000 --- a/src/test/compile-fail/copy-a-resource.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Debug)] -struct foo { - i: isize, -} - -impl Drop for foo { - fn drop(&mut self) {} -} - -fn foo(i:isize) -> foo { - foo { - i: i - } -} - -fn main() { - let x = foo(10); - let _y = x.clone(); - //~^ ERROR no method named `clone` found - println!("{:?}", x); -} diff --git a/src/test/compile-fail/crate-name-mismatch.rs b/src/test/compile-fail/crate-name-mismatch.rs deleted file mode 100644 index 589c0beb760..00000000000 --- a/src/test/compile-fail/crate-name-mismatch.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --crate-name foo - -#![crate_name = "bar"] -//~^ ERROR: --crate-name and #[crate_name] are required to match, but `foo` != `bar` - -fn main() {} diff --git a/src/test/compile-fail/crateresolve1.rs b/src/test/compile-fail/crateresolve1.rs deleted file mode 100644 index 8c3dbda6802..00000000000 --- a/src/test/compile-fail/crateresolve1.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:crateresolve1-1.rs -// aux-build:crateresolve1-2.rs -// aux-build:crateresolve1-3.rs -// error-pattern:multiple matching crates for `crateresolve1` - -extern crate crateresolve1; - -fn main() { -} diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs deleted file mode 100644 index 7c76cf475d2..00000000000 --- a/src/test/compile-fail/cross-borrow-trait.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that cross-borrowing (implicitly converting from `Box` to `&T`) is -// forbidden when `T` is a trait. - -struct Foo; -trait Trait { fn foo(&self) {} } -impl Trait for Foo {} - -pub fn main() { - let x: Box = Box::new(Foo); - let _y: &Trait = x; //~ ERROR E0308 - //~| expected type `&dyn Trait` - //~| found type `std::boxed::Box` -} diff --git a/src/test/compile-fail/cross-fn-cache-hole.rs b/src/test/compile-fail/cross-fn-cache-hole.rs deleted file mode 100644 index d437fc019fd..00000000000 --- a/src/test/compile-fail/cross-fn-cache-hole.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that when there are vacuous predicates in the environment -// (which make a fn uncallable) we don't erroneously cache those and -// then consider them satisfied elsewhere. The current technique for -// doing this is to not use global caches when there is a chance that -// the environment contains such a predicate. -// We still error for `i32: Bar` pending #48214 - -trait Foo: Bar { -} - -trait Bar { } - -// We don't always check where clauses for sanity, but in this case -// wfcheck does report an error here: -fn vacuous() //~ ERROR the trait bound `i32: Bar` is not satisfied - where i32: Foo -{ - // ... the original intention was to check that we don't use that - // vacuous where clause (which could never be satisfied) to accept - // the following line and then mess up calls elsewhere. - require::(); -} - -fn require() - where A: Bar -{ -} - -fn main() { - require::(); -} diff --git a/src/test/compile-fail/custom_attribute.rs b/src/test/compile-fail/custom_attribute.rs deleted file mode 100644 index eff734230ee..00000000000 --- a/src/test/compile-fail/custom_attribute.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(stmt_expr_attributes)] - -#[foo] //~ ERROR The attribute `foo` -fn main() { - #[foo] //~ ERROR The attribute `foo` - let x = (); - #[foo] //~ ERROR The attribute `foo` - x -} diff --git a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs b/src/test/compile-fail/cycle-projection-based-on-where-clause.rs deleted file mode 100644 index 56ad1771e00..00000000000 --- a/src/test/compile-fail/cycle-projection-based-on-where-clause.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Example cycle where a bound on `T` uses a shorthand for `T`. This -// creates a cycle because we have to know the bounds on `T` to figure -// out what trait defines `Item`, but we can't know the bounds on `T` -// without knowing how to handle `T::Item`. -// -// Note that in the future cases like this could perhaps become legal, -// if we got more fine-grained about our cycle detection or changed -// how we handle `T::Item` resolution. - -use std::ops::Add; - -// Preamble. -trait Trait { type Item; } - -struct A - where T : Trait, - T : Add - //~^ ERROR cycle detected - //~| ERROR associated type `Item` not found for `T` -{ - data: T -} - -fn main() { -} diff --git a/src/test/compile-fail/cycle-trait-default-type-trait.rs b/src/test/compile-fail/cycle-trait-default-type-trait.rs deleted file mode 100644 index b8bae215456..00000000000 --- a/src/test/compile-fail/cycle-trait-default-type-trait.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a cycle where a type parameter on a trait has a default that -// again references the trait. - -trait Foo> { - //~^ ERROR cycle detected -} - -fn main() { } diff --git a/src/test/compile-fail/cycle-trait-supertrait-direct.rs b/src/test/compile-fail/cycle-trait-supertrait-direct.rs deleted file mode 100644 index b802463fcb0..00000000000 --- a/src/test/compile-fail/cycle-trait-supertrait-direct.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a supertrait cycle where a trait extends itself. - -trait Chromosome: Chromosome { - //~^ ERROR cycle detected -} - -fn main() { } diff --git a/src/test/compile-fail/dead-code-closure-bang.rs b/src/test/compile-fail/dead-code-closure-bang.rs deleted file mode 100644 index d808d797272..00000000000 --- a/src/test/compile-fail/dead-code-closure-bang.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test FIXME(#20574) - -#![deny(unreachable_code)] - -fn main() { - let x = || panic!(); - x(); - println!("Foo bar"); //~ ERROR: unreachable statement -} diff --git a/src/test/compile-fail/dead-code-ret.rs b/src/test/compile-fail/dead-code-ret.rs deleted file mode 100644 index 250d22db374..00000000000 --- a/src/test/compile-fail/dead-code-ret.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: unreachable statement - -#![deny(unreachable_code)] - -fn main() { - return; - println!("Paul is dead"); -} diff --git a/src/test/compile-fail/defaulted-never-note.rs b/src/test/compile-fail/defaulted-never-note.rs deleted file mode 100644 index ac8ac85824e..00000000000 --- a/src/test/compile-fail/defaulted-never-note.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// We need to opt inot the `!` feature in order to trigger the -// requirement that this is testing. -#![feature(never_type)] - -#![allow(unused)] - -trait Deserialize: Sized { - fn deserialize() -> Result; -} - -impl Deserialize for () { - fn deserialize() -> Result<(), String> { - Ok(()) - } -} - -trait ImplementedForUnitButNotNever {} - -impl ImplementedForUnitButNotNever for () {} - -fn foo(_t: T) {} -//~^ NOTE required by `foo` - -fn smeg() { - let _x = return; - foo(_x); - //~^ ERROR the trait bound - //~| NOTE the trait `ImplementedForUnitButNotNever` is not implemented - //~| NOTE the trait is implemented for `()` -} - -fn main() { - smeg(); -} - diff --git a/src/test/compile-fail/dep-graph-assoc-type-codegen.rs b/src/test/compile-fail/dep-graph-assoc-type-codegen.rs deleted file mode 100644 index c20cfbc7e23..00000000000 --- a/src/test/compile-fail/dep-graph-assoc-type-codegen.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that when a trait impl changes, fns whose body uses that trait -// must also be recompiled. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(warnings)] - -fn main() { } - -pub trait Foo: Sized { - type T; - fn method(self) { } -} - -mod x { - use Foo; - - #[rustc_if_this_changed] - impl Foo for char { type T = char; } - - impl Foo for u32 { type T = u32; } -} - -mod y { - use Foo; - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - pub fn use_char_assoc() { - // Careful here: in the representation, ::T gets - // normalized away, so at a certain point we had no edge to - // codegen. (But now codegen just depends on typeck.) - let x: ::T = 'a'; - } - - pub fn take_foo(t: T) { } -} diff --git a/src/test/compile-fail/dep-graph-caller-callee.rs b/src/test/compile-fail/dep-graph-caller-callee.rs deleted file mode 100644 index 222c1972005..00000000000 --- a/src/test/compile-fail/dep-graph-caller-callee.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that immediate callers have to change when callee changes, but -// not callers' callers. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -fn main() { } - -mod x { - #[rustc_if_this_changed] - pub fn x() { } -} - -mod y { - use x; - - // These dependencies SHOULD exist: - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - pub fn y() { - x::x(); - } -} - -mod z { - use y; - - // These are expected to yield errors, because changes to `x` - // affect the BODY of `y`, but not its signature. - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - pub fn z() { - y::y(); - } -} diff --git a/src/test/compile-fail/dep-graph-struct-signature.rs b/src/test/compile-fail/dep-graph-struct-signature.rs deleted file mode 100644 index 647605ae438..00000000000 --- a/src/test/compile-fail/dep-graph-struct-signature.rs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test cases where a changing struct appears in the signature of fns -// and methods. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -fn main() { } - -#[rustc_if_this_changed] -struct WillChange { - x: u32, - y: u32 -} - -struct WontChange { - x: u32, - y: u32 -} - -// these are valid dependencies -mod signatures { - use WillChange; - - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path - #[rustc_then_this_would_need(AssociatedItems)] //~ ERROR no path - #[rustc_then_this_would_need(TraitDefOfItem)] //~ ERROR no path - trait Bar { - #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK - fn do_something(x: WillChange); - } - - #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - fn some_fn(x: WillChange) { } - - #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - fn new_foo(x: u32, y: u32) -> WillChange { - WillChange { x: x, y: y } - } - - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK - impl WillChange { - #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - fn new(x: u32, y: u32) -> WillChange { loop { } } - } - - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK - impl WillChange { - #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - fn method(&self, x: u32) { } - } - - struct WillChanges { - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK - x: WillChange, - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK - y: WillChange - } - - // The fields change, not the type itself. - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path - fn indirect(x: WillChanges) { } -} - -mod invalid_signatures { - use WontChange; - - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path - trait A { - #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path - fn do_something_else_twice(x: WontChange); - } - - #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - fn b(x: WontChange) { } - - #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange` - fn c(x: u32) { } -} diff --git a/src/test/compile-fail/dep-graph-trait-impl-two-traits-same-method.rs b/src/test/compile-fail/dep-graph-trait-impl-two-traits-same-method.rs deleted file mode 100644 index 7dd02f57b36..00000000000 --- a/src/test/compile-fail/dep-graph-trait-impl-two-traits-same-method.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that adding an impl to a trait `Foo` DOES affect functions -// that only use `Bar` if they have methods in common. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_imports)] - -fn main() { } - -pub trait Foo: Sized { - fn method(self) { } -} - -pub trait Bar: Sized { - fn method(self) { } -} - -mod x { - use {Foo, Bar}; - - #[rustc_if_this_changed] - impl Foo for u32 { } - - impl Bar for char { } -} - -mod y { - use {Foo, Bar}; - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - pub fn with_char() { - char::method('a'); - } -} - -mod z { - use y; - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - pub fn z() { - y::with_char(); - } -} diff --git a/src/test/compile-fail/dep-graph-trait-impl-two-traits.rs b/src/test/compile-fail/dep-graph-trait-impl-two-traits.rs deleted file mode 100644 index 6b3525333bc..00000000000 --- a/src/test/compile-fail/dep-graph-trait-impl-two-traits.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that adding an impl to a trait `Foo` does not affect functions -// that only use `Bar`, so long as they do not have methods in common. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(warnings)] - -fn main() { } - -pub trait Foo: Sized { - fn foo(self) { } -} - -pub trait Bar: Sized { - fn bar(self) { } -} - -mod x { - use {Foo, Bar}; - - #[rustc_if_this_changed] - impl Foo for char { } - - impl Bar for char { } -} - -mod y { - use {Foo, Bar}; - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - pub fn call_bar() { - char::bar('a'); - } -} - -mod z { - use y; - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - pub fn z() { - y::call_bar(); - } -} diff --git a/src/test/compile-fail/dep-graph-trait-impl.rs b/src/test/compile-fail/dep-graph-trait-impl.rs deleted file mode 100644 index 85b3e69065d..00000000000 --- a/src/test/compile-fail/dep-graph-trait-impl.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that when a trait impl changes, fns whose body uses that trait -// must also be recompiled. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(warnings)] - -fn main() { } - -pub trait Foo: Sized { - fn method(self) { } -} - -mod x { - use Foo; - - #[rustc_if_this_changed] - impl Foo for char { } - - impl Foo for u32 { } -} - -mod y { - use Foo; - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - pub fn with_char() { - char::method('a'); - } - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - pub fn take_foo_with_char() { - take_foo::('a'); - } - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - pub fn with_u32() { - u32::method(22); - } - - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - pub fn take_foo_with_u32() { - take_foo::(22); - } - - pub fn take_foo(t: T) { } -} - -mod z { - use y; - - // These are expected to yield errors, because changes to `x` - // affect the BODY of `y`, but not its signature. - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - pub fn z() { - y::with_char(); - y::with_u32(); - } -} diff --git a/src/test/compile-fail/dep-graph-type-alias.rs b/src/test/compile-fail/dep-graph-type-alias.rs deleted file mode 100644 index dca1fa4d98f..00000000000 --- a/src/test/compile-fail/dep-graph-type-alias.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// Test that changing what a `type` points to does not go unnoticed. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -fn main() { } - - -#[rustc_if_this_changed] -type TypeAlias = u32; - -// The type alias directly affects the type of the field, -// not the enclosing struct: -#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path -struct Struct { - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK - x: TypeAlias, - y: u32 -} - -#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path -enum Enum { - Variant1 { - #[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK - t: TypeAlias - }, - Variant2(i32) -} - -#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path -trait Trait { - #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK - fn method(&self, _: TypeAlias); -} - -struct SomeType; - -#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR no path -impl SomeType { - #[rustc_then_this_would_need(FnSignature)] //~ ERROR OK - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK - fn method(&self, _: TypeAlias) {} -} - -#[rustc_then_this_would_need(TypeOfItem)] //~ ERROR OK -type TypeAlias2 = TypeAlias; - -#[rustc_then_this_would_need(FnSignature)] //~ ERROR OK -#[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK -fn function(_: TypeAlias) { - -} diff --git a/src/test/compile-fail/dep-graph-variance-alias.rs b/src/test/compile-fail/dep-graph-variance-alias.rs deleted file mode 100644 index 18cfd001804..00000000000 --- a/src/test/compile-fail/dep-graph-variance-alias.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that changing what a `type` points to does not go unnoticed -// by the variance analysis. - -// compile-flags: -Z query-dep-graph - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -fn main() { } - -struct Foo { - f: T -} - -#[rustc_if_this_changed(Krate)] -type TypeAlias = Foo; - -#[rustc_then_this_would_need(ItemVariances)] //~ ERROR OK -struct Use { - x: TypeAlias -} diff --git a/src/test/compile-fail/deprecated_no_stack_check.rs b/src/test/compile-fail/deprecated_no_stack_check.rs deleted file mode 100644 index 38aaefd52b3..00000000000 --- a/src/test/compile-fail/deprecated_no_stack_check.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(warnings)] -#![feature(no_stack_check)] -//~^ ERROR: 12:12: 12:26: feature has been removed [E0557] -fn main() { - -} diff --git a/src/test/compile-fail/deprecation-in-staged-api.rs b/src/test/compile-fail/deprecation-in-staged-api.rs deleted file mode 100644 index 5c6facbf014..00000000000 --- a/src/test/compile-fail/deprecation-in-staged-api.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// #[deprecated] can't be used in staged api - -#![feature(staged_api)] - -#![stable(feature = "stable_test_feature", since = "1.0.0")] - -#[deprecated] -fn main() { } //~ERROR `#[deprecated]` cannot be used in staged api diff --git a/src/test/compile-fail/deprecation-lint-2.rs b/src/test/compile-fail/deprecation-lint-2.rs deleted file mode 100644 index 2817e06652a..00000000000 --- a/src/test/compile-fail/deprecation-lint-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:deprecation-lint.rs -// error-pattern: use of deprecated item - -#![deny(deprecated)] - -#[macro_use] -extern crate deprecation_lint; - -use deprecation_lint::*; - -fn main() { - macro_test!(); -} diff --git a/src/test/compile-fail/deprecation-lint-3.rs b/src/test/compile-fail/deprecation-lint-3.rs deleted file mode 100644 index 7faaa181d39..00000000000 --- a/src/test/compile-fail/deprecation-lint-3.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:deprecation-lint.rs -// error-pattern: use of deprecated item - -#![deny(deprecated)] -#![allow(warnings)] - -#[macro_use] -extern crate deprecation_lint; - -use deprecation_lint::*; - -fn main() { - macro_test_arg_nested!(deprecated_text); -} diff --git a/src/test/compile-fail/deprecation-lint-nested.rs b/src/test/compile-fail/deprecation-lint-nested.rs deleted file mode 100644 index eedbba59c6f..00000000000 --- a/src/test/compile-fail/deprecation-lint-nested.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(deprecated)] -#![allow(warnings)] - -#[deprecated] -fn issue_35128() { - format_args!("foo"); -} - -#[deprecated] -fn issue_35128_minimal() { - static FOO: &'static str = "foo"; - let _ = FOO; -} - -#[deprecated] -mod silent { - type DeprecatedType = u8; - struct DeprecatedStruct; - fn deprecated_fn() {} - trait DeprecatedTrait {} - static DEPRECATED_STATIC: u8 = 0; - const DEPRECATED_CONST: u8 = 1; - - struct Foo(DeprecatedType); - - impl DeprecatedTrait for Foo {} - - impl Foo { - fn bar() { - deprecated_fn(); - } - } - - fn foo() -> u8 { - DEPRECATED_STATIC + - DEPRECATED_CONST - } -} - -#[deprecated] -mod loud { - #[deprecated] - type DeprecatedType = u8; - #[deprecated] - struct DeprecatedStruct; - #[deprecated] - fn deprecated_fn() {} - #[deprecated] - trait DeprecatedTrait {} - #[deprecated] - static DEPRECATED_STATIC: u8 = 0; - #[deprecated] - const DEPRECATED_CONST: u8 = 1; - - struct Foo(DeprecatedType); //~ ERROR use of deprecated item - - impl DeprecatedTrait for Foo {} //~ ERROR use of deprecated item - - impl Foo { - fn bar() { //~ ERROR use of deprecated item - deprecated_fn(); //~ ERROR use of deprecated item - } - } - - fn foo() -> u8 { - DEPRECATED_STATIC + //~ ERROR use of deprecated item - DEPRECATED_CONST //~ ERROR use of deprecated item - } -} - -fn main() {} diff --git a/src/test/compile-fail/deprecation-lint.rs b/src/test/compile-fail/deprecation-lint.rs deleted file mode 100644 index 93eb6b6b115..00000000000 --- a/src/test/compile-fail/deprecation-lint.rs +++ /dev/null @@ -1,445 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:deprecation-lint.rs -// ignore-tidy-linelength - -#![deny(deprecated)] -#![allow(warnings)] - -#[macro_use] -extern crate deprecation_lint; - -mod cross_crate { - use deprecation_lint::*; - - fn test() { - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated' - foo.method_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' - Foo::method_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' - ::method_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated' - foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - - deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text - foo.method_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text - Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text - ::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::MethodTester::method_deprecated_text': text - foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - - let _ = DeprecatedStruct { //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedStruct': text - i: 0 //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedStruct::i': text - }; - - let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedUnitStruct': text - - let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'deprecation_lint::Enum::DeprecatedVariant': text - - let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTupleStruct': text - - let _ = nested::DeprecatedStruct { //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedStruct': text - i: 0 //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedStruct::i': text - }; - - let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedUnitStruct': text - - let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'deprecation_lint::nested::Enum::DeprecatedVariant': text - - let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'deprecation_lint::nested::DeprecatedTupleStruct': text - - // At the moment, the lint checker only checks stability in - // in the arguments of macros. - // Eventually, we will want to lint the contents of the - // macro in the module *defining* it. Also, stability levels - // on macros themselves are not yet linted. - macro_test_arg!(deprecated_text()); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text - macro_test_arg!(macro_test_arg!(deprecated_text())); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_text': text - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'deprecation_lint::Trait::trait_deprecated_text': text - } - - struct S; - - impl DeprecatedTrait for S {} //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTrait': text - trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item 'deprecation_lint::DeprecatedTrait': text - - pub fn foo() { - let x = Stable { - override2: 3, - //~^ ERROR use of deprecated item 'deprecation_lint::Stable::override2': text - }; - - let _ = x.override2; - //~^ ERROR use of deprecated item 'deprecation_lint::Stable::override2': text - - let Stable { - override2: _ - //~^ ERROR use of deprecated item 'deprecation_lint::Stable::override2': text - } = x; - // all fine - let Stable { .. } = x; - - let x = Stable2(1, 2, 3); - - let _ = x.2; - //~^ ERROR use of deprecated item 'deprecation_lint::Stable2::2': text - - let Stable2(_, - _, - _) - //~^ ERROR use of deprecated item 'deprecation_lint::Stable2::2': text - = x; - // all fine - let Stable2(..) = x; - - let x = Deprecated { - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated': text - inherit: 1, - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated::inherit': text - }; - - let _ = x.inherit; - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated::inherit': text - - let Deprecated { - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated': text - inherit: _, - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated::inherit': text - } = x; - - let Deprecated - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated': text - { .. } = x; - - let x = Deprecated2(1, 2, 3); - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2': text - - let _ = x.0; - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::0': text - let _ = x.1; - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::1': text - let _ = x.2; - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::2': text - - let Deprecated2 - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2': text - (_, - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::0': text - _, - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::1': text - _) - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2::2': text - = x; - let Deprecated2 - //~^ ERROR use of deprecated item 'deprecation_lint::Deprecated2': text - // the patterns are all fine: - (..) = x; - } -} - -mod inheritance { - use deprecation_lint::*; - - fn test_inheritance() { - deprecated_mod::deprecated(); //~ ERROR use of deprecated item 'deprecation_lint::deprecated_mod::deprecated': text - } -} - -mod this_crate { - #[deprecated(since = "1.0.0", note = "text")] - pub fn deprecated() {} - #[deprecated(since = "1.0.0", note = "text")] - pub fn deprecated_text() {} - - #[deprecated(since = "99.99.99", note = "text")] - pub fn deprecated_future() {} - #[deprecated(since = "99.99.99", note = "text")] - pub fn deprecated_future_text() {} - - pub struct MethodTester; - - impl MethodTester { - #[deprecated(since = "1.0.0", note = "text")] - pub fn method_deprecated(&self) {} - #[deprecated(since = "1.0.0", note = "text")] - pub fn method_deprecated_text(&self) {} - } - - pub trait Trait { - #[deprecated(since = "1.0.0", note = "text")] - fn trait_deprecated(&self) {} - #[deprecated(since = "1.0.0", note = "text")] - fn trait_deprecated_text(&self) {} - } - - impl Trait for MethodTester {} - - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedStruct { - i: isize - } - pub struct UnstableStruct { - i: isize - } - pub struct StableStruct { - i: isize - } - - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedUnitStruct; - - pub enum Enum { - #[deprecated(since = "1.0.0", note = "text")] - DeprecatedVariant, - } - - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedTupleStruct(isize); - - mod nested { - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedStruct { - i: isize - } - - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedUnitStruct; - - pub enum Enum { - #[deprecated(since = "1.0.0", note = "text")] - DeprecatedVariant, - } - - #[deprecated(since = "1.0.0", note = "text")] - pub struct DeprecatedTupleStruct(pub isize); - } - - fn test() { - use self::nested; - - // Only the deprecated cases of the following should generate - // errors, because other stability attributes now have meaning - // only *across* crates, not within a single crate. - - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); //~ ERROR use of deprecated item 'this_crate::deprecated' - foo.method_deprecated(); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' - Foo::method_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' - ::method_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated' - foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - - deprecated_text(); //~ ERROR use of deprecated item 'this_crate::deprecated_text': text - foo.method_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text - Foo::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text - ::method_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text - foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - - deprecated_future(); // Fine; no error. - deprecated_future_text(); // Fine; no error. - - let _ = DeprecatedStruct { - //~^ ERROR use of deprecated item 'this_crate::DeprecatedStruct': text - i: 0 //~ ERROR use of deprecated item 'this_crate::DeprecatedStruct::i': text - }; - - let _ = DeprecatedUnitStruct; //~ ERROR use of deprecated item 'this_crate::DeprecatedUnitStruct': text - - let _ = Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'this_crate::Enum::DeprecatedVariant': text - - let _ = DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'this_crate::DeprecatedTupleStruct': text - - let _ = nested::DeprecatedStruct { - //~^ ERROR use of deprecated item 'this_crate::nested::DeprecatedStruct': text - i: 0 //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedStruct::i': text - }; - - let _ = nested::DeprecatedUnitStruct; //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedUnitStruct': text - - let _ = nested::Enum::DeprecatedVariant; //~ ERROR use of deprecated item 'this_crate::nested::Enum::DeprecatedVariant': text - - let _ = nested::DeprecatedTupleStruct (1); //~ ERROR use of deprecated item 'this_crate::nested::DeprecatedTupleStruct': text - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ ERROR use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - } - - #[deprecated(since = "1.0.0", note = "text")] - fn test_fn_body() { - fn fn_in_body() {} - fn_in_body(); - } - - fn test_fn_closure_body() { - let _ = || { - #[deprecated] - fn bar() { } - bar(); //~ ERROR use of deprecated item 'this_crate::test_fn_closure_body::{{closure}}::bar' - }; - } - - impl MethodTester { - #[deprecated(since = "1.0.0", note = "text")] - fn test_method_body(&self) { - fn fn_in_body() {} - fn_in_body(); - } - } - - #[deprecated(since = "1.0.0", note = "text")] - pub trait DeprecatedTrait { - fn dummy(&self) { } - } - - struct S; - - impl DeprecatedTrait for S { } //~ ERROR use of deprecated item 'this_crate::DeprecatedTrait': text - - trait LocalTrait : DeprecatedTrait { } //~ ERROR use of deprecated item 'this_crate::DeprecatedTrait': text -} - -mod this_crate2 { - struct Stable { - #[deprecated(since = "1.0.0", note = "text")] - override2: u8, - } - - struct Stable2(u8, - u8, - #[deprecated(since = "1.0.0", note = "text")] u8); - - #[deprecated(since = "1.0.0", note = "text")] - struct Deprecated { - inherit: u8, - } - - #[deprecated(since = "1.0.0", note = "text")] - struct Deprecated2(u8, - u8, - u8); - - pub fn foo() { - let x = Stable { - override2: 3, - //~^ ERROR use of deprecated item 'this_crate2::Stable::override2': text - }; - - let _ = x.override2; - //~^ ERROR use of deprecated item 'this_crate2::Stable::override2': text - - let Stable { - override2: _ - //~^ ERROR use of deprecated item 'this_crate2::Stable::override2': text - } = x; - // all fine - let Stable { .. } = x; - - let x = Stable2(1, 2, 3); - - let _ = x.2; - //~^ ERROR use of deprecated item 'this_crate2::Stable2::2': text - - let Stable2(_, - _, - _) - //~^ ERROR use of deprecated item 'this_crate2::Stable2::2': text - = x; - // all fine - let Stable2(..) = x; - - let x = Deprecated { - //~^ ERROR use of deprecated item 'this_crate2::Deprecated': text - inherit: 1, - //~^ ERROR use of deprecated item 'this_crate2::Deprecated::inherit': text - }; - - let _ = x.inherit; - //~^ ERROR use of deprecated item 'this_crate2::Deprecated::inherit': text - - let Deprecated { - //~^ ERROR use of deprecated item 'this_crate2::Deprecated': text - inherit: _, - //~^ ERROR use of deprecated item 'this_crate2::Deprecated::inherit': text - } = x; - - let Deprecated - //~^ ERROR use of deprecated item 'this_crate2::Deprecated': text - // the patterns are all fine: - { .. } = x; - - let x = Deprecated2(1, 2, 3); - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2': text - - let _ = x.0; - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::0': text - let _ = x.1; - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::1': text - let _ = x.2; - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::2': text - - let Deprecated2 - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2': text - (_, - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::0': text - _, - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::1': text - _) - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2::2': text - = x; - let Deprecated2 - //~^ ERROR use of deprecated item 'this_crate2::Deprecated2': text - // the patterns are all fine: - (..) = x; - } -} - -fn main() {} diff --git a/src/test/compile-fail/deref-non-pointer.rs b/src/test/compile-fail/deref-non-pointer.rs deleted file mode 100644 index 1c711c0145d..00000000000 --- a/src/test/compile-fail/deref-non-pointer.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match *1 { //~ ERROR: cannot be dereferenced - _ => { panic!(); } - } -} diff --git a/src/test/compile-fail/derive-assoc-type-not-impl.rs b/src/test/compile-fail/derive-assoc-type-not-impl.rs deleted file mode 100644 index 3799f2ffba4..00000000000 --- a/src/test/compile-fail/derive-assoc-type-not-impl.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - type X; - fn method(&self) {} -} - -#[derive(Clone)] -struct Bar { - x: T::X, -} - -struct NotClone; - -impl Foo for NotClone { - type X = i8; -} - -fn main() { - Bar:: { x: 1 }.clone(); //~ ERROR -} diff --git a/src/test/compile-fail/derive-on-trait-item-or-impl-item.rs b/src/test/compile-fail/derive-on-trait-item-or-impl-item.rs deleted file mode 100644 index 9ff1c14f54c..00000000000 --- a/src/test/compile-fail/derive-on-trait-item-or-impl-item.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - #[derive(Clone)] - //~^ ERROR `derive` may only be applied to structs, enums and unions - type Bar; -} - -impl Bar { - #[derive(Clone)] - //~^ ERROR `derive` may only be applied to structs, enums and unions - fn bar(&self) {} -} - -fn main() {} diff --git a/src/test/compile-fail/derived-errors/issue-30580.rs b/src/test/compile-fail/derived-errors/issue-30580.rs deleted file mode 100644 index 553ad0a3341..00000000000 --- a/src/test/compile-fail/derived-errors/issue-30580.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we do not see uninformative region-related errors -// when we get some basic type-checking failure. See #30580. - -pub struct Foo { a: u32 } -pub struct Pass<'a, 'tcx: 'a>(&'a mut &'a (), &'a &'tcx ()); - -impl<'a, 'tcx> Pass<'a, 'tcx> -{ - pub fn tcx(&self) -> &'a &'tcx () { self.1 } - fn lol(&mut self, b: &Foo) - { - b.c; //~ ERROR no field `c` on type `&Foo` - self.tcx(); - } -} - -fn main() {} diff --git a/src/test/compile-fail/derived-errors/issue-31997.rs b/src/test/compile-fail/derived-errors/issue-31997.rs deleted file mode 100644 index 2e1d3c55a8f..00000000000 --- a/src/test/compile-fail/derived-errors/issue-31997.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the resolve failure does not lead to downstream type errors. -// See issue #31997. - -trait TheTrait { } - -fn closure(x: F) -> Result - where F: FnMut() -> T, T: TheTrait, -{ - unimplemented!() -} - -fn foo() -> Result<(), ()> { - try!(closure(|| bar(0 as *mut _))); //~ ERROR cannot find function `bar` in this scope - Ok(()) -} - -fn main() { } diff --git a/src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs deleted file mode 100644 index 244acbf6605..00000000000 --- a/src/test/compile-fail/derives-span-Clone-enum-struct-variant.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Clone)] -enum Enum { - A { - x: Error //~ ERROR - } -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Clone-enum.rs b/src/test/compile-fail/derives-span-Clone-enum.rs deleted file mode 100644 index 785a3d35430..00000000000 --- a/src/test/compile-fail/derives-span-Clone-enum.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Clone)] -enum Enum { - A( - Error //~ ERROR - ) -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Clone-struct.rs b/src/test/compile-fail/derives-span-Clone-struct.rs deleted file mode 100644 index b1b1dc7bed1..00000000000 --- a/src/test/compile-fail/derives-span-Clone-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Clone)] -struct Struct { - x: Error //~ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Clone-tuple-struct.rs b/src/test/compile-fail/derives-span-Clone-tuple-struct.rs deleted file mode 100644 index d56e21b9a8a..00000000000 --- a/src/test/compile-fail/derives-span-Clone-tuple-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Clone)] -struct Struct( - Error //~ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs deleted file mode 100644 index 4c25e482c2a..00000000000 --- a/src/test/compile-fail/derives-span-Debug-enum-struct-variant.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Debug)] -enum Enum { - A { - x: Error //~ ERROR - } -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Debug-enum.rs b/src/test/compile-fail/derives-span-Debug-enum.rs deleted file mode 100644 index 0cb02aa54e6..00000000000 --- a/src/test/compile-fail/derives-span-Debug-enum.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Debug)] -enum Enum { - A( - Error //~ ERROR - ) -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Debug-struct.rs b/src/test/compile-fail/derives-span-Debug-struct.rs deleted file mode 100644 index 33fa82355ec..00000000000 --- a/src/test/compile-fail/derives-span-Debug-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Debug)] -struct Struct { - x: Error //~ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Debug-tuple-struct.rs b/src/test/compile-fail/derives-span-Debug-tuple-struct.rs deleted file mode 100644 index 760ed199f6a..00000000000 --- a/src/test/compile-fail/derives-span-Debug-tuple-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Debug)] -struct Struct( - Error //~ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Default-struct.rs b/src/test/compile-fail/derives-span-Default-struct.rs deleted file mode 100644 index 4adfe75adaf..00000000000 --- a/src/test/compile-fail/derives-span-Default-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Default)] -struct Struct { - x: Error //~ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Default-tuple-struct.rs b/src/test/compile-fail/derives-span-Default-tuple-struct.rs deleted file mode 100644 index a5e3a7cd49f..00000000000 --- a/src/test/compile-fail/derives-span-Default-tuple-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Default)] -struct Struct( - Error //~ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs deleted file mode 100644 index 6abd1d31e66..00000000000 --- a/src/test/compile-fail/derives-span-Eq-enum-struct-variant.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(Eq,PartialEq)] -enum Enum { - A { - x: Error //~ ERROR - } -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Eq-enum.rs b/src/test/compile-fail/derives-span-Eq-enum.rs deleted file mode 100644 index f361278a620..00000000000 --- a/src/test/compile-fail/derives-span-Eq-enum.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(Eq,PartialEq)] -enum Enum { - A( - Error //~ ERROR - ) -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Eq-struct.rs b/src/test/compile-fail/derives-span-Eq-struct.rs deleted file mode 100644 index 7067caa6d5c..00000000000 --- a/src/test/compile-fail/derives-span-Eq-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(Eq,PartialEq)] -struct Struct { - x: Error //~ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Eq-tuple-struct.rs b/src/test/compile-fail/derives-span-Eq-tuple-struct.rs deleted file mode 100644 index 1a09628b770..00000000000 --- a/src/test/compile-fail/derives-span-Eq-tuple-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(Eq,PartialEq)] -struct Struct( - Error //~ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs deleted file mode 100644 index 907045cce47..00000000000 --- a/src/test/compile-fail/derives-span-Hash-enum-struct-variant.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Hash)] -enum Enum { - A { - x: Error //~ ERROR - } -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Hash-enum.rs b/src/test/compile-fail/derives-span-Hash-enum.rs deleted file mode 100644 index 321b9e71a0f..00000000000 --- a/src/test/compile-fail/derives-span-Hash-enum.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Hash)] -enum Enum { - A( - Error //~ ERROR - ) -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Hash-struct.rs b/src/test/compile-fail/derives-span-Hash-struct.rs deleted file mode 100644 index 7f69c3a8e25..00000000000 --- a/src/test/compile-fail/derives-span-Hash-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Hash)] -struct Struct { - x: Error //~ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Hash-tuple-struct.rs b/src/test/compile-fail/derives-span-Hash-tuple-struct.rs deleted file mode 100644 index 2dee63c4298..00000000000 --- a/src/test/compile-fail/derives-span-Hash-tuple-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(Hash)] -struct Struct( - Error //~ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs b/src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs deleted file mode 100644 index 8f4e393c96a..00000000000 --- a/src/test/compile-fail/derives-span-Ord-enum-struct-variant.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(Eq,PartialOrd,PartialEq)] -struct Error; - -#[derive(Ord,Eq,PartialOrd,PartialEq)] -enum Enum { - A { - x: Error //~ ERROR - } -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Ord-enum.rs b/src/test/compile-fail/derives-span-Ord-enum.rs deleted file mode 100644 index b8ceacf3753..00000000000 --- a/src/test/compile-fail/derives-span-Ord-enum.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(Eq,PartialOrd,PartialEq)] -struct Error; - -#[derive(Ord,Eq,PartialOrd,PartialEq)] -enum Enum { - A( - Error //~ ERROR - ) -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Ord-struct.rs b/src/test/compile-fail/derives-span-Ord-struct.rs deleted file mode 100644 index 2ff62bac2bc..00000000000 --- a/src/test/compile-fail/derives-span-Ord-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(Eq,PartialOrd,PartialEq)] -struct Error; - -#[derive(Ord,Eq,PartialOrd,PartialEq)] -struct Struct { - x: Error //~ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-Ord-tuple-struct.rs b/src/test/compile-fail/derives-span-Ord-tuple-struct.rs deleted file mode 100644 index 24eacb71d7b..00000000000 --- a/src/test/compile-fail/derives-span-Ord-tuple-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(Eq,PartialOrd,PartialEq)] -struct Error; - -#[derive(Ord,Eq,PartialOrd,PartialEq)] -struct Struct( - Error //~ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs b/src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs deleted file mode 100644 index 14d94f1599e..00000000000 --- a/src/test/compile-fail/derives-span-PartialEq-enum-struct-variant.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(PartialEq)] -enum Enum { - A { - x: Error //~ ERROR -//~^ ERROR - } -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialEq-enum.rs b/src/test/compile-fail/derives-span-PartialEq-enum.rs deleted file mode 100644 index ab58bb938b9..00000000000 --- a/src/test/compile-fail/derives-span-PartialEq-enum.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(PartialEq)] -enum Enum { - A( - Error //~ ERROR -//~^ ERROR - ) -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialEq-struct.rs b/src/test/compile-fail/derives-span-PartialEq-struct.rs deleted file mode 100644 index 05a0990ff03..00000000000 --- a/src/test/compile-fail/derives-span-PartialEq-struct.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(PartialEq)] -struct Struct { - x: Error //~ ERROR -//~^ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs b/src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs deleted file mode 100644 index cdeb7ce45bc..00000000000 --- a/src/test/compile-fail/derives-span-PartialEq-tuple-struct.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - - -struct Error; - -#[derive(PartialEq)] -struct Struct( - Error //~ ERROR -//~^ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs b/src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs deleted file mode 100644 index a5df717e06b..00000000000 --- a/src/test/compile-fail/derives-span-PartialOrd-enum-struct-variant.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(PartialOrd,PartialEq)] -enum Enum { - A { - x: Error //~ ERROR - } -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialOrd-enum.rs b/src/test/compile-fail/derives-span-PartialOrd-enum.rs deleted file mode 100644 index 3411d2f3119..00000000000 --- a/src/test/compile-fail/derives-span-PartialOrd-enum.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(PartialOrd,PartialEq)] -enum Enum { - A( - Error //~ ERROR - ) -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialOrd-struct.rs b/src/test/compile-fail/derives-span-PartialOrd-struct.rs deleted file mode 100644 index 1feadc2fd83..00000000000 --- a/src/test/compile-fail/derives-span-PartialOrd-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(PartialOrd,PartialEq)] -struct Struct { - x: Error //~ ERROR -} - -fn main() {} diff --git a/src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs b/src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs deleted file mode 100644 index 9db0fed2d9e..00000000000 --- a/src/test/compile-fail/derives-span-PartialOrd-tuple-struct.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py' - -#[derive(PartialEq)] -struct Error; - -#[derive(PartialOrd,PartialEq)] -struct Struct( - Error //~ ERROR -); - -fn main() {} diff --git a/src/test/compile-fail/deriving-bounds.rs b/src/test/compile-fail/deriving-bounds.rs deleted file mode 100644 index 72d06274de4..00000000000 --- a/src/test/compile-fail/deriving-bounds.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Send)] -//~^ ERROR this unsafe trait should be implemented explicitly -struct Test; - -#[derive(Sync)] -//~^ ERROR this unsafe trait should be implemented explicitly -struct Test1; - -pub fn main() {} diff --git a/src/test/compile-fail/deriving-copyclone.rs b/src/test/compile-fail/deriving-copyclone.rs deleted file mode 100644 index 92fb7c5737a..00000000000 --- a/src/test/compile-fail/deriving-copyclone.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// this will get a no-op Clone impl -#[derive(Copy, Clone)] -struct A { - a: i32, - b: i64 -} - -// this will get a deep Clone impl -#[derive(Copy, Clone)] -struct B { - a: i32, - b: T -} - -struct C; // not Copy or Clone -#[derive(Clone)] struct D; // Clone but not Copy - -fn is_copy(_: T) {} -fn is_clone(_: T) {} - -fn main() { - // A can be copied and cloned - is_copy(A { a: 1, b: 2 }); - is_clone(A { a: 1, b: 2 }); - - // B can be copied and cloned - is_copy(B { a: 1, b: 2 }); - is_clone(B { a: 1, b: 2 }); - - // B cannot be copied or cloned - is_copy(B { a: 1, b: C }); //~ERROR Copy - is_clone(B { a: 1, b: C }); //~ERROR Clone - - // B can be cloned but not copied - is_copy(B { a: 1, b: D }); //~ERROR Copy - is_clone(B { a: 1, b: D }); -} - diff --git a/src/test/compile-fail/deriving-meta-unknown-trait.rs b/src/test/compile-fail/deriving-meta-unknown-trait.rs deleted file mode 100644 index d388ece0844..00000000000 --- a/src/test/compile-fail/deriving-meta-unknown-trait.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#[derive(Eqr)] -//~^ ERROR cannot find derive macro `Eqr` in this scope -struct Foo; - -pub fn main() {} diff --git a/src/test/compile-fail/deriving-no-inner-impl-error-message.rs b/src/test/compile-fail/deriving-no-inner-impl-error-message.rs deleted file mode 100644 index 129c859b919..00000000000 --- a/src/test/compile-fail/deriving-no-inner-impl-error-message.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct NoCloneOrEq; - -#[derive(PartialEq)] -struct E { - x: NoCloneOrEq //~ ERROR binary operation `==` cannot be applied to type `NoCloneOrEq` - //~^ ERROR binary operation `!=` cannot be applied to type `NoCloneOrEq` -} -#[derive(Clone)] -struct C { - x: NoCloneOrEq - //~^ ERROR `NoCloneOrEq: std::clone::Clone` is not satisfied -} - - -fn main() {} diff --git a/src/test/compile-fail/deriving-non-type.rs b/src/test/compile-fail/deriving-non-type.rs deleted file mode 100644 index 84dd22435b8..00000000000 --- a/src/test/compile-fail/deriving-non-type.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -struct S; - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -trait T { } - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -impl S { } - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -impl T for S { } - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -static s: usize = 0; - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -const c: usize = 0; - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -mod m { } - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -extern "C" { } - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -type A = usize; - -#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs, enums and unions -fn main() { } diff --git a/src/test/compile-fail/deriving-primitive.rs b/src/test/compile-fail/deriving-primitive.rs deleted file mode 100644 index 04fdee5e3ed..00000000000 --- a/src/test/compile-fail/deriving-primitive.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(FromPrimitive)] //~ ERROR cannot find derive macro `FromPrimitive` in this scope -enum Foo {} - -fn main() {} - diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs deleted file mode 100644 index b5acdc12ca0..00000000000 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The regression test for #15031 to make sure destructuring trait -// reference work properly. - -#![feature(box_patterns)] -#![feature(box_syntax)] - -trait T { fn foo(&self) {} } -impl T for isize {} - -fn main() { - // For an expression of the form: - // - // let &...&x = &..&SomeTrait; - // - // Say we have n `&` at the left hand and m `&` right hand, then: - // if n < m, we are golden; - // if n == m, it's a derefing non-derefable type error; - // if n > m, it's a type mismatch error. - - // n < m - let &x = &(&1isize as &T); - let &x = &&(&1isize as &T); - let &&x = &&(&1isize as &T); - - // n == m - let &x = &1isize as &T; //~ ERROR type `&dyn T` cannot be dereferenced - let &&x = &(&1isize as &T); //~ ERROR type `&dyn T` cannot be dereferenced - let box x = box 1isize as Box; //~ ERROR type `std::boxed::Box` cannot be dereferenced - - // n > m - let &&x = &1isize as &T; - //~^ ERROR mismatched types - //~| expected type `dyn T` - //~| found type `&_` - //~| expected trait T, found reference - let &&&x = &(&1isize as &T); - //~^ ERROR mismatched types - //~| expected type `dyn T` - //~| found type `&_` - //~| expected trait T, found reference - let box box x = box 1isize as Box; - //~^ ERROR mismatched types - //~| expected type `dyn T` - //~| found type `std::boxed::Box<_>` -} diff --git a/src/test/compile-fail/directory_ownership/foo/compiletest-ignore-dir b/src/test/compile-fail/directory_ownership/foo/compiletest-ignore-dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs b/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs deleted file mode 100644 index fc4bca865c9..00000000000 --- a/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs b/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs deleted file mode 100644 index fc4bca865c9..00000000000 --- a/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/compile-fail/directory_ownership/macro-expanded-mod.rs b/src/test/compile-fail/directory_ownership/macro-expanded-mod.rs deleted file mode 100644 index 8e631a64f7a..00000000000 --- a/src/test/compile-fail/directory_ownership/macro-expanded-mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that macro-expanded non-inline modules behave correctly - -macro_rules! mod_decl { - ($i:ident) => { mod $i; } -} - -mod macro_expanded_mod_helper { - mod_decl!(foo); // This should search in the folder `macro_expanded_mod_helper` -} - -fn main() { - mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block -} diff --git a/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs b/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs deleted file mode 100644 index 4ef92981314..00000000000 --- a/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test not a test, auxiliary diff --git a/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs b/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs deleted file mode 100644 index 41a8c288e7c..00000000000 --- a/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test not a test, auxiliary - -mod_decl!(bar); diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs deleted file mode 100644 index ff93fddf9b3..00000000000 --- a/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mod statements in non-mod.rs files are unstable - -mod mod_file_not_owning_aux1; - -fn main() {} diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs deleted file mode 100644 index 4ac94a92e37..00000000000 --- a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test this is not a test - -macro_rules! m { - () => { mod mod_file_not_owning_aux2; } -} -m!(); diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs deleted file mode 100644 index fc4bca865c9..00000000000 --- a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs deleted file mode 100644 index 41401d640f6..00000000000 --- a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test this is not a test diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux3.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux3.rs deleted file mode 100644 index 3a164fd55d9..00000000000 --- a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux3.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test this is not a test - -mod mod_file_not_owning_aux2; diff --git a/src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs b/src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs deleted file mode 100644 index c4ede12e820..00000000000 --- a/src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that non-inline modules are not allowed inside blocks. - -fn main() { - mod foo; //~ ERROR Cannot declare a non-inline module inside a block -} diff --git a/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs b/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs deleted file mode 100644 index 0cffb7cc9e5..00000000000 --- a/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mod statements in non-mod.rs files are unstable - -// This is not a directory owner since the file name is not "mod.rs". -#[path = "mod_file_not_owning_aux1.rs"] -mod foo; diff --git a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs b/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs deleted file mode 100644 index 2621820c222..00000000000 --- a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct X { - x: String, -} - -impl Drop for X { - fn drop(&mut self) { - println!("value: {}", self.x); - } -} - -fn unwrap(x: X) -> String { - let X { x: y } = x; //~ ERROR cannot move out of type - y -} - -fn main() { - let x = X { x: "hello".to_string() }; - let y = unwrap(x); - println!("contents: {}", y); -} diff --git a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs b/src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs deleted file mode 100644 index 38049209903..00000000000 --- a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct X { - x: String, -} - -impl Drop for X { - fn drop(&mut self) { - println!("value: {}", self.x); - } -} - -fn main() { - let x = X { x: "hello".to_string() }; - - match x { - X { x: y } => println!("contents: {}", y) - //~^ ERROR cannot move out of type `X`, which implements the `Drop` trait - } -} diff --git a/src/test/compile-fail/discrim-ill-typed.rs b/src/test/compile-fail/discrim-ill-typed.rs deleted file mode 100644 index 62e54c3f237..00000000000 --- a/src/test/compile-fail/discrim-ill-typed.rs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// When explicit discriminant value has -// a type that does not match the representation -// type, rustc should fail gracefully. - -// See also run-pass/discrim-explicit-23030.rs where the input types -// are correct. - -#![allow(dead_code, unused_variables, unused_imports)] - -use std::{i8,u8,i16,u16,i32,u32,i64, u64}; - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo = 0_u8, - //~^ ERROR mismatched types - //~| expected i8, found u8 - } - - let x = A::Ok; -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo = 0_i8, - //~^ ERROR mismatched types - //~| expected u8, found i8 - } - - let x = A::Ok; -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo = 0_u16, - //~^ ERROR mismatched types - //~| expected i16, found u16 - } - - let x = A::Ok; -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo = 0_i16, - //~^ ERROR mismatched types - //~| expected u16, found i16 - } - - let x = A::Ok; -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo = 0_u32, - //~^ ERROR mismatched types - //~| expected i32, found u32 - } - - let x = A::Ok; -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo = 0_i32, - //~^ ERROR mismatched types - //~| expected u32, found i32 - } - - let x = A::Ok; -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo = 0_u64, - //~^ ERROR mismatched types - //~| expected i64, found u64 - } - - let x = A::Ok; -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo = 0_i64, - //~^ ERROR mismatched types - //~| expected u64, found i64 - } - - let x = A::Ok; -} - -fn main() { } diff --git a/src/test/compile-fail/diverging-fn-tail-35849.rs b/src/test/compile-fail/diverging-fn-tail-35849.rs deleted file mode 100644 index 9ef5159cb77..00000000000 --- a/src/test/compile-fail/diverging-fn-tail-35849.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn assert_sizeof() -> ! { - unsafe { - ::std::mem::transmute::(panic!()) - //~^ ERROR mismatched types - } -} - -fn main() { } diff --git a/src/test/compile-fail/diverging-tuple-parts-39485.rs b/src/test/compile-fail/diverging-tuple-parts-39485.rs deleted file mode 100644 index eedad08ab55..00000000000 --- a/src/test/compile-fail/diverging-tuple-parts-39485.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// After #39485, this test used to pass, but that change was reverted -// due to numerous inference failures like #39808, so it now fails -// again. #39485 made it so that diverging types never propagate -// upward; but we now do propagate such types upward in many more -// cases. - -fn g() { - &panic!() //~ ERROR mismatched types -} - -fn f() -> isize { - (return 1, return 2) //~ ERROR mismatched types -} - -fn main() {} diff --git a/src/test/compile-fail/does-nothing.rs b/src/test/compile-fail/does-nothing.rs deleted file mode 100644 index 01de94bddbd..00000000000 --- a/src/test/compile-fail/does-nothing.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { println!("doing"); this_does_nothing_what_the; println!("boing"); } -//~^ ERROR cannot find value `this_does_nothing_what_the` in this scope diff --git a/src/test/compile-fail/dollar-crate-is-keyword-2.rs b/src/test/compile-fail/dollar-crate-is-keyword-2.rs deleted file mode 100644 index 87a29038035..00000000000 --- a/src/test/compile-fail/dollar-crate-is-keyword-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a {} - -macro_rules! m { - () => { - use a::$crate; //~ ERROR unresolved import `a::$crate` - use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position - type A = a::$crate; //~ ERROR `$crate` in paths can only be used in start position - } -} - -m!(); - -fn main() {} diff --git a/src/test/compile-fail/dollar-crate-is-keyword.rs b/src/test/compile-fail/dollar-crate-is-keyword.rs deleted file mode 100644 index 4a667f020ad..00000000000 --- a/src/test/compile-fail/dollar-crate-is-keyword.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! m { - () => { - // Avoid having more than one `$crate`-named item in the same module, - // as even though they error, they still parse as `$crate` and conflict. - mod foo { - struct $crate {} //~ ERROR expected identifier, found reserved identifier `$crate` - } - - use $crate; // OK - //~^ WARN `$crate` may not be imported - use $crate as $crate; //~ ERROR expected identifier, found reserved identifier `$crate` - //~^ WARN `$crate` may not be imported - } -} - -m!(); - -fn main() {} diff --git a/src/test/compile-fail/double-type-import.rs b/src/test/compile-fail/double-type-import.rs deleted file mode 100644 index 9629da735b0..00000000000 --- a/src/test/compile-fail/double-type-import.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub use self::bar::X; - use self::bar::X; - //~^ ERROR the name `X` is defined multiple times - - mod bar { - pub struct X; - } -} - -fn main() { - let _ = foo::X; -} diff --git a/src/test/compile-fail/drop-on-non-struct.rs b/src/test/compile-fail/drop-on-non-struct.rs deleted file mode 100644 index 26b247d0d0f..00000000000 --- a/src/test/compile-fail/drop-on-non-struct.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -impl<'a> Drop for &'a mut isize { - //~^ ERROR the Drop trait may only be implemented on structures - //~^^ ERROR E0117 - fn drop(&mut self) { - println!("kaboom"); - } -} - -fn main() { -} diff --git a/src/test/compile-fail/drop-with-active-borrows-1.rs b/src/test/compile-fail/drop-with-active-borrows-1.rs deleted file mode 100644 index 903365fb909..00000000000 --- a/src/test/compile-fail/drop-with-active-borrows-1.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let a = "".to_string(); - let b: Vec<&str> = a.lines().collect(); - drop(a); //~ ERROR cannot move out of `a` because it is borrowed - for s in &b { - println!("{}", *s); - } -} diff --git a/src/test/compile-fail/drop-with-active-borrows-2.rs b/src/test/compile-fail/drop-with-active-borrows-2.rs deleted file mode 100644 index 33e4d3e62c4..00000000000 --- a/src/test/compile-fail/drop-with-active-borrows-2.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn read_lines_borrowed<'a>() -> Vec<&'a str> { - let raw_lines: Vec = vec!["foo ".to_string(), " bar".to_string()]; - raw_lines.iter().map(|l| l.trim()).collect() - //~^ ERROR `raw_lines` does not live long enough -} - -fn main() { - println!("{:?}", read_lines_borrowed()); -} diff --git a/src/test/compile-fail/dropck_no_diverge_on_nonregular_1.rs b/src/test/compile-fail/dropck_no_diverge_on_nonregular_1.rs deleted file mode 100644 index f0968853819..00000000000 --- a/src/test/compile-fail/dropck_no_diverge_on_nonregular_1.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue 22443: Reject code using non-regular types that would -// otherwise cause dropck to loop infinitely. - -use std::marker::PhantomData; - -struct Digit { - elem: T -} - -struct Node { m: PhantomData<&'static T> } - - -enum FingerTree { - Single(T), - // Bug report said Digit after Box would stack overflow (versus - // Digit before Box; see dropck_no_diverge_on_nonregular_2). - Deep( - Box>>, - Digit, - ) -} - -fn main() { - let ft = //~ ERROR overflow while adding drop-check rules for FingerTree - FingerTree::Single(1); - //~^ ERROR overflow while adding drop-check rules for FingerTree -} diff --git a/src/test/compile-fail/dropck_no_diverge_on_nonregular_2.rs b/src/test/compile-fail/dropck_no_diverge_on_nonregular_2.rs deleted file mode 100644 index 886bd6bea20..00000000000 --- a/src/test/compile-fail/dropck_no_diverge_on_nonregular_2.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue 22443: Reject code using non-regular types that would -// otherwise cause dropck to loop infinitely. - -use std::marker::PhantomData; - -struct Digit { - elem: T -} - -struct Node { m: PhantomData<&'static T> } - -enum FingerTree { - Single(T), - // Bug report said Digit before Box would infinite loop (versus - // Digit after Box; see dropck_no_diverge_on_nonregular_1). - Deep( - Digit, - Box>>, - ) -} - -fn main() { - let ft = //~ ERROR overflow while adding drop-check rules for FingerTree - FingerTree::Single(1); - //~^ ERROR overflow while adding drop-check rules for FingerTree -} diff --git a/src/test/compile-fail/dropck_no_diverge_on_nonregular_3.rs b/src/test/compile-fail/dropck_no_diverge_on_nonregular_3.rs deleted file mode 100644 index 45531666ecf..00000000000 --- a/src/test/compile-fail/dropck_no_diverge_on_nonregular_3.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue 22443: Reject code using non-regular types that would -// otherwise cause dropck to loop infinitely. -// -// This version is just checking that we still sanely handle a trivial -// wrapper around the non-regular type. (It also demonstrates how the -// error messages will report different types depending on which type -// dropck is analyzing.) - -use std::marker::PhantomData; - -struct Digit { - elem: T -} - -struct Node { m: PhantomData<&'static T> } - -enum FingerTree { - Single(T), - // According to the bug report, Digit before Box would infinite loop. - Deep( - Digit, - Box>>, - ) -} - -enum Wrapper { - Simple, - Other(FingerTree), -} - -fn main() { - let w = //~ ERROR overflow while adding drop-check rules for std::option - Some(Wrapper::Simple::); - //~^ ERROR overflow while adding drop-check rules for std::option::Option - //~| ERROR overflow while adding drop-check rules for Wrapper -} diff --git a/src/test/compile-fail/dropck_trait_cycle_checked.rs b/src/test/compile-fail/dropck_trait_cycle_checked.rs deleted file mode 100644 index b6b7fa1a233..00000000000 --- a/src/test/compile-fail/dropck_trait_cycle_checked.rs +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Reject mixing cyclic structure and Drop when using trait -// objects to hide the cross-references. -// -// (Compare against compile-fail/dropck_vec_cycle_checked.rs) - -use std::cell::Cell; -use id::Id; - -mod s { - use std::sync::atomic::{AtomicUsize, Ordering}; - - static S_COUNT: AtomicUsize = AtomicUsize::new(0); - - pub fn next_count() -> usize { - S_COUNT.fetch_add(1, Ordering::SeqCst) + 1 - } -} - -mod id { - use s; - #[derive(Debug)] - pub struct Id { - orig_count: usize, - count: usize, - } - - impl Id { - pub fn new() -> Id { - let c = s::next_count(); - println!("building Id {}", c); - Id { orig_count: c, count: c } - } - pub fn count(&self) -> usize { - println!("Id::count on {} returns {}", self.orig_count, self.count); - self.count - } - } - - impl Drop for Id { - fn drop(&mut self) { - println!("dropping Id {}", self.count); - self.count = 0; - } - } -} - -trait HasId { - fn count(&self) -> usize; -} - -#[derive(Debug)] -struct CheckId { - v: T -} - -#[allow(non_snake_case)] -fn CheckId(t: T) -> CheckId { CheckId{ v: t } } - -impl Drop for CheckId { - fn drop(&mut self) { - assert!(self.v.count() > 0); - } -} - -trait Obj<'a> : HasId { - fn set0(&self, b: &'a Box>); - fn set1(&self, b: &'a Box>); -} - -struct O<'a> { - id: Id, - obj0: CheckId>>>>, - obj1: CheckId>>>>, -} - -impl<'a> HasId for O<'a> { - fn count(&self) -> usize { self.id.count() } -} - -impl<'a> O<'a> { - fn new() -> Box> { - Box::new(O { - id: Id::new(), - obj0: CheckId(Cell::new(None)), - obj1: CheckId(Cell::new(None)), - }) - } -} - -impl<'a> HasId for Cell>>> { - fn count(&self) -> usize { - match self.get() { - None => 1, - Some(c) => c.count(), - } - } -} - -impl<'a> Obj<'a> for O<'a> { - fn set0(&self, b: &'a Box>) { - self.obj0.v.set(Some(b)) - } - fn set1(&self, b: &'a Box>) { - self.obj1.v.set(Some(b)) - } -} - - -fn f() { - let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - o1.set0(&o2); //~ ERROR `o2` does not live long enough - o1.set1(&o3); //~ ERROR `o3` does not live long enough - o2.set0(&o2); //~ ERROR `o2` does not live long enough - o2.set1(&o3); //~ ERROR `o3` does not live long enough - o3.set0(&o1); //~ ERROR `o1` does not live long enough - o3.set1(&o2); //~ ERROR `o2` does not live long enough -} - -fn main() { - f(); -} diff --git a/src/test/compile-fail/dst-bad-assign-2.rs b/src/test/compile-fail/dst-bad-assign-2.rs deleted file mode 100644 index 372f3187805..00000000000 --- a/src/test/compile-fail/dst-bad-assign-2.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Forbid assignment into a dynamically sized type. - -struct Fat { - f1: isize, - f2: &'static str, - ptr: T -} - -#[derive(PartialEq,Eq)] -struct Bar; - -#[derive(PartialEq,Eq)] -struct Bar1 { - f: isize -} - -trait ToBar { - fn to_bar(&self) -> Bar; - fn to_val(&self) -> isize; -} - -impl ToBar for Bar1 { - fn to_bar(&self) -> Bar { - Bar - } - fn to_val(&self) -> isize { - self.f - } -} - -pub fn main() { - // Assignment. - let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box = Box::new(Bar1 {f: 36}); - f5.ptr = *z; - //~^ ERROR the size for values of type - -} diff --git a/src/test/compile-fail/dst-bad-assign-3.rs b/src/test/compile-fail/dst-bad-assign-3.rs deleted file mode 100644 index 339cfb5443d..00000000000 --- a/src/test/compile-fail/dst-bad-assign-3.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Forbid assignment into a dynamically sized type. - -#![feature(unsized_tuple_coercion)] - -type Fat = (isize, &'static str, T); - -#[derive(PartialEq,Eq)] -struct Bar; - -#[derive(PartialEq,Eq)] -struct Bar1 { - f: isize -} - -trait ToBar { - fn to_bar(&self) -> Bar; - fn to_val(&self) -> isize; -} - -impl ToBar for Bar1 { - fn to_bar(&self) -> Bar { - Bar - } - fn to_val(&self) -> isize { - self.f - } -} - -pub fn main() { - // Assignment. - let f5: &mut Fat = &mut (5, "some str", Bar1 {f :42}); - let z: Box = Box::new(Bar1 {f: 36}); - f5.2 = Bar1 {f: 36}; - //~^ ERROR mismatched types - //~| expected type `dyn ToBar` - //~| found type `Bar1` - //~| expected trait ToBar, found struct `Bar1` - //~| ERROR the size for values of type -} diff --git a/src/test/compile-fail/dst-bad-assign.rs b/src/test/compile-fail/dst-bad-assign.rs deleted file mode 100644 index 9a329c636ae..00000000000 --- a/src/test/compile-fail/dst-bad-assign.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Forbid assignment into a dynamically sized type. - -struct Fat { - f1: isize, - f2: &'static str, - ptr: T -} - -#[derive(PartialEq,Eq)] -struct Bar; - -#[derive(PartialEq,Eq)] -struct Bar1 { - f: isize -} - -trait ToBar { - fn to_bar(&self) -> Bar; - fn to_val(&self) -> isize; -} - -impl ToBar for Bar1 { - fn to_bar(&self) -> Bar { - Bar - } - fn to_val(&self) -> isize { - self.f - } -} - -pub fn main() { - // Assignment. - let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box = Box::new(Bar1 {f: 36}); - f5.ptr = Bar1 {f: 36}; - //~^ ERROR mismatched types - //~| expected type `dyn ToBar` - //~| found type `Bar1` - //~| expected trait ToBar, found struct `Bar1` - //~| ERROR the size for values of type -} diff --git a/src/test/compile-fail/dst-bad-coerce1.rs b/src/test/compile-fail/dst-bad-coerce1.rs deleted file mode 100644 index b0de84a5300..00000000000 --- a/src/test/compile-fail/dst-bad-coerce1.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Attempt to change the type as well as unsizing. - -#![feature(unsized_tuple_coercion)] - -struct Fat { - ptr: T -} - -struct Foo; -trait Bar { fn bar(&self) {} } - -pub fn main() { - // With a vec of isize. - let f1 = Fat { ptr: [1, 2, 3] }; - let f2: &Fat<[isize; 3]> = &f1; - let f3: &Fat<[usize]> = f2; - //~^ ERROR mismatched types - - // With a trait. - let f1 = Fat { ptr: Foo }; - let f2: &Fat = &f1; - let f3: &Fat = f2; - //~^ ERROR `Foo: Bar` is not satisfied - - // Tuple with a vec of isize. - let f1 = ([1, 2, 3],); - let f2: &([isize; 3],) = &f1; - let f3: &([usize],) = f2; - //~^ ERROR mismatched types - - // Tuple with a trait. - let f1 = (Foo,); - let f2: &(Foo,) = &f1; - let f3: &(Bar,) = f2; - //~^ ERROR `Foo: Bar` is not satisfied -} diff --git a/src/test/compile-fail/dst-bad-coerce2.rs b/src/test/compile-fail/dst-bad-coerce2.rs deleted file mode 100644 index 9e92f649b2d..00000000000 --- a/src/test/compile-fail/dst-bad-coerce2.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Attempt to change the mutability as well as unsizing. - -struct Fat { - ptr: T -} - -struct Foo; -trait Bar {} -impl Bar for Foo {} - -pub fn main() { - // With a vec of ints. - let f1 = Fat { ptr: [1, 2, 3] }; - let f2: &Fat<[isize; 3]> = &f1; - let f3: &mut Fat<[isize]> = f2; //~ ERROR mismatched types - - // With a trait. - let f1 = Fat { ptr: Foo }; - let f2: &Fat = &f1; - let f3: &mut Fat = f2; //~ ERROR mismatched types - - // Tuple with a vec of ints. - let f1 = ([1, 2, 3],); - let f2: &([isize; 3],) = &f1; - let f3: &mut ([isize],) = f2; //~ ERROR mismatched types - - // Tuple with a trait. - let f1 = (Foo,); - let f2: &(Foo,) = &f1; - let f3: &mut (Bar,) = f2; //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/dst-bad-coerce3.rs b/src/test/compile-fail/dst-bad-coerce3.rs deleted file mode 100644 index 35a147c15bb..00000000000 --- a/src/test/compile-fail/dst-bad-coerce3.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Attempt to extend the lifetime as well as unsizing. - -#![feature(unsized_tuple_coercion)] - -struct Fat { - ptr: T -} - -struct Foo; -trait Bar { fn bar(&self) {} } -impl Bar for Foo {} - -fn baz<'a>() { - // With a vec of ints. - let f1 = Fat { ptr: [1, 2, 3] }; - let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a Fat<[isize]> = f2; - - // With a trait. - let f1 = Fat { ptr: Foo }; - let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a Fat = f2; - - // Tuple with a vec of ints. - let f1 = ([1, 2, 3],); - let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a ([isize],) = f2; - - // Tuple with a trait. - let f1 = (Foo,); - let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a (Bar,) = f2; -} - -pub fn main() { - baz(); -} diff --git a/src/test/compile-fail/dst-bad-coerce4.rs b/src/test/compile-fail/dst-bad-coerce4.rs deleted file mode 100644 index 874b7588ff9..00000000000 --- a/src/test/compile-fail/dst-bad-coerce4.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Attempt to coerce from unsized to sized. - -#![feature(unsized_tuple_coercion)] - -struct Fat { - ptr: T -} - -pub fn main() { - // With a vec of isizes. - let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; - let f2: &Fat<[isize; 3]> = f1; - //~^ ERROR mismatched types - //~| expected type `&Fat<[isize; 3]>` - //~| found type `&Fat<[isize]>` - //~| expected array of 3 elements, found slice - - // Tuple with a vec of isizes. - let f1: &([isize],) = &([1, 2, 3],); - let f2: &([isize; 3],) = f1; - //~^ ERROR mismatched types - //~| expected type `&([isize; 3],)` - //~| found type `&([isize],)` - //~| expected array of 3 elements, found slice -} diff --git a/src/test/compile-fail/dst-bad-coercions.rs b/src/test/compile-fail/dst-bad-coercions.rs deleted file mode 100644 index 883c16b0895..00000000000 --- a/src/test/compile-fail/dst-bad-coercions.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test implicit coercions involving DSTs and raw pointers. - -struct S; -trait T {} -impl T for S {} - -struct Foo { - f: T -} - -pub fn main() { - // Test that we cannot convert from *-ptr to &S and &T - let x: *const S = &S; - let y: &S = x; //~ ERROR mismatched types - let y: &T = x; //~ ERROR mismatched types - - // Test that we cannot convert from *-ptr to &S and &T (mut version) - let x: *mut S = &mut S; - let y: &S = x; //~ ERROR mismatched types - let y: &T = x; //~ ERROR mismatched types - - // Test that we cannot convert an immutable ptr to a mutable one using *-ptrs - let x: &mut T = &S; //~ ERROR mismatched types - let x: *mut T = &S; //~ ERROR mismatched types - let x: *mut S = &S; //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/dst-bad-deep-2.rs b/src/test/compile-fail/dst-bad-deep-2.rs deleted file mode 100644 index a54301071ba..00000000000 --- a/src/test/compile-fail/dst-bad-deep-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Try to initialise a DST struct where the lost information is deeply nested. -// This is an error because it requires an unsized rvalue. This is a problem -// because it would require stack allocation of an unsized temporary (*g in the -// test). - -#![feature(unsized_tuple_coercion)] - -pub fn main() { - let f: ([isize; 3],) = ([5, 6, 7],); - let g: &([isize],) = &f; - let h: &(([isize],),) = &(*g,); - //~^ ERROR the size for values of type -} diff --git a/src/test/compile-fail/dst-bad-deep.rs b/src/test/compile-fail/dst-bad-deep.rs deleted file mode 100644 index 3d7e2b8f671..00000000000 --- a/src/test/compile-fail/dst-bad-deep.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Try to initialise a DST struct where the lost information is deeply nested. -// This is an error because it requires an unsized rvalue. This is a problem -// because it would require stack allocation of an unsized temporary (*g in the -// test). - -struct Fat { - ptr: T -} - -pub fn main() { - let f: Fat<[isize; 3]> = Fat { ptr: [5, 6, 7] }; - let g: &Fat<[isize]> = &f; - let h: &Fat> = &Fat { ptr: *g }; - //~^ ERROR the size for values of type -} diff --git a/src/test/compile-fail/dst-index.rs b/src/test/compile-fail/dst-index.rs deleted file mode 100644 index c52458934bd..00000000000 --- a/src/test/compile-fail/dst-index.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that overloaded index expressions with DST result types -// can't be used as rvalues - -use std::ops::Index; -use std::fmt::Debug; - -#[derive(Copy, Clone)] -struct S; - -impl Index for S { - type Output = str; - - fn index(&self, _: usize) -> &str { - "hello" - } -} - -#[derive(Copy, Clone)] -struct T; - -impl Index for T { - type Output = Debug + 'static; - - fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) { - static x: usize = 42; - &x - } -} - -fn main() { - S[0]; - //~^ ERROR cannot move out of indexed content - //~^^ ERROR E0161 - T[0]; - //~^ ERROR cannot move out of indexed content - //~^^ ERROR E0161 -} diff --git a/src/test/compile-fail/dst-object-from-unsized-type.rs b/src/test/compile-fail/dst-object-from-unsized-type.rs deleted file mode 100644 index 70b46b1bd79..00000000000 --- a/src/test/compile-fail/dst-object-from-unsized-type.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we cannot create objects from unsized types. - -trait Foo { fn foo(&self) {} } -impl Foo for str {} -impl Foo for [u8] {} - -fn test1(t: &T) { - let u: &Foo = t; - //~^ ERROR the size for values of type -} - -fn test2(t: &T) { - let v: &Foo = t as &Foo; - //~^ ERROR the size for values of type -} - -fn test3() { - let _: &[&Foo] = &["hi"]; - //~^ ERROR the size for values of type -} - -fn test4(x: &[u8]) { - let _: &Foo = x as &Foo; - //~^ ERROR the size for values of type -} - -fn main() { } diff --git a/src/test/compile-fail/dst-rvalue.rs b/src/test/compile-fail/dst-rvalue.rs deleted file mode 100644 index 69bda8c1671..00000000000 --- a/src/test/compile-fail/dst-rvalue.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that dynamically sized rvalues are forbidden - -#![feature(box_syntax)] - -pub fn main() { - let _x: Box = box *"hello world"; - //~^ ERROR E0161 - //~^^ ERROR cannot move out of borrowed content - - let array: &[isize] = &[1, 2, 3]; - let _x: Box<[isize]> = box *array; - //~^ ERROR E0161 - //~^^ ERROR cannot move out of borrowed content -} diff --git a/src/test/compile-fail/dst-sized-trait-param.rs b/src/test/compile-fail/dst-sized-trait-param.rs deleted file mode 100644 index 7316a48970f..00000000000 --- a/src/test/compile-fail/dst-sized-trait-param.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that when you implement a trait that has a sized type -// parameter, the corresponding value must be sized. Also that the -// self type must be sized if appropriate. - -trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized - -impl Foo<[isize]> for usize { } -//~^ ERROR the size for values of type - -impl Foo for [usize] { } -//~^ ERROR the size for values of type - -pub fn main() { } diff --git a/src/test/compile-fail/dupe-symbols-1.rs b/src/test/compile-fail/dupe-symbols-1.rs deleted file mode 100644 index 9fa4eafcad0..00000000000 --- a/src/test/compile-fail/dupe-symbols-1.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -#![crate_type="rlib"] -#![allow(warnings)] - -#[export_name="fail"] -pub fn a() { -} - -#[export_name="fail"] -pub fn b() { -//~^ symbol `fail` is already defined -} diff --git a/src/test/compile-fail/dupe-symbols-2.rs b/src/test/compile-fail/dupe-symbols-2.rs deleted file mode 100644 index 1f19bd2f249..00000000000 --- a/src/test/compile-fail/dupe-symbols-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -#![crate_type="rlib"] -#![allow(warnings)] - -pub mod a { - #[no_mangle] - pub extern fn fail() { - } -} - -pub mod b { - #[no_mangle] - pub extern fn fail() { - //~^ symbol `fail` is already defined - } -} diff --git a/src/test/compile-fail/dupe-symbols-3.rs b/src/test/compile-fail/dupe-symbols-3.rs deleted file mode 100644 index 98a61c33c58..00000000000 --- a/src/test/compile-fail/dupe-symbols-3.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -#![crate_type="rlib"] -#![allow(warnings)] - -#[export_name="fail"] -pub fn a() { -} - -#[no_mangle] -pub fn fail() { -//~^ symbol `fail` is already defined -} diff --git a/src/test/compile-fail/dupe-symbols-4.rs b/src/test/compile-fail/dupe-symbols-4.rs deleted file mode 100644 index 9e730699d25..00000000000 --- a/src/test/compile-fail/dupe-symbols-4.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// error-pattern: symbol `fail` is already defined -#![crate_type="rlib"] -#![allow(warnings)] - - -pub trait A { - fn fail(self); -} - -struct B; -struct C; - -impl A for B { - #[no_mangle] - fn fail(self) {} -} - -impl A for C { - #[no_mangle] - fn fail(self) {} -} diff --git a/src/test/compile-fail/dupe-symbols-5.rs b/src/test/compile-fail/dupe-symbols-5.rs deleted file mode 100644 index eb4b50d03ca..00000000000 --- a/src/test/compile-fail/dupe-symbols-5.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -#![crate_type="rlib"] -#![allow(warnings)] - -#[export_name="fail"] -static HELLO: u8 = 0; - -#[export_name="fail"] -pub fn b() { -//~^ symbol `fail` is already defined -} diff --git a/src/test/compile-fail/dupe-symbols-6.rs b/src/test/compile-fail/dupe-symbols-6.rs deleted file mode 100644 index 6f412d9a0de..00000000000 --- a/src/test/compile-fail/dupe-symbols-6.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![crate_type="rlib"] -#![allow(warnings)] - -#[export_name="fail"] -static HELLO: u8 = 0; - -#[export_name="fail"] -static HELLO_TWICE: u16 = 0; -//~^ symbol `fail` is already defined diff --git a/src/test/compile-fail/dupe-symbols-7.rs b/src/test/compile-fail/dupe-symbols-7.rs deleted file mode 100644 index c2880ba6f51..00000000000 --- a/src/test/compile-fail/dupe-symbols-7.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// error-pattern: entry symbol `main` defined multiple times -#![allow(warnings)] - -#[no_mangle] -fn main(){} diff --git a/src/test/compile-fail/duplicate-parameter.rs b/src/test/compile-fail/duplicate-parameter.rs deleted file mode 100644 index 7586bc61cd6..00000000000 --- a/src/test/compile-fail/duplicate-parameter.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f(a: isize, a: isize) {} -//~^ ERROR identifier `a` is bound more than once in this parameter list - -fn main() { -} diff --git a/src/test/compile-fail/duplicate-type-parameter.rs b/src/test/compile-fail/duplicate-type-parameter.rs deleted file mode 100644 index 3b0f8ee5bda..00000000000 --- a/src/test/compile-fail/duplicate-type-parameter.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -type Foo = Option; -//~^ ERROR the name `T` is already used - -struct Bar(T); -//~^ ERROR the name `T` is already used - -struct Baz { -//~^ ERROR the name `T` is already used - x: T, -} - -enum Boo { -//~^ ERROR the name `T` is already used - A(T), - B, -} - -fn quux(x: T) {} -//~^ ERROR the name `T` is already used - -trait Qux {} -//~^ ERROR the name `T` is already used - -impl Qux for Option {} -//~^ ERROR the name `T` is already used -//~^^ ERROR the type parameter `T` is not constrained - -fn main() { -} diff --git a/src/test/compile-fail/duplicate_entry_error.rs b/src/test/compile-fail/duplicate_entry_error.rs deleted file mode 100644 index 176aa7cca53..00000000000 --- a/src/test/compile-fail/duplicate_entry_error.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// note-pattern: first defined in crate `std`. - -// Test for issue #31788 and E0152 - -#![feature(lang_items)] - -use std::panic::PanicInfo; - -#[lang = "panic_impl"] -fn panic_impl(info: &PanicInfo) -> ! { -//~^ ERROR: duplicate lang item found: `panic_impl`. - loop {} -} - -fn main() {} diff --git a/src/test/compile-fail/dyn-trait-compatibility.rs b/src/test/compile-fail/dyn-trait-compatibility.rs deleted file mode 100644 index 454b6d2f566..00000000000 --- a/src/test/compile-fail/dyn-trait-compatibility.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -type A0 = dyn; -//~^ ERROR cannot find type `dyn` in this scope -type A1 = dyn::dyn; -//~^ ERROR Use of undeclared type or module `dyn` -type A2 = dyn; -//~^ ERROR cannot find type `dyn` in this scope -//~| ERROR cannot find type `dyn` in this scope -//~| ERROR cannot find type `dyn` in this scope -type A3 = dyn<::dyn>; -//~^ ERROR cannot find type `dyn` in this scope -//~| ERROR cannot find type `dyn` in this scope -//~| ERROR Use of undeclared type or module `dyn` - -fn main() {} diff --git a/src/test/compile-fail/edition-extern-crate-allowed.rs b/src/test/compile-fail/edition-extern-crate-allowed.rs deleted file mode 100644 index 7368564e250..00000000000 --- a/src/test/compile-fail/edition-extern-crate-allowed.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:edition-extern-crate-allowed.rs -// compile-flags: --edition 2015 -// compile-pass - -#![warn(rust_2018_idioms)] - -extern crate edition_extern_crate_allowed; -//~^ WARNING unused extern crate - -fn main() {} diff --git a/src/test/compile-fail/edition-feature-ok.rs b/src/test/compile-fail/edition-feature-ok.rs deleted file mode 100644 index 3a3a6ff95f9..00000000000 --- a/src/test/compile-fail/edition-feature-ok.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:--edition 2018 -// compile-pass - -#![feature(rust_2018_preview)] - -fn main() {} diff --git a/src/test/compile-fail/edition-raw-pointer-method-2015.rs b/src/test/compile-fail/edition-raw-pointer-method-2015.rs deleted file mode 100644 index 4ba44fa54d8..00000000000 --- a/src/test/compile-fail/edition-raw-pointer-method-2015.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// edition:2015 - -// tests that editions work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: type annotations needed [tyvar_behind_raw_pointer] - //~^^ warning: this was previously accepted -} diff --git a/src/test/compile-fail/edition-raw-pointer-method-2018.rs b/src/test/compile-fail/edition-raw-pointer-method-2018.rs deleted file mode 100644 index c8548ed35b9..00000000000 --- a/src/test/compile-fail/edition-raw-pointer-method-2018.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// edition:2018 - -// tests that editions work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0699] -} diff --git a/src/test/compile-fail/elided-test.rs b/src/test/compile-fail/elided-test.rs deleted file mode 100644 index 0cdd0010a74..00000000000 --- a/src/test/compile-fail/elided-test.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: `main` function not found - -// Since we're not compiling a test runner this function should be elided -// and the build will fail because main doesn't exist -#[test] -fn main() { -} diff --git a/src/test/compile-fail/empty-comment.rs b/src/test/compile-fail/empty-comment.rs deleted file mode 100644 index a5568ff826b..00000000000 --- a/src/test/compile-fail/empty-comment.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// `/**/` was previously regarded as a doc comment because it starts with `/**` and ends with `*/`. -// This could break some internal logic that assumes the length of a doc comment is at least 5, -// leading to an ICE. - -macro_rules! one_arg_macro { - ($fmt:expr) => (print!(concat!($fmt, "\n"))); -} - -fn main() { - one_arg_macro!(/**/); //~ ERROR unexpected end -} diff --git a/src/test/compile-fail/empty-extern-arg.rs b/src/test/compile-fail/empty-extern-arg.rs deleted file mode 100644 index 8791481d9e7..00000000000 --- a/src/test/compile-fail/empty-extern-arg.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --extern std= -// error-pattern: can't find crate for `std` - -fn main() {} diff --git a/src/test/compile-fail/empty-linkname.rs b/src/test/compile-fail/empty-linkname.rs deleted file mode 100644 index 20e0f9cd0b2..00000000000 --- a/src/test/compile-fail/empty-linkname.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "")] //~ ERROR: given with empty name -extern { -} - -fn main() {} diff --git a/src/test/compile-fail/empty-macro-use.rs b/src/test/compile-fail/empty-macro-use.rs deleted file mode 100644 index 823a7426079..00000000000 --- a/src/test/compile-fail/empty-macro-use.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:two_macros.rs - -#[macro_use()] -extern crate two_macros; - -pub fn main() { - macro_two!(); - //~^ ERROR cannot find macro -} diff --git a/src/test/compile-fail/empty-never-array.rs b/src/test/compile-fail/empty-never-array.rs deleted file mode 100644 index 53b24e17319..00000000000 --- a/src/test/compile-fail/empty-never-array.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] - -enum Helper { - T(T, [!; 0]), - #[allow(dead_code)] - U(U), -} - -fn transmute(t: T) -> U { - let Helper::U(u) = Helper::T(t, []); - //~^ ERROR refutable pattern in local binding: `T(_, _)` not covered - u -} - -fn main() { - println!("{:?}", transmute::<&str, (*const u8, u64)>("type safety")); -} diff --git a/src/test/compile-fail/empty-struct-braces-expr.rs b/src/test/compile-fail/empty-struct-braces-expr.rs deleted file mode 100644 index 3096e8f8313..00000000000 --- a/src/test/compile-fail/empty-struct-braces-expr.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Can't use empty braced struct as constant or constructor function - -// aux-build:empty-struct.rs - -extern crate empty_struct; -use empty_struct::*; - -struct Empty1 {} - -enum E { - Empty3 {} -} - -fn main() { - let e1 = Empty1; //~ ERROR expected value, found struct `Empty1` - let e1 = Empty1(); //~ ERROR expected function, found struct `Empty1` - let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3` - let e3 = E::Empty3(); //~ ERROR expected function, found struct variant `E::Empty3` - - let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1` - let xe1 = XEmpty1(); //~ ERROR expected function, found struct `XEmpty1` - let xe3 = XE::Empty3; //~ ERROR no variant named `Empty3` found for type - let xe3 = XE::Empty3(); //~ ERROR no variant named `Empty3` found for type -} diff --git a/src/test/compile-fail/empty-struct-braces-pat-1.rs b/src/test/compile-fail/empty-struct-braces-pat-1.rs deleted file mode 100644 index e527170e9f9..00000000000 --- a/src/test/compile-fail/empty-struct-braces-pat-1.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Can't use empty braced struct as constant pattern - -// aux-build:empty-struct.rs - -extern crate empty_struct; -use empty_struct::*; - -struct Empty1 {} - -enum E { - Empty3 {} -} - -fn main() { - let e1 = Empty1 {}; - let e3 = E::Empty3 {}; - let xe1 = XEmpty1 {}; - let xe3 = XE::XEmpty3 {}; - - match e1 { - Empty1 => () // Not an error, `Empty1` is interpreted as a new binding - } - match e3 { - E::Empty3 => () - //~^ ERROR expected unit struct/variant or constant, found struct variant `E::Empty3` - } - match xe1 { - XEmpty1 => () // Not an error, `XEmpty1` is interpreted as a new binding - } - match xe3 { - XE::XEmpty3 => () - //~^ ERROR expected unit struct/variant or constant, found struct variant `XE::XEmpty3` - } -} diff --git a/src/test/compile-fail/empty-struct-braces-pat-2.rs b/src/test/compile-fail/empty-struct-braces-pat-2.rs deleted file mode 100644 index d3b13457dc6..00000000000 --- a/src/test/compile-fail/empty-struct-braces-pat-2.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Can't use empty braced struct as enum pattern - -// aux-build:empty-struct.rs - -extern crate empty_struct; -use empty_struct::*; - -struct Empty1 {} - -fn main() { - let e1 = Empty1 {}; - let xe1 = XEmpty1 {}; - - match e1 { - Empty1() => () //~ ERROR expected tuple struct/variant, found struct `Empty1` - } - match xe1 { - XEmpty1() => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` - } - match e1 { - Empty1(..) => () //~ ERROR expected tuple struct/variant, found struct `Empty1` - } - match xe1 { - XEmpty1(..) => () //~ ERROR expected tuple struct/variant, found struct `XEmpty1` - } -} diff --git a/src/test/compile-fail/empty-struct-braces-pat-3.rs b/src/test/compile-fail/empty-struct-braces-pat-3.rs deleted file mode 100644 index d6c5b953492..00000000000 --- a/src/test/compile-fail/empty-struct-braces-pat-3.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Can't use empty braced struct as enum pattern - -// aux-build:empty-struct.rs - -extern crate empty_struct; -use empty_struct::*; - -enum E { - Empty3 {} -} - -fn main() { - let e3 = E::Empty3 {}; - let xe3 = XE::XEmpty3 {}; - - match e3 { - E::Empty3() => () - //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3` - } - match xe3 { - XE::XEmpty3() => () - //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3` - } - match e3 { - E::Empty3(..) => () - //~^ ERROR expected tuple struct/variant, found struct variant `E::Empty3` - } - match xe3 { - XE::XEmpty3(..) => () - //~^ ERROR expected tuple struct/variant, found struct variant `XE::XEmpty3 - } -} diff --git a/src/test/compile-fail/empty-struct-tuple-pat.rs b/src/test/compile-fail/empty-struct-tuple-pat.rs deleted file mode 100644 index 5e683eafade..00000000000 --- a/src/test/compile-fail/empty-struct-tuple-pat.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Can't use unit struct as enum pattern - -// aux-build:empty-struct.rs - -extern crate empty_struct; -use empty_struct::*; - -struct Empty2(); - -enum E { - Empty4() -} - -// remove attribute after warning cycle and promoting warnings to errors -fn main() { - let e2 = Empty2(); - let e4 = E::Empty4(); - let xe6 = XEmpty6(); - let xe5 = XE::XEmpty5(); - - match e2 { - Empty2 => () //~ ERROR match bindings cannot shadow tuple structs - } - match xe6 { - XEmpty6 => () //~ ERROR match bindings cannot shadow tuple structs - } - - match e4 { - E::Empty4 => () - //~^ ERROR expected unit struct/variant or constant, found tuple variant `E::Empty4` - } - match xe5 { - XE::XEmpty5 => (), - //~^ ERROR expected unit struct/variant or constant, found tuple variant `XE::XEmpty5` - _ => {}, - } -} diff --git a/src/test/compile-fail/empty-struct-unit-pat.rs b/src/test/compile-fail/empty-struct-unit-pat.rs deleted file mode 100644 index 532c2d85053..00000000000 --- a/src/test/compile-fail/empty-struct-unit-pat.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Can't use unit struct as tuple struct pattern - -// aux-build:empty-struct.rs - -extern crate empty_struct; -use empty_struct::*; - -struct Empty2; - -enum E { - Empty4 -} - -fn main() { - let e2 = Empty2; - let e4 = E::Empty4; - let xe2 = XEmpty2; - let xe4 = XE::XEmpty4; - - match e2 { - Empty2() => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` - } - match xe2 { - XEmpty2() => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` - } - match e2 { - Empty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `Empty2` - } - match xe2 { - XEmpty2(..) => () //~ ERROR expected tuple struct/variant, found unit struct `XEmpty2` - } - - match e4 { - E::Empty4() => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` - } - match xe4 { - XE::XEmpty4() => (), - //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4` - _ => {}, - } - match e4 { - E::Empty4(..) => () //~ ERROR expected tuple struct/variant, found unit variant `E::Empty4` - } - match xe4 { - XE::XEmpty4(..) => (), - //~^ ERROR expected tuple struct/variant, found unit variant `XE::XEmpty4` - _ => {}, - } -} diff --git a/src/test/compile-fail/enable-unstable-lib-feature.rs b/src/test/compile-fail/enable-unstable-lib-feature.rs deleted file mode 100644 index b10a0a60f14..00000000000 --- a/src/test/compile-fail/enable-unstable-lib-feature.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that enabling an unstable feature disables warnings - -// aux-build:stability_cfg2.rs - -#![feature(unstable_test_feature)] -#![deny(non_snake_case)] // To trigger a hard error - -// Shouldn't generate a warning about unstable features -#[allow(unused_extern_crates)] -extern crate stability_cfg2; - -pub fn BOGUS() { } //~ ERROR - -pub fn main() { } diff --git a/src/test/compile-fail/enum-discrim-autosizing.rs b/src/test/compile-fail/enum-discrim-autosizing.rs deleted file mode 100644 index 3a243330ad9..00000000000 --- a/src/test/compile-fail/enum-discrim-autosizing.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// With no repr attribute the discriminant will default to isize. -// On 32-bit architectures this is equivalent to i32 so the variants -// collide. On other architectures we need compilation to fail anyway, -// so force the repr. -#[cfg_attr(not(target_pointer_width = "32"), repr(i32))] -enum Eu64 { - Au64 = 0, - Bu64 = 0x8000_0000_0000_0000 //~ERROR already exists -} - diff --git a/src/test/compile-fail/enum-discrim-too-small.rs b/src/test/compile-fail/enum-discrim-too-small.rs deleted file mode 100644 index 393a67be57f..00000000000 --- a/src/test/compile-fail/enum-discrim-too-small.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#[repr(u8)] -enum Eu8 { - Au8 = 23, - Bu8 = 223, - Cu8 = -23, - //~^ ERROR cannot apply unary operator `-` to type `u8` -} - -#[repr(u16)] -enum Eu16 { - Au16 = 23, - Bu16 = 55555, - Cu16 = -22333, - //~^ ERROR cannot apply unary operator `-` to type `u16` -} - -#[repr(u32)] -enum Eu32 { - Au32 = 23, - Bu32 = 3_000_000_000, - Cu32 = -2_000_000_000, - //~^ ERROR cannot apply unary operator `-` to type `u32` -} - -#[repr(u64)] -enum Eu64 { - Au32 = 23, - Bu32 = 3_000_000_000, - Cu32 = -2_000_000_000, - //~^ ERROR cannot apply unary operator `-` to type `u64` -} - -// u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`. This is a -// little counterintuitive, but since the discriminant can store all the bits, and extracting it -// with a cast requires specifying the signedness, there is no loss of information in those cases. -// This also applies to isize and usize on 64-bit targets. - -pub fn main() { } diff --git a/src/test/compile-fail/enum-discrim-too-small2.rs b/src/test/compile-fail/enum-discrim-too-small2.rs deleted file mode 100644 index d66716c14c3..00000000000 --- a/src/test/compile-fail/enum-discrim-too-small2.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(overflowing_literals)] -#![allow(dead_code)] - -#[repr(i8)] -enum Ei8 { - Ai8 = 23, - Bi8 = -23, - Ci8 = 223, //~ ERROR literal out of range for i8 -} - -#[repr(i16)] -enum Ei16 { - Ai16 = 23, - Bi16 = -22333, - Ci16 = 55555, //~ ERROR literal out of range for i16 -} - -#[repr(i32)] -enum Ei32 { - Ai32 = 23, - Bi32 = -2_000_000_000, - Ci32 = 3_000_000_000, //~ ERROR literal out of range for i32 -} - -#[repr(i64)] -enum Ei64 { - Ai64 = 23, - Bi64 = -9223372036854775808, - Ci64 = 9223372036854775809, //~ ERROR literal out of range for i64 -} - -// u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`. This is a -// little counterintuitive, but since the discriminant can store all the bits, and extracting it -// with a cast requires specifying the signedness, there is no loss of information in those cases. -// This also applies to isize and usize on 64-bit targets. - -pub fn main() { } diff --git a/src/test/compile-fail/enum-in-scope.rs b/src/test/compile-fail/enum-in-scope.rs deleted file mode 100644 index bc1bd03f2d6..00000000000 --- a/src/test/compile-fail/enum-in-scope.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct hello(isize); - -fn main() { - let hello = 0; //~ERROR let bindings cannot shadow tuple structs -} diff --git a/src/test/compile-fail/enum-to-float-cast-2.rs b/src/test/compile-fail/enum-to-float-cast-2.rs deleted file mode 100644 index e6f473c8aac..00000000000 --- a/src/test/compile-fail/enum-to-float-cast-2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that enum-to-float casts are disallowed. - -enum E { - L0 = -1, - H0 = 1 -} - -enum F { - L1 = 1, - H1 = 0xFFFFFFFFFFFFFFFF -} - -pub fn main() { - let a = E::L0 as f32; //~ ERROR casting - let c = F::H1 as f32; //~ ERROR casting - assert_eq!(a, -1.0f32); - assert_eq!(c, -1.0f32); -} diff --git a/src/test/compile-fail/enum-to-float-cast.rs b/src/test/compile-fail/enum-to-float-cast.rs deleted file mode 100644 index b562ba0e41a..00000000000 --- a/src/test/compile-fail/enum-to-float-cast.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that enum-to-float casts are disallowed. - -enum E { - L0 = -1, - H0 = 1 -} - -enum F { - L1 = 1, - H1 = 0xFFFFFFFFFFFFFFFF -} - -static C0: f32 = E::L0 as f32; //~ ERROR casting -static C1: f32 = F::H1 as f32; //~ ERROR casting - -pub fn main() { - let b = C0; - let d = C1; - assert_eq!(b, -1.0f32); - assert_eq!(d, -1.0f32); -} diff --git a/src/test/compile-fail/enum-variant-type-2.rs b/src/test/compile-fail/enum-variant-type-2.rs deleted file mode 100644 index 258bfd1e3ba..00000000000 --- a/src/test/compile-fail/enum-variant-type-2.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that enum variants are not actually types. - -enum Foo { - Bar -} - -fn foo(x: Foo::Bar) {} //~ ERROR expected type, found variant `Foo::Bar` - -fn main() {} diff --git a/src/test/compile-fail/enums-pats-not-idents.rs b/src/test/compile-fail/enums-pats-not-idents.rs deleted file mode 100644 index 36bd54f599b..00000000000 --- a/src/test/compile-fail/enums-pats-not-idents.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let a(1) = 13; //~ ERROR cannot find tuple struct/variant `a` in this scope -} diff --git a/src/test/compile-fail/error-should-say-copy-not-pod.rs b/src/test/compile-fail/error-should-say-copy-not-pod.rs deleted file mode 100644 index 8b1e2fc1966..00000000000 --- a/src/test/compile-fail/error-should-say-copy-not-pod.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that the error message uses the word Copy, not Pod. - -fn check_bound(_: T) {} - -fn main() { - check_bound("nocopy".to_string()); //~ ERROR : std::marker::Copy` is not satisfied -} diff --git a/src/test/compile-fail/estr-subtyping.rs b/src/test/compile-fail/estr-subtyping.rs deleted file mode 100644 index b5c6db0cea9..00000000000 --- a/src/test/compile-fail/estr-subtyping.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn wants_uniq(x: String) { } -fn wants_slice(x: &str) { } - -fn has_uniq(x: String) { - wants_uniq(x); - wants_slice(&*x); -} - -fn has_slice(x: &str) { - wants_uniq(x); //~ ERROR mismatched types - wants_slice(x); -} - -fn main() { -} diff --git a/src/test/compile-fail/eval-enum.rs b/src/test/compile-fail/eval-enum.rs deleted file mode 100644 index ada038114d8..00000000000 --- a/src/test/compile-fail/eval-enum.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Test { - DivZero = 1/0, - //~^ attempt to divide by zero - //~| ERROR could not evaluate enum discriminant - //~| ERROR this expression will panic at runtime - RemZero = 1%0, - //~^ attempt to calculate the remainder with a divisor of zero - //~| ERROR could not evaluate enum discriminant - //~| ERROR this expression will panic at runtime -} - -fn main() {} diff --git a/src/test/compile-fail/exclusive-drop-and-copy.rs b/src/test/compile-fail/exclusive-drop-and-copy.rs deleted file mode 100644 index b4cb2469659..00000000000 --- a/src/test/compile-fail/exclusive-drop-and-copy.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// issue #20126 - -#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented -struct Foo; - -impl Drop for Foo { - fn drop(&mut self) {} -} - -#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented -struct Bar(::std::marker::PhantomData); - -impl Drop for Bar { - fn drop(&mut self) {} -} - -fn main() {} diff --git a/src/test/compile-fail/exclusive_range_pattern_syntax_collision.rs b/src/test/compile-fail/exclusive_range_pattern_syntax_collision.rs deleted file mode 100644 index 69e5898ed4d..00000000000 --- a/src/test/compile-fail/exclusive_range_pattern_syntax_collision.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(exclusive_range_pattern)] - -fn main() { - match [5..4, 99..105, 43..44] { - [_, 99.., _] => {}, //~ ERROR unexpected token: `,` - _ => {}, - } -} diff --git a/src/test/compile-fail/exclusive_range_pattern_syntax_collision2.rs b/src/test/compile-fail/exclusive_range_pattern_syntax_collision2.rs deleted file mode 100644 index 9212ea86118..00000000000 --- a/src/test/compile-fail/exclusive_range_pattern_syntax_collision2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(exclusive_range_pattern)] - -fn main() { - match [5..4, 99..105, 43..44] { - [_, 99..] => {}, //~ ERROR unexpected token: `]` - _ => {}, - } -} diff --git a/src/test/compile-fail/exclusive_range_pattern_syntax_collision3.rs b/src/test/compile-fail/exclusive_range_pattern_syntax_collision3.rs deleted file mode 100644 index d83305857ac..00000000000 --- a/src/test/compile-fail/exclusive_range_pattern_syntax_collision3.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(exclusive_range_pattern)] - -fn main() { - match [5..4, 99..105, 43..44] { - [..9, 99..100, _] => {}, //~ ERROR expected one of `,` or `]`, found `9` - _ => {}, - } -} diff --git a/src/test/compile-fail/expanded-cfg.rs b/src/test/compile-fail/expanded-cfg.rs deleted file mode 100644 index 77351f6e4f1..00000000000 --- a/src/test/compile-fail/expanded-cfg.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(custom_attribute, rustc_attrs)] - -macro_rules! mac { - {} => { - #[cfg(attr)] - mod m { - #[lang_item] - fn f() {} - - #[cfg_attr(target_thread_local, custom)] - fn g() {} - } - - #[cfg(attr)] - unconfigured_invocation!(); - } -} - -mac! {} - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/explicit-call-to-dtor.rs b/src/test/compile-fail/explicit-call-to-dtor.rs deleted file mode 100644 index 90030488dd6..00000000000 --- a/src/test/compile-fail/explicit-call-to-dtor.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - x: isize -} - -impl Drop for Foo { - fn drop(&mut self) { - println!("kaboom"); - } -} - -fn main() { - let x = Foo { x: 3 }; - x.drop(); //~ ERROR explicit use of destructor method -} diff --git a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs b/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs deleted file mode 100644 index 63ed74dfa49..00000000000 --- a/src/test/compile-fail/explicit-call-to-supertrait-dtor.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - x: isize -} - -trait Bar : Drop { - fn blah(&self); -} - -impl Drop for Foo { - fn drop(&mut self) { - println!("kaboom"); - } -} - -impl Bar for Foo { - fn blah(&self) { - self.drop(); //~ ERROR explicit use of destructor method - } -} - -fn main() { - let x = Foo { x: 3 }; -} diff --git a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs deleted file mode 100644 index eac134ff3cc..00000000000 --- a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo<'a,'b> { - x: &'a isize, - y: &'b isize, -} - -impl<'a,'b> Foo<'a,'b> { - fn bar(self: - Foo<'b,'a> - //~^ ERROR mismatched method receiver - //~| expected type `Foo<'a, 'b>` - //~| found type `Foo<'b, 'a>` - //~| lifetime mismatch - //~| ERROR mismatched method receiver - //~| expected type `Foo<'a, 'b>` - //~| found type `Foo<'b, 'a>` - //~| lifetime mismatch - ) {} -} - -fn main() {} diff --git a/src/test/compile-fail/export-fully-qualified.rs b/src/test/compile-fail/export-fully-qualified.rs deleted file mode 100644 index 19fa13f8377..00000000000 --- a/src/test/compile-fail/export-fully-qualified.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// In this test baz isn't resolved when called as foo.baz even though -// it's called from inside foo. This is somewhat surprising and may -// want to change eventually. - -mod foo { - pub fn bar() { foo::baz(); } //~ ERROR failed to resolve. Use of undeclared type or module `foo` - - fn baz() { } -} - -fn main() { } diff --git a/src/test/compile-fail/export-import.rs b/src/test/compile-fail/export-import.rs deleted file mode 100644 index 3877250126d..00000000000 --- a/src/test/compile-fail/export-import.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use m::unexported; -//~^ ERROR: is private - -mod m { - pub fn exported() { } - - fn unexported() { } -} - - -fn main() { unexported(); } diff --git a/src/test/compile-fail/export-tag-variant.rs b/src/test/compile-fail/export-tag-variant.rs deleted file mode 100644 index b6e8cf71ddd..00000000000 --- a/src/test/compile-fail/export-tag-variant.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub fn x() { } - - enum y { y1, } -} - -fn main() { let z = foo::y::y1; } //~ ERROR: enum `y` is private diff --git a/src/test/compile-fail/export.rs b/src/test/compile-fail/export.rs deleted file mode 100644 index c28ea70c752..00000000000 --- a/src/test/compile-fail/export.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub fn x(y: isize) { log(debug, y); } - //~^ ERROR cannot find function `log` in this scope - //~| ERROR cannot find value `debug` in this scope - fn z(y: isize) { log(debug, y); } - //~^ ERROR cannot find function `log` in this scope - //~| ERROR cannot find value `debug` in this scope -} - -fn main() { foo::z(10); } //~ ERROR function `z` is private diff --git a/src/test/compile-fail/export2.rs b/src/test/compile-fail/export2.rs deleted file mode 100644 index dc96ce7f504..00000000000 --- a/src/test/compile-fail/export2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub fn x() { bar::x(); } //~ ERROR failed to resolve. Use of undeclared type or module `bar` -} - -mod bar { - fn x() { println!("x"); } - - pub fn y() { } -} - -fn main() { foo::x(); } diff --git a/src/test/compile-fail/expr_attr_paren_order.rs b/src/test/compile-fail/expr_attr_paren_order.rs deleted file mode 100644 index 49b2fa0e350..00000000000 --- a/src/test/compile-fail/expr_attr_paren_order.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(stmt_expr_attributes)] - -fn main() { - - // Test that attributes on parens get concatenated - // in the expected order in the hir folder. - - #[deny(non_snake_case)] ( - #![allow(non_snake_case)] - { - let X = 0; - let _ = X; - } - ); - - #[allow(non_snake_case)] ( - #![deny(non_snake_case)] - { - let X = 0; //~ ERROR snake case name - let _ = X; - } - ); - -} diff --git a/src/test/compile-fail/ext-nonexistent.rs b/src/test/compile-fail/ext-nonexistent.rs deleted file mode 100644 index a5bf7960624..00000000000 --- a/src/test/compile-fail/ext-nonexistent.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:cannot find macro -fn main() { iamnotanextensionthatexists!(""); } diff --git a/src/test/compile-fail/extenv-arg-2-not-string-literal.rs b/src/test/compile-fail/extenv-arg-2-not-string-literal.rs deleted file mode 100644 index c2362689721..00000000000 --- a/src/test/compile-fail/extenv-arg-2-not-string-literal.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { env!("one", 10); } //~ ERROR: expected string literal diff --git a/src/test/compile-fail/extenv-no-args.rs b/src/test/compile-fail/extenv-no-args.rs deleted file mode 100644 index afa47dbe744..00000000000 --- a/src/test/compile-fail/extenv-no-args.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { env!(); } //~ ERROR: env! takes 1 or 2 arguments diff --git a/src/test/compile-fail/extenv-not-defined-custom.rs b/src/test/compile-fail/extenv-not-defined-custom.rs deleted file mode 100644 index 485b6c09f0a..00000000000 --- a/src/test/compile-fail/extenv-not-defined-custom.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); } //~ ERROR: my error message diff --git a/src/test/compile-fail/extenv-not-defined-default.rs b/src/test/compile-fail/extenv-not-defined-default.rs deleted file mode 100644 index d99d4dc33a2..00000000000 --- a/src/test/compile-fail/extenv-not-defined-default.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - env!("__HOPEFULLY_NOT_DEFINED__"); - //~^ ERROR: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined -} diff --git a/src/test/compile-fail/extenv-not-string-literal.rs b/src/test/compile-fail/extenv-not-string-literal.rs deleted file mode 100644 index 07ce47a14d8..00000000000 --- a/src/test/compile-fail/extenv-not-string-literal.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { env!(10, "two"); } //~ ERROR: expected string literal diff --git a/src/test/compile-fail/extenv-too-many-args.rs b/src/test/compile-fail/extenv-too-many-args.rs deleted file mode 100644 index c6c4f0ec6b8..00000000000 --- a/src/test/compile-fail/extenv-too-many-args.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { env!("one", "two", "three"); } //~ ERROR: env! takes 1 or 2 arguments diff --git a/src/test/compile-fail/extern-crate-visibility.rs b/src/test/compile-fail/extern-crate-visibility.rs deleted file mode 100644 index 6bb88e40910..00000000000 --- a/src/test/compile-fail/extern-crate-visibility.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - extern crate core; -} - -// Check that private crates can be used from outside their modules, albeit with warnings -use foo::core::cell; //~ ERROR extern crate `core` is private - -fn f() { - foo::core::cell::Cell::new(0); //~ ERROR extern crate `core` is private - - use foo::*; - mod core {} // Check that private crates are not glob imported -} - -mod bar { - pub extern crate core; -} - -mod baz { - pub use bar::*; - use self::core::cell; // Check that public extern crates are glob imported -} - -fn main() {} diff --git a/src/test/compile-fail/extern-macro.rs b/src/test/compile-fail/extern-macro.rs deleted file mode 100644 index 4267103ab9a..00000000000 --- a/src/test/compile-fail/extern-macro.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// #41719 - -#![feature(use_extern_macros)] - -fn main() { - enum Foo {} - let _ = Foo::bar!(); //~ ERROR fail to resolve non-ident macro path -} diff --git a/src/test/compile-fail/extern-main-fn.rs b/src/test/compile-fail/extern-main-fn.rs deleted file mode 100644 index d9bdb4ecd04..00000000000 --- a/src/test/compile-fail/extern-main-fn.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern fn main() {} //~ ERROR: main function has wrong type [E0580] diff --git a/src/test/compile-fail/extern-types-distinct-types.rs b/src/test/compile-fail/extern-types-distinct-types.rs deleted file mode 100644 index 8b434bbfc6d..00000000000 --- a/src/test/compile-fail/extern-types-distinct-types.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(extern_types)] - -extern { - type A; - type B; -} - -fn foo(r: &A) -> &B { - r //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/extern-types-not-sync-send.rs b/src/test/compile-fail/extern-types-not-sync-send.rs deleted file mode 100644 index 10abb80a2f7..00000000000 --- a/src/test/compile-fail/extern-types-not-sync-send.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Make sure extern types are !Sync and !Send. - -#![feature(extern_types)] - -extern { - type A; -} - -fn assert_sync() { } -fn assert_send() { } - -fn main() { - assert_sync::(); - //~^ ERROR `A` cannot be shared between threads safely [E0277] - - assert_send::(); - //~^ ERROR `A` cannot be sent between threads safely [E0277] -} diff --git a/src/test/compile-fail/extern-types-unsized.rs b/src/test/compile-fail/extern-types-unsized.rs deleted file mode 100644 index f2db4553868..00000000000 --- a/src/test/compile-fail/extern-types-unsized.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Make sure extern types are !Sized. - -#![feature(extern_types)] - -extern { - type A; -} - -struct Foo { - x: u8, - tail: A, -} - -struct Bar { - x: u8, - tail: T, -} - -fn assert_sized() { } - -fn main() { - assert_sized::(); - //~^ ERROR the size for values of type - - assert_sized::(); - //~^ ERROR the size for values of type - - assert_sized::>(); - //~^ ERROR the size for values of type - - assert_sized::>>(); - //~^ ERROR the size for values of type -} diff --git a/src/test/compile-fail/extern-with-type-bounds.rs b/src/test/compile-fail/extern-with-type-bounds.rs deleted file mode 100644 index 9493a1ae892..00000000000 --- a/src/test/compile-fail/extern-with-type-bounds.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(intrinsics)] - -extern "rust-intrinsic" { - // Real example from libcore - fn type_id() -> u64; - - // Silent bounds made explicit to make sure they are actually - // resolved. - fn transmute(val: T) -> U; - - // Bounds aren't checked right now, so this should work - // even though it's incorrect. - fn size_of() -> usize; - - // Unresolved bounds should still error. - fn align_of() -> usize; - //~^ ERROR cannot find trait `NoSuchTrait` in this scope -} - -fn main() {} diff --git a/src/test/compile-fail/extern-wrong-value-type.rs b/src/test/compile-fail/extern-wrong-value-type.rs deleted file mode 100644 index 66b06c505e4..00000000000 --- a/src/test/compile-fail/extern-wrong-value-type.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern fn f() { -} - -fn is_fn(_: F) where F: Fn() {} - -fn main() { - // extern functions are extern "C" fn - let _x: extern "C" fn() = f; // OK - is_fn(f); - //~^ ERROR `extern "C" fn() {f}: std::ops::Fn<()>` is not satisfied -} diff --git a/src/test/compile-fail/external-doc-error.rs b/src/test/compile-fail/external-doc-error.rs deleted file mode 100644 index 1ae0d0bd276..00000000000 --- a/src/test/compile-fail/external-doc-error.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(external_doc)] - -#[doc(include = "not-a-file.md")] //~ ERROR: couldn't read -pub struct SomeStruct; - -fn main() {} diff --git a/src/test/compile-fail/extoption_env-no-args.rs b/src/test/compile-fail/extoption_env-no-args.rs deleted file mode 100644 index fd56756584a..00000000000 --- a/src/test/compile-fail/extoption_env-no-args.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { option_env!(); } //~ ERROR: option_env! takes 1 argument diff --git a/src/test/compile-fail/extoption_env-not-string-literal.rs b/src/test/compile-fail/extoption_env-not-string-literal.rs deleted file mode 100644 index 6371a5c711d..00000000000 --- a/src/test/compile-fail/extoption_env-not-string-literal.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { option_env!(10); } //~ ERROR: argument must be a string literal diff --git a/src/test/compile-fail/extoption_env-too-many-args.rs b/src/test/compile-fail/extoption_env-too-many-args.rs deleted file mode 100644 index b31e857c14e..00000000000 --- a/src/test/compile-fail/extoption_env-too-many-args.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { option_env!("one", "two"); } //~ ERROR: option_env! takes 1 argument diff --git a/src/test/compile-fail/fail-no-dead-code-core.rs b/src/test/compile-fail/fail-no-dead-code-core.rs deleted file mode 100644 index aed76e36fca..00000000000 --- a/src/test/compile-fail/fail-no-dead-code-core.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(dead_code)] -#![allow(unreachable_code)] - -#[macro_use] -extern crate core; - -fn foo() { //~ ERROR function is never used - - // none of these should have any dead_code exposed to the user - panic!(); - - panic!("foo"); - - panic!("bar {}", "baz") -} - - -fn main() {} diff --git a/src/test/compile-fail/fail-no-dead-code.rs b/src/test/compile-fail/fail-no-dead-code.rs deleted file mode 100644 index 6e5d3a31355..00000000000 --- a/src/test/compile-fail/fail-no-dead-code.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(dead_code)] -#![allow(unreachable_code)] - -fn foo() { //~ ERROR function is never used - - // none of these should have any dead_code exposed to the user - panic!(); - - panic!("foo"); - - panic!("bar {}", "baz") -} - - -fn main() {} diff --git a/src/test/compile-fail/fail-simple.rs b/src/test/compile-fail/fail-simple.rs deleted file mode 100644 index a20ff864705..00000000000 --- a/src/test/compile-fail/fail-simple.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - panic!(@); //~ ERROR no rules expected the token `@` -} diff --git a/src/test/compile-fail/feature-gate-alloc-error-handler.rs b/src/test/compile-fail/feature-gate-alloc-error-handler.rs deleted file mode 100644 index 66691af2d03..00000000000 --- a/src/test/compile-fail/feature-gate-alloc-error-handler.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![no_std] -#![no_main] - -use core::alloc::Layout; - -#[alloc_error_handler] //~ ERROR #[alloc_error_handler] is an unstable feature (see issue #51540) -fn oom(info: Layout) -> ! { - loop {} -} diff --git a/src/test/compile-fail/feature-gate-panic-implementation.rs b/src/test/compile-fail/feature-gate-panic-implementation.rs deleted file mode 100644 index ae9fbc7b13b..00000000000 --- a/src/test/compile-fail/feature-gate-panic-implementation.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![no_std] -#![no_main] - -use core::panic::PanicInfo; - -#[panic_implementation] //~ ERROR #[panic_implementation] is an unstable feature (see issue #44489) -fn panic(info: &PanicInfo) -> ! { - loop {} -} diff --git a/src/test/compile-fail/feature-gate-tool_lints.rs b/src/test/compile-fail/feature-gate-tool_lints.rs deleted file mode 100644 index c311eb7ed7a..00000000000 --- a/src/test/compile-fail/feature-gate-tool_lints.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[warn(clippy::assign_ops)] //~ ERROR scoped lint `clippy::assign_ops` is experimental -fn main() {} diff --git a/src/test/compile-fail/feature-gate-without_gate_irrefutable_pattern.rs b/src/test/compile-fail/feature-gate-without_gate_irrefutable_pattern.rs deleted file mode 100644 index 7bcddbb6a2f..00000000000 --- a/src/test/compile-fail/feature-gate-without_gate_irrefutable_pattern.rs +++ /dev/null @@ -1,17 +0,0 @@ -// gate-test-irrefutable_let_patterns - -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[allow(irrefutable_let_patterns)] -fn main() { - if let _ = 5 {} - //~^ ERROR 15:12: 15:13: irrefutable if-let pattern [E0162] -} diff --git a/src/test/compile-fail/feature-gated-feature-in-macro-arg.rs b/src/test/compile-fail/feature-gated-feature-in-macro-arg.rs deleted file mode 100644 index ae342af4a52..00000000000 --- a/src/test/compile-fail/feature-gated-feature-in-macro-arg.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// tests that input to a macro is checked for use of gated features. If this -// test succeeds due to the acceptance of a feature, pick a new feature to -// test. Not ideal, but oh well :( - -fn main() { - let a = &[1, 2, 3]; - println!("{}", { - extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change - fn atomic_fence(); - } - atomic_fence(); - 42 - }); -} diff --git a/src/test/compile-fail/float-literal-inference-restrictions.rs b/src/test/compile-fail/float-literal-inference-restrictions.rs deleted file mode 100644 index 1e58df69f16..00000000000 --- a/src/test/compile-fail/float-literal-inference-restrictions.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x: f32 = 1; //~ ERROR mismatched types - let y: f32 = 1f64; //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/fn-bad-block-type.rs b/src/test/compile-fail/fn-bad-block-type.rs deleted file mode 100644 index c5c355cfbce..00000000000 --- a/src/test/compile-fail/fn-bad-block-type.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:mismatched types - -fn f() -> isize { true } - -fn main() { } diff --git a/src/test/compile-fail/fn-compare-mismatch.rs b/src/test/compile-fail/fn-compare-mismatch.rs deleted file mode 100644 index 27be1ada445..00000000000 --- a/src/test/compile-fail/fn-compare-mismatch.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - fn f() { } - fn g() { } - let x = f == g; - //~^ ERROR binary operation `==` cannot be applied - //~| ERROR mismatched types -} diff --git a/src/test/compile-fail/fn-item-type.rs b/src/test/compile-fail/fn-item-type.rs deleted file mode 100644 index 6217a9f16b9..00000000000 --- a/src/test/compile-fail/fn-item-type.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the types of distinct fn items are not compatible by -// default. See also `run-pass/fn-item-type-*.rs`. - -fn foo(x: isize) -> isize { x * 2 } -fn bar(x: isize) -> isize { x * 4 } - -fn eq(x: T, y: T) { } - -trait Foo { fn foo() { /* this is a default fn */ } } -impl Foo for T { /* `foo` is still default here */ } - -fn main() { - eq(foo::, bar::); - //~^ ERROR mismatched types - //~| expected type `fn(isize) -> isize {foo::}` - //~| found type `fn(isize) -> isize {bar::}` - //~| expected fn item, found a different fn item - - eq(foo::, foo::); - //~^ ERROR mismatched types - //~| expected u8, found i8 - - eq(bar::, bar::>); - //~^ ERROR mismatched types - //~| expected type `fn(isize) -> isize {bar::}` - //~| found type `fn(isize) -> isize {bar::>}` - //~| expected struct `std::string::String`, found struct `std::vec::Vec` - - // Make sure we distinguish between trait methods correctly. - eq(::foo, ::foo); - //~^ ERROR mismatched types - //~| expected u8, found u16 -} diff --git a/src/test/compile-fail/fn-trait-formatting.rs b/src/test/compile-fail/fn-trait-formatting.rs deleted file mode 100644 index 56d64d77ee2..00000000000 --- a/src/test/compile-fail/fn-trait-formatting.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn needs_fn(x: F) where F: Fn(isize) -> isize {} - -fn main() { - let _: () = (box |_: isize| {}) as Box; - //~^ ERROR mismatched types - //~| expected type `()` - //~| found type `std::boxed::Box` - let _: () = (box |_: isize, isize| {}) as Box; - //~^ ERROR mismatched types - //~| expected type `()` - //~| found type `std::boxed::Box` - let _: () = (box || -> isize { unimplemented!() }) as Box isize>; - //~^ ERROR mismatched types - //~| expected type `()` - //~| found type `std::boxed::Box isize>` - - needs_fn(1); - //~^ ERROR : std::ops::Fn<(isize,)>` -} diff --git a/src/test/compile-fail/for-expn.rs b/src/test/compile-fail/for-expn.rs deleted file mode 100644 index 7e9d4df005d..00000000000 --- a/src/test/compile-fail/for-expn.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an error on a sub-expresson in a for loop has the correct span. - -fn main() { - // Odd formatting to make sure we get the right span. - for t in & - foo //~ ERROR cannot find value `foo` in this scope - { - } -} diff --git a/src/test/compile-fail/for-loop-bogosity.rs b/src/test/compile-fail/for-loop-bogosity.rs deleted file mode 100644 index 96ad184fd35..00000000000 --- a/src/test/compile-fail/for-loop-bogosity.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct MyStruct { - x: isize, - y: isize, -} - -impl MyStruct { - fn next(&mut self) -> Option { - Some(self.x) - } -} - -pub fn main() { - let mut bogus = MyStruct { - x: 1, - y: 2, - }; - for x in bogus { //~ ERROR `MyStruct: std::iter::Iterator` is not satisfied - drop(x); - } -} diff --git a/src/test/compile-fail/for-loop-refutable-pattern-error-message.rs b/src/test/compile-fail/for-loop-refutable-pattern-error-message.rs deleted file mode 100644 index 81c4db68628..00000000000 --- a/src/test/compile-fail/for-loop-refutable-pattern-error-message.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - for &1 in [1].iter() {} //~ ERROR refutable pattern in `for` loop binding -} diff --git a/src/test/compile-fail/for-loop-type-error.rs b/src/test/compile-fail/for-loop-type-error.rs deleted file mode 100644 index 7f0e40128f5..00000000000 --- a/src/test/compile-fail/for-loop-type-error.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - let x = () + (); //~ ERROR binary operation - - // this shouldn't have a flow-on error: - for _ in x {} -} diff --git a/src/test/compile-fail/for-loop-unconstrained-element-type.rs b/src/test/compile-fail/for-loop-unconstrained-element-type.rs deleted file mode 100644 index fb5553166ba..00000000000 --- a/src/test/compile-fail/for-loop-unconstrained-element-type.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that `for` loops don't introduce artificial -// constraints on the type of the binding (`i`). -// Subtle changes in the desugaring can cause the -// type of elements in the vector to (incorrectly) -// fallback to `!` or `()`. - -fn main() { - for i in Vec::new() { } //~ ERROR type annotations needed -} diff --git a/src/test/compile-fail/foreign-fn-return-lifetime.rs b/src/test/compile-fail/foreign-fn-return-lifetime.rs deleted file mode 100644 index da77066150c..00000000000 --- a/src/test/compile-fail/foreign-fn-return-lifetime.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern "C" { - fn g(_: &u8) -> &u8; // OK - fn f() -> &u8; //~ ERROR missing lifetime specifier -} - -fn main() {} diff --git a/src/test/compile-fail/foreign-unsafe-fn-called.rs b/src/test/compile-fail/foreign-unsafe-fn-called.rs deleted file mode 100644 index 5fad4c3677c..00000000000 --- a/src/test/compile-fail/foreign-unsafe-fn-called.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -mod test { - extern { - pub fn free(); - } -} - -fn main() { - test::free(); - //~^ ERROR call to unsafe function is unsafe -} diff --git a/src/test/compile-fail/fully-qualified-type-name1.rs b/src/test/compile-fail/fully-qualified-type-name1.rs deleted file mode 100644 index 1a7ceb2e763..00000000000 --- a/src/test/compile-fail/fully-qualified-type-name1.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we use fully-qualified type names in error messages. - -fn main() { - let x: Option; - x = 5; - //~^ ERROR mismatched types - //~| expected type `std::option::Option` - //~| found type `{integer}` - //~| expected enum `std::option::Option`, found integral variable -} diff --git a/src/test/compile-fail/fully-qualified-type-name2.rs b/src/test/compile-fail/fully-qualified-type-name2.rs deleted file mode 100644 index 9ba8a11d536..00000000000 --- a/src/test/compile-fail/fully-qualified-type-name2.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we use fully-qualified type names in error messages. - -mod x { - pub enum foo { } -} - -mod y { - pub enum foo { } -} - -fn bar(x: x::foo) -> y::foo { - return x; - //~^ ERROR mismatched types - //~| expected type `y::foo` - //~| found type `x::foo` - //~| expected enum `y::foo`, found enum `x::foo` -} - -fn main() { -} diff --git a/src/test/compile-fail/fully-qualified-type-name3.rs b/src/test/compile-fail/fully-qualified-type-name3.rs deleted file mode 100644 index dc0c9a093ff..00000000000 --- a/src/test/compile-fail/fully-qualified-type-name3.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we use fully-qualified type names in error messages. - -// ignore-test - -type T1 = usize; -type T2 = isize; - -fn bar(x: T1) -> T2 { - return x; - //~^ ERROR mismatched types: expected `T2`, found `T1` -} - -fn main() { -} diff --git a/src/test/compile-fail/fully-qualified-type-name4.rs b/src/test/compile-fail/fully-qualified-type-name4.rs deleted file mode 100644 index 3c8fde751f1..00000000000 --- a/src/test/compile-fail/fully-qualified-type-name4.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we use fully-qualified type names in error messages. - -use std::option::Option; - -fn bar(x: usize) -> Option { - return x; - //~^ ERROR mismatched types - //~| expected type `std::option::Option` - //~| found type `usize` - //~| expected enum `std::option::Option`, found usize -} - -fn main() { -} diff --git a/src/test/compile-fail/functional-struct-update-noncopyable.rs b/src/test/compile-fail/functional-struct-update-noncopyable.rs deleted file mode 100644 index 7ce32bbc975..00000000000 --- a/src/test/compile-fail/functional-struct-update-noncopyable.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// issue 7327 - -use std::sync::Arc; - -struct A { y: Arc, x: Arc } - -impl Drop for A { - fn drop(&mut self) { println!("x={}", *self.x); } -} -fn main() { - let a = A { y: Arc::new(1), x: Arc::new(2) }; - let _b = A { y: Arc::new(3), ..a }; //~ ERROR cannot move out of type `A` - let _c = a; -} diff --git a/src/test/compile-fail/functional-struct-update-respects-privacy.rs b/src/test/compile-fail/functional-struct-update-respects-privacy.rs deleted file mode 100644 index 3f41401eb69..00000000000 --- a/src/test/compile-fail/functional-struct-update-respects-privacy.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// RFC 736 (and Issue 21407): functional struct update should respect privacy. - -// The `foo` module attempts to maintains an invariant that each `S` -// has a unique `u64` id. -use self::foo::S; -mod foo { - use std::cell::{UnsafeCell}; - - static mut count : UnsafeCell = UnsafeCell::new(1); - - pub struct S { pub a: u8, pub b: String, secret_uid: u64 } - - pub fn make_secrets(a: u8, b: String) -> S { - let val = unsafe { let p = count.get(); let val = *p; *p = val + 1; val }; - println!("creating {}, uid {}", b, val); - S { a: a, b: b, secret_uid: val } - } - - impl Drop for S { - fn drop(&mut self) { - println!("dropping {}, uid {}", self.b, self.secret_uid); - } - } -} - -fn main() { - let s_1 = foo::make_secrets(3, format!("ess one")); - let s_2 = foo::S { b: format!("ess two"), ..s_1 }; // FRU ... - //~^ ERROR field `secret_uid` of struct `foo::S` is private - println!("main forged an S named: {}", s_2.b); - // at end of scope, ... both s_1 *and* s_2 get dropped. Boom! -} diff --git a/src/test/compile-fail/future-incompatible-lint-group.rs b/src/test/compile-fail/future-incompatible-lint-group.rs deleted file mode 100644 index 5f320135edf..00000000000 --- a/src/test/compile-fail/future-incompatible-lint-group.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(future_incompatible)] - -trait Tr { - fn f(u8) {} //~ ERROR anonymous parameters are deprecated - //~^ WARN this was previously accepted -} - -fn main() {} diff --git a/src/test/compile-fail/gated-attr-literals.rs b/src/test/compile-fail/gated-attr-literals.rs deleted file mode 100644 index 8d36745116b..00000000000 --- a/src/test/compile-fail/gated-attr-literals.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that literals in attributes don't parse without the feature gate. - -// gate-test-attr_literals - -#![feature(custom_attribute)] - -#[fake_attr] // OK -#[fake_attr(100)] - //~^ ERROR non-string literals in attributes -#[fake_attr(1, 2, 3)] - //~^ ERROR non-string literals in attributes -#[fake_attr("hello")] - //~^ ERROR string literals in top-level positions, are experimental -#[fake_attr(name = "hello")] // OK -#[fake_attr(1, "hi", key = 12, true, false)] - //~^ ERROR non-string literals in attributes, or string literals in top-level positions -#[fake_attr(key = "hello", val = 10)] - //~^ ERROR non-string literals in attributes -#[fake_attr(key("hello"), val(10))] - //~^ ERROR non-string literals in attributes, or string literals in top-level positions -#[fake_attr(enabled = true, disabled = false)] - //~^ ERROR non-string literals in attributes -#[fake_attr(true)] - //~^ ERROR non-string literals in attributes -#[fake_attr(pi = 3.14159)] - //~^ ERROR non-string literals in attributes -#[fake_attr(b"hi")] - //~^ ERROR string literals in top-level positions, are experimental -#[fake_doc(r"doc")] - //~^ ERROR string literals in top-level positions, are experimental -struct Q { } - -fn main() { } diff --git a/src/test/compile-fail/gated-bad-feature.rs b/src/test/compile-fail/gated-bad-feature.rs deleted file mode 100644 index 5baafd41531..00000000000 --- a/src/test/compile-fail/gated-bad-feature.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature( - foo_bar_baz, - foo(bar), - foo = "baz" -)] -//~^^^ ERROR: malformed feature -//~^^^ ERROR: malformed feature - -#![feature] //~ ERROR: malformed feature -#![feature = "foo"] //~ ERROR: malformed feature - -#![feature(test_removed_feature)] //~ ERROR: feature has been removed diff --git a/src/test/compile-fail/generator-yielding-or-returning-itself.rs b/src/test/compile-fail/generator-yielding-or-returning-itself.rs deleted file mode 100644 index 13abdf616b2..00000000000 --- a/src/test/compile-fail/generator-yielding-or-returning-itself.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generator_trait)] -#![feature(generators)] - -// Test that we cannot create a generator that returns a value of its -// own type. - -use std::ops::Generator; - -pub fn want_cyclic_generator_return(_: T) - where T: Generator -{ -} - -fn supply_cyclic_generator_return() { - want_cyclic_generator_return(|| { - //~^ ERROR type mismatch - if false { yield None.unwrap(); } - None.unwrap() - }) -} - -pub fn want_cyclic_generator_yield(_: T) - where T: Generator -{ -} - -fn supply_cyclic_generator_yield() { - want_cyclic_generator_yield(|| { - //~^ ERROR type mismatch - if false { yield None.unwrap(); } - None.unwrap() - }) -} - -fn main() { } diff --git a/src/test/compile-fail/generic-extern-lifetime.rs b/src/test/compile-fail/generic-extern-lifetime.rs deleted file mode 100644 index fa2d4743937..00000000000 --- a/src/test/compile-fail/generic-extern-lifetime.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test to make sure the names of the lifetimes are correctly resolved -// in extern blocks. - -extern { - pub fn life<'a>(x:&'a i32); - pub fn life2<'b>(x:&'a i32, y:&'b i32); //~ ERROR use of undeclared lifetime name `'a` - pub fn life3<'a>(x:&'a i32, y:&i32) -> &'a i32; - pub fn life4<'b>(x: for<'c> fn(&'a i32)); //~ ERROR use of undeclared lifetime name `'a` - pub fn life5<'b>(x: for<'c> fn(&'b i32)); - pub fn life6<'b>(x: for<'c> fn(&'c i32)); - pub fn life7<'b>() -> for<'c> fn(&'a i32); //~ ERROR use of undeclared lifetime name `'a` - pub fn life8<'b>() -> for<'c> fn(&'b i32); - pub fn life9<'b>() -> for<'c> fn(&'c i32); -} -fn main() {} diff --git a/src/test/compile-fail/generic-extern.rs b/src/test/compile-fail/generic-extern.rs deleted file mode 100644 index a7140d1be87..00000000000 --- a/src/test/compile-fail/generic-extern.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - fn foo(); //~ ERROR foreign items may not have type parameters -} - -fn main() { - foo::(); -} diff --git a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs b/src/test/compile-fail/generic-impl-less-params-with-defaults.rs deleted file mode 100644 index 3f5f7bb3a53..00000000000 --- a/src/test/compile-fail/generic-impl-less-params-with-defaults.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker; - -struct Foo( - marker::PhantomData<(A,B,C)>); - -impl Foo { - fn new() -> Foo {Foo(marker::PhantomData)} -} - -fn main() { - Foo::::new(); - //~^ ERROR wrong number of type arguments -} diff --git a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs b/src/test/compile-fail/generic-impl-more-params-with-defaults.rs deleted file mode 100644 index 31411992089..00000000000 --- a/src/test/compile-fail/generic-impl-more-params-with-defaults.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker; - -struct Heap; - -struct Vec( - marker::PhantomData<(T,A)>); - -impl Vec { - fn new() -> Vec {Vec(marker::PhantomData)} -} - -fn main() { - Vec::::new(); - //~^ ERROR wrong number of type arguments -} diff --git a/src/test/compile-fail/generic-lifetime-trait-impl.rs b/src/test/compile-fail/generic-lifetime-trait-impl.rs deleted file mode 100644 index 9b9f09f4777..00000000000 --- a/src/test/compile-fail/generic-lifetime-trait-impl.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This code used to produce an ICE on the definition of trait Bar -// with the following message: -// -// Type parameter out of range when substituting in region 'a (root -// type=fn(Self) -> 'astr) (space=FnSpace, index=0) -// -// Regression test for issue #16218. - -trait Bar<'a> { - fn dummy(&'a self); -} - -trait Foo<'a> { - fn dummy(&'a self) { } - fn bar<'b, T: Bar<'b>>(self) -> &'b str; -} - -impl<'a> Foo<'a> for &'a str { - fn bar>(self) -> &'a str { panic!() } //~ ERROR lifetime -} - -fn main() { -} diff --git a/src/test/compile-fail/generic-no-mangle.rs b/src/test/compile-fail/generic-no-mangle.rs deleted file mode 100644 index 2b4c94d281f..00000000000 --- a/src/test/compile-fail/generic-no-mangle.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(no_mangle_generic_items)] - -#[no_mangle] -pub fn foo() {} //~ ERROR functions generic over types must be mangled - -#[no_mangle] -pub extern fn bar() {} //~ ERROR functions generic over types must be mangled - -#[no_mangle] -pub fn baz(x: &i32) -> &i32 { x } - -#[no_mangle] -pub fn qux<'a>(x: &'a i32) -> &i32 { x } - -fn main() {} diff --git a/src/test/compile-fail/generic-non-trailing-defaults.rs b/src/test/compile-fail/generic-non-trailing-defaults.rs deleted file mode 100644 index 13b7753082c..00000000000 --- a/src/test/compile-fail/generic-non-trailing-defaults.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Heap; - -struct Vec(A, T); -//~^ ERROR type parameters with a default must be trailing - -struct Foo, C>(A, B, C); -//~^ ERROR type parameters with a default must be trailing -//~| ERROR type parameters with a default cannot use forward declared identifiers - -fn main() {} diff --git a/src/test/compile-fail/generic-type-params-forward-mention.rs b/src/test/compile-fail/generic-type-params-forward-mention.rs deleted file mode 100644 index bfa6af0da43..00000000000 --- a/src/test/compile-fail/generic-type-params-forward-mention.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that we get an error and not an ICE for this problematic case. -struct Foo, U = bool>(T, U); -//~^ ERROR type parameters with a default cannot use forward declared identifiers -fn main() { - let x: Foo; -} diff --git a/src/test/compile-fail/generic-type-params-name-repr.rs b/src/test/compile-fail/generic-type-params-name-repr.rs deleted file mode 100644 index 71d7cf792e4..00000000000 --- a/src/test/compile-fail/generic-type-params-name-repr.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker; - -struct A; -struct B; -struct C; -struct Foo(marker::PhantomData<(T,U,V)>); - -struct Hash(marker::PhantomData); -struct HashMap>(marker::PhantomData<(K,V,H)>); - -fn main() { - // Ensure that the printed type doesn't include the default type params... - let _: Foo = (); - //~^ ERROR mismatched types - //~| expected type `Foo` - //~| found type `()` - //~| expected struct `Foo`, found () - - // ...even when they're present, but the same types as the defaults. - let _: Foo = (); - //~^ ERROR mismatched types - //~| expected type `Foo` - //~| found type `()` - //~| expected struct `Foo`, found () - - // Including cases where the default is using previous type params. - let _: HashMap = (); - //~^ ERROR mismatched types - //~| expected type `HashMap` - //~| found type `()` - //~| expected struct `HashMap`, found () - let _: HashMap> = (); - //~^ ERROR mismatched types - //~| expected type `HashMap` - //~| found type `()` - //~| expected struct `HashMap`, found () - - // But not when there's a different type in between. - let _: Foo = (); - //~^ ERROR mismatched types - //~| expected type `Foo` - //~| found type `()` - //~| expected struct `Foo`, found () - - // And don't print <> at all when there's just defaults. - let _: Foo = (); - //~^ ERROR mismatched types - //~| expected type `Foo` - //~| found type `()` - //~| expected struct `Foo`, found () -} diff --git a/src/test/compile-fail/glob-cycles.rs b/src/test/compile-fail/glob-cycles.rs deleted file mode 100644 index 8f1b8ec91db..00000000000 --- a/src/test/compile-fail/glob-cycles.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -mod foo { - pub use bar::*; - pub use main as f; -} - -mod bar { - pub use foo::*; -} - -pub use foo::*; -pub use baz::*; -mod baz { - pub use super::*; -} - -#[rustc_error] -pub fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/glob-resolve1.rs b/src/test/compile-fail/glob-resolve1.rs deleted file mode 100644 index 2723b4ce256..00000000000 --- a/src/test/compile-fail/glob-resolve1.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Make sure that globs only bring in public things. - -use bar::*; - -mod bar { - use self::fpriv as import; - fn fpriv() {} - extern { - fn epriv(); - } - enum A { A1 } - pub enum B { B1 } - - struct C; - - type D = isize; -} - -fn foo() {} - -fn main() { - fpriv(); //~ ERROR cannot find function `fpriv` in this scope - epriv(); //~ ERROR cannot find function `epriv` in this scope - B; //~ ERROR expected value, found enum `B` - C; //~ ERROR cannot find value `C` in this scope - import(); //~ ERROR: cannot find function `import` in this scope - - foo::(); //~ ERROR: cannot find type `A` in this scope - foo::(); //~ ERROR: cannot find type `C` in this scope - foo::(); //~ ERROR: cannot find type `D` in this scope -} diff --git a/src/test/compile-fail/hashmap-iter-value-lifetime.rs b/src/test/compile-fail/hashmap-iter-value-lifetime.rs deleted file mode 100644 index 9cf145a1ff3..00000000000 --- a/src/test/compile-fail/hashmap-iter-value-lifetime.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let mut my_stuff = std::collections::HashMap::new(); - my_stuff.insert(0, 42); - - let (_, thing) = my_stuff.iter().next().unwrap(); - - my_stuff.clear(); //~ ERROR cannot borrow - - println!("{}", *thing); -} diff --git a/src/test/compile-fail/hashmap-lifetimes.rs b/src/test/compile-fail/hashmap-lifetimes.rs deleted file mode 100644 index 6858599f63a..00000000000 --- a/src/test/compile-fail/hashmap-lifetimes.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let mut my_stuff = std::collections::HashMap::new(); - my_stuff.insert(0, 42); - - let mut it = my_stuff.iter(); - my_stuff.insert(1, 43); //~ ERROR cannot borrow -} diff --git a/src/test/compile-fail/hidden-rt-injection.rs b/src/test/compile-fail/hidden-rt-injection.rs deleted file mode 100644 index a27a8464707..00000000000 --- a/src/test/compile-fail/hidden-rt-injection.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This is testing that users can't access the runtime crate. - -mod m { - // The rt has been called both 'native' and 'rt' - use native; //~ ERROR unresolved import -} - -fn main() { } diff --git a/src/test/compile-fail/hidden-rt-injection2.rs b/src/test/compile-fail/hidden-rt-injection2.rs deleted file mode 100644 index fa6584ddd98..00000000000 --- a/src/test/compile-fail/hidden-rt-injection2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This is testing that users can't access the runtime crate. - -mod m { - // The rt has been called both 'native' and 'rt' - use rt; //~ ERROR unresolved import -} - -fn main() { } diff --git a/src/test/compile-fail/hr-subtype.rs b/src/test/compile-fail/hr-subtype.rs deleted file mode 100644 index 86df2382732..00000000000 --- a/src/test/compile-fail/hr-subtype.rs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Targeted tests for the higher-ranked subtyping code. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -// revisions: bound_a_vs_bound_a -// revisions: bound_a_vs_bound_b -// revisions: bound_inv_a_vs_bound_inv_b -// revisions: bound_co_a_vs_bound_co_b -// revisions: bound_a_vs_free_x -// revisions: free_x_vs_free_x -// revisions: free_x_vs_free_y -// revisions: free_inv_x_vs_free_inv_y -// revisions: bound_a_b_vs_bound_a -// revisions: bound_co_a_b_vs_bound_co_a -// revisions: bound_contra_a_contra_b_ret_co_a -// revisions: bound_co_a_co_b_ret_contra_a -// revisions: bound_inv_a_b_vs_bound_inv_a -// revisions: bound_a_b_ret_a_vs_bound_a_ret_a - -fn gimme(_: Option) { } - -struct Inv<'a> { x: *mut &'a u32 } - -struct Co<'a> { x: fn(&'a u32) } - -struct Contra<'a> { x: &'a u32 } - -macro_rules! check { - ($rev:ident: ($t1:ty, $t2:ty)) => { - #[cfg($rev)] - fn subtype<'x,'y:'x,'z:'y>() { - gimme::<$t2>(None::<$t1>); - //[free_inv_x_vs_free_inv_y]~^ ERROR mismatched types - } - - #[cfg($rev)] - fn supertype<'x,'y:'x,'z:'y>() { - gimme::<$t1>(None::<$t2>); - //[bound_a_vs_free_x]~^ ERROR mismatched types - //[free_x_vs_free_y]~^^ ERROR mismatched types - //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR mismatched types - //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR mismatched types - //[free_inv_x_vs_free_inv_y]~^^^^^ ERROR mismatched types - //[bound_a_b_vs_bound_a]~^^^^^^ ERROR mismatched types - //[bound_co_a_b_vs_bound_co_a]~^^^^^^^ ERROR mismatched types - //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^ ERROR mismatched types - //[bound_co_a_co_b_ret_contra_a]~^^^^^^^^^ ERROR mismatched types - } - } -} - -// If both have bound regions, they are equivalent, regardless of -// variant. -check! { bound_a_vs_bound_a: (for<'a> fn(&'a u32), - for<'a> fn(&'a u32)) } -check! { bound_a_vs_bound_b: (for<'a> fn(&'a u32), - for<'b> fn(&'b u32)) } -check! { bound_inv_a_vs_bound_inv_b: (for<'a> fn(Inv<'a>), - for<'b> fn(Inv<'b>)) } -check! { bound_co_a_vs_bound_co_b: (for<'a> fn(Co<'a>), - for<'b> fn(Co<'b>)) } - -// Bound is a subtype of free. -check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), - fn(&'x u32)) } - -// Two free regions are relatable if subtyping holds. -check! { free_x_vs_free_x: (fn(&'x u32), - fn(&'x u32)) } -check! { free_x_vs_free_y: (fn(&'x u32), - fn(&'y u32)) } -check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), - fn(Inv<'y>)) } - -// Somewhat surprisingly, a fn taking two distinct bound lifetimes and -// a fn taking one bound lifetime can be interchangeable, but only if -// we are co- or contra-variant with respect to both lifetimes. -// -// The reason is: -// - if we are covariant, then 'a and 'b can be set to the call-site -// intersection; -// - if we are contravariant, then 'a can be inferred to 'static. -check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), - for<'a> fn(&'a u32, &'a u32)) } -check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), - for<'a> fn(Co<'a>, Co<'a>)) } -check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, - for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } -check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, - for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } - -// If we make those lifetimes invariant, then the two types are not interchangeable. -check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>), - for<'a> fn(Inv<'a>, Inv<'a>)) } -check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u32) -> &'a u32, - for<'a> fn(&'a u32, &'a u32) -> &'a u32) } - -#[rustc_error] -fn main() { -//[bound_a_vs_bound_a]~^ ERROR compilation successful -//[bound_a_vs_bound_b]~^^ ERROR compilation successful -//[bound_inv_a_vs_bound_inv_b]~^^^ ERROR compilation successful -//[bound_co_a_vs_bound_co_b]~^^^^ ERROR compilation successful -//[free_x_vs_free_x]~^^^^^ ERROR compilation successful -} diff --git a/src/test/compile-fail/hrtb-conflate-regions.rs b/src/test/compile-fail/hrtb-conflate-regions.rs deleted file mode 100644 index 845429d4b0c..00000000000 --- a/src/test/compile-fail/hrtb-conflate-regions.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an impl with only one bound region `'a` cannot be used to -// satisfy a constraint where there are two bound regions. - -trait Foo { - fn foo(&self, x: X) { } -} - -fn want_foo2() - where T : for<'a,'b> Foo<(&'a isize, &'b isize)> -{ -} - -fn want_foo1() - where T : for<'z> Foo<(&'z isize, &'z isize)> -{ -} - -/////////////////////////////////////////////////////////////////////////// -// Expressed as a where clause - -struct SomeStruct; - -impl<'a> Foo<(&'a isize, &'a isize)> for SomeStruct -{ -} - -fn a() { want_foo1::(); } // OK -- foo wants just one region -fn b() { want_foo2::(); } //~ ERROR E0277 - -fn main() { } diff --git a/src/test/compile-fail/hrtb-debruijn-in-receiver.rs b/src/test/compile-fail/hrtb-debruijn-in-receiver.rs deleted file mode 100644 index 2365f494075..00000000000 --- a/src/test/compile-fail/hrtb-debruijn-in-receiver.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test the case where the `Self` type has a bound lifetime that must -// be adjusted in the fn signature. Issue #19537. - -use std::collections::HashMap; - -struct Foo<'a> { - map: HashMap -} - -impl<'a> Foo<'a> { - fn new() -> Foo<'a> { panic!() } - fn insert(&'a mut self) { } -} -fn main() { - let mut foo = Foo::new(); - foo.insert(); - foo.insert(); //~ ERROR cannot borrow -} diff --git a/src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs b/src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs deleted file mode 100644 index b55dccec2d5..00000000000 --- a/src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test HRTB supertraits with several levels of expansion required. - -trait Foo<'tcx> -{ - fn foo(&'tcx self) -> &'tcx isize; -} - -trait Bar<'ccx> - : for<'tcx> Foo<'tcx> -{ - fn bar(&'ccx self) -> &'ccx isize; -} - -trait Baz - : for<'ccx> Bar<'ccx> -{ - fn dummy(&self); -} - -trait Qux - : Bar<'static> -{ - fn dummy(&self); -} - -fn want_foo_for_any_tcx(f: &F) - where F : for<'tcx> Foo<'tcx> -{ -} - -fn want_bar_for_any_ccx(b: &B) - where B : for<'ccx> Bar<'ccx> -{ -} - -fn want_baz(b: &B) - where B : Baz -{ - want_foo_for_any_tcx(b); - want_bar_for_any_ccx(b); -} - -fn want_qux(b: &B) - where B : Qux -{ - want_foo_for_any_tcx(b); - want_bar_for_any_ccx(b); //~ ERROR E0277 -} - -fn main() {} diff --git a/src/test/compile-fail/hrtb-higher-ranker-supertraits.rs b/src/test/compile-fail/hrtb-higher-ranker-supertraits.rs deleted file mode 100644 index 4c5add4acea..00000000000 --- a/src/test/compile-fail/hrtb-higher-ranker-supertraits.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a trait (`Bar`) with a higher-ranked supertrait. - -trait Foo<'tcx> -{ - fn foo(&'tcx self) -> &'tcx isize; -} - -trait Bar<'ccx> - : for<'tcx> Foo<'tcx> -{ - fn bar(&'ccx self) -> &'ccx isize; -} - -fn want_foo_for_some_tcx<'x,F>(f: &'x F) - where F : Foo<'x> -{ - want_foo_for_some_tcx(f); - want_foo_for_any_tcx(f); //~ ERROR E0277 -} - -fn want_foo_for_any_tcx(f: &F) - where F : for<'tcx> Foo<'tcx> -{ - want_foo_for_some_tcx(f); - want_foo_for_any_tcx(f); -} - -fn want_bar_for_some_ccx<'x,B>(b: &B) - where B : Bar<'x> -{ - want_foo_for_some_tcx(b); - want_foo_for_any_tcx(b); - - want_bar_for_some_ccx(b); - want_bar_for_any_ccx(b); //~ ERROR E0277 -} - -fn want_bar_for_any_ccx(b: &B) - where B : for<'ccx> Bar<'ccx> -{ - want_foo_for_some_tcx(b); - want_foo_for_any_tcx(b); - - want_bar_for_some_ccx(b); - want_bar_for_any_ccx(b); -} - -fn main() {} diff --git a/src/test/compile-fail/hrtb-identity-fn-borrows.rs b/src/test/compile-fail/hrtb-identity-fn-borrows.rs deleted file mode 100644 index e98cf4eb2ab..00000000000 --- a/src/test/compile-fail/hrtb-identity-fn-borrows.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the `'a` in the where clause correctly links the region -// of the output to the region of the input. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -fn call_repeatedly(f: F) - where F : for<'a> FnLike<&'a isize, &'a isize> -{ - // Result is stored: cannot re-assign `x` - let mut x = 3; - let y = f.call(&x); - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed - - // Result is not stored: can re-assign `x` - let mut x = 3; - f.call(&x); - f.call(&x); - f.call(&x); - x = 5; - drop(y); -} - -fn main() { -} diff --git a/src/test/compile-fail/hrtb-just-for-static.rs b/src/test/compile-fail/hrtb-just-for-static.rs deleted file mode 100644 index aec950f992c..00000000000 --- a/src/test/compile-fail/hrtb-just-for-static.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a case where you have an impl of `Foo` for all `X` that -// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. - -trait Foo { - fn foo(&self, x: X) { } -} - -fn want_hrtb() - where T : for<'a> Foo<&'a isize> -{ -} - -// AnyInt implements Foo<&'a isize> for any 'a, so it is a match. -struct AnyInt; -impl<'a> Foo<&'a isize> for AnyInt { } -fn give_any() { - want_hrtb::() -} - -// StaticInt only implements Foo<&'static isize>, so it is an error. -struct StaticInt; -impl Foo<&'static isize> for StaticInt { } -fn give_static() { - want_hrtb::() //~ ERROR `for<'a> StaticInt: Foo<&'a isize>` is not satisfied -} - -fn main() { } diff --git a/src/test/compile-fail/hrtb-perfect-forwarding.rs b/src/test/compile-fail/hrtb-perfect-forwarding.rs deleted file mode 100644 index fcfbeefced0..00000000000 --- a/src/test/compile-fail/hrtb-perfect-forwarding.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a case where you have an impl of `Foo` for all `X` that -// is being applied to `for<'a> Foo<&'a mut X>`. Issue #19730. - -trait Foo { - fn foo(&mut self, x: X) { } -} - -trait Bar { - fn bar(&mut self, x: X) { } -} - -impl<'a,X,F> Foo for &'a mut F - where F : Foo + Bar -{ -} - -impl<'a,X,F> Bar for &'a mut F - where F : Bar -{ -} - -fn no_hrtb<'b,T>(mut t: T) - where T : Bar<&'b isize> -{ - // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that - // `&mut T : Bar<&'b isize>`. - no_hrtb(&mut t); -} - -fn bar_hrtb(mut t: T) - where T : for<'b> Bar<&'b isize> -{ - // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above - // ensures that `&mut T : for<'b> Bar<&'b isize>`. This is an - // example of a "perfect forwarding" impl. - bar_hrtb(&mut t); -} - -fn foo_hrtb_bar_not<'b,T>(mut t: T) - where T : for<'a> Foo<&'a isize> + Bar<&'b isize> -{ - // Not OK -- The forwarding impl for `Foo` requires that `Bar` also - // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a - // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where - // clause only specifies `T : Bar<&'b isize>`. - foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> T: Bar<&'a isize>` is not satisfied -} - -fn foo_hrtb_bar_hrtb(mut t: T) - where T : for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize> -{ - // OK -- now we have `T : for<'b> Bar&'b isize>`. - foo_hrtb_bar_hrtb(&mut t); -} - -fn main() { } diff --git a/src/test/compile-fail/huge-array-simple.rs b/src/test/compile-fail/huge-array-simple.rs deleted file mode 100644 index 54340cf7ac4..00000000000 --- a/src/test/compile-fail/huge-array-simple.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// FIXME (#23926): the error output is not consistent between a -// self-hosted and a cross-compiled setup. Skipping for now. - -// ignore-test FIXME(#23926) - -#![allow(exceeding_bitshifts)] - -fn main() { - let _fat : [u8; (1<<61)+(1<<31)] = - [0; (1u64<<61) as usize +(1u64<<31) as usize]; -} diff --git a/src/test/compile-fail/huge-array.rs b/src/test/compile-fail/huge-array.rs deleted file mode 100644 index 7de84802e1d..00000000000 --- a/src/test/compile-fail/huge-array.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:; 1518600000 - -fn generic(t: T) { - let s: [T; 1518600000] = [t; 1518600000]; -} - -fn main() { - let x: [u8; 1518599999] = [0; 1518599999]; - generic::<[u8; 1518599999]>(x); -} diff --git a/src/test/compile-fail/huge-enum.rs b/src/test/compile-fail/huge-enum.rs deleted file mode 100644 index 6e7c05370b9..00000000000 --- a/src/test/compile-fail/huge-enum.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: Option - -// FIXME: work properly with higher limits - -#[cfg(target_pointer_width = "32")] -fn main() { - let big: Option<[u32; (1<<29)-1]> = None; -} - -#[cfg(target_pointer_width = "64")] -fn main() { - let big: Option<[u32; (1<<45)-1]> = None; -} diff --git a/src/test/compile-fail/huge-struct.rs b/src/test/compile-fail/huge-struct.rs deleted file mode 100644 index a10c61d6606..00000000000 --- a/src/test/compile-fail/huge-struct.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: too big for the current - -struct S32 { - v0: T, - v1: T, - v2: T, - v3: T, - v4: T, - v5: T, - v6: T, - v7: T, - v8: T, - u9: T, - v10: T, - v11: T, - v12: T, - v13: T, - v14: T, - v15: T, - v16: T, - v17: T, - v18: T, - v19: T, - v20: T, - v21: T, - v22: T, - v23: T, - v24: T, - u25: T, - v26: T, - v27: T, - v28: T, - v29: T, - v30: T, - v31: T, -} - -struct S1k { val: S32> } - -struct S1M { val: S1k> } - -fn main() { - let fat: Option>>> = None; -} diff --git a/src/test/compile-fail/hygienic-label-1.rs b/src/test/compile-fail/hygienic-label-1.rs deleted file mode 100644 index 305b43402da..00000000000 --- a/src/test/compile-fail/hygienic-label-1.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - () => { break 'x; } //~ ERROR use of undeclared label `'x` -} - -pub fn main() { - 'x: loop { foo!() } -} diff --git a/src/test/compile-fail/hygienic-label-2.rs b/src/test/compile-fail/hygienic-label-2.rs deleted file mode 100644 index 24194d7bbe9..00000000000 --- a/src/test/compile-fail/hygienic-label-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - ($e: expr) => { 'x: loop { $e } } -} - -pub fn main() { - foo!(break 'x); //~ ERROR use of undeclared label `'x` -} diff --git a/src/test/compile-fail/hygienic-label-3.rs b/src/test/compile-fail/hygienic-label-3.rs deleted file mode 100644 index b107b71024d..00000000000 --- a/src/test/compile-fail/hygienic-label-3.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - () => { break 'x; } //~ ERROR use of undeclared label `'x` -} - -pub fn main() { - 'x: for _ in 0..1 { - foo!() - }; -} diff --git a/src/test/compile-fail/hygienic-label-4.rs b/src/test/compile-fail/hygienic-label-4.rs deleted file mode 100644 index 5bfcb6360e4..00000000000 --- a/src/test/compile-fail/hygienic-label-4.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - ($e: expr) => { 'x: for _ in 0..1 { $e } } -} - -pub fn main() { - foo!(break 'x); //~ ERROR use of undeclared label `'x` -} diff --git a/src/test/compile-fail/if-branch-types.rs b/src/test/compile-fail/if-branch-types.rs deleted file mode 100644 index ca9803f66b2..00000000000 --- a/src/test/compile-fail/if-branch-types.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x = if true { 10i32 } else { 10u32 }; - //~^ ERROR if and else have incompatible types - //~| expected i32, found u32 -} diff --git a/src/test/compile-fail/if-let.rs b/src/test/compile-fail/if-let.rs deleted file mode 100644 index 1e9144910b0..00000000000 --- a/src/test/compile-fail/if-let.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn macros() { - macro_rules! foo{ - ($p:pat, $e:expr, $b:block) => {{ - if let $p = $e $b - }} - } - macro_rules! bar{ - ($p:pat, $e:expr, $b:block) => {{ - foo!($p, $e, $b) - }} - } - - foo!(a, 1, { //~ ERROR irrefutable if-let - println!("irrefutable pattern"); - }); - bar!(a, 1, { //~ ERROR irrefutable if-let - println!("irrefutable pattern"); - }); -} - -pub fn main() { - if let a = 1 { //~ ERROR irrefutable if-let - println!("irrefutable pattern"); - } - - if let a = 1 { //~ ERROR irrefutable if-let - println!("irrefutable pattern"); - } else if true { - println!("else-if in irrefutable if-let"); - } else { - println!("else in irrefutable if-let"); - } - - if let 1 = 2 { - println!("refutable pattern"); - } else if let a = 1 { //~ ERROR irrefutable if-let - println!("irrefutable pattern"); - } - - if true { - println!("if"); - } else if let a = 1 { //~ ERROR irrefutable if-let - println!("irrefutable pattern"); - } -} diff --git a/src/test/compile-fail/if-loop.rs b/src/test/compile-fail/if-loop.rs deleted file mode 100644 index 15f04df6939..00000000000 --- a/src/test/compile-fail/if-loop.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -// This used to ICE because the "if" being unreachable was not handled correctly -fn err() { - if loop {} {} -} - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/if-typeck.rs b/src/test/compile-fail/if-typeck.rs deleted file mode 100644 index d5d7d2005be..00000000000 --- a/src/test/compile-fail/if-typeck.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:mismatched types -// issue #513 - -fn f() { } - -fn main() { - - // f is not a bool - if f { } -} diff --git a/src/test/compile-fail/if-without-else-result.rs b/src/test/compile-fail/if-without-else-result.rs deleted file mode 100644 index 95bcce5a847..00000000000 --- a/src/test/compile-fail/if-without-else-result.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let a = if true { true }; - //~^ ERROR if may be missing an else clause [E0317] - //~| expected type `()` - //~| found type `bool` - //~| expected (), found bool - println!("{}", a); -} diff --git a/src/test/compile-fail/ifmt-bad-format-args.rs b/src/test/compile-fail/ifmt-bad-format-args.rs deleted file mode 100644 index 8bd3cb0f60b..00000000000 --- a/src/test/compile-fail/ifmt-bad-format-args.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - format_args!(); //~ ERROR: requires at least a format string argument - format_args!(|| {}); //~ ERROR: must be a string literal -} diff --git a/src/test/compile-fail/ifmt-unimpl.rs b/src/test/compile-fail/ifmt-unimpl.rs deleted file mode 100644 index 9b9bae92c33..00000000000 --- a/src/test/compile-fail/ifmt-unimpl.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - format!("{:X}", "3"); - //~^ ERROR: `str: std::fmt::UpperHex` is not satisfied -} diff --git a/src/test/compile-fail/ifmt-unknown-trait.rs b/src/test/compile-fail/ifmt-unknown-trait.rs deleted file mode 100644 index d90b3d3cf81..00000000000 --- a/src/test/compile-fail/ifmt-unknown-trait.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - format!("{:notimplemented}", "3"); - //~^ ERROR: unknown format trait `notimplemented` -} diff --git a/src/test/compile-fail/illegal-ufcs-drop.rs b/src/test/compile-fail/illegal-ufcs-drop.rs deleted file mode 100644 index f4c653bd573..00000000000 --- a/src/test/compile-fail/illegal-ufcs-drop.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct Foo; - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn main() { - Drop::drop(&mut Foo) //~ ERROR explicit use of destructor method -} diff --git a/src/test/compile-fail/immut-function-arguments.rs b/src/test/compile-fail/immut-function-arguments.rs deleted file mode 100644 index 61a074952ef..00000000000 --- a/src/test/compile-fail/immut-function-arguments.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn f(y: Box) { - *y = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign -} - -fn g() { - let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign -} - -fn main() {} diff --git a/src/test/compile-fail/impl-bounds-checking.rs b/src/test/compile-fail/impl-bounds-checking.rs deleted file mode 100644 index f90365b71ae..00000000000 --- a/src/test/compile-fail/impl-bounds-checking.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Clone2 { - fn clone(&self) -> Self; -} - - -trait Getter { - fn get(&self) -> T; -} - -impl Getter for isize { //~ ERROR `isize: Clone2` is not satisfied - fn get(&self) -> isize { *self } -} - -fn main() { } diff --git a/src/test/compile-fail/impl-trait/impl-generic-mismatch-ab.rs b/src/test/compile-fail/impl-trait/impl-generic-mismatch-ab.rs deleted file mode 100644 index 23549918ff1..00000000000 --- a/src/test/compile-fail/impl-trait/impl-generic-mismatch-ab.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; - -trait Foo { - fn foo(&self, a: &A, b: &impl Debug); -} - -impl Foo for () { - fn foo(&self, a: &impl Debug, b: &B) { } - //~^ ERROR method `foo` has an incompatible type for trait -} - -fn main() {} diff --git a/src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs b/src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs deleted file mode 100644 index 653ef1723e0..00000000000 --- a/src/test/compile-fail/impl-trait/infinite-impl-trait-issue-38064.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that attempts to construct infinite types via impl trait fail -// in a graceful way. -// -// Regression test for #38064. - -// error-pattern:overflow evaluating the requirement `impl Quux` - -trait Quux {} - -fn foo() -> impl Quux { - struct Foo(T); - impl Quux for Foo {} - Foo(bar()) -} - -fn bar() -> impl Quux { - struct Bar(T); - impl Quux for Bar {} - Bar(foo()) -} - -// effectively: -// struct Foo(Bar); -// struct Bar(Foo); -// should produce an error about infinite size - -fn main() { foo(); } diff --git a/src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs deleted file mode 100644 index 537fc975bcf..00000000000 --- a/src/test/compile-fail/impl-trait/must_outlive_least_region_or_bound.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; - -fn elided(x: &i32) -> impl Copy { x } -//~^ ERROR explicit lifetime required in the type of `x` [E0621] - -fn explicit<'a>(x: &'a i32) -> impl Copy { x } -//~^ ERROR cannot infer an appropriate lifetime - -trait LifetimeTrait<'a> {} -impl<'a> LifetimeTrait<'a> for &'a i32 {} - -fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } -//~^ ERROR cannot infer an appropriate lifetime - -// Tests that a closure type contianing 'b cannot be returned from a type where -// only 'a was expected. -fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - //~^ ERROR lifetime mismatch - move |_| println!("{}", y) -} - -fn ty_param_wont_outlive_static(x: T) -> impl Debug + 'static { - //~^ ERROR the parameter type `T` may not live long enough - x -} - -fn main() {} diff --git a/src/test/compile-fail/impl-trait/needs_least_region_or_bound.rs b/src/test/compile-fail/impl-trait/needs_least_region_or_bound.rs deleted file mode 100644 index 6c0a0b800ce..00000000000 --- a/src/test/compile-fail/impl-trait/needs_least_region_or_bound.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; - -trait MultiRegionTrait<'a, 'b> {} -impl<'a, 'b> MultiRegionTrait<'a, 'b> for (&'a u32, &'b u32) {} - -fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> { -//~^ ERROR ambiguous lifetime bound - (x, y) -} - -fn main() {} diff --git a/src/test/compile-fail/impl-trait/no-trait.rs b/src/test/compile-fail/impl-trait/no-trait.rs deleted file mode 100644 index 5299ba297d0..00000000000 --- a/src/test/compile-fail/impl-trait/no-trait.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() -> impl 'static {} //~ ERROR at least one trait must be specified - -fn main() {} diff --git a/src/test/compile-fail/impl-trait/type_parameters_captured.rs b/src/test/compile-fail/impl-trait/type_parameters_captured.rs deleted file mode 100644 index 7c3430ab90e..00000000000 --- a/src/test/compile-fail/impl-trait/type_parameters_captured.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt::Debug; - -trait Any {} -impl Any for T {} - -// Check that type parameters are captured and not considered 'static -fn foo(x: T) -> impl Any + 'static { - //~^ ERROR the parameter type `T` may not live long enough - x -} - -fn main() {} diff --git a/src/test/compile-fail/impl-trait/where-allowed.rs b/src/test/compile-fail/impl-trait/where-allowed.rs deleted file mode 100644 index 2891cd59e3e..00000000000 --- a/src/test/compile-fail/impl-trait/where-allowed.rs +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A simple test for testing many permutations of allowedness of -//! impl Trait -use std::fmt::Debug; - -// Allowed -fn in_parameters(_: impl Debug) { panic!() } - -// Allowed -fn in_return() -> impl Debug { panic!() } - -// Allowed -fn in_adt_in_parameters(_: Vec) { panic!() } - -// Allowed -fn in_adt_in_return() -> Vec { panic!() } - -// Disallowed -fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_dyn_Fn_return_in_return() -> &'static dyn Fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -//~^^ ERROR nested `impl Trait` is not allowed - -// Disallowed -fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -//~^^ ERROR nested `impl Trait` is not allowed - -// Disallowed -fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_Fn_parameter_in_generics (_: F) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -fn in_Fn_return_in_generics impl Debug> (_: F) { panic!() } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - - -// Allowed -fn in_impl_Trait_in_parameters(_: impl Iterator) { panic!() } - -// Allowed -fn in_impl_Trait_in_return() -> impl IntoIterator { - vec![vec![0; 10], vec![12; 7], vec![8; 3]] -} - -// Disallowed -struct InBraceStructField { x: impl Debug } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -struct InAdtInBraceStructField { x: Vec } -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -struct InTupleStructField(impl Debug); -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed -enum InEnum { - InBraceVariant { x: impl Debug }, - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - InTupleVariant(impl Debug), - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Allowed -trait InTraitDefnParameters { - fn in_parameters(_: impl Debug); -} - -// Disallowed -trait InTraitDefnReturn { - fn in_return() -> impl Debug; - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Allowed and disallowed in trait impls -trait DummyTrait { - type Out; - fn in_trait_impl_parameter(impl Debug); - fn in_trait_impl_return() -> Self::Out; -} -impl DummyTrait for () { - type Out = impl Debug; - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - - fn in_trait_impl_parameter(_: impl Debug) { } - // Allowed - - fn in_trait_impl_return() -> impl Debug { () } - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Allowed -struct DummyType; -impl DummyType { - fn in_inherent_impl_parameters(_: impl Debug) { } - fn in_inherent_impl_return() -> impl Debug { () } -} - -// Disallowed -extern "C" { - fn in_foreign_parameters(_: impl Debug); - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - - fn in_foreign_return() -> impl Debug; - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Allowed -extern "C" fn in_extern_fn_parameters(_: impl Debug) { -} - -// Allowed -extern "C" fn in_extern_fn_return() -> impl Debug { - 22 -} - -type InTypeAlias = impl Debug; -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -type InReturnInTypeAlias = fn() -> impl Debug; -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - -// Disallowed in impl headers -impl PartialEq for () { - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Disallowed in impl headers -impl PartialEq<()> for impl Debug { - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Disallowed in inherent impls -impl impl Debug { - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Disallowed in inherent impls -struct InInherentImplAdt { t: T } -impl InInherentImplAdt { - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - -// Disallowed in where clauses -fn in_fn_where_clause() - where impl Debug: Debug -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -{ -} - -// Disallowed in where clauses -fn in_adt_in_fn_where_clause() - where Vec: Debug -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -{ -} - -// Disallowed -fn in_trait_parameter_in_fn_where_clause() - where T: PartialEq -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -{ -} - -// Disallowed -fn in_Fn_parameter_in_fn_where_clause() - where T: Fn(impl Debug) -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -{ -} - -// Disallowed -fn in_Fn_return_in_fn_where_clause() - where T: Fn() -> impl Debug -//~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -{ -} - -fn main() { - let _in_local_variable: impl Fn() = || {}; - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types - let _in_return_in_local_variable = || -> impl Fn() { || {} }; - //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types -} - diff --git a/src/test/compile-fail/impl-unused-tps-inherent.rs b/src/test/compile-fail/impl-unused-tps-inherent.rs deleted file mode 100644 index 3803bb9b045..00000000000 --- a/src/test/compile-fail/impl-unused-tps-inherent.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct MyType; - -struct MyType1(T); - -trait Bar { - type Out; -} - -impl MyType { - //~^ ERROR the type parameter `T` is not constrained -} - -impl MyType1 { - // OK, T is used in `Foo`. -} - -impl MyType1 { - //~^ ERROR the type parameter `U` is not constrained -} - -impl MyType1 where T: Bar { - // OK, T is used in `Foo`. -} - -fn main() { } diff --git a/src/test/compile-fail/impl-unused-tps.rs b/src/test/compile-fail/impl-unused-tps.rs deleted file mode 100644 index c9399afbb93..00000000000 --- a/src/test/compile-fail/impl-unused-tps.rs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - fn get(&self, A: &A) { } -} - -trait Bar { - type Out; -} - -impl Foo for [isize;0] { - // OK, T is used in `Foo`. -} - -impl Foo for [isize;1] { - //~^ ERROR the type parameter `U` is not constrained -} - -impl Foo for [isize;2] where T : Bar { - // OK, `U` is now constrained by the output type parameter. -} - -impl,U> Foo for [isize;3] { - // OK, same as above but written differently. -} - -impl Foo for U { - // OK, T, U are used everywhere. Note that the coherence check - // hasn't executed yet, so no errors about overlap. -} - -impl Bar for T { - //~^ ERROR the type parameter `U` is not constrained - - type Out = U; - - // Using `U` in an associated type within the impl is not good enough! -} - -impl Bar for T - where T : Bar -{ - //~^^^ ERROR the type parameter `U` is not constrained - - // This crafty self-referential attempt is still no good. -} - -impl Foo for T - where (T,U): Bar -{ - //~^^^ ERROR the type parameter `U` is not constrained - //~| ERROR the type parameter `V` is not constrained - - // Here, `V` is bound by an output type parameter, but the inputs - // are not themselves constrained. -} - -impl Foo<(T,U)> for T - where (T,U): Bar -{ - // As above, but both T and U ARE constrained. -} - -fn main() { } diff --git a/src/test/compile-fail/implicit-method-bind.rs b/src/test/compile-fail/implicit-method-bind.rs deleted file mode 100644 index e116966670d..00000000000 --- a/src/test/compile-fail/implicit-method-bind.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let _f = 10i32.abs; //~ ERROR attempted to take value of method -} diff --git a/src/test/compile-fail/import-crate-var.rs b/src/test/compile-fail/import-crate-var.rs deleted file mode 100644 index b09883d9ade..00000000000 --- a/src/test/compile-fail/import-crate-var.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:import_crate_var.rs - -#![feature(rustc_attrs)] - -#[macro_use] extern crate import_crate_var; - -#[rustc_error] -fn main() { //~ ERROR compilation successful - m!(); - //~^ WARN `$crate` may not be imported - //~| NOTE `use $crate;` was erroneously allowed and will become a hard error -} diff --git a/src/test/compile-fail/import-from-missing.rs b/src/test/compile-fail/import-from-missing.rs deleted file mode 100644 index 220b255bde4..00000000000 --- a/src/test/compile-fail/import-from-missing.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use spam::{ham, eggs}; //~ ERROR unresolved import `spam::eggs` [E0432] - //~^ no `eggs` in `spam` - -mod spam { - pub fn ham() { } -} - -fn main() { - ham(); - // Expect eggs to pass because the compiler inserts a fake name for it - eggs(); -} diff --git a/src/test/compile-fail/import-glob-0.rs b/src/test/compile-fail/import-glob-0.rs deleted file mode 100644 index 774eaf174d9..00000000000 --- a/src/test/compile-fail/import-glob-0.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use module_of_many_things::*; - -mod module_of_many_things { - pub fn f1() { println!("f1"); } - pub fn f2() { println!("f2"); } - fn f3() { println!("f3"); } - pub fn f4() { println!("f4"); } -} - - -fn main() { - f1(); - f2(); - f999(); //~ ERROR cannot find function `f999` in this scope - f4(); -} diff --git a/src/test/compile-fail/import-glob-circular.rs b/src/test/compile-fail/import-glob-circular.rs deleted file mode 100644 index d9cc17791ed..00000000000 --- a/src/test/compile-fail/import-glob-circular.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod circ1 { - pub use circ2::f2; - pub fn f1() { println!("f1"); } - pub fn common() -> usize { return 0; } -} - -mod circ2 { - pub use circ1::f1; - pub fn f2() { println!("f2"); } - pub fn common() -> usize { return 1; } -} - -mod test { - use circ1::*; - - fn test() { f1066(); } //~ ERROR cannot find function `f1066` in this scope -} diff --git a/src/test/compile-fail/import-loop-2.rs b/src/test/compile-fail/import-loop-2.rs deleted file mode 100644 index b7bbe11a4dc..00000000000 --- a/src/test/compile-fail/import-loop-2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:import - -mod a { - pub use b::x; -} - -mod b { - pub use a::x; - - fn main() { let y = x; } -} diff --git a/src/test/compile-fail/import-loop.rs b/src/test/compile-fail/import-loop.rs deleted file mode 100644 index f9b57f00776..00000000000 --- a/src/test/compile-fail/import-loop.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:import - -use y::x; - -mod y { - pub use y::x; -} - -fn main() { } diff --git a/src/test/compile-fail/import-prefix-macro-1.rs b/src/test/compile-fail/import-prefix-macro-1.rs deleted file mode 100644 index beb15a11a96..00000000000 --- a/src/test/compile-fail/import-prefix-macro-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub mod b { - pub mod c { - pub struct S; - pub struct Z; - } - } -} - -macro_rules! import { - ($p: path) => (use $p {S, Z}); //~ERROR expected one of `::`, `;`, or `as`, found `{` -} - -import! { a::b::c } - -fn main() {} diff --git a/src/test/compile-fail/import-prefix-macro-2.rs b/src/test/compile-fail/import-prefix-macro-2.rs deleted file mode 100644 index 56c6273aa9a..00000000000 --- a/src/test/compile-fail/import-prefix-macro-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub mod b { - pub mod c { - pub struct S; - pub struct Z; - } - } -} - -macro_rules! import { - ($p: path) => (use ::$p {S, Z}); //~ERROR expected identifier, found `a::b::c` -} - -import! { a::b::c } - -fn main() {} diff --git a/src/test/compile-fail/import-trait-method.rs b/src/test/compile-fail/import-trait-method.rs deleted file mode 100644 index 75081b10d86..00000000000 --- a/src/test/compile-fail/import-trait-method.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - fn foo(); -} - -use Foo::foo; //~ ERROR not directly importable - -fn main() { foo(); } diff --git a/src/test/compile-fail/import.rs b/src/test/compile-fail/import.rs deleted file mode 100644 index 81a5334ed7a..00000000000 --- a/src/test/compile-fail/import.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use zed::bar; -use zed::baz; //~ ERROR unresolved import `zed::baz` [E0432] - //~^ no `baz` in `zed`. Did you mean to use `bar`? - - -mod zed { - pub fn bar() { println!("bar"); } - use foo; //~ ERROR unresolved import `foo` [E0432] - //~^ no `foo` in the root -} - -fn main() { - zed::foo(); //~ ERROR `foo` is private - bar(); -} diff --git a/src/test/compile-fail/import2.rs b/src/test/compile-fail/import2.rs deleted file mode 100644 index c4bd9ff1e2a..00000000000 --- a/src/test/compile-fail/import2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use baz::zed::bar; //~ ERROR unresolved import `baz::zed` [E0432] - //~^ Could not find `zed` in `baz` - -mod baz {} -mod zed { - pub fn bar() { println!("bar3"); } -} -fn main() { - bar(); -} diff --git a/src/test/compile-fail/import3.rs b/src/test/compile-fail/import3.rs deleted file mode 100644 index 0a7827587a6..00000000000 --- a/src/test/compile-fail/import3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: unresolved -use main::bar; - -fn main() { println!("foo"); } diff --git a/src/test/compile-fail/import4.rs b/src/test/compile-fail/import4.rs deleted file mode 100644 index 5f3163e9390..00000000000 --- a/src/test/compile-fail/import4.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: import - - -mod a { pub use b::foo; } -mod b { pub use a::foo; } - -fn main() { println!("loop"); } diff --git a/src/test/compile-fail/imports/reexports.rs b/src/test/compile-fail/imports/reexports.rs deleted file mode 100644 index f50b5b0e849..00000000000 --- a/src/test/compile-fail/imports/reexports.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - fn foo() {} - mod foo {} - - mod a { - pub use super::foo; //~ ERROR cannot be re-exported - pub use super::*; //~ ERROR must import something with the glob's visibility - } -} - -mod b { - pub fn foo() {} - mod foo { pub struct S; } - - pub mod a { - pub use super::foo; // This is OK since the value `foo` is visible enough. - fn f(_: foo::S) {} // `foo` is imported in the type namespace (but not `pub` re-exported). - } - - pub mod b { - pub use super::*; // This is also OK since the value `foo` is visible enough. - fn f(_: foo::S) {} // Again, the module `foo` is imported (but not `pub` re-exported). - } -} - -mod c { - // Test that `foo` is not re-exported. - use b::a::foo::S; //~ ERROR `foo` - use b::b::foo::S as T; //~ ERROR `foo` -} - -fn main() {} diff --git a/src/test/compile-fail/imports/unused-macro-use.rs b/src/test/compile-fail/imports/unused-macro-use.rs deleted file mode 100644 index 365521970cd..00000000000 --- a/src/test/compile-fail/imports/unused-macro-use.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused)] - -#[macro_use] //~ ERROR unused `#[macro_use]` import -extern crate core; - -#[macro_use( - panic //~ ERROR unused `#[macro_use]` import -)] -extern crate core as core_2; - -fn main() {} diff --git a/src/test/compile-fail/imports/unused.rs b/src/test/compile-fail/imports/unused.rs deleted file mode 100644 index 1eb756fe9e4..00000000000 --- a/src/test/compile-fail/imports/unused.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused)] - -mod foo { - fn f() {} - - mod m1 { - pub(super) use super::f; //~ ERROR unused - } - - mod m2 { - #[allow(unused)] - use super::m1::*; // (despite this glob import) - } - - mod m3 { - pub(super) use super::f; // Check that this is counted as used (c.f. #36249). - } - - pub mod m4 { - use super::m3::*; - pub fn g() { f(); } - } -} - -fn main() { - foo::m4::g(); -} diff --git a/src/test/compile-fail/inaccessible-test-modules.rs b/src/test/compile-fail/inaccessible-test-modules.rs deleted file mode 100644 index bfc1ac2daef..00000000000 --- a/src/test/compile-fail/inaccessible-test-modules.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:--test - -// the `--test` harness creates modules with these textual names, but -// they should be inaccessible from normal code. -use __test as x; //~ ERROR unresolved import `__test` -use __test_reexports as y; //~ ERROR unresolved import `__test_reexports` - -#[test] -fn baz() {} diff --git a/src/test/compile-fail/index-bot.rs b/src/test/compile-fail/index-bot.rs deleted file mode 100644 index fc88ff6f47b..00000000000 --- a/src/test/compile-fail/index-bot.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - (return)[0]; //~ ERROR cannot index into a value of type `!` -} diff --git a/src/test/compile-fail/index_message.rs b/src/test/compile-fail/index_message.rs deleted file mode 100644 index b9daad936c3..00000000000 --- a/src/test/compile-fail/index_message.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let z = (); - let _ = z[0]; //~ ERROR cannot index into a value of type `()` -} diff --git a/src/test/compile-fail/indexing-requires-a-uint.rs b/src/test/compile-fail/indexing-requires-a-uint.rs deleted file mode 100644 index 624944f7344..00000000000 --- a/src/test/compile-fail/indexing-requires-a-uint.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Make sure that indexing an array is only valid with a `usize`, not any other -// integral type. - -fn main() { - fn bar(_: T) {} - [0][0u8]; //~ ERROR: the trait bound `u8: std::slice::SliceIndex<[{integer}]>` is not satisfied - - [0][0]; // should infer to be a usize - - let i = 0; // i is an IntVar - [0][i]; // i should be locked to usize - bar::(i); // i should not be re-coerced back to an isize - //~^ ERROR: mismatched types -} diff --git a/src/test/compile-fail/infinite-autoderef.rs b/src/test/compile-fail/infinite-autoderef.rs deleted file mode 100644 index 3635c4dbb02..00000000000 --- a/src/test/compile-fail/infinite-autoderef.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: reached the recursion limit while auto-dereferencing - -#![feature(box_syntax)] - -use std::ops::Deref; - -struct Foo; - -impl Deref for Foo { - type Target = Foo; - - fn deref(&self) -> &Foo { - self - } -} - -pub fn main() { - let mut x; - loop { - x = box x; - x.foo; - x.bar(); - } - - Foo.foo; - Foo.bar(); -} diff --git a/src/test/compile-fail/infinite-instantiation.rs b/src/test/compile-fail/infinite-instantiation.rs deleted file mode 100644 index 08e6bf24691..00000000000 --- a/src/test/compile-fail/infinite-instantiation.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// -// We get an error message at the top of file (dummy span). -// This is not helpful, but also kind of annoying to prevent, -// so for now just live with it. -// This test case was originally for issue #2258. - -trait ToOpt: Sized { - fn to_option(&self) -> Option; -} - -impl ToOpt for usize { - fn to_option(&self) -> Option { - Some(*self) - } -} - -impl ToOpt for Option { - fn to_option(&self) -> Option> { - Some((*self).clone()) - } -} - -fn function(counter: usize, t: T) { -//~^ ERROR reached the recursion limit while instantiating `function:: 0 { - function(counter - 1, t.to_option()); - // FIXME(#4287) Error message should be here. It should be - // a type error to instantiate `test` at a type other than T. - } -} - -fn main() { - function(22, 22); -} diff --git a/src/test/compile-fail/infinite-macro-expansion.rs b/src/test/compile-fail/infinite-macro-expansion.rs deleted file mode 100644 index 14d22702db7..00000000000 --- a/src/test/compile-fail/infinite-macro-expansion.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! recursive { - () => (recursive!()) //~ ERROR recursion limit reached while expanding the macro `recursive` -} - -fn main() { - recursive!() -} diff --git a/src/test/compile-fail/infinite-tag-type-recursion.rs b/src/test/compile-fail/infinite-tag-type-recursion.rs deleted file mode 100644 index c9a7f731aea..00000000000 --- a/src/test/compile-fail/infinite-tag-type-recursion.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum mlist { cons(isize, mlist), nil, } -//~^ ERROR recursive type `mlist` has infinite size - -fn main() { let a = mlist::cons(10, mlist::cons(11, mlist::nil)); } diff --git a/src/test/compile-fail/infinite-vec-type-recursion.rs b/src/test/compile-fail/infinite-vec-type-recursion.rs deleted file mode 100644 index 42c80b54313..00000000000 --- a/src/test/compile-fail/infinite-vec-type-recursion.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -type x = Vec; -//~^ ERROR cycle detected - -fn main() { let b: x = Vec::new(); } diff --git a/src/test/compile-fail/inhabitedness-infinite-loop.rs b/src/test/compile-fail/inhabitedness-infinite-loop.rs deleted file mode 100644 index d11aacec196..00000000000 --- a/src/test/compile-fail/inhabitedness-infinite-loop.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:reached recursion limit - -#![feature(never_type)] -#![feature(exhaustive_patterns)] - -struct Foo<'a, T: 'a> { - ph: std::marker::PhantomData, - foo: &'a Foo<'a, (T, T)>, -} - -fn wub(f: Foo) { - match f {} -} - -fn main() {} - diff --git a/src/test/compile-fail/init-unsafe.rs b/src/test/compile-fail/init-unsafe.rs deleted file mode 100644 index 9e599cebd7a..00000000000 --- a/src/test/compile-fail/init-unsafe.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(core_intrinsics)] - -use std::intrinsics::{init}; - -// Test that the `init` intrinsic is really unsafe -pub fn main() { - let stuff = init::(); //~ ERROR call to unsafe function is unsafe -} diff --git a/src/test/compile-fail/inner-static-type-parameter.rs b/src/test/compile-fail/inner-static-type-parameter.rs deleted file mode 100644 index 4d763017c0f..00000000000 --- a/src/test/compile-fail/inner-static-type-parameter.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// see #9186 - -enum Bar { What } //~ ERROR parameter `T` is never used - -fn foo() { - static a: Bar = Bar::What; -//~^ ERROR can't use type parameters from outer function -} - -fn main() { -} diff --git a/src/test/compile-fail/integer-literal-suffix-inference.rs b/src/test/compile-fail/integer-literal-suffix-inference.rs deleted file mode 100644 index 7a850d90a87..00000000000 --- a/src/test/compile-fail/integer-literal-suffix-inference.rs +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - - // the smallest positive values that need these types - let a8: i8 = 8; - let a16: i16 = 128; - let a32: i32 = 32_768; - let a64: i64 = 2_147_483_648; - - // the smallest negative values that need these types - let c8: i8 = -9; - let c16: i16 = -129; - let c32: i32 = -32_769; - let c64: i64 = -2_147_483_649; - - fn id_i8(n: i8) -> i8 { n } - fn id_i16(n: i16) -> i16 { n } - fn id_i32(n: i32) -> i32 { n } - fn id_i64(n: i64) -> i64 { n } - - // the smallest values that need these types - let b8: u8 = 16; - let b16: u16 = 256; - let b32: u32 = 65_536; - let b64: u64 = 4_294_967_296; - - fn id_u8(n: u8) -> u8 { n } - fn id_u16(n: u16) -> u16 { n } - fn id_u32(n: u32) -> u32 { n } - fn id_u64(n: u64) -> u64 { n } - - id_i8(a8); // ok - id_i8(a16); - //~^ ERROR mismatched types - //~| expected i8, found i16 - id_i8(a32); - //~^ ERROR mismatched types - //~| expected i8, found i32 - id_i8(a64); - //~^ ERROR mismatched types - //~| expected i8, found i64 - - id_i16(a8); - //~^ ERROR mismatched types - //~| expected i16, found i8 - id_i16(a16); // ok - id_i16(a32); - //~^ ERROR mismatched types - //~| expected i16, found i32 - id_i16(a64); - //~^ ERROR mismatched types - //~| expected i16, found i64 - - id_i32(a8); - //~^ ERROR mismatched types - //~| expected i32, found i8 - id_i32(a16); - //~^ ERROR mismatched types - //~| expected i32, found i16 - id_i32(a32); // ok - id_i32(a64); - //~^ ERROR mismatched types - //~| expected i32, found i64 - - id_i64(a8); - //~^ ERROR mismatched types - //~| expected i64, found i8 - id_i64(a16); - //~^ ERROR mismatched types - //~| expected i64, found i16 - id_i64(a32); - //~^ ERROR mismatched types - //~| expected i64, found i32 - id_i64(a64); // ok - - id_i8(c8); // ok - id_i8(c16); - //~^ ERROR mismatched types - //~| expected i8, found i16 - id_i8(c32); - //~^ ERROR mismatched types - //~| expected i8, found i32 - id_i8(c64); - //~^ ERROR mismatched types - //~| expected i8, found i64 - - id_i16(c8); - //~^ ERROR mismatched types - //~| expected i16, found i8 - id_i16(c16); // ok - id_i16(c32); - //~^ ERROR mismatched types - //~| expected i16, found i32 - id_i16(c64); - //~^ ERROR mismatched types - //~| expected i16, found i64 - - id_i32(c8); - //~^ ERROR mismatched types - //~| expected i32, found i8 - id_i32(c16); - //~^ ERROR mismatched types - //~| expected i32, found i16 - id_i32(c32); // ok - id_i32(c64); - //~^ ERROR mismatched types - //~| expected i32, found i64 - - id_i64(a8); - //~^ ERROR mismatched types - //~| expected i64, found i8 - id_i64(a16); - //~^ ERROR mismatched types - //~| expected i64, found i16 - id_i64(a32); - //~^ ERROR mismatched types - //~| expected i64, found i32 - id_i64(a64); // ok - - id_u8(b8); // ok - id_u8(b16); - //~^ ERROR mismatched types - //~| expected u8, found u16 - id_u8(b32); - //~^ ERROR mismatched types - //~| expected u8, found u32 - id_u8(b64); - //~^ ERROR mismatched types - //~| expected u8, found u64 - - id_u16(b8); - //~^ ERROR mismatched types - //~| expected u16, found u8 - id_u16(b16); // ok - id_u16(b32); - //~^ ERROR mismatched types - //~| expected u16, found u32 - id_u16(b64); - //~^ ERROR mismatched types - //~| expected u16, found u64 - - id_u32(b8); - //~^ ERROR mismatched types - //~| expected u32, found u8 - id_u32(b16); - //~^ ERROR mismatched types - //~| expected u32, found u16 - id_u32(b32); // ok - id_u32(b64); - //~^ ERROR mismatched types - //~| expected u32, found u64 - - id_u64(b8); - //~^ ERROR mismatched types - //~| expected u64, found u8 - id_u64(b16); - //~^ ERROR mismatched types - //~| expected u64, found u16 - id_u64(b32); - //~^ ERROR mismatched types - //~| expected u64, found u32 - id_u64(b64); // ok -} diff --git a/src/test/compile-fail/integral-indexing.rs b/src/test/compile-fail/integral-indexing.rs deleted file mode 100644 index 4b01afb8131..00000000000 --- a/src/test/compile-fail/integral-indexing.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - let v: Vec = vec![0, 1, 2, 3, 4, 5]; - let s: String = "abcdef".to_string(); - v[3_usize]; - v[3]; - v[3u8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied - v[3i8]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied - v[3u32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied - v[3i32]; //~ERROR : std::slice::SliceIndex<[isize]>` is not satisfied - s.as_bytes()[3_usize]; - s.as_bytes()[3]; - s.as_bytes()[3u8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied - s.as_bytes()[3i8]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied - s.as_bytes()[3u32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied - s.as_bytes()[3i32]; //~ERROR : std::slice::SliceIndex<[u8]>` is not satisfied -} diff --git a/src/test/compile-fail/integral-variable-unification-error.rs b/src/test/compile-fail/integral-variable-unification-error.rs deleted file mode 100644 index f2686ae4d19..00000000000 --- a/src/test/compile-fail/integral-variable-unification-error.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let mut x = 2; - x = 5.0; - //~^ ERROR mismatched types - //~| expected type `{integer}` - //~| found type `{float}` - //~| expected integral variable, found floating-point variable -} diff --git a/src/test/compile-fail/internal-unstable-noallow.rs b/src/test/compile-fail/internal-unstable-noallow.rs deleted file mode 100644 index 2e42e9d3b01..00000000000 --- a/src/test/compile-fail/internal-unstable-noallow.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// this has to be separate to internal-unstable.rs because these tests -// have error messages pointing deep into the internals of the -// cross-crate macros, and hence need to use error-pattern instead of -// the // ~ form. - -// aux-build:internal_unstable.rs -// error-pattern:use of unstable library feature 'function' -// error-pattern:use of unstable library feature 'struct_field' -// error-pattern:use of unstable library feature 'method' -// error-pattern:use of unstable library feature 'struct2_field' - -#[macro_use] -extern crate internal_unstable; - -fn main() { - call_unstable_noallow!(); - - construct_unstable_noallow!(0); - - |x: internal_unstable::Foo| { call_method_noallow!(x) }; - - |x: internal_unstable::Bar| { access_field_noallow!(x) }; -} diff --git a/src/test/compile-fail/internal-unstable-thread-local.rs b/src/test/compile-fail/internal-unstable-thread-local.rs deleted file mode 100644 index 74526fb3d83..00000000000 --- a/src/test/compile-fail/internal-unstable-thread-local.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:internal_unstable.rs - -#![allow(dead_code)] - -extern crate internal_unstable; - - -thread_local!(static FOO: () = ()); -thread_local!(static BAR: () = internal_unstable::unstable()); //~ ERROR use of unstable - -fn main() {} diff --git a/src/test/compile-fail/internal-unstable.rs b/src/test/compile-fail/internal-unstable.rs deleted file mode 100644 index e01259f0deb..00000000000 --- a/src/test/compile-fail/internal-unstable.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:internal_unstable.rs - -#![feature(allow_internal_unstable)] - -#[macro_use] -extern crate internal_unstable; - -macro_rules! foo { - ($e: expr, $f: expr) => {{ - $e; - $f; - internal_unstable::unstable(); //~ ERROR use of unstable - }} -} - -#[allow_internal_unstable] -macro_rules! bar { - ($e: expr) => {{ - foo!($e, - internal_unstable::unstable()); - internal_unstable::unstable(); - }} -} - -fn main() { - // ok, the instability is contained. - call_unstable_allow!(); - construct_unstable_allow!(0); - |x: internal_unstable::Foo| { call_method_allow!(x) }; - |x: internal_unstable::Bar| { access_field_allow!(x) }; - - // bad. - pass_through_allow!(internal_unstable::unstable()); //~ ERROR use of unstable - - pass_through_noallow!(internal_unstable::unstable()); //~ ERROR use of unstable - - - - println!("{:?}", internal_unstable::unstable()); //~ ERROR use of unstable - - bar!(internal_unstable::unstable()); //~ ERROR use of unstable -} diff --git a/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs b/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs deleted file mode 100644 index a224690af76..00000000000 --- a/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test number of arguments in platform-specific intrinsic function -// This is the error E0444 - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -struct f64x2(f64, f64); - -extern "platform-intrinsic" { - fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ platform-specific intrinsic -} - -pub fn main() { -} diff --git a/src/test/compile-fail/invalid-crate-type.rs b/src/test/compile-fail/invalid-crate-type.rs deleted file mode 100644 index 4b6b6c2fe76..00000000000 --- a/src/test/compile-fail/invalid-crate-type.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// regression test for issue 11256 -#![crate_type="foo"] //~ ERROR invalid `crate_type` value - -fn main() { - return -} diff --git a/src/test/compile-fail/invalid-inline.rs b/src/test/compile-fail/invalid-inline.rs deleted file mode 100644 index 93b985b4fb0..00000000000 --- a/src/test/compile-fail/invalid-inline.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![allow(dead_code)] - -#[inline(please_no)] //~ ERROR invalid argument -fn a() { -} - -#[inline(please,no)] //~ ERROR expected one argument -fn b() { -} - -#[inline()] //~ ERROR expected one argument -fn c() { -} - -fn main() { - a(); - b(); - c(); -} diff --git a/src/test/compile-fail/invalid-macro-matcher.rs b/src/test/compile-fail/invalid-macro-matcher.rs deleted file mode 100644 index d710f5647dd..00000000000 --- a/src/test/compile-fail/invalid-macro-matcher.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_macros)] - -macro_rules! invalid { - _ => (); //~ ERROR invalid macro matcher -} - -fn main() { -} diff --git a/src/test/compile-fail/invalid-plugin-attr.rs b/src/test/compile-fail/invalid-plugin-attr.rs deleted file mode 100644 index 3bf09e10ae8..00000000000 --- a/src/test/compile-fail/invalid-plugin-attr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_attributes)] -#![feature(plugin)] - -#[plugin(bla)] //~ ERROR unused attribute - //~^ ERROR should be an inner attribute - -fn main() {} diff --git a/src/test/compile-fail/invalid_crate_type_syntax.rs b/src/test/compile-fail/invalid_crate_type_syntax.rs deleted file mode 100644 index 6d42515704e..00000000000 --- a/src/test/compile-fail/invalid_crate_type_syntax.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// regression test for issue 16974 -#![crate_type(lib)] //~ ERROR `crate_type` requires a value - -fn my_lib_fn() {} diff --git a/src/test/compile-fail/isssue-38821.rs b/src/test/compile-fail/isssue-38821.rs deleted file mode 100644 index 63de780e109..00000000000 --- a/src/test/compile-fail/isssue-38821.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Nullable(T); - -pub trait NotNull {} - -pub trait IntoNullable { - type Nullable; -} - -impl IntoNullable for T { - type Nullable = Nullable; -} - -impl IntoNullable for Nullable { - type Nullable = Nullable; -} - -pub trait Expression { - type SqlType; -} - -pub trait Column: Expression {} - -#[derive(Debug, Copy, Clone)] -//~^ ERROR the trait bound `::SqlType: NotNull` is not satisfied -pub enum ColumnInsertValue where - Col: Column, - Expr: Expression::Nullable>, -{ - Expression(Col, Expr), - Default(Col), -} - -fn main() {} diff --git a/src/test/compile-fail/issue-10755.rs b/src/test/compile-fail/issue-10755.rs deleted file mode 100644 index 57915bce456..00000000000 --- a/src/test/compile-fail/issue-10755.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -C linker=llllll -Z linker-flavor=ld -// error-pattern: linker `llllll` not found - -fn main() { -} diff --git a/src/test/compile-fail/issue-11593.rs b/src/test/compile-fail/issue-11593.rs deleted file mode 100644 index 2749438433d..00000000000 --- a/src/test/compile-fail/issue-11593.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:private_trait_xc.rs - -extern crate private_trait_xc; - -struct Bar; - -impl private_trait_xc::Foo for Bar {} -//~^ ERROR: trait `Foo` is private - -fn main() {} diff --git a/src/test/compile-fail/issue-11680.rs b/src/test/compile-fail/issue-11680.rs deleted file mode 100644 index 7dccd781106..00000000000 --- a/src/test/compile-fail/issue-11680.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_11680.rs - -extern crate issue_11680 as other; - -fn main() { - let _b = other::Foo::Bar(1); - //~^ ERROR: enum `Foo` is private - - let _b = other::test::Foo::Bar(1); - //~^ ERROR: enum `Foo` is private -} diff --git a/src/test/compile-fail/issue-15919.rs b/src/test/compile-fail/issue-15919.rs deleted file mode 100644 index df7e7c102b2..00000000000 --- a/src/test/compile-fail/issue-15919.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: too big for the current architecture - -#[cfg(target_pointer_width = "32")] -fn main() { - let x = [0usize; 0xffff_ffff]; -} - -#[cfg(target_pointer_width = "64")] -fn main() { - let x = [0usize; 0xffff_ffff_ffff_ffff]; -} diff --git a/src/test/compile-fail/issue-16725.rs b/src/test/compile-fail/issue-16725.rs deleted file mode 100644 index cadf602a4cf..00000000000 --- a/src/test/compile-fail/issue-16725.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_16725.rs - -extern crate issue_16725 as foo; - -fn main() { - unsafe { foo::bar(); } - //~^ ERROR: function `bar` is private -} diff --git a/src/test/compile-fail/issue-17718-const-privacy.rs b/src/test/compile-fail/issue-17718-const-privacy.rs deleted file mode 100644 index 523a387956a..00000000000 --- a/src/test/compile-fail/issue-17718-const-privacy.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_17718_const_privacy.rs - -extern crate issue_17718_const_privacy as other; - -use a::B; //~ ERROR: constant `B` is private -use other::{ - FOO, - BAR, //~ ERROR: constant `BAR` is private - FOO2, -}; - -mod a { - const B: usize = 3; -} - -fn main() {} diff --git a/src/test/compile-fail/issue-17913.rs b/src/test/compile-fail/issue-17913.rs deleted file mode 100644 index 80e5f2b6e21..00000000000 --- a/src/test/compile-fail/issue-17913.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern: too big for the current architecture - -#![feature(box_syntax)] - -#[cfg(target_pointer_width = "64")] -fn main() { - let n = 0_usize; - let a: Box<_> = box [&n; 0xF000000000000000_usize]; - println!("{}", a[0xFFFFFF_usize]); -} - -#[cfg(target_pointer_width = "32")] -fn main() { - let n = 0_usize; - let a: Box<_> = box [&n; 0xFFFFFFFF_usize]; - println!("{}", a[0xFFFFFF_usize]); -} diff --git a/src/test/compile-fail/issue-19163.rs b/src/test/compile-fail/issue-19163.rs deleted file mode 100644 index cd6f7c4fd8f..00000000000 --- a/src/test/compile-fail/issue-19163.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue-19163.rs - -#[macro_use] extern crate issue_19163; - -use std::io::Write; - -fn main() { - let mut v = vec![]; - mywrite!(&v, "Hello world"); - //~^ error: cannot borrow immutable borrowed content as mutable -} diff --git a/src/test/compile-fail/issue-1920-1.rs b/src/test/compile-fail/issue-1920-1.rs deleted file mode 100644 index 97dd290a45b..00000000000 --- a/src/test/compile-fail/issue-1920-1.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Test that absolute path names are correct when a crate is not linked into the root namespace - -// aux-build:issue_1920.rs - -mod foo { - pub extern crate issue_1920; -} - -fn assert_clone() where T : Clone { } - -fn main() { - assert_clone::(); - //~^ ERROR `foo::issue_1920::S: std::clone::Clone` is not satisfied -} diff --git a/src/test/compile-fail/issue-1920-2.rs b/src/test/compile-fail/issue-1920-2.rs deleted file mode 100644 index 2af6e2cc991..00000000000 --- a/src/test/compile-fail/issue-1920-2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Test that when a crate is linked under another name that name is used in global paths - -// aux-build:issue_1920.rs - -extern crate issue_1920 as bar; - -fn assert_clone() where T : Clone { } - -fn main() { - assert_clone::(); - //~^ ERROR `bar::S: std::clone::Clone` is not satisfied -} diff --git a/src/test/compile-fail/issue-1920-3.rs b/src/test/compile-fail/issue-1920-3.rs deleted file mode 100644 index fa6efea845f..00000000000 --- a/src/test/compile-fail/issue-1920-3.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Test that when a crate is linked multiple times that the shortest absolute path name is used - -// aux-build:issue_1920.rs - -mod foo { - pub extern crate issue_1920; -} - -extern crate issue_1920; - -fn assert_clone() where T : Clone { } - -fn main() { - assert_clone::(); - //~^ ERROR `issue_1920::S: std::clone::Clone` is not satisfied -} diff --git a/src/test/compile-fail/issue-21146.rs b/src/test/compile-fail/issue-21146.rs deleted file mode 100644 index 457d40e62b0..00000000000 --- a/src/test/compile-fail/issue-21146.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: expected one of `!` or `::`, found `` -include!("auxiliary/issue-21146-inc.rs"); -fn main() {} diff --git a/src/test/compile-fail/issue-21202.rs b/src/test/compile-fail/issue-21202.rs deleted file mode 100644 index 2bce838c1cf..00000000000 --- a/src/test/compile-fail/issue-21202.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_21202.rs - -extern crate issue_21202 as crate1; - -use crate1::A; - -mod B { - use crate1::A::Foo; - fn bar(f: Foo) { - Foo::foo(&f); - //~^ ERROR: method `foo` is private - } -} - -fn main() { } diff --git a/src/test/compile-fail/issue-22638.rs b/src/test/compile-fail/issue-22638.rs deleted file mode 100644 index 1c534ebbd43..00000000000 --- a/src/test/compile-fail/issue-22638.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] - -#![recursion_limit = "20"] -#![type_length_limit = "20000000"] -#![crate_type = "rlib"] - -#[derive(Clone)] -struct A (B); - -impl A { - pub fn matches(&self, f: &F) { - let &A(ref term) = self; - term.matches(f); - } -} - -#[derive(Clone)] -enum B { - Variant1, - Variant2(C), -} - -impl B { - pub fn matches(&self, f: &F) { - match self { - &B::Variant2(ref factor) => { - factor.matches(&|| ()) - } - _ => unreachable!("") - } - } -} - -#[derive(Clone)] -struct C (D); - -impl C { - pub fn matches(&self, f: &F) { - let &C(ref base) = self; - base.matches(&|| { - C(base.clone()).matches(f) - }) - } -} - -#[derive(Clone)] -struct D (Box); - -impl D { - pub fn matches(&self, f: &F) { - //~^ ERROR reached the type-length limit while instantiating `D::matches::<[closure - let &D(ref a) = self; - a.matches(f) - } -} - -pub fn matches() { - A(B::Variant1).matches(&(|| ())) -} diff --git a/src/test/compile-fail/issue-23595-1.rs b/src/test/compile-fail/issue-23595-1.rs deleted file mode 100644 index a3422d859c6..00000000000 --- a/src/test/compile-fail/issue-23595-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(associated_type_defaults)] - -use std::ops::{Index}; - -trait Hierarchy { - type Value; - type ChildKey; - type Children = Index; - //~^ ERROR: the value of the associated type `ChildKey` - //~^^ ERROR: the value of the associated type `Children` - //~^^^ ERROR: the value of the associated type `Value` - - fn data(&self) -> Option<(Self::Value, Self::Children)>; -} - -fn main() {} diff --git a/src/test/compile-fail/issue-26548.rs b/src/test/compile-fail/issue-26548.rs deleted file mode 100644 index 85ddf8d9493..00000000000 --- a/src/test/compile-fail/issue-26548.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//~^^^^^^^^^^ ERROR cycle detected when computing layout of -//~| NOTE ...which requires computing layout of -//~| NOTE ...which again requires computing layout of - -trait Mirror { type It: ?Sized; } -impl Mirror for T { type It = Self; } -struct S(Option<::It>); - -fn main() { //~ NOTE cycle used when processing `main` - let _s = S(None); -} diff --git a/src/test/compile-fail/issue-28075.rs b/src/test/compile-fail/issue-28075.rs deleted file mode 100644 index 0f6b9d1b5dc..00000000000 --- a/src/test/compile-fail/issue-28075.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Unstable entities should be caught in import lists - -// aux-build:lint_stability.rs - -#![allow(warnings)] - -extern crate lint_stability; - -use lint_stability::{unstable, deprecated}; -//~^ ERROR use of unstable library feature 'unstable_test_feature' - -fn main() { -} diff --git a/src/test/compile-fail/issue-28388-1.rs b/src/test/compile-fail/issue-28388-1.rs deleted file mode 100644 index 187d91731d0..00000000000 --- a/src/test/compile-fail/issue-28388-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. - -use foo::{}; //~ ERROR cannot find module or enum `foo` in the crate root - -fn main() {} diff --git a/src/test/compile-fail/issue-28388-2.rs b/src/test/compile-fail/issue-28388-2.rs deleted file mode 100644 index 4ed5bfab06f..00000000000 --- a/src/test/compile-fail/issue-28388-2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. - -mod m { - mod n {} -} - -use m::n::{}; -//~^ ERROR module `n` is private - -fn main() {} diff --git a/src/test/compile-fail/issue-28388-3.rs b/src/test/compile-fail/issue-28388-3.rs deleted file mode 100644 index 12e3457ef9e..00000000000 --- a/src/test/compile-fail/issue-28388-3.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. - -// aux-build:lint_stability.rs - -extern crate lint_stability; - -use lint_stability::UnstableEnum::{}; -//~^ ERROR use of unstable library feature 'unstable_test_feature' -use lint_stability::StableEnum::{}; // OK - -fn main() {} diff --git a/src/test/compile-fail/issue-28625.rs b/src/test/compile-fail/issue-28625.rs deleted file mode 100644 index dc9155ed66c..00000000000 --- a/src/test/compile-fail/issue-28625.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Bar { - type Bar; -} - -struct ArrayPeano { - data: T::Bar, -} - -fn foo(a: &ArrayPeano) -> &[T] where T: Bar { - unsafe { std::mem::transmute(a) } //~ ERROR transmute called with types of different sizes -} - -impl Bar for () { - type Bar = (); -} - -fn main() { - let x: ArrayPeano<()> = ArrayPeano { data: () }; - foo(&x); -} diff --git a/src/test/compile-fail/issue-28848.rs b/src/test/compile-fail/issue-28848.rs deleted file mode 100644 index 1a06d59f0b1..00000000000 --- a/src/test/compile-fail/issue-28848.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo<'a, 'b: 'a>(&'a &'b ()); - -impl<'a, 'b> Foo<'a, 'b> { - fn xmute(a: &'b ()) -> &'a () { - unreachable!() - } -} - -pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { - Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied -} - -fn main() {} diff --git a/src/test/compile-fail/issue-29181.rs b/src/test/compile-fail/issue-29181.rs deleted file mode 100644 index 2fcec51912e..00000000000 --- a/src/test/compile-fail/issue-29181.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue-29181.rs - -extern crate issue_29181 as foo; - -fn main() { - 0.homura(); //~ ERROR no method named `homura` found -} diff --git a/src/test/compile-fail/issue-30123.rs b/src/test/compile-fail/issue-30123.rs deleted file mode 100644 index 653097ad69f..00000000000 --- a/src/test/compile-fail/issue-30123.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_30123_aux.rs - -extern crate issue_30123_aux; -use issue_30123_aux::*; - -fn main() { - let ug = Graph::::new_undirected(); - //~^ ERROR no function or associated item named `new_undirected` found for type -} diff --git a/src/test/compile-fail/issue-30535.rs b/src/test/compile-fail/issue-30535.rs deleted file mode 100644 index 90f5220a623..00000000000 --- a/src/test/compile-fail/issue-30535.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue-30535.rs - -extern crate issue_30535 as foo; - -fn bar( - _: foo::Foo::FooV //~ ERROR expected type, found variant `foo::Foo::FooV` -) {} - -fn main() {} diff --git a/src/test/compile-fail/issue-32377.rs b/src/test/compile-fail/issue-32377.rs deleted file mode 100644 index 5091ba4ee1a..00000000000 --- a/src/test/compile-fail/issue-32377.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem; -use std::marker::PhantomData; - -trait Foo { - type Error; -} - -struct Bar { - stream: PhantomData, -} - -fn foo(x: [usize; 2]) -> Bar { - unsafe { mem::transmute(x) } - //~^ ERROR transmute called with types of different sizes -} - -fn main() {} diff --git a/src/test/compile-fail/issue-36881.rs b/src/test/compile-fail/issue-36881.rs deleted file mode 100644 index 0f5aa24926b..00000000000 --- a/src/test/compile-fail/issue-36881.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue-36881-aux.rs - -fn main() { - #[allow(unused_extern_crates)] - extern crate issue_36881_aux; - use issue_36881_aux::Foo; //~ ERROR unresolved import -} diff --git a/src/test/compile-fail/issue-37131.rs b/src/test/compile-fail/issue-37131.rs deleted file mode 100644 index efb0b249a8a..00000000000 --- a/src/test/compile-fail/issue-37131.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that compiling for a target which is not installed will result in a helpful -// error message. - -// compile-flags: --target=thumbv6m-none-eabi -// ignore-arm - -// error-pattern:target may not be installed -fn main() { } diff --git a/src/test/compile-fail/issue-41549.rs b/src/test/compile-fail/issue-41549.rs deleted file mode 100644 index 67be194c8ed..00000000000 --- a/src/test/compile-fail/issue-41549.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_41549.rs - - -extern crate issue_41549; - -struct S; - -impl issue_41549::Trait for S { - const CONST: () = (); //~ ERROR incompatible type for trait -} - -fn main() {} diff --git a/src/test/compile-fail/issue-43733-2.rs b/src/test/compile-fail/issue-43733-2.rs deleted file mode 100644 index a5ba9ef9bd3..00000000000 --- a/src/test/compile-fail/issue-43733-2.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(const_fn)] -#![feature(cfg_target_thread_local, thread_local_internals)] - -// On platforms *without* `#[thread_local]`, use -// a custom non-`Sync` type to fake the same error. -#[cfg(not(target_thread_local))] -struct Key { - _data: std::cell::UnsafeCell>, - _flag: std::cell::Cell, -} - -#[cfg(not(target_thread_local))] -impl Key { - const fn new() -> Self { - Key { - _data: std::cell::UnsafeCell::new(None), - _flag: std::cell::Cell::new(false), - } - } -} - -#[cfg(target_thread_local)] -use std::thread::__FastLocalKeyInner as Key; - -static __KEY: Key<()> = Key::new(); -//~^ ERROR `std::cell::UnsafeCell>` cannot be shared between threads -//~| ERROR `std::cell::Cell` cannot be shared between threads safely [E0277] - -fn main() {} diff --git a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs b/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs deleted file mode 100644 index f5a20dd96dc..00000000000 --- a/src/test/compile-fail/issue-46209-private-enum-variant-reexport.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(crate_visibility_modifier)] - -mod rank { - pub use self::Professor::*; - //~^ ERROR enum is private and its variants cannot be re-exported - pub use self::Lieutenant::{JuniorGrade, Full}; - //~^ ERROR variant `JuniorGrade` is private and cannot be re-exported - //~| ERROR variant `Full` is private and cannot be re-exported - pub use self::PettyOfficer::*; - //~^ ERROR enum is private and its variants cannot be re-exported - pub use self::Crewman::*; - //~^ ERROR enum is private and its variants cannot be re-exported - - enum Professor { - Adjunct, - Assistant, - Associate, - Full - } - - enum Lieutenant { - JuniorGrade, - Full, - } - - pub(in rank) enum PettyOfficer { - SecondClass, - FirstClass, - Chief, - MasterChief - } - - crate enum Crewman { - Recruit, - Apprentice, - Full - } - -} - -fn main() {} diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs deleted file mode 100644 index 4c67fb3bef1..00000000000 --- a/src/test/compile-fail/issue-50264-inner-deref-trait/option_deref.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(inner_deref)] - -fn main() { - let _result = &Some(42).deref(); -//~^ ERROR no method named `deref` found for type `std::option::Option<{integer}>` -} diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs deleted file mode 100644 index 73bdf0b9209..00000000000 --- a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(inner_deref)] - -fn main() { - let _result = &Ok(42).deref(); -//~^ ERROR no method named `deref` found -} diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs deleted file mode 100644 index 5d1e7472d8f..00000000000 --- a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_err.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(inner_deref)] - -fn main() { - let _result = &Err(41).deref_err(); -//~^ ERROR no method named `deref_err` found -} diff --git a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs b/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs deleted file mode 100644 index bee8e0c062b..00000000000 --- a/src/test/compile-fail/issue-50264-inner-deref-trait/result_deref_ok.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(inner_deref)] - -fn main() { - let _result = &Ok(42).deref_ok(); -//~^ ERROR no method named `deref_ok` found -} diff --git a/src/test/compile-fail/issue-52489.rs b/src/test/compile-fail/issue-52489.rs deleted file mode 100644 index c43cc12ca02..00000000000 --- a/src/test/compile-fail/issue-52489.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 -// aux-build:issue-52489.rs - -use issue_52489; -//~^ ERROR use of unstable library feature 'issue_52489_unstable' - -fn main() {} diff --git a/src/test/compile-fail/issue-5500-1.rs b/src/test/compile-fail/issue-5500-1.rs deleted file mode 100644 index 4bd147a5e1c..00000000000 --- a/src/test/compile-fail/issue-5500-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=compare - -struct TrieMapIterator<'a> { - node: &'a usize -} - -fn main() { - let a = 5; - let _iter = TrieMapIterator{node: &a}; - _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding - //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) - // MIR doesn't generate an error because the code isn't reachable. This is OK - // because the test is here to check that the compiler doesn't ICE (cf. #5500). - panic!() -} diff --git a/src/test/compile-fail/issue-5844.rs b/src/test/compile-fail/issue-5844.rs deleted file mode 100644 index 02e5b9b0921..00000000000 --- a/src/test/compile-fail/issue-5844.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//aux-build:issue_5844_aux.rs - -extern crate issue_5844_aux; - -fn main () { - issue_5844_aux::rand(); //~ ERROR: requires unsafe -} diff --git a/src/test/compile-fail/issue32829.rs b/src/test/compile-fail/issue32829.rs deleted file mode 100644 index 2b223bac8e6..00000000000 --- a/src/test/compile-fail/issue32829.rs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#![feature(const_fn)] - -const bad : u32 = { - { - 5; - //~^ ERROR statements in constants are unstable - 0 - } -}; - -const bad_two : u32 = { - { - invalid(); - //~^ ERROR statements in constants are unstable - //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants - 0 - } -}; - -const bad_three : u32 = { - { - valid(); - //~^ ERROR statements in constants are unstable - 0 - } -}; - -static bad_four : u32 = { - { - 5; - //~^ ERROR statements in statics are unstable - 0 - } -}; - -static bad_five : u32 = { - { - invalid(); - //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants - //~| ERROR statements in statics are unstable - 0 - } -}; - -static bad_six : u32 = { - { - valid(); - //~^ ERROR statements in statics are unstable - 0 - } -}; - -static mut bad_seven : u32 = { - { - 5; - //~^ ERROR statements in statics are unstable - 0 - } -}; - -static mut bad_eight : u32 = { - { - invalid(); - //~^ ERROR statements in statics are unstable - //~| ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants - 0 - } -}; - -static mut bad_nine : u32 = { - { - valid(); - //~^ ERROR statements in statics are unstable - 0 - } -}; - - -fn invalid() {} -const fn valid() {} - -fn main() {} diff --git a/src/test/compile-fail/keyword-extern-as-identifier.rs b/src/test/compile-fail/keyword-extern-as-identifier.rs deleted file mode 100644 index 3e445853957..00000000000 --- a/src/test/compile-fail/keyword-extern-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(extern_in_paths)] - -fn main() { - let extern = 0; //~ ERROR cannot find unit struct/variant or constant `extern` in this scope -} diff --git a/src/test/compile-fail/keyword-false-as-identifier.rs b/src/test/compile-fail/keyword-false-as-identifier.rs deleted file mode 100644 index f246d6e75df..00000000000 --- a/src/test/compile-fail/keyword-false-as-identifier.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let false = 22; //~ error: mismatched types -} diff --git a/src/test/compile-fail/keyword-self-as-identifier.rs b/src/test/compile-fail/keyword-self-as-identifier.rs deleted file mode 100644 index b50fc68bed6..00000000000 --- a/src/test/compile-fail/keyword-self-as-identifier.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let Self = 22; //~ ERROR cannot find unit struct/variant or constant `Self` in this scope -} diff --git a/src/test/compile-fail/keyword-super-as-identifier.rs b/src/test/compile-fail/keyword-super-as-identifier.rs deleted file mode 100644 index 54dac771f01..00000000000 --- a/src/test/compile-fail/keyword-super-as-identifier.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let super = 22; //~ ERROR failed to resolve. There are too many initial `super`s -} diff --git a/src/test/compile-fail/keyword-super.rs b/src/test/compile-fail/keyword-super.rs deleted file mode 100644 index 02047bd639f..00000000000 --- a/src/test/compile-fail/keyword-super.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let super: isize; //~ ERROR failed to resolve. There are too many initial `super`s -} diff --git a/src/test/compile-fail/keyword-true-as-identifier.rs b/src/test/compile-fail/keyword-true-as-identifier.rs deleted file mode 100644 index b09d09db560..00000000000 --- a/src/test/compile-fail/keyword-true-as-identifier.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let true = 22; //~ error: mismatched types -} diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs deleted file mode 100644 index 747fe2d2046..00000000000 --- a/src/test/compile-fail/kindck-copy.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test which of the builtin types are considered POD. - -use std::rc::Rc; - -fn assert_copy() { } - -trait Dummy { } - -#[derive(Copy, Clone)] -struct MyStruct { - x: isize, - y: isize, -} - -struct MyNoncopyStruct { - x: Box, -} - -fn test<'a,T,U:Copy>(_: &'a isize) { - // lifetime pointers are ok... - assert_copy::<&'static isize>(); - assert_copy::<&'a isize>(); - assert_copy::<&'a str>(); - assert_copy::<&'a [isize]>(); - - // ...unless they are mutable - assert_copy::<&'static mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied - assert_copy::<&'a mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied - - // boxes are not ok - assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied - assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied - assert_copy:: >(); //~ ERROR : std::marker::Copy` is not satisfied - assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied - - // borrowed object types are generally ok - assert_copy::<&'a Dummy>(); - assert_copy::<&'a (Dummy+Send)>(); - assert_copy::<&'static (Dummy+Send)>(); - - // owned object types are not ok - assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied - assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied - - // mutable object types are not ok - assert_copy::<&'a mut (Dummy+Send)>(); //~ ERROR : std::marker::Copy` is not satisfied - - // unsafe ptrs are ok - assert_copy::<*const isize>(); - assert_copy::<*const &'a mut isize>(); - - // regular old ints and such are ok - assert_copy::(); - assert_copy::(); - assert_copy::<()>(); - - // tuples are ok - assert_copy::<(isize,isize)>(); - - // structs of POD are ok - assert_copy::(); - - // structs containing non-POD are not ok - assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied - - // ref counted types are not ok - assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied -} - -pub fn main() { -} diff --git a/src/test/compile-fail/kindck-impl-type-params-2.rs b/src/test/compile-fail/kindck-impl-type-params-2.rs deleted file mode 100644 index 21aefc4f9c1..00000000000 --- a/src/test/compile-fail/kindck-impl-type-params-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -trait Foo { -} - -impl Foo for T { -} - -fn take_param(foo: &T) { } - -fn main() { - let x: Box<_> = box 3; - take_param(&x); - //~^ ERROR `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied -} diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs deleted file mode 100644 index 3a0e66f58e0..00000000000 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #14061: tests the interaction between generic implementation -// parameter bounds and trait objects. - -#![feature(box_syntax)] - -use std::marker; - -struct S(marker::PhantomData); - -trait Gettable { - fn get(&self) -> T { panic!() } -} - -impl Gettable for S {} - -fn f(val: T) { - let t: S = S(marker::PhantomData); - let a = &t as &Gettable; - //~^ ERROR `T` cannot be sent between threads safely - //~| ERROR : std::marker::Copy` is not satisfied -} - -fn g(val: T) { - let t: S = S(marker::PhantomData); - let a: &Gettable = &t; - //~^ ERROR `T` cannot be sent between threads safely - //~| ERROR : std::marker::Copy` is not satisfied -} - -fn foo<'a>() { - let t: S<&'a isize> = S(marker::PhantomData); - let a = &t as &Gettable<&'a isize>; - //~^ ERROR does not fulfill -} - -fn foo2<'a>() { - let t: Box> = box S(marker::PhantomData); - let a = t as Box>; - //~^ ERROR : std::marker::Copy` is not satisfied -} - -fn foo3<'a>() { - struct Foo; // does not impl Copy - - let t: Box> = box S(marker::PhantomData); - let a: Box> = t; - //~^ ERROR : std::marker::Copy` is not satisfied -} - -fn main() { } diff --git a/src/test/compile-fail/kindck-inherited-copy-bound.rs b/src/test/compile-fail/kindck-inherited-copy-bound.rs deleted file mode 100644 index 0731fbaf01c..00000000000 --- a/src/test/compile-fail/kindck-inherited-copy-bound.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that Copy bounds inherited by trait are checked. - -#![feature(box_syntax)] - -use std::any::Any; - -trait Foo : Copy { - fn foo(&self) {} -} - -impl Foo for T { -} - -fn take_param(foo: &T) { } - -fn a() { - let x: Box<_> = box 3; - take_param(&x); //~ ERROR E0277 -} - -fn b() { - let x: Box<_> = box 3; - let y = &x; - let z = &x as &Foo; - //~^ ERROR E0038 - //~| ERROR E0038 -} - -fn main() { } diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs deleted file mode 100644 index 43c212b2af5..00000000000 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::rc::Rc; - -fn foo(_x: Rc) {} - -fn bar(_: F) { } - -fn main() { - let x = Rc::new(3); - bar(move|| foo(x)); - //~^ ERROR `std::rc::Rc` cannot be sent between threads safely -} diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs deleted file mode 100644 index 82b97878549..00000000000 --- a/src/test/compile-fail/kindck-send-object.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test which of the builtin types are considered sendable. The tests -// in this file all test the "kind" violates detected during kindck. -// See all `regions-bounded-by-send.rs` - -fn assert_send() { } -trait Dummy { } -trait Message : Send { } - -// careful with object types, who knows what they close over... - -fn object_ref_with_static_bound_not_ok() { - assert_send::<&'static (Dummy+'static)>(); - //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] -} - -fn box_object_with_no_bound_not_ok<'a>() { - assert_send::>(); - //~^ ERROR `dyn Dummy` cannot be sent between threads safely -} - -fn object_with_send_bound_ok() { - assert_send::<&'static (Dummy+Sync)>(); - assert_send::>(); -} - -fn main() { } diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs deleted file mode 100644 index 853630aa416..00000000000 --- a/src/test/compile-fail/kindck-send-object1.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test which object types are considered sendable. This test -// is broken into two parts because some errors occur in distinct -// phases in the compiler. See kindck-send-object2.rs as well! - -fn assert_send() { } -trait Dummy { } - -// careful with object types, who knows what they close over... -fn test51<'a>() { - assert_send::<&'a Dummy>(); - //~^ ERROR `(dyn Dummy + 'a)` cannot be shared between threads safely [E0277] -} -fn test52<'a>() { - assert_send::<&'a (Dummy+Sync)>(); - //~^ ERROR does not fulfill the required lifetime -} - -// ...unless they are properly bounded -fn test60() { - assert_send::<&'static (Dummy+Sync)>(); -} -fn test61() { - assert_send::>(); -} - -// closure and object types can have lifetime bounds which make -// them not ok -fn test_71<'a>() { - assert_send::>(); - //~^ ERROR `(dyn Dummy + 'a)` cannot be sent between threads safely -} - -fn main() { } diff --git a/src/test/compile-fail/kindck-send-object2.rs b/src/test/compile-fail/kindck-send-object2.rs deleted file mode 100644 index 0265f888e7c..00000000000 --- a/src/test/compile-fail/kindck-send-object2.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Continue kindck-send-object1.rs. - -fn assert_send() { } -trait Dummy { } - -fn test50() { - assert_send::<&'static Dummy>(); - //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] -} - -fn test53() { - assert_send::>(); - //~^ ERROR `dyn Dummy` cannot be sent between threads safely -} - -// ...unless they are properly bounded -fn test60() { - assert_send::<&'static (Dummy+Sync)>(); -} -fn test61() { - assert_send::>(); -} - -fn main() { } diff --git a/src/test/compile-fail/kindck-send-owned.rs b/src/test/compile-fail/kindck-send-owned.rs deleted file mode 100644 index e48460a8753..00000000000 --- a/src/test/compile-fail/kindck-send-owned.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test which of the builtin types are considered sendable. - -fn assert_send() { } - -// owned content are ok -fn test30() { assert_send::>(); } -fn test31() { assert_send::(); } -fn test32() { assert_send:: >(); } - -// but not if they own a bad thing -fn test40() { - assert_send::>(); - //~^ ERROR `*mut u8` cannot be sent between threads safely -} - -fn main() { } diff --git a/src/test/compile-fail/kindck-send-unsafe.rs b/src/test/compile-fail/kindck-send-unsafe.rs deleted file mode 100644 index 99b995b0906..00000000000 --- a/src/test/compile-fail/kindck-send-unsafe.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate core; - -fn assert_send() { } - -fn test71<'a>() { - assert_send::<*mut &'a isize>(); - //~^ ERROR `*mut &'a isize` cannot be sent between threads safely -} - -fn main() { -} diff --git a/src/test/compile-fail/kindck-send-unsafe.rs~rust-lang_master b/src/test/compile-fail/kindck-send-unsafe.rs~rust-lang_master deleted file mode 100644 index a9bbfcfa262..00000000000 --- a/src/test/compile-fail/kindck-send-unsafe.rs~rust-lang_master +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn assert_send() { } - -// unsafe ptrs are ok unless they point at unsendable things -fn test70() { - assert_send::<*mut int>(); -} -fn test71<'a>() { - assert_send::<*mut &'a int>(); //~ ERROR does not fulfill the required lifetime -} - -fn main() { -} diff --git a/src/test/compile-fail/label-static.rs b/src/test/compile-fail/label-static.rs deleted file mode 100644 index a0fb25ea06e..00000000000 --- a/src/test/compile-fail/label-static.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - 'static: loop { //~ ERROR invalid label name `'static` - break 'static //~ ERROR invalid label name `'static` - } -} diff --git a/src/test/compile-fail/label-underscore.rs b/src/test/compile-fail/label-underscore.rs deleted file mode 100644 index 30411bf8789..00000000000 --- a/src/test/compile-fail/label-underscore.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - '_: loop { //~ ERROR invalid label name `'_` - break '_ //~ ERROR invalid label name `'_` - } -} diff --git a/src/test/compile-fail/lang-item-missing.rs b/src/test/compile-fail/lang-item-missing.rs deleted file mode 100644 index ce2fa2548c3..00000000000 --- a/src/test/compile-fail/lang-item-missing.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a missing lang item (in this case `sized`) does not cause an ICE, -// see #17392. - -// error-pattern: requires `sized` lang_item - -#![feature(start, no_core)] -#![no_core] - -#[start] -fn start(argc: isize, argv: *const *const u8) -> isize { - 0 -} diff --git a/src/test/compile-fail/lexical-scopes.rs b/src/test/compile-fail/lexical-scopes.rs deleted file mode 100644 index 39da0d47a95..00000000000 --- a/src/test/compile-fail/lexical-scopes.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct T { i: i32 } -fn f() { - let t = T { i: 0 }; //~ ERROR expected struct, variant or union type, found type parameter `T` -} - -mod Foo { - pub fn f() {} -} -fn g() { - Foo::f(); //~ ERROR no function or associated item named `f` -} - -fn main() {} diff --git a/src/test/compile-fail/lifetime-bound-will-change-warning.rs b/src/test/compile-fail/lifetime-bound-will-change-warning.rs deleted file mode 100644 index 7e9a4f82478..00000000000 --- a/src/test/compile-fail/lifetime-bound-will-change-warning.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lifetime_bound_will_change_warning_lib.rs - -// Test that various corner cases cause an error. These are tests -// that used to pass before we tweaked object defaults. - -#![allow(dead_code)] -#![allow(unused_variables)] -#![feature(rustc_attrs)] - -extern crate lifetime_bound_will_change_warning_lib as lib; - -fn just_ref(x: &Fn()) { -} - -fn ref_obj(x: &Box) { - // this will change to &Box... - - // Note: no warning is issued here, because the type of `x` will change to 'static - if false { ref_obj(x); } -} - -fn test1<'a>(x: &'a Box) { - // just_ref will stay the same. - just_ref(&**x) -} - -fn test1cc<'a>(x: &'a Box) { - // same as test1, but cross-crate - lib::just_ref(&**x) -} - -fn test2<'a>(x: &'a Box) { - // but ref_obj will not, so warn. - ref_obj(x) //~ ERROR mismatched types -} - -fn test2cc<'a>(x: &'a Box) { - // same as test2, but cross crate - lib::ref_obj(x) //~ ERROR mismatched types -} - -fn test3<'a>(x: &'a Box) { - // here, we have a 'static bound, so even when ref_obj changes, no error results - ref_obj(x) -} - -fn test3cc<'a>(x: &'a Box) { - // same as test3, but cross crate - lib::ref_obj(x) -} - -#[rustc_error] -fn main() { -} diff --git a/src/test/compile-fail/lifetime-no-keyword.rs b/src/test/compile-fail/lifetime-no-keyword.rs deleted file mode 100644 index d583c4fc6c6..00000000000 --- a/src/test/compile-fail/lifetime-no-keyword.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo<'a>(a: &'a isize) { } -fn bar(a: &'static isize) { } -fn baz<'let>(a: &'let isize) { } //~ ERROR lifetimes cannot use keyword names -//~^ ERROR lifetimes cannot use keyword names -fn zab<'self>(a: &'self isize) { } //~ ERROR lifetimes cannot use keyword names -//~^ ERROR lifetimes cannot use keyword names -fn main() { } diff --git a/src/test/compile-fail/linkage2.rs b/src/test/compile-fail/linkage2.rs deleted file mode 100644 index afae4a451d6..00000000000 --- a/src/test/compile-fail/linkage2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(linkage)] - -extern { - #[linkage = "extern_weak"] static foo: i32; - //~^ ERROR: must have type `*const T` or `*mut T` -} - -fn main() { - println!("{}", unsafe { foo }); -} diff --git a/src/test/compile-fail/linkage3.rs b/src/test/compile-fail/linkage3.rs deleted file mode 100644 index c222989ed66..00000000000 --- a/src/test/compile-fail/linkage3.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(linkage)] - -extern { - #[linkage = "foo"] static foo: *const i32; - //~^ ERROR: invalid linkage specified -} - -fn main() { - println!("{:?}", unsafe { foo }); -} diff --git a/src/test/compile-fail/linkage4.rs b/src/test/compile-fail/linkage4.rs deleted file mode 100644 index 1cf6e90d6c8..00000000000 --- a/src/test/compile-fail/linkage4.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[linkage = "external"] -static foo: isize = 0; -//~^^ ERROR: the `linkage` attribute is experimental and not portable - -fn main() {} diff --git a/src/test/compile-fail/lint-attr-non-item-node.rs b/src/test/compile-fail/lint-attr-non-item-node.rs deleted file mode 100644 index 930f69e51e1..00000000000 --- a/src/test/compile-fail/lint-attr-non-item-node.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks that lint attributes work on non-item AST nodes - -fn main() { - #[deny(unreachable_code)] - loop { - break; - "unreachable"; //~ ERROR unreachable statement - } -} diff --git a/src/test/compile-fail/lint-change-warnings.rs b/src/test/compile-fail/lint-change-warnings.rs deleted file mode 100644 index 19e253e3b8e..00000000000 --- a/src/test/compile-fail/lint-change-warnings.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(warnings)] -#![allow(dead_code)] - -fn main() { - while true {} //~ ERROR: infinite -} - -#[allow(warnings)] -fn foo() { - while true {} -} - -#[warn(warnings)] -fn bar() { - while true {} //~ WARNING: infinite -} - -#[forbid(warnings)] -fn baz() { - while true {} //~ ERROR: infinite -} diff --git a/src/test/compile-fail/lint-ctypes-enum.rs b/src/test/compile-fail/lint-ctypes-enum.rs deleted file mode 100644 index 7b7ffd8fc10..00000000000 --- a/src/test/compile-fail/lint-ctypes-enum.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(improper_ctypes)] -#![allow(dead_code)] - -enum Z { } -enum U { A } -enum B { C, D } -enum T { E, F, G } - -#[repr(C)] -enum ReprC { A, B, C } - -#[repr(u8)] -enum U8 { A, B, C } - -#[repr(isize)] -enum Isize { A, B, C } - -extern { - fn zf(x: Z); - fn uf(x: U); //~ ERROR enum has no representation hint - fn bf(x: B); //~ ERROR enum has no representation hint - fn tf(x: T); //~ ERROR enum has no representation hint - fn reprc(x: ReprC); - fn u8(x: U8); - fn isize(x: Isize); -} - -pub fn main() { } diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs deleted file mode 100644 index 2fe72365bab..00000000000 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] -#![allow(unused_variables)] -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] -#![deny(dead_code)] - -#![crate_type="lib"] - -pub use foo2::Bar2; - -mod foo { - pub struct Bar; //~ ERROR: struct is never constructed -} - -mod foo2 { - pub struct Bar2; -} - -pub static pub_static: isize = 0; -static priv_static: isize = 0; //~ ERROR: static item is never used -const used_static: isize = 0; -pub static used_static2: isize = used_static; -const USED_STATIC: isize = 0; -const STATIC_USED_IN_ENUM_DISCRIMINANT: isize = 10; - -pub const pub_const: isize = 0; -const priv_const: isize = 0; //~ ERROR: constant item is never used -const used_const: isize = 0; -pub const used_const2: isize = used_const; -const USED_CONST: isize = 1; -const CONST_USED_IN_ENUM_DISCRIMINANT: isize = 11; - -pub type typ = *const UsedStruct4; -pub struct PubStruct; -struct PrivStruct; //~ ERROR: struct is never constructed -struct UsedStruct1 { - #[allow(dead_code)] - x: isize -} -struct UsedStruct2(isize); -struct UsedStruct3; -pub struct UsedStruct4; -// this struct is never used directly, but its method is, so we don't want -// to warn it -struct SemiUsedStruct; -impl SemiUsedStruct { - fn la_la_la() {} -} -struct StructUsedAsField; -pub struct StructUsedInEnum; -struct StructUsedInGeneric; -pub struct PubStruct2 { - #[allow(dead_code)] - struct_used_as_field: *const StructUsedAsField -} - -pub enum pub_enum { foo1, bar1 } -pub enum pub_enum2 { a(*const StructUsedInEnum) } -pub enum pub_enum3 { - Foo = STATIC_USED_IN_ENUM_DISCRIMINANT, - Bar = CONST_USED_IN_ENUM_DISCRIMINANT, -} - -enum priv_enum { foo2, bar2 } //~ ERROR: enum is never used -enum used_enum { - foo3, - bar3 //~ ERROR variant is never constructed -} - -fn f() {} - -pub fn pub_fn() { - used_fn(); - let used_struct1 = UsedStruct1 { x: 1 }; - let used_struct2 = UsedStruct2(1); - let used_struct3 = UsedStruct3; - let e = used_enum::foo3; - SemiUsedStruct::la_la_la(); - - let i = 1; - match i { - USED_STATIC => (), - USED_CONST => (), - _ => () - } - f::(); -} -fn priv_fn() { //~ ERROR: function is never used - let unused_struct = PrivStruct; -} -fn used_fn() {} - -fn foo() { //~ ERROR: function is never used - bar(); - let unused_enum = priv_enum::foo2; -} - -fn bar() { //~ ERROR: function is never used - foo(); -} - -// Code with #[allow(dead_code)] should be marked live (and thus anything it -// calls is marked live) -#[allow(dead_code)] -fn g() { h(); } -fn h() {} diff --git a/src/test/compile-fail/lint-dead-code-2.rs b/src/test/compile-fail/lint-dead-code-2.rs deleted file mode 100644 index 4a0e4f4319e..00000000000 --- a/src/test/compile-fail/lint-dead-code-2.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] -#![deny(dead_code)] -#![feature(main, start)] - -struct Foo; - -trait Bar { - fn bar1(&self); - fn bar2(&self) { - self.bar1(); - } -} - -impl Bar for Foo { - fn bar1(&self) { - live_fn(); - } -} - -fn live_fn() {} - -fn dead_fn() {} //~ ERROR: function is never used - -#[main] -fn dead_fn2() {} //~ ERROR: function is never used - -fn used_fn() {} - -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - used_fn(); - let foo = Foo; - foo.bar2(); - 0 -} - -// this is not main -fn main() { //~ ERROR: function is never used - dead_fn(); - dead_fn2(); -} diff --git a/src/test/compile-fail/lint-dead-code-3.rs b/src/test/compile-fail/lint-dead-code-3.rs deleted file mode 100644 index 112d3630952..00000000000 --- a/src/test/compile-fail/lint-dead-code-3.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] -#![allow(non_camel_case_types)] -#![deny(dead_code)] - -#![crate_type="lib"] - - -pub use extern_foo as x; -extern { - pub fn extern_foo(); -} - -struct Foo; //~ ERROR: struct is never constructed -impl Foo { - fn foo(&self) { //~ ERROR: method is never used - bar() - } -} - -fn bar() { //~ ERROR: function is never used - fn baz() {} - - Foo.foo(); - baz(); -} - -// no warning -struct Foo2; -impl Foo2 { fn foo2(&self) { bar2() } } -fn bar2() { - fn baz2() {} - - Foo2.foo2(); - baz2(); -} - -pub fn pub_fn() { - let foo2_struct = Foo2; - foo2_struct.foo2(); - - blah::baz(); -} - -mod blah { - // not warned because it's used in the parameter of `free` and return of - // `malloc` below, which are also used. - enum c_void {} - - extern { - fn free(p: *const c_void); - fn malloc(size: usize) -> *const c_void; - } - - pub fn baz() { - unsafe { free(malloc(4)); } - } -} - -enum c_void {} //~ ERROR: enum is never used -extern { - fn free(p: *const c_void); //~ ERROR: foreign function is never used -} - -// Check provided method -mod inner { - pub trait Trait { - fn f(&self) { f(); } - } - - impl Trait for isize {} - - fn f() {} -} - -pub fn foo() { - let a: &inner::Trait = &1_isize; - a.f(); -} diff --git a/src/test/compile-fail/lint-dead-code-4.rs b/src/test/compile-fail/lint-dead-code-4.rs deleted file mode 100644 index 1296cf46e6f..00000000000 --- a/src/test/compile-fail/lint-dead-code-4.rs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] -#![allow(non_camel_case_types)] -#![deny(dead_code)] - -struct Foo { - x: usize, - b: bool, //~ ERROR: field is never used -} - -fn field_read(f: Foo) -> usize { - f.x.pow(2) -} - -enum XYZ { - X, //~ ERROR variant is never constructed - Y { //~ ERROR variant is never constructed - a: String, - b: i32, - c: i32, - }, - Z -} - -enum ABC { //~ ERROR enum is never used - A, - B { - a: String, - b: i32, - c: i32, - }, - C -} - -// ensure struct variants get warning for their fields -enum IJK { - I, //~ ERROR variant is never constructed - J { - a: String, - b: i32, //~ ERROR field is never used - c: i32, //~ ERROR field is never used - }, - K //~ ERROR variant is never constructed - -} - -fn struct_variant_partial_use(b: IJK) -> String { - match b { - IJK::J { a, b: _, .. } => a, - _ => "".to_string() - } -} - -fn field_match_in_patterns(b: XYZ) -> String { - match b { - XYZ::Y { a, b: _, .. } => a, - _ => "".to_string() - } -} - -struct Bar { - x: usize, //~ ERROR: field is never used - b: bool, - c: bool, //~ ERROR: field is never used - _guard: () -} - -#[repr(C)] -struct Baz { - x: u32, -} - -fn field_match_in_let(f: Bar) -> bool { - let Bar { b, c: _, .. } = f; - b -} - -fn main() { - field_read(Foo { x: 1, b: false }); - field_match_in_patterns(XYZ::Z); - struct_variant_partial_use(IJK::J { a: "".into(), b: 1, c: -1 }); - field_match_in_let(Bar { x: 42, b: true, c: false, _guard: () }); - let _ = Baz { x: 0 }; -} diff --git a/src/test/compile-fail/lint-dead-code-5.rs b/src/test/compile-fail/lint-dead-code-5.rs deleted file mode 100644 index ee5cf24823d..00000000000 --- a/src/test/compile-fail/lint-dead-code-5.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] -#![deny(dead_code)] - -enum Enum1 { - Variant1(isize), - Variant2 //~ ERROR: variant is never constructed -} - -enum Enum2 { - Variant3(bool), - #[allow(dead_code)] - Variant4(isize), - Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5` - Variant6(isize), //~ ERROR: variant is never constructed: `Variant6` - _Variant7, -} - -enum Enum3 { //~ ERROR: enum is never used - Variant8, - Variant9 -} - -fn main() { - let v = Enum1::Variant1(1); - match v { - Enum1::Variant1(_) => (), - Enum1::Variant2 => () - } - let x = Enum2::Variant3(true); -} diff --git a/src/test/compile-fail/lint-dead-code-type-alias.rs b/src/test/compile-fail/lint-dead-code-type-alias.rs deleted file mode 100644 index aaa01aa6bbe..00000000000 --- a/src/test/compile-fail/lint-dead-code-type-alias.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(dead_code)] - -type Used = u8; -type Unused = u8; //~ ERROR type alias is never used - -fn id(x: Used) -> Used { x } - -fn main() { - id(0); -} diff --git a/src/test/compile-fail/lint-dead-code-variant.rs b/src/test/compile-fail/lint-dead-code-variant.rs deleted file mode 100644 index 3301560c315..00000000000 --- a/src/test/compile-fail/lint-dead-code-variant.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(dead_code)] - -#[derive(Clone)] -enum Enum { - Variant1, //~ ERROR: variant is never constructed - Variant2, -} - -fn main() { - let e = Enum::Variant2; - e.clone(); -} diff --git a/src/test/compile-fail/lint-directives-on-use-items-issue-10534.rs b/src/test/compile-fail/lint-directives-on-use-items-issue-10534.rs deleted file mode 100644 index 18159aec708..00000000000 --- a/src/test/compile-fail/lint-directives-on-use-items-issue-10534.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_imports)] -#![allow(non_upper_case_globals)] - -// The aim of this test is to ensure that deny/allow/warn directives -// are applied to individual "use" statements instead of silently -// ignored. - -#[allow(dead_code)] -mod a { pub static x: isize = 3; pub static y: isize = 4; } - -mod b { - use a::x; //~ ERROR: unused import - #[allow(unused_imports)] - use a::y; // no error here -} - -#[allow(unused_imports)] -mod c { - use a::x; - #[deny(unused_imports)] - use a::y; //~ ERROR: unused import -} - -fn main() {} diff --git a/src/test/compile-fail/lint-exceeding-bitshifts.rs b/src/test/compile-fail/lint-exceeding-bitshifts.rs deleted file mode 100644 index 5ebfcc4926b..00000000000 --- a/src/test/compile-fail/lint-exceeding-bitshifts.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(exceeding_bitshifts, const_err)] -#![allow(unused_variables)] -#![allow(dead_code)] - -fn main() { - let n = 1u8 << 7; - let n = 1u8 << 8; //~ ERROR: attempt to shift left with overflow - let n = 1u16 << 15; - let n = 1u16 << 16; //~ ERROR: attempt to shift left with overflow - let n = 1u32 << 31; - let n = 1u32 << 32; //~ ERROR: attempt to shift left with overflow - let n = 1u64 << 63; - let n = 1u64 << 64; //~ ERROR: attempt to shift left with overflow - let n = 1i8 << 7; - let n = 1i8 << 8; //~ ERROR: attempt to shift left with overflow - let n = 1i16 << 15; - let n = 1i16 << 16; //~ ERROR: attempt to shift left with overflow - let n = 1i32 << 31; - let n = 1i32 << 32; //~ ERROR: attempt to shift left with overflow - let n = 1i64 << 63; - let n = 1i64 << 64; //~ ERROR: attempt to shift left with overflow - - let n = 1u8 >> 7; - let n = 1u8 >> 8; //~ ERROR: attempt to shift right with overflow - let n = 1u16 >> 15; - let n = 1u16 >> 16; //~ ERROR: attempt to shift right with overflow - let n = 1u32 >> 31; - let n = 1u32 >> 32; //~ ERROR: attempt to shift right with overflow - let n = 1u64 >> 63; - let n = 1u64 >> 64; //~ ERROR: attempt to shift right with overflow - let n = 1i8 >> 7; - let n = 1i8 >> 8; //~ ERROR: attempt to shift right with overflow - let n = 1i16 >> 15; - let n = 1i16 >> 16; //~ ERROR: attempt to shift right with overflow - let n = 1i32 >> 31; - let n = 1i32 >> 32; //~ ERROR: attempt to shift right with overflow - let n = 1i64 >> 63; - let n = 1i64 >> 64; //~ ERROR: attempt to shift right with overflow - - let n = 1u8; - let n = n << 7; - let n = n << 8; //~ ERROR: attempt to shift left with overflow - - let n = 1u8 << -8; //~ ERROR: attempt to shift left with overflow - - let n = 1i8<<(1isize+-1); -} diff --git a/src/test/compile-fail/lint-exceeding-bitshifts2.rs b/src/test/compile-fail/lint-exceeding-bitshifts2.rs deleted file mode 100644 index 3ba300eb7c4..00000000000 --- a/src/test/compile-fail/lint-exceeding-bitshifts2.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(exceeding_bitshifts, const_err)] -#![allow(unused_variables)] -#![allow(dead_code)] - -fn main() { - let n = 1u8 << (4+3); - let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow - let n = 1i64 >> [63][0]; - let n = 1i64 >> [64][0]; // should be linting, needs to wait for const propagation - - #[cfg(target_pointer_width = "32")] - const BITS: usize = 32; - #[cfg(target_pointer_width = "64")] - const BITS: usize = 64; - let n = 1_isize << BITS; //~ ERROR: attempt to shift left with overflow - let n = 1_usize << BITS; //~ ERROR: attempt to shift left with overflow -} diff --git a/src/test/compile-fail/lint-forbid-cmdline.rs b/src/test/compile-fail/lint-forbid-cmdline.rs deleted file mode 100644 index 6a4d17b33de..00000000000 --- a/src/test/compile-fail/lint-forbid-cmdline.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -F deprecated - -#[allow(deprecated)] //~ ERROR allow(deprecated) overruled by outer forbid(deprecated) -fn main() { -} diff --git a/src/test/compile-fail/lint-impl-fn.rs b/src/test/compile-fail/lint-impl-fn.rs deleted file mode 100644 index 54a720d75b5..00000000000 --- a/src/test/compile-fail/lint-impl-fn.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(while_true)] -#![allow(dead_code)] - -struct A(isize); - -impl A { - fn foo(&self) { while true {} } - - #[deny(while_true)] - fn bar(&self) { while true {} } //~ ERROR: infinite loops -} - -#[deny(while_true)] -mod foo { - struct B(isize); - - impl B { - fn foo(&self) { while true {} } //~ ERROR: infinite loops - - #[allow(while_true)] - fn bar(&self) { while true {} } - } -} - -#[deny(while_true)] -fn main() { - while true {} //~ ERROR: infinite loops -} - -#[deny(while_true)] -fn bar() { - while cfg!(unix) {} // no error -} diff --git a/src/test/compile-fail/lint-malformed.rs b/src/test/compile-fail/lint-malformed.rs deleted file mode 100644 index ad5e3aa3f06..00000000000 --- a/src/test/compile-fail/lint-malformed.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny = "foo"] //~ ERROR malformed lint attribute -#![allow(bar = "baz")] //~ ERROR malformed lint attribute - -fn main() { } diff --git a/src/test/compile-fail/lint-misplaced-attr.rs b/src/test/compile-fail/lint-misplaced-attr.rs deleted file mode 100644 index 18ea5a383f6..00000000000 --- a/src/test/compile-fail/lint-misplaced-attr.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// When denying at the crate level, be sure to not get random warnings from the -// injected intrinsics by the compiler. - -#![deny(unused_attributes)] - -mod a { - #![crate_type = "bin"] //~ ERROR unused attribute - //~^ ERROR should be in the root module -} - -#[crate_type = "bin"] fn main() {} //~ ERROR unused attribute - //~^ ERROR should be an inner diff --git a/src/test/compile-fail/lint-missing-copy-implementations.rs b/src/test/compile-fail/lint-missing-copy-implementations.rs deleted file mode 100644 index 94a11aac067..00000000000 --- a/src/test/compile-fail/lint-missing-copy-implementations.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// See issue 19712 - -#![deny(missing_copy_implementations)] - -mod inner { - pub struct Foo { //~ ERROR type could implement `Copy`; consider adding `impl Copy` - pub field: i32 - } -} - -pub fn foo() -> inner::Foo { - inner::Foo { field: 42 } -} - -fn main() {} diff --git a/src/test/compile-fail/lint-missing-doc.rs b/src/test/compile-fail/lint-missing-doc.rs deleted file mode 100644 index 4add67f61e0..00000000000 --- a/src/test/compile-fail/lint-missing-doc.rs +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// When denying at the crate level, be sure to not get random warnings from the -// injected intrinsics by the compiler. -#![deny(missing_docs)] -#![allow(dead_code)] -#![feature(associated_type_defaults)] - -//! Some garbage docs for the crate here -#![doc="More garbage"] - -type Typedef = String; -pub type PubTypedef = String; //~ ERROR: missing documentation for a type alias - -struct Foo { - a: isize, - b: isize, -} - -pub struct PubFoo { //~ ERROR: missing documentation for a struct - pub a: isize, //~ ERROR: missing documentation for a struct field - b: isize, -} - -#[allow(missing_docs)] -pub struct PubFoo2 { - pub a: isize, - pub c: isize, -} - -mod module_no_dox {} -pub mod pub_module_no_dox {} //~ ERROR: missing documentation for a module - -/// dox -pub fn foo() {} -pub fn foo2() {} //~ ERROR: missing documentation for a function -fn foo3() {} -#[allow(missing_docs)] pub fn foo4() {} - -/// dox -pub trait A { - /// dox - fn foo(&self); - /// dox - fn foo_with_impl(&self) {} -} - -#[allow(missing_docs)] -trait B { - fn foo(&self); - fn foo_with_impl(&self) {} -} - -pub trait C { //~ ERROR: missing documentation for a trait - fn foo(&self); //~ ERROR: missing documentation for a trait method - fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method -} - -#[allow(missing_docs)] -pub trait D { - fn dummy(&self) { } -} - -/// dox -pub trait E { - type AssociatedType; //~ ERROR: missing documentation for an associated type - type AssociatedTypeDef = Self; //~ ERROR: missing documentation for an associated type - - /// dox - type DocumentedType; - /// dox - type DocumentedTypeDef = Self; - /// dox - fn dummy(&self) {} -} - -impl Foo { - pub fn foo() {} - fn bar() {} -} - -impl PubFoo { - pub fn foo() {} //~ ERROR: missing documentation for a method - /// dox - pub fn foo1() {} - fn foo2() {} - #[allow(missing_docs)] pub fn foo3() {} -} - -#[allow(missing_docs)] -trait F { - fn a(); - fn b(&self); -} - -// should need to redefine documentation for implementations of traits -impl F for Foo { - fn a() {} - fn b(&self) {} -} - -// It sure is nice if doc(hidden) implies allow(missing_docs), and that it -// applies recursively -#[doc(hidden)] -mod a { - pub fn baz() {} - pub mod b { - pub fn baz() {} - } -} - -enum Baz { - BazA { - a: isize, - b: isize - }, - BarB -} - -pub enum PubBaz { //~ ERROR: missing documentation for an enum - PubBazA { //~ ERROR: missing documentation for a variant - a: isize, //~ ERROR: missing documentation for a struct field - }, -} - -/// dox -pub enum PubBaz2 { - /// dox - PubBaz2A { - /// dox - a: isize, - }, -} - -#[allow(missing_docs)] -pub enum PubBaz3 { - PubBaz3A { - b: isize - }, -} - -#[doc(hidden)] -pub fn baz() {} - - -const FOO: u32 = 0; -/// dox -pub const FOO1: u32 = 0; -#[allow(missing_docs)] -pub const FOO2: u32 = 0; -#[doc(hidden)] -pub const FOO3: u32 = 0; -pub const FOO4: u32 = 0; //~ ERROR: missing documentation for a const - - -static BAR: u32 = 0; -/// dox -pub static BAR1: u32 = 0; -#[allow(missing_docs)] -pub static BAR2: u32 = 0; -#[doc(hidden)] -pub static BAR3: u32 = 0; -pub static BAR4: u32 = 0; //~ ERROR: missing documentation for a static - - -mod internal_impl { - /// dox - pub fn documented() {} - pub fn undocumented1() {} //~ ERROR: missing documentation for a function - pub fn undocumented2() {} //~ ERROR: missing documentation for a function - fn undocumented3() {} - /// dox - pub mod globbed { - /// dox - pub fn also_documented() {} - pub fn also_undocumented1() {} //~ ERROR: missing documentation for a function - fn also_undocumented2() {} - } -} -/// dox -pub mod public_interface { - pub use internal_impl::documented as foo; - pub use internal_impl::undocumented1 as bar; - pub use internal_impl::{documented, undocumented2}; - pub use internal_impl::globbed::*; -} - -fn main() {} diff --git a/src/test/compile-fail/lint-non-camel-case-types.rs b/src/test/compile-fail/lint-non-camel-case-types.rs deleted file mode 100644 index 5dcdf3a863f..00000000000 --- a/src/test/compile-fail/lint-non-camel-case-types.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![forbid(non_camel_case_types)] -#![allow(dead_code)] - -struct ONE_TWO_THREE; -//~^ ERROR type `ONE_TWO_THREE` should have a camel case name such as `OneTwoThree` - -struct foo { //~ ERROR type `foo` should have a camel case name such as `Foo` - bar: isize, -} - -enum foo2 { //~ ERROR type `foo2` should have a camel case name such as `Foo2` - Bar -} - -struct foo3 { //~ ERROR type `foo3` should have a camel case name such as `Foo3` - bar: isize -} - -type foo4 = isize; //~ ERROR type `foo4` should have a camel case name such as `Foo4` - -enum Foo5 { - bar //~ ERROR variant `bar` should have a camel case name such as `Bar` -} - -trait foo6 { //~ ERROR trait `foo6` should have a camel case name such as `Foo6` - fn dummy(&self) { } -} - -fn f(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty` - -#[repr(C)] -struct foo7 { - bar: isize, -} - -type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase` - -struct X86_64; - -struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` - -struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123` - -struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3` - -fn main() { } diff --git a/src/test/compile-fail/lint-non-snake-case-crate-2.rs b/src/test/compile-fail/lint-non-snake-case-crate-2.rs deleted file mode 100644 index fe22c21df24..00000000000 --- a/src/test/compile-fail/lint-non-snake-case-crate-2.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --crate-name NonSnakeCase -// error-pattern: crate `NonSnakeCase` should have a snake case name such as `non_snake_case` - -#![deny(non_snake_case)] - -fn main() {} diff --git a/src/test/compile-fail/lint-non-snake-case-crate.rs b/src/test/compile-fail/lint-non-snake-case-crate.rs deleted file mode 100644 index 9ca0a34e6ff..00000000000 --- a/src/test/compile-fail/lint-non-snake-case-crate.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "NonSnakeCase"] -//~^ ERROR crate `NonSnakeCase` should have a snake case name such as `non_snake_case` -#![deny(non_snake_case)] - -fn main() {} diff --git a/src/test/compile-fail/lint-non-snake-case-functions.rs b/src/test/compile-fail/lint-non-snake-case-functions.rs deleted file mode 100644 index 6cfdc6ad90b..00000000000 --- a/src/test/compile-fail/lint-non-snake-case-functions.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(non_snake_case)] -#![allow(dead_code)] - -struct Foo; - -impl Foo { - fn Foo_Method() {} - //~^ ERROR method `Foo_Method` should have a snake case name such as `foo_method` - - // Don't allow two underscores in a row - fn foo__method(&self) {} - //~^ ERROR method `foo__method` should have a snake case name such as `foo_method` - - pub fn xyZ(&mut self) {} - //~^ ERROR method `xyZ` should have a snake case name such as `xy_z` - - fn render_HTML() {} - //~^ ERROR method `render_HTML` should have a snake case name such as `render_html` -} - -trait X { - fn ABC(); - //~^ ERROR trait method `ABC` should have a snake case name such as `abc` - - fn a_b_C(&self) {} - //~^ ERROR trait method `a_b_C` should have a snake case name such as `a_b_c` - - fn something__else(&mut self); - //~^ ERROR trait method `something__else` should have a snake case name such as `something_else` -} - -impl X for Foo { - // These errors should be caught at the trait definition not the impl - fn ABC() {} - fn something__else(&mut self) {} -} - -fn Cookie() {} -//~^ ERROR function `Cookie` should have a snake case name such as `cookie` - -pub fn bi_S_Cuit() {} -//~^ ERROR function `bi_S_Cuit` should have a snake case name such as `bi_s_cuit` - -fn main() { } diff --git a/src/test/compile-fail/lint-non-snake-case-lifetimes.rs b/src/test/compile-fail/lint-non-snake-case-lifetimes.rs deleted file mode 100644 index 64669d90d06..00000000000 --- a/src/test/compile-fail/lint-non-snake-case-lifetimes.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(non_snake_case)] -#![allow(dead_code)] - -fn f<'FooBar>( //~ ERROR lifetime `'FooBar` should have a snake case name such as `'foo_bar` - _: &'FooBar () -) {} - -fn main() { } diff --git a/src/test/compile-fail/lint-non-snake-case-modules.rs b/src/test/compile-fail/lint-non-snake-case-modules.rs deleted file mode 100644 index 5bc84698ec9..00000000000 --- a/src/test/compile-fail/lint-non-snake-case-modules.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(non_snake_case)] -#![allow(dead_code)] - -mod FooBar { //~ ERROR module `FooBar` should have a snake case name such as `foo_bar` - pub struct S; -} - -fn f(_: FooBar::S) { } - -fn main() { } diff --git a/src/test/compile-fail/lint-non-uppercase-statics.rs b/src/test/compile-fail/lint-non-uppercase-statics.rs deleted file mode 100644 index 84cc24a0010..00000000000 --- a/src/test/compile-fail/lint-non-uppercase-statics.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![forbid(non_upper_case_globals)] -#![allow(dead_code)] - -static foo: isize = 1; //~ ERROR static variable `foo` should have an upper case name such as `FOO` - -static mut bar: isize = 1; - //~^ ERROR static variable `bar` should have an upper case name such as `BAR` - -#[no_mangle] -pub static extern_foo: isize = 1; // OK, because #[no_mangle] supersedes the warning - -fn main() { } diff --git a/src/test/compile-fail/lint-obsolete-attr.rs b/src/test/compile-fail/lint-obsolete-attr.rs deleted file mode 100644 index b234f08d04a..00000000000 --- a/src/test/compile-fail/lint-obsolete-attr.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// When denying at the crate level, be sure to not get random warnings from the -// injected intrinsics by the compiler. - -#![deny(unused_attributes)] -#![allow(dead_code)] -#![feature(custom_attribute)] - -#[ab_isize="stdcall"] extern {} //~ ERROR unused attribute - -#[fixed_stack_segment] fn f() {} //~ ERROR unused attribute - -fn main() {} diff --git a/src/test/compile-fail/lint-output-format.rs b/src/test/compile-fail/lint-output-format.rs deleted file mode 100644 index 81e0b708b87..00000000000 --- a/src/test/compile-fail/lint-output-format.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -F unused_features -// aux-build:lint_output_format.rs - -#![allow(deprecated)] - -extern crate lint_output_format; //~ ERROR use of unstable library feature -use lint_output_format::{foo, bar}; //~ ERROR use of unstable library feature - -fn main() { - let _x = foo(); - let _y = bar(); //~ ERROR use of unstable library feature -} diff --git a/src/test/compile-fail/lint-owned-heap-memory.rs b/src/test/compile-fail/lint-owned-heap-memory.rs deleted file mode 100644 index 9c68da8beaf..00000000000 --- a/src/test/compile-fail/lint-owned-heap-memory.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![forbid(box_pointers)] -#![feature(box_syntax)] - -struct Foo { - x: Box //~ ERROR type uses owned -} - -fn main() { - let _x : Foo = Foo {x : box 10}; - //~^ ERROR type uses owned -} diff --git a/src/test/compile-fail/lint-qualification.rs b/src/test/compile-fail/lint-qualification.rs deleted file mode 100644 index 57c2166565f..00000000000 --- a/src/test/compile-fail/lint-qualification.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_qualifications)] - -mod foo { - pub fn bar() {} -} - -fn main() { - use foo::bar; - foo::bar(); //~ ERROR: unnecessary qualification - bar(); - - let _ = || -> Result<(), ()> { try!(Ok(())); Ok(()) }; // issue #37345 - - macro_rules! m { () => { - $crate::foo::bar(); // issue #37357 - ::foo::bar(); // issue #38682 - } } - m!(); -} diff --git a/src/test/compile-fail/lint-removed-allow.rs b/src/test/compile-fail/lint-removed-allow.rs deleted file mode 100644 index 9f84190ea18..00000000000 --- a/src/test/compile-fail/lint-removed-allow.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// No warnings about removed lint when -// allow(renamed_and_removed_lints) - -#![allow(renamed_and_removed_lints)] - -#[deny(raw_pointer_derive)] -#[deny(unused_variables)] -fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/compile-fail/lint-removed-cmdline.rs b/src/test/compile-fail/lint-removed-cmdline.rs deleted file mode 100644 index 09725b20146..00000000000 --- a/src/test/compile-fail/lint-removed-cmdline.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The raw_pointer_derived lint warns about its removal -// cc #30346 - -// compile-flags:-D raw_pointer_derive - -// error-pattern:lint `raw_pointer_derive` has been removed -// error-pattern:requested on the command line with `-D raw_pointer_derive` - -#![warn(unused)] - -#[deny(warnings)] -fn main() { let unused = (); } diff --git a/src/test/compile-fail/lint-removed.rs b/src/test/compile-fail/lint-removed.rs deleted file mode 100644 index 4e53852008f..00000000000 --- a/src/test/compile-fail/lint-removed.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The raw_pointer_derived lint was removed, but is now reported by -// the renamed_and_removed_lints lint, which means it's a warning by -// default, and allowed in cargo dependency builds. -// cc #30346 - -#[deny(raw_pointer_derive)] //~ WARN `raw_pointer_derive` has been removed -#[deny(unused_variables)] -fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/compile-fail/lint-renamed-allow.rs b/src/test/compile-fail/lint-renamed-allow.rs deleted file mode 100644 index f6b94e89826..00000000000 --- a/src/test/compile-fail/lint-renamed-allow.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// No warnings about renamed lint when -// allow(renamed_and_removed_lints) - -#![allow(renamed_and_removed_lints)] - -#[deny(single_use_lifetime)] -#[deny(unused)] -fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/compile-fail/lint-renamed-cmdline.rs b/src/test/compile-fail/lint-renamed-cmdline.rs deleted file mode 100644 index f5abf2733b9..00000000000 --- a/src/test/compile-fail/lint-renamed-cmdline.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-D bare_trait_object - -// error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects` -// error-pattern:requested on the command line with `-D bare_trait_object` -// error-pattern:unused - -#[deny(unused)] -fn main() { let unused = (); } diff --git a/src/test/compile-fail/lint-renamed.rs b/src/test/compile-fail/lint-renamed.rs deleted file mode 100644 index c147ec5cf95..00000000000 --- a/src/test/compile-fail/lint-renamed.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[deny(bare_trait_object)] -//~^ WARN lint `bare_trait_object` has been renamed to `bare_trait_objects` -#[deny(unused)] -fn main() { let unused = (); } //~ ERROR unused diff --git a/src/test/compile-fail/lint-shorthand-field.rs b/src/test/compile-fail/lint-shorthand-field.rs deleted file mode 100644 index 97a976a493f..00000000000 --- a/src/test/compile-fail/lint-shorthand-field.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(bad_style, unused_variables)] -#![deny(non_shorthand_field_patterns)] - -struct Foo { - x: isize, - y: isize, -} - -fn main() { - { - let Foo { - x: x, //~ ERROR the `x:` in this pattern is redundant - y: ref y, //~ ERROR the `y:` in this pattern is redundant - } = Foo { x: 0, y: 0 }; - - let Foo { - x, - ref y, - } = Foo { x: 0, y: 0 }; - } - - { - const x: isize = 1; - - match (Foo { x: 1, y: 1 }) { - Foo { x: x, ..} => {}, - _ => {}, - } - } - - { - struct Bar { - x: x, - } - - struct x; - - match (Bar { x: x }) { - Bar { x: x } => {}, - } - } - - { - struct Bar { - x: Foo, - } - - enum Foo { x } - - match (Bar { x: Foo::x }) { - Bar { x: Foo::x } => {}, - } - } -} diff --git a/src/test/compile-fail/lint-stability-2.rs b/src/test/compile-fail/lint-stability-2.rs deleted file mode 100644 index 1f2fa077caf..00000000000 --- a/src/test/compile-fail/lint-stability-2.rs +++ /dev/null @@ -1,423 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_stability.rs -// aux-build:stability_cfg1.rs - -#![allow(deprecated)] -#![allow(dead_code)] -#![feature(staged_api)] - -#![stable(feature = "rust1", since = "1.0.0")] - -#[macro_use] -extern crate lint_stability; - -mod cross_crate { - extern crate stability_cfg1; - - use lint_stability::*; - - fn test() { - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); - foo.method_deprecated(); - Foo::method_deprecated(&foo); - ::method_deprecated(&foo); - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - - deprecated_text(); - foo.method_deprecated_text(); - Foo::method_deprecated_text(&foo); - ::method_deprecated_text(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - - foo.method_deprecated_unstable(); - //~^ ERROR use of unstable library feature - Foo::method_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - ::method_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - foo.trait_deprecated_unstable(); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - - foo.method_deprecated_unstable_text(); - //~^ ERROR use of unstable library feature - Foo::method_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - ::method_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - foo.trait_deprecated_unstable_text(); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - - foo.method_unstable(); //~ ERROR use of unstable library feature - Foo::method_unstable(&foo); //~ ERROR use of unstable library feature - ::method_unstable(&foo); //~ ERROR use of unstable library feature - foo.trait_unstable(); //~ ERROR use of unstable library feature - ::trait_unstable(&foo); //~ ERROR use of unstable library feature - - foo.method_unstable_text(); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - Foo::method_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - ::method_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - foo.trait_unstable_text(); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - ::trait_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - - stable(); - foo.method_stable(); - Foo::method_stable(&foo); - ::method_stable(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - - stable_text(); - foo.method_stable_text(); - Foo::method_stable_text(&foo); - ::method_stable_text(&foo); - foo.trait_stable_text(); - Trait::trait_stable_text(&foo); - ::trait_stable_text(&foo); - ::trait_stable_text(&foo); - - struct S2(T::TypeDeprecated); - - let _ = DeprecatedStruct { - i: 0 - }; - let _ = StableStruct { i: 0 }; - - let _ = DeprecatedUnitStruct; - let _ = StableUnitStruct; - - let _ = Enum::DeprecatedVariant; - let _ = Enum::StableVariant; - - let _ = DeprecatedTupleStruct (1); - let _ = StableTupleStruct (1); - - // At the moment, the lint checker only checks stability in - // in the arguments of macros. - // Eventually, we will want to lint the contents of the - // macro in the module *defining* it. Also, stability levels - // on macros themselves are not yet linted. - macro_test_arg!(deprecated_text()); - macro_test_arg!(macro_test_arg!(deprecated_text())); - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - foo.trait_deprecated_unstable(); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - foo.trait_deprecated_unstable_text(); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - foo.trait_unstable(); //~ ERROR use of unstable library feature - ::trait_unstable(&foo); //~ ERROR use of unstable library feature - foo.trait_unstable_text(); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - ::trait_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); - foo.trait_deprecated_text(); - foo.trait_deprecated_unstable(); - //~^ ERROR use of unstable library feature - foo.trait_deprecated_unstable_text(); - //~^ ERROR use of unstable library feature - foo.trait_unstable(); //~ ERROR use of unstable library feature - foo.trait_unstable_text(); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - foo.trait_stable(); - } - - struct S; - - impl DeprecatedTrait for S {} - trait LocalTrait2 : DeprecatedTrait { } -} - -mod this_crate { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn deprecated() {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn deprecated_text() {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn unstable() {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - pub fn unstable_text() {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn stable() {} - #[stable(feature = "rust1", since = "1.0.0")] - pub fn stable_text() {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub struct MethodTester; - - impl MethodTester { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn method_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - pub fn method_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable_text(&self) {} - } - - pub trait Trait { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - fn trait_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - fn trait_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable_text(&self) {} - } - - impl Trait for MethodTester {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedUnitStruct; - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableUnitStruct; - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableUnitStruct; - - pub enum Enum { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - DeprecatedVariant, - #[unstable(feature = "unstable_test_feature", issue = "0")] - UnstableVariant, - - #[stable(feature = "rust1", since = "1.0.0")] - StableVariant, - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedTupleStruct(isize); - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableTupleStruct(isize); - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableTupleStruct(isize); - - fn test() { - // Only the deprecated cases of the following should generate - // errors, because other stability attributes now have meaning - // only *across* crates, not within a single crate. - - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); - foo.method_deprecated(); - Foo::method_deprecated(&foo); - ::method_deprecated(&foo); - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - - deprecated_text(); - foo.method_deprecated_text(); - Foo::method_deprecated_text(&foo); - ::method_deprecated_text(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - - unstable(); - foo.method_unstable(); - Foo::method_unstable(&foo); - ::method_unstable(&foo); - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - - unstable_text(); - foo.method_unstable_text(); - Foo::method_unstable_text(&foo); - ::method_unstable_text(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - - stable(); - foo.method_stable(); - Foo::method_stable(&foo); - ::method_stable(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - - stable_text(); - foo.method_stable_text(); - Foo::method_stable_text(&foo); - ::method_stable_text(&foo); - foo.trait_stable_text(); - Trait::trait_stable_text(&foo); - ::trait_stable_text(&foo); - ::trait_stable_text(&foo); - - let _ = DeprecatedStruct { - i: 0 - }; - let _ = UnstableStruct { i: 0 }; - let _ = StableStruct { i: 0 }; - - let _ = DeprecatedUnitStruct; - let _ = UnstableUnitStruct; - let _ = StableUnitStruct; - - let _ = Enum::DeprecatedVariant; - let _ = Enum::UnstableVariant; - let _ = Enum::StableVariant; - - let _ = DeprecatedTupleStruct (1); - let _ = UnstableTupleStruct (1); - let _ = StableTupleStruct (1); - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); - foo.trait_deprecated_text(); - foo.trait_unstable(); - foo.trait_unstable_text(); - foo.trait_stable(); - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn test_fn_body() { - fn fn_in_body() {} - fn_in_body(); - } - - impl MethodTester { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn test_method_body(&self) { - fn fn_in_body() {} - fn_in_body(); - } - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub trait DeprecatedTrait { - fn dummy(&self) { } - } - - struct S; - - impl DeprecatedTrait for S { } - - trait LocalTrait : DeprecatedTrait { } -} - -fn main() {} diff --git a/src/test/compile-fail/lint-stability-deprecated.rs b/src/test/compile-fail/lint-stability-deprecated.rs deleted file mode 100644 index de2c27bdcbc..00000000000 --- a/src/test/compile-fail/lint-stability-deprecated.rs +++ /dev/null @@ -1,473 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_stability.rs -// aux-build:inherited_stability.rs -// aux-build:stability_cfg1.rs -// aux-build:stability_cfg2.rs -// ignore-tidy-linelength - -#![warn(deprecated)] -#![allow(dead_code, unused_extern_crates)] -#![feature(staged_api, unstable_test_feature, rustc_attrs)] - -#![stable(feature = "rust1", since = "1.0.0")] - -#[macro_use] -extern crate lint_stability; - -mod cross_crate { - extern crate stability_cfg1; - extern crate stability_cfg2; - - use lint_stability::*; - - fn test() { - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); //~ WARN use of deprecated item 'lint_stability::deprecated' - foo.method_deprecated(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' - Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' - ::method_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated' - foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - - deprecated_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text - foo.method_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text - Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text - ::method_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_text': text - foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - - deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable' - foo.method_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' - Foo::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' - ::method_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable' - foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - - deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text - foo.method_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text - Foo::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text - ::method_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::MethodTester::method_deprecated_unstable_text': text - foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - - unstable(); - foo.method_unstable(); - Foo::method_unstable(&foo); - ::method_unstable(&foo); - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - - unstable_text(); - foo.method_unstable_text(); - Foo::method_unstable_text(&foo); - ::method_unstable_text(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - - stable(); - foo.method_stable(); - Foo::method_stable(&foo); - ::method_stable(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - - stable_text(); - foo.method_stable_text(); - Foo::method_stable_text(&foo); - ::method_stable_text(&foo); - foo.trait_stable_text(); - Trait::trait_stable_text(&foo); - ::trait_stable_text(&foo); - ::trait_stable_text(&foo); - - struct S1(T::TypeUnstable); - struct S2(T::TypeDeprecated); - //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated': text - type A = TraitWithAssociatedTypes< - TypeUnstable = u8, - TypeDeprecated = u16, - //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated' - >; - - let _ = DeprecatedStruct { //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct' - i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedStruct::i' - }; - let _ = DeprecatedUnstableStruct { - //~^ WARN use of deprecated item 'lint_stability::DeprecatedUnstableStruct' - i: 0 //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableStruct::i' - }; - let _ = UnstableStruct { i: 0 }; - let _ = StableStruct { i: 0 }; - - let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnitStruct' - let _ = DeprecatedUnstableUnitStruct; //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableUnitStruct' - let _ = UnstableUnitStruct; - let _ = StableUnitStruct; - - let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedVariant' - let _ = Enum::DeprecatedUnstableVariant; //~ WARN use of deprecated item 'lint_stability::Enum::DeprecatedUnstableVariant' - let _ = Enum::UnstableVariant; - let _ = Enum::StableVariant; - - let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedTupleStruct' - let _ = DeprecatedUnstableTupleStruct (1); //~ WARN use of deprecated item 'lint_stability::DeprecatedUnstableTupleStruct' - let _ = UnstableTupleStruct (1); - let _ = StableTupleStruct (1); - - // At the moment, the lint checker only checks stability in - // in the arguments of macros. - // Eventually, we will want to lint the contents of the - // macro in the module *defining* it. Also, stability levels - // on macros themselves are not yet linted. - macro_test_arg!(deprecated_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text - macro_test_arg!(deprecated_unstable_text()); //~ WARN use of deprecated item 'lint_stability::deprecated_unstable_text': text - macro_test_arg!(macro_test_arg!(deprecated_text())); //~ WARN use of deprecated item 'lint_stability::deprecated_text': text - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - Trait::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - ::trait_deprecated_unstable(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - Trait::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - ::trait_deprecated_unstable_text(&foo); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text - foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' - foo.trait_deprecated_unstable_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable_text': text - foo.trait_unstable(); - foo.trait_unstable_text(); - foo.trait_stable(); - } - - struct S; - - impl UnstableTrait for S { } - impl DeprecatedTrait for S {} //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text - trait LocalTrait : UnstableTrait { } - trait LocalTrait2 : DeprecatedTrait { } //~ WARN use of deprecated item 'lint_stability::DeprecatedTrait': text - - impl Trait for S { - fn trait_stable(&self) {} - fn trait_unstable(&self) {} - } -} - -mod inheritance { - extern crate inherited_stability; - use self::inherited_stability::*; - - fn test_inheritance() { - unstable(); - stable(); - - stable_mod::unstable(); - stable_mod::stable(); - - unstable_mod::deprecated(); //~ WARN use of deprecated item 'inheritance::inherited_stability::unstable_mod::deprecated': text - unstable_mod::unstable(); - - let _ = Unstable::UnstableVariant; - let _ = Unstable::StableVariant; - - let x: usize = 0; - x.unstable(); - x.stable(); - } -} - -mod this_crate { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn deprecated() {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn deprecated_text() {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn unstable() {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - pub fn unstable_text() {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn stable() {} - #[stable(feature = "rust1", since = "1.0.0")] - pub fn stable_text() {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub struct MethodTester; - - impl MethodTester { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn method_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - pub fn method_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable_text(&self) {} - } - - pub trait Trait { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - fn trait_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - fn trait_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable_text(&self) {} - } - - impl Trait for MethodTester {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedUnitStruct; - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableUnitStruct; - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableUnitStruct; - - pub enum Enum { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - DeprecatedVariant, - #[unstable(feature = "unstable_test_feature", issue = "0")] - UnstableVariant, - - #[stable(feature = "rust1", since = "1.0.0")] - StableVariant, - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedTupleStruct(isize); - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableTupleStruct(isize); - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableTupleStruct(isize); - - fn test() { - // Only the deprecated cases of the following should generate - // errors, because other stability attributes now have meaning - // only *across* crates, not within a single crate. - - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); //~ WARN use of deprecated item 'this_crate::deprecated' - foo.method_deprecated(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' - Foo::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' - ::method_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated' - foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - - deprecated_text(); //~ WARN use of deprecated item 'this_crate::deprecated_text': text - foo.method_deprecated_text(); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text - Foo::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text - ::method_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::MethodTester::method_deprecated_text': text - foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - - unstable(); - foo.method_unstable(); - Foo::method_unstable(&foo); - ::method_unstable(&foo); - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - - unstable_text(); - foo.method_unstable_text(); - Foo::method_unstable_text(&foo); - ::method_unstable_text(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - - stable(); - foo.method_stable(); - Foo::method_stable(&foo); - ::method_stable(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - - stable_text(); - foo.method_stable_text(); - Foo::method_stable_text(&foo); - ::method_stable_text(&foo); - foo.trait_stable_text(); - Trait::trait_stable_text(&foo); - ::trait_stable_text(&foo); - ::trait_stable_text(&foo); - - let _ = DeprecatedStruct { - //~^ WARN use of deprecated item 'this_crate::DeprecatedStruct' - i: 0 //~ WARN use of deprecated item 'this_crate::DeprecatedStruct::i' - }; - let _ = UnstableStruct { i: 0 }; - let _ = StableStruct { i: 0 }; - - let _ = DeprecatedUnitStruct; //~ WARN use of deprecated item 'this_crate::DeprecatedUnitStruct' - let _ = UnstableUnitStruct; - let _ = StableUnitStruct; - - let _ = Enum::DeprecatedVariant; //~ WARN use of deprecated item 'this_crate::Enum::DeprecatedVariant' - let _ = Enum::UnstableVariant; - let _ = Enum::StableVariant; - - let _ = DeprecatedTupleStruct (1); //~ WARN use of deprecated item 'this_crate::DeprecatedTupleStruct' - let _ = UnstableTupleStruct (1); - let _ = StableTupleStruct (1); - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - Trait::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - ::trait_deprecated(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - Trait::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - ::trait_deprecated_text(&foo); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' - foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text - foo.trait_unstable(); - foo.trait_unstable_text(); - foo.trait_stable(); - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn test_fn_body() { - fn fn_in_body() {} - fn_in_body(); //~ WARN use of deprecated item 'this_crate::test_fn_body::fn_in_body': text - } - - impl MethodTester { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn test_method_body(&self) { - fn fn_in_body() {} - fn_in_body(); //~ WARN use of deprecated item 'this_crate::MethodTester::test_method_body::fn_in_body': text - } - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub trait DeprecatedTrait { - fn dummy(&self) { } - } - - struct S; - - impl DeprecatedTrait for S { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait' - - trait LocalTrait : DeprecatedTrait { } //~ WARN use of deprecated item 'this_crate::DeprecatedTrait' -} - -#[rustc_error] fn main() {} //~ ERROR: compilation successful diff --git a/src/test/compile-fail/lint-stability-fields-deprecated.rs b/src/test/compile-fail/lint-stability-fields-deprecated.rs deleted file mode 100644 index 0ad4466d0e2..00000000000 --- a/src/test/compile-fail/lint-stability-fields-deprecated.rs +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_stability_fields.rs - -#![deny(deprecated)] -#![allow(dead_code)] -#![feature(staged_api, unstable_test_feature)] - -#![stable(feature = "rust1", since = "1.0.0")] - -mod cross_crate { - extern crate lint_stability_fields; - - use self::lint_stability_fields::*; - - pub fn foo() { - let x = Stable { - inherit: 1, - override1: 2, - override2: 3, - //~^ ERROR use of deprecated item - }; - - let _ = x.inherit; - let _ = x.override1; - let _ = x.override2; - //~^ ERROR use of deprecated item - - let Stable { - inherit: _, - override1: _, - override2: _ - //~^ ERROR use of deprecated item - } = x; - // all fine - let Stable { .. } = x; - - let x = Stable2(1, 2, 3); - - let _ = x.0; - let _ = x.1; - let _ = x.2; - //~^ ERROR use of deprecated item - - let Stable2(_, - _, - _) - //~^ ERROR use of deprecated item - = x; - // all fine - let Stable2(..) = x; - - - let x = Unstable { - inherit: 1, - override1: 2, - override2: 3, - //~^ ERROR use of deprecated item - }; - - let _ = x.inherit; - let _ = x.override1; - let _ = x.override2; - //~^ ERROR use of deprecated item - - let Unstable { - inherit: _, - override1: _, - override2: _ - //~^ ERROR use of deprecated item - } = x; - - let Unstable - // the patterns are all fine: - { .. } = x; - - - let x = Unstable2(1, 2, 3); - - let _ = x.0; - let _ = x.1; - let _ = x.2; - //~^ ERROR use of deprecated item - - let Unstable2 - (_, - _, - _) - //~^ ERROR use of deprecated item - = x; - let Unstable2 - // the patterns are all fine: - (..) = x; - - - let x = Deprecated { - //~^ ERROR use of deprecated item - inherit: 1, - //~^ ERROR use of deprecated item - override1: 2, - //~^ ERROR use of deprecated item - override2: 3, - //~^ ERROR use of deprecated item - }; - - let _ = x.inherit; - //~^ ERROR use of deprecated item - let _ = x.override1; - //~^ ERROR use of deprecated item - let _ = x.override2; - //~^ ERROR use of deprecated item - - let Deprecated { - //~^ ERROR use of deprecated item - inherit: _, - //~^ ERROR use of deprecated item - override1: _, - //~^ ERROR use of deprecated item - override2: _ - //~^ ERROR use of deprecated item - } = x; - - let Deprecated - //~^ ERROR use of deprecated item - // the patterns are all fine: - { .. } = x; - - let x = Deprecated2(1, 2, 3); - //~^ ERROR use of deprecated item - - let _ = x.0; - //~^ ERROR use of deprecated item - let _ = x.1; - //~^ ERROR use of deprecated item - let _ = x.2; - //~^ ERROR use of deprecated item - - let Deprecated2 - //~^ ERROR use of deprecated item - (_, - //~^ ERROR use of deprecated item - _, - //~^ ERROR use of deprecated item - _) - //~^ ERROR use of deprecated item - = x; - let Deprecated2 - //~^ ERROR use of deprecated item - // the patterns are all fine: - (..) = x; - } -} - -mod this_crate { - #[stable(feature = "rust1", since = "1.0.0")] - struct Stable { - inherit: u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] - #[unstable(feature = "unstable_test_feature", issue = "0")] - override2: u8, - } - - #[stable(feature = "rust1", since = "1.0.0")] - struct Stable2(u8, - #[stable(feature = "rust1", since = "1.0.0")] u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); - - #[unstable(feature = "unstable_test_feature", issue = "0")] - struct Unstable { - inherit: u8, - #[stable(feature = "rust1", since = "1.0.0")] - override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] - #[unstable(feature = "unstable_test_feature", issue = "0")] - override2: u8, - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - struct Unstable2(u8, - #[stable(feature = "rust1", since = "1.0.0")] u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - struct Deprecated { - inherit: u8, - #[stable(feature = "rust1", since = "1.0.0")] - override1: u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - override2: u8, - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - struct Deprecated2(u8, - #[stable(feature = "rust1", since = "1.0.0")] u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] u8); - - pub fn foo() { - let x = Stable { - inherit: 1, - override1: 2, - override2: 3, - //~^ ERROR use of deprecated item - }; - - let _ = x.inherit; - let _ = x.override1; - let _ = x.override2; - //~^ ERROR use of deprecated item - - let Stable { - inherit: _, - override1: _, - override2: _ - //~^ ERROR use of deprecated item - } = x; - // all fine - let Stable { .. } = x; - - let x = Stable2(1, 2, 3); - - let _ = x.0; - let _ = x.1; - let _ = x.2; - //~^ ERROR use of deprecated item - - let Stable2(_, - _, - _) - //~^ ERROR use of deprecated item - = x; - // all fine - let Stable2(..) = x; - - - let x = Unstable { - inherit: 1, - override1: 2, - override2: 3, - //~^ ERROR use of deprecated item - }; - - let _ = x.inherit; - let _ = x.override1; - let _ = x.override2; - //~^ ERROR use of deprecated item - - let Unstable { - inherit: _, - override1: _, - override2: _ - //~^ ERROR use of deprecated item - } = x; - - let Unstable - // the patterns are all fine: - { .. } = x; - - - let x = Unstable2(1, 2, 3); - - let _ = x.0; - let _ = x.1; - let _ = x.2; - //~^ ERROR use of deprecated item - - let Unstable2 - (_, - _, - _) - //~^ ERROR use of deprecated item - = x; - let Unstable2 - // the patterns are all fine: - (..) = x; - - - let x = Deprecated { - //~^ ERROR use of deprecated item - inherit: 1, - //~^ ERROR use of deprecated item - override1: 2, - //~^ ERROR use of deprecated item - override2: 3, - //~^ ERROR use of deprecated item - }; - - let _ = x.inherit; - //~^ ERROR use of deprecated item - let _ = x.override1; - //~^ ERROR use of deprecated item - let _ = x.override2; - //~^ ERROR use of deprecated item - - let Deprecated { - //~^ ERROR use of deprecated item - inherit: _, - //~^ ERROR use of deprecated item - override1: _, - //~^ ERROR use of deprecated item - override2: _ - //~^ ERROR use of deprecated item - } = x; - - let Deprecated - //~^ ERROR use of deprecated item - // the patterns are all fine: - { .. } = x; - - let x = Deprecated2(1, 2, 3); - //~^ ERROR use of deprecated item - - let _ = x.0; - //~^ ERROR use of deprecated item - let _ = x.1; - //~^ ERROR use of deprecated item - let _ = x.2; - //~^ ERROR use of deprecated item - - let Deprecated2 - //~^ ERROR use of deprecated item - (_, - //~^ ERROR use of deprecated item - _, - //~^ ERROR use of deprecated item - _) - //~^ ERROR use of deprecated item - = x; - let Deprecated2 - //~^ ERROR use of deprecated item - // the patterns are all fine: - (..) = x; - } -} - -fn main() {} diff --git a/src/test/compile-fail/lint-stability-fields.rs b/src/test/compile-fail/lint-stability-fields.rs deleted file mode 100644 index db6b64dabfe..00000000000 --- a/src/test/compile-fail/lint-stability-fields.rs +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_stability_fields.rs -#![allow(deprecated)] -#![allow(dead_code)] -#![feature(staged_api)] - -#![stable(feature = "rust1", since = "1.0.0")] - -mod cross_crate { - extern crate lint_stability_fields; - - mod reexport { - #[stable(feature = "rust1", since = "1.0.0")] - pub use super::lint_stability_fields::*; - } - - use self::lint_stability_fields::*; - - pub fn foo() { - let x = Stable { - inherit: 1, - override1: 2, //~ ERROR use of unstable - override2: 3, //~ ERROR use of unstable - }; - - let _ = x.inherit; - let _ = x.override1; //~ ERROR use of unstable - let _ = x.override2; //~ ERROR use of unstable - - let Stable { - inherit: _, - override1: _, //~ ERROR use of unstable - override2: _ //~ ERROR use of unstable - } = x; - // all fine - let Stable { .. } = x; - - let x = Stable2(1, 2, 3); - - let _ = x.0; - let _ = x.1; //~ ERROR use of unstable - let _ = x.2; //~ ERROR use of unstable - - let Stable2(_, - _, //~ ERROR use of unstable - _) //~ ERROR use of unstable - = x; - // all fine - let Stable2(..) = x; - - - let x = Unstable { //~ ERROR use of unstable - inherit: 1, //~ ERROR use of unstable - override1: 2, - override2: 3, //~ ERROR use of unstable - }; - - let _ = x.inherit; //~ ERROR use of unstable - let _ = x.override1; - let _ = x.override2; //~ ERROR use of unstable - - let Unstable { //~ ERROR use of unstable - inherit: _, //~ ERROR use of unstable - override1: _, - override2: _ //~ ERROR use of unstable - } = x; - - let Unstable //~ ERROR use of unstable - // the patterns are all fine: - { .. } = x; - - // Unstable items are still unstable even when used through a stable "pub use". - let x = reexport::Unstable2(1, 2, 3); //~ ERROR use of unstable - - let x = Unstable2(1, 2, 3); //~ ERROR use of unstable - - let _ = x.0; //~ ERROR use of unstable - let _ = x.1; - let _ = x.2; //~ ERROR use of unstable - - let Unstable2 //~ ERROR use of unstable - (_, //~ ERROR use of unstable - _, - _) //~ ERROR use of unstable - = x; - let Unstable2 //~ ERROR use of unstable - // the patterns are all fine: - (..) = x; - - - let x = Deprecated { //~ ERROR use of unstable - inherit: 1, //~ ERROR use of unstable - override1: 2, - override2: 3, //~ ERROR use of unstable - }; - - let _ = x.inherit; //~ ERROR use of unstable - let _ = x.override1; - let _ = x.override2; //~ ERROR use of unstable - - let Deprecated { //~ ERROR use of unstable - inherit: _, //~ ERROR use of unstable - override1: _, - override2: _ //~ ERROR use of unstable - } = x; - - let Deprecated //~ ERROR use of unstable - // the patterns are all fine: - { .. } = x; - - let x = Deprecated2(1, 2, 3); //~ ERROR use of unstable - - let _ = x.0; //~ ERROR use of unstable - let _ = x.1; - let _ = x.2; //~ ERROR use of unstable - - let Deprecated2 //~ ERROR use of unstable - (_, //~ ERROR use of unstable - _, - _) //~ ERROR use of unstable - = x; - let Deprecated2 //~ ERROR use of unstable - // the patterns are all fine: - (..) = x; - } -} - -mod this_crate { - #[stable(feature = "rust1", since = "1.0.0")] - struct Stable { - inherit: u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] - #[unstable(feature = "unstable_test_feature", issue = "0")] - override2: u8, - } - - #[stable(feature = "rust1", since = "1.0.0")] - struct Stable2(u8, - #[stable(feature = "rust1", since = "1.0.0")] u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); - - #[unstable(feature = "unstable_test_feature", issue = "0")] - struct Unstable { - inherit: u8, - #[stable(feature = "rust1", since = "1.0.0")] - override1: u8, - #[rustc_deprecated(since = "1.0.0", reason = "text")] - #[unstable(feature = "unstable_test_feature", issue = "0")] - override2: u8, - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - struct Unstable2(u8, - #[stable(feature = "rust1", since = "1.0.0")] u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] u8); - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - struct Deprecated { - inherit: u8, - #[stable(feature = "rust1", since = "1.0.0")] - override1: u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] - override2: u8, - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - struct Deprecated2(u8, - #[stable(feature = "rust1", since = "1.0.0")] u8, - #[unstable(feature = "unstable_test_feature", issue = "0")] u8); - - pub fn foo() { - let x = Stable { - inherit: 1, - override1: 2, - override2: 3, - }; - - let _ = x.inherit; - let _ = x.override1; - let _ = x.override2; - - let Stable { - inherit: _, - override1: _, - override2: _ - } = x; - // all fine - let Stable { .. } = x; - - let x = Stable2(1, 2, 3); - - let _ = x.0; - let _ = x.1; - let _ = x.2; - - let Stable2(_, - _, - _) - = x; - // all fine - let Stable2(..) = x; - - - let x = Unstable { - inherit: 1, - override1: 2, - override2: 3, - }; - - let _ = x.inherit; - let _ = x.override1; - let _ = x.override2; - - let Unstable { - inherit: _, - override1: _, - override2: _ - } = x; - - let Unstable - // the patterns are all fine: - { .. } = x; - - - let x = Unstable2(1, 2, 3); - - let _ = x.0; - let _ = x.1; - let _ = x.2; - - let Unstable2 - (_, - _, - _) - = x; - let Unstable2 - // the patterns are all fine: - (..) = x; - - - let x = Deprecated { - inherit: 1, - override1: 2, - override2: 3, - }; - - let _ = x.inherit; - let _ = x.override1; - let _ = x.override2; - - let Deprecated { - inherit: _, - override1: _, - override2: _ - } = x; - - let Deprecated - // the patterns are all fine: - { .. } = x; - - let x = Deprecated2(1, 2, 3); - - let _ = x.0; - let _ = x.1; - let _ = x.2; - - let Deprecated2 - (_, - _, - _) - = x; - let Deprecated2 - // the patterns are all fine: - (..) = x; - } -} - -fn main() {} diff --git a/src/test/compile-fail/lint-stability.rs b/src/test/compile-fail/lint-stability.rs deleted file mode 100644 index 720b1235d47..00000000000 --- a/src/test/compile-fail/lint-stability.rs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_stability.rs -// aux-build:inherited_stability.rs -// aux-build:stability_cfg1.rs -// aux-build:stability_cfg2.rs - -#![allow(deprecated)] -#![allow(dead_code)] -#![feature(staged_api)] - -#![stable(feature = "rust1", since = "1.0.0")] - -#[macro_use] -extern crate lint_stability; - -mod cross_crate { - extern crate stability_cfg1; - extern crate stability_cfg2; //~ ERROR use of unstable library feature - - use lint_stability::*; - - fn test() { - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); - foo.method_deprecated(); - Foo::method_deprecated(&foo); - ::method_deprecated(&foo); - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - - deprecated_text(); - foo.method_deprecated_text(); - Foo::method_deprecated_text(&foo); - ::method_deprecated_text(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - - deprecated_future(); // Fine; no error. - - deprecated_unstable(); - //~^ ERROR use of unstable library feature - Trait::trait_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - - deprecated_unstable_text(); - //~^ ERROR use of unstable library feature - Trait::trait_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - - unstable(); //~ ERROR use of unstable library feature - Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature - ::trait_unstable(&foo); //~ ERROR use of unstable library feature - - unstable_text(); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - Trait::trait_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - ::trait_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - - stable(); - foo.method_stable(); - Foo::method_stable(&foo); - ::method_stable(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - - stable_text(); - foo.method_stable_text(); - Foo::method_stable_text(&foo); - ::method_stable_text(&foo); - foo.trait_stable_text(); - Trait::trait_stable_text(&foo); - ::trait_stable_text(&foo); - ::trait_stable_text(&foo); - - struct S1(T::TypeUnstable); - //~^ ERROR use of unstable library feature - struct S2(T::TypeDeprecated); - type A = TraitWithAssociatedTypes< - TypeUnstable = u8, //~ ERROR use of unstable library feature - TypeDeprecated = u16, - >; - - let _ = DeprecatedStruct { - i: 0 - }; - let _ = DeprecatedUnstableStruct { - //~^ ERROR use of unstable library feature - i: 0 - }; - let _ = UnstableStruct { i: 0 }; //~ ERROR use of unstable library feature - let _ = StableStruct { i: 0 }; - - let _ = DeprecatedUnitStruct; - let _ = DeprecatedUnstableUnitStruct; - //~^ ERROR use of unstable library feature - let _ = UnstableUnitStruct; //~ ERROR use of unstable library feature - let _ = StableUnitStruct; - - let _ = Enum::DeprecatedVariant; - let _ = Enum::DeprecatedUnstableVariant; - //~^ ERROR use of unstable library feature - let _ = Enum::UnstableVariant; //~ ERROR use of unstable library feature - let _ = Enum::StableVariant; - - let _ = DeprecatedTupleStruct (1); - let _ = DeprecatedUnstableTupleStruct (1); - //~^ ERROR use of unstable library feature - let _ = UnstableTupleStruct (1); //~ ERROR use of unstable library feature - let _ = StableTupleStruct (1); - - // At the moment, the lint checker only checks stability in - // in the arguments of macros. - // Eventually, we will want to lint the contents of the - // macro in the module *defining* it. Also, stability levels - // on macros themselves are not yet linted. - macro_test_arg!(deprecated_text()); - macro_test_arg!(deprecated_unstable_text()); - //~^ ERROR use of unstable library feature - macro_test_arg!(macro_test_arg!(deprecated_text())); - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - Trait::trait_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable(&foo); - //~^ ERROR use of unstable library feature - Trait::trait_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - ::trait_deprecated_unstable_text(&foo); - //~^ ERROR use of unstable library feature - Trait::trait_unstable(&foo); //~ ERROR use of unstable library feature - ::trait_unstable(&foo); //~ ERROR use of unstable library feature - Trait::trait_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - ::trait_unstable_text(&foo); - //~^ ERROR use of unstable library feature 'unstable_test_feature': text - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); - foo.trait_deprecated_text(); - foo.trait_stable(); - } - - struct S; - - impl UnstableTrait for S { } //~ ERROR use of unstable library feature - impl DeprecatedTrait for S {} - trait LocalTrait : UnstableTrait { } //~ ERROR use of unstable library feature - trait LocalTrait2 : DeprecatedTrait { } - - impl Trait for S { - fn trait_stable(&self) {} - fn trait_unstable(&self) {} //~ ERROR use of unstable library feature - } -} - -mod inheritance { - extern crate inherited_stability; //~ ERROR use of unstable library feature - use self::inherited_stability::*; //~ ERROR use of unstable library feature - - fn test_inheritance() { - unstable(); //~ ERROR use of unstable library feature - stable(); - - stable_mod::unstable(); //~ ERROR use of unstable library feature - stable_mod::stable(); - - unstable_mod::deprecated(); - unstable_mod::unstable(); //~ ERROR use of unstable library feature - - let _ = Unstable::UnstableVariant; //~ ERROR use of unstable library feature - let _ = Unstable::StableVariant; - - let x: usize = 0; - x.stable(); - } -} - -mod this_crate { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn deprecated() {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn deprecated_text() {} - - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_deprecated(since = "99.99.99", reason = "text")] - pub fn deprecated_future() {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn unstable() {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - pub fn unstable_text() {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn stable() {} - #[stable(feature = "rust1", since = "1.0.0")] - pub fn stable_text() {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub struct MethodTester; - - impl MethodTester { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub fn method_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub fn method_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - pub fn method_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - pub fn method_stable_text(&self) {} - } - - pub trait Trait { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated(&self) {} - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn trait_deprecated_text(&self) {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - fn trait_unstable(&self) {} - #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] - fn trait_unstable_text(&self) {} - - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable(&self) {} - #[stable(feature = "rust1", since = "1.0.0")] - fn trait_stable_text(&self) {} - } - - impl Trait for MethodTester {} - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableStruct { - #[stable(feature = "stable_test_feature", since = "1.0.0")] i: isize - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedUnitStruct; - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableUnitStruct; - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableUnitStruct; - - pub enum Enum { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - DeprecatedVariant, - #[unstable(feature = "unstable_test_feature", issue = "0")] - UnstableVariant, - - #[stable(feature = "rust1", since = "1.0.0")] - StableVariant, - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub struct DeprecatedTupleStruct(isize); - #[unstable(feature = "unstable_test_feature", issue = "0")] - pub struct UnstableTupleStruct(isize); - #[stable(feature = "rust1", since = "1.0.0")] - pub struct StableTupleStruct(isize); - - fn test() { - // Only the deprecated cases of the following should generate - // errors, because other stability attributes now have meaning - // only *across* crates, not within a single crate. - - type Foo = MethodTester; - let foo = MethodTester; - - deprecated(); - foo.method_deprecated(); - Foo::method_deprecated(&foo); - ::method_deprecated(&foo); - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - - deprecated_text(); - foo.method_deprecated_text(); - Foo::method_deprecated_text(&foo); - ::method_deprecated_text(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - - deprecated_future(); - - unstable(); - foo.method_unstable(); - Foo::method_unstable(&foo); - ::method_unstable(&foo); - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - - unstable_text(); - foo.method_unstable_text(); - Foo::method_unstable_text(&foo); - ::method_unstable_text(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - - stable(); - foo.method_stable(); - Foo::method_stable(&foo); - ::method_stable(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - - stable_text(); - foo.method_stable_text(); - Foo::method_stable_text(&foo); - ::method_stable_text(&foo); - foo.trait_stable_text(); - Trait::trait_stable_text(&foo); - ::trait_stable_text(&foo); - ::trait_stable_text(&foo); - - let _ = DeprecatedStruct { - i: 0 - }; - let _ = UnstableStruct { i: 0 }; - let _ = StableStruct { i: 0 }; - - let _ = DeprecatedUnitStruct; - let _ = UnstableUnitStruct; - let _ = StableUnitStruct; - - let _ = Enum::DeprecatedVariant; - let _ = Enum::UnstableVariant; - let _ = Enum::StableVariant; - - let _ = DeprecatedTupleStruct (1); - let _ = UnstableTupleStruct (1); - let _ = StableTupleStruct (1); - } - - fn test_method_param(foo: Foo) { - foo.trait_deprecated(); - Trait::trait_deprecated(&foo); - ::trait_deprecated(&foo); - ::trait_deprecated(&foo); - foo.trait_deprecated_text(); - Trait::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - ::trait_deprecated_text(&foo); - foo.trait_unstable(); - Trait::trait_unstable(&foo); - ::trait_unstable(&foo); - ::trait_unstable(&foo); - foo.trait_unstable_text(); - Trait::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - ::trait_unstable_text(&foo); - foo.trait_stable(); - Trait::trait_stable(&foo); - ::trait_stable(&foo); - ::trait_stable(&foo); - } - - fn test_method_object(foo: &Trait) { - foo.trait_deprecated(); - foo.trait_deprecated_text(); - foo.trait_unstable(); - foo.trait_unstable_text(); - foo.trait_stable(); - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn test_fn_body() { - fn fn_in_body() {} - fn_in_body(); - } - - impl MethodTester { - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - fn test_method_body(&self) { - fn fn_in_body() {} - fn_in_body(); - } - } - - #[unstable(feature = "unstable_test_feature", issue = "0")] - #[rustc_deprecated(since = "1.0.0", reason = "text")] - pub trait DeprecatedTrait { - fn dummy(&self) { } - } - - struct S; - - impl DeprecatedTrait for S { } - - trait LocalTrait : DeprecatedTrait { } -} - -fn main() {} diff --git a/src/test/compile-fail/lint-stability2.rs b/src/test/compile-fail/lint-stability2.rs deleted file mode 100644 index d2ec00d6495..00000000000 --- a/src/test/compile-fail/lint-stability2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_stability.rs -// error-pattern: use of deprecated item - -#![deny(deprecated)] - -#[macro_use] -extern crate lint_stability; - -use lint_stability::*; - -fn main() { - macro_test!(); -} diff --git a/src/test/compile-fail/lint-stability3.rs b/src/test/compile-fail/lint-stability3.rs deleted file mode 100644 index 44a36f215f3..00000000000 --- a/src/test/compile-fail/lint-stability3.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_stability.rs -// error-pattern: use of deprecated item - -#![deny(deprecated)] -#![allow(warnings)] - -#[macro_use] -extern crate lint_stability; - -use lint_stability::*; - -fn main() { - macro_test_arg_nested!(deprecated_text); -} diff --git a/src/test/compile-fail/lint-type-limits.rs b/src/test/compile-fail/lint-type-limits.rs deleted file mode 100644 index 29929c120c3..00000000000 --- a/src/test/compile-fail/lint-type-limits.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// compile-flags: -D unused-comparisons -fn main() { } - -fn foo() { - let mut i = 100_usize; - while i >= 0 { //~ ERROR comparison is useless due to type limits - i -= 1; - } -} - -fn bar() -> i8 { - return 123; -} - -fn bleh() { - let u = 42u8; - let _ = u > 255; //~ ERROR comparison is useless due to type limits - let _ = 255 < u; //~ ERROR comparison is useless due to type limits - let _ = u < 0; //~ ERROR comparison is useless due to type limits - let _ = 0 > u; //~ ERROR comparison is useless due to type limits - let _ = u <= 255; //~ ERROR comparison is useless due to type limits - let _ = 255 >= u; //~ ERROR comparison is useless due to type limits - let _ = u >= 0; //~ ERROR comparison is useless due to type limits - let _ = 0 <= u; //~ ERROR comparison is useless due to type limits -} diff --git a/src/test/compile-fail/lint-type-limits2.rs b/src/test/compile-fail/lint-type-limits2.rs deleted file mode 100644 index 8fc18d16469..00000000000 --- a/src/test/compile-fail/lint-type-limits2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// compile-flags: -D unused-comparisons -fn main() { } - - -fn bar() -> i8 { - return 123; -} - -fn baz() -> bool { - 128 > bar() //~ ERROR comparison is useless due to type limits - //~| WARN literal out of range for i8 -} diff --git a/src/test/compile-fail/lint-type-limits3.rs b/src/test/compile-fail/lint-type-limits3.rs deleted file mode 100644 index b09dc0acdbf..00000000000 --- a/src/test/compile-fail/lint-type-limits3.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// compile-flags: -D unused-comparisons -fn main() { } - -fn qux() { - let mut i = 1i8; - while 200 != i { //~ ERROR comparison is useless due to type limits - //~| WARN literal out of range for i8 - i += 1; - } -} diff --git a/src/test/compile-fail/lint-type-overflow.rs b/src/test/compile-fail/lint-type-overflow.rs deleted file mode 100644 index ce336905c01..00000000000 --- a/src/test/compile-fail/lint-type-overflow.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// - -#![deny(overflowing_literals)] - -fn test(x: i8) { - println!("x {}", x); -} - -#[allow(unused_variables)] -fn main() { - let x1: u8 = 255; // should be OK - let x1: u8 = 256; //~ error: literal out of range for u8 - - let x1 = 255_u8; // should be OK - let x1 = 256_u8; //~ error: literal out of range for u8 - - let x2: i8 = -128; // should be OK - let x1: i8 = 128; //~ error: literal out of range for i8 - - let x3: i8 = -129; //~ error: literal out of range for i8 - let x3: i8 = -(129); //~ error: literal out of range for i8 - let x3: i8 = -{129}; //~ error: literal out of range for i8 - - test(1000); //~ error: literal out of range for i8 - - let x = 128_i8; //~ error: literal out of range for i8 - let x = 127_i8; - let x = -128_i8; - let x = -(128_i8); - let x = -129_i8; //~ error: literal out of range for i8 - - let x: i32 = 2147483647; // should be OK - let x = 2147483647_i32; // should be OK - let x: i32 = 2147483648; //~ error: literal out of range for i32 - let x = 2147483648_i32; //~ error: literal out of range for i32 - let x: i32 = -2147483648; // should be OK - let x = -2147483648_i32; // should be OK - let x: i32 = -2147483649; //~ error: literal out of range for i32 - let x = -2147483649_i32; //~ error: literal out of range for i32 - let x = 2147483648; //~ error: literal out of range for i32 - - let x = 9223372036854775808_i64; //~ error: literal out of range for i64 - let x = -9223372036854775808_i64; // should be OK - let x = 18446744073709551615_i64; //~ error: literal out of range for i64 - let x: i64 = -9223372036854775809; //~ error: literal out of range for i64 - let x = -9223372036854775809_i64; //~ error: literal out of range for i64 -} diff --git a/src/test/compile-fail/lint-type-overflow2.rs b/src/test/compile-fail/lint-type-overflow2.rs deleted file mode 100644 index f7cf8a68d56..00000000000 --- a/src/test/compile-fail/lint-type-overflow2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// - -#![warn(overflowing_literals)] -#![warn(const_err)] -#![feature(rustc_attrs)] - -#[allow(unused_variables)] -#[rustc_error] -fn main() { //~ ERROR: compilation successful - let x2: i8 = --128; //~ warn: literal out of range for i8 - - let x = -3.40282357e+38_f32; //~ warn: literal out of range for f32 - let x = 3.40282357e+38_f32; //~ warn: literal out of range for f32 - let x = -1.7976931348623159e+308_f64; //~ warn: literal out of range for f64 - let x = 1.7976931348623159e+308_f64; //~ warn: literal out of range for f64 -} diff --git a/src/test/compile-fail/lint-unexported-no-mangle.rs b/src/test/compile-fail/lint-unexported-no-mangle.rs deleted file mode 100644 index cd64dfa7a47..00000000000 --- a/src/test/compile-fail/lint-unexported-no-mangle.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-F private_no_mangle_fns -F no_mangle_const_items -F private_no_mangle_statics - -#[no_mangle] -fn foo() { //~ ERROR function is marked #[no_mangle], but not exported -} - -#[allow(dead_code)] -#[no_mangle] -const FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] - -#[no_mangle] -pub const PUB_FOO: u64 = 1; //~ ERROR const items should never be #[no_mangle] - -#[no_mangle] -pub fn bar() { -} - -#[no_mangle] -pub static BAR: u64 = 1; - -#[allow(dead_code)] -#[no_mangle] -static PRIVATE_BAR: u64 = 1; //~ ERROR static is marked #[no_mangle], but not exported - - -fn main() { - foo(); - bar(); -} diff --git a/src/test/compile-fail/lint-unknown-attr.rs b/src/test/compile-fail/lint-unknown-attr.rs deleted file mode 100644 index af4e81be195..00000000000 --- a/src/test/compile-fail/lint-unknown-attr.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// When denying at the crate level, be sure to not get random warnings from the -// injected intrinsics by the compiler. - -#![feature(custom_attribute)] -#![deny(unused_attributes)] - -#![mutable_doc] //~ ERROR unused attribute - -#[dance] mod a {} //~ ERROR unused attribute - -#[dance] fn main() {} //~ ERROR unused attribute diff --git a/src/test/compile-fail/lint-unknown-feature-default.rs b/src/test/compile-fail/lint-unknown-feature-default.rs deleted file mode 100644 index 5a0568f05e6..00000000000 --- a/src/test/compile-fail/lint-unknown-feature-default.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests the default for the unused_features lint - -#![allow(stable_features)] -// FIXME(#44232) we should warn that this isn't used. -#![feature(rust1)] - -#![feature(rustc_attrs)] - -#[rustc_error] -fn main() { } //~ ERROR: compilation successful diff --git a/src/test/compile-fail/lint-unknown-feature.rs b/src/test/compile-fail/lint-unknown-feature.rs deleted file mode 100644 index 81f99f99492..00000000000 --- a/src/test/compile-fail/lint-unknown-feature.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![warn(unused_features)] - -#![allow(stable_features)] -// FIXME(#44232) we should warn that this isn't used. -#![feature(rust1)] - -#![feature(rustc_attrs)] - -#[rustc_error] -fn main() {} //~ ERROR: compilation successful diff --git a/src/test/compile-fail/lint-unknown-lint-cmdline.rs b/src/test/compile-fail/lint-unknown-lint-cmdline.rs deleted file mode 100644 index 0c41959f8a7..00000000000 --- a/src/test/compile-fail/lint-unknown-lint-cmdline.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-D bogus - -// error-pattern:unknown lint -// error-pattern:requested on the command line with `-D bogus` - -fn main() { } diff --git a/src/test/compile-fail/lint-unknown-lint.rs b/src/test/compile-fail/lint-unknown-lint.rs deleted file mode 100644 index 2de8d849d19..00000000000 --- a/src/test/compile-fail/lint-unknown-lint.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(not_a_real_lint)] //~ WARN unknown lint -#![deny(unused)] -fn main() { let unused = (); } //~ ERROR unused variable diff --git a/src/test/compile-fail/lint-unnecessary-import-braces.rs b/src/test/compile-fail/lint-unnecessary-import-braces.rs deleted file mode 100644 index 214a03c13f4..00000000000 --- a/src/test/compile-fail/lint-unnecessary-import-braces.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_import_braces)] - -use test::{A}; //~ ERROR braces around A is unnecessary - -mod test { - use test::{self}; // OK - use test::{self as rename}; // OK - pub struct A; -} - -fn main() {} diff --git a/src/test/compile-fail/lint-unnecessary-parens.rs b/src/test/compile-fail/lint-unnecessary-parens.rs deleted file mode 100644 index 7cd0a6bbf0f..00000000000 --- a/src/test/compile-fail/lint-unnecessary-parens.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_parens)] - -#[derive(Eq, PartialEq)] -struct X { y: bool } -impl X { - fn foo(&self, conjunct: bool) -> bool { self.y && conjunct } -} - -fn foo() -> isize { - return (1); //~ ERROR unnecessary parentheses around `return` value -} -fn bar(y: bool) -> X { - return (X { y }); //~ ERROR unnecessary parentheses around `return` value -} - -fn main() { - foo(); - bar((true)); //~ ERROR unnecessary parentheses around function argument - - if (true) {} //~ ERROR unnecessary parentheses around `if` condition - while (true) {} //~ ERROR unnecessary parentheses around `while` condition - match (true) { //~ ERROR unnecessary parentheses around `match` head expression - _ => {} - } - if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` head expression - while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` head expression - let v = X { y: false }; - // struct lits needs parens, so these shouldn't warn. - if (v == X { y: true }) {} - if (X { y: true } == v) {} - if (X { y: false }.y) {} - - while (X { y: false }.foo(true)) {} - while (true | X { y: false }.y) {} - - match (X { y: false }) { - _ => {} - } - - X { y: false }.foo((true)); //~ ERROR unnecessary parentheses around method argument - - let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value - _a = (0); //~ ERROR unnecessary parentheses around assigned value - _a += (1); //~ ERROR unnecessary parentheses around assigned value -} diff --git a/src/test/compile-fail/lint-unsafe-code.rs b/src/test/compile-fail/lint-unsafe-code.rs deleted file mode 100644 index 10f245aaaf9..00000000000 --- a/src/test/compile-fail/lint-unsafe-code.rs +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_unsafe)] -#![allow(dead_code)] -#![deny(unsafe_code)] - -struct Bar; -struct Bar2; -struct Bar3; - -#[allow(unsafe_code)] -mod allowed_unsafe { - fn allowed() { unsafe {} } - unsafe fn also_allowed() {} - unsafe trait AllowedUnsafe { } - unsafe impl AllowedUnsafe for super::Bar {} -} - -macro_rules! unsafe_in_macro { - () => { - unsafe {} //~ ERROR: usage of an `unsafe` block - } -} - -unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function -unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait -unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait - -trait Baz { - unsafe fn baz(&self); //~ ERROR: declaration of an `unsafe` method - unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method - unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method -} - -impl Baz for Bar { - unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method - unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method -} - - -#[allow(unsafe_code)] -trait A { - unsafe fn allowed_unsafe(&self); - unsafe fn allowed_unsafe_provided(&self) {} -} - -#[allow(unsafe_code)] -impl Baz for Bar2 { - unsafe fn baz(&self) {} - unsafe fn provided_override(&self) {} -} - -impl Baz for Bar3 { - #[allow(unsafe_code)] - unsafe fn baz(&self) {} - unsafe fn provided_override(&self) {} //~ ERROR: implementation of an `unsafe` method -} - -#[allow(unsafe_code)] -unsafe trait B { - fn dummy(&self) {} -} - -trait C { - #[allow(unsafe_code)] - unsafe fn baz(&self); - unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method -} - -impl C for Bar { - #[allow(unsafe_code)] - unsafe fn baz(&self) {} - unsafe fn provided(&self) {} //~ ERROR: implementation of an `unsafe` method -} - -impl C for Bar2 { - unsafe fn baz(&self) {} //~ ERROR: implementation of an `unsafe` method -} - -trait D { - #[allow(unsafe_code)] - unsafe fn unsafe_provided(&self) {} -} - -impl D for Bar {} - -fn main() { - unsafe {} //~ ERROR: usage of an `unsafe` block - - unsafe_in_macro!() -} diff --git a/src/test/compile-fail/lint-unused-extern-crate.rs b/src/test/compile-fail/lint-unused-extern-crate.rs deleted file mode 100644 index 8f0b53fd599..00000000000 --- a/src/test/compile-fail/lint-unused-extern-crate.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lint_unused_extern_crate.rs -// aux-build:lint_unused_extern_crate2.rs -// aux-build:lint_unused_extern_crate3.rs -// aux-build:lint_unused_extern_crate4.rs -// aux-build:lint_unused_extern_crate5.rs - -#![deny(unused_extern_crates)] -#![allow(unused_variables)] -#![allow(deprecated)] - -extern crate lint_unused_extern_crate5; //~ ERROR: unused extern crate - -pub extern crate lint_unused_extern_crate4; // no error, it is re-exported - -extern crate lint_unused_extern_crate3; // no error, it is used - -extern crate lint_unused_extern_crate2; // no error, the use marks it as used - // even if imported objects aren't used - -extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used - -#[allow(unused_imports)] -use lint_unused_extern_crate2::foo as bar; - -use other::*; - -mod foo { - // Test that this is unused even though an earler `extern crate` is used. - extern crate lint_unused_extern_crate2; //~ ERROR unused extern crate -} - -fn main() { - lint_unused_extern_crate3::foo(); - let y = foo(); -} diff --git a/src/test/compile-fail/lint-unused-imports.rs b/src/test/compile-fail/lint-unused-imports.rs deleted file mode 100644 index 5bb2ab75c53..00000000000 --- a/src/test/compile-fail/lint-unused-imports.rs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_imports)] -#![allow(dead_code)] - -use bar::c::cc as cal; - -use std::mem::*; // shouldn't get errors for not using - // everything imported -use std::fmt::{}; -//~^ ERROR unused import: `use std::fmt::{};` - -// Should get errors for both 'Some' and 'None' -use std::option::Option::{Some, None}; -//~^ ERROR unused imports: `None`, `Some` - -use test::A; //~ ERROR unused import: `test::A` -// Be sure that if we just bring some methods into scope that they're also -// counted as being used. -use test::B; -// But only when actually used: do not get confused by the method with the same name. -use test::B2; //~ ERROR unused import: `test::B2` - -// Make sure this import is warned about when at least one of its imported names -// is unused -use test2::{foo, bar}; //~ ERROR unused import: `bar` - -mod test2 { - pub fn foo() {} - pub fn bar() {} -} - -mod test { - pub trait A { fn a(&self) {} } - pub trait B { fn b(&self) {} } - pub trait B2 { fn b(&self) {} } - pub struct C; - impl A for C {} - impl B for C {} -} - -mod foo { - pub struct Point{pub x: isize, pub y: isize} - pub struct Square{pub p: Point, pub h: usize, pub w: usize} -} - -mod bar { - // Don't ignore on 'pub use' because we're not sure if it's used or not - pub use std::cmp::PartialEq; - pub struct Square; - - pub mod c { - use foo::Point; - use foo::Square; //~ ERROR unused import: `foo::Square` - pub fn cc(_p: Point) -> super::Square { - fn f() -> super::Square { - super::Square - } - f() - } - } - - #[allow(unused_imports)] - mod foo { - use std::cmp::PartialEq; - } -} - -fn g() { - use self::g; //~ ERROR unused import: `self::g` - fn f() { - self::g(); - } -} - -// c.f. issue #35135 -#[allow(unused_variables)] -fn h() { - use test2::foo; //~ ERROR unused import: `test2::foo` - let foo = 0; -} - -fn main() { - cal(foo::Point{x:3, y:9}); - let mut a = 3; - let mut b = 4; - swap(&mut a, &mut b); - test::C.b(); - let _a = foo(); -} diff --git a/src/test/compile-fail/lint-unused-mut-self.rs b/src/test/compile-fail/lint-unused-mut-self.rs deleted file mode 100644 index 370f664e430..00000000000 --- a/src/test/compile-fail/lint-unused-mut-self.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_assignments)] -#![allow(unused_variables)] -#![allow(dead_code)] -#![deny(unused_mut)] - -struct Foo; -impl Foo { - fn foo(mut self) {} //~ ERROR: variable does not need to be mutable - fn bar(mut self: Box) {} //~ ERROR: variable does not need to be mutable -} - -fn main() {} diff --git a/src/test/compile-fail/lint-unused-mut-variables.rs b/src/test/compile-fail/lint-unused-mut-variables.rs deleted file mode 100644 index 14d836074dc..00000000000 --- a/src/test/compile-fail/lint-unused-mut-variables.rs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: lexical nll -#![cfg_attr(nll, feature(nll))] - -// Exercise the unused_mut attribute in some positive and negative cases - -#![allow(unused_assignments)] -#![allow(unused_variables)] -#![allow(dead_code)] -#![deny(unused_mut)] - - -fn main() { - // negative cases - let mut a = 3; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - let mut a = 2; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - let mut b = 3; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - let mut a = vec![3]; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - let (mut a, b) = (1, 2); //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - let mut a; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - a = 3; - - let mut b; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - if true { - b = 3; - } else { - b = 4; - } - - match 30 { - mut x => {} //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - } - match (30, 2) { - (mut x, 1) | //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - (mut x, 2) | - (mut x, 3) => { - } - _ => {} - } - - let x = |mut y: isize| 10; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - fn what(mut foo: isize) {} //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - - let mut a = &mut 5; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - *a = 4; - - let mut a = 5; - let mut b = (&mut a,); //[lexical]~ ERROR: variable does not need to be mutable - *b.0 = 4; //[nll]~^ ERROR: variable does not need to be mutable - - let mut x = &mut 1; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - let mut f = || { - *x += 1; - }; - f(); - - fn mut_ref_arg(mut arg : &mut [u8]) -> &mut [u8] { - &mut arg[..] //[lexical]~^ ERROR: variable does not need to be mutable - //[nll]~^^ ERROR: variable does not need to be mutable - } - - let mut v : &mut Vec<()> = &mut vec![]; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable - v.push(()); - - // positive cases - let mut a = 2; - a = 3; - let mut a = Vec::new(); - a.push(3); - let mut a = Vec::new(); - callback(|| { - a.push(3); - }); - let mut a = Vec::new(); - callback(|| { - callback(|| { - a.push(3); - }); - }); - let (mut a, b) = (1, 2); - a = 34; - - match 30 { - mut x => { - x = 21; - } - } - - match (30, 2) { - (mut x, 1) | - (mut x, 2) | - (mut x, 3) => { - x = 21 - } - _ => {} - } - - let x = |mut y: isize| y = 32; - fn nothing(mut foo: isize) { foo = 37; } - - // leading underscore should avoid the warning, just like the - // unused variable lint. - let mut _allowed = 1; -} - -fn callback(f: F) where F: FnOnce() {} - -// make sure the lint attribute can be turned off -#[allow(unused_mut)] -fn foo(mut a: isize) { - let mut a = 3; - let mut b = vec![2]; -} - -// make sure the lint attribute can be turned off on let statements -#[deny(unused_mut)] -fn bar() { - #[allow(unused_mut)] - let mut a = 3; - let mut b = vec![2]; //[lexical]~ ERROR: variable does not need to be mutable - //[nll]~^ ERROR: variable does not need to be mutable -} diff --git a/src/test/compile-fail/lint-uppercase-variables.rs b/src/test/compile-fail/lint-uppercase-variables.rs deleted file mode 100644 index 1d947684792..00000000000 --- a/src/test/compile-fail/lint-uppercase-variables.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![warn(unused)] -#![allow(dead_code)] -#![deny(non_snake_case)] - -mod foo { - pub enum Foo { Foo } -} - -struct Something { - X: usize //~ ERROR structure field `X` should have a snake case name such as `x` -} - -fn test(Xx: usize) { //~ ERROR variable `Xx` should have a snake case name such as `xx` - println!("{}", Xx); -} - -fn main() { - let Test: usize = 0; //~ ERROR variable `Test` should have a snake case name such as `test` - println!("{}", Test); - - match foo::Foo::Foo { - Foo => {} -//~^ ERROR variable `Foo` should have a snake case name such as `foo` -//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo` -//~^^^ WARN unused variable: `Foo` - } - - test(1); - - let _ = Something { X: 0 }; -} diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs b/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs deleted file mode 100644 index 7bc3680ca77..00000000000 --- a/src/test/compile-fail/liveness-assign-imm-local-in-loop.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - -fn test() { - let v: isize; - //[mir]~^ NOTE consider changing this to `mut v` - loop { - v = 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable variable - //[mir]~| NOTE cannot assign twice to immutable variable - v.clone(); // just to prevent liveness warnings - } -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs b/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs deleted file mode 100644 index 7812cdd8684..00000000000 --- a/src/test/compile-fail/liveness-assign-imm-local-in-op-eq.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - -fn test() { - let v: isize; - //[mir]~^ NOTE consider changing this to `mut v` - v = 2; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - v += 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable - v.clone(); -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-assign-imm-local-with-drop.rs b/src/test/compile-fail/liveness-assign-imm-local-with-drop.rs deleted file mode 100644 index bb61a9037d9..00000000000 --- a/src/test/compile-fail/liveness-assign-imm-local-with-drop.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - -fn test() { - let b = Box::new(1); //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| NOTE consider changing this to `mut b` - drop(b); - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable - drop(b); -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs b/src/test/compile-fail/liveness-assign-imm-local-with-init.rs deleted file mode 100644 index 672e9fab837..00000000000 --- a/src/test/compile-fail/liveness-assign-imm-local-with-init.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - -fn test() { - let v: isize = 1; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| NOTE consider changing this to `mut v` - v.clone(); - v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable - v.clone(); -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-closure-require-ret.rs b/src/test/compile-fail/liveness-closure-require-ret.rs deleted file mode 100644 index 17cd8231222..00000000000 --- a/src/test/compile-fail/liveness-closure-require-ret.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn force(f: F) -> isize where F: FnOnce() -> isize { f() } -fn main() { println!("{}", force(|| {})); } //~ ERROR mismatched types diff --git a/src/test/compile-fail/liveness-dead.rs b/src/test/compile-fail/liveness-dead.rs deleted file mode 100644 index ddd8fc68c43..00000000000 --- a/src/test/compile-fail/liveness-dead.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![deny(unused_assignments)] - -fn f1(x: &mut isize) { - *x = 1; // no error -} - -fn f2() { - let mut x: isize = 3; //~ ERROR: value assigned to `x` is never read - x = 4; - x.clone(); -} - -fn f3() { - let mut x: isize = 3; - x.clone(); - x = 4; //~ ERROR: value assigned to `x` is never read -} - -fn f4(mut x: i32) { //~ ERROR: value passed to `x` is never read - x = 4; - x.clone(); -} - -fn f5(mut x: i32) { - x.clone(); - x = 4; //~ ERROR: value assigned to `x` is never read -} - -fn main() {} diff --git a/src/test/compile-fail/liveness-forgot-ret.rs b/src/test/compile-fail/liveness-forgot-ret.rs deleted file mode 100644 index 1ee4be08a1c..00000000000 --- a/src/test/compile-fail/liveness-forgot-ret.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn god_exists(a: isize) -> bool { return god_exists(a); } - -fn f(a: isize) -> isize { if god_exists(a) { return 5; }; } -//~^ ERROR mismatched types - -fn main() { f(12); } diff --git a/src/test/compile-fail/liveness-issue-2163.rs b/src/test/compile-fail/liveness-issue-2163.rs deleted file mode 100644 index 69bceec8c32..00000000000 --- a/src/test/compile-fail/liveness-issue-2163.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::vec::Vec; - -fn main() { - let a: Vec = Vec::new(); - a.iter().all(|_| -> bool { - //~^ ERROR mismatched types - }); -} diff --git a/src/test/compile-fail/liveness-missing-ret2.rs b/src/test/compile-fail/liveness-missing-ret2.rs deleted file mode 100644 index a35eb1af4f3..00000000000 --- a/src/test/compile-fail/liveness-missing-ret2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() -> isize { //~ ERROR mismatched types - // Make sure typestate doesn't interpret this match expression as - // the function result - match true { true => { } _ => {} }; -} - -fn main() { } diff --git a/src/test/compile-fail/liveness-move-call-arg.rs b/src/test/compile-fail/liveness-move-call-arg.rs deleted file mode 100644 index 9340964c1fb..00000000000 --- a/src/test/compile-fail/liveness-move-call-arg.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn take(_x: Box) {} - -fn main() { - - let x: Box = box 25; - loop { - take(x); //~ ERROR use of moved value: `x` - } -} diff --git a/src/test/compile-fail/liveness-move-in-loop.rs b/src/test/compile-fail/liveness-move-in-loop.rs deleted file mode 100644 index 65ccaceac08..00000000000 --- a/src/test/compile-fail/liveness-move-in-loop.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn main() { - let y: Box = box 42; - let mut x: Box; - loop { - println!("{}", y); - loop { - loop { - loop { - x = y; //~ ERROR use of moved value - x.clone(); - } - } - } - } -} diff --git a/src/test/compile-fail/liveness-move-in-while.rs b/src/test/compile-fail/liveness-move-in-while.rs deleted file mode 100644 index cadfd487121..00000000000 --- a/src/test/compile-fail/liveness-move-in-while.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn main() { - let y: Box = box 42; - let mut x: Box; - loop { - println!("{}", y); //~ ERROR use of moved value: `y` - while true { while true { while true { x = y; x.clone(); } } } - //~^ ERROR use of moved value: `y` - } -} diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs deleted file mode 100644 index d056d6be806..00000000000 --- a/src/test/compile-fail/liveness-unused.rs +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![warn(unused)] -#![deny(unused_variables)] -#![deny(unused_assignments)] -#![allow(dead_code, non_camel_case_types, trivial_numeric_casts)] - -use std::ops::AddAssign; - -fn f1(x: isize) { - //~^ ERROR unused variable: `x` -} - -fn f1b(x: &mut isize) { - //~^ ERROR unused variable: `x` -} - -#[allow(unused_variables)] -fn f1c(x: isize) {} - -fn f1d() { - let x: isize; - //~^ ERROR unused variable: `x` -} - -fn f2() { - let x = 3; - //~^ ERROR unused variable: `x` -} - -fn f3() { - let mut x = 3; - //~^ ERROR variable `x` is assigned to, but never used - x += 4; - //~^ ERROR value assigned to `x` is never read -} - -fn f3b() { - let mut z = 3; - //~^ ERROR variable `z` is assigned to, but never used - loop { - z += 4; - } -} - -#[allow(unused_variables)] -fn f3c() { - let mut z = 3; - loop { z += 4; } -} - -#[allow(unused_variables)] -#[allow(unused_assignments)] -fn f3d() { - let mut x = 3; - x += 4; -} - -fn f4() { - match Some(3) { - Some(i) => { - //~^ ERROR unused variable: `i` - } - None => {} - } -} - -enum tri { - a(isize), b(isize), c(isize) -} - -fn f4b() -> isize { - match tri::a(3) { - tri::a(i) | tri::b(i) | tri::c(i) => { - i - } - } -} - -fn f5a() { - for x in 1..10 { } - //~^ ERROR unused variable: `x` -} - -fn f5b() { - for (x, _) in [1, 2, 3].iter().enumerate() { } - //~^ ERROR unused variable: `x` -} - -fn f5c() { - for (_, x) in [1, 2, 3].iter().enumerate() { - //~^ ERROR unused variable: `x` - continue; - drop(*x as i32); //~ WARNING unreachable statement - } -} - -struct View<'a>(&'a mut [i32]); - -impl<'a> AddAssign for View<'a> { - fn add_assign(&mut self, rhs: i32) { - for lhs in self.0.iter_mut() { - *lhs += rhs; - } - } -} - -fn f6() { - let mut array = [1, 2, 3]; - let mut v = View(&mut array); - - // ensure an error shows up for x even if lhs of an overloaded add assign - - let x; - //~^ ERROR variable `x` is assigned to, but never used - - *({ - x = 0; //~ ERROR value assigned to `x` is never read - &mut v - }) += 1; -} - - -struct MutRef<'a>(&'a mut i32); - -impl<'a> AddAssign for MutRef<'a> { - fn add_assign(&mut self, rhs: i32) { - *self.0 += rhs; - } -} - -fn f7() { - let mut a = 1; - { - // `b` does not trigger unused_variables - let mut b = MutRef(&mut a); - b += 1; - } - drop(a); -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-use-after-move.rs b/src/test/compile-fail/liveness-use-after-move.rs deleted file mode 100644 index 6fcab380030..00000000000 --- a/src/test/compile-fail/liveness-use-after-move.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn main() { - let x: Box<_> = box 5; - let y = x; - println!("{}", *x); //~ ERROR use of moved value: `*x` - y.clone(); -} diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs deleted file mode 100644 index 03d8d62e0b4..00000000000 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker; - -fn send(ch: _chan, data: T) { - println!("{:?}", ch); - println!("{:?}", data); - panic!(); -} - -#[derive(Debug)] -struct _chan(isize, marker::PhantomData); - -// Tests that "log(debug, message);" is flagged as using -// message after the send deinitializes it -fn test00_start(ch: _chan>, message: Box, _count: Box) { - send(ch, message); - println!("{}", message); //~ ERROR use of moved value: `message` -} - -fn main() { panic!(); } diff --git a/src/test/compile-fail/loop-break-value.rs b/src/test/compile-fail/loop-break-value.rs deleted file mode 100644 index 938f7fba2a0..00000000000 --- a/src/test/compile-fail/loop-break-value.rs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] - -fn main() { - let val: ! = loop { break break; }; - //~^ ERROR mismatched types - - loop { - if true { - break "asdf"; - } else { - break 123; //~ ERROR mismatched types - } - }; - - let _: i32 = loop { - break "asdf"; //~ ERROR mismatched types - }; - - let _: i32 = 'outer_loop: loop { - loop { - break 'outer_loop "nope"; //~ ERROR mismatched types - break "ok"; - }; - }; - - 'while_loop: while true { - break; - break (); //~ ERROR `break` with value from a `while` loop - loop { - break 'while_loop 123; - //~^ ERROR `break` with value from a `while` loop - break 456; - break 789; - }; - } - - while let Some(_) = Some(()) { - if break () { //~ ERROR `break` with value from a `while let` loop - } - } - - while let Some(_) = Some(()) { - break None; - //~^ ERROR `break` with value from a `while let` loop - } - - 'while_let_loop: while let Some(_) = Some(()) { - loop { - break 'while_let_loop "nope"; - //~^ ERROR `break` with value from a `while let` loop - break 33; - }; - } - - for _ in &[1,2,3] { - break (); //~ ERROR `break` with value from a `for` loop - break [()]; - //~^ ERROR `break` with value from a `for` loop - } - - 'for_loop: for _ in &[1,2,3] { - loop { - break Some(3); - break 'for_loop Some(17); - //~^ ERROR `break` with value from a `for` loop - }; - } - - let _: i32 = 'a: loop { - let _: () = 'b: loop { - break ('c: loop { - break; - break 'c 123; //~ ERROR mismatched types - }); - break 'a 123; - }; - }; - - loop { - break (break, break); //~ ERROR mismatched types - }; - - loop { - break; - break 2; //~ ERROR mismatched types - }; - - loop { - break 2; - break; //~ ERROR mismatched types - break 4; - }; -} diff --git a/src/test/compile-fail/loop-labeled-break-value.rs b/src/test/compile-fail/loop-labeled-break-value.rs deleted file mode 100644 index f0792c145d2..00000000000 --- a/src/test/compile-fail/loop-labeled-break-value.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - loop { - let _: i32 = loop { break }; //~ ERROR mismatched types - } - loop { - let _: i32 = 'inner: loop { break 'inner }; //~ ERROR mismatched types - } - loop { - let _: i32 = 'inner2: loop { loop { break 'inner2 } }; //~ ERROR mismatched types - } -} diff --git a/src/test/compile-fail/loop-proper-liveness.rs b/src/test/compile-fail/loop-proper-liveness.rs deleted file mode 100644 index e411313c273..00000000000 --- a/src/test/compile-fail/loop-proper-liveness.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test1() { - // In this test the outer 'a loop may terminate without `x` getting initialised. Although the - // `x = loop { ... }` statement is reached, the value itself ends up never being computed and - // thus leaving `x` uninit. - let x: i32; - 'a: loop { - x = loop { break 'a }; - } - println!("{:?}", x); //~ ERROR use of possibly uninitialized variable -} - -// test2 and test3 should not fail. -fn test2() { - // In this test the `'a` loop will never terminate thus making the use of `x` unreachable. - let x: i32; - 'a: loop { - x = loop { continue 'a }; - } - println!("{:?}", x); -} - -fn test3() { - let x: i32; - // Similarly, the use of variable `x` is unreachable. - 'a: loop { - x = loop { return }; - } - println!("{:?}", x); -} - -fn main() { -} diff --git a/src/test/compile-fail/loop-properly-diverging-2.rs b/src/test/compile-fail/loop-properly-diverging-2.rs deleted file mode 100644 index c22091ce63c..00000000000 --- a/src/test/compile-fail/loop-properly-diverging-2.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn forever2() -> i32 { - let x: i32 = loop { break }; //~ ERROR mismatched types - x -} - -fn main() {} diff --git a/src/test/compile-fail/lto-duplicate-symbols.rs b/src/test/compile-fail/lto-duplicate-symbols.rs deleted file mode 100644 index 9c1dbfc2af9..00000000000 --- a/src/test/compile-fail/lto-duplicate-symbols.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lto-duplicate-symbols1.rs -// aux-build:lto-duplicate-symbols2.rs -// error-pattern:Linking globals named 'foo': symbol multiply defined! -// compile-flags: -C lto -// no-prefer-dynamic - -extern crate lto_duplicate_symbols1; -extern crate lto_duplicate_symbols2; - -fn main() {} diff --git a/src/test/compile-fail/lub-if.rs b/src/test/compile-fail/lub-if.rs deleted file mode 100644 index 8d2a0fd07e8..00000000000 --- a/src/test/compile-fail/lub-if.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we correctly consider the type of `match` to be the LUB -// of the various arms, particularly in the case where regions are -// involved. - -pub fn opt_str0<'a>(maybestr: &'a Option) -> &'a str { - if maybestr.is_none() { - "(none)" - } else { - let s: &'a str = maybestr.as_ref().unwrap(); - s - } -} - -pub fn opt_str1<'a>(maybestr: &'a Option) -> &'a str { - if maybestr.is_some() { - let s: &'a str = maybestr.as_ref().unwrap(); - s - } else { - "(none)" - } -} - -pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { - if maybestr.is_none() { - "(none)" - } else { - let s: &'a str = maybestr.as_ref().unwrap(); - s //~ ERROR E0312 - } -} - -pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { - if maybestr.is_some() { - let s: &'a str = maybestr.as_ref().unwrap(); - s //~ ERROR E0312 - } else { - "(none)" - } -} - - -fn main() {} diff --git a/src/test/compile-fail/lub-match.rs b/src/test/compile-fail/lub-match.rs deleted file mode 100644 index b9423feb5c1..00000000000 --- a/src/test/compile-fail/lub-match.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we correctly consider the type of `match` to be the LUB -// of the various arms, particularly in the case where regions are -// involved. - -pub fn opt_str0<'a>(maybestr: &'a Option) -> &'a str { - match *maybestr { - Some(ref s) => { - let s: &'a str = s; - s - } - None => "(none)", - } -} - -pub fn opt_str1<'a>(maybestr: &'a Option) -> &'a str { - match *maybestr { - None => "(none)", - Some(ref s) => { - let s: &'a str = s; - s - } - } -} - -pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { - match *maybestr { - None => "(none)", - Some(ref s) => { - let s: &'a str = s; - s //~ ERROR E0312 - } - } -} - -pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { - match *maybestr { - Some(ref s) => { - let s: &'a str = s; - s //~ ERROR E0312 - } - None => "(none)", - } -} - -fn main() {} diff --git a/src/test/compile-fail/macro-attribute.rs b/src/test/compile-fail/macro-attribute.rs deleted file mode 100644 index a77b1724876..00000000000 --- a/src/test/compile-fail/macro-attribute.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[doc = $not_there] //~ ERROR arbitrary tokens in non-macro attributes are unstable -fn main() { } diff --git a/src/test/compile-fail/macro-comma-behavior.rs b/src/test/compile-fail/macro-comma-behavior.rs deleted file mode 100644 index 620e57b463d..00000000000 --- a/src/test/compile-fail/macro-comma-behavior.rs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Companion test to the similarly-named file in run-pass. - -// compile-flags: -C debug_assertions=yes -// revisions: std core - -#![cfg_attr(core, no_std)] - -#[cfg(std)] use std::fmt; -#[cfg(core)] use core::fmt; - -// (see documentation of the similarly-named test in run-pass) -fn to_format_or_not_to_format() { - let falsum = || false; - - // assert!(true, "{}",); // see run-pass - - assert_eq!(1, 1, "{}",); - //[core]~^ ERROR no arguments - //[std]~^^ ERROR no arguments - assert_ne!(1, 2, "{}",); - //[core]~^ ERROR no arguments - //[std]~^^ ERROR no arguments - - // debug_assert!(true, "{}",); // see run-pass - - debug_assert_eq!(1, 1, "{}",); - //[core]~^ ERROR no arguments - //[std]~^^ ERROR no arguments - debug_assert_ne!(1, 2, "{}",); - //[core]~^ ERROR no arguments - //[std]~^^ ERROR no arguments - - #[cfg(std)] { - eprint!("{}",); - //[std]~^ ERROR no arguments - } - - #[cfg(std)] { - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // eprintln!("{}",); - // [std]~^ ERROR no arguments - } - - #[cfg(std)] { - format!("{}",); - //[std]~^ ERROR no arguments - } - - format_args!("{}",); - //[core]~^ ERROR no arguments - //[std]~^^ ERROR no arguments - - // if falsum() { panic!("{}",); } // see run-pass - - #[cfg(std)] { - print!("{}",); - //[std]~^ ERROR no arguments - } - - #[cfg(std)] { - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // println!("{}",); - // [std]~^ ERROR no arguments - } - - unimplemented!("{}",); - //[core]~^ ERROR no arguments - //[std]~^^ ERROR no arguments - - // if falsum() { unreachable!("{}",); } // see run-pass - - struct S; - impl fmt::Display for S { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}",)?; - //[core]~^ ERROR no arguments - //[std]~^^ ERROR no arguments - - // FIXME: compile-fail says "expected error not found" even though - // rustc does emit an error - // writeln!(f, "{}",)?; - // [core]~^ ERROR no arguments - // [std]~^^ ERROR no arguments - Ok(()) - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/macro-comma-support.rs b/src/test/compile-fail/macro-comma-support.rs deleted file mode 100644 index e5fe9b4dd7f..00000000000 --- a/src/test/compile-fail/macro-comma-support.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This is a companion to the similarly-named test in run-pass. -// -// It tests macros that unavoidably produce compile errors. - -fn compile_error() { - compile_error!("lel"); //~ ERROR lel - compile_error!("lel",); //~ ERROR lel -} - -fn main() {} diff --git a/src/test/compile-fail/macro-crate-nonterminal-non-root.rs b/src/test/compile-fail/macro-crate-nonterminal-non-root.rs deleted file mode 100644 index 76211b88bd7..00000000000 --- a/src/test/compile-fail/macro-crate-nonterminal-non-root.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:macro_crate_nonterminal.rs - -mod foo { - #[macro_use] - extern crate macro_crate_nonterminal; //~ ERROR must be at the crate root -} - -fn main() { -} diff --git a/src/test/compile-fail/macro-error.rs b/src/test/compile-fail/macro-error.rs deleted file mode 100644 index 82a5aa48729..00000000000 --- a/src/test/compile-fail/macro-error.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - ($a:expr) => a; //~ ERROR macro rhs must be delimited -} - -fn main() { - foo!(0); // Check that we report errors at macro definition, not expansion. - - let _: cfg!(foo) = (); //~ ERROR non-type macro in type position -} diff --git a/src/test/compile-fail/macro-expanded-include/file.txt b/src/test/compile-fail/macro-expanded-include/file.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/test/compile-fail/macro-expanded-include/foo/mod.rs b/src/test/compile-fail/macro-expanded-include/foo/mod.rs deleted file mode 100644 index 888bdf5179a..00000000000 --- a/src/test/compile-fail/macro-expanded-include/foo/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -macro_rules! m { - () => { include!("file.txt"); } -} - -macro_rules! n { - () => { unsafe { asm!(include_str!("file.txt")); } } -} diff --git a/src/test/compile-fail/macro-expanded-include/test.rs b/src/test/compile-fail/macro-expanded-include/test.rs deleted file mode 100644 index 4afb61ab76c..00000000000 --- a/src/test/compile-fail/macro-expanded-include/test.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-emscripten no asm! support - -#![feature(asm, rustc_attrs)] -#![allow(unused)] - -#[macro_use] -mod foo; - -m!(); -fn f() { n!(); } - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/macro-expansion-tests.rs b/src/test/compile-fail/macro-expansion-tests.rs deleted file mode 100644 index 06f2d86e5d9..00000000000 --- a/src/test/compile-fail/macro-expansion-tests.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_macros)] - -mod macros_cant_escape_fns { - fn f() { - macro_rules! m { () => { 3 + 4 } } - } - fn g() -> i32 { m!() } - //~^ ERROR cannot find macro -} - -mod macros_cant_escape_mods { - mod f { - macro_rules! m { () => { 3 + 4 } } - } - fn g() -> i32 { m!() } - //~^ ERROR cannot find macro -} - -mod macros_can_escape_flattened_mods_test { - #[macro_use] - mod f { - macro_rules! m { () => { 3 + 4 } } - } - fn g() -> i32 { m!() } -} - -fn macro_tokens_should_match() { - macro_rules! m { (a) => { 13 } } - m!(a); -} - -// should be able to use a bound identifier as a literal in a macro definition: -fn self_macro_parsing() { - macro_rules! foo { (zz) => { 287; } } - fn f(zz: i32) { - foo!(zz); - } -} - -fn main() {} diff --git a/src/test/compile-fail/macro-follow.rs b/src/test/compile-fail/macro-follow.rs deleted file mode 100644 index 6e80e9b574b..00000000000 --- a/src/test/compile-fail/macro-follow.rs +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// Check the macro follow sets (see corresponding rpass test). - -#![allow(unused_macros)] - -// FOLLOW(pat) = {FatArrow, Comma, Eq, Or, Ident(if), Ident(in)} -macro_rules! follow_pat { - ($p:pat ()) => {}; //~ERROR `$p:pat` is followed by `(` - ($p:pat []) => {}; //~ERROR `$p:pat` is followed by `[` - ($p:pat {}) => {}; //~ERROR `$p:pat` is followed by `{` - ($p:pat :) => {}; //~ERROR `$p:pat` is followed by `:` - ($p:pat >) => {}; //~ERROR `$p:pat` is followed by `>` - ($p:pat +) => {}; //~ERROR `$p:pat` is followed by `+` - ($p:pat ident) => {}; //~ERROR `$p:pat` is followed by `ident` - ($p:pat $p:pat) => {}; //~ERROR `$p:pat` is followed by `$p:pat` - ($p:pat $e:expr) => {}; //~ERROR `$p:pat` is followed by `$e:expr` - ($p:pat $t:ty) => {}; //~ERROR `$p:pat` is followed by `$t:ty` - ($p:pat $s:stmt) => {}; //~ERROR `$p:pat` is followed by `$s:stmt` - ($p:pat $p:path) => {}; //~ERROR `$p:pat` is followed by `$p:path` - ($p:pat $b:block) => {}; //~ERROR `$p:pat` is followed by `$b:block` - ($p:pat $i:ident) => {}; //~ERROR `$p:pat` is followed by `$i:ident` - ($p:pat $t:tt) => {}; //~ERROR `$p:pat` is followed by `$t:tt` - ($p:pat $i:item) => {}; //~ERROR `$p:pat` is followed by `$i:item` - ($p:pat $m:meta) => {}; //~ERROR `$p:pat` is followed by `$m:meta` -} -// FOLLOW(expr) = {FatArrow, Comma, Semicolon} -macro_rules! follow_expr { - ($e:expr ()) => {}; //~ERROR `$e:expr` is followed by `(` - ($e:expr []) => {}; //~ERROR `$e:expr` is followed by `[` - ($e:expr {}) => {}; //~ERROR `$e:expr` is followed by `{` - ($e:expr =) => {}; //~ERROR `$e:expr` is followed by `=` - ($e:expr |) => {}; //~ERROR `$e:expr` is followed by `|` - ($e:expr :) => {}; //~ERROR `$e:expr` is followed by `:` - ($e:expr >) => {}; //~ERROR `$e:expr` is followed by `>` - ($e:expr +) => {}; //~ERROR `$e:expr` is followed by `+` - ($e:expr ident) => {}; //~ERROR `$e:expr` is followed by `ident` - ($e:expr if) => {}; //~ERROR `$e:expr` is followed by `if` - ($e:expr in) => {}; //~ERROR `$e:expr` is followed by `in` - ($e:expr $p:pat) => {}; //~ERROR `$e:expr` is followed by `$p:pat` - ($e:expr $e:expr) => {}; //~ERROR `$e:expr` is followed by `$e:expr` - ($e:expr $t:ty) => {}; //~ERROR `$e:expr` is followed by `$t:ty` - ($e:expr $s:stmt) => {}; //~ERROR `$e:expr` is followed by `$s:stmt` - ($e:expr $p:path) => {}; //~ERROR `$e:expr` is followed by `$p:path` - ($e:expr $b:block) => {}; //~ERROR `$e:expr` is followed by `$b:block` - ($e:expr $i:ident) => {}; //~ERROR `$e:expr` is followed by `$i:ident` - ($e:expr $t:tt) => {}; //~ERROR `$e:expr` is followed by `$t:tt` - ($e:expr $i:item) => {}; //~ERROR `$e:expr` is followed by `$i:item` - ($e:expr $m:meta) => {}; //~ERROR `$e:expr` is followed by `$m:meta` -} -// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or, -// Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)} -macro_rules! follow_ty { - ($t:ty ()) => {}; //~ERROR `$t:ty` is followed by `(` - ($t:ty []) => {}; // ok (RFC 1462) - ($t:ty +) => {}; //~ERROR `$t:ty` is followed by `+` - ($t:ty ident) => {}; //~ERROR `$t:ty` is followed by `ident` - ($t:ty if) => {}; //~ERROR `$t:ty` is followed by `if` - ($t:ty $p:pat) => {}; //~ERROR `$t:ty` is followed by `$p:pat` - ($t:ty $e:expr) => {}; //~ERROR `$t:ty` is followed by `$e:expr` - ($t:ty $t:ty) => {}; //~ERROR `$t:ty` is followed by `$t:ty` - ($t:ty $s:stmt) => {}; //~ERROR `$t:ty` is followed by `$s:stmt` - ($t:ty $p:path) => {}; //~ERROR `$t:ty` is followed by `$p:path` - ($t:ty $b:block) => {}; // ok (RFC 1494) - ($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident` - ($t:ty $t:tt) => {}; //~ERROR `$t:ty` is followed by `$t:tt` - ($t:ty $i:item) => {}; //~ERROR `$t:ty` is followed by `$i:item` - ($t:ty $m:meta) => {}; //~ERROR `$t:ty` is followed by `$m:meta` -} -// FOLLOW(stmt) = FOLLOW(expr) -macro_rules! follow_stmt { - ($s:stmt ()) => {}; //~ERROR `$s:stmt` is followed by `(` - ($s:stmt []) => {}; //~ERROR `$s:stmt` is followed by `[` - ($s:stmt {}) => {}; //~ERROR `$s:stmt` is followed by `{` - ($s:stmt =) => {}; //~ERROR `$s:stmt` is followed by `=` - ($s:stmt |) => {}; //~ERROR `$s:stmt` is followed by `|` - ($s:stmt :) => {}; //~ERROR `$s:stmt` is followed by `:` - ($s:stmt >) => {}; //~ERROR `$s:stmt` is followed by `>` - ($s:stmt +) => {}; //~ERROR `$s:stmt` is followed by `+` - ($s:stmt ident) => {}; //~ERROR `$s:stmt` is followed by `ident` - ($s:stmt if) => {}; //~ERROR `$s:stmt` is followed by `if` - ($s:stmt in) => {}; //~ERROR `$s:stmt` is followed by `in` - ($s:stmt $p:pat) => {}; //~ERROR `$s:stmt` is followed by `$p:pat` - ($s:stmt $e:expr) => {}; //~ERROR `$s:stmt` is followed by `$e:expr` - ($s:stmt $t:ty) => {}; //~ERROR `$s:stmt` is followed by `$t:ty` - ($s:stmt $s:stmt) => {}; //~ERROR `$s:stmt` is followed by `$s:stmt` - ($s:stmt $p:path) => {}; //~ERROR `$s:stmt` is followed by `$p:path` - ($s:stmt $b:block) => {}; //~ERROR `$s:stmt` is followed by `$b:block` - ($s:stmt $i:ident) => {}; //~ERROR `$s:stmt` is followed by `$i:ident` - ($s:stmt $t:tt) => {}; //~ERROR `$s:stmt` is followed by `$t:tt` - ($s:stmt $i:item) => {}; //~ERROR `$s:stmt` is followed by `$i:item` - ($s:stmt $m:meta) => {}; //~ERROR `$s:stmt` is followed by `$m:meta` -} -// FOLLOW(path) = FOLLOW(ty) -macro_rules! follow_path { - ($p:path ()) => {}; //~ERROR `$p:path` is followed by `(` - ($p:path []) => {}; // ok (RFC 1462) - ($p:path +) => {}; //~ERROR `$p:path` is followed by `+` - ($p:path ident) => {}; //~ERROR `$p:path` is followed by `ident` - ($p:path if) => {}; //~ERROR `$p:path` is followed by `if` - ($p:path $p:pat) => {}; //~ERROR `$p:path` is followed by `$p:pat` - ($p:path $e:expr) => {}; //~ERROR `$p:path` is followed by `$e:expr` - ($p:path $t:ty) => {}; //~ERROR `$p:path` is followed by `$t:ty` - ($p:path $s:stmt) => {}; //~ERROR `$p:path` is followed by `$s:stmt` - ($p:path $p:path) => {}; //~ERROR `$p:path` is followed by `$p:path` - ($p:path $b:block) => {}; // ok (RFC 1494) - ($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident` - ($p:path $t:tt) => {}; //~ERROR `$p:path` is followed by `$t:tt` - ($p:path $i:item) => {}; //~ERROR `$p:path` is followed by `$i:item` - ($p:path $m:meta) => {}; //~ERROR `$p:path` is followed by `$m:meta` -} -// FOLLOW(block) = any token -// FOLLOW(ident) = any token - -fn main() {} - diff --git a/src/test/compile-fail/macro-followed-by-seq-bad.rs b/src/test/compile-fail/macro-followed-by-seq-bad.rs deleted file mode 100644 index 21cc946ded6..00000000000 --- a/src/test/compile-fail/macro-followed-by-seq-bad.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #25436: check that things which can be -// followed by any token also permit X* to come afterwards. - -#![allow(unused_macros)] - -macro_rules! foo { - ( $a:expr $($b:tt)* ) => { }; //~ ERROR not allowed for `expr` fragments - ( $a:ty $($b:tt)* ) => { }; //~ ERROR not allowed for `ty` fragments -} - -fn main() { } diff --git a/src/test/compile-fail/macro-inner-attributes.rs b/src/test/compile-fail/macro-inner-attributes.rs deleted file mode 100644 index 1111b21d455..00000000000 --- a/src/test/compile-fail/macro-inner-attributes.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(custom_attribute)] - -macro_rules! test { ($nm:ident, - #[$a:meta], - $i:item) => (mod $nm { #![$a] $i }); } - -test!(a, - #[cfg(qux)], - pub fn bar() { }); - -test!(b, - #[cfg(not(qux))], - pub fn bar() { }); - -#[qux] -fn main() { - a::bar(); - //~^ ERROR failed to resolve. Use of undeclared type or module `a` - b::bar(); -} diff --git a/src/test/compile-fail/macro-input-future-proofing.rs b/src/test/compile-fail/macro-input-future-proofing.rs deleted file mode 100644 index e5fdba63b0f..00000000000 --- a/src/test/compile-fail/macro-input-future-proofing.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_macros)] - -macro_rules! errors_everywhere { - ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` - ($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty` - ($ty:ty , ) => (); - ( ( $ty:ty ) ) => (); - ( { $ty:ty } ) => (); - ( [ $ty:ty ] ) => (); - ($bl:block < ) => (); - ($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat` - ($pa:pat , ) => (); - ($pa:pat $pb:pat $ty:ty ,) => (); - //~^ ERROR `$pa:pat` is followed by `$pb:pat`, which is not allowed - //~^^ ERROR `$pb:pat` is followed by `$ty:ty`, which is not allowed - ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-` - ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-` - ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty` - ( $($a:expr)* $($b:tt)* ) => { }; - //~^ ERROR `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments -} - -fn main() { } diff --git a/src/test/compile-fail/macro-local-data-key-priv.rs b/src/test/compile-fail/macro-local-data-key-priv.rs deleted file mode 100644 index 3ae629cd895..00000000000 --- a/src/test/compile-fail/macro-local-data-key-priv.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// check that the local data keys are private by default. - -mod bar { - thread_local!(static baz: f64 = 0.0); -} - -fn main() { - bar::baz.with(|_| ()); - //~^ ERROR `baz` is private -} diff --git a/src/test/compile-fail/macro-match-nonterminal.rs b/src/test/compile-fail/macro-match-nonterminal.rs deleted file mode 100644 index 6cca729e2c2..00000000000 --- a/src/test/compile-fail/macro-match-nonterminal.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! test { ($a, $b) => (()); } //~ ERROR missing fragment - -fn main() { - test!() -} diff --git a/src/test/compile-fail/macro-missing-delimiters.rs b/src/test/compile-fail/macro-missing-delimiters.rs deleted file mode 100644 index eed2a207e89..00000000000 --- a/src/test/compile-fail/macro-missing-delimiters.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! baz( - baz => () //~ ERROR invalid macro matcher; -); - -fn main() { - baz!(baz); -} diff --git a/src/test/compile-fail/macro-missing-fragment.rs b/src/test/compile-fail/macro-missing-fragment.rs deleted file mode 100644 index 66f4ce55be8..00000000000 --- a/src/test/compile-fail/macro-missing-fragment.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! m { - ( $( any_token $field_rust_type )* ) => {}; //~ ERROR missing fragment -} - -fn main() { - m!(); -} diff --git a/src/test/compile-fail/macro-non-lifetime.rs b/src/test/compile-fail/macro-non-lifetime.rs deleted file mode 100644 index 647d7aaa759..00000000000 --- a/src/test/compile-fail/macro-non-lifetime.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for issue #50381: non-lifetime passed to :lifetime. - -#![feature(macro_lifetime_matcher)] - -macro_rules! m { ($x:lifetime) => { } } - -fn main() { - m!(a); - //~^ ERROR no rules expected the token `a` -} diff --git a/src/test/compile-fail/macro-outer-attributes.rs b/src/test/compile-fail/macro-outer-attributes.rs deleted file mode 100644 index acb58596fe4..00000000000 --- a/src/test/compile-fail/macro-outer-attributes.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(custom_attribute)] - -macro_rules! test { ($nm:ident, - #[$a:meta], - $i:item) => (mod $nm { #[$a] $i }); } - -test!(a, - #[cfg(qux)], - pub fn bar() { }); - -test!(b, - #[cfg(not(qux))], - pub fn bar() { }); - -// test1!(#[bar]) -#[qux] -fn main() { - a::bar(); //~ ERROR cannot find function `bar` in module `a` - b::bar(); -} diff --git a/src/test/compile-fail/macro-parameter-span.rs b/src/test/compile-fail/macro-parameter-span.rs deleted file mode 100644 index 3b168fec953..00000000000 --- a/src/test/compile-fail/macro-parameter-span.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - ($id: ident) => { - $id - } -} - -// Testing that the error span points to the parameter 'x' in the callsite, -// not to the macro variable '$id' -fn main() { - foo!( - x //~ ERROR cannot find value `x` in this scope - ); -} diff --git a/src/test/compile-fail/macro-stability.rs b/src/test/compile-fail/macro-stability.rs deleted file mode 100644 index a4b922c0fe1..00000000000 --- a/src/test/compile-fail/macro-stability.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:unstable-macros.rs - -#![feature(staged_api)] -#[macro_use] extern crate unstable_macros; - -#[unstable(feature = "local_unstable", issue = "0")] -macro_rules! local_unstable { () => () } - -fn main() { - local_unstable!(); - unstable_macro!(); //~ ERROR: macro unstable_macro! is unstable -} diff --git a/src/test/compile-fail/macro-stmt-matchers.rs b/src/test/compile-fail/macro-stmt-matchers.rs deleted file mode 100644 index 8f46d3301eb..00000000000 --- a/src/test/compile-fail/macro-stmt-matchers.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -#[rustc_error] -fn main() { //~ ERROR compilation successful - macro_rules! m { ($s:stmt;) => { $s } } - m!(vec![].push(0);); -} diff --git a/src/test/compile-fail/macro-tt-matchers.rs b/src/test/compile-fail/macro-tt-matchers.rs deleted file mode 100644 index 7255e7d00b6..00000000000 --- a/src/test/compile-fail/macro-tt-matchers.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -macro_rules! foo { - ($x:tt) => (type Alias = $x;) -} - -foo!(Box); - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/macro-use-bad-args-1.rs b/src/test/compile-fail/macro-use-bad-args-1.rs deleted file mode 100644 index a07cc834411..00000000000 --- a/src/test/compile-fail/macro-use-bad-args-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] - -#[allow(unused_extern_crates)] -#[macro_use(foo(bar))] //~ ERROR bad macro import -extern crate std; diff --git a/src/test/compile-fail/macro-use-bad-args-2.rs b/src/test/compile-fail/macro-use-bad-args-2.rs deleted file mode 100644 index 89004f16897..00000000000 --- a/src/test/compile-fail/macro-use-bad-args-2.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] - -#[allow(unused_extern_crates)] -#[macro_use(foo="bar")] //~ ERROR bad macro import -extern crate std; diff --git a/src/test/compile-fail/macro-use-scope.rs b/src/test/compile-fail/macro-use-scope.rs deleted file mode 100644 index 9d389413ba9..00000000000 --- a/src/test/compile-fail/macro-use-scope.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:two_macros.rs - -#![feature(rustc_attrs)] -#![allow(unused)] - -fn f() { - let _ = macro_one!(); -} -#[macro_use(macro_one)] // Check that this macro is usable in the above function -extern crate two_macros; - -fn g() { - macro_two!(); -} -macro_rules! m { () => { - #[macro_use(macro_two)] // Check that this macro is usable in the above function - extern crate two_macros as _two_macros; -} } -m!(); - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/macro-use-undef.rs b/src/test/compile-fail/macro-use-undef.rs deleted file mode 100644 index dd725aae95e..00000000000 --- a/src/test/compile-fail/macro-use-undef.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:two_macros.rs - -#[macro_use(macro_two, no_way)] //~ ERROR imported macro not found -extern crate two_macros; - -pub fn main() { - macro_two!(); -} diff --git a/src/test/compile-fail/macro-use-wrong-name.rs b/src/test/compile-fail/macro-use-wrong-name.rs deleted file mode 100644 index 143ecb4ce5e..00000000000 --- a/src/test/compile-fail/macro-use-wrong-name.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:two_macros.rs - -#[macro_use(macro_one)] -extern crate two_macros; - -pub fn main() { - macro_two!(); - //~^ ERROR cannot find macro -} diff --git a/src/test/compile-fail/macro-with-seps-err-msg.rs b/src/test/compile-fail/macro-with-seps-err-msg.rs deleted file mode 100644 index 1281adce5c5..00000000000 --- a/src/test/compile-fail/macro-with-seps-err-msg.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// gate-test-use_extern_macros - -fn main() { - globnar::brotz!(); //~ ERROR non-ident macro paths are experimental -} diff --git a/src/test/compile-fail/macros-in-extern.rs b/src/test/compile-fail/macros-in-extern.rs deleted file mode 100644 index 40053853b15..00000000000 --- a/src/test/compile-fail/macros-in-extern.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-wasm32 - -#![feature(decl_macro)] - -macro_rules! returns_isize( - ($ident:ident) => ( - fn $ident() -> isize; - ) -); - -macro takes_u32_returns_u32($ident:ident) { - fn $ident (arg: u32) -> u32; -} - -macro_rules! emits_nothing( - () => () -); - -fn main() { - assert_eq!(unsafe { rust_get_test_int() }, 0isize); - assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEFu32); -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - returns_isize!(rust_get_test_int); - //~^ ERROR macro invocations in `extern {}` blocks are experimental - takes_u32_returns_u32!(rust_dbg_extern_identity_u32); - //~^ ERROR macro invocations in `extern {}` blocks are experimental - emits_nothing!(); - //~^ ERROR macro invocations in `extern {}` blocks are experimental -} diff --git a/src/test/compile-fail/macros-nonfatal-errors.rs b/src/test/compile-fail/macros-nonfatal-errors.rs deleted file mode 100644 index 7046ee12b50..00000000000 --- a/src/test/compile-fail/macros-nonfatal-errors.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// test that errors in a (selection) of macros don't kill compilation -// immediately, so that we get more errors listed at a time. - -#![feature(asm)] -#![feature(trace_macros, concat_idents)] - -#[derive(Default)] //~ ERROR -enum OrDeriveThis {} - -fn main() { - asm!(invalid); //~ ERROR - - concat_idents!("not", "idents"); //~ ERROR - - option_env!(invalid); //~ ERROR - env!(invalid); //~ ERROR - env!(foo, abr, baz); //~ ERROR - env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); //~ ERROR - - foo::blah!(); //~ ERROR - - format!(invalid); //~ ERROR - - include!(invalid); //~ ERROR - - include_str!(invalid); //~ ERROR - include_str!("i'd be quite surprised if a file with this name existed"); //~ ERROR - include_bytes!(invalid); //~ ERROR - include_bytes!("i'd be quite surprised if a file with this name existed"); //~ ERROR - - trace_macros!(invalid); //~ ERROR -} diff --git a/src/test/compile-fail/main-wrong-type.rs b/src/test/compile-fail/main-wrong-type.rs deleted file mode 100644 index 402cd3a2d31..00000000000 --- a/src/test/compile-fail/main-wrong-type.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S { - x: isize, - y: isize, -} - -fn main(foo: S) { -//~^ ERROR: main function has wrong type [E0580] -} diff --git a/src/test/compile-fail/malformed-derive-entry.rs b/src/test/compile-fail/malformed-derive-entry.rs deleted file mode 100644 index ac000628f2b..00000000000 --- a/src/test/compile-fail/malformed-derive-entry.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Copy(Bad))] -//~^ ERROR expected one of `)`, `,`, or `::`, found `(` -struct Test1; - -#[derive(Copy="bad")] -//~^ ERROR expected one of `)`, `,`, or `::`, found `=` -struct Test2; - -#[derive()] -//~^ WARNING empty trait list -struct Test3; - -#[derive] -//~^ WARNING empty trait list -struct Test4; diff --git a/src/test/compile-fail/malformed-plugin-1.rs b/src/test/compile-fail/malformed-plugin-1.rs deleted file mode 100644 index 214a5e5e3eb..00000000000 --- a/src/test/compile-fail/malformed-plugin-1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(plugin)] -#![plugin] //~ ERROR malformed plugin attribute - -fn main() {} diff --git a/src/test/compile-fail/malformed-plugin-2.rs b/src/test/compile-fail/malformed-plugin-2.rs deleted file mode 100644 index 1b112608bee..00000000000 --- a/src/test/compile-fail/malformed-plugin-2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(plugin)] -#![plugin="bleh"] //~ ERROR malformed plugin attribute - -fn main() {} diff --git a/src/test/compile-fail/malformed-plugin-3.rs b/src/test/compile-fail/malformed-plugin-3.rs deleted file mode 100644 index 0c948831de2..00000000000 --- a/src/test/compile-fail/malformed-plugin-3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(plugin)] -#![plugin(foo="bleh")] //~ ERROR malformed plugin attribute - -fn main() {} diff --git a/src/test/compile-fail/malformed_macro_lhs.rs b/src/test/compile-fail/malformed_macro_lhs.rs deleted file mode 100644 index 0b437be5393..00000000000 --- a/src/test/compile-fail/malformed_macro_lhs.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! my_precioooous { - t => (1); //~ ERROR invalid macro matcher -} - -fn main() { - my_precioooous!(); -} diff --git a/src/test/compile-fail/manual-link-bad-form.rs b/src/test/compile-fail/manual-link-bad-form.rs deleted file mode 100644 index fc4fa838a56..00000000000 --- a/src/test/compile-fail/manual-link-bad-form.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-l static= -// error-pattern: empty library name given via `-l` - -fn main() { -} diff --git a/src/test/compile-fail/manual-link-bad-kind.rs b/src/test/compile-fail/manual-link-bad-kind.rs deleted file mode 100644 index e9cbdb09948..00000000000 --- a/src/test/compile-fail/manual-link-bad-kind.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-l bar=foo -// error-pattern: unknown library kind `bar`, expected one of dylib, framework, or static - -fn main() { -} diff --git a/src/test/compile-fail/manual-link-bad-search-path.rs b/src/test/compile-fail/manual-link-bad-search-path.rs deleted file mode 100644 index 2bf61cbe24c..00000000000 --- a/src/test/compile-fail/manual-link-bad-search-path.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-L native= -// error-pattern: empty search path given via `-L` - -fn main() { -} diff --git a/src/test/compile-fail/manual-link-framework.rs b/src/test/compile-fail/manual-link-framework.rs deleted file mode 100644 index 1ecf63813e9..00000000000 --- a/src/test/compile-fail/manual-link-framework.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-macos -// ignore-ios -// compile-flags:-l framework=foo -// error-pattern: native frameworks are only available on macOS targets - -fn main() { -} diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs deleted file mode 100644 index e8ff9e817af..00000000000 --- a/src/test/compile-fail/map-types.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -use std::collections::HashMap; - -trait Map -{ - fn get(&self, k: K) -> V { panic!() } -} - -impl Map for HashMap {} - -// Test that trait types printed in error msgs include the type arguments. - -fn main() { - let x: Box> = box HashMap::new(); - let x: Box> = x; - let y: Box> = Box::new(x); - //~^ ERROR `std::boxed::Box>: Map` is not satisfied -} diff --git a/src/test/compile-fail/match-argm-statics-2.rs b/src/test/compile-fail/match-argm-statics-2.rs deleted file mode 100644 index 70e148627c4..00000000000 --- a/src/test/compile-fail/match-argm-statics-2.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use self::Direction::{North, East, South, West}; - -#[derive(PartialEq, Eq)] -struct NewBool(bool); - -#[derive(PartialEq, Eq)] -enum Direction { - North, - East, - South, - West -} - -const TRUE_TRUE: (bool, bool) = (true, true); - -fn nonexhaustive_1() { - match (true, false) { - //~^ ERROR non-exhaustive patterns: `(true, false)` not covered - TRUE_TRUE => (), - (false, false) => (), - (false, true) => () - } -} - -const NONE: Option = None; -const EAST: Direction = East; - -fn nonexhaustive_2() { - match Some(Some(North)) { - //~^ ERROR non-exhaustive patterns: `Some(Some(West))` not covered - Some(NONE) => (), - Some(Some(North)) => (), - Some(Some(EAST)) => (), - Some(Some(South)) => (), - None => () - } -} - -const NEW_FALSE: NewBool = NewBool(false); -struct Foo { - bar: Option, - baz: NewBool -} - -const STATIC_FOO: Foo = Foo { bar: None, baz: NEW_FALSE }; - -fn nonexhaustive_3() { - match (Foo { bar: Some(North), baz: NewBool(true) }) { - //~^ ERROR non-exhaustive patterns: `Foo { bar: Some(North), baz: NewBool(true) }` - Foo { bar: None, baz: NewBool(true) } => (), - Foo { bar: _, baz: NEW_FALSE } => (), - Foo { bar: Some(West), baz: NewBool(true) } => (), - Foo { bar: Some(South), .. } => (), - Foo { bar: Some(EAST), .. } => () - } -} - -fn main() { - nonexhaustive_1(); - nonexhaustive_2(); - nonexhaustive_3(); -} - diff --git a/src/test/compile-fail/match-arm-statics.rs b/src/test/compile-fail/match-arm-statics.rs deleted file mode 100644 index 40d73ab51c7..00000000000 --- a/src/test/compile-fail/match-arm-statics.rs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![deny(unreachable_patterns)] - -use self::Direction::{North, East, South, West}; - -#[derive(PartialEq, Eq)] -struct NewBool(bool); - -#[derive(PartialEq, Eq)] -enum Direction { - North, - East, - South, - West -} - -const TRUE_TRUE: (bool, bool) = (true, true); - -fn unreachable_1() { - match (true, false) { - TRUE_TRUE => (), - (false, false) => (), - (false, true) => (), - (true, false) => (), - (true, true) => () - //~^ ERROR unreachable pattern - } -} - -const NONE: Option = None; -const EAST: Direction = East; - -fn unreachable_2() { - match Some(Some(North)) { - Some(NONE) => (), - Some(Some(North)) => (), - Some(Some(EAST)) => (), - Some(Some(South)) => (), - Some(Some(West)) => (), - Some(Some(East)) => (), - //~^ ERROR unreachable pattern - None => () - } -} - -const NEW_FALSE: NewBool = NewBool(false); -struct Foo { - bar: Option, - baz: NewBool -} - -fn unreachable_3() { - match (Foo { bar: Some(EAST), baz: NewBool(true) }) { - Foo { bar: None, baz: NewBool(true) } => (), - Foo { bar: _, baz: NEW_FALSE } => (), - Foo { bar: Some(West), baz: NewBool(true) } => (), - Foo { bar: Some(South), .. } => (), - Foo { bar: Some(EAST), .. } => (), - Foo { bar: Some(North), baz: NewBool(true) } => (), - Foo { bar: Some(EAST), baz: NewBool(false) } => () - //~^ ERROR unreachable pattern - } -} - -fn main() { - unreachable_1(); - unreachable_2(); - unreachable_3(); -} diff --git a/src/test/compile-fail/match-byte-array-patterns-2.rs b/src/test/compile-fail/match-byte-array-patterns-2.rs deleted file mode 100644 index abb770df107..00000000000 --- a/src/test/compile-fail/match-byte-array-patterns-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let buf = &[0, 1, 2, 3]; - - match buf { //~ ERROR non-exhaustive - b"AAAA" => {} - } - - let buf: &[u8] = buf; - - match buf { //~ ERROR non-exhaustive - b"AAAA" => {} - } -} - diff --git a/src/test/compile-fail/match-byte-array-patterns.rs b/src/test/compile-fail/match-byte-array-patterns.rs deleted file mode 100644 index 9db4319b786..00000000000 --- a/src/test/compile-fail/match-byte-array-patterns.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] -#![deny(unreachable_patterns)] - -fn main() { - let buf = &[0, 1, 2, 3]; - - match buf { - b"AAAA" => {}, - &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern - _ => {} - } - - match buf { - &[0x41, 0x41, 0x41, 0x41] => {} - b"AAAA" => {}, //~ ERROR unreachable pattern - _ => {} - } - - match buf { - &[_, 0x41, 0x41, 0x41] => {}, - b"AAAA" => {}, //~ ERROR unreachable pattern - _ => {} - } - - match buf { - &[0x41, .., 0x41] => {} - b"AAAA" => {}, //~ ERROR unreachable pattern - _ => {} - } - - let buf: &[u8] = buf; - - match buf { - b"AAAA" => {}, - &[0x41, 0x41, 0x41, 0x41] => {} //~ ERROR unreachable pattern - _ => {} - } - - match buf { - &[0x41, 0x41, 0x41, 0x41] => {} - b"AAAA" => {}, //~ ERROR unreachable pattern - _ => {} - } - - match buf { - &[_, 0x41, 0x41, 0x41] => {}, - b"AAAA" => {}, //~ ERROR unreachable pattern - _ => {} - } - - match buf { - &[0x41, .., 0x41] => {} - b"AAAA" => {}, //~ ERROR unreachable pattern - _ => {} - } -} diff --git a/src/test/compile-fail/match-ill-type2.rs b/src/test/compile-fail/match-ill-type2.rs deleted file mode 100644 index aa47ea670fd..00000000000 --- a/src/test/compile-fail/match-ill-type2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match 1i32 { - 1i32 => 1, - 2u32 => 1, //~ ERROR mismatched types - _ => 2, - }; -} diff --git a/src/test/compile-fail/match-join.rs b/src/test/compile-fail/match-join.rs deleted file mode 100644 index 888094fd016..00000000000 --- a/src/test/compile-fail/match-join.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// a good test that we merge paths correctly in the presence of a -// variable that's used before it's declared - -fn my_panic() -> ! { panic!(); } - -fn main() { - match true { false => { my_panic(); } true => { } } - - println!("{}", x); //~ ERROR cannot find value `x` in this scope - let x: isize; -} diff --git a/src/test/compile-fail/match-no-arms-unreachable-after.rs b/src/test/compile-fail/match-no-arms-unreachable-after.rs deleted file mode 100644 index db08f5e5e66..00000000000 --- a/src/test/compile-fail/match-no-arms-unreachable-after.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(warnings)] -#![deny(unreachable_code)] - -enum Void { } - -fn foo(v: Void) { - match v { } - let x = 2; //~ ERROR unreachable -} - -fn main() { -} diff --git a/src/test/compile-fail/match-non-exhaustive.rs b/src/test/compile-fail/match-non-exhaustive.rs deleted file mode 100644 index a24d2ed4b7f..00000000000 --- a/src/test/compile-fail/match-non-exhaustive.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match 0 { 1 => () } //~ ERROR non-exhaustive patterns - match 0 { 0 if false => () } //~ ERROR non-exhaustive patterns -} diff --git a/src/test/compile-fail/match-pattern-field-mismatch-2.rs b/src/test/compile-fail/match-pattern-field-mismatch-2.rs deleted file mode 100644 index aed9130d60e..00000000000 --- a/src/test/compile-fail/match-pattern-field-mismatch-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - enum color { - rgb(usize, usize, usize), - cmyk(usize, usize, usize, usize), - no_color, - } - - fn foo(c: color) { - match c { - color::rgb(_, _, _) => { } - color::cmyk(_, _, _, _) => { } - color::no_color(_) => { } - //~^ ERROR expected tuple struct/variant, found unit variant `color::no_color` - } - } -} diff --git a/src/test/compile-fail/match-pattern-field-mismatch.rs b/src/test/compile-fail/match-pattern-field-mismatch.rs deleted file mode 100644 index ddd5d633170..00000000000 --- a/src/test/compile-fail/match-pattern-field-mismatch.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - enum color { - rgb(usize, usize, usize), - cmyk(usize, usize, usize, usize), - no_color, - } - - fn foo(c: color) { - match c { - color::rgb(_, _) => { } - //~^ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields - color::cmyk(_, _, _, _) => { } - color::no_color => { } - } - } -} diff --git a/src/test/compile-fail/match-privately-empty.rs b/src/test/compile-fail/match-privately-empty.rs deleted file mode 100644 index 8777ef2ffe3..00000000000 --- a/src/test/compile-fail/match-privately-empty.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] -#![feature(exhaustive_patterns)] - -mod private { - pub struct Private { - _bot: !, - pub misc: bool, - } - pub const DATA: Option = None; -} - -fn main() { - match private::DATA { - //~^ ERROR non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered - None => {} - Some(private::Private { - misc: false, - .. - }) => {} - } -} diff --git a/src/test/compile-fail/match-range-fail-2.rs b/src/test/compile-fail/match-range-fail-2.rs deleted file mode 100644 index b42e2ff919a..00000000000 --- a/src/test/compile-fail/match-range-fail-2.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(exclusive_range_pattern)] - -fn main() { - match 5 { - 6 ..= 1 => { } - _ => { } - }; - //~^^^ ERROR lower range bound must be less than or equal to upper - - match 5 { - 0 .. 0 => { } - _ => { } - }; - //~^^^ ERROR lower range bound must be less than upper - - match 5u64 { - 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } - _ => { } - }; - //~^^^ ERROR lower range bound must be less than or equal to upper -} diff --git a/src/test/compile-fail/match-range-fail-dominate.rs b/src/test/compile-fail/match-range-fail-dominate.rs deleted file mode 100644 index 256aa180f4a..00000000000 --- a/src/test/compile-fail/match-range-fail-dominate.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//error-pattern: unreachable -//error-pattern: unreachable -//error-pattern: unreachable -//error-pattern: unreachable -//error-pattern: unreachable - -#![deny(unreachable_patterns)] - -fn main() { - match 5 { - 1 ... 10 => { } - 5 ... 6 => { } - _ => {} - }; - - match 5 { - 3 ... 6 => { } - 4 ... 6 => { } - _ => {} - }; - - match 5 { - 4 ... 6 => { } - 4 ... 6 => { } - _ => {} - }; - - match 'c' { - 'A' ... 'z' => {} - 'a' ... 'z' => {} - _ => {} - }; - - match 1.0f64 { - 0.01f64 ... 6.5f64 => {} - 0.02f64 => {} - _ => {} - }; -} diff --git a/src/test/compile-fail/match-range-fail.rs b/src/test/compile-fail/match-range-fail.rs deleted file mode 100644 index ca99b0c7b89..00000000000 --- a/src/test/compile-fail/match-range-fail.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match "wow" { - "bar" ..= "foo" => { } - }; - //~^^ ERROR only char and numeric types are allowed in range - //~| start type: &'static str - //~| end type: &'static str - - match "wow" { - 10 ..= "what" => () - }; - //~^^ ERROR only char and numeric types are allowed in range - //~| start type: {integer} - //~| end type: &'static str - - match 5 { - 'c' ..= 100 => { } - _ => { } - }; - //~^^^ ERROR mismatched types - //~| expected type `{integer}` - //~| found type `char` -} diff --git a/src/test/compile-fail/match-ref-ice.rs b/src/test/compile-fail/match-ref-ice.rs deleted file mode 100644 index cb8f8fad532..00000000000 --- a/src/test/compile-fail/match-ref-ice.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unreachable_patterns)] - -// The arity of `ref x` is always 1. If the pattern is compared to some non-structural type whose -// arity is always 0, an ICE occurs. -// -// Related issue: #23009 - -fn main() { - let homura = [1, 2, 3]; - - match homura { - [1, ref _madoka, 3] => (), - [1, 2, 3] => (), //~ ERROR unreachable pattern - [_, _, _] => (), - } -} diff --git a/src/test/compile-fail/match-ref-mut-invariance.rs b/src/test/compile-fail/match-ref-mut-invariance.rs deleted file mode 100644 index c2b54a972bd..00000000000 --- a/src/test/compile-fail/match-ref-mut-invariance.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that when making a ref mut binding with type `&mut T`, the -// type `T` must match precisely the type `U` of the value being -// matched, and in particular cannot be some supertype of `U`. Issue -// #23116. This test focuses on a `match`. - -#![allow(dead_code)] -struct S<'b>(&'b i32); -impl<'b> S<'b> { - fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { - match self.0 { ref mut x => x } //~ ERROR mismatched types - } -} - -fn main() {} diff --git a/src/test/compile-fail/match-ref-mut-let-invariance.rs b/src/test/compile-fail/match-ref-mut-let-invariance.rs deleted file mode 100644 index ea16c61dfd4..00000000000 --- a/src/test/compile-fail/match-ref-mut-let-invariance.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that when making a ref mut binding with type `&mut T`, the -// type `T` must match precisely the type `U` of the value being -// matched, and in particular cannot be some supertype of `U`. Issue -// #23116. This test focuses on a `let`. - -#![allow(dead_code)] -struct S<'b>(&'b i32); -impl<'b> S<'b> { - fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { - let ref mut x = self.0; - x //~ ERROR mismatched types - } -} - -fn main() {} diff --git a/src/test/compile-fail/match-slice-patterns.rs b/src/test/compile-fail/match-slice-patterns.rs deleted file mode 100644 index a8ec95da3d8..00000000000 --- a/src/test/compile-fail/match-slice-patterns.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] - -fn check(list: &[Option<()>]) { - match list { - //~^ ERROR `&[_, Some(_), None, _]` not covered - &[] => {}, - &[_] => {}, - &[_, _] => {}, - &[_, None, ..] => {}, - &[.., Some(_), _] => {}, - } -} - -fn main() {} diff --git a/src/test/compile-fail/match-static-const-lc.rs b/src/test/compile-fail/match-static-const-lc.rs deleted file mode 100644 index afc858c0c29..00000000000 --- a/src/test/compile-fail/match-static-const-lc.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #7526: lowercase static constants in patterns look like bindings - -#![allow(dead_code)] -#![deny(non_upper_case_globals)] - -#[allow(non_upper_case_globals)] -pub const a : isize = 97; - -fn f() { - let r = match (0,0) { - (0, a) => 0, - //~^ ERROR constant in pattern `a` should have an upper case name such as `A` - (x, y) => 1 + x + y, - }; - assert_eq!(r, 1); -} - -mod m { - #[allow(non_upper_case_globals)] - pub const aha : isize = 7; -} - -fn g() { - use self::m::aha; - let r = match (0,0) { - (0, aha) => 0, - //~^ ERROR constant in pattern `aha` should have an upper case name such as `AHA` - (x, y) => 1 + x + y, - }; - assert_eq!(r, 1); -} - -mod n { - pub const OKAY : isize = 8; -} - -fn h() { - use self::n::OKAY as not_okay; - let r = match (0,0) { - (0, not_okay) => 0, -//~^ ERROR constant in pattern `not_okay` should have an upper case name such as `NOT_OKAY` - (x, y) => 1 + x + y, - }; - assert_eq!(r, 1); -} - -fn main () { - f(); - g(); - h(); -} diff --git a/src/test/compile-fail/match-struct.rs b/src/test/compile-fail/match-struct.rs deleted file mode 100644 index 0dbdda1f9ba..00000000000 --- a/src/test/compile-fail/match-struct.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct S { a: isize } -enum E { C(isize) } - -fn main() { - match (S { a: 1 }) { - E::C(_) => (), - //~^ ERROR mismatched types - //~| expected type `S` - //~| found type `E` - //~| expected struct `S`, found enum `E` - _ => () - } -} diff --git a/src/test/compile-fail/match-tag-nullary.rs b/src/test/compile-fail/match-tag-nullary.rs deleted file mode 100644 index 0fb26200359..00000000000 --- a/src/test/compile-fail/match-tag-nullary.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -enum a { A, } -enum b { B, } - -fn main() { let x: a = a::A; match x { b::B => { } } } diff --git a/src/test/compile-fail/match-tag-unary.rs b/src/test/compile-fail/match-tag-unary.rs deleted file mode 100644 index 48733fd423d..00000000000 --- a/src/test/compile-fail/match-tag-unary.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -enum a { A(isize), } -enum b { B(isize), } - -fn main() { let x: a = a::A(0); match x { b::B(y) => { } } } diff --git a/src/test/compile-fail/match-unreachable-warning-with-diverging-discrim.rs b/src/test/compile-fail/match-unreachable-warning-with-diverging-discrim.rs deleted file mode 100644 index aae0f3135d8..00000000000 --- a/src/test/compile-fail/match-unreachable-warning-with-diverging-discrim.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_parens)] -#![deny(unreachable_code)] - -fn main() { - match (return) { } //~ ERROR unreachable expression -} diff --git a/src/test/compile-fail/match-unresolved-one-arm.rs b/src/test/compile-fail/match-unresolved-one-arm.rs deleted file mode 100644 index ea0f8db99e8..00000000000 --- a/src/test/compile-fail/match-unresolved-one-arm.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() -> T { panic!("Rocks for my pillow") } - -fn main() { - let x = match () { //~ ERROR type annotations needed - () => foo() // T here should be unresolved - }; -} diff --git a/src/test/compile-fail/match-vec-fixed.rs b/src/test/compile-fail/match-vec-fixed.rs deleted file mode 100644 index 05971d70167..00000000000 --- a/src/test/compile-fail/match-vec-fixed.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unreachable_patterns)] - -fn a() { - let v = [1, 2, 3]; - match v { - [_, _, _] => {} - [_, _, _] => {} //~ ERROR unreachable pattern - } - match v { - [_, 1, _] => {} - [_, 1, _] => {} //~ ERROR unreachable pattern - _ => {} - } -} - -fn main() { - a(); -} diff --git a/src/test/compile-fail/match-vec-mismatch-2.rs b/src/test/compile-fail/match-vec-mismatch-2.rs deleted file mode 100644 index 52c5375f4e7..00000000000 --- a/src/test/compile-fail/match-vec-mismatch-2.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match () { - [()] => { } - //~^ ERROR expected an array or slice, found `()` - } -} diff --git a/src/test/compile-fail/match-vec-mismatch.rs b/src/test/compile-fail/match-vec-mismatch.rs deleted file mode 100644 index d737aa0029b..00000000000 --- a/src/test/compile-fail/match-vec-mismatch.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] - -fn main() { - match "foo".to_string() { - ['f', 'o', ..] => {} - //~^ ERROR expected an array or slice, found `std::string::String` - _ => { } - }; - - // Note that this one works with default binding modes. - match &[0, 1, 2] { - [..] => {} - }; - - match &[0, 1, 2] { - &[..] => {} // ok - }; - - match [0, 1, 2] { - [0] => {}, //~ ERROR pattern requires - - [0, 1, x..] => { - let a: [_; 1] = x; - } - [0, 1, 2, 3, x..] => {} //~ ERROR pattern requires - }; - - match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope - [] => {} - }; -} - -fn another_fn_to_avoid_suppression() { - match Default::default() - { - [] => {} //~ ERROR type annotations needed - }; -} diff --git a/src/test/compile-fail/match-vec-unreachable.rs b/src/test/compile-fail/match-vec-unreachable.rs deleted file mode 100644 index d6e3fdbe088..00000000000 --- a/src/test/compile-fail/match-vec-unreachable.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] -#![deny(unreachable_patterns)] - -fn main() { - let x: Vec<(isize, isize)> = Vec::new(); - let x: &[(isize, isize)] = &x; - match *x { - [a, (2, 3), _] => (), - [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern - _ => () - } - - let x: Vec = vec!["foo".to_string(), - "bar".to_string(), - "baz".to_string()]; - let x: &[String] = &x; - match *x { - [ref a, _, _, ..] => { println!("{}", a); } - [_, _, _, _, _] => { } //~ ERROR unreachable pattern - _ => { } - } - - let x: Vec = vec!['a', 'b', 'c']; - let x: &[char] = &x; - match *x { - ['a', 'b', 'c', ref _tail..] => {} - ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern - _ => {} - } -} diff --git a/src/test/compile-fail/maybe-bounds-where-cpass.rs b/src/test/compile-fail/maybe-bounds-where-cpass.rs deleted file mode 100644 index f10526200ff..00000000000 --- a/src/test/compile-fail/maybe-bounds-where-cpass.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -struct S(*const T) where T: ?Sized; - -#[rustc_error] -fn main() { //~ ERROR compilation successful - let u = vec![1, 2, 3]; - let _s: S<[u8]> = S(&u[..]); -} diff --git a/src/test/compile-fail/maybe-bounds-where.rs b/src/test/compile-fail/maybe-bounds-where.rs deleted file mode 100644 index 211fac2ee23..00000000000 --- a/src/test/compile-fail/maybe-bounds-where.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S1(T) where (T): ?Sized; -//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared - -struct S2(T) where u8: ?Sized; -//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared - -struct S3(T) where &'static T: ?Sized; -//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared - -trait Trait<'a> {} - -struct S4(T) where for<'a> T: ?Trait<'a>; -//~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared - -struct S5(*const T) where T: ?Trait<'static> + ?Sized; -//~^ ERROR type parameter has more than one relaxed default bound -//~| WARN default bound relaxed for a type parameter - -impl S1 { - fn f() where T: ?Sized {} - //~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared -} - -fn main() { - let u = vec![1, 2, 3]; - let _s: S5<[u8]> = S5(&u[..]); // OK -} diff --git a/src/test/compile-fail/meta-expected-error-correct-rev.rs b/src/test/compile-fail/meta-expected-error-correct-rev.rs deleted file mode 100644 index bd70879d13e..00000000000 --- a/src/test/compile-fail/meta-expected-error-correct-rev.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: a - -// Counterpart to `meta-expected-error-wrong-rev.rs` - -#[cfg(a)] -fn foo() { - let x: u32 = 22_usize; //[a]~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/meta-expected-error-wrong-rev.rs b/src/test/compile-fail/meta-expected-error-wrong-rev.rs deleted file mode 100644 index 3c13050812c..00000000000 --- a/src/test/compile-fail/meta-expected-error-wrong-rev.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: a -// should-fail - -// This is a "meta-test" of the compilertest framework itself. In -// particular, it includes the right error message, but the message -// targets the wrong revision, so we expect the execution to fail. -// See also `meta-expected-error-correct-rev.rs`. - -#[cfg(a)] -fn foo() { - let x: u32 = 22_usize; //[b]~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs b/src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs deleted file mode 100644 index 9acf5a52166..00000000000 --- a/src/test/compile-fail/method-ambig-one-trait-unknown-int-type.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we invoking `foo()` successfully resolves to the trait `foo` -// (prompting the mismatched types error) but does not influence the choice -// of what kind of `Vec` we have, eventually leading to a type error. - -trait foo { - fn foo(&self) -> isize; -} - -impl foo for Vec { - fn foo(&self) -> isize {1} -} - -impl foo for Vec { - fn foo(&self) -> isize {2} -} - -// This is very hokey: we have heuristics to suppress messages about -// type annotations required. But placing these two bits of code into -// distinct functions, in this order, causes us to print out both -// errors I'd like to see. - -fn m1() { - // we couldn't infer the type of the vector just based on calling foo()... - let mut x = Vec::new(); - //~^ ERROR type annotations needed [E0282] - x.foo(); -} - -fn m2() { - let mut x = Vec::new(); - - // ...but we still resolved `foo()` to the trait and hence know the return type. - let y: usize = x.foo(); //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/method-ambig-two-traits-cross-crate.rs b/src/test/compile-fail/method-ambig-two-traits-cross-crate.rs deleted file mode 100644 index c1d4551fd9e..00000000000 --- a/src/test/compile-fail/method-ambig-two-traits-cross-crate.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test an ambiguity scenario where one copy of the method is available -// from a trait imported from another crate. - -// aux-build:ambig_impl_2_lib.rs -extern crate ambig_impl_2_lib; -use ambig_impl_2_lib::me; -trait me2 { - fn me(&self) -> usize; -} -impl me2 for usize { fn me(&self) -> usize { *self } } -fn main() { 1_usize.me(); } //~ ERROR E0034 diff --git a/src/test/compile-fail/method-ambig-two-traits-from-bounds.rs b/src/test/compile-fail/method-ambig-two-traits-from-bounds.rs deleted file mode 100644 index 184927c0135..00000000000 --- a/src/test/compile-fail/method-ambig-two-traits-from-bounds.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait A { fn foo(&self); } -trait B { fn foo(&self); } - -fn foo(t: T) { - t.foo(); //~ ERROR E0034 -} - -fn main() {} diff --git a/src/test/compile-fail/method-ambig-two-traits-with-default-method.rs b/src/test/compile-fail/method-ambig-two-traits-with-default-method.rs deleted file mode 100644 index 17312fb1869..00000000000 --- a/src/test/compile-fail/method-ambig-two-traits-with-default-method.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we correctly report an ambiguity where two applicable traits -// are in scope and the method being invoked is a default method not -// defined directly in the impl. - -trait Foo { fn method(&self) {} } -trait Bar { fn method(&self) {} } - -impl Foo for usize {} -impl Bar for usize {} - -fn main() { - 1_usize.method(); //~ ERROR E0034 -} diff --git a/src/test/compile-fail/method-call-lifetime-args-lint.rs b/src/test/compile-fail/method-call-lifetime-args-lint.rs deleted file mode 100644 index b2a94e0af42..00000000000 --- a/src/test/compile-fail/method-call-lifetime-args-lint.rs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(late_bound_lifetime_arguments)] -#![allow(unused)] - -struct S; - -impl S { - fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - fn late_implicit(self, _: &u8, _: &u8) {} - fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - - // 'late lifetimes here belong to nested types not to the tested functions. - fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8), - _: Box Fn(&'late u8)>) - -> &'a u8 { loop {} } - fn early_tricky_implicit<'a>(_: fn(&u8), - _: Box) - -> &'a u8 { loop {} } -} - -fn method_call() { - S.late(&0, &0); // OK - S.late::<'static>(&0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late::<'static, 'static>(&0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late::<'static, 'static, 'static>(&0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_early(&0); // OK - S.late_early::<'static>(&0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_early::<'static, 'static>(&0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_early::<'static, 'static, 'static>(&0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - - S.late_implicit(&0, &0); // OK - S.late_implicit::<'static>(&0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_implicit::<'static, 'static>(&0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_implicit::<'static, 'static, 'static>(&0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_implicit_early(&0); // OK - S.late_implicit_early::<'static>(&0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_implicit_early::<'static, 'static>(&0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - S.late_implicit_early::<'static, 'static, 'static>(&0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - - S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK - S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK -} - -fn ufcs() { - S::late_early::<'static>(S, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted - - S::late_implicit_early::<'static>(S, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted -} - -fn lint_not_inference_error() { - fn f<'early, 'late, T: 'early>() {} - - // Make sure `u8` is substituted and not replaced with an inference variable - f::<'static, u8>; - //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted -} - -fn main() {} diff --git a/src/test/compile-fail/method-call-lifetime-args-subst-index.rs b/src/test/compile-fail/method-call-lifetime-args-subst-index.rs deleted file mode 100644 index a9505e4f936..00000000000 --- a/src/test/compile-fail/method-call-lifetime-args-subst-index.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(unused)] - -struct S; - -impl S { - fn early_and_type<'a, T>(self) -> &'a T { loop {} } -} - -fn test() { - S.early_and_type::(); -} - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/method-call-lifetime-args-unresolved.rs b/src/test/compile-fail/method-call-lifetime-args-unresolved.rs deleted file mode 100644 index 4910bfaf4f6..00000000000 --- a/src/test/compile-fail/method-call-lifetime-args-unresolved.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - 0.clone::<'a>(); //~ ERROR use of undeclared lifetime name `'a` -} diff --git a/src/test/compile-fail/method-call-lifetime-args.rs b/src/test/compile-fail/method-call-lifetime-args.rs deleted file mode 100644 index f0a87c74703..00000000000 --- a/src/test/compile-fail/method-call-lifetime-args.rs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S; - -impl S { - fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - fn late_implicit(self, _: &u8, _: &u8) {} - fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } - fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } - fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } - fn life_and_type<'a, T>(self) -> &'a T { loop {} } -} - -fn method_call() { - S.early(); // OK - S.early::<'static>(); - //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter - S.early::<'static, 'static, 'static>(); - //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters - let _: &u8 = S.life_and_type::<'static>(); - S.life_and_type::(); - S.life_and_type::<'static, u8>(); -} - -fn ufcs() { - S::late(S, &0, &0); // OK - S::late::<'static>(S, &0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late::<'static, 'static>(S, &0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late::<'static, 'static, 'static>(S, &0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_early(S, &0); // OK - S::late_early::<'static, 'static>(S, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_early::<'static, 'static, 'static>(S, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - - S::late_implicit(S, &0, &0); // OK - S::late_implicit::<'static>(S, &0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_implicit::<'static, 'static>(S, &0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_implicit::<'static, 'static, 'static>(S, &0, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_implicit_early(S, &0); // OK - S::late_implicit_early::<'static, 'static>(S, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_implicit_early::<'static, 'static, 'static>(S, &0); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_implicit_self_early(&S); // OK - S::late_implicit_self_early::<'static, 'static>(&S); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_implicit_self_early::<'static, 'static, 'static>(&S); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_unused_early(S); // OK - S::late_unused_early::<'static, 'static>(S); - //~^ ERROR cannot specify lifetime arguments explicitly - S::late_unused_early::<'static, 'static, 'static>(S); - //~^ ERROR cannot specify lifetime arguments explicitly - - S::early(S); // OK - S::early::<'static>(S); - //~^ ERROR expected 2 lifetime parameters, found 1 lifetime parameter - S::early::<'static, 'static, 'static>(S); - //~^ ERROR expected at most 2 lifetime parameters, found 3 lifetime parameters - let _: &u8 = S::life_and_type::<'static>(S); - S::life_and_type::(S); - S::life_and_type::<'static, u8>(S); -} - -fn main() {} diff --git a/src/test/compile-fail/method-call-type-binding.rs b/src/test/compile-fail/method-call-type-binding.rs deleted file mode 100644 index 6c0793ee78f..00000000000 --- a/src/test/compile-fail/method-call-type-binding.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - 0.clone::(); //~ ERROR associated type bindings are not allowed here -} diff --git a/src/test/compile-fail/method-macro-backtrace.rs b/src/test/compile-fail/method-macro-backtrace.rs deleted file mode 100644 index f3c227849dc..00000000000 --- a/src/test/compile-fail/method-macro-backtrace.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// forbid-output: in this expansion of - -macro_rules! make_method { - ($name:ident) => ( fn $name(&self) { } ) -} - -struct S; - -impl S { - // We had a bug where these wouldn't clean up macro backtrace frames. - make_method!(foo1); - make_method!(foo2); - make_method!(foo3); - make_method!(foo4); - make_method!(foo5); - make_method!(foo6); - make_method!(foo7); - make_method!(foo8); - - // Cause an error. It shouldn't have any macro backtrace frames. - fn bar(&self) { } - fn bar(&self) { } //~ ERROR duplicate definitions -} - -fn main() { } diff --git a/src/test/compile-fail/method-path-in-pattern.rs b/src/test/compile-fail/method-path-in-pattern.rs deleted file mode 100644 index 671a518073c..00000000000 --- a/src/test/compile-fail/method-path-in-pattern.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo; - -impl Foo { - fn bar(&self) {} -} - -trait MyTrait { - fn trait_bar() {} -} - -impl MyTrait for Foo {} - -fn main() { - match 0u32 { - Foo::bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `::bar` - } - match 0u32 { - ::bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `::bar` - } - match 0u32 { - ::trait_bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `::trait_bar` - } -} diff --git a/src/test/compile-fail/method-resolvable-path-in-pattern.rs b/src/test/compile-fail/method-resolvable-path-in-pattern.rs deleted file mode 100644 index 4d8959466b9..00000000000 --- a/src/test/compile-fail/method-resolvable-path-in-pattern.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo; - -trait MyTrait { - fn trait_bar() {} -} - -impl MyTrait for Foo {} - -fn main() { - match 0u32 { - ::trait_bar => {} - //~^ ERROR expected unit struct/variant or constant, found method `MyTrait::trait_bar` - } -} diff --git a/src/test/compile-fail/method-self-arg-1.rs b/src/test/compile-fail/method-self-arg-1.rs deleted file mode 100644 index 4c8800878f0..00000000000 --- a/src/test/compile-fail/method-self-arg-1.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test method calls with self as an argument cannot subvert type checking. - -struct Foo; - -impl Foo { - fn bar(&self) {} -} - -fn main() { - let x = Foo; - Foo::bar(x); //~ ERROR mismatched types - //~| expected type `&Foo` - //~| found type `Foo` - //~| expected &Foo, found struct `Foo` - Foo::bar(&42); //~ ERROR mismatched types - //~| expected type `&Foo` - //~| found type `&{integer}` - //~| expected struct `Foo`, found integral variable -} diff --git a/src/test/compile-fail/method-self-arg-2.rs b/src/test/compile-fail/method-self-arg-2.rs deleted file mode 100644 index dd5b2004145..00000000000 --- a/src/test/compile-fail/method-self-arg-2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test method calls with self as an argument cannot subvert borrow checking. - -struct Foo; - -impl Foo { - fn bar(&self) {} - fn baz(&mut self) {} -} - -fn main() { - let mut x = Foo; - let y = &mut x; - Foo::bar(&x); //~ERROR cannot borrow `x` - - let mut x = Foo; - let y = &mut x; - Foo::baz(&mut x); //~ERROR cannot borrow `x` -} diff --git a/src/test/compile-fail/minus-string.rs b/src/test/compile-fail/minus-string.rs deleted file mode 100644 index 1ba30c67a03..00000000000 --- a/src/test/compile-fail/minus-string.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:cannot apply unary operator `-` to type `std::string::String` - -fn main() { -"foo".to_string(); } diff --git a/src/test/compile-fail/mir-dataflow/README.md b/src/test/compile-fail/mir-dataflow/README.md deleted file mode 100644 index a3ab14b23c7..00000000000 --- a/src/test/compile-fail/mir-dataflow/README.md +++ /dev/null @@ -1,53 +0,0 @@ -This directory contains unit tests for the MIR-based dataflow -analysis. - -These unit tests check the dataflow analysis by embedding calls to a -special `rustc_peek` intrinsic within the code, in tandem with an -attribute `#[rustc_mir(rustc_peek_maybe_init)]` (\*). With that -attribute in place, `rustc_peek` calls are a signal to the compiler to -lookup the computed dataflow state for the Lvalue corresponding to the -argument expression being fed to `rustc_peek`. If the dataflow state -for that Lvalue is a 1-bit at that point in the control flow, then no -error is emitted by the compiler at that point; if it is a 0-bit, then -that invocation of `rustc_peek` will emit an error with the message -"rustc_peek: bit not set". - -(\*): Or `#[rustc_mir(rustc_peek_maybe_uninit)]`, and perhaps other -variants in the future. - -The end effect is that one can write unit tests for MIR dataflow that -perform simple-queries of the computed dataflow state, and the tests -should be able to be robust in the face of changes to how MIR is -represented or constructed. - ----- - -Sometimes understanding the dataflow results is difficult without -looking at the actual MIR control-flow graph being processed with the -corresponding GEN and KILL sets. - -For a graphviz-rendering with dataflow annotations, add the attribute -`#[rustc_mir(borrowck_graphviz_postflow="/path/to/suffix.dot")]` to -the function in question. (You can change the content of -`"suffix.dot"` to control the filenames used for the output). This -will generate a separate file for each dataflow analysis, adding a -prefix (corresponding to the name of the analysis) to the filename in -each generated output path. - - * For example, the above attribute will currently cause two files to - be generated: `/path/to/maybe_init_suffix.dot` and - `/path/to/maybe_uninit_suffix.dot`. - - * The generated `.dot` file shows both the computed dataflow results - on *entry* to each block, as well as the gen- and kill-sets that - were so-called "transfer functions" summarizing the effect of each - basic block. - - * (In addition to the `borrowck_graphviz_postflow` attribute-key - noted above, there is also `borrowck_graphviz_preflow`; it has the - same interface and generates the same set of files, but it renders - the dataflow state after building the gen- and kill-sets but - *before* running the dataflow analysis itself, so each entry-set is - just the initial default state for that dataflow analysis. This is - less useful for understanding the error message output in these - tests.) diff --git a/src/test/compile-fail/mir-dataflow/def-inits-1.rs b/src/test/compile-fail/mir-dataflow/def-inits-1.rs deleted file mode 100644 index f5f0ede6864..00000000000 --- a/src/test/compile-fail/mir-dataflow/def-inits-1.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// General test of maybe_uninits state computed by MIR dataflow. - -#![feature(nll)] -#![feature(core_intrinsics, rustc_attrs)] - -use std::intrinsics::rustc_peek; -use std::mem::{drop, replace}; - -struct S(i32); - -#[rustc_mir(rustc_peek_definite_init,stop_after_dataflow)] -fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { - let ret; - // `ret` starts off uninitialized - unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set - - // All function formal parameters start off initialized. - - unsafe { rustc_peek(&x) }; - unsafe { rustc_peek(&y) }; - unsafe { rustc_peek(&z) }; - - ret = if test { - ::std::mem::replace(x, y) - } else { - z = y; - z - }; - - // `z` may be uninitialized here. - unsafe { rustc_peek(&z); } //~ ERROR rustc_peek: bit not set - - // `y` is definitely uninitialized here. - unsafe { rustc_peek(&y); } //~ ERROR rustc_peek: bit not set - - // `x` is still (definitely) initialized (replace above is a reborrow). - unsafe { rustc_peek(&x); } - - ::std::mem::drop(x); - - // `x` is *definitely* uninitialized here - unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set - - // `ret` is now definitely initialized (via `if` above). - unsafe { rustc_peek(&ret); } - - ret -} -fn main() { - foo(true, &mut S(13), S(14), S(15)); - foo(false, &mut S(13), S(14), S(15)); -} diff --git a/src/test/compile-fail/mir-dataflow/inits-1.rs b/src/test/compile-fail/mir-dataflow/inits-1.rs deleted file mode 100644 index 595f01f7c94..00000000000 --- a/src/test/compile-fail/mir-dataflow/inits-1.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// General test of maybe_inits state computed by MIR dataflow. - -#![feature(nll)] -#![feature(core_intrinsics, rustc_attrs)] - -use std::intrinsics::rustc_peek; -use std::mem::{drop, replace}; - -struct S(i32); - -#[rustc_mir(rustc_peek_maybe_init,stop_after_dataflow)] -fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { - let ret; - // `ret` starts off uninitialized, so we get an error report here. - unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set - - // All function formal parameters start off initialized. - - unsafe { rustc_peek(&x) }; - unsafe { rustc_peek(&y) }; - unsafe { rustc_peek(&z) }; - - ret = if test { - ::std::mem::replace(x, y) - } else { - z = y; - z - }; - - - // `z` may be initialized here. - unsafe { rustc_peek(&z); } - - // `y` is definitely uninitialized here. - unsafe { rustc_peek(&y); } //~ ERROR rustc_peek: bit not set - - // `x` is still (definitely) initialized (replace above is a reborrow). - unsafe { rustc_peek(&x); } - - ::std::mem::drop(x); - - // `x` is *definitely* uninitialized here - unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set - - // `ret` is now definitely initialized (via `if` above). - unsafe { rustc_peek(&ret); } - - ret -} - -fn main() { - foo(true, &mut S(13), S(14), S(15)); - foo(false, &mut S(13), S(14), S(15)); -} diff --git a/src/test/compile-fail/mir-dataflow/uninits-1.rs b/src/test/compile-fail/mir-dataflow/uninits-1.rs deleted file mode 100644 index bb10c03254e..00000000000 --- a/src/test/compile-fail/mir-dataflow/uninits-1.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// General test of maybe_uninits state computed by MIR dataflow. - -#![feature(nll)] -#![feature(core_intrinsics, rustc_attrs)] - -use std::intrinsics::rustc_peek; -use std::mem::{drop, replace}; - -struct S(i32); - -#[rustc_mir(rustc_peek_maybe_uninit,stop_after_dataflow)] -fn foo(test: bool, x: &mut S, y: S, mut z: S) -> S { - let ret; - // `ret` starts off uninitialized - unsafe { rustc_peek(&ret); } - - // All function formal parameters start off initialized. - - unsafe { rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set - unsafe { rustc_peek(&y) }; //~ ERROR rustc_peek: bit not set - unsafe { rustc_peek(&z) }; //~ ERROR rustc_peek: bit not set - - ret = if test { - ::std::mem::replace(x, y) - } else { - z = y; - z - }; - - // `z` may be uninitialized here. - unsafe { rustc_peek(&z); } - - // `y` is definitely uninitialized here. - unsafe { rustc_peek(&y); } - - // `x` is still (definitely) initialized (replace above is a reborrow). - unsafe { rustc_peek(&x); } //~ ERROR rustc_peek: bit not set - - ::std::mem::drop(x); - - // `x` is *definitely* uninitialized here - unsafe { rustc_peek(&x); } - - // `ret` is now definitely initialized (via `if` above). - unsafe { rustc_peek(&ret); } //~ ERROR rustc_peek: bit not set - - ret -} -fn main() { - foo(true, &mut S(13), S(14), S(15)); - foo(false, &mut S(13), S(14), S(15)); -} diff --git a/src/test/compile-fail/mir-dataflow/uninits-2.rs b/src/test/compile-fail/mir-dataflow/uninits-2.rs deleted file mode 100644 index 9854ea779b3..00000000000 --- a/src/test/compile-fail/mir-dataflow/uninits-2.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// General test of maybe_uninits state computed by MIR dataflow. - -#![feature(nll)] -#![feature(core_intrinsics, rustc_attrs)] - -use std::intrinsics::rustc_peek; -use std::mem::{drop, replace}; - -struct S(i32); - -#[rustc_mir(rustc_peek_maybe_uninit,stop_after_dataflow)] -fn foo(x: &mut S) { - // `x` is initialized here, so maybe-uninit bit is 0. - - unsafe { rustc_peek(&x) }; //~ ERROR rustc_peek: bit not set - - ::std::mem::drop(x); - - // `x` definitely uninitialized here, so maybe-uninit bit is 1. - unsafe { rustc_peek(&x) }; -} -fn main() { - foo(&mut S(13)); - foo(&mut S(13)); -} diff --git a/src/test/compile-fail/mir-unpretty.rs b/src/test/compile-fail/mir-unpretty.rs deleted file mode 100644 index fa936502157..00000000000 --- a/src/test/compile-fail/mir-unpretty.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z unpretty=mir - -fn main() { - let x: () = 0; //~ ERROR: mismatched types -} diff --git a/src/test/compile-fail/missing-derivable-attr.rs b/src/test/compile-fail/missing-derivable-attr.rs deleted file mode 100644 index 7eee51e4076..00000000000 --- a/src/test/compile-fail/missing-derivable-attr.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait MyEq { - fn eq(&self, other: &Self) -> bool; -} - -struct A { - x: isize -} - -impl MyEq for isize { - fn eq(&self, other: &isize) -> bool { *self == *other } -} - -impl MyEq for A {} //~ ERROR not all trait items implemented, missing: `eq` - -fn main() { -} diff --git a/src/test/compile-fail/missing-macro-use.rs b/src/test/compile-fail/missing-macro-use.rs deleted file mode 100644 index bfe49ea0009..00000000000 --- a/src/test/compile-fail/missing-macro-use.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:two_macros.rs - -extern crate two_macros; - -pub fn main() { - macro_two!(); - //~^ ERROR cannot find macro `macro_two!` in this scope -} diff --git a/src/test/compile-fail/missing-main.rs b/src/test/compile-fail/missing-main.rs deleted file mode 100644 index 2788a5c2d58..00000000000 --- a/src/test/compile-fail/missing-main.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: `main` function not found -fn mian() { } diff --git a/src/test/compile-fail/missing-return.rs b/src/test/compile-fail/missing-return.rs deleted file mode 100644 index efd0c827a35..00000000000 --- a/src/test/compile-fail/missing-return.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: return - -fn f() -> isize { } - -fn main() { f(); } diff --git a/src/test/compile-fail/missing-semicolon-warning.rs b/src/test/compile-fail/missing-semicolon-warning.rs deleted file mode 100644 index bbc958b87a5..00000000000 --- a/src/test/compile-fail/missing-semicolon-warning.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(unused)] - -macro_rules! m { - ($($e1:expr),*; $($e2:expr),*) => { - $( let x = $e1 )*; //~ WARN expected `;` - $( println!("{}", $e2) )*; //~ WARN expected `;` - } -} - -#[rustc_error] -fn main() { m!(0, 0; 0, 0); } //~ ERROR compilation successful diff --git a/src/test/compile-fail/missing-stability.rs b/src/test/compile-fail/missing-stability.rs deleted file mode 100644 index 1922efb5e19..00000000000 --- a/src/test/compile-fail/missing-stability.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks that exported items without stability attributes cause an error - -#![crate_type="lib"] -#![feature(staged_api)] - -#![stable(feature = "stable_test_feature", since = "1.0.0")] - -pub fn unmarked() { - //~^ ERROR This node does not have a stability attribute - () -} - -#[unstable(feature = "unstable_test_feature", issue = "0")] -pub mod foo { - // #[unstable] is inherited - pub fn unmarked() {} -} - -#[stable(feature = "stable_test_feature", since="1.0.0")] -pub mod bar { - // #[stable] is not inherited - pub fn unmarked() {} - //~^ ERROR This node does not have a stability attribute -} diff --git a/src/test/compile-fail/missing_debug_impls.rs b/src/test/compile-fail/missing_debug_impls.rs deleted file mode 100644 index ddc9081e33b..00000000000 --- a/src/test/compile-fail/missing_debug_impls.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --crate-type lib -#![deny(missing_debug_implementations)] -#![allow(unused)] - -use std::fmt; - -pub enum A {} //~ ERROR type does not implement `fmt::Debug` - -#[derive(Debug)] -pub enum B {} - -pub enum C {} - -impl fmt::Debug for C { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - Ok(()) - } -} - -pub struct Foo; //~ ERROR type does not implement `fmt::Debug` - -#[derive(Debug)] -pub struct Bar; - -pub struct Baz; - -impl fmt::Debug for Baz { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - Ok(()) - } -} - -struct PrivateStruct; - -enum PrivateEnum {} - -#[derive(Debug)] -struct GenericType(T); diff --git a/src/test/compile-fail/mod_file_aux.rs b/src/test/compile-fail/mod_file_aux.rs deleted file mode 100644 index b7470811f60..00000000000 --- a/src/test/compile-fail/mod_file_aux.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test Not a test. Used by other tests - -pub fn foo() -> isize { 10 } diff --git a/src/test/compile-fail/mod_file_correct_spans.rs b/src/test/compile-fail/mod_file_correct_spans.rs deleted file mode 100644 index 52837479869..00000000000 --- a/src/test/compile-fail/mod_file_correct_spans.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Testing that the codemap is maintained correctly when parsing mods from external files - -mod mod_file_aux; - -fn main() { - assert!(mod_file_aux::bar() == 10); - //~^ ERROR cannot find function `bar` in module `mod_file_aux` -} diff --git a/src/test/compile-fail/mod_file_disambig.rs b/src/test/compile-fail/mod_file_disambig.rs deleted file mode 100644 index 27c253234be..00000000000 --- a/src/test/compile-fail/mod_file_disambig.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both - -fn main() { - assert_eq!(mod_file_aux::bar(), 10); -} diff --git a/src/test/compile-fail/mod_file_disambig_aux.rs b/src/test/compile-fail/mod_file_disambig_aux.rs deleted file mode 100644 index f617b293463..00000000000 --- a/src/test/compile-fail/mod_file_disambig_aux.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test not a test. aux file diff --git a/src/test/compile-fail/mod_file_disambig_aux/mod.rs b/src/test/compile-fail/mod_file_disambig_aux/mod.rs deleted file mode 100644 index f617b293463..00000000000 --- a/src/test/compile-fail/mod_file_disambig_aux/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test not a test. aux file diff --git a/src/test/compile-fail/module-macro_use-arguments.rs b/src/test/compile-fail/module-macro_use-arguments.rs deleted file mode 100644 index 6d3038b4820..00000000000 --- a/src/test/compile-fail/module-macro_use-arguments.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use(foo, bar)] //~ ERROR arguments to macro_use are not allowed here -mod foo { -} - -fn main() { -} diff --git a/src/test/compile-fail/move-guard-same-consts.rs b/src/test/compile-fail/move-guard-same-consts.rs deleted file mode 100644 index 05fe48e0199..00000000000 --- a/src/test/compile-fail/move-guard-same-consts.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// #47295: We used to have a hack of special-casing adjacent amtch -// arms whose patterns were composed solely of constants to not have -// them linked in the cfg. -// -// THis was broken for various reasons. In particular, that hack was -// originally authored under the assunption that other checks -// elsewhere would ensure that the two patterns did not overlap. But -// that assumption did not hold, at least not in the long run (namely, -// overlapping patterns were turned into warnings rather than errors). - -#![feature(box_syntax)] - -fn main() { - let x: Box<_> = box 1; - - let v = (1, 2); - - match v { - (1, 2) if take(x) => (), - (1, 2) if take(x) => (), //~ ERROR use of moved value: `x` - _ => (), - } -} - -fn take(_: T) -> bool { false } diff --git a/src/test/compile-fail/move-in-guard-1.rs b/src/test/compile-fail/move-in-guard-1.rs deleted file mode 100644 index 068bfa3cd7c..00000000000 --- a/src/test/compile-fail/move-in-guard-1.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -pub fn main() { - let x: Box<_> = box 1; - - let v = (1, 2); - - match v { - (1, _) if take(x) => (), - (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` - _ => (), - } -} - -fn take(_: T) -> bool { false } diff --git a/src/test/compile-fail/move-in-guard-2.rs b/src/test/compile-fail/move-in-guard-2.rs deleted file mode 100644 index 984963b2f83..00000000000 --- a/src/test/compile-fail/move-in-guard-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -pub fn main() { - let x: Box<_> = box 1; - - let v = (1, 2); - - match v { - (1, _) | - (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` - _ => (), - } -} - -fn take(_: T) -> bool { false } diff --git a/src/test/compile-fail/move-into-dead-array-1.rs b/src/test/compile-fail/move-into-dead-array-1.rs deleted file mode 100644 index 61ccb694fd2..00000000000 --- a/src/test/compile-fail/move-into-dead-array-1.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that we cannot move into an uninitialized fixed-size array. - -struct D { _x: u8 } - -fn d() -> D { D { _x: 0 } } - -fn main() { - foo(1); - foo(3); -} - -fn foo(i: usize) { - let mut a: [D; 4]; - a[i] = d(); //~ ERROR use of possibly uninitialized variable: `a` -} diff --git a/src/test/compile-fail/move-into-dead-array-2.rs b/src/test/compile-fail/move-into-dead-array-2.rs deleted file mode 100644 index d484837c001..00000000000 --- a/src/test/compile-fail/move-into-dead-array-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that we cannot move into an uninitialized fixed-size array. - -struct D { _x: u8 } - -fn d() -> D { D { _x: 0 } } - -fn main() { - foo([d(), d(), d(), d()], 1); - foo([d(), d(), d(), d()], 3); -} - -fn foo(mut a: [D; 4], i: usize) { - drop(a); - a[i] = d(); //~ ERROR use of moved value: `a` -} diff --git a/src/test/compile-fail/move-out-of-array-1.rs b/src/test/compile-fail/move-out-of-array-1.rs deleted file mode 100644 index 796b13538b2..00000000000 --- a/src/test/compile-fail/move-out-of-array-1.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that we cannot move out of a fixed-size array (especially -// when the element type has a destructor). - - -struct D { _x: u8 } - -impl Drop for D { fn drop(&mut self) { } } - -fn main() { - fn d() -> D { D { _x: 0 } } - - let _d1 = foo([d(), d(), d(), d()], 1); - let _d3 = foo([d(), d(), d(), d()], 3); -} - -fn foo(a: [D; 4], i: usize) -> D { - a[i] //~ ERROR cannot move out of type `[D; 4]`, a non-copy array -} diff --git a/src/test/compile-fail/move-out-of-slice-1.rs b/src/test/compile-fail/move-out-of-slice-1.rs deleted file mode 100644 index 5efbef549dd..00000000000 --- a/src/test/compile-fail/move-out-of-slice-1.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_patterns)] - -struct A; - -fn main() { - let a: Box<[A]> = Box::new([A]); - match a { - box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice - _ => {} - } -} diff --git a/src/test/compile-fail/move-out-of-tuple-field.rs b/src/test/compile-fail/move-out-of-tuple-field.rs deleted file mode 100644 index b7393666719..00000000000 --- a/src/test/compile-fail/move-out-of-tuple-field.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct Foo(Box); - -fn main() { - let x: (Box<_>,) = (box 1,); - let y = x.0; - let z = x.0; //~ ERROR use of moved value: `x.0` - - let x = Foo(box 1); - let y = x.0; - let z = x.0; //~ ERROR use of moved value: `x.0` -} diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs deleted file mode 100644 index 63fb4ff02a4..00000000000 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that if you move from `x.f` or `x[0]`, `x` is inaccessible. -// Also tests that we give a more specific error message. - -struct Foo { f: String, y: isize } -fn consume(_s: String) {} -fn touch(_a: &A) {} - -fn f20() { - let x = vec!["hi".to_string()]; - consume(x.into_iter().next().unwrap()); - touch(&x[0]); //~ ERROR use of moved value: `x` -} - -fn main() {} diff --git a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs b/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs deleted file mode 100644 index 32fa773ec80..00000000000 --- a/src/test/compile-fail/moves-based-on-type-capture-clause-bad.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::thread; - -fn main() { - let x = "Hello world!".to_string(); - thread::spawn(move|| { - println!("{}", x); - }); - println!("{}", x); //~ ERROR use of moved value -} diff --git a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs deleted file mode 100644 index 0c4aae8cfad..00000000000 --- a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for a subtle failure computing kinds of cyclic types, in which -// temporary kinds wound up being stored in a cache and used later. -// See rustc::ty::type_contents() for more information. - - -struct List { key: isize, next: Option> } - -fn foo(node: Box) -> isize { - let r = match node.next { - Some(right) => consume(right), - None => 0 - }; - consume(node) + r //~ ERROR use of partially moved value: `node` -} - -fn consume(v: Box) -> isize { - v.key -} - -fn main() {} diff --git a/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs b/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs deleted file mode 100644 index 5329dcaaaf4..00000000000 --- a/src/test/compile-fail/moves-based-on-type-distribute-copy-over-paren.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that references to move-by-default values trigger moves when -// they occur as part of various kinds of expressions. - -struct Foo { f: A } -fn touch(_a: &A) {} - -fn f00() { - let x = "hi".to_string(); - let _y = Foo { f:x }; - //~^ NOTE value moved here - touch(&x); //~ ERROR use of moved value: `x` - //~^ NOTE value used here after move - //~| NOTE move occurs because `x` has type `std::string::String` -} - -fn f05() { - let x = "hi".to_string(); - let _y = Foo { f:(((x))) }; - //~^ NOTE value moved here - touch(&x); //~ ERROR use of moved value: `x` - //~^ NOTE value used here after move - //~| NOTE move occurs because `x` has type `std::string::String` -} - -fn f10() { - let x = "hi".to_string(); - let _y = Foo { f:x.clone() }; - touch(&x); -} - -fn f20() { - let x = "hi".to_string(); - let _y = Foo { f:(x).clone() }; - touch(&x); -} - -fn f30() { - let x = "hi".to_string(); - let _y = Foo { f:((x)).clone() }; - touch(&x); -} - -fn f40() { - let x = "hi".to_string(); - let _y = Foo { f:(((((((x)).clone()))))) }; - touch(&x); -} - -fn main() {} diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs deleted file mode 100644 index 194f278259b..00000000000 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that references to move-by-default values trigger moves when -// they occur as part of various kinds of expressions. - - -struct Foo { f: A } -fn guard(_s: String) -> bool {panic!()} -fn touch(_a: &A) {} - -fn f10() { - let x = "hi".to_string(); - let _y = Foo { f:x }; - touch(&x); //~ ERROR use of moved value: `x` -} - -fn f20() { - let x = "hi".to_string(); - let _y = (x, 3); - touch(&x); //~ ERROR use of moved value: `x` -} - -fn f21() { - let x = vec![1, 2, 3]; - let _y = (x[0], 3); - touch(&x); -} - -fn f30(cond: bool) { - let x = "hi".to_string(); - let y = "ho".to_string(); - let _y = if cond { - x - } else { - y - }; - touch(&x); //~ ERROR use of moved value: `x` - touch(&y); //~ ERROR use of moved value: `y` -} - -fn f40(cond: bool) { - let x = "hi".to_string(); - let y = "ho".to_string(); - let _y = match cond { - true => x, - false => y - }; - touch(&x); //~ ERROR use of moved value: `x` - touch(&y); //~ ERROR use of moved value: `y` -} - -fn f50(cond: bool) { - let x = "hi".to_string(); - let y = "ho".to_string(); - let _y = match cond { - _ if guard(x) => 10, - true => 10, - false => 20, - }; - touch(&x); //~ ERROR use of moved value: `x` - touch(&y); -} - -fn f70() { - let x = "hi".to_string(); - let _y = [x]; - touch(&x); //~ ERROR use of moved value: `x` -} - -fn f80() { - let x = "hi".to_string(); - let _y = vec![x]; - touch(&x); //~ ERROR use of moved value: `x` -} - -fn f100() { - let x = vec!["hi".to_string()]; - let _y = x.into_iter().next().unwrap(); - touch(&x); //~ ERROR use of moved value: `x` -} - -fn f110() { - let x = vec!["hi".to_string()]; - let _y = [x.into_iter().next().unwrap(); 1]; - touch(&x); //~ ERROR use of moved value: `x` -} - -fn f120() { - let mut x = vec!["hi".to_string(), "ho".to_string()]; - x.swap(0, 1); - touch(&x[0]); - touch(&x[1]); -} - -fn main() {} diff --git a/src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs deleted file mode 100644 index 4251be36ab4..00000000000 --- a/src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax, unboxed_closures)] - -use std::usize; - -fn to_fn>(f: F) -> F { f } - -fn test(_x: Box) {} - -fn main() { - let i = box 3; - let _f = to_fn(|| test(i)); //~ ERROR cannot move out -} diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs deleted file mode 100644 index d5296065999..00000000000 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests correct kind-checking of the reason stack closures without the :Copy -// bound must be noncopyable. For details see -// http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/ - -struct R<'a> { - // This struct is needed to create the - // otherwise infinite type of a fn that - // accepts itself as argument: - c: Box -} - -fn innocent_looking_victim() { - let mut x = Some("hello".to_string()); - conspirator(|f, writer| { - if writer { - x = None; - } else { - match x { - Some(ref msg) => { - (f.c)(f, true); - //~^ ERROR: cannot borrow `*f` as mutable more than once at a time - println!("{}", msg); - }, - None => panic!("oops"), - } - } - }) -} - -fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { - let mut r = R {c: Box::new(f)}; - f(&mut r, false) //~ ERROR use of moved value -} - -fn main() { innocent_looking_victim() } diff --git a/src/test/compile-fail/moves-sru-moved-field.rs b/src/test/compile-fail/moves-sru-moved-field.rs deleted file mode 100644 index 15977fbeb73..00000000000 --- a/src/test/compile-fail/moves-sru-moved-field.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -type Noncopyable = Box; - -struct Foo { - copied: isize, - moved: Box, - noncopyable: Noncopyable -} - -fn test0(f: Foo, g: Noncopyable, h: Noncopyable) { - // just copy implicitly copyable fields from `f`, no moves: - let _b = Foo {moved: box 1, noncopyable: g, ..f}; - let _c = Foo {moved: box 2, noncopyable: h, ..f}; -} - -fn test1(f: Foo, g: Noncopyable, h: Noncopyable) { - // copying move-by-default fields from `f`, so move: - let _b = Foo {noncopyable: g, ..f}; - let _c = Foo {noncopyable: h, ..f}; //~ ERROR use of moved value: `f.moved` -} - -fn main() {} diff --git a/src/test/compile-fail/multiple-main-2.rs b/src/test/compile-fail/multiple-main-2.rs deleted file mode 100644 index d9c232d7dac..00000000000 --- a/src/test/compile-fail/multiple-main-2.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(main)] - -#[main] -fn bar() { -} - -#[main] -fn foo() { //~ ERROR multiple functions with a #[main] attribute -} diff --git a/src/test/compile-fail/multiple-main-3.rs b/src/test/compile-fail/multiple-main-3.rs deleted file mode 100644 index 866a59e7a4f..00000000000 --- a/src/test/compile-fail/multiple-main-3.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(main)] - -#[main] -fn main1() { -} - -mod foo { - #[main] - fn main2() { //~ ERROR multiple functions with a #[main] attribute - } -} diff --git a/src/test/compile-fail/multiple-plugin-registrars.rs b/src/test/compile-fail/multiple-plugin-registrars.rs deleted file mode 100644 index f5ebf84b8e0..00000000000 --- a/src/test/compile-fail/multiple-plugin-registrars.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: multiple plugin registration functions found - -#![feature(plugin_registrar)] - -// the registration function isn't typechecked yet -#[plugin_registrar] -pub fn one() {} - -#[plugin_registrar] -pub fn two() {} - -fn main() {} diff --git a/src/test/compile-fail/mut-cant-alias.rs b/src/test/compile-fail/mut-cant-alias.rs deleted file mode 100644 index 99d7258477a..00000000000 --- a/src/test/compile-fail/mut-cant-alias.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cell::RefCell; - -fn main() { - let m = RefCell::new(0); - let mut b = m.borrow_mut(); - let b1 = &mut *b; - let b2 = &mut *b; //~ ERROR cannot borrow -} diff --git a/src/test/compile-fail/mut-cross-borrowing.rs b/src/test/compile-fail/mut-cross-borrowing.rs deleted file mode 100644 index 73982fa2811..00000000000 --- a/src/test/compile-fail/mut-cross-borrowing.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn f(_: &mut isize) {} - -fn main() { - let mut x: Box<_> = box 3; - f(x) //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/mut-pattern-internal-mutability.rs b/src/test/compile-fail/mut-pattern-internal-mutability.rs deleted file mode 100644 index a05ee64937e..00000000000 --- a/src/test/compile-fail/mut-pattern-internal-mutability.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn main() { - let foo = &mut 1; - - let &mut x = foo; - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `x` - - // explicitly mut-ify internals - let &mut mut x = foo; - x += 1; - - // check borrowing is detected successfully - let &mut ref x = foo; - *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed - //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed - drop(x); -} diff --git a/src/test/compile-fail/mut-pattern-mismatched.rs b/src/test/compile-fail/mut-pattern-mismatched.rs deleted file mode 100644 index 7685a5c0808..00000000000 --- a/src/test/compile-fail/mut-pattern-mismatched.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let foo = &mut 1; - - // (separate lines to ensure the spans are accurate) - - let &_ //~ ERROR mismatched types - //~| expected type `&mut {integer}` - //~| found type `&_` - //~| types differ in mutability - = foo; - let &mut _ = foo; - - let bar = &1; - let &_ = bar; - let &mut _ //~ ERROR mismatched types - //~| expected type `&{integer}` - //~| found type `&mut _` - //~| types differ in mutability - = bar; -} diff --git a/src/test/compile-fail/mut-suggestion.rs b/src/test/compile-fail/mut-suggestion.rs deleted file mode 100644 index 0015c8e5c00..00000000000 --- a/src/test/compile-fail/mut-suggestion.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Copy, Clone)] -struct S; - -impl S { - fn mutate(&mut self) { - } -} - -fn func(arg: S) { - //~^ consider changing this to `mut arg` - arg.mutate(); - //~^ ERROR cannot borrow immutable argument - //~| cannot borrow mutably -} - -fn main() { - let local = S; - //~^ consider changing this to `mut local` - local.mutate(); - //~^ ERROR cannot borrow immutable local variable - //~| cannot borrow mutably -} diff --git a/src/test/compile-fail/mutable-class-fields-2.rs b/src/test/compile-fail/mutable-class-fields-2.rs deleted file mode 100644 index 46af3a862c2..00000000000 --- a/src/test/compile-fail/mutable-class-fields-2.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct cat { - meows : usize, - - how_hungry : isize, -} - -impl cat { - pub fn eat(&self) { - self.how_hungry -= 5; //~ ERROR cannot assign - } - -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -fn main() { - let nyan : cat = cat(52, 99); - nyan.eat(); -} diff --git a/src/test/compile-fail/mutable-class-fields.rs b/src/test/compile-fail/mutable-class-fields.rs deleted file mode 100644 index f138ae93f71..00000000000 --- a/src/test/compile-fail/mutable-class-fields.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -struct cat { - meows : usize, - how_hungry : isize, -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -fn main() { - let nyan : cat = cat(52, 99); - nyan.how_hungry = 0; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign -} diff --git a/src/test/compile-fail/mutable-enum-indirect.rs b/src/test/compile-fail/mutable-enum-indirect.rs deleted file mode 100644 index 9107745b0e9..00000000000 --- a/src/test/compile-fail/mutable-enum-indirect.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that an `&` pointer to something inherently mutable is itself -// to be considered mutable. - -#![feature(optin_builtin_traits)] - -use std::marker::Sync; - -struct NoSync; -impl !Sync for NoSync {} - -enum Foo { A(NoSync) } - -fn bar(_: T) {} - -fn main() { - let x = Foo::A(NoSync); - bar(&x); - //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] -} diff --git a/src/test/compile-fail/mutexguard-sync.rs b/src/test/compile-fail/mutexguard-sync.rs deleted file mode 100644 index 2d4b50eb7b2..00000000000 --- a/src/test/compile-fail/mutexguard-sync.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// MutexGuard> must not be Sync, that would be unsound. -use std::sync::Mutex; -use std::cell::Cell; - -fn test_sync(_t: T) {} - -fn main() -{ - let m = Mutex::new(Cell::new(0i32)); - let guard = m.lock().unwrap(); - test_sync(guard); - //~^ ERROR `std::cell::Cell` cannot be shared between threads safely [E0277] -} diff --git a/src/test/compile-fail/namespace-mix.rs b/src/test/compile-fail/namespace-mix.rs deleted file mode 100644 index c1c724fc431..00000000000 --- a/src/test/compile-fail/namespace-mix.rs +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:namespace-mix.rs - -extern crate namespace_mix; -use namespace_mix::*; - -mod c { - pub struct S {} - pub struct TS(); - pub struct US; - pub enum E { - V {}, - TV(), - UV, - } - - pub struct Item; -} - -// Use something emitting the type argument name, e.g. unsatisfied bound. -trait Impossible {} -fn check(_: T) {} - -mod m1 { - pub use ::c::*; - pub type S = ::c::Item; -} -mod m2 { - pub use ::c::*; - pub const S: ::c::Item = ::c::Item; -} - -fn f12() { - check(m1::S{}); //~ ERROR c::Item - check(m1::S); //~ ERROR expected value, found type alias `m1::S` - check(m2::S{}); //~ ERROR c::S - check(m2::S); //~ ERROR c::Item -} -fn xf12() { - check(xm1::S{}); //~ ERROR c::Item - check(xm1::S); //~ ERROR expected value, found type alias `xm1::S` - check(xm2::S{}); //~ ERROR c::S - check(xm2::S); //~ ERROR c::Item -} - -mod m3 { - pub use ::c::*; - pub type TS = ::c::Item; -} -mod m4 { - pub use ::c::*; - pub const TS: ::c::Item = ::c::Item; -} - -fn f34() { - check(m3::TS{}); //~ ERROR c::Item - check(m3::TS); //~ ERROR c::TS - check(m4::TS{}); //~ ERROR c::TS - check(m4::TS); //~ ERROR c::Item -} -fn xf34() { - check(xm3::TS{}); //~ ERROR c::Item - check(xm3::TS); //~ ERROR c::TS - check(xm4::TS{}); //~ ERROR c::TS - check(xm4::TS); //~ ERROR c::Item -} - -mod m5 { - pub use ::c::*; - pub type US = ::c::Item; -} -mod m6 { - pub use ::c::*; - pub const US: ::c::Item = ::c::Item; -} - -fn f56() { - check(m5::US{}); //~ ERROR c::Item - check(m5::US); //~ ERROR c::US - check(m6::US{}); //~ ERROR c::US - check(m6::US); //~ ERROR c::Item -} -fn xf56() { - check(xm5::US{}); //~ ERROR c::Item - check(xm5::US); //~ ERROR c::US - check(xm6::US{}); //~ ERROR c::US - check(xm6::US); //~ ERROR c::Item -} - -mod m7 { - pub use ::c::E::*; - pub type V = ::c::Item; -} -mod m8 { - pub use ::c::E::*; - pub const V: ::c::Item = ::c::Item; -} - -fn f78() { - check(m7::V{}); //~ ERROR c::Item - check(m7::V); //~ ERROR expected value, found struct variant `m7::V` - check(m8::V{}); //~ ERROR c::E - check(m8::V); //~ ERROR c::Item -} -fn xf78() { - check(xm7::V{}); //~ ERROR c::Item - check(xm7::V); //~ ERROR expected value, found struct variant `xm7::V` - check(xm8::V{}); //~ ERROR c::E - check(xm8::V); //~ ERROR c::Item -} - -mod m9 { - pub use ::c::E::*; - pub type TV = ::c::Item; -} -mod mA { - pub use ::c::E::*; - pub const TV: ::c::Item = ::c::Item; -} - -fn f9A() { - check(m9::TV{}); //~ ERROR c::Item - check(m9::TV); //~ ERROR c::E - check(mA::TV{}); //~ ERROR c::E - check(mA::TV); //~ ERROR c::Item -} -fn xf9A() { - check(xm9::TV{}); //~ ERROR c::Item - check(xm9::TV); //~ ERROR c::E - check(xmA::TV{}); //~ ERROR c::E - check(xmA::TV); //~ ERROR c::Item -} - -mod mB { - pub use ::c::E::*; - pub type UV = ::c::Item; -} -mod mC { - pub use ::c::E::*; - pub const UV: ::c::Item = ::c::Item; -} - -fn fBC() { - check(mB::UV{}); //~ ERROR c::Item - check(mB::UV); //~ ERROR c::E - check(mC::UV{}); //~ ERROR c::E - check(mC::UV); //~ ERROR c::Item -} -fn xfBC() { - check(xmB::UV{}); //~ ERROR c::Item - check(xmB::UV); //~ ERROR c::E - check(xmC::UV{}); //~ ERROR c::E - check(xmC::UV); //~ ERROR c::Item -} - -fn main() {} diff --git a/src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs b/src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs deleted file mode 100644 index 67800f8de4e..00000000000 --- a/src/test/compile-fail/namespaced-enum-glob-import-no-impls-xcrate.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:namespaced_enums.rs -extern crate namespaced_enums; - -mod m { - pub use namespaced_enums::Foo::*; -} - -pub fn main() { - use namespaced_enums::Foo::*; - - foo(); //~ ERROR cannot find function `foo` in this scope - m::foo(); //~ ERROR cannot find function `foo` in module `m` - bar(); //~ ERROR cannot find function `bar` in this scope - m::bar(); //~ ERROR cannot find function `bar` in module `m` -} diff --git a/src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs b/src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs deleted file mode 100644 index d5e659c236e..00000000000 --- a/src/test/compile-fail/namespaced-enum-glob-import-no-impls.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m2 { - pub enum Foo { - A, - B(isize), - C { a: isize }, - } - - impl Foo { - pub fn foo() {} - pub fn bar(&self) {} - } -} - -mod m { - pub use m2::Foo::*; -} - -pub fn main() { - use m2::Foo::*; - - foo(); //~ ERROR cannot find function `foo` in this scope - m::foo(); //~ ERROR cannot find function `foo` in module `m` - bar(); //~ ERROR cannot find function `bar` in this scope - m::bar(); //~ ERROR cannot find function `bar` in module `m` -} diff --git a/src/test/compile-fail/nested-cfg-attrs.rs b/src/test/compile-fail/nested-cfg-attrs.rs deleted file mode 100644 index f0c41ff7854..00000000000 --- a/src/test/compile-fail/nested-cfg-attrs.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg_attr(all(), cfg_attr(all(), cfg(foo)))] -fn f() {} - -fn main() { f() } //~ ERROR cannot find function `f` in this scope diff --git a/src/test/compile-fail/nested-ty-params.rs b/src/test/compile-fail/nested-ty-params.rs deleted file mode 100644 index aac37289bb7..00000000000 --- a/src/test/compile-fail/nested-ty-params.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:can't use type parameters from outer function -fn hd(v: Vec ) -> U { - fn hd1(w: [U]) -> U { return w[0]; } - - return hd1(v); -} diff --git a/src/test/compile-fail/never-assign-dead-code.rs b/src/test/compile-fail/never-assign-dead-code.rs deleted file mode 100644 index 0fb75b535c6..00000000000 --- a/src/test/compile-fail/never-assign-dead-code.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an assignment of type ! makes the rest of the block dead code. - -#![feature(never_type)] -#![feature(rustc_attrs)] -#![warn(unused)] - -#[rustc_error] -fn main() { //~ ERROR: compilation successful - let x: ! = panic!("aah"); //~ WARN unused - drop(x); //~ WARN unreachable - //~^ WARN unreachable -} diff --git a/src/test/compile-fail/never-assign-wrong-type.rs b/src/test/compile-fail/never-assign-wrong-type.rs deleted file mode 100644 index c0dd2cab749..00000000000 --- a/src/test/compile-fail/never-assign-wrong-type.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can't use another type in place of ! - -#![feature(never_type)] -#![deny(warnings)] - -fn main() { - let x: ! = "hello"; //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/never_transmute_never.rs b/src/test/compile-fail/never_transmute_never.rs deleted file mode 100644 index cbcc47f60c3..00000000000 --- a/src/test/compile-fail/never_transmute_never.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass - -#![crate_type="lib"] - -#![feature(never_type)] -#![allow(dead_code)] -#![allow(unreachable_code)] -#![allow(unused_variables)] - -struct Foo; - -pub fn f(x: !) -> ! { - x -} - -pub fn ub() { - // This is completely undefined behaviour, - // but we still want to make sure it compiles. - let x: ! = unsafe { - std::mem::transmute::(Foo) - }; - f(x) -} diff --git a/src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs b/src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs deleted file mode 100644 index 7b1dd9265af..00000000000 --- a/src/test/compile-fail/nll/constant-thread-locals-issue-47053.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #47053 - -#![feature(nll)] -#![feature(thread_local)] - -#[thread_local] -static FOO: isize = 5; - -fn main() { - FOO = 6; //~ ERROR cannot assign to immutable static item `FOO` [E0594] -} diff --git a/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs b/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs deleted file mode 100644 index 2a4295fd90a..00000000000 --- a/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the 'static bound from the Copy impl is respected. Regression test for #29149. - -#![feature(nll)] - -#[derive(Clone)] struct Foo<'a>(&'a u32); -impl Copy for Foo<'static> {} - -fn main() { - let s = 2; - let a = Foo(&s); //~ ERROR `s` does not live long enough [E0597] - drop(a); - drop(a); -} diff --git a/src/test/compile-fail/nll/loan_ends_mid_block_pair.rs b/src/test/compile-fail/nll/loan_ends_mid_block_pair.rs deleted file mode 100644 index 97126e98cbf..00000000000 --- a/src/test/compile-fail/nll/loan_ends_mid_block_pair.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// compile-flags:-Zborrowck=compare - -#![allow(warnings)] -#![feature(rustc_attrs)] - - -fn main() { -} - -fn nll_fail() { - let mut data = ('a', 'b', 'c'); - let c = &mut data.0; - capitalize(c); - data.0 = 'e'; - //~^ ERROR (Ast) [E0506] - //~| ERROR (Mir) [E0506] - data.0 = 'f'; - //~^ ERROR (Ast) [E0506] - //~| ERROR (Mir) [E0506] - data.0 = 'g'; - //~^ ERROR (Ast) [E0506] - //~| ERROR (Mir) [E0506] - capitalize(c); -} - -fn nll_ok() { - let mut data = ('a', 'b', 'c'); - let c = &mut data.0; - capitalize(c); - data.0 = 'e'; - //~^ ERROR (Ast) [E0506] - data.0 = 'f'; - //~^ ERROR (Ast) [E0506] - data.0 = 'g'; - //~^ ERROR (Ast) [E0506] -} - -fn capitalize(_: &mut char) { -} diff --git a/src/test/compile-fail/nll/loan_ends_mid_block_vec.rs b/src/test/compile-fail/nll/loan_ends_mid_block_vec.rs deleted file mode 100644 index b5357d0ee82..00000000000 --- a/src/test/compile-fail/nll/loan_ends_mid_block_vec.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// compile-flags:-Zborrowck=compare - -#![allow(warnings)] -#![feature(rustc_attrs)] - -fn main() { -} - -fn nll_fail() { - let mut data = vec!['a', 'b', 'c']; - let slice = &mut data; - capitalize(slice); - data.push('d'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] - data.push('e'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] - data.push('f'); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] - capitalize(slice); -} - -fn nll_ok() { - let mut data = vec!['a', 'b', 'c']; - let slice = &mut data; - capitalize(slice); - data.push('d'); - //~^ ERROR (Ast) [E0499] - data.push('e'); - //~^ ERROR (Ast) [E0499] - data.push('f'); - //~^ ERROR (Ast) [E0499] -} - -fn capitalize(_: &mut [char]) { -} diff --git a/src/test/compile-fail/nll/match-guards-always-borrow.rs b/src/test/compile-fail/nll/match-guards-always-borrow.rs deleted file mode 100644 index 98553144627..00000000000 --- a/src/test/compile-fail/nll/match-guards-always-borrow.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//revisions: ast mir -//[mir] compile-flags: -Z borrowck=mir - -#![feature(rustc_attrs)] - -// Here is arielb1's basic example from rust-lang/rust#27282 -// that AST borrowck is flummoxed by: - -fn should_reject_destructive_mutate_in_guard() { - match Some(&4) { - None => {}, - ref mut foo if { - (|| { let bar = foo; bar.take() })(); - //[mir]~^ ERROR cannot move out of borrowed content [E0507] - false } => { }, - Some(s) => std::process::exit(*s), - } -} - -// Here below is a case that needs to keep working: we only use the -// binding via immutable-borrow in the guard, and we mutate in the arm -// body. -fn allow_mutate_in_arm_body() { - match Some(&4) { - None => {}, - ref mut foo if foo.is_some() && false => { foo.take(); () } - Some(s) => std::process::exit(*s), - } -} - -// Here below is a case that needs to keep working: we only use the -// binding via immutable-borrow in the guard, and we move into the arm -// body. -fn allow_move_into_arm_body() { - match Some(&4) { - None => {}, - mut foo if foo.is_some() && false => { foo.take(); () } - Some(s) => std::process::exit(*s), - } -} - -// Since this is a compile-fail test that is explicitly encoding the -// different behavior of AST- vs MIR-borrowck where AST-borrowck does -// not error, we need to use rustc_error to placate the test harness -// that wants *some* error to occur. -#[rustc_error] -fn main() { //[ast]~ ERROR compilation successful - should_reject_destructive_mutate_in_guard(); - allow_mutate_in_arm_body(); - allow_move_into_arm_body(); -} diff --git a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs b/src/test/compile-fail/nll/reference-carried-through-struct-field.rs deleted file mode 100644 index 589a3daa38d..00000000000 --- a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//revisions: ast mir -//[mir] compile-flags: -Z borrowck=mir - -#![allow(unused_assignments)] - -struct Wrap<'a> { w: &'a mut u32 } - -fn foo() { - let mut x = 22; - let wrapper = Wrap { w: &mut x }; - x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] - //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] - *wrapper.w += 1; -} - -fn main() { } diff --git a/src/test/compile-fail/nll/region-ends-after-if-condition.rs b/src/test/compile-fail/nll/region-ends-after-if-condition.rs deleted file mode 100644 index e1c47a6bbff..00000000000 --- a/src/test/compile-fail/nll/region-ends-after-if-condition.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Basic test for liveness constraints: the region (`R1`) that appears -// in the type of `p` includes the points after `&v[0]` up to (but not -// including) the call to `use_x`. The `else` branch is not included. - -// compile-flags:-Zborrowck=compare - -#![allow(warnings)] -#![feature(rustc_attrs)] - -struct MyStruct { - field: String -} - -fn foo1() { - let mut my_struct = MyStruct { field: format!("Hello") }; - - let value = &my_struct.field; - if value.is_empty() { - my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0502] - } -} - -fn foo2() { - let mut my_struct = MyStruct { field: format!("Hello") }; - - let value = &my_struct.field; - if value.is_empty() { - my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0502] - //~| ERROR (Mir) [E0502] - } - drop(value); -} - -fn main() { } diff --git a/src/test/compile-fail/nll/return_from_loop.rs b/src/test/compile-fail/nll/return_from_loop.rs deleted file mode 100644 index 13f1ca6431b..00000000000 --- a/src/test/compile-fail/nll/return_from_loop.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Basic test for liveness constraints: the region (`R1`) that appears -// in the type of `p` includes the points after `&v[0]` up to (but not -// including) the call to `use_x`. The `else` branch is not included. - -// compile-flags:-Zborrowck=compare - -#![allow(warnings)] -#![feature(rustc_attrs)] - -struct MyStruct { - field: String -} - -fn main() { -} - -fn nll_fail() { - let mut my_struct = MyStruct { field: format!("Hello") }; - - let value = &mut my_struct.field; - loop { - my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0499] - //~| ERROR (Mir) [E0499] - value.len(); - return; - } -} - -fn nll_ok() { - let mut my_struct = MyStruct { field: format!("Hello") }; - - let value = &mut my_struct.field; - loop { - my_struct.field.push_str("Hello, world!"); - //~^ ERROR (Ast) [E0499] - return; - } -} diff --git a/src/test/compile-fail/nll/unused-mut-issue-50343.rs b/src/test/compile-fail/nll/unused-mut-issue-50343.rs deleted file mode 100644 index e9110b8114b..00000000000 --- a/src/test/compile-fail/nll/unused-mut-issue-50343.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(nll)] -#![deny(unused_mut)] - -fn main() { - vec![(42, 22)].iter().map(|(mut x, _y)| ()).count(); - //~^ ERROR: variable does not need to be mutable -} diff --git a/src/test/compile-fail/nll/where_clauses_in_functions.rs b/src/test/compile-fail/nll/where_clauses_in_functions.rs deleted file mode 100644 index 0efdd19df3c..00000000000 --- a/src/test/compile-fail/nll/where_clauses_in_functions.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Zborrowck=mir - -#![allow(dead_code)] - -fn foo<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) -where - 'a: 'b, -{ - (x, y) -} - -fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - foo(x, y) - //~^ ERROR unsatisfied lifetime constraints - //~| WARNING not reporting region error due to nll -} - -fn main() {} diff --git a/src/test/compile-fail/nll/where_clauses_in_structs.rs b/src/test/compile-fail/nll/where_clauses_in_structs.rs deleted file mode 100644 index 92e7db86173..00000000000 --- a/src/test/compile-fail/nll/where_clauses_in_structs.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z borrowck=mir - -#![allow(dead_code)] - -use std::cell::Cell; - -struct Foo<'a: 'b, 'b> { - x: Cell<&'a u32>, - y: Cell<&'b u32>, -} - -fn bar<'a, 'b>(x: Cell<&'a u32>, y: Cell<&'b u32>) { - Foo { x, y }; - //~^ ERROR unsatisfied lifetime constraints - //~| WARNING not reporting region error due to nll -} - -fn main() {} diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs deleted file mode 100644 index 5e1d22bf63b..00000000000 --- a/src/test/compile-fail/no-capture-arc.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: use of moved value - -use std::sync::Arc; -use std::thread; - -fn main() { - let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - let arc_v = Arc::new(v); - - thread::spawn(move|| { - assert_eq!((*arc_v)[3], 4); - }); - - assert_eq!((*arc_v)[2], 3); - - println!("{:?}", *arc_v); -} diff --git a/src/test/compile-fail/no-implicit-prelude-nested.rs b/src/test/compile-fail/no-implicit-prelude-nested.rs deleted file mode 100644 index c64839ad0de..00000000000 --- a/src/test/compile-fail/no-implicit-prelude-nested.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that things from the prelude aren't in scope. Use many of them -// so that renaming some things won't magically make this test fail -// for the wrong reason (e.g. if `Add` changes to `Addition`, and -// `no_implicit_prelude` stops working, then the `impl Add` will still -// fail with the same error message). - -#[no_implicit_prelude] -mod foo { - mod baz { - struct Test; - impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope - impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope - impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope - impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope - impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope - - fn foo() { - drop(2) //~ ERROR cannot find function `drop` in this scope - } - } - - struct Test; - impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope - impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope - impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope - impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope - impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope - - fn foo() { - drop(2) //~ ERROR cannot find function `drop` in this scope - } -} - -fn qux() { - #[no_implicit_prelude] - mod qux_inner { - struct Test; - impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope - impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope - impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope - impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope - impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope - - fn foo() { - drop(2) //~ ERROR cannot find function `drop` in this scope - } - } -} - - -fn main() { - // these should work fine - drop(2) -} diff --git a/src/test/compile-fail/no-implicit-prelude.rs b/src/test/compile-fail/no-implicit-prelude.rs deleted file mode 100644 index 0e39d9ebdc1..00000000000 --- a/src/test/compile-fail/no-implicit-prelude.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_implicit_prelude] - -// Test that things from the prelude aren't in scope. Use many of them -// so that renaming some things won't magically make this test fail -// for the wrong reason (e.g. if `Add` changes to `Addition`, and -// `no_implicit_prelude` stops working, then the `impl Add` will still -// fail with the same error message). - -struct Test; -impl Add for Test {} //~ ERROR cannot find trait `Add` in this scope -impl Clone for Test {} //~ ERROR cannot find trait `Clone` in this scope -impl Iterator for Test {} //~ ERROR cannot find trait `Iterator` in this scope -impl ToString for Test {} //~ ERROR cannot find trait `ToString` in this scope -impl Writer for Test {} //~ ERROR cannot find trait `Writer` in this scope - -fn main() { - drop(2) //~ ERROR cannot find function `drop` in this scope -} diff --git a/src/test/compile-fail/no-link.rs b/src/test/compile-fail/no-link.rs deleted file mode 100644 index f74ff55e2c0..00000000000 --- a/src/test/compile-fail/no-link.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:empty-struct.rs - -#[no_link] -extern crate empty_struct; -//~^ WARN proc macro crates and `#[no_link]` crates have no effect without `#[macro_use]` - -fn main() { - empty_struct::XEmpty1; //~ ERROR cannot find value `XEmpty1` in module `empty_struct` -} diff --git a/src/test/compile-fail/no-patterns-in-args-2.rs b/src/test/compile-fail/no-patterns-in-args-2.rs deleted file mode 100644 index 4d2412c34a5..00000000000 --- a/src/test/compile-fail/no-patterns-in-args-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(patterns_in_fns_without_body)] - -trait Tr { - fn f1(mut arg: u8); //~ ERROR patterns aren't allowed in methods without bodies - //~^ WARN was previously accepted - fn f2(&arg: u8); //~ ERROR patterns aren't allowed in methods without bodies - fn g1(arg: u8); // OK - fn g2(_: u8); // OK - #[allow(anonymous_parameters)] - fn g3(u8); // OK -} - -fn main() {} diff --git a/src/test/compile-fail/no-patterns-in-args-macro.rs b/src/test/compile-fail/no-patterns-in-args-macro.rs deleted file mode 100644 index f85ce8f57ea..00000000000 --- a/src/test/compile-fail/no-patterns-in-args-macro.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! m { - ($pat: pat) => { - trait Tr { - fn trait_method($pat: u8); - } - - type A = fn($pat: u8); - - extern { - fn foreign_fn($pat: u8); - } - } -} - -mod good_pat { - m!(good_pat); // OK -} - -mod bad_pat { - m!((bad, pat)); - //~^ ERROR patterns aren't allowed in function pointer types - //~| ERROR patterns aren't allowed in foreign function declarations - //~| ERROR patterns aren't allowed in methods without bodies -} - -fn main() {} diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs deleted file mode 100644 index 76c8a444320..00000000000 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::sync::Arc; -use std::thread; - -fn main() { - let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - let arc_v = Arc::new(v); - - thread::spawn(move|| { - assert_eq!((*arc_v)[3], 4); - }); - - assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` - - println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` -} diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs deleted file mode 100644 index 6825963c486..00000000000 --- a/src/test/compile-fail/no-send-res-ports.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::thread; -use std::rc::Rc; - -#[derive(Debug)] -struct Port(Rc); - -fn main() { - #[derive(Debug)] - struct foo { - _x: Port<()>, - } - - impl Drop for foo { - fn drop(&mut self) {} - } - - fn foo(x: Port<()>) -> foo { - foo { - _x: x - } - } - - let x = foo(Port(Rc::new(()))); - - thread::spawn(move|| { - //~^ ERROR `std::rc::Rc<()>` cannot be sent between threads safely - let y = x; - println!("{:?}", y); - }); -} diff --git a/src/test/compile-fail/no-std-inject.rs b/src/test/compile-fail/no-std-inject.rs deleted file mode 100644 index 49064853d21..00000000000 --- a/src/test/compile-fail/no-std-inject.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] -#![allow(unused_extern_crates)] - -extern crate core; //~ ERROR: the name `core` is defined multiple times -extern crate std; - -fn main() {} diff --git a/src/test/compile-fail/no-type-for-node-ice.rs b/src/test/compile-fail/no-type-for-node-ice.rs deleted file mode 100644 index f049f69e4bb..00000000000 --- a/src/test/compile-fail/no-type-for-node-ice.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Related issues: #20401, #20506, #20614, #20752, #20829, #20846, #20885, #20886 - -fn main() { - "".homura[""]; //~ no field `homura` on type `&'static str` -} diff --git a/src/test/compile-fail/no-warn-on-field-replace-issue-34101.rs b/src/test/compile-fail/no-warn-on-field-replace-issue-34101.rs deleted file mode 100644 index 2940b891534..00000000000 --- a/src/test/compile-fail/no-warn-on-field-replace-issue-34101.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue 34101: Circa 2016-06-05, `fn inline` below issued an -// erroneous warning from the elaborate_drops pass about moving out of -// a field in `Foo`, which has a destructor (and thus cannot have -// content moved out of it). The reason that the warning is erroneous -// in this case is that we are doing a *replace*, not a move, of the -// content in question, and it is okay to replace fields within `Foo`. -// -// Another more subtle problem was that the elaborate_drops was -// creating a separate drop flag for that internally replaced content, -// even though the compiler should enforce an invariant that any drop -// flag for such subcontent of `Foo` will always have the same value -// as the drop flag for `Foo` itself. -// -// This test is structured in a funny way; we cannot test for emission -// of the warning in question via the lint system, and therefore -// `#![deny(warnings)]` does nothing to detect it. -// -// So instead we use `#[rustc_error]` and put the test into -// `compile_fail`, where the emitted warning *will* be caught. - -#![feature(rustc_attrs)] - -struct Foo(String); - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn inline() { - // (dummy variable so `f` gets assigned `var1` in MIR for both fn's) - let _s = (); - let mut f = Foo(String::from("foo")); - f.0 = String::from("bar"); -} - -fn outline() { - let _s = String::from("foo"); - let mut f = Foo(_s); - f.0 = String::from("bar"); -} - -#[rustc_error] -fn main() { //~ ERROR compilation successful - inline(); - outline(); -} diff --git a/src/test/compile-fail/no_crate_type.rs b/src/test/compile-fail/no_crate_type.rs deleted file mode 100644 index b2cc5cae697..00000000000 --- a/src/test/compile-fail/no_crate_type.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// regression test for issue 11256 -#![crate_type] //~ ERROR `crate_type` requires a value - -fn main() { - return -} diff --git a/src/test/compile-fail/no_owned_box_lang_item.rs b/src/test/compile-fail/no_owned_box_lang_item.rs deleted file mode 100644 index 1c2bf1573dc..00000000000 --- a/src/test/compile-fail/no_owned_box_lang_item.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we don't ICE when we are missing the owned_box lang item. - -// error-pattern: requires `owned_box` lang_item - -#![feature(lang_items, box_syntax)] -#![no_std] - -fn main() { - let x = box 1i32; -} - -#[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {} -#[lang = "panic_impl"] fn panic_impl() -> ! { loop {} } diff --git a/src/test/compile-fail/no_send-enum.rs b/src/test/compile-fail/no_send-enum.rs deleted file mode 100644 index 83f19ed19ef..00000000000 --- a/src/test/compile-fail/no_send-enum.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -struct NoSend; -impl !Send for NoSend {} - -enum Foo { - A(NoSend) -} - -fn bar(_: T) {} - -fn main() { - let x = Foo::A(NoSend); - bar(x); - //~^ ERROR `NoSend` cannot be sent between threads safely -} diff --git a/src/test/compile-fail/no_send-rc.rs b/src/test/compile-fail/no_send-rc.rs deleted file mode 100644 index d3616d14422..00000000000 --- a/src/test/compile-fail/no_send-rc.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::rc::Rc; - -fn bar(_: T) {} - -fn main() { - let x = Rc::new(5); - bar(x); - //~^ ERROR `std::rc::Rc<{integer}>` cannot be sent between threads safely -} diff --git a/src/test/compile-fail/no_send-struct.rs b/src/test/compile-fail/no_send-struct.rs deleted file mode 100644 index d38d993e7e8..00000000000 --- a/src/test/compile-fail/no_send-struct.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -struct Foo { - a: isize, -} - -impl !Send for Foo {} - -fn bar(_: T) {} - -fn main() { - let x = Foo { a: 5 }; - bar(x); - //~^ ERROR `Foo` cannot be sent between threads safely -} diff --git a/src/test/compile-fail/no_share-enum.rs b/src/test/compile-fail/no_share-enum.rs deleted file mode 100644 index 77a7012b3b0..00000000000 --- a/src/test/compile-fail/no_share-enum.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -use std::marker::Sync; - -struct NoSync; -impl !Sync for NoSync {} - -enum Foo { A(NoSync) } - -fn bar(_: T) {} - -fn main() { - let x = Foo::A(NoSync); - bar(x); - //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] -} diff --git a/src/test/compile-fail/no_share-struct.rs b/src/test/compile-fail/no_share-struct.rs deleted file mode 100644 index 34e43e9f2aa..00000000000 --- a/src/test/compile-fail/no_share-struct.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -use std::marker::Sync; - -struct Foo { a: isize } -impl !Sync for Foo {} - -fn bar(_: T) {} - -fn main() { - let x = Foo { a: 5 }; - bar(x); - //~^ ERROR `Foo` cannot be shared between threads safely [E0277] -} diff --git a/src/test/compile-fail/noexporttypeexe.rs b/src/test/compile-fail/noexporttypeexe.rs deleted file mode 100644 index c950ef5b680..00000000000 --- a/src/test/compile-fail/noexporttypeexe.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:noexporttypelib.rs - -extern crate noexporttypelib; - -fn main() { - // Here, the type returned by foo() is not exported. - // This used to cause internal errors when serializing - // because the def_id associated with the type was - // not convertible to a path. - let x: isize = noexporttypelib::foo(); - //~^ ERROR mismatched types - //~| expected type `isize` - //~| found type `std::option::Option` - //~| expected isize, found enum `std::option::Option` -} diff --git a/src/test/compile-fail/nolink-with-link-args.rs b/src/test/compile-fail/nolink-with-link-args.rs deleted file mode 100644 index 6dfd74f541e..00000000000 --- a/src/test/compile-fail/nolink-with-link-args.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:aFdEfSeVEE -// compile-flags: -Z linker-flavor=ld - -/* We're testing that link_args are indeed passed when nolink is specified. -So we try to compile with junk link_args and make sure they are visible in -the compiler output. */ - -#![feature(link_args)] - -#[link_args = "aFdEfSeVEEE"] -extern {} - -fn main() { } diff --git a/src/test/compile-fail/non-constant-in-const-path.rs b/src/test/compile-fail/non-constant-in-const-path.rs deleted file mode 100644 index 1aae25105a8..00000000000 --- a/src/test/compile-fail/non-constant-in-const-path.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x = 0; - match 1 { - 0 ..= x => {} - //~^ ERROR runtime values cannot be referenced in patterns - }; -} diff --git a/src/test/compile-fail/non-copyable-void.rs b/src/test/compile-fail/non-copyable-void.rs deleted file mode 100644 index 63e5f963754..00000000000 --- a/src/test/compile-fail/non-copyable-void.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -extern crate libc; - -fn main() { - let x : *const Vec = &vec![1,2,3]; - let y : *const libc::c_void = x as *const libc::c_void; - unsafe { - let _z = (*y).clone(); - //~^ ERROR no method named `clone` found - } -} diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs deleted file mode 100644 index 1d524217a12..00000000000 --- a/src/test/compile-fail/non-exhaustive-match-nested.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] - -enum t { a(u), b } -enum u { c, d } - -fn match_nested_vecs<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str { - match (l1, l2) { //~ ERROR non-exhaustive patterns: `(Some(&[]), Err(_))` not covered - (Some(&[]), Ok(&[])) => "Some(empty), Ok(empty)", - (Some(&[_, ..]), Ok(_)) | (Some(&[_, ..]), Err(())) => "Some(non-empty), any", - (None, Ok(&[])) | (None, Err(())) | (None, Ok(&[_])) => "None, Ok(less than one element)", - (None, Ok(&[_, _, ..])) => "None, Ok(at least two elements)" - } -} - -fn main() { - let x = t::a(u::c); - match x { //~ ERROR non-exhaustive patterns: `a(c)` not covered - t::a(u::d) => { panic!("hello"); } - t::b => { panic!("goodbye"); } - } -} diff --git a/src/test/compile-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs deleted file mode 100644 index 13b62429f46..00000000000 --- a/src/test/compile-fail/non-exhaustive-match.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(slice_patterns)] -#![allow(illegal_floating_point_literal_pattern)] - -enum t { a, b, } - -fn main() { - let x = t::a; - match x { t::b => { } } //~ ERROR non-exhaustive patterns: `a` not covered - match true { //~ ERROR non-exhaustive patterns: `false` not covered - true => {} - } - match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered - None => {} - } - match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, _)` not covered - (_, _, 4) => {} - } - match (t::a, t::a) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered - (t::a, t::b) => {} - (t::b, t::a) => {} - } - match t::a { //~ ERROR non-exhaustive patterns: `b` not covered - t::a => {} - } - // This is exhaustive, though the algorithm got it wrong at one point - match (t::a, t::b) { - (t::a, _) => {} - (_, t::a) => {} - (t::b, t::b) => {} - } - let vec = vec![Some(42), None, Some(21)]; - let vec: &[Option] = &vec; - match *vec { //~ ERROR non-exhaustive patterns: `[]` not covered - [Some(..), None, ref tail..] => {} - [Some(..), Some(..), ref tail..] => {} - [None] => {} - } - let vec = vec![1]; - let vec: &[isize] = &vec; - match *vec { - [_, ref tail..] => (), - [] => () - } - let vec = vec![0.5f32]; - let vec: &[f32] = &vec; - match *vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered - [0.1, 0.2, 0.3] => (), - [0.1, 0.2] => (), - [0.1] => (), - [] => () - } - let vec = vec![Some(42), None, Some(21)]; - let vec: &[Option] = &vec; - match *vec { - [Some(..), None, ref tail..] => {} - [Some(..), Some(..), ref tail..] => {} - [None, None, ref tail..] => {} - [None, Some(..), ref tail..] => {} - [Some(_)] => {} - [None] => {} - [] => {} - } -} diff --git a/src/test/compile-fail/non-interger-atomic.rs b/src/test/compile-fail/non-interger-atomic.rs deleted file mode 100644 index 2a6e148ca79..00000000000 --- a/src/test/compile-fail/non-interger-atomic.rs +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(core_intrinsics)] -#![allow(warnings)] -#![crate_type = "rlib"] - -use std::intrinsics; - -#[derive(Copy, Clone)] -pub struct Foo(i64); -pub type Bar = &'static Fn(); -pub type Quux = [u8; 100]; - -pub unsafe fn test_bool_load(p: &mut bool, v: bool) { - intrinsics::atomic_load(p); - //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_bool_store(p: &mut bool, v: bool) { - intrinsics::atomic_store(p, v); - //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) { - intrinsics::atomic_xchg(p, v); - //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) { - intrinsics::atomic_cxchg(p, v, v); - //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) { - intrinsics::atomic_load(p); - //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) { - intrinsics::atomic_store(p, v); - //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) { - intrinsics::atomic_xchg(p, v); - //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) { - intrinsics::atomic_cxchg(p, v, v); - //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) { - intrinsics::atomic_load(p); - //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` -} - -pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) { - intrinsics::atomic_store(p, v); - //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` -} - -pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) { - intrinsics::atomic_xchg(p, v); - //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` -} - -pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) { - intrinsics::atomic_cxchg(p, v, v); - //~^ ERROR expected basic integer type, found `&dyn std::ops::Fn()` -} - -pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) { - intrinsics::atomic_load(p); - //~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]` -} - -pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) { - intrinsics::atomic_store(p, v); - //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]` -} - -pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) { - intrinsics::atomic_xchg(p, v); - //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]` -} - -pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) { - intrinsics::atomic_cxchg(p, v, v); - //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]` -} diff --git a/src/test/compile-fail/noncopyable-class.rs b/src/test/compile-fail/noncopyable-class.rs deleted file mode 100644 index f5712b0c957..00000000000 --- a/src/test/compile-fail/noncopyable-class.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a class with a non-copyable field can't be -// copied - -#[derive(Debug)] -struct bar { - x: isize, -} - -impl Drop for bar { - fn drop(&mut self) {} -} - -fn bar(x:isize) -> bar { - bar { - x: x - } -} - -#[derive(Debug)] -struct foo { - i: isize, - j: bar, -} - -fn foo(i:isize) -> foo { - foo { - i: i, - j: bar(5) - } -} - -fn main() { - let x = foo(10); - let _y = x.clone(); //~ ERROR no method named `clone` found - println!("{:?}", x); -} diff --git a/src/test/compile-fail/nonscalar-cast.rs b/src/test/compile-fail/nonscalar-cast.rs deleted file mode 100644 index 0abbc05eef0..00000000000 --- a/src/test/compile-fail/nonscalar-cast.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Debug)] -struct foo { - x: isize -} - -fn main() { - println!("{}", foo{ x: 1 } as isize); //~ non-primitive cast: `foo` as `isize` [E0605] -} diff --git a/src/test/compile-fail/not-clone-closure.rs b/src/test/compile-fail/not-clone-closure.rs deleted file mode 100644 index 967cb3610ca..00000000000 --- a/src/test/compile-fail/not-clone-closure.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that closures do not implement `Clone` if their environment is not `Clone`. - -struct S(i32); - -fn main() { - let a = S(5); - let hello = move || { - println!("Hello {}", a.0); - }; - - let hello = hello.clone(); //~ ERROR the trait bound `S: std::clone::Clone` is not satisfied -} diff --git a/src/test/compile-fail/not-copy-closure.rs b/src/test/compile-fail/not-copy-closure.rs deleted file mode 100644 index 10567c5c961..00000000000 --- a/src/test/compile-fail/not-copy-closure.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that closures do not implement `Copy` if their environment is not `Copy`. - -fn main() { - let mut a = 5; - let hello = || { - a += 1; - }; - - let b = hello; - let c = hello; //~ ERROR use of moved value: `hello` [E0382] -} diff --git a/src/test/compile-fail/not-panic-safe-2.rs b/src/test/compile-fail/not-panic-safe-2.rs deleted file mode 100644 index 5490acf4bd6..00000000000 --- a/src/test/compile-fail/not-panic-safe-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -use std::panic::UnwindSafe; -use std::rc::Rc; -use std::cell::RefCell; - -fn assert() {} - -fn main() { - assert::>>(); - //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a - //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a -} diff --git a/src/test/compile-fail/not-panic-safe-3.rs b/src/test/compile-fail/not-panic-safe-3.rs deleted file mode 100644 index 0fac395a115..00000000000 --- a/src/test/compile-fail/not-panic-safe-3.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -use std::panic::UnwindSafe; -use std::sync::Arc; -use std::cell::RefCell; - -fn assert() {} - -fn main() { - assert::>>(); - //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a - //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a -} diff --git a/src/test/compile-fail/not-panic-safe-4.rs b/src/test/compile-fail/not-panic-safe-4.rs deleted file mode 100644 index bf0392018b5..00000000000 --- a/src/test/compile-fail/not-panic-safe-4.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -use std::panic::UnwindSafe; -use std::cell::RefCell; - -fn assert() {} - -fn main() { - assert::<&RefCell>(); - //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a - //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a -} diff --git a/src/test/compile-fail/not-panic-safe-5.rs b/src/test/compile-fail/not-panic-safe-5.rs deleted file mode 100644 index 627a0fe78cf..00000000000 --- a/src/test/compile-fail/not-panic-safe-5.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -use std::panic::UnwindSafe; -use std::cell::UnsafeCell; - -fn assert() {} - -fn main() { - assert::<*const UnsafeCell>(); //~ ERROR E0277 -} diff --git a/src/test/compile-fail/not-panic-safe-6.rs b/src/test/compile-fail/not-panic-safe-6.rs deleted file mode 100644 index 950f0a0b53a..00000000000 --- a/src/test/compile-fail/not-panic-safe-6.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -use std::panic::UnwindSafe; -use std::cell::RefCell; - -fn assert() {} - -fn main() { - assert::<*mut RefCell>(); - //~^ ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a - //~| ERROR the type `std::cell::UnsafeCell` may contain interior mutability and a -} diff --git a/src/test/compile-fail/not-panic-safe.rs b/src/test/compile-fail/not-panic-safe.rs deleted file mode 100644 index 0ebf3d3fed7..00000000000 --- a/src/test/compile-fail/not-panic-safe.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![feature(recover)] - -use std::panic::UnwindSafe; - -fn assert() {} - -fn main() { - assert::<&mut i32>(); - //~^ ERROR the type `&mut i32` may not be safely transferred across an unwind boundary -} diff --git a/src/test/compile-fail/not-sync.rs b/src/test/compile-fail/not-sync.rs deleted file mode 100644 index a383244f415..00000000000 --- a/src/test/compile-fail/not-sync.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cell::{Cell, RefCell}; -use std::rc::{Rc, Weak}; -use std::sync::mpsc::{Receiver, Sender}; - -fn test() {} - -fn main() { - test::>(); - //~^ ERROR `std::cell::Cell` cannot be shared between threads safely [E0277] - test::>(); - //~^ ERROR `std::cell::RefCell` cannot be shared between threads safely [E0277] - - test::>(); - //~^ ERROR `std::rc::Rc` cannot be shared between threads safely [E0277] - test::>(); - //~^ ERROR `std::rc::Weak` cannot be shared between threads safely [E0277] - - test::>(); - //~^ ERROR `std::sync::mpsc::Receiver` cannot be shared between threads safely [E0277] - test::>(); - //~^ ERROR `std::sync::mpsc::Sender` cannot be shared between threads safely [E0277] -} diff --git a/src/test/compile-fail/not-utf8.bin b/src/test/compile-fail/not-utf8.bin deleted file mode 100644 index 4148e5b88fe..00000000000 Binary files a/src/test/compile-fail/not-utf8.bin and /dev/null differ diff --git a/src/test/compile-fail/not-utf8.rs b/src/test/compile-fail/not-utf8.rs deleted file mode 100644 index 5331062d9b6..00000000000 --- a/src/test/compile-fail/not-utf8.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: did not contain valid UTF-8 - -fn foo() { - include!("not-utf8.bin") -} diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs deleted file mode 100644 index 30f8d5e2f45..00000000000 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an object type `Box` is not considered to implement the -// trait `Foo`. Issue #5087. - -trait Foo {} -fn take_foo(f: F) {} -fn take_object(f: Box) { take_foo(f); } -//~^ ERROR `std::boxed::Box: Foo` is not satisfied -fn main() {} diff --git a/src/test/compile-fail/object-lifetime-default-ambiguous.rs b/src/test/compile-fail/object-lifetime-default-ambiguous.rs deleted file mode 100644 index 3df83d91999..00000000000 --- a/src/test/compile-fail/object-lifetime-default-ambiguous.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that if a struct declares multiple region bounds for a given -// type parameter, an explicit lifetime bound is required on object -// lifetimes within. - -#![allow(dead_code)] - -trait Test { - fn foo(&self) { } -} - -struct Ref0 { - r: *mut T -} - -struct Ref1<'a,T:'a+?Sized> { - r: &'a T -} - -struct Ref2<'a,'b:'a,T:'a+'b+?Sized> { - r: &'a &'b T -} - -fn a<'a,'b>(t: Ref2<'a,'b,Test>) { - //~^ ERROR lifetime bound for this object type cannot be deduced from context -} - -fn b(t: Ref2) { - //~^ ERROR lifetime bound for this object type cannot be deduced from context -} - -fn c(t: Ref2<&Test>) { - // In this case, the &'a overrides. -} - -fn d(t: Ref2>) { - // In this case, the lifetime parameter from the Ref1 overrides. -} - -fn e(t: Ref2>) { - // In this case, Ref2 is ambiguous, but Ref0 overrides with 'static. -} - -fn f(t: &Ref2) { - //~^ ERROR lifetime bound for this object type cannot be deduced from context -} - -fn main() { -} diff --git a/src/test/compile-fail/object-lifetime-default-elision.rs b/src/test/compile-fail/object-lifetime-default-elision.rs deleted file mode 100644 index e37b6a2bb9c..00000000000 --- a/src/test/compile-fail/object-lifetime-default-elision.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test various cases where the old rules under lifetime elision -// yield slightly different results than the new rules. - -#![allow(dead_code)] - -trait SomeTrait { - fn dummy(&self) { } -} - -struct SomeStruct<'a> { - r: Box -} - -fn deref(ss: &T) -> T { - // produces the type of a deref without worrying about whether a - // move out would actually be legal - loop { } -} - -fn load0<'a>(ss: &'a Box) -> Box { - // Under old rules, the fully elaborated types of input/output were: - // - // for<'a,'b> fn(&'a Box) -> Box - // - // Under new rules the result is: - // - // for<'a> fn(&'a Box) -> Box - // - // Therefore, no type error. - - deref(ss) -} - -fn load1(ss: &SomeTrait) -> &SomeTrait { - // Under old rules, the fully elaborated types of input/output were: - // - // for<'a,'b> fn(&'a (SomeTrait+'b)) -> &'a (SomeTrait+'a) - // - // Under new rules the result is: - // - // for<'a> fn(&'a (SomeTrait+'a)) -> &'a (SomeTrait+'a) - // - // In both cases, returning `ss` is legal. - - ss -} - -fn load2<'a>(ss: &'a SomeTrait) -> &SomeTrait { - // Same as `load1` but with an explicit name thrown in for fun. - - ss -} - -fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { - // Under old rules, the fully elaborated types of input/output were: - // - // for<'a,'b,'c>fn(&'a (SomeTrait+'c)) -> &'b (SomeTrait+'a) - // - // Based on the input/output types, the compiler could infer that - // 'c : 'a - // 'b : 'a - // must hold, and therefore it permitted `&'a (Sometrait+'c)` to be - // coerced to `&'b (SomeTrait+'a)`. - // - // Under the newer defaults, though, we get: - // - // for<'a,'b> fn(&'a (SomeTrait+'a)) -> &'b (SomeTrait+'b) - // - // which fails to type check. - - ss - //~^ ERROR cannot infer - //~| ERROR cannot infer -} - -fn main() { -} diff --git a/src/test/compile-fail/object-lifetime-default-from-box-error.rs b/src/test/compile-fail/object-lifetime-default-from-box-error.rs deleted file mode 100644 index b253612bc32..00000000000 --- a/src/test/compile-fail/object-lifetime-default-from-box-error.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test various cases where the defaults should lead to errors being -// reported. - -#![allow(dead_code)] - -trait SomeTrait { - fn dummy(&self) { } -} - -struct SomeStruct<'a> { - r: Box -} - -fn load(ss: &mut SomeStruct) -> Box { - // `Box` defaults to a `'static` bound, so this return - // is illegal. - - ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] -} - -fn store(ss: &mut SomeStruct, b: Box) { - // No error: b is bounded by 'static which outlives the - // (anonymous) lifetime on the struct. - - ss.r = b; -} - -fn store1<'b>(ss: &mut SomeStruct, b: Box) { - // Here we override the lifetimes explicitly, and so naturally we get an error. - - ss.r = b; //~ ERROR 41:12: 41:13: explicit lifetime required in the type of `ss` [E0621] -} - -fn main() { -} diff --git a/src/test/compile-fail/object-lifetime-default-from-rptr-box-error.rs b/src/test/compile-fail/object-lifetime-default-from-rptr-box-error.rs deleted file mode 100644 index 98301ef1a0a..00000000000 --- a/src/test/compile-fail/object-lifetime-default-from-rptr-box-error.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the lifetime from the enclosing `&` is "inherited" -// through the `Box` struct. - -#![allow(dead_code)] - -trait Test { - fn foo(&self) { } -} - -struct SomeStruct<'a> { - t: &'a Box, -} - -fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types -} - -fn main() { -} diff --git a/src/test/compile-fail/object-lifetime-default-from-rptr-struct-error.rs b/src/test/compile-fail/object-lifetime-default-from-rptr-struct-error.rs deleted file mode 100644 index 836e4fa1142..00000000000 --- a/src/test/compile-fail/object-lifetime-default-from-rptr-struct-error.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the lifetime from the enclosing `&` is "inherited" -// through the `MyBox` struct. - -#![allow(dead_code)] -#![feature(rustc_error)] - -trait Test { - fn foo(&self) { } -} - -struct SomeStruct<'a> { - t: &'a MyBox, - u: &'a MyBox, -} - -struct MyBox { - b: Box -} - -fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { - ss.t = t; //~ ERROR mismatched types -} - -fn main() { -} diff --git a/src/test/compile-fail/object-lifetime-default-mybox.rs b/src/test/compile-fail/object-lifetime-default-mybox.rs deleted file mode 100644 index 54657e76e97..00000000000 --- a/src/test/compile-fail/object-lifetime-default-mybox.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a "pass-through" object-lifetime-default that produces errors. - -#![allow(dead_code)] - -trait SomeTrait { - fn dummy(&self) { } -} - -struct MyBox { - r: Box -} - -fn deref(ss: &T) -> T { - // produces the type of a deref without worrying about whether a - // move out would actually be legal - loop { } -} - -fn load0(ss: &MyBox) -> MyBox { - deref(ss) -} - -fn load1<'a,'b>(a: &'a MyBox, - b: &'b MyBox) - -> &'b MyBox -{ - a //~ ERROR lifetime mismatch -} - -fn load2<'a>(ss: &MyBox) -> MyBox { - load0(ss) //~ ERROR mismatched types -} - -fn main() { -} diff --git a/src/test/compile-fail/object-lifetime-default.rs b/src/test/compile-fail/object-lifetime-default.rs deleted file mode 100644 index 104e10f3207..00000000000 --- a/src/test/compile-fail/object-lifetime-default.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -#[rustc_object_lifetime_default] -struct A(T); //~ ERROR BaseDefault - -#[rustc_object_lifetime_default] -struct B<'a,T>(&'a (), T); //~ ERROR BaseDefault - -#[rustc_object_lifetime_default] -struct C<'a,T:'a>(&'a T); //~ ERROR 'a - -#[rustc_object_lifetime_default] -struct D<'a,'b,T:'a+'b>(&'a T, &'b T); //~ ERROR Ambiguous - -#[rustc_object_lifetime_default] -struct E<'a,'b:'a,T:'b>(&'a T, &'b T); //~ ERROR 'b - -#[rustc_object_lifetime_default] -struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U); //~ ERROR 'a,'b - -#[rustc_object_lifetime_default] -struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Ambiguous - -fn main() { } diff --git a/src/test/compile-fail/object-pointer-types.rs b/src/test/compile-fail/object-pointer-types.rs deleted file mode 100644 index 98c14cee942..00000000000 --- a/src/test/compile-fail/object-pointer-types.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -trait Foo { - fn borrowed(&self); - fn borrowed_mut(&mut self); - - fn owned(self: Box); -} - -fn borrowed_receiver(x: &Foo) { - x.borrowed(); - x.borrowed_mut(); // See [1] - x.owned(); //~ ERROR no method named `owned` found -} - -fn borrowed_mut_receiver(x: &mut Foo) { - x.borrowed(); - x.borrowed_mut(); - x.owned(); //~ ERROR no method named `owned` found -} - -fn owned_receiver(x: Box) { - x.borrowed(); - x.borrowed_mut(); // See [1] - x.managed(); //~ ERROR no method named `managed` found - x.owned(); -} - -fn main() {} - -// [1]: These cases are illegal, but the error is not detected -// until borrowck, so see the test borrowck-object-mutability.rs diff --git a/src/test/compile-fail/object-safety-by-value-self-use.rs b/src/test/compile-fail/object-safety-by-value-self-use.rs deleted file mode 100644 index e575bbb6cea..00000000000 --- a/src/test/compile-fail/object-safety-by-value-self-use.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that while a trait with by-value self is object-safe, we -// can't actually invoke it from an object (yet...?). - -#![feature(rustc_attrs)] - -trait Bar { - fn bar(self); -} - -trait Baz { - fn baz(self: Self); -} - -fn use_bar(t: Box) { - t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) -} - -fn main() { } diff --git a/src/test/compile-fail/object-safety-by-value-self.rs b/src/test/compile-fail/object-safety-by-value-self.rs deleted file mode 100644 index 5a8772d6142..00000000000 --- a/src/test/compile-fail/object-safety-by-value-self.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that a trait with by-value self is considered object-safe. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(trivial_casts)] - -trait Bar { - fn bar(self); -} - -trait Baz { - fn baz(self: Self); -} - -trait Quux { - // Legal because of the where clause: - fn baz(self: Self) where Self : Sized; -} - -fn make_bar(t: &T) -> &Bar { - t // legal -} - -fn make_bar_explicit(t: &T) -> &Bar { - t as &Bar // legal -} - -fn make_baz(t: &T) -> &Baz { - t // legal -} - -fn make_baz_explicit(t: &T) -> &Baz { - t as &Baz // legal -} - -fn make_quux(t: &T) -> &Quux { - t -} - -fn make_quux_explicit(t: &T) -> &Quux { - t as &Quux -} - -#[rustc_error] -fn main() { //~ ERROR compilation successful -} diff --git a/src/test/compile-fail/object-safety-issue-22040.rs b/src/test/compile-fail/object-safety-issue-22040.rs deleted file mode 100644 index 06d2441d3c0..00000000000 --- a/src/test/compile-fail/object-safety-issue-22040.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for #22040. - -use std::fmt::Debug; - -trait Expr: Debug + PartialEq { - fn print_element_count(&self); -} - -//#[derive(PartialEq)] -#[derive(Debug)] -struct SExpr<'x> { - elements: Vec>, - //~^ ERROR E0038 -} - -impl<'x> PartialEq for SExpr<'x> { - fn eq(&self, other:&SExpr<'x>) -> bool { - println!("L1: {} L2: {}", self.elements.len(), other.elements.len()); - - let result = self.elements.len() == other.elements.len(); - - println!("Got compare {}", result); - return result; - } -} - -impl <'x> SExpr<'x> { - fn new() -> SExpr<'x> { return SExpr{elements: Vec::new(),}; } -} - -impl <'x> Expr for SExpr<'x> { - fn print_element_count(&self) { - println!("element count: {}", self.elements.len()); - } -} - -fn main() { - let a: Box = Box::new(SExpr::new()); - let b: Box = Box::new(SExpr::new()); - - // assert_eq!(a , b); -} diff --git a/src/test/compile-fail/object-safety-no-static.rs b/src/test/compile-fail/object-safety-no-static.rs deleted file mode 100644 index dd1d5af3f4a..00000000000 --- a/src/test/compile-fail/object-safety-no-static.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we correctly prevent users from making trait objects -// from traits with static methods. - -trait Foo { - fn foo(); -} - -fn foo_implicit(b: Box) -> Box { - //~^ ERROR E0038 - loop { } -} - -fn main() { -} diff --git a/src/test/compile-fail/object-safety-phantom-fn.rs b/src/test/compile-fail/object-safety-phantom-fn.rs deleted file mode 100644 index 518c45ac9df..00000000000 --- a/src/test/compile-fail/object-safety-phantom-fn.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that `Self` appearing in a phantom fn does not make a trait not object safe. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait Baz { -} - -trait Bar { -} - -fn make_bar>(t: &T) -> &Bar { - t -} - -fn make_baz(t: &T) -> &Baz { - t -} - -#[rustc_error] -fn main() { //~ ERROR compilation successful -} diff --git a/src/test/compile-fail/object-safety-sized-2.rs b/src/test/compile-fail/object-safety-sized-2.rs deleted file mode 100644 index 3e1942d5a01..00000000000 --- a/src/test/compile-fail/object-safety-sized-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we correctly prevent users from making trait objects -// from traits where `Self : Sized`. - -trait Bar - where Self : Sized -{ - fn bar(&self, t: T); -} - -fn make_bar(t: &T) -> &Bar { - //~^ ERROR E0038 - loop { } -} - -fn main() { -} diff --git a/src/test/compile-fail/occurs-check-2.rs b/src/test/compile-fail/occurs-check-2.rs deleted file mode 100644 index 5d162fe944e..00000000000 --- a/src/test/compile-fail/occurs-check-2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn main() { - let f; - let g; - g = f; - f = box g; - //~^ ERROR mismatched types - //~| cyclic type of infinite size -} diff --git a/src/test/compile-fail/occurs-check-3.rs b/src/test/compile-fail/occurs-check-3.rs deleted file mode 100644 index ba7688e8524..00000000000 --- a/src/test/compile-fail/occurs-check-3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:mismatched types -// From Issue #778 -enum clam { a(T), } -fn main() { let c; c = clam::a(c); match c { clam::a::(_) => { } } } diff --git a/src/test/compile-fail/occurs-check.rs b/src/test/compile-fail/occurs-check.rs deleted file mode 100644 index 2c784365ea9..00000000000 --- a/src/test/compile-fail/occurs-check.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn main() { - let f; - f = box f; - //~^ ERROR mismatched types - //~| cyclic type of infinite size -} diff --git a/src/test/compile-fail/old-suffixes-are-really-forbidden.rs b/src/test/compile-fail/old-suffixes-are-really-forbidden.rs deleted file mode 100644 index 9a71dc98014..00000000000 --- a/src/test/compile-fail/old-suffixes-are-really-forbidden.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let a = 1_is; //~ ERROR invalid suffix - let b = 2_us; //~ ERROR invalid suffix -} diff --git a/src/test/compile-fail/once-cant-call-twice-on-heap.rs b/src/test/compile-fail/once-cant-call-twice-on-heap.rs deleted file mode 100644 index 6441f308f29..00000000000 --- a/src/test/compile-fail/once-cant-call-twice-on-heap.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Testing guarantees provided by once functions. -// This program would segfault if it were legal. - -#![feature(once_fns)] -use std::sync::Arc; - -fn foo(blk: F) { - blk(); - blk(); //~ ERROR use of moved value -} - -fn main() { - let x = Arc::new(true); - foo(move|| { - assert!(*x); - drop(x); - }); -} diff --git a/src/test/compile-fail/opt-in-copy.rs b/src/test/compile-fail/opt-in-copy.rs deleted file mode 100644 index bc18b52a0c1..00000000000 --- a/src/test/compile-fail/opt-in-copy.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct CantCopyThis; - -struct IWantToCopyThis { - but_i_cant: CantCopyThis, -} - -impl Copy for IWantToCopyThis {} -//~^ ERROR the trait `Copy` may not be implemented for this type - -enum CantCopyThisEither { - A, - B, -} - -enum IWantToCopyThisToo { - ButICant(CantCopyThisEither), -} - -impl Copy for IWantToCopyThisToo {} -//~^ ERROR the trait `Copy` may not be implemented for this type - -fn main() {} diff --git a/src/test/compile-fail/or-patter-mismatch.rs b/src/test/compile-fail/or-patter-mismatch.rs deleted file mode 100644 index 59508d6ac95..00000000000 --- a/src/test/compile-fail/or-patter-mismatch.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -enum blah { a(isize, isize, usize), b(isize, isize), } - -fn main() { match blah::a(1, 1, 2) { blah::a(_, x, y) | blah::b(x, y) => { } } } diff --git a/src/test/compile-fail/orphan-check-diagnostics.rs b/src/test/compile-fail/orphan-check-diagnostics.rs deleted file mode 100644 index 8201565c331..00000000000 --- a/src/test/compile-fail/orphan-check-diagnostics.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:orphan_check_diagnostics.rs -// see #22388 - -extern crate orphan_check_diagnostics; - -use orphan_check_diagnostics::RemoteTrait; - -trait LocalTrait { fn dummy(&self) { } } - -impl RemoteTrait for T where T: LocalTrait {} -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() {} diff --git a/src/test/compile-fail/osx-frameworks.rs b/src/test/compile-fail/osx-frameworks.rs deleted file mode 100644 index 026ef3c95f6..00000000000 --- a/src/test/compile-fail/osx-frameworks.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-macos this is supposed to succeed on osx - -#[link(name = "foo", kind = "framework")] -extern {} -//~^^ ERROR: native frameworks are only available on macOS - -fn main() { -} diff --git a/src/test/compile-fail/out-of-order-shadowing.rs b/src/test/compile-fail/out-of-order-shadowing.rs deleted file mode 100644 index 1fafaf85112..00000000000 --- a/src/test/compile-fail/out-of-order-shadowing.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:define_macro.rs -// error-pattern: `bar` is already in scope - -macro_rules! bar { () => {} } -define_macro!(bar); -bar!(); - -macro_rules! m { () => { #[macro_use] extern crate define_macro; } } -m!(); - -fn main() {} diff --git a/src/test/compile-fail/output-type-mismatch.rs b/src/test/compile-fail/output-type-mismatch.rs deleted file mode 100644 index 158e99ac200..00000000000 --- a/src/test/compile-fail/output-type-mismatch.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -fn f() { } - -fn main() { let i: isize; i = f(); } diff --git a/src/test/compile-fail/overlap-marker-trait.rs b/src/test/compile-fail/overlap-marker-trait.rs deleted file mode 100644 index a649ae25f34..00000000000 --- a/src/test/compile-fail/overlap-marker-trait.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for RFC 1268: we allow overlapping impls of marker traits, -// that is, traits without items. In this case, a type `T` is -// `MyMarker` if it is either `Debug` or `Display`. This test just -// checks that we don't consider **all** types to be `MyMarker`. See -// also the companion test in -// `run-pass/overlap-permitted-for-marker-traits.rs`. - -#![feature(overlapping_marker_traits)] -#![feature(optin_builtin_traits)] - -use std::fmt::{Debug, Display}; - -trait Marker {} - -impl Marker for T {} -impl Marker for T {} - -fn is_marker() { } - -struct NotDebugOrDisplay; - -fn main() { - // Debug && Display: - is_marker::(); - - // Debug && !Display: - is_marker::>(); - - // !Debug && !Display - is_marker::(); //~ ERROR -} diff --git a/src/test/compile-fail/overloaded-calls-nontuple.rs b/src/test/compile-fail/overloaded-calls-nontuple.rs deleted file mode 100644 index 7113224664b..00000000000 --- a/src/test/compile-fail/overloaded-calls-nontuple.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(fn_traits, unboxed_closures)] - -use std::ops::FnMut; - -struct S { - x: isize, - y: isize, -} - -impl FnMut for S { - extern "rust-call" fn call_mut(&mut self, z: isize) -> isize { - self.x + self.y + z - } -} - -impl FnOnce for S { - type Output = isize; - extern "rust-call" fn call_once(mut self, z: isize) -> isize { self.call_mut(z) } -} - -fn main() { - let mut s = S { - x: 1, - y: 2, - }; - drop(s(3)) //~ ERROR cannot use call notation -} diff --git a/src/test/compile-fail/packed-struct-generic-transmute.rs b/src/test/compile-fail/packed-struct-generic-transmute.rs deleted file mode 100644 index c96184d5988..00000000000 --- a/src/test/compile-fail/packed-struct-generic-transmute.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This assumes the packed and non-packed structs are different sizes. - -// the error points to the start of the file, not the line with the -// transmute - -// error-pattern: transmute called with types of different sizes - -use std::mem; - -#[repr(packed)] -struct Foo { - bar: T, - baz: S -} - -struct Oof { - rab: T, - zab: S -} - -fn main() { - let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 }; - unsafe { - let oof: Oof<[u8; 5], i32> = mem::transmute(foo); - println!("{:?} {:?}", &oof.rab[..], oof.zab); - } -} diff --git a/src/test/compile-fail/packed-struct-transmute.rs b/src/test/compile-fail/packed-struct-transmute.rs deleted file mode 100644 index abb02dd39e6..00000000000 --- a/src/test/compile-fail/packed-struct-transmute.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This assumes the packed and non-packed structs are different sizes. - -// the error points to the start of the file, not the line with the -// transmute - -// error-pattern: transmute called with types of different sizes - -use std::mem; - -#[repr(packed)] -struct Foo { - bar: u8, - baz: usize -} - -#[derive(Debug)] -struct Oof { - rab: u8, - zab: usize -} - -fn main() { - let foo = Foo { bar: 1, baz: 10 }; - unsafe { - let oof: Oof = mem::transmute(foo); - println!("{:?}", oof); - } -} diff --git a/src/test/compile-fail/panic-implementation-bad-signature-1.rs b/src/test/compile-fail/panic-implementation-bad-signature-1.rs deleted file mode 100644 index fec11fdbd7b..00000000000 --- a/src/test/compile-fail/panic-implementation-bad-signature-1.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(panic_implementation)] -#![no_std] -#![no_main] - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic( - info: PanicInfo, //~ ERROR argument should be `&PanicInfo` -) -> () //~ ERROR return type should be `!` -{ -} diff --git a/src/test/compile-fail/panic-implementation-bad-signature-2.rs b/src/test/compile-fail/panic-implementation-bad-signature-2.rs deleted file mode 100644 index 2a628c05699..00000000000 --- a/src/test/compile-fail/panic-implementation-bad-signature-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(panic_implementation)] -#![no_std] -#![no_main] - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic( - info: &'static PanicInfo, //~ ERROR argument should be `&PanicInfo` -) -> ! -{ - loop {} -} diff --git a/src/test/compile-fail/panic-implementation-bad-signature-3.rs b/src/test/compile-fail/panic-implementation-bad-signature-3.rs deleted file mode 100644 index 29337025b70..00000000000 --- a/src/test/compile-fail/panic-implementation-bad-signature-3.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(panic_implementation)] -#![no_std] -#![no_main] - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic() -> ! { //~ ERROR function should have one argument - loop {} -} diff --git a/src/test/compile-fail/panic-implementation-bad-signature-4.rs b/src/test/compile-fail/panic-implementation-bad-signature-4.rs deleted file mode 100644 index d5f942ba2d6..00000000000 --- a/src/test/compile-fail/panic-implementation-bad-signature-4.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(panic_implementation)] -#![no_std] -#![no_main] - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic(pi: &PanicInfo) -> ! { - //~^ ERROR `#[panic_implementation]` function should have no type parameters - loop {} -} diff --git a/src/test/compile-fail/panic-implementation-duplicate.rs b/src/test/compile-fail/panic-implementation-duplicate.rs deleted file mode 100644 index 017113af409..00000000000 --- a/src/test/compile-fail/panic-implementation-duplicate.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort - -#![feature(lang_items)] -#![feature(panic_implementation)] -#![no_std] -#![no_main] - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic(info: &PanicInfo) -> ! { - loop {} -} - -#[lang = "panic_impl"] -fn panic2(info: &PanicInfo) -> ! { //~ ERROR duplicate lang item found: `panic_impl`. - loop {} -} diff --git a/src/test/compile-fail/panic-implementation-missing.rs b/src/test/compile-fail/panic-implementation-missing.rs deleted file mode 100644 index b11081a3e3b..00000000000 --- a/src/test/compile-fail/panic-implementation-missing.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: `#[panic_implementation]` function required, but not found - -#![feature(lang_items)] -#![no_main] -#![no_std] - -#[lang = "eh_personality"] -fn eh() {} diff --git a/src/test/compile-fail/panic-implementation-requires-panic-info.rs b/src/test/compile-fail/panic-implementation-requires-panic-info.rs deleted file mode 100644 index 597f44d9832..00000000000 --- a/src/test/compile-fail/panic-implementation-requires-panic-info.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort -// error-pattern: language item required, but not found: `panic_info` - -#![feature(lang_items)] -#![feature(no_core)] -#![feature(panic_implementation)] -#![no_core] -#![no_main] - -#[panic_implementation] -fn panic() -> ! { - loop {} -} - -#[lang = "sized"] -trait Sized {} diff --git a/src/test/compile-fail/panic-implementation-std.rs b/src/test/compile-fail/panic-implementation-std.rs deleted file mode 100644 index f25cd3605c1..00000000000 --- a/src/test/compile-fail/panic-implementation-std.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: duplicate lang item found: `panic_impl`. - -#![feature(panic_implementation)] - -use std::panic::PanicInfo; - -#[panic_implementation] -fn panic(info: PanicInfo) -> ! { - loop {} -} - -fn main() {} diff --git a/src/test/compile-fail/panic-implementation-twice.rs b/src/test/compile-fail/panic-implementation-twice.rs deleted file mode 100644 index 78dc545c036..00000000000 --- a/src/test/compile-fail/panic-implementation-twice.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:some-panic-impl.rs - -#![feature(panic_implementation)] -#![feature(lang_items)] -#![no_std] -#![no_main] - -extern crate some_panic_impl; - -use core::panic::PanicInfo; - -#[panic_implementation] -fn panic(info: &PanicInfo) -> ! { - //~^ error duplicate lang item found: `panic_impl` - loop {} -} - -#[lang = "eh_personality"] -fn eh() {} diff --git a/src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs b/src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs deleted file mode 100644 index f392ccd7676..00000000000 --- a/src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort -C prefer-dynamic -// ignore-musl - no dylibs here -// ignore-cloudabi -// ignore-emscripten -// error-pattern:`panic_unwind` is not compiled with this crate's panic strategy - -// This is a test where the local crate, compiled with `panic=abort`, links to -// the standard library **dynamically** which is already linked against -// `panic=unwind`. We should fail because the linked panic runtime does not -// correspond with our `-C panic` option. -// -// Note that this test assumes that the dynamic version of the standard library -// is linked to `panic_unwind`, which is currently the case. - -fn main() { -} diff --git a/src/test/compile-fail/panic-runtime/auxiliary/depends.rs b/src/test/compile-fail/panic-runtime/auxiliary/depends.rs deleted file mode 100644 index b90dec9281b..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/depends.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] -#![panic_runtime] -#![no_std] - -extern crate needs_panic_runtime; diff --git a/src/test/compile-fail/panic-runtime/auxiliary/needs-panic-runtime.rs b/src/test/compile-fail/panic-runtime/auxiliary/needs-panic-runtime.rs deleted file mode 100644 index d6c21fecf6b..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/needs-panic-runtime.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![feature(needs_panic_runtime)] -#![crate_type = "rlib"] -#![needs_panic_runtime] -#![no_std] diff --git a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-abort.rs b/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-abort.rs deleted file mode 100644 index 3b74156b6b0..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-abort.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] - -#![no_std] -#![panic_runtime] - -#[no_mangle] -pub extern fn __rust_maybe_catch_panic() {} - -#[no_mangle] -pub extern fn __rust_start_panic() {} - -#[no_mangle] -pub extern fn rust_eh_personality() {} diff --git a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-lang-items.rs b/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-lang-items.rs deleted file mode 100644 index d9848a554ab..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-lang-items.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -#![no_std] -#![feature(lang_items)] - -use core::panic::PanicInfo; - -#[lang = "panic_impl"] -fn panic_impl(info: &PanicInfo) -> ! { loop {} } -#[lang = "eh_personality"] -fn eh_personality() {} -#[lang = "eh_unwind_resume"] -fn eh_unwind_resume() {} diff --git a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind.rs b/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind.rs deleted file mode 100644 index 4bb36839d98..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=unwind -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] - -#![no_std] -#![panic_runtime] - -#[no_mangle] -pub extern fn __rust_maybe_catch_panic() {} - -#[no_mangle] -pub extern fn __rust_start_panic() {} - -#[no_mangle] -pub extern fn rust_eh_personality() {} diff --git a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind2.rs b/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind2.rs deleted file mode 100644 index 4bb36839d98..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind2.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=unwind -// no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] - -#![no_std] -#![panic_runtime] - -#[no_mangle] -pub extern fn __rust_maybe_catch_panic() {} - -#[no_mangle] -pub extern fn __rust_start_panic() {} - -#[no_mangle] -pub extern fn rust_eh_personality() {} diff --git a/src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-abort.rs b/src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-abort.rs deleted file mode 100644 index e1902e44a60..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-abort.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=abort -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![no_std] - -extern crate panic_runtime_abort; diff --git a/src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs b/src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs deleted file mode 100644 index 2183338b249..00000000000 --- a/src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![no_std] - -extern crate panic_runtime_unwind; diff --git a/src/test/compile-fail/panic-runtime/bad-panic-flag1.rs b/src/test/compile-fail/panic-runtime/bad-panic-flag1.rs deleted file mode 100644 index f067b6b8349..00000000000 --- a/src/test/compile-fail/panic-runtime/bad-panic-flag1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic=foo -// error-pattern:either `panic` or `abort` was expected - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/bad-panic-flag2.rs b/src/test/compile-fail/panic-runtime/bad-panic-flag2.rs deleted file mode 100644 index 0ecf65f080f..00000000000 --- a/src/test/compile-fail/panic-runtime/bad-panic-flag2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-C panic -// error-pattern:requires either `panic` or `abort` - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/libtest-unwinds.rs b/src/test/compile-fail/panic-runtime/libtest-unwinds.rs deleted file mode 100644 index 71751034c39..00000000000 --- a/src/test/compile-fail/panic-runtime/libtest-unwinds.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:is not compiled with this crate's panic strategy `abort` -// compile-flags:-C panic=abort -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(test)] - -extern crate test; - -fn main() { -} - diff --git a/src/test/compile-fail/panic-runtime/needs-gate.rs b/src/test/compile-fail/panic-runtime/needs-gate.rs deleted file mode 100644 index 1b3b978c408..00000000000 --- a/src/test/compile-fail/panic-runtime/needs-gate.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// gate-test-needs_panic_runtime -// gate-test-panic_runtime - -#![panic_runtime] //~ ERROR: is an experimental feature -#![needs_panic_runtime] //~ ERROR: is an experimental feature - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/runtime-depend-on-needs-runtime.rs b/src/test/compile-fail/panic-runtime/runtime-depend-on-needs-runtime.rs deleted file mode 100644 index 7cfdacbd983..00000000000 --- a/src/test/compile-fail/panic-runtime/runtime-depend-on-needs-runtime.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:needs-panic-runtime.rs -// aux-build:depends.rs -// error-pattern:cannot depend on a crate that needs a panic runtime - -extern crate depends; diff --git a/src/test/compile-fail/panic-runtime/transitive-link-a-bunch.rs b/src/test/compile-fail/panic-runtime/transitive-link-a-bunch.rs deleted file mode 100644 index f886aac9a10..00000000000 --- a/src/test/compile-fail/panic-runtime/transitive-link-a-bunch.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:panic-runtime-unwind.rs -// aux-build:panic-runtime-abort.rs -// aux-build:wants-panic-runtime-unwind.rs -// aux-build:wants-panic-runtime-abort.rs -// aux-build:panic-runtime-lang-items.rs -// error-pattern: is not compiled with this crate's panic strategy `unwind` -// ignore-wasm32-bare compiled with panic=abort by default - -#![no_std] - -extern crate wants_panic_runtime_unwind; -extern crate wants_panic_runtime_abort; -extern crate panic_runtime_lang_items; - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/two-panic-runtimes.rs b/src/test/compile-fail/panic-runtime/two-panic-runtimes.rs deleted file mode 100644 index 0fe0da2fa2c..00000000000 --- a/src/test/compile-fail/panic-runtime/two-panic-runtimes.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:cannot link together two panic runtimes: panic_runtime_unwind and panic_runtime_unwind2 -// ignore-tidy-linelength -// aux-build:panic-runtime-unwind.rs -// aux-build:panic-runtime-unwind2.rs -// aux-build:panic-runtime-lang-items.rs - -#![no_std] - -extern crate panic_runtime_unwind; -extern crate panic_runtime_unwind2; -extern crate panic_runtime_lang_items; - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/want-abort-got-unwind.rs b/src/test/compile-fail/panic-runtime/want-abort-got-unwind.rs deleted file mode 100644 index b178006411b..00000000000 --- a/src/test/compile-fail/panic-runtime/want-abort-got-unwind.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:is not compiled with this crate's panic strategy `abort` -// aux-build:panic-runtime-unwind.rs -// compile-flags:-C panic=abort - -extern crate panic_runtime_unwind; - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/want-abort-got-unwind2.rs b/src/test/compile-fail/panic-runtime/want-abort-got-unwind2.rs deleted file mode 100644 index de8e010c3cb..00000000000 --- a/src/test/compile-fail/panic-runtime/want-abort-got-unwind2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:is not compiled with this crate's panic strategy `abort` -// aux-build:panic-runtime-unwind.rs -// aux-build:wants-panic-runtime-unwind.rs -// compile-flags:-C panic=abort - -extern crate wants_panic_runtime_unwind; - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/want-unwind-got-abort.rs b/src/test/compile-fail/panic-runtime/want-unwind-got-abort.rs deleted file mode 100644 index dda92d9a560..00000000000 --- a/src/test/compile-fail/panic-runtime/want-unwind-got-abort.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:is incompatible with this crate's strategy of `unwind` -// aux-build:panic-runtime-abort.rs -// aux-build:panic-runtime-lang-items.rs -// ignore-wasm32-bare compiled with panic=abort by default - -#![no_std] - -extern crate panic_runtime_abort; -extern crate panic_runtime_lang_items; - -fn main() {} diff --git a/src/test/compile-fail/panic-runtime/want-unwind-got-abort2.rs b/src/test/compile-fail/panic-runtime/want-unwind-got-abort2.rs deleted file mode 100644 index 49f719057d2..00000000000 --- a/src/test/compile-fail/panic-runtime/want-unwind-got-abort2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:is incompatible with this crate's strategy of `unwind` -// aux-build:panic-runtime-abort.rs -// aux-build:wants-panic-runtime-abort.rs -// aux-build:panic-runtime-lang-items.rs -// ignore-wasm32-bare compiled with panic=abort by default - -#![no_std] - -extern crate wants_panic_runtime_abort; -extern crate panic_runtime_lang_items; - -fn main() {} diff --git a/src/test/compile-fail/panic_implementation-closures.rs b/src/test/compile-fail/panic_implementation-closures.rs deleted file mode 100644 index 4fa9a639928..00000000000 --- a/src/test/compile-fail/panic_implementation-closures.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass - -#![crate_type = "rlib"] -#![no_std] -#![feature(panic_implementation)] - -#[panic_implementation] -pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! { - |x: u8| x; - loop {} -} diff --git a/src/test/compile-fail/paren-span.rs b/src/test/compile-fail/paren-span.rs deleted file mode 100644 index 8ed5050f3de..00000000000 --- a/src/test/compile-fail/paren-span.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Be smart about span of parenthesized expression in macro. - -macro_rules! paren { - ($e:expr) => (($e)) - // ^^^^ do not highlight here -} - -mod m { - pub struct S { - x: i32 - } - pub fn make() -> S { - S { x: 0 } - } -} - -fn main() { - let s = m::make(); - paren!(s.x); //~ ERROR field `x` of struct `m::S` is private - // ^^^ highlight here -} diff --git a/src/test/compile-fail/parse-error-correct.rs b/src/test/compile-fail/parse-error-correct.rs deleted file mode 100644 index bc7c333723d..00000000000 --- a/src/test/compile-fail/parse-error-correct.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error - -// Test that the parser is error correcting missing idents. Despite a parsing -// error (or two), we still run type checking (and don't get extra errors there). - -fn main() { - let y = 42; - let x = y.; //~ ERROR unexpected token - let x = y.(); //~ ERROR unexpected token - //~^ ERROR expected function, found `{integer}` - let x = y.foo; //~ ERROR `{integer}` is a primitive type and therefore doesn't have fields [E061 -} diff --git a/src/test/compile-fail/parser-recovery-1.rs b/src/test/compile-fail/parser-recovery-1.rs deleted file mode 100644 index 9fb4d6facdd..00000000000 --- a/src/test/compile-fail/parser-recovery-1.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error - -// Test that we can recover from missing braces in the parser. - -trait Foo { - fn bar() { - let x = foo(); //~ ERROR cannot find function `foo` in this scope - -} - -fn main() { - let x = y.; //~ ERROR unexpected token - //~^ ERROR cannot find value `y` in this scope -} //~ ERROR this file contains an un-closed delimiter diff --git a/src/test/compile-fail/parser-recovery-2.rs b/src/test/compile-fail/parser-recovery-2.rs deleted file mode 100644 index 03b1a9b876f..00000000000 --- a/src/test/compile-fail/parser-recovery-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error - -// Test that we can recover from mismatched braces in the parser. - -trait Foo { - fn bar() { - let x = foo(); //~ ERROR cannot find function `foo` in this scope - ) //~ ERROR incorrect close delimiter: `)` -} - -fn main() { - let x = y.; //~ ERROR unexpected token - //~^ ERROR cannot find value `y` in this scope -} diff --git a/src/test/compile-fail/pat-shadow-in-nested-binding.rs b/src/test/compile-fail/pat-shadow-in-nested-binding.rs deleted file mode 100644 index 3dbe08f1908..00000000000 --- a/src/test/compile-fail/pat-shadow-in-nested-binding.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct foo(usize); - -fn main() { - let (foo, _) = (2, 3); //~ ERROR let bindings cannot shadow tuple structs -} diff --git a/src/test/compile-fail/pat-tuple-bad-type.rs b/src/test/compile-fail/pat-tuple-bad-type.rs deleted file mode 100644 index 251e7b47dcc..00000000000 --- a/src/test/compile-fail/pat-tuple-bad-type.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x; - - match x { - (..) => {} //~ ERROR type annotations needed - _ => {} - } - - match 0u8 { - (..) => {} //~ ERROR mismatched types - _ => {} - } - - x = 10; -} diff --git a/src/test/compile-fail/pat-tuple-overfield.rs b/src/test/compile-fail/pat-tuple-overfield.rs deleted file mode 100644 index 851fa5c5be6..00000000000 --- a/src/test/compile-fail/pat-tuple-overfield.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S(u8, u8, u8); - -fn main() { - match (1, 2, 3) { - (1, 2, 3, 4) => {} //~ ERROR mismatched types - (1, 2, .., 3, 4) => {} //~ ERROR mismatched types - _ => {} - } - match S(1, 2, 3) { - S(1, 2, 3, 4) => {} - //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields - S(1, 2, .., 3, 4) => {} - //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields - _ => {} - } -} diff --git a/src/test/compile-fail/patkind-litrange-no-expr.rs b/src/test/compile-fail/patkind-litrange-no-expr.rs deleted file mode 100644 index 8fef98f815f..00000000000 --- a/src/test/compile-fail/patkind-litrange-no-expr.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! enum_number { - ($name:ident { $($variant:ident = $value:expr, )* }) => { - enum $name { - $($variant = $value,)* - } - - fn foo(value: i32) -> Option<$name> { - match value { - $( $value => Some($name::$variant), )* // PatKind::Lit - $( $value ..= 42 => Some($name::$variant), )* // PatKind::Range - _ => None - } - } - } -} - -enum_number!(Change { - Pos = 1, - Neg = -1, - Arith = 1 + 1, //~ ERROR arbitrary expressions aren't allowed in patterns - //~^ ERROR only char and numeric types are allowed in range patterns -}); - -fn main() {} diff --git a/src/test/compile-fail/pattern-binding-disambiguation.rs b/src/test/compile-fail/pattern-binding-disambiguation.rs deleted file mode 100644 index c740f6bb47c..00000000000 --- a/src/test/compile-fail/pattern-binding-disambiguation.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct UnitStruct; -struct TupleStruct(); -struct BracedStruct{} - -enum E { - UnitVariant, - TupleVariant(), - BracedVariant{}, -} -use E::*; - -const CONST: () = (); -static STATIC: () = (); - -fn function() {} - -fn main() { - let doesnt_matter = 0; - - match UnitStruct { - UnitStruct => {} // OK, `UnitStruct` is a unit struct pattern - } - match doesnt_matter { - TupleStruct => {} //~ ERROR match bindings cannot shadow tuple structs - } - match doesnt_matter { - BracedStruct => {} // OK, `BracedStruct` is a fresh binding - } - match UnitVariant { - UnitVariant => {} // OK, `UnitVariant` is a unit variant pattern - } - match doesnt_matter { - TupleVariant => {} //~ ERROR match bindings cannot shadow tuple variants - } - match doesnt_matter { - BracedVariant => {} //~ ERROR match bindings cannot shadow struct variants - } - match CONST { - CONST => {} // OK, `CONST` is a const pattern - } - match doesnt_matter { - STATIC => {} //~ ERROR match bindings cannot shadow statics - } - match doesnt_matter { - function => {} // OK, `function` is a fresh binding - } - - let UnitStruct = UnitStruct; // OK, `UnitStruct` is a unit struct pattern - let TupleStruct = doesnt_matter; //~ ERROR let bindings cannot shadow tuple structs - let BracedStruct = doesnt_matter; // OK, `BracedStruct` is a fresh binding - let UnitVariant = UnitVariant; // OK, `UnitVariant` is a unit variant pattern - let TupleVariant = doesnt_matter; //~ ERROR let bindings cannot shadow tuple variants - let BracedVariant = doesnt_matter; //~ ERROR let bindings cannot shadow struct variants - let CONST = CONST; // OK, `CONST` is a const pattern - let STATIC = doesnt_matter; //~ ERROR let bindings cannot shadow statics - let function = doesnt_matter; // OK, `function` is a fresh binding -} diff --git a/src/test/compile-fail/pattern-bindings-after-at.rs b/src/test/compile-fail/pattern-bindings-after-at.rs deleted file mode 100644 index da2a97b0ca8..00000000000 --- a/src/test/compile-fail/pattern-bindings-after-at.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Option { - None, - Some(T), -} - -fn main() { - match &mut Some(1) { - ref mut z @ &mut Some(ref a) => { - //~^ ERROR pattern bindings are not allowed after an `@` - **z = None; - println!("{}", *a); - } - _ => () - } -} diff --git a/src/test/compile-fail/pattern-error-continue.rs b/src/test/compile-fail/pattern-error-continue.rs deleted file mode 100644 index e63b84594aa..00000000000 --- a/src/test/compile-fail/pattern-error-continue.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that certain pattern-match type errors are non-fatal - -enum A { - B(isize, isize), - C(isize, isize, isize), - D -} - -struct S { - a: isize -} - -fn f(_c: char) {} - -fn main() { - match A::B(1, 2) { - A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but - A::D(_) => (), //~ ERROR expected tuple struct/variant, found unit variant `A::D` - _ => () - } - match 'c' { - S { .. } => (), - //~^ ERROR mismatched types - //~| expected type `char` - //~| found type `S` - //~| expected char, found struct `S` - - _ => () - } - f(true); - //~^ ERROR mismatched types - //~| expected char, found bool - - match () { - E::V => {} //~ ERROR failed to resolve. Use of undeclared type or module `E` - } -} diff --git a/src/test/compile-fail/pattern-ident-path-generics.rs b/src/test/compile-fail/pattern-ident-path-generics.rs deleted file mode 100644 index 0b7886842b4..00000000000 --- a/src/test/compile-fail/pattern-ident-path-generics.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match Some("foo") { - None:: => {} //~ ERROR mismatched types - Some(_) => {} - } -} diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs deleted file mode 100644 index cd4a98835c8..00000000000 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum bar { t1((), Option>), t2, } - -// n.b. my change changes this error message, but I think it's right -- tjc -fn foo(t: bar) -> isize { match t { bar::t1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } -//~^ ERROR binary operation `*` cannot be applied to - -fn main() { } diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs deleted file mode 100644 index be8d3e027e7..00000000000 --- a/src/test/compile-fail/pattern-tyvar.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -enum bar { t1((), Option >), t2, } - -fn foo(t: bar) { - match t { - bar::t1(_, Some::(x)) => { - println!("{}", x); - } - _ => { panic!(); } - } -} - -fn main() { } diff --git a/src/test/compile-fail/phantom-oibit.rs b/src/test/compile-fail/phantom-oibit.rs deleted file mode 100644 index 51e7d5da98f..00000000000 --- a/src/test/compile-fail/phantom-oibit.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that OIBIT checks `T` when it encounters a `PhantomData` field, instead of checking -// the `PhantomData` type itself (which almost always implements an auto trait) - -#![feature(optin_builtin_traits)] - -use std::marker::{PhantomData}; - -unsafe auto trait Zen {} - -unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} - -struct Guard<'a, T: 'a> { - _marker: PhantomData<&'a T>, -} - -struct Nested(T); - -fn is_zen(_: T) {} - -fn not_sync(x: Guard) { - is_zen(x) - //~^ ERROR `T` cannot be shared between threads safely [E0277] -} - -fn nested_not_sync(x: Nested>) { - is_zen(x) - //~^ ERROR `T` cannot be shared between threads safely [E0277] -} - -fn main() {} diff --git a/src/test/compile-fail/platform-intrinsic-params.rs b/src/test/compile-fail/platform-intrinsic-params.rs deleted file mode 100644 index e8a9031dba8..00000000000 --- a/src/test/compile-fail/platform-intrinsic-params.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(platform_intrinsics)] -extern "platform-intrinsic" { - fn x86_mm_movemask_ps() -> i32; //~ERROR found 0, expected 1 -} - -fn main() { } diff --git a/src/test/compile-fail/pptypedef.rs b/src/test/compile-fail/pptypedef.rs deleted file mode 100644 index 7ece52e7537..00000000000 --- a/src/test/compile-fail/pptypedef.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn let_in(x: T, f: F) where F: FnOnce(T) {} - -fn main() { - let_in(3u32, |i| { assert!(i == 3i32); }); - //~^ ERROR mismatched types - //~| expected u32, found i32 - - let_in(3i32, |i| { assert!(i == 3u32); }); - //~^ ERROR mismatched types - //~| expected i32, found u32 -} diff --git a/src/test/compile-fail/prim-with-args.rs b/src/test/compile-fail/prim-with-args.rs deleted file mode 100644 index cc0b74dc82a..00000000000 --- a/src/test/compile-fail/prim-with-args.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - -let x: isize; //~ ERROR type parameters are not allowed on this type -let x: i8; //~ ERROR type parameters are not allowed on this type -let x: i16; //~ ERROR type parameters are not allowed on this type -let x: i32; //~ ERROR type parameters are not allowed on this type -let x: i64; //~ ERROR type parameters are not allowed on this type -let x: usize; //~ ERROR type parameters are not allowed on this type -let x: u8; //~ ERROR type parameters are not allowed on this type -let x: u16; //~ ERROR type parameters are not allowed on this type -let x: u32; //~ ERROR type parameters are not allowed on this type -let x: u64; //~ ERROR type parameters are not allowed on this type -let x: char; //~ ERROR type parameters are not allowed on this type - -let x: isize<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: i8<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: i16<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: i32<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: i64<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: usize<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: u8<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: u16<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: u32<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: u64<'static>; //~ ERROR lifetime parameters are not allowed on this type -let x: char<'static>; //~ ERROR lifetime parameters are not allowed on this type - -} diff --git a/src/test/compile-fail/priv-in-bad-locations.rs b/src/test/compile-fail/priv-in-bad-locations.rs deleted file mode 100644 index 8901d8c08e5..00000000000 --- a/src/test/compile-fail/priv-in-bad-locations.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub extern { //~ ERROR unnecessary visibility qualifier - pub fn bar(); -} - -trait A { - fn foo(&self) {} -} - -struct B; - -pub impl B {} //~ ERROR unnecessary visibility qualifier - -pub impl A for B { //~ ERROR unnecessary visibility qualifier - pub fn foo(&self) {} //~ ERROR unnecessary visibility qualifier -} - -pub fn main() {} diff --git a/src/test/compile-fail/privacy-in-paths.rs b/src/test/compile-fail/privacy-in-paths.rs deleted file mode 100644 index 0a8689ea6d6..00000000000 --- a/src/test/compile-fail/privacy-in-paths.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub use self::bar::S; - mod bar { - pub struct S; - pub use baz; - } - - trait T { - type Assoc; - } - impl T for () { - type Assoc = S; - } -} - -impl foo::S { - fn f() {} -} - -pub mod baz { - fn f() {} - - fn g() { - ::foo::bar::baz::f(); //~ERROR module `bar` is private - ::foo::bar::S::f(); //~ERROR module `bar` is private - <() as ::foo::T>::Assoc::f(); //~ERROR trait `T` is private - } -} - -fn main() {} diff --git a/src/test/compile-fail/privacy-ns1.rs b/src/test/compile-fail/privacy-ns1.rs deleted file mode 100644 index e7e522f99d4..00000000000 --- a/src/test/compile-fail/privacy-ns1.rs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check we do the correct privacy checks when we import a name and there is an -// item with that name in both the value and type namespaces. - -#![allow(dead_code)] -#![allow(unused_imports)] - - -// public type, private value -pub mod foo1 { - pub trait Bar { - } - pub struct Baz; - - fn Bar() { } -} - -fn test_glob1() { - use foo1::*; - - Bar(); //~ ERROR expected function, found trait `Bar` -} - -// private type, public value -pub mod foo2 { - trait Bar { - } - pub struct Baz; - - pub fn Bar() { } -} - -fn test_glob2() { - use foo2::*; - - let _x: Box; //~ ERROR expected type, found function `Bar` -} - -// neither public -pub mod foo3 { - trait Bar { - } - pub struct Baz; - - fn Bar() { } -} - -fn test_glob3() { - use foo3::*; - - Bar(); //~ ERROR cannot find function `Bar` in this scope - let _x: Box; //~ ERROR cannot find type `Bar` in this scope -} - -fn main() { -} diff --git a/src/test/compile-fail/privacy-ns2.rs b/src/test/compile-fail/privacy-ns2.rs deleted file mode 100644 index ec9396b5e7b..00000000000 --- a/src/test/compile-fail/privacy-ns2.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check we do the correct privacy checks when we import a name and there is an -// item with that name in both the value and type namespaces. - -#![allow(dead_code)] -#![allow(unused_imports)] - - -// public type, private value -pub mod foo1 { - pub trait Bar { - } - pub struct Baz; - - fn Bar() { } -} - -fn test_single1() { - use foo1::Bar; - - Bar(); //~ ERROR expected function, found trait `Bar` -} - -fn test_list1() { - use foo1::{Bar,Baz}; - - Bar(); //~ ERROR expected function, found trait `Bar` -} - -// private type, public value -pub mod foo2 { - trait Bar { - } - pub struct Baz; - - pub fn Bar() { } -} - -fn test_single2() { - use foo2::Bar; - - let _x : Box; //~ ERROR expected type, found function `Bar` -} - -fn test_list2() { - use foo2::{Bar,Baz}; - - let _x: Box; //~ ERROR expected type, found function `Bar` -} - -// neither public -pub mod foo3 { - trait Bar { - } - pub struct Baz; - - fn Bar() { } -} - -fn test_unused3() { - use foo3::Bar; //~ ERROR `Bar` is private -} - -fn test_single3() { - use foo3::Bar; //~ ERROR `Bar` is private - - Bar(); - let _x: Box; -} - -fn test_list3() { - use foo3::{Bar,Baz}; //~ ERROR `Bar` is private - - Bar(); - let _x: Box; -} - -fn main() { -} diff --git a/src/test/compile-fail/privacy-sanity.rs b/src/test/compile-fail/privacy-sanity.rs deleted file mode 100644 index f245b7cef29..00000000000 --- a/src/test/compile-fail/privacy-sanity.rs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -pub trait Tr { - fn f(); - const C: u8; - type T; -} -pub struct S { - pub a: u8 -} -struct Ts(pub u8); - -pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier -} -pub impl S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} - pub const C: u8 = 0; - // pub type T = u8; -} -pub extern "C" { //~ ERROR unnecessary visibility qualifier - pub fn f(); - pub static St: u8; -} - -const MAIN: u8 = { - pub trait Tr { - fn f(); - const C: u8; - type T; - } - pub struct S { - pub a: u8 - } - struct Ts(pub u8); - - pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier - } - pub impl S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} - pub const C: u8 = 0; - // pub type T = u8; - } - pub extern "C" { //~ ERROR unnecessary visibility qualifier - pub fn f(); - pub static St: u8; - } - - 0 -}; - -fn main() { - pub trait Tr { - fn f(); - const C: u8; - type T; - } - pub struct S { - pub a: u8 - } - struct Ts(pub u8); - - pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier - } - pub impl S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} - pub const C: u8 = 0; - // pub type T = u8; - } - pub extern "C" { //~ ERROR unnecessary visibility qualifier - pub fn f(); - pub static St: u8; - } -} diff --git a/src/test/compile-fail/privacy-ufcs.rs b/src/test/compile-fail/privacy-ufcs.rs deleted file mode 100644 index 28c1a003e39..00000000000 --- a/src/test/compile-fail/privacy-ufcs.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test to ensure private traits are inaccessible with UFCS angle-bracket syntax. - -mod foo { - trait Bar { - fn baz() {} - } - - impl Bar for i32 {} -} - -fn main() { - ::baz(); //~ERROR trait `Bar` is private -} diff --git a/src/test/compile-fail/privacy/associated-item-privacy-inherent.rs b/src/test/compile-fail/privacy/associated-item-privacy-inherent.rs deleted file mode 100644 index 63cb6e82c25..00000000000 --- a/src/test/compile-fail/privacy/associated-item-privacy-inherent.rs +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(decl_macro, associated_type_defaults)] -#![allow(unused, private_in_public)] - -mod priv_nominal { - pub struct Pub; - impl Pub { - fn method(&self) {} - const CONST: u8 = 0; - // type AssocTy = u8; - } - - pub macro mac() { - let value = Pub::method; - //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private - value; - //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private - Pub.method(); - //~^ ERROR type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private - Pub::CONST; - //~^ ERROR associated constant `CONST` is private - // let _: Pub::AssocTy; - // pub type InSignatureTy = Pub::AssocTy; - } -} -fn priv_nominal() { - priv_nominal::mac!(); -} - -mod priv_signature { - struct Priv; - pub struct Pub; - impl Pub { - pub fn method(&self, arg: Priv) {} - } - - pub macro mac() { - let value = Pub::method; - //~^ ERROR type `priv_signature::Priv` is private - value; - //~^ ERROR type `priv_signature::Priv` is private - Pub.method(loop {}); - //~^ ERROR type `priv_signature::Priv` is private - } -} -fn priv_signature() { - priv_signature::mac!(); -} - -mod priv_substs { - struct Priv; - pub struct Pub; - impl Pub { - pub fn method(&self) {} - } - - pub macro mac() { - let value = Pub::method::; - //~^ ERROR type `priv_substs::Priv` is private - value; - //~^ ERROR type `priv_substs::Priv` is private - Pub.method::(); - //~^ ERROR type `priv_substs::Priv` is private - } -} -fn priv_substs() { - priv_substs::mac!(); -} - -mod priv_parent_substs { - struct Priv; - pub struct Pub(T); - impl Pub { - pub fn method(&self) {} - pub fn static_method() {} - pub const CONST: u8 = 0; - // pub type AssocTy = u8; - } - - pub macro mac() { - let value = ::method; - //~^ ERROR type `priv_parent_substs::Priv` is private - value; - //~^ ERROR type `priv_parent_substs::Priv` is private - let value = Pub::method; - //~^ ERROR type `priv_parent_substs::Priv` is private - value; - //~^ ERROR type `priv_parent_substs::Priv` is private - let value = ::static_method; - //~^ ERROR type `priv_parent_substs::Priv` is private - value; - //~^ ERROR type `priv_parent_substs::Priv` is private - let value = Pub::static_method; - //~^ ERROR type `priv_parent_substs::Priv` is private - value; - //~^ ERROR type `priv_parent_substs::Priv` is private - Pub(Priv).method(); - //~^ ERROR type `priv_parent_substs::Priv` is private - - ::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private - Pub::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private - - // let _: Pub::AssocTy; - // pub type InSignatureTy = Pub::AssocTy; - } -} -fn priv_parent_substs() { - priv_parent_substs::mac!(); -} - -fn main() {} diff --git a/src/test/compile-fail/privacy/associated-item-privacy-trait.rs b/src/test/compile-fail/privacy/associated-item-privacy-trait.rs deleted file mode 100644 index bdc0c680a92..00000000000 --- a/src/test/compile-fail/privacy/associated-item-privacy-trait.rs +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#![feature(decl_macro, associated_type_defaults)] -#![allow(unused, private_in_public)] - -mod priv_trait { - trait PrivTr { - fn method(&self) {} - const CONST: u8 = 0; - type AssocTy = u8; - } - pub struct Pub; - impl PrivTr for Pub {} - pub trait PubTr: PrivTr {} - - pub macro mac() { - let value = ::method; - //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private - value; - //~^ ERROR type `for<'r> fn(&'r priv_trait::Pub) {::method}` is private - Pub.method(); - //~^ ERROR type `for<'r> fn(&'r Self) {::method}` is private - ::CONST; - //~^ ERROR associated constant `PrivTr::CONST` is private - let _: ::AssocTy; - //~^ ERROR trait `priv_trait::PrivTr` is private - //~| ERROR trait `priv_trait::PrivTr` is private - pub type InSignatureTy = ::AssocTy; - //~^ ERROR trait `priv_trait::PrivTr` is private - pub trait InSignatureTr: PrivTr {} - //~^ ERROR trait `priv_trait::PrivTr` is private - impl PrivTr for u8 {} - //~^ ERROR trait `priv_trait::PrivTr` is private - } -} -fn priv_trait() { - priv_trait::mac!(); -} - -mod priv_signature { - pub trait PubTr { - fn method(&self, arg: Priv) {} - } - struct Priv; - pub struct Pub; - impl PubTr for Pub {} - - pub macro mac() { - let value = ::method; - //~^ ERROR type `priv_signature::Priv` is private - value; - //~^ ERROR type `priv_signature::Priv` is private - Pub.method(loop {}); - //~^ ERROR type `priv_signature::Priv` is private - } -} -fn priv_signature() { - priv_signature::mac!(); -} - -mod priv_substs { - pub trait PubTr { - fn method(&self) {} - } - struct Priv; - pub struct Pub; - impl PubTr for Pub {} - - pub macro mac() { - let value = ::method::; - //~^ ERROR type `priv_substs::Priv` is private - value; - //~^ ERROR type `priv_substs::Priv` is private - Pub.method::(); - //~^ ERROR type `priv_substs::Priv` is private - } -} -fn priv_substs() { - priv_substs::mac!(); -} - -mod priv_parent_substs { - pub trait PubTr { - fn method(&self) {} - const CONST: u8 = 0; - type AssocTy = u8; - } - struct Priv; - pub struct Pub; - impl PubTr for Pub {} - impl PubTr for Priv {} - - pub macro mac() { - let value = ::method; - //~^ ERROR type `priv_parent_substs::Priv` is private - value; - //~^ ERROR type `priv_parent_substs::Priv` is private - let value = >::method; - //~^ ERROR type `priv_parent_substs::Priv` is private - value; - //~^ ERROR type `priv_parent_substs::Priv` is private - Pub.method(); - //~^ ERROR type `priv_parent_substs::Priv` is private - - let value = >::method; - //~^ ERROR type `priv_parent_substs::Priv` is private - value; - //~^ ERROR type `priv_parent_substs::Priv` is private - Priv.method(); - //~^ ERROR type `priv_parent_substs::Priv` is private - - ::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private - >::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private - >::CONST; - //~^ ERROR type `priv_parent_substs::Priv` is private - - let _: ::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private - let _: >::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private - let _: >::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private - - pub type InSignatureTy1 = ::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - pub type InSignatureTy2 = >::AssocTy; - //~^ ERROR type `priv_parent_substs::Priv` is private - impl PubTr for u8 {} - //~^ ERROR type `priv_parent_substs::Priv` is private - } -} -fn priv_parent_substs() { - priv_parent_substs::mac!(); -} - -fn main() {} diff --git a/src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs b/src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs deleted file mode 100644 index 6019369aa2e..00000000000 --- a/src/test/compile-fail/privacy/associated-item-privacy-type-binding.rs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(decl_macro, associated_type_defaults)] -#![allow(unused, private_in_public)] - -mod priv_trait { - trait PrivTr { - type AssocTy = u8; - } - pub trait PubTr: PrivTr {} - - pub macro mac1() { - let _: Box>; - //~^ ERROR type `(dyn priv_trait::PubTr + ')` is private - //~| ERROR type `(dyn priv_trait::PubTr + ')` is private - type InSignatureTy2 = Box>; - //~^ ERROR type `(dyn priv_trait::PubTr + 'static)` is private - trait InSignatureTr2: PubTr {} - //~^ ERROR trait `priv_trait::PrivTr` is private - } - pub macro mac2() { - let _: Box>; - //~^ ERROR type `(dyn priv_trait::PrivTr + ')` is private - //~| ERROR type `(dyn priv_trait::PrivTr + ')` is private - type InSignatureTy1 = Box>; - //~^ ERROR type `(dyn priv_trait::PrivTr + 'static)` is private - trait InSignatureTr1: PrivTr {} - //~^ ERROR trait `priv_trait::PrivTr` is private - } -} -fn priv_trait1() { - priv_trait::mac1!(); -} -fn priv_trait2() { - priv_trait::mac2!(); -} - -mod priv_parent_substs { - pub trait PubTrWithParam { - type AssocTy = u8; - } - struct Priv; - pub trait PubTr: PubTrWithParam {} - - pub macro mac() { - let _: Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private - let _: Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private - //~| ERROR type `priv_parent_substs::Priv` is private - pub type InSignatureTy1 = Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private - pub type InSignatureTy2 = Box>; - //~^ ERROR type `priv_parent_substs::Priv` is private - trait InSignatureTr1: PubTrWithParam {} - //~^ ERROR type `priv_parent_substs::Priv` is private - trait InSignatureTr2: PubTr {} - //~^ ERROR type `priv_parent_substs::Priv` is private - } -} -fn priv_parent_substs() { - priv_parent_substs::mac!(); -} - -fn main() {} diff --git a/src/test/compile-fail/privacy/legacy-ctor-visibility.rs b/src/test/compile-fail/privacy/legacy-ctor-visibility.rs deleted file mode 100644 index 95144916fd7..00000000000 --- a/src/test/compile-fail/privacy/legacy-ctor-visibility.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#![allow(unused)] - -use m::S; - -mod m { - pub struct S(u8); - - mod n { - use S; - fn f() { - S(10); - //~^ ERROR private struct constructors are not usable through re-exports in outer modules - //~| WARN this was previously accepted - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs b/src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs deleted file mode 100644 index c4ab96c8456..00000000000 --- a/src/test/compile-fail/privacy/restricted/auxiliary/pub_restricted.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(crate_visibility_modifier)] - -pub(crate) struct Crate; - -#[derive(Default)] -pub struct Universe { - pub x: i32, - pub(crate) y: i32, - crate z: i32, -} - -impl Universe { - pub fn f(&self) {} - pub(crate) fn g(&self) {} - crate fn h(&self) {} -} diff --git a/src/test/compile-fail/privacy/restricted/lookup-ignores-private.rs b/src/test/compile-fail/privacy/restricted/lookup-ignores-private.rs deleted file mode 100644 index abd71b9c90b..00000000000 --- a/src/test/compile-fail/privacy/restricted/lookup-ignores-private.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -mod foo { - pub use foo::bar::S; - mod bar { - #[derive(Default)] - pub struct S { - pub(in foo) x: i32, - } - impl S { - pub(in foo) fn f(&self) -> i32 { 0 } - } - - pub struct S2 { - pub(crate) x: bool, - } - impl S2 { - pub(crate) fn f(&self) -> bool { false } - } - - impl ::std::ops::Deref for S { - type Target = S2; - fn deref(&self) -> &S2 { unimplemented!() } - } - } -} - -#[rustc_error] -fn main() { //~ ERROR compilation successful - let s = foo::S::default(); - let _: bool = s.x; - let _: bool = s.f(); -} diff --git a/src/test/compile-fail/privacy/restricted/private-in-public.rs b/src/test/compile-fail/privacy/restricted/private-in-public.rs deleted file mode 100644 index 4d3f5377797..00000000000 --- a/src/test/compile-fail/privacy/restricted/private-in-public.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(crate_visibility_modifier)] - -mod foo { - struct Priv; - mod bar { - use foo::Priv; - pub(super) fn f(_: Priv) {} - pub(crate) fn g(_: Priv) {} //~ ERROR E0446 - crate fn h(_: Priv) {} //~ ERROR E0446 - } -} - -fn main() { } diff --git a/src/test/compile-fail/privacy/restricted/struct-literal-field.rs b/src/test/compile-fail/privacy/restricted/struct-literal-field.rs deleted file mode 100644 index 21d90dfea4b..00000000000 --- a/src/test/compile-fail/privacy/restricted/struct-literal-field.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(warnings)] - -mod foo { - pub mod bar { - pub struct S { - pub(in foo) x: i32, - } - } - - fn f() { - use foo::bar::S; - S { x: 0 }; // ok - } -} - -fn main() { - use foo::bar::S; - S { x: 0 }; //~ ERROR private -} diff --git a/src/test/compile-fail/privacy/restricted/test.rs b/src/test/compile-fail/privacy/restricted/test.rs deleted file mode 100644 index 8c1d609e244..00000000000 --- a/src/test/compile-fail/privacy/restricted/test.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:pub_restricted.rs - -#![allow(warnings)] -extern crate pub_restricted; - -mod foo { - pub mod bar { - pub(super) fn f() {} - #[derive(Default)] - pub struct S { - pub(super) x: i32, - } - impl S { - pub(super) fn f(&self) {} - pub(super) fn g() {} - } - } - fn f() { - use foo::bar::S; - pub(self) use foo::bar::f; // ok - pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported - S::default().x; // ok - S::default().f(); // ok - S::g(); // ok - } -} - -fn f() { - use foo::bar::S; - use foo::bar::f; //~ ERROR private - S::default().x; //~ ERROR private - S::default().f(); //~ ERROR private - S::g(); //~ ERROR private -} - -fn main() { - use pub_restricted::Universe; - use pub_restricted::Crate; //~ ERROR private - - let u = Universe::default(); - let _ = u.x; - let _ = u.y; //~ ERROR private - let _ = u.z; //~ ERROR private - u.f(); - u.g(); //~ ERROR private - u.h(); //~ ERROR private -} - -mod pathological { - pub(in bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`? - pub(in foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules -} diff --git a/src/test/compile-fail/privacy/union-field-privacy-1.rs b/src/test/compile-fail/privacy/union-field-privacy-1.rs deleted file mode 100644 index eeebb1b737a..00000000000 --- a/src/test/compile-fail/privacy/union-field-privacy-1.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m { - pub union U { - pub a: u8, - pub(super) b: u8, - c: u8, - } -} - -fn main() { unsafe { - let u = m::U { a: 0 }; // OK - let u = m::U { b: 0 }; // OK - let u = m::U { c: 0 }; //~ ERROR field `c` of union `m::U` is private - - let m::U { a } = u; // OK - let m::U { b } = u; // OK - let m::U { c } = u; //~ ERROR field `c` of union `m::U` is private -}} diff --git a/src/test/compile-fail/privacy/union-field-privacy-2.rs b/src/test/compile-fail/privacy/union-field-privacy-2.rs deleted file mode 100644 index d6bb765202d..00000000000 --- a/src/test/compile-fail/privacy/union-field-privacy-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m { - pub union U { - pub a: u8, - pub(super) b: u8, - c: u8, - } -} - -fn main() { - let u = m::U { a: 10 }; - - let a = u.a; // OK - let b = u.b; // OK - let c = u.c; //~ ERROR field `c` of struct `m::U` is private -} diff --git a/src/test/compile-fail/privacy1.rs b/src/test/compile-fail/privacy1.rs deleted file mode 100644 index afe8c2fda3d..00000000000 --- a/src/test/compile-fail/privacy1.rs +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(lang_items, start, no_core)] -#![no_core] // makes debugging this test *a lot* easier (during resolve) - -#[lang="sized"] -pub trait Sized {} - -#[lang="copy"] -pub trait Copy {} - -mod bar { - // shouldn't bring in too much - pub use self::glob::*; - - // can't publicly re-export private items - pub use self::baz::{foo, bar}; - - pub struct A; - impl A { - pub fn foo() {} - fn bar() {} - - pub fn foo2(&self) {} - fn bar2(&self) {} - } - - trait B { - fn foo() -> Self; - } - - impl B for isize { fn foo() -> isize { 3 } } - - pub enum Enum { - Pub - } - - mod baz { - pub struct A; - impl A { - pub fn foo() {} - fn bar() {} - - pub fn foo2(&self) {} - fn bar2(&self) {} - } - - pub fn foo() {} - pub fn bar() {} - } - - extern { - fn epriv(); - pub fn epub(); - } - - fn test() { - self::Enum::Pub; - unsafe { - epriv(); - epub(); - } - self::baz::A; - self::baz::A::foo(); - self::baz::A::bar(); //~ ERROR: method `bar` is private - self::baz::A.foo2(); - - // this used to cause an ICE in privacy traversal. - super::gpub(); - } - - mod glob { - pub fn gpub() {} - fn gpriv() {} - } -} - -pub fn gpub() {} - -fn lol() { - bar::A; - bar::A::foo(); - bar::A::bar(); //~ ERROR: method `bar` is private - bar::A.foo2(); -} - -mod foo { - fn test() { - ::bar::A::foo(); - ::bar::A::bar(); //~ ERROR: method `bar` is private - ::bar::A.foo2(); - ::bar::baz::A::foo(); //~ ERROR: module `baz` is private - ::bar::baz::A::bar(); //~ ERROR: module `baz` is private - //~^ ERROR: method `bar` is private - ::bar::baz::A.foo2(); //~ ERROR: module `baz` is private - ::bar::baz::A.bar2(); //~ ERROR: module `baz` is private - //~^ ERROR: method `bar2` is private - - let _: isize = - ::bar::B::foo(); //~ ERROR: trait `B` is private - ::lol(); - - ::bar::Enum::Pub; - - unsafe { - ::bar::epriv(); //~ ERROR: function `epriv` is private - ::bar::epub(); - } - - ::bar::foo(); - ::bar::bar(); - - ::bar::gpub(); - - ::bar::baz::foo(); //~ ERROR: module `baz` is private - ::bar::baz::bar(); //~ ERROR: module `baz` is private - } - - fn test2() { - use bar::baz::{foo, bar}; - //~^ ERROR: module `baz` is private - //~| ERROR: module `baz` is private - - foo(); - bar(); - } - - fn test3() { - use bar::baz; - //~^ ERROR: module `baz` is private - } - - fn test4() { - use bar::{foo, bar}; - foo(); - bar(); - } - - fn test5() { - use bar; - bar::foo(); - bar::bar(); - } - - impl ::bar::B for f32 { fn foo() -> f32 { 1.0 } } - //~^ ERROR: trait `B` is private -} - -pub mod mytest { - // Even though the inner `A` struct is a publicly exported item (usable from - // external crates through `foo::foo`, it should not be accessible through - // its definition path (which has the private `i` module). - use self::foo::i::A; //~ ERROR: module `i` is private - - pub mod foo { - pub use self::i::A as foo; - - mod i { - pub struct A; - } - } -} - -#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/compile-fail/privacy2.rs b/src/test/compile-fail/privacy2.rs deleted file mode 100644 index 113dd287940..00000000000 --- a/src/test/compile-fail/privacy2.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(start, no_core)] -#![no_core] // makes debugging this test *a lot* easier (during resolve) - -// Test to make sure that globs don't leak in regular `use` statements. - -mod bar { - pub use self::glob::*; - - pub mod glob { - use foo; - } -} - -pub fn foo() {} - -fn test1() { - use bar::foo; - //~^ ERROR unresolved import `bar::foo` [E0432] - //~| no `foo` in `bar` -} - -fn test2() { - use bar::glob::foo; - //~^ ERROR `foo` is private -} - -#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/compile-fail/privacy3.rs b/src/test/compile-fail/privacy3.rs deleted file mode 100644 index b841717bd11..00000000000 --- a/src/test/compile-fail/privacy3.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(start, no_core)] -#![no_core] // makes debugging this test *a lot* easier (during resolve) - -// Test to make sure that private items imported through globs remain private -// when they're used. - -mod bar { - pub use self::glob::*; - - mod glob { - fn gpriv() {} - } -} - -pub fn foo() {} - -fn test1() { - use bar::gpriv; - //~^ ERROR unresolved import `bar::gpriv` [E0432] - //~| no `gpriv` in `bar` - - // This should pass because the compiler will insert a fake name binding - // for `gpriv` - gpriv(); -} - -#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/compile-fail/privacy4.rs b/src/test/compile-fail/privacy4.rs deleted file mode 100644 index d9f76744284..00000000000 --- a/src/test/compile-fail/privacy4.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(lang_items, start, no_core)] -#![no_core] // makes debugging this test *a lot* easier (during resolve) - -#[lang = "sized"] pub trait Sized {} -#[lang="copy"] pub trait Copy {} - -// Test to make sure that private items imported through globs remain private -// when they're used. - -mod bar { - pub use self::glob::*; - - mod glob { - fn gpriv() {} - } -} - -pub fn foo() {} - -fn test2() { - use bar::glob::gpriv; //~ ERROR: module `glob` is private - gpriv(); -} - -#[start] fn main(_: isize, _: *const *const u8) -> isize { 3 } diff --git a/src/test/compile-fail/privacy5.rs b/src/test/compile-fail/privacy5.rs deleted file mode 100644 index 599c1f87160..00000000000 --- a/src/test/compile-fail/privacy5.rs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:privacy_tuple_struct.rs - -extern crate privacy_tuple_struct as other; - -mod a { - pub struct A(()); - pub struct B(isize); - pub struct C(pub isize, isize); - pub struct D(pub isize); - - fn test() { - let a = A(()); - let b = B(2); - let c = C(2, 3); - let d = D(4); - - let A(()) = a; - let A(_) = a; - match a { A(()) => {} } - match a { A(_) => {} } - - let B(_) = b; - let B(_b) = b; - match b { B(_) => {} } - match b { B(_b) => {} } - match b { B(1) => {} B(_) => {} } - - let C(_, _) = c; - let C(_a, _) = c; - let C(_, _b) = c; - let C(_a, _b) = c; - match c { C(_, _) => {} } - match c { C(_a, _) => {} } - match c { C(_, _b) => {} } - match c { C(_a, _b) => {} } - - let D(_) = d; - let D(_d) = d; - match d { D(_) => {} } - match d { D(_d) => {} } - match d { D(1) => {} D(_) => {} } - - let a2 = A; - let b2 = B; - let c2 = C; - let d2 = D; - } -} - -fn this_crate() { - let a = a::A(()); //~ ERROR tuple struct `A` is private - let b = a::B(2); //~ ERROR tuple struct `B` is private - let c = a::C(2, 3); //~ ERROR tuple struct `C` is private - let d = a::D(4); - - let a::A(()) = a; //~ ERROR tuple struct `A` is private - let a::A(_) = a; //~ ERROR tuple struct `A` is private - match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private - match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private - - let a::B(_) = b; //~ ERROR tuple struct `B` is private - let a::B(_b) = b; //~ ERROR tuple struct `B` is private - match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private - match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private - match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private - //~^ ERROR tuple struct `B` is private - - let a::C(_, _) = c; //~ ERROR tuple struct `C` is private - let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private - let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private - let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private - match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private - - let a::D(_) = d; - let a::D(_d) = d; - match d { a::D(_) => {} } - match d { a::D(_d) => {} } - match d { a::D(1) => {} a::D(_) => {} } - - let a2 = a::A; //~ ERROR tuple struct `A` is private - let b2 = a::B; //~ ERROR tuple struct `B` is private - let c2 = a::C; //~ ERROR tuple struct `C` is private - let d2 = a::D; -} - -fn xcrate() { - let a = other::A(()); //~ ERROR tuple struct `A` is private - let b = other::B(2); //~ ERROR tuple struct `B` is private - let c = other::C(2, 3); //~ ERROR tuple struct `C` is private - let d = other::D(4); - - let other::A(()) = a; //~ ERROR tuple struct `A` is private - let other::A(_) = a; //~ ERROR tuple struct `A` is private - match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private - match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private - - let other::B(_) = b; //~ ERROR tuple struct `B` is private - let other::B(_b) = b; //~ ERROR tuple struct `B` is private - match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private - match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private - match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private - //~^ ERROR tuple struct `B` is private - - let other::C(_, _) = c; //~ ERROR tuple struct `C` is private - let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private - let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private - let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private - match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private - - let other::D(_) = d; - let other::D(_d) = d; - match d { other::D(_) => {} } - match d { other::D(_d) => {} } - match d { other::D(1) => {} other::D(_) => {} } - - let a2 = other::A; //~ ERROR tuple struct `A` is private - let b2 = other::B; //~ ERROR tuple struct `B` is private - let c2 = other::C; //~ ERROR tuple struct `C` is private - let d2 = other::D; -} - -fn main() {} diff --git a/src/test/compile-fail/private-impl-method.rs b/src/test/compile-fail/private-impl-method.rs deleted file mode 100644 index e04380f12ac..00000000000 --- a/src/test/compile-fail/private-impl-method.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub struct Foo { - pub x: isize - } - - impl Foo { - fn foo(&self) {} - } -} - -fn f() { - impl a::Foo { - fn bar(&self) {} // This should be visible outside `f` - } -} - -fn main() { - let s = a::Foo { x: 1 }; - s.bar(); - s.foo(); //~ ERROR method `foo` is private -} diff --git a/src/test/compile-fail/private-in-public-assoc-ty.rs b/src/test/compile-fail/private-in-public-assoc-ty.rs deleted file mode 100644 index 59dee256642..00000000000 --- a/src/test/compile-fail/private-in-public-assoc-ty.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Private types and traits are not allowed in interfaces of associated types. -// This test also ensures that the checks are performed even inside private modules. - -#![feature(associated_type_defaults)] - -mod m { - struct Priv; - trait PrivTr {} - impl PrivTr for Priv {} - pub trait PubTrAux1 {} - pub trait PubTrAux2 { type A; } - - // "Private-in-public in associated types is hard error" in RFC 2145 - // applies only to the aliased types, not bounds. - pub trait PubTr { - //~^ WARN private trait `m::PrivTr` in public interface - //~| WARN this was previously accepted - //~| WARN private type `m::Priv` in public interface - //~| WARN this was previously accepted - type Alias1: PrivTr; - type Alias2: PubTrAux1 = u8; - type Alias3: PubTrAux2 = u8; - - type Alias4 = Priv; - //~^ ERROR private type `m::Priv` in public interface - } - impl PubTr for u8 { - type Alias1 = Priv; - //~^ ERROR private type `m::Priv` in public interface - } -} - -fn main() {} diff --git a/src/test/compile-fail/private-in-public-ill-formed.rs b/src/test/compile-fail/private-in-public-ill-formed.rs deleted file mode 100644 index 480406054ad..00000000000 --- a/src/test/compile-fail/private-in-public-ill-formed.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod aliases_pub { - struct Priv; - mod m { - pub struct Pub3; - } - - trait PrivTr { - type AssocAlias; - } - impl PrivTr for Priv { - type AssocAlias = m::Pub3; - } - - impl ::AssocAlias { //~ ERROR no base type found for inherent implementation - pub fn f(arg: Priv) {} // private type `aliases_pub::Priv` in public interface - } -} - -mod aliases_priv { - struct Priv; - struct Priv3; - - trait PrivTr { - type AssocAlias; - } - impl PrivTr for Priv { - type AssocAlias = Priv3; - } - - impl ::AssocAlias { //~ ERROR no base type found for inherent implementation - pub fn f(arg: Priv) {} // OK - } -} - -fn main() {} diff --git a/src/test/compile-fail/private-in-public-lint.rs b/src/test/compile-fail/private-in-public-lint.rs deleted file mode 100644 index fd92300cd15..00000000000 --- a/src/test/compile-fail/private-in-public-lint.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m1 { - pub struct Pub; - struct Priv; - - impl Pub { - pub fn f() -> Priv {Priv} //~ ERROR private type `m1::Priv` in public interface - } -} - -mod m2 { - pub struct Pub; - struct Priv; - - impl Pub { - pub fn f() -> Priv {Priv} //~ ERROR private type `m2::Priv` in public interface - } -} - -fn main() {} diff --git a/src/test/compile-fail/private-in-public-warn.rs b/src/test/compile-fail/private-in-public-warn.rs deleted file mode 100644 index 6eeb14638e7..00000000000 --- a/src/test/compile-fail/private-in-public-warn.rs +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Private types and traits are not allowed in public interfaces. -// This test also ensures that the checks are performed even inside private modules. - -#![feature(associated_type_defaults)] -#![deny(private_in_public)] -#![allow(improper_ctypes)] - -mod types { - struct Priv; - pub struct Pub; - pub trait PubTr { - type Alias; - } - - pub type Alias = Priv; //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - pub enum E { - V1(Priv), //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - V2 { field: Priv }, //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - } - pub trait Tr { - const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - type Alias = Priv; //~ ERROR private type `types::Priv` in public interface - fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - } - extern { - pub static ES: Priv; //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - pub fn ef1(arg: Priv); //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - pub fn ef2() -> Priv; //~ ERROR private type `types::Priv` in public interface - //~^ WARNING hard error - } - impl PubTr for Pub { - type Alias = Priv; //~ ERROR private type `types::Priv` in public interface - } -} - -mod traits { - trait PrivTr {} - pub struct Pub(T); - pub trait PubTr {} - - pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface - //~| WARNING hard error - pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARNING hard error - pub trait Tr2 {} //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARNING hard error - pub trait Tr3 { - //~^ ERROR private trait `traits::PrivTr` in public interface - //~| WARNING hard error - type Alias: PrivTr; - fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARNING hard error - } - impl Pub {} //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARNING hard error - impl PubTr for Pub {} //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARNING hard error -} - -mod traits_where { - trait PrivTr {} - pub struct Pub(T); - pub trait PubTr {} - - pub type Alias where T: PrivTr = T; - //~^ ERROR private trait `traits_where::PrivTr` in public interface - //~| WARNING hard error - pub trait Tr2 where T: PrivTr {} - //~^ ERROR private trait `traits_where::PrivTr` in public interface - //~| WARNING hard error - pub trait Tr3 { - fn f(arg: T) where T: PrivTr {} - //~^ ERROR private trait `traits_where::PrivTr` in public interface - //~| WARNING hard error - } - impl Pub where T: PrivTr {} - //~^ ERROR private trait `traits_where::PrivTr` in public interface - //~| WARNING hard error - impl PubTr for Pub where T: PrivTr {} - //~^ ERROR private trait `traits_where::PrivTr` in public interface - //~| WARNING hard error -} - -mod generics { - struct Priv(T); - pub struct Pub(T); - trait PrivTr {} - pub trait PubTr {} - - pub trait Tr1: PrivTr {} - //~^ ERROR private trait `generics::PrivTr` in public interface - //~| WARNING hard error - pub trait Tr2: PubTr {} //~ ERROR private type `generics::Priv` in public interface - //~^ WARNING hard error - pub trait Tr3: PubTr<[Priv; 1]> {} //~ ERROR private type `generics::Priv` in public interface - //~^ WARNING hard error - pub trait Tr4: PubTr> {} //~ ERROR private type `generics::Priv` in public interface - //~^ WARNING hard error -} - -mod impls { - struct Priv; - pub struct Pub; - trait PrivTr { - type Alias; - } - pub trait PubTr { - type Alias; - } - - impl Priv { - pub fn f(arg: Priv) {} // OK - } - impl PrivTr for Priv { - type Alias = Priv; // OK - } - impl PubTr for Priv { - type Alias = Priv; // OK - } - impl PrivTr for Pub { - type Alias = Priv; // OK - } - impl PubTr for Pub { - type Alias = Priv; //~ ERROR private type `impls::Priv` in public interface - } -} - -mod impls_generics { - struct Priv(T); - pub struct Pub(T); - trait PrivTr { - type Alias; - } - pub trait PubTr { - type Alias; - } - - impl Priv { - pub fn f(arg: Priv) {} // OK - } - impl Pub { - pub fn f(arg: Priv) {} // OK - } - impl PrivTr for Priv { - type Alias = Priv; // OK - } - impl PubTr for Priv { - type Alias = Priv; // OK - } - impl PubTr for Priv { - type Alias = Priv; // OK - } - impl PubTr for [Priv; 1] { - type Alias = Priv; // OK - } - impl PubTr for Pub { - type Alias = Priv; // OK - } - impl PrivTr for Pub { - type Alias = Priv; // OK - } - impl PubTr for Pub { - type Alias = Priv; // OK - } -} - -mod aliases_pub { - struct Priv; - mod m { - pub struct Pub1; - pub struct Pub2; - pub struct Pub3; - pub trait PubTr { - type Check = u8; - } - } - - use self::m::Pub1 as PrivUseAlias; - use self::m::PubTr as PrivUseAliasTr; - type PrivAlias = m::Pub2; - trait PrivTr { - type AssocAlias; - } - impl PrivTr for Priv { - type AssocAlias = m::Pub3; - } - - pub fn f1(arg: PrivUseAlias) {} // OK - pub fn f2(arg: PrivAlias) {} // OK - - pub trait Tr1: PrivUseAliasTr {} // OK - pub trait Tr2: PrivUseAliasTr {} // OK - - impl PrivAlias { - pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface - //~^ WARNING hard error - } - impl PrivUseAliasTr for PrivUseAlias { - type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface - } - impl PrivUseAliasTr for PrivAlias { - type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface - } - impl PrivUseAliasTr for ::AssocAlias { - type Check = Priv; //~ ERROR private type `aliases_pub::Priv` in public interface - } -} - -mod aliases_priv { - struct Priv; - - struct Priv1; - struct Priv2; - struct Priv3; - trait PrivTr1 { - type Check = u8; - } - - use self::Priv1 as PrivUseAlias; - use self::PrivTr1 as PrivUseAliasTr; - type PrivAlias = Priv2; - trait PrivTr { - type AssocAlias; - } - impl PrivTr for Priv { - type AssocAlias = Priv3; - } - - pub trait Tr1: PrivUseAliasTr {} - //~^ ERROR private trait `aliases_priv::PrivTr1` in public interface - //~| WARNING hard error - pub trait Tr2: PrivUseAliasTr {} - //~^ ERROR private trait `aliases_priv::PrivTr1` in public interface - //~| WARNING hard error - //~| ERROR private type `aliases_priv::Priv2` in public interface - //~| WARNING hard error - - impl PrivUseAlias { - pub fn f(arg: Priv) {} // OK - } - impl PrivAlias { - pub fn f(arg: Priv) {} // OK - } - impl PrivUseAliasTr for PrivUseAlias { - type Check = Priv; // OK - } - impl PrivUseAliasTr for PrivAlias { - type Check = Priv; // OK - } - impl PrivUseAliasTr for ::AssocAlias { - type Check = Priv; // OK - } -} - -mod aliases_params { - struct Priv; - type PrivAliasGeneric = T; - type Result = ::std::result::Result; - - pub fn f1(arg: PrivAliasGeneric) {} // OK, not an error -} - -fn main() {} diff --git a/src/test/compile-fail/private-in-public.rs b/src/test/compile-fail/private-in-public.rs deleted file mode 100644 index b865e391d29..00000000000 --- a/src/test/compile-fail/private-in-public.rs +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Private types and traits are not allowed in public interfaces. -// This test also ensures that the checks are performed even inside private modules. - -#![feature(associated_type_defaults)] - -mod types { - struct Priv; - pub struct Pub; - pub trait PubTr { - type Alias; - } - - pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface - pub static S: Priv = Priv; //~ ERROR private type `types::Priv` in public interface - pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface - pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface - pub struct S1(pub Priv); //~ ERROR private type `types::Priv` in public interface - pub struct S2 { pub field: Priv } //~ ERROR private type `types::Priv` in public interface - impl Pub { - pub const C: Priv = Priv; //~ ERROR private type `types::Priv` in public interface - pub fn f1(arg: Priv) {} //~ ERROR private type `types::Priv` in public interface - pub fn f2() -> Priv { panic!() } //~ ERROR private type `types::Priv` in public interface - } -} - -mod traits { - trait PrivTr {} - pub struct Pub(T); - pub trait PubTr {} - - pub enum E { V(T) } //~ ERROR private trait `traits::PrivTr` in public interface - pub fn f(arg: T) {} //~ ERROR private trait `traits::PrivTr` in public interface - pub struct S1(T); //~ ERROR private trait `traits::PrivTr` in public interface - impl Pub { //~ ERROR private trait `traits::PrivTr` in public interface - pub fn f(arg: U) {} //~ ERROR private trait `traits::PrivTr` in public interface - } -} - -mod traits_where { - trait PrivTr {} - pub struct Pub(T); - pub trait PubTr {} - - pub enum E where T: PrivTr { V(T) } - //~^ ERROR private trait `traits_where::PrivTr` in public interface - pub fn f(arg: T) where T: PrivTr {} - //~^ ERROR private trait `traits_where::PrivTr` in public interface - pub struct S1(T) where T: PrivTr; - //~^ ERROR private trait `traits_where::PrivTr` in public interface - impl Pub where T: PrivTr { - //~^ ERROR private trait `traits_where::PrivTr` in public interface - pub fn f(arg: U) where U: PrivTr {} - //~^ ERROR private trait `traits_where::PrivTr` in public interface - } -} - -mod generics { - struct Priv(T); - pub struct Pub(T); - trait PrivTr {} - pub trait PubTr {} - - pub fn f1(arg: [Priv; 1]) {} //~ ERROR private type `generics::Priv` in public interface - pub fn f2(arg: Pub) {} //~ ERROR private type `generics::Priv` in public interface - pub fn f3(arg: Priv) {} - //~^ ERROR private type `generics::Priv` in public interface -} - -mod impls { - struct Priv; - pub struct Pub; - trait PrivTr { - type Alias; - } - pub trait PubTr { - type Alias; - } - - impl Pub { - pub fn f(arg: Priv) {} //~ ERROR private type `impls::Priv` in public interface - } -} - -mod aliases_pub { - struct Priv; - mod m { - pub struct Pub1; - pub struct Pub2; - pub struct Pub3; - pub trait PubTr { - type Check = u8; - } - } - - use self::m::Pub1 as PrivUseAlias; - use self::m::PubTr as PrivUseAliasTr; - type PrivAlias = m::Pub2; - trait PrivTr { - type Assoc = m::Pub3; - } - impl PrivTr for Priv {} - - // This should be OK, but associated type aliases are not substituted yet - pub fn f3(arg: ::Assoc) {} - //~^ ERROR private type `::Assoc` in public interface - //~| ERROR private type `aliases_pub::Priv` in public interface - - impl PrivUseAlias { - pub fn f(arg: Priv) {} //~ ERROR private type `aliases_pub::Priv` in public interface - } -} - -mod aliases_priv { - struct Priv; - - struct Priv1; - struct Priv2; - struct Priv3; - trait PrivTr1 { - type Check = u8; - } - - use self::Priv1 as PrivUseAlias; - use self::PrivTr1 as PrivUseAliasTr; - type PrivAlias = Priv2; - trait PrivTr { - type Assoc = Priv3; - } - impl PrivTr for Priv {} - - pub fn f1(arg: PrivUseAlias) {} //~ ERROR private type `aliases_priv::Priv1` in public interface - pub fn f2(arg: PrivAlias) {} //~ ERROR private type `aliases_priv::Priv2` in public interface - pub fn f3(arg: ::Assoc) {} - //~^ ERROR private type `::Assoc` in public - //~| ERROR private type `aliases_priv::Priv` in public interface -} - -mod aliases_params { - struct Priv; - type PrivAliasGeneric = T; - type Result = ::std::result::Result; - - pub fn f2(arg: PrivAliasGeneric) {} - //~^ ERROR private type `aliases_params::Priv` in public interface - pub fn f3(arg: Result) {} //~ ERROR private type `aliases_params::Priv` in public interface -} - -fn main() {} diff --git a/src/test/compile-fail/private-inferred-type-1.rs b/src/test/compile-fail/private-inferred-type-1.rs deleted file mode 100644 index ba8b3d1810a..00000000000 --- a/src/test/compile-fail/private-inferred-type-1.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Arr0 { - fn arr0_secret(&self); -} -trait TyParam { - fn ty_param_secret(&self); -} - -mod m { - struct Priv; - - impl ::Arr0 for [Priv; 0] { fn arr0_secret(&self) {} } - impl ::TyParam for Option { fn ty_param_secret(&self) {} } -} - -fn main() { - [].arr0_secret(); //~ ERROR type `m::Priv` is private - None.ty_param_secret(); //~ ERROR type `m::Priv` is private -} diff --git a/src/test/compile-fail/private-inferred-type-2.rs b/src/test/compile-fail/private-inferred-type-2.rs deleted file mode 100644 index e981f125750..00000000000 --- a/src/test/compile-fail/private-inferred-type-2.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:private-inferred-type.rs - -extern crate private_inferred_type as ext; - -mod m { - struct Priv; - pub struct Pub(pub T); - - impl Pub { - pub fn get_priv() -> Priv { Priv } - pub fn static_method() {} - } -} - -fn main() { - m::Pub::get_priv; //~ ERROR type `m::Priv` is private - m::Pub::static_method; //~ ERROR type `m::Priv` is private - ext::Pub::static_method; //~ ERROR type `ext::Priv` is private -} diff --git a/src/test/compile-fail/private-inferred-type-3.rs b/src/test/compile-fail/private-inferred-type-3.rs deleted file mode 100644 index 0c393f02323..00000000000 --- a/src/test/compile-fail/private-inferred-type-3.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:private-inferred-type.rs - -// error-pattern:type `fn() {ext::priv_fn}` is private -// error-pattern:static `PRIV_STATIC` is private -// error-pattern:type `ext::PrivEnum` is private -// error-pattern:type `fn() {::method}` is private -// error-pattern:type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct::{{constructor}}}` is pr -// error-pattern:type `fn(u8) -> ext::PubTupleStruct {ext::PubTupleStruct::{{constructor}}}` is priv -// error-pattern:type `for<'r> fn(&'r ext::Pub) {>::priv_method}` is private - -#![feature(decl_macro)] - -extern crate private_inferred_type as ext; - -fn main() { - ext::m!(); -} diff --git a/src/test/compile-fail/private-inferred-type.rs b/src/test/compile-fail/private-inferred-type.rs deleted file mode 100644 index 3ca8b1eb2ed..00000000000 --- a/src/test/compile-fail/private-inferred-type.rs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(associated_consts)] -#![feature(decl_macro)] -#![allow(private_in_public)] - -mod m { - fn priv_fn() {} - static PRIV_STATIC: u8 = 0; - enum PrivEnum { Variant } - pub enum PubEnum { Variant } - trait PrivTrait { fn method() {} } - impl PrivTrait for u8 {} - pub trait PubTrait { fn method() {} } - impl PubTrait for u8 {} - struct PrivTupleStruct(u8); - pub struct PubTupleStruct(u8); - impl PubTupleStruct { fn method() {} } - - struct Priv; - pub type Alias = Priv; - pub struct Pub(pub T); - - impl Pub { - pub fn static_method() {} - pub const INHERENT_ASSOC_CONST: u8 = 0; - } - impl Pub { - pub fn static_method_generic_self() {} - pub const INHERENT_ASSOC_CONST_GENERIC_SELF: u8 = 0; - } - impl Pub { - fn priv_method(&self) {} - pub fn method_with_substs(&self) {} - pub fn method_with_priv_params(&self, _: Priv) {} - } - impl TraitWithAssocConst for Priv {} - impl TraitWithAssocTy for Priv { type AssocTy = u8; } - - pub macro m() { - priv_fn; //~ ERROR type `fn() {m::priv_fn}` is private - PRIV_STATIC; // OK, not cross-crate - PrivEnum::Variant; //~ ERROR type `m::PrivEnum` is private - PubEnum::Variant; // OK - ::method; //~ ERROR type `fn() {::method}` is private - ::method; // OK - PrivTupleStruct; - //~^ ERROR type `fn(u8) -> m::PrivTupleStruct {m::PrivTupleStruct::{{constructor}}}` is priv - PubTupleStruct; - //~^ ERROR type `fn(u8) -> m::PubTupleStruct {m::PubTupleStruct::{{constructor}}}` is privat - Pub(0u8).priv_method(); - //~^ ERROR type `for<'r> fn(&'r m::Pub) {>::priv_method}` is private - } - - trait Trait {} - pub trait TraitWithTyParam {} - pub trait TraitWithTyParam2 { fn pub_method() {} } - pub trait TraitWithAssocTy { type AssocTy; } - pub trait TraitWithAssocConst { const TRAIT_ASSOC_CONST: u8 = 0; } - impl Trait for u8 {} - impl TraitWithTyParam for u8 {} - impl TraitWithTyParam2 for u8 {} - impl TraitWithAssocTy for u8 { type AssocTy = Priv; } - //~^ ERROR private type `m::Priv` in public interface - - pub fn leak_anon1() -> impl Trait + 'static { 0 } - pub fn leak_anon2() -> impl TraitWithTyParam { 0 } - pub fn leak_anon3() -> impl TraitWithAssocTy { 0 } - - pub fn leak_dyn1() -> Box { Box::new(0) } - pub fn leak_dyn2() -> Box> { Box::new(0) } - pub fn leak_dyn3() -> Box> { Box::new(0) } -} - -mod adjust { - // Construct a chain of derefs with a private type in the middle - use std::ops::Deref; - - pub struct S1; - struct S2; - pub type S2Alias = S2; - pub struct S3; - - impl Deref for S1 { - type Target = S2Alias; //~ ERROR private type `adjust::S2` in public interface - fn deref(&self) -> &Self::Target { loop {} } - } - impl Deref for S2 { - type Target = S3; - fn deref(&self) -> &Self::Target { loop {} } - } - - impl S3 { - pub fn method_s3(&self) {} - } -} - -fn main() { - let _: m::Alias; //~ ERROR type `m::Priv` is private - //~^ ERROR type `m::Priv` is private - let _: ::AssocTy; //~ ERROR type `m::Priv` is private - m::Alias {}; //~ ERROR type `m::Priv` is private - m::Pub { 0: m::Alias {} }; //~ ERROR type `m::Priv` is private - m::Pub { 0: loop {} }; // OK, `m::Pub` is in value context, so it means Pub<_>, not Pub - m::Pub::static_method; //~ ERROR type `m::Priv` is private - m::Pub::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - m::Pub(0u8).method_with_substs::(); //~ ERROR type `m::Priv` is private - m::Pub(0u8).method_with_priv_params(loop{}); //~ ERROR type `m::Priv` is private - ::TRAIT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - >::INHERENT_ASSOC_CONST; //~ ERROR type `m::Priv` is private - >::INHERENT_ASSOC_CONST_GENERIC_SELF; //~ ERROR type `m::Priv` is private - >::static_method_generic_self; //~ ERROR type `m::Priv` is private - use m::TraitWithTyParam2; - u8::pub_method; //~ ERROR type `m::Priv` is private - - adjust::S1.method_s3(); //~ ERROR type `adjust::S2` is private - - m::m!(); - - m::leak_anon1(); //~ ERROR trait `m::Trait` is private - m::leak_anon2(); //~ ERROR type `m::Priv` is private - m::leak_anon3(); //~ ERROR type `m::Priv` is private - - m::leak_dyn1(); //~ ERROR type `(dyn m::Trait + 'static)` is private - m::leak_dyn2(); //~ ERROR type `m::Priv` is private - m::leak_dyn3(); //~ ERROR type `m::Priv` is private - - // Check that messages are not duplicated for various kinds of assignments - let a = m::Alias {}; //~ ERROR type `m::Priv` is private - let mut b = a; //~ ERROR type `m::Priv` is private - b = a; //~ ERROR type `m::Priv` is private - match a { //~ ERROR type `m::Priv` is private - _ => {} - } -} diff --git a/src/test/compile-fail/private-item-simple.rs b/src/test/compile-fail/private-item-simple.rs deleted file mode 100644 index 2b9e32b8f58..00000000000 --- a/src/test/compile-fail/private-item-simple.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - fn f() {} -} - -fn main() { - a::f(); //~ ERROR function `f` is private -} diff --git a/src/test/compile-fail/private-method-cross-crate.rs b/src/test/compile-fail/private-method-cross-crate.rs deleted file mode 100644 index 68059baa385..00000000000 --- a/src/test/compile-fail/private-method-cross-crate.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:cci_class_5.rs -extern crate cci_class_5; -use cci_class_5::kitties::cat; - -fn main() { - let nyan : cat = cat(52, 99); - nyan.nap(); //~ ERROR method `nap` is private -} diff --git a/src/test/compile-fail/private-method-inherited.rs b/src/test/compile-fail/private-method-inherited.rs deleted file mode 100644 index c6419991b11..00000000000 --- a/src/test/compile-fail/private-method-inherited.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that inherited visibility applies to methods. - -mod a { - pub struct Foo; - - impl Foo { - fn f(self) {} - } -} - -fn main() { - let x = a::Foo; - x.f(); //~ ERROR method `f` is private -} diff --git a/src/test/compile-fail/private-method.rs b/src/test/compile-fail/private-method.rs deleted file mode 100644 index 16510c2c8c9..00000000000 --- a/src/test/compile-fail/private-method.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:method `nap` is private - -mod kitties { - pub struct cat { - meows : usize, - - how_hungry : isize, - } - - impl cat { - fn nap(&self) {} - } - - pub fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } - } -} - -fn main() { - let nyan : kitties::cat = kitties::cat(52, 99); - nyan.nap(); -} diff --git a/src/test/compile-fail/private-struct-field-cross-crate.rs b/src/test/compile-fail/private-struct-field-cross-crate.rs deleted file mode 100644 index 067c17668c6..00000000000 --- a/src/test/compile-fail/private-struct-field-cross-crate.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:cci_class.rs -extern crate cci_class; -use cci_class::kitties::cat; - -fn main() { - let nyan : cat = cat(52, 99); - assert_eq!(nyan.meows, 52); - //~^ ERROR field `meows` of struct `cci_class::kitties::cat` is private -} diff --git a/src/test/compile-fail/private-struct-field-ctor.rs b/src/test/compile-fail/private-struct-field-ctor.rs deleted file mode 100644 index 0a0f2d490a8..00000000000 --- a/src/test/compile-fail/private-struct-field-ctor.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub struct Foo { - x: isize - } -} - -fn main() { - let s = a::Foo { x: 1 }; //~ ERROR field `x` of struct `a::Foo` is private -} diff --git a/src/test/compile-fail/private-struct-field-pattern.rs b/src/test/compile-fail/private-struct-field-pattern.rs deleted file mode 100644 index e9dd6cd1d74..00000000000 --- a/src/test/compile-fail/private-struct-field-pattern.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use a::Foo; - -mod a { - pub struct Foo { - x: isize - } - - pub fn make() -> Foo { - Foo { x: 3 } - } -} - -fn main() { - match a::make() { - Foo { x: _ } => {} //~ ERROR field `x` of struct `a::Foo` is private - } -} diff --git a/src/test/compile-fail/private-struct-field.rs b/src/test/compile-fail/private-struct-field.rs deleted file mode 100644 index 1423117dc81..00000000000 --- a/src/test/compile-fail/private-struct-field.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod cat { - pub struct Cat { - meows: usize - } - - pub fn new_cat() -> Cat { - Cat { meows: 52 } - } -} - -fn main() { - let nyan = cat::new_cat(); - assert_eq!(nyan.meows, 52); //~ ERROR field `meows` of struct `cat::Cat` is private -} diff --git a/src/test/compile-fail/private-type-in-interface.rs b/src/test/compile-fail/private-type-in-interface.rs deleted file mode 100644 index 4235b4be271..00000000000 --- a/src/test/compile-fail/private-type-in-interface.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:private-inferred-type.rs - -#![allow(warnings)] - -extern crate private_inferred_type as ext; - -mod m { - struct Priv; - pub type Alias = Priv; - - pub trait Trait { type X; } - impl Trait for Priv { type X = u8; } -} - -fn f(_: m::Alias) {} //~ ERROR type `m::Priv` is private - //~^ ERROR type `m::Priv` is private -fn f_ext(_: ext::Alias) {} //~ ERROR type `ext::Priv` is private - //~^ ERROR type `ext::Priv` is private - -trait Tr1 {} -impl m::Alias {} //~ ERROR type `m::Priv` is private -impl Tr1 for ext::Alias {} //~ ERROR type `ext::Priv` is private -type A = ::X; //~ ERROR type `m::Priv` is private - -trait Tr2 {} -impl Tr2 for u8 {} -fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private -//~^ ERROR type `m::Priv` is private -fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private -//~^ ERROR type `ext::Priv` is private - -fn main() {} diff --git a/src/test/compile-fail/private-variant-reexport.rs b/src/test/compile-fail/private-variant-reexport.rs deleted file mode 100644 index 5d770f88155..00000000000 --- a/src/test/compile-fail/private-variant-reexport.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m1 { - pub use ::E::V; //~ ERROR variant `V` is private and cannot be re-exported -} - -mod m2 { - pub use ::E::{V}; //~ ERROR variant `V` is private and cannot be re-exported -} - -mod m3 { - pub use ::E::V::{self}; //~ ERROR variant `V` is private and cannot be re-exported -} - -mod m4 { - pub use ::E::*; //~ ERROR enum is private and its variants cannot be re-exported -} - -enum E { V } - -fn main() {} diff --git a/src/test/compile-fail/ptr-coercion.rs b/src/test/compile-fail/ptr-coercion.rs deleted file mode 100644 index 1390c9507c1..00000000000 --- a/src/test/compile-fail/ptr-coercion.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test coercions between pointers which don't do anything fancy like unsizing. -// These are testing that we don't lose mutability when converting to raw pointers. - -pub fn main() { - // *const -> *mut - let x: *const isize = &42; - let x: *mut isize = x; //~ ERROR mismatched types - //~| expected type `*mut isize` - //~| found type `*const isize` - //~| types differ in mutability - - // & -> *mut - let x: *mut isize = &42; //~ ERROR mismatched types - //~| expected type `*mut isize` - //~| found type `&isize` - //~| types differ in mutability - - let x: *const isize = &42; - let x: *mut isize = x; //~ ERROR mismatched types - //~| expected type `*mut isize` - //~| found type `*const isize` - //~| types differ in mutability -} diff --git a/src/test/compile-fail/pub-reexport-priv-extern-crate.rs b/src/test/compile-fail/pub-reexport-priv-extern-crate.rs deleted file mode 100644 index 2e71e007e9e..00000000000 --- a/src/test/compile-fail/pub-reexport-priv-extern-crate.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] - -extern crate core; -pub use core as reexported_core; //~ ERROR `core` is private, and cannot be re-exported - //~^ WARN this was previously accepted - -mod foo1 { - extern crate core; -} - -mod foo2 { - use foo1::core; //~ ERROR `core` is private, and cannot be re-exported - //~^ WARN this was previously accepted - pub mod bar { - extern crate core; - } -} - -mod baz { - pub use foo2::bar::core; //~ ERROR `core` is private, and cannot be re-exported - //~^ WARN this was previously accepted -} - -fn main() {} diff --git a/src/test/compile-fail/qualified-path-params.rs b/src/test/compile-fail/qualified-path-params.rs deleted file mode 100644 index 018a3b2ae32..00000000000 --- a/src/test/compile-fail/qualified-path-params.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that qualified paths with type parameters -// fail during type checking and not during parsing - -struct S; - -trait Tr { - type A; -} - -impl Tr for S { - type A = S; -} - -impl S { - fn f() {} -} - -fn main() { - match 10 { - ::A::f:: => {} - //~^ ERROR expected unit struct/variant or constant, found method `<::A>::f` - 0 ..= ::A::f:: => {} //~ ERROR only char and numeric types are allowed in range - } -} diff --git a/src/test/compile-fail/question-mark-type-infer.rs b/src/test/compile-fail/question-mark-type-infer.rs deleted file mode 100644 index e15c9af41e0..00000000000 --- a/src/test/compile-fail/question-mark-type-infer.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(question_mark, question_mark_carrier)] - -// Test that type inference fails where there are multiple possible return types -// for the `?` operator. - -fn f(x: &i32) -> Result { - Ok(*x) -} - -fn g() -> Result, ()> { - let l = [1, 2, 3, 4]; - l.iter().map(f).collect()? //~ ERROR type annotations required: cannot resolve -} - -fn main() { - g(); -} diff --git a/src/test/compile-fail/quote-with-interpolated.rs b/src/test/compile-fail/quote-with-interpolated.rs deleted file mode 100644 index 1fafb1c7a1b..00000000000 --- a/src/test/compile-fail/quote-with-interpolated.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(quote)] -fn main() { - macro_rules! foo { - ($bar:expr) => { - quote_expr!(cx, $bar) //~ ERROR quote! with interpolated token - } - } - foo!(bar); -} diff --git a/src/test/compile-fail/range-1.rs b/src/test/compile-fail/range-1.rs deleted file mode 100644 index 59c78052e15..00000000000 --- a/src/test/compile-fail/range-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test range syntax - type errors. - -pub fn main() { - // Mixed types. - let _ = 0u32..10i32; - //~^ ERROR mismatched types - - // Bool => does not implement iterator. - for i in false..true {} - //~^ ERROR `bool: std::iter::Step` is not satisfied - - // Unsized type. - let arr: &[_] = &[1, 2, 3]; - let range = *arr..; - //~^ ERROR the size for values of type -} diff --git a/src/test/compile-fail/range_traits-1.rs b/src/test/compile-fail/range_traits-1.rs deleted file mode 100644 index 78d3702b449..00000000000 --- a/src/test/compile-fail/range_traits-1.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::*; - -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -struct AllTheRanges { - a: Range, - //~^ ERROR can't compare - //~| ERROR Ord - b: RangeTo, - //~^ ERROR can't compare - //~| ERROR Ord - c: RangeFrom, - //~^ ERROR can't compare - //~| ERROR Ord - d: RangeFull, - //~^ ERROR can't compare - //~| ERROR Ord - e: RangeInclusive, - //~^ ERROR can't compare - //~| ERROR Ord - f: RangeToInclusive, - //~^ ERROR can't compare - //~| ERROR Ord -} - -fn main() {} diff --git a/src/test/compile-fail/range_traits-2.rs b/src/test/compile-fail/range_traits-2.rs deleted file mode 100644 index 64fcd25f538..00000000000 --- a/src/test/compile-fail/range_traits-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::*; - -#[derive(Copy, Clone)] //~ ERROR Copy -struct R(Range); - -fn main() {} - diff --git a/src/test/compile-fail/range_traits-3.rs b/src/test/compile-fail/range_traits-3.rs deleted file mode 100644 index d26b7956ae8..00000000000 --- a/src/test/compile-fail/range_traits-3.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::*; - -#[derive(Copy, Clone)] //~ ERROR Copy -struct R(RangeFrom); - -fn main() {} - diff --git a/src/test/compile-fail/range_traits-4.rs b/src/test/compile-fail/range_traits-4.rs deleted file mode 100644 index 630969bdbdf..00000000000 --- a/src/test/compile-fail/range_traits-4.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -use std::ops::*; - -#[derive(Copy, Clone)] -struct R(RangeTo); - -#[rustc_error] -fn main() {} //~ ERROR success - diff --git a/src/test/compile-fail/range_traits-5.rs b/src/test/compile-fail/range_traits-5.rs deleted file mode 100644 index 5963c4a9496..00000000000 --- a/src/test/compile-fail/range_traits-5.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -use std::ops::*; - -#[derive(Copy, Clone)] -struct R(RangeFull); - -#[rustc_error] -fn main() {} //~ ERROR success - diff --git a/src/test/compile-fail/range_traits-6.rs b/src/test/compile-fail/range_traits-6.rs deleted file mode 100644 index f9510b5061c..00000000000 --- a/src/test/compile-fail/range_traits-6.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::*; - -#[derive(Copy, Clone)] //~ ERROR Copy -struct R(RangeInclusive); - -fn main() {} - diff --git a/src/test/compile-fail/range_traits-7.rs b/src/test/compile-fail/range_traits-7.rs deleted file mode 100644 index 871b55b85cf..00000000000 --- a/src/test/compile-fail/range_traits-7.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -use std::ops::*; - -#[derive(Copy, Clone)] -struct R(RangeToInclusive); - -#[rustc_error] -fn main() {} //~ ERROR success - diff --git a/src/test/compile-fail/recursion.rs b/src/test/compile-fail/recursion.rs deleted file mode 100644 index 3221ae46296..00000000000 --- a/src/test/compile-fail/recursion.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Nil {NilValue} -struct Cons {head:isize, tail:T} -trait Dot {fn dot(&self, other:Self) -> isize;} -impl Dot for Nil { - fn dot(&self, _:Nil) -> isize {0} -} -impl Dot for Cons { - fn dot(&self, other:Cons) -> isize { - self.head * other.head + self.tail.dot(other.tail) - } -} -fn test (n:isize, i:isize, first:T, second:T) ->isize { //~ ERROR recursion limit - match n { 0 => {first.dot(second)} - // FIXME(#4287) Error message should be here. It should be - // a type error to instantiate `test` at a type other than T. - _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} - } -} -pub fn main() { - let n = test(1, 0, Nil::NilValue, Nil::NilValue); - println!("{}", n); -} diff --git a/src/test/compile-fail/recursive-enum.rs b/src/test/compile-fail/recursive-enum.rs deleted file mode 100644 index 555755cdb96..00000000000 --- a/src/test/compile-fail/recursive-enum.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum list { cons(T, list), nil } -//~^ ERROR recursive type `list` has infinite size - -fn main() {} diff --git a/src/test/compile-fail/recursive-reexports.rs b/src/test/compile-fail/recursive-reexports.rs deleted file mode 100644 index b57b73325c0..00000000000 --- a/src/test/compile-fail/recursive-reexports.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:recursive_reexports.rs - -extern crate recursive_reexports; - -fn f() -> recursive_reexports::S {} //~ ERROR cannot find type `S` in module `recursive_reexports` - -fn main() {} diff --git a/src/test/compile-fail/recursive-static-definition.rs b/src/test/compile-fail/recursive-static-definition.rs deleted file mode 100644 index 62c1859e09d..00000000000 --- a/src/test/compile-fail/recursive-static-definition.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static FOO: u32 = FOO; -//~^ ERROR cycle detected when const-evaluating `FOO` - -fn main() {} diff --git a/src/test/compile-fail/recursive-types-are-not-uninhabited.rs b/src/test/compile-fail/recursive-types-are-not-uninhabited.rs deleted file mode 100644 index fa936697072..00000000000 --- a/src/test/compile-fail/recursive-types-are-not-uninhabited.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct R<'a> { - r: &'a R<'a>, -} - -fn foo(res: Result) -> u32 { - let Ok(x) = res; - //~^ ERROR refutable pattern - x -} - -fn main() { - foo(Ok(23)); -} - diff --git a/src/test/compile-fail/ref-suggestion.rs b/src/test/compile-fail/ref-suggestion.rs deleted file mode 100644 index 0a0867195d9..00000000000 --- a/src/test/compile-fail/ref-suggestion.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x = vec![1]; - let y = x; - x; //~ ERROR use of moved value - - let x = vec![1]; - let mut y = x; - x; //~ ERROR use of moved value - - let x = (Some(vec![1]), ()); - - match x { - (Some(y), ()) => {}, - _ => {}, - } - x; //~ ERROR use of partially moved value -} diff --git a/src/test/compile-fail/refutable-pattern-errors.rs b/src/test/compile-fail/refutable-pattern-errors.rs deleted file mode 100644 index 7b4009481ab..00000000000 --- a/src/test/compile-fail/refutable-pattern-errors.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn func((1, (Some(1), 2..=3)): (isize, (Option, isize))) { } -//~^ ERROR refutable pattern in function argument: `(_, _)` not covered - -fn main() { - let (1, (Some(1), 2..=3)) = (1, (None, 2)); - //~^ ERROR refutable pattern in local binding: `(_, _)` not covered -} diff --git a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs b/src/test/compile-fail/refutable-pattern-in-fn-arg.rs deleted file mode 100644 index be42f0f0ed8..00000000000 --- a/src/test/compile-fail/refutable-pattern-in-fn-arg.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let f = |3: isize| println!("hello"); - //~^ ERROR refutable pattern in function argument: `_` not covered - f(4); -} diff --git a/src/test/compile-fail/region-borrow-params-issue-29793-big.rs b/src/test/compile-fail/region-borrow-params-issue-29793-big.rs deleted file mode 100644 index 642e90f6de8..00000000000 --- a/src/test/compile-fail/region-borrow-params-issue-29793-big.rs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #29793, big regression test: do not let borrows of -// parameters to ever be returned (expanded with exploration of -// variations). -// -// This is the version of the test that actually exposed unsound -// behavior (because the improperly accepted closure was actually -// able to be invoked). - -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -struct WrapA(Option); - -impl WrapA { - fn new() -> WrapA { - WrapA(None) - } - fn set(mut self, f: F) -> Self { - self.0 = Some(f); - self - } -} - -struct WrapB(Option); - -impl WrapB { - fn new() -> WrapB { - WrapB(None) - } - fn set(mut self, f: F) -> Self { - self.0 = Some(f); - self - } -} - -trait DoStuff : Sized { - fn handle(self); -} - -impl DoStuff for WrapA - where F: FnMut(usize, usize) -> T, T: DoStuff { - fn handle(mut self) { - if let Some(ref mut f) = self.0 { - let x = f(1, 2); - let _foo = [0usize; 16]; - x.handle(); - } - } - } - -impl DoStuff for WrapB where F: FnMut(bool) -> usize { - fn handle(mut self) { - if let Some(ref mut f) = self.0 { - println!("{}", f(true)); - } - } -} - -impl WrapA - where F: FnMut(usize, usize) -> T, T: DoStuff { - fn handle_ref(&mut self) { - if let Some(ref mut f) = self.0 { - let x = f(1, 2); - } - } - } - -fn main() { - let mut w = WrapA::new().set(|x: usize, y: usize| { - WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - //[ast]~^ ERROR `x` does not live long enough - //[ast]~| ERROR `y` does not live long enough - //[mir]~^^^ ERROR `x` does not live long enough - //[mir]~| ERROR `y` does not live long enough - }); - - w.handle(); // This works - // w.handle_ref(); // This doesn't -} diff --git a/src/test/compile-fail/region-bound-extra-bound-in-inherent-impl.rs b/src/test/compile-fail/region-bound-extra-bound-in-inherent-impl.rs deleted file mode 100644 index c1df057b396..00000000000 --- a/src/test/compile-fail/region-bound-extra-bound-in-inherent-impl.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test related to #22779. In this case, the impl is an inherent impl, -// so it doesn't have to match any trait, so no error results. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct MySlice<'a, T:'a>(&'a mut [T]); - -impl<'a, T> MySlice<'a, T> { - fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b { - &mut self.0[..] - } -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/region-bound-on-closure-outlives-call.rs b/src/test/compile-fail/region-bound-on-closure-outlives-call.rs deleted file mode 100644 index b73c283fa51..00000000000 --- a/src/test/compile-fail/region-bound-on-closure-outlives-call.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn call_rec(mut f: F) -> usize where F: FnMut(usize) -> usize { - (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` -} - -fn main() {} diff --git a/src/test/compile-fail/region-bound-same-bounds-in-trait-and-impl.rs b/src/test/compile-fail/region-bound-same-bounds-in-trait-and-impl.rs deleted file mode 100644 index 3115e5a9a43..00000000000 --- a/src/test/compile-fail/region-bound-same-bounds-in-trait-and-impl.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test related to #22779, but where the `'a:'b` relation -// appears in the trait too. No error here. - -#![feature(rustc_attrs)] - -trait Tr<'a, T> { - fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b; -} - -impl<'a, T> Tr<'a, T> for &'a mut [T] { - fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b { - &mut self[..] - } -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs b/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs deleted file mode 100644 index fd8d5ff9e7e..00000000000 --- a/src/test/compile-fail/region-bounds-on-objects-and-type-parameters.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test related to when a region bound is required to be specified. - -trait IsStatic : 'static { } -trait IsSend : Send { } -trait Is<'a> : 'a { } -trait Is2<'a> : 'a { } -trait SomeTrait { } - -// Bounds on object types: - -struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used - // All of these are ok, because we can derive exactly one bound: - a: Box, - b: Box>, - c: Box>, - d: Box, - e: Box+Send>, // we can derive two bounds, but one is 'static, so ok - f: Box, // OK, defaults to 'static due to RFC 599. - g: Box, - - z: Box+'b+'c>, - //~^ ERROR only a single explicit lifetime bound is permitted - //~| ERROR lifetime bound not satisfied -} - -fn test< - 'a, - 'b, - A:IsStatic, - B:Is<'a>+Is2<'b>, // OK in a parameter, but not an object type. - C:'b+Is<'a>+Is2<'b>, - D:Is<'a>+Is2<'static>, - E:'a+'b // OK in a parameter, but not an object type. ->() { } - -fn main() { } diff --git a/src/test/compile-fail/region-invariant-static-error-reporting.rs b/src/test/compile-fail/region-invariant-static-error-reporting.rs deleted file mode 100644 index 646ae8183a2..00000000000 --- a/src/test/compile-fail/region-invariant-static-error-reporting.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test checks that the error messages you get for this example -// at least mention `'a` and `'static`. The precise messages can drift -// over time, but this test used to exhibit some pretty bogus messages -// that were not remotely helpful. - -// error-pattern:the lifetime 'a -// error-pattern:the static lifetime - -struct Invariant<'a>(Option<&'a mut &'a mut ()>); - -fn mk_static() -> Invariant<'static> { Invariant(None) } - -fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { - let bad = if x.is_some() { - x.unwrap() - } else { - mk_static() - }; - f(bad); -} - -fn main() {} diff --git a/src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs b/src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs deleted file mode 100644 index e3d96f52e81..00000000000 --- a/src/test/compile-fail/region-lifetime-bounds-on-fns-where-clause.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { - // Note: this is legal because of the `'b:'a` declaration. - *x = *y; -} - -fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { - // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 -} - -fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { - // Here we try to call `foo` but do not know that `'a` and `'b` are - // related as required. - a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] -} - -fn d() { - // 'a and 'b are early bound in the function `a` because they appear - // inconstraints: - let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types -} - -fn e() { - // 'a and 'b are late bound in the function `b` because there are - // no constraints: - let _: fn(&mut &isize, &mut &isize) = b; -} - -fn main() { } diff --git a/src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs b/src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs deleted file mode 100644 index d8d12444ddd..00000000000 --- a/src/test/compile-fail/region-multiple-lifetime-bounds-on-fns-where-clause.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c { - // Note: this is legal because of the `'b:'a` declaration. - *x = *y; - *z = *y; -} - -fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 - *z = *y; //~ ERROR E0623 -} - -fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - // Here we try to call `foo` but do not know that `'a` and `'b` are - // related as required. - a(x, y, z); //~ ERROR 26:7: 26:8: lifetime mismatch [E0623] -} - -fn d() { - // 'a and 'b are early bound in the function `a` because they appear - // inconstraints: - let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR mismatched types -} - -fn e() { - // 'a and 'b are late bound in the function `b` because there are - // no constraints: - let _: fn(&mut &isize, &mut &isize, &mut &isize) = b; -} - -fn main() { } diff --git a/src/test/compile-fail/region-object-lifetime-1.rs b/src/test/compile-fail/region-object-lifetime-1.rs deleted file mode 100644 index 1e615be9d6a..00000000000 --- a/src/test/compile-fail/region-object-lifetime-1.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various tests related to testing how region inference works -// with respect to the object receivers. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -trait Foo { - fn borrowed<'a>(&'a self) -> &'a (); -} - -// Here the receiver and return value all have the same lifetime, -// so no error results. -fn borrowed_receiver_same_lifetime<'a>(x: &'a Foo) -> &'a () { - x.borrowed() -} - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/region-object-lifetime-2.rs b/src/test/compile-fail/region-object-lifetime-2.rs deleted file mode 100644 index e011b8f5697..00000000000 --- a/src/test/compile-fail/region-object-lifetime-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various tests related to testing how region inference works -// with respect to the object receivers. - -trait Foo { - fn borrowed<'a>(&'a self) -> &'a (); -} - -// Borrowed receiver but two distinct lifetimes, we get an error. -fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { - x.borrowed() //~ ERROR cannot infer -} - -fn main() {} diff --git a/src/test/compile-fail/region-object-lifetime-3.rs b/src/test/compile-fail/region-object-lifetime-3.rs deleted file mode 100644 index 84dd97643a1..00000000000 --- a/src/test/compile-fail/region-object-lifetime-3.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various tests related to testing how region inference works -// with respect to the object receivers. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -trait Foo { - fn borrowed<'a>(&'a self) -> &'a (); -} - -// Borrowed receiver with two distinct lifetimes, but we know that -// 'b:'a, hence &'a () is permitted. -fn borrowed_receiver_related_lifetimes<'a,'b>(x: &'a (Foo+'b)) -> &'a () { - x.borrowed() -} - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/region-object-lifetime-4.rs b/src/test/compile-fail/region-object-lifetime-4.rs deleted file mode 100644 index 0a68e7f1076..00000000000 --- a/src/test/compile-fail/region-object-lifetime-4.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various tests related to testing how region inference works -// with respect to the object receivers. - -trait Foo { - fn borrowed<'a>(&'a self) -> &'a (); -} - -// Here we have two distinct lifetimes, but we try to return a pointer -// with the longer lifetime when (from the signature) we only know -// that it lives as long as the shorter lifetime. Therefore, error. -fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { - x.borrowed() //~ ERROR cannot infer -} - -fn main() {} diff --git a/src/test/compile-fail/region-object-lifetime-5.rs b/src/test/compile-fail/region-object-lifetime-5.rs deleted file mode 100644 index 26aad0e33b1..00000000000 --- a/src/test/compile-fail/region-object-lifetime-5.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various tests related to testing how region inference works -// with respect to the object receivers. - -trait Foo { - fn borrowed<'a>(&'a self) -> &'a (); -} - -// Here, the object is bounded by an anonymous lifetime and returned -// as `&'static`, so you get an error. -fn owned_receiver(x: Box) -> &'static () { - x.borrowed() //~ ERROR `*x` does not live long enough -} - -fn main() {} diff --git a/src/test/compile-fail/region-object-lifetime-in-coercion.rs b/src/test/compile-fail/region-object-lifetime-in-coercion.rs deleted file mode 100644 index 5bf397ab383..00000000000 --- a/src/test/compile-fail/region-object-lifetime-in-coercion.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that attempts to implicitly coerce a value into an -// object respect the lifetime bound on the object type. - -trait Foo {} -impl<'a> Foo for &'a [u8] {} - -fn a(v: &[u8]) -> Box { - let x: Box = Box::new(v); - //~^ ERROR explicit lifetime required in the type of `v` [E0621] - x -} - -fn b(v: &[u8]) -> Box { - Box::new(v) - //~^ ERROR explicit lifetime required in the type of `v` [E0621] -} - -fn c(v: &[u8]) -> Box { - // same as previous case due to RFC 599 - - Box::new(v) - //~^ ERROR explicit lifetime required in the type of `v` [E0621] -} - -fn d<'a,'b>(v: &'a [u8]) -> Box { - Box::new(v) - //~^ ERROR cannot infer an appropriate lifetime due to conflicting -} - -fn e<'a:'b,'b>(v: &'a [u8]) -> Box { - Box::new(v) // OK, thanks to 'a:'b -} - -fn main() { } diff --git a/src/test/compile-fail/regions-addr-of-arg.rs b/src/test/compile-fail/regions-addr-of-arg.rs deleted file mode 100644 index c54b4aaace5..00000000000 --- a/src/test/compile-fail/regions-addr-of-arg.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that taking the address of an argument yields a lifetime -// bounded by the current function call. - -fn foo(a: isize) { - let _p: &'static isize = &a; //~ ERROR `a` does not live long enough -} - -fn bar(a: isize) { - let _q: &isize = &a; -} - -fn zed<'a>(a: isize) -> &'a isize { - &a //~ ERROR `a` does not live long enough -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs deleted file mode 100644 index 04ee0526403..00000000000 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct dog { - cats_chased: usize, -} - -impl dog { - pub fn chase_cat(&mut self) { - let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer - *p += 1; - } - - pub fn chase_cat_2(&mut self) { - let p: &mut usize = &mut self.cats_chased; - *p += 1; - } -} - -fn dog() -> dog { - dog { - cats_chased: 0 - } -} - -fn main() { - let mut d = dog(); - d.chase_cat(); - println!("cats_chased: {}", d.cats_chased); -} diff --git a/src/test/compile-fail/regions-addr-of-upvar-self.rs b/src/test/compile-fail/regions-addr-of-upvar-self.rs deleted file mode 100644 index 28491f1155c..00000000000 --- a/src/test/compile-fail/regions-addr-of-upvar-self.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::usize; - -struct dog { - food: usize, -} - -impl dog { - pub fn chase_cat(&mut self) { - let _f = || { - let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer - *p = 3; - }; - } -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-adjusted-lvalue-op.rs b/src/test/compile-fail/regions-adjusted-lvalue-op.rs deleted file mode 100644 index bb02d6d8bba..00000000000 --- a/src/test/compile-fail/regions-adjusted-lvalue-op.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// check that we link regions in mutable place ops correctly - issue #41774 - -struct Data(i32); - -trait OhNo { - fn oh_no(&mut self, other: &Vec) { loop {} } -} - -impl OhNo for Data {} -impl OhNo for [Data] {} - -fn main() { - let mut v = vec![Data(0)]; - v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because -} diff --git a/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs b/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs deleted file mode 100644 index f2ff877cd82..00000000000 --- a/src/test/compile-fail/regions-assoc-type-in-supertrait-outlives-container.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are imposing the requirement that every associated -// type of a bound that appears in the where clause on a struct must -// outlive the location in which the type appears, even when the -// associted type is in a supertype. Issue #22246. - -#![allow(dead_code)] - -/////////////////////////////////////////////////////////////////////////// - -pub trait TheTrait { - type TheAssocType; -} - -pub trait TheSubTrait : TheTrait { -} - -pub struct TheType<'b> { - m: [fn(&'b()); 0] -} - -impl<'b> TheTrait for TheType<'b> { - type TheAssocType = &'b (); -} - -impl<'b> TheSubTrait for TheType<'b> { -} - -/////////////////////////////////////////////////////////////////////////// - -pub struct WithAssoc { - m: [T; 0] -} - -fn with_assoc<'a,'b>() { - // For this type to be valid, the rules require that all - // associated types of traits that appear in `WithAssoc` must - // outlive 'a. In this case, that means TheType<'b>::TheAssocType, - // which is &'b (), must outlive 'a. - - let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs b/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs deleted file mode 100644 index f921eccef1f..00000000000 --- a/src/test/compile-fail/regions-assoc-type-region-bound-in-trait-not-met.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the compiler checks that arbitrary region bounds declared -// in the trait must be satisfied on the impl. Issue #20890. - -trait Foo<'a> { - type Value: 'a; - fn dummy(&'a self) { } -} - -impl<'a> Foo<'a> for &'a i16 { - // OK. - type Value = &'a i32; -} - -impl<'a> Foo<'static> for &'a i32 { - //~^ ERROR cannot infer - type Value = &'a i32; -} - -impl<'a,'b> Foo<'b> for &'a i64 { - //~^ ERROR cannot infer - type Value = &'a i32; -} - -fn main() { } diff --git a/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs b/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs deleted file mode 100644 index 1cf83b8ac58..00000000000 --- a/src/test/compile-fail/regions-assoc-type-static-bound-in-trait-not-met.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the compiler checks that the 'static bound declared in -// the trait must be satisfied on the impl. Issue #20890. - -trait Foo { - type Value: 'static; - fn dummy(&self) { } -} - -impl<'a> Foo for &'a i32 { - //~^ ERROR cannot infer - type Value = &'a i32; -} - -impl<'a> Foo for i32 { - // OK. - type Value = i32; -} - -fn main() { } diff --git a/src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs b/src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs deleted file mode 100644 index 19c50d57e1b..00000000000 --- a/src/test/compile-fail/regions-bounded-by-trait-requiring-static.rs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test which of the builtin types are considered sendable. The tests -// in this file all test region bound and lifetime violations that are -// detected during type check. - -trait Dummy : 'static { } -fn assert_send() { } - -// lifetime pointers with 'static lifetime are ok - -fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) { - assert_send::<&'static isize>(); - assert_send::<&'static str>(); - assert_send::<&'static [isize]>(); - - // whether or not they are mutable - assert_send::<&'static mut isize>(); -} - -// otherwise lifetime pointers are not ok - -fn param_not_ok<'a>(x: &'a isize) { - assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime -} - -fn param_not_ok1<'a>(_: &'a isize) { - assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime -} - -fn param_not_ok2<'a>(_: &'a isize) { - assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime -} - -// boxes are ok - -fn box_ok() { - assert_send::>(); - assert_send::(); - assert_send::>(); -} - -// but not if they own a bad thing - -fn box_with_region_not_ok<'a>() { - assert_send::>(); //~ ERROR does not fulfill the required lifetime -} - -// raw pointers are ok unless they point at unsendable things - -fn unsafe_ok1<'a>(_: &'a isize) { - assert_send::<*const isize>(); - assert_send::<*mut isize>(); -} - -fn unsafe_ok2<'a>(_: &'a isize) { - assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime -} - -fn unsafe_ok3<'a>(_: &'a isize) { - assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs deleted file mode 100644 index 24e4c5fbd91..00000000000 --- a/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:rbmtp_cross_crate_lib.rs - -// Check explicit region bounds on methods in the cross crate case. - -extern crate rbmtp_cross_crate_lib as lib; - -use lib::Inv; -use lib::MaybeOwned; -use lib::IntoMaybeOwned; - -fn call_into_maybe_owned<'x,F:IntoMaybeOwned<'x>>(f: F) { - // Exercise a code path I found to be buggy. We were not encoding - // the region parameters from the receiver correctly on trait - // methods. - f.into_maybe_owned(); -} - -fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { - // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. - a.bigger_region(b) //~ ERROR 30:7: 30:20: lifetime mismatch [E0623] -} - -fn main() { } diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs deleted file mode 100644 index 3e9d2aa6c3b..00000000000 --- a/src/test/compile-fail/regions-bounded-method-type-parameters-trait-bound.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that explicit region bounds are allowed on the various -// nominal types (but not on other types) and that they are type -// checked. - -struct Inv<'a> { // invariant w/r/t 'a - x: &'a mut &'a isize -} - -trait Foo<'x> { - fn method<'y:'x>(self, y: Inv<'y>); -} - -fn caller1<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { - // Here the value provided for 'y is 'a, and hence 'a:'a holds. - f.method(a); -} - -fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { - // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. - f.method(b); //~ ERROR 30:7: 30:13: lifetime mismatch [E0623] -} - -fn caller3<'a,'b:'a,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { - // Here the value provided for 'y is 'b, and hence 'b:'a holds. - f.method(b); -} - -fn main() { } diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters.rs b/src/test/compile-fail/regions-bounded-method-type-parameters.rs deleted file mode 100644 index da4e8231a23..00000000000 --- a/src/test/compile-fail/regions-bounded-method-type-parameters.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that explicit region bounds are allowed on the various -// nominal types (but not on other types) and that they are type -// checked. - -struct Foo; - -impl Foo { - fn some_method(self) { } -} - -fn caller<'a>(x: &isize) { - Foo.some_method::<&'a isize>(); - //~^ ERROR does not fulfill the required lifetime -} - -fn main() { } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs deleted file mode 100644 index 5ce80be98d9..00000000000 --- a/src/test/compile-fail/regions-bounds.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that explicit region bounds are allowed on the various -// nominal types (but not on other types) and that they are type -// checked. - -struct an_enum<'a>(&'a isize); -struct a_class<'a> { x:&'a isize } - -fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { - return e; //~ ERROR mismatched types -} - -fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { - return e; //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/regions-close-associated-type-into-object.rs b/src/test/compile-fail/regions-close-associated-type-into-object.rs deleted file mode 100644 index 6b88abfca6c..00000000000 --- a/src/test/compile-fail/regions-close-associated-type-into-object.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -trait X {} - -trait Iter { - type Item: X; - - fn into_item(self) -> Self::Item; - fn as_item(&self) -> &Self::Item; -} - -fn bad1(v: T) -> Box -{ - let item = v.into_item(); - Box::new(item) //~ ERROR associated type `::Item` may not live long enough -} - -fn bad2(v: T) -> Box - where Box : X -{ - let item: Box<_> = box v.into_item(); - Box::new(item) //~ ERROR associated type `::Item` may not live long enough -} - -fn bad3<'a, T: Iter>(v: T) -> Box -{ - let item = v.into_item(); - Box::new(item) //~ ERROR associated type `::Item` may not live long enough -} - -fn bad4<'a, T: Iter>(v: T) -> Box - where Box : X -{ - let item: Box<_> = box v.into_item(); - Box::new(item) //~ ERROR associated type `::Item` may not live long enough -} - -fn ok1<'a, T: Iter>(v: T) -> Box - where T::Item : 'a -{ - let item = v.into_item(); - Box::new(item) // OK, T::Item : 'a is declared -} - -fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box - where T::Item : Clone -{ - let item = Clone::clone(w); - Box::new(item) // OK, T::Item : 'a is implied -} - -fn ok3<'a, T: Iter>(v: &'a T) -> Box - where T::Item : Clone + 'a -{ - let item = Clone::clone(v.as_item()); - Box::new(item) // OK, T::Item : 'a was declared -} - -fn meh1<'a, T: Iter>(v: &'a T) -> Box - where T::Item : Clone -{ - // This case is kind of interesting. It's the same as `ok3` but - // without the explicit declaration. This is valid because `T: 'a - // => T::Item: 'a`, and the former we can deduce from our argument - // of type `&'a T`. - - let item = Clone::clone(v.as_item()); - Box::new(item) -} - -fn main() {} diff --git a/src/test/compile-fail/regions-close-object-into-object-1.rs b/src/test/compile-fail/regions-close-object-into-object-1.rs deleted file mode 100644 index 5d9818d624b..00000000000 --- a/src/test/compile-fail/regions-close-object-into-object-1.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] -#![allow(warnings)] - -trait A { } -struct B<'a, T:'a>(&'a (A+'a)); - -trait X { } - -impl<'a, T> X for B<'a, T> {} - -fn f<'a, T:'static, U>(v: Box+'static>) -> Box { - box B(&*v) as Box //~ ERROR `*v` does not live long enough -} - -fn main() {} diff --git a/src/test/compile-fail/regions-close-object-into-object-2.rs b/src/test/compile-fail/regions-close-object-into-object-2.rs deleted file mode 100644 index 6cef9956655..00000000000 --- a/src/test/compile-fail/regions-close-object-into-object-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -trait A { } -struct B<'a, T:'a>(&'a (A+'a)); - -trait X { } -impl<'a, T> X for B<'a, T> {} - -fn g<'a, T: 'static>(v: Box+'a>) -> Box { - box B(&*v) as Box //~ ERROR cannot infer -} - -fn main() { } diff --git a/src/test/compile-fail/regions-close-object-into-object-3.rs b/src/test/compile-fail/regions-close-object-into-object-3.rs deleted file mode 100644 index 3004245b15a..00000000000 --- a/src/test/compile-fail/regions-close-object-into-object-3.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] -#![allow(warnings)] - -trait A { } -struct B<'a, T:'a>(&'a (A+'a)); - -trait X { } -impl<'a, T> X for B<'a, T> {} - -fn h<'a, T, U:'static>(v: Box+'static>) -> Box { - box B(&*v) as Box //~ ERROR `*v` does not live long enough -} - -fn main() {} diff --git a/src/test/compile-fail/regions-close-object-into-object-4.rs b/src/test/compile-fail/regions-close-object-into-object-4.rs deleted file mode 100644 index bc5b7b7cf78..00000000000 --- a/src/test/compile-fail/regions-close-object-into-object-4.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -trait A { } -struct B<'a, T:'a>(&'a (A+'a)); - -trait X { } -impl<'a, T> X for B<'a, T> {} - -fn i<'a, T, U>(v: Box+'a>) -> Box { - box B(&*v) as Box //~ ERROR cannot infer -} - -fn main() {} diff --git a/src/test/compile-fail/regions-close-object-into-object-5.rs b/src/test/compile-fail/regions-close-object-into-object-5.rs deleted file mode 100644 index 6cbe5234ce0..00000000000 --- a/src/test/compile-fail/regions-close-object-into-object-5.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] -#![allow(warnings)] - -trait A -{ - fn get(&self) -> T { panic!() } -} - -struct B<'a, T:'a>(&'a (A+'a)); - -trait X { fn foo(&self) {} } - -impl<'a, T> X for B<'a, T> {} - -fn f<'a, T, U>(v: Box+'static>) -> Box { - // oh dear! - box B(&*v) as Box - //~^ ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough -} - -fn main() {} diff --git a/src/test/compile-fail/regions-close-over-type-parameter-1.rs b/src/test/compile-fail/regions-close-over-type-parameter-1.rs deleted file mode 100644 index b70ec59420d..00000000000 --- a/src/test/compile-fail/regions-close-over-type-parameter-1.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -// Test for what happens when a type parameter `A` is closed over into -// an object. This should yield errors unless `A` (and the object) -// both have suitable bounds. - -trait SomeTrait { fn get(&self) -> isize; } - -fn make_object1(v: A) -> Box { - box v as Box - //~^ ERROR the parameter type `A` may not live long enough - //~| ERROR the parameter type `A` may not live long enough -} - -fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box { - box v as Box -} - -fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box { - box v as Box - //~^ ERROR the parameter type `A` may not live long enough - //~| ERROR the parameter type `A` may not live long enough -} - -fn main() { } diff --git a/src/test/compile-fail/regions-close-over-type-parameter-multiple.rs b/src/test/compile-fail/regions-close-over-type-parameter-multiple.rs deleted file mode 100644 index ad6c5a31bbb..00000000000 --- a/src/test/compile-fail/regions-close-over-type-parameter-multiple.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -// Various tests where we over type parameters with multiple lifetime -// bounds. - -trait SomeTrait { fn get(&self) -> isize; } - -fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { - // A outlives 'a AND 'b... - box v as Box // ...hence this type is safe. -} - -fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { - // A outlives 'a AND 'b... - box v as Box // ...hence this type is safe. -} - -fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { - // A outlives 'a AND 'b...but not 'c. - box v as Box //~ ERROR cannot infer an appropriate lifetime -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-close-param-into-object.rs b/src/test/compile-fail/regions-close-param-into-object.rs deleted file mode 100644 index c9063405bd7..00000000000 --- a/src/test/compile-fail/regions-close-param-into-object.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait X { fn foo(&self) {} } - -fn p1(v: T) -> Box - where T : X -{ - Box::new(v) //~ ERROR parameter type `T` may not live long enough -} - -fn p2(v: Box) -> Box - where Box : X -{ - Box::new(v) //~ ERROR parameter type `T` may not live long enough -} - -fn p3<'a,T>(v: T) -> Box - where T : X -{ - Box::new(v) //~ ERROR parameter type `T` may not live long enough -} - -fn p4<'a,T>(v: Box) -> Box - where Box : X -{ - Box::new(v) //~ ERROR parameter type `T` may not live long enough -} - -fn main() {} diff --git a/src/test/compile-fail/regions-creating-enums.rs b/src/test/compile-fail/regions-creating-enums.rs deleted file mode 100644 index ad2dc28afef..00000000000 --- a/src/test/compile-fail/regions-creating-enums.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum ast<'a> { - num(usize), - add(&'a ast<'a>, &'a ast<'a>) -} - -fn build() { - let x = ast::num(3); - let y = ast::num(4); - let z = ast::add(&x, &y); - compute(&z); -} - -fn compute(x: &ast) -> usize { - match *x { - ast::num(x) => { x } - ast::add(x, y) => { compute(x) + compute(y) } - } -} - -fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { - match *x { - ast::num(x) => { - return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough - } - ast::add(x, y) => { - let m_x = map_nums(x, f); - let m_y = map_nums(y, f); - return &ast::add(m_x, m_y); //~ ERROR borrowed value does not live long enough - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/regions-creating-enums3.rs b/src/test/compile-fail/regions-creating-enums3.rs deleted file mode 100644 index dcc579d26c1..00000000000 --- a/src/test/compile-fail/regions-creating-enums3.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum ast<'a> { - num(usize), - add(&'a ast<'a>, &'a ast<'a>) -} - -fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> { - ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623] -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-creating-enums4.rs b/src/test/compile-fail/regions-creating-enums4.rs deleted file mode 100644 index 5dc9b370f32..00000000000 --- a/src/test/compile-fail/regions-creating-enums4.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum ast<'a> { - num(usize), - add(&'a ast<'a>, &'a ast<'a>) -} - -fn mk_add_bad2<'a,'b>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'b> { - ast::add(x, y) //~ ERROR cannot infer -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-early-bound-error-method.rs b/src/test/compile-fail/regions-early-bound-error-method.rs deleted file mode 100644 index eaf9a750570..00000000000 --- a/src/test/compile-fail/regions-early-bound-error-method.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that you can use a fn lifetime parameter as part of -// the value for a type parameter in a bound. - -trait GetRef<'a> { - fn get(&self) -> &'a isize; -} - -struct Box<'a> { - t: &'a isize -} - -impl<'a> GetRef<'a> for Box<'a> { - fn get(&self) -> &'a isize { - self.t - } -} - -impl<'a> Box<'a> { - fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { - g2.get() - //~^ ERROR E0312 - } -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-early-bound-error.rs b/src/test/compile-fail/regions-early-bound-error.rs deleted file mode 100644 index 90a33950047..00000000000 --- a/src/test/compile-fail/regions-early-bound-error.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that you can use a fn lifetime parameter as part of -// the value for a type parameter in a bound. - -trait GetRef<'a, T> { - fn get(&self) -> &'a T; -} - -struct Box<'a, T:'a> { - t: &'a T -} - -impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { - fn get(&self) -> &'a T { - self.t - } -} - -fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { - g1.get() - //~^ ERROR E0312 -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-enum-not-wf.rs b/src/test/compile-fail/regions-enum-not-wf.rs deleted file mode 100644 index e21f92bc9b8..00000000000 --- a/src/test/compile-fail/regions-enum-not-wf.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various examples of structs whose fields are not well-formed. - -#![allow(dead_code)] - -enum Ref1<'a, T> { - Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough -} - -enum Ref2<'a, T> { - Ref2Variant1, - Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough -} - -enum RefOk<'a, T:'a> { - RefOkVariant1(&'a T) -} - -enum RefIndirect<'a, T> { - RefIndirectVariant1(isize, RefOk<'a,T>) - //~^ ERROR the parameter type `T` may not live long enough -} - -enum RefDouble<'a, 'b, T> { - RefDoubleVariant1(&'a &'b T) - //~^ ERROR reference has a longer lifetime than the data -} - -fn main() { } diff --git a/src/test/compile-fail/regions-escape-method.rs b/src/test/compile-fail/regions-escape-method.rs deleted file mode 100644 index e3771cfebba..00000000000 --- a/src/test/compile-fail/regions-escape-method.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a method call where the parameter `B` would (illegally) be -// inferred to a region bound in the method argument. If this program -// were accepted, then the closure passed to `s.f` could escape its -// argument. - -struct S; - -impl S { - fn f(&self, _: F) where F: FnOnce(&i32) -> B { - } -} - -fn main() { - let s = S; - s.f(|p| p) //~ ERROR cannot infer -} diff --git a/src/test/compile-fail/regions-escape-via-trait-or-not.rs b/src/test/compile-fail/regions-escape-via-trait-or-not.rs deleted file mode 100644 index a4363b00e1c..00000000000 --- a/src/test/compile-fail/regions-escape-via-trait-or-not.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -trait Deref { - fn get(self) -> isize; -} - -impl<'a> Deref for &'a isize { - fn get(self) -> isize { - *self - } -} - -fn with(f: F) -> isize where F: FnOnce(&isize) -> R { - f(&3).get() -} - -fn return_it() -> isize { - with(|o| o) //~ ERROR cannot infer -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-fn-subtyping-return-static.rs b/src/test/compile-fail/regions-fn-subtyping-return-static.rs deleted file mode 100644 index 6be65a5e359..00000000000 --- a/src/test/compile-fail/regions-fn-subtyping-return-static.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// In this fn, the type `F` is a function that takes a reference to a -// struct and returns another reference with the same lifetime. -// -// Meanwhile, the bare fn `foo` takes a reference to a struct with -// *ANY* lifetime and returns a reference with the 'static lifetime. -// This can safely be considered to be an instance of `F` because all -// lifetimes are sublifetimes of 'static. - -#![allow(dead_code)] -#![allow(unused_variables)] - -struct S; - -// Given 'cx, return 'cx -type F = for<'cx> fn(&'cx S) -> &'cx S; -fn want_F(f: F) { } - -// Given anything, return 'static -type G = for<'cx> fn(&'cx S) -> &'static S; -fn want_G(f: G) { } - -// Should meet both. -fn foo(x: &S) -> &'static S { - panic!() -} - -// Should meet both. -fn bar<'a,'b>(x: &'a S) -> &'b S { - panic!() -} - -// Meets F, but not G. -fn baz(x: &S) -> &S { - panic!() -} - -fn supply_F() { - want_F(foo); - - // FIXME(#33684) -- this should be a subtype, but current alg. rejects it incorrectly - want_F(bar); //~ ERROR E0308 - - want_F(baz); -} - -fn supply_G() { - want_G(foo); - want_G(bar); - want_G(baz); - //~^ ERROR mismatched types - //~| expected type `for<'cx> fn(&'cx S) -> &'static S` - //~| found type `for<'r> fn(&'r S) -> &'r S {baz}` - //~| expected concrete lifetime, found bound lifetime parameter 'cx -} - -pub fn main() { -} diff --git a/src/test/compile-fail/regions-free-region-ordering-callee-4.rs b/src/test/compile-fail/regions-free-region-ordering-callee-4.rs deleted file mode 100644 index bd31d1a5a90..00000000000 --- a/src/test/compile-fail/regions-free-region-ordering-callee-4.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that callees correctly infer an ordering between free regions -// that appear in their parameter list. See also -// regions-free-region-ordering-caller.rs - -fn ordering4<'a, 'b, F>(a: &'a usize, b: &'b usize, x: F) where F: FnOnce(&'a &'b usize) { - //~^ ERROR reference has a longer lifetime than the data it references - // Do not infer ordering from closure argument types. - let z: Option<&'a &'b usize> = None; -} - -fn main() {} diff --git a/src/test/compile-fail/regions-free-region-ordering-callee.rs b/src/test/compile-fail/regions-free-region-ordering-callee.rs deleted file mode 100644 index 073a4f79b05..00000000000 --- a/src/test/compile-fail/regions-free-region-ordering-callee.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that callees correctly infer an ordering between free regions -// that appear in their parameter list. See also -// regions-free-region-ordering-caller.rs - -fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize { - // It is safe to assume that 'a <= 'b due to the type of x - let y: &'b usize = &**x; - return y; -} - -fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { - // However, it is not safe to assume that 'b <= 'a - &*y //~ ERROR 23:5: 23:8: lifetime mismatch [E0623] -} - -fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { - // Do not infer an ordering from the return value. - let z: &'b usize = &*x; - //~^ ERROR 28:24: 28:27: lifetime mismatch [E0623] - panic!(); -} - -// see regions-free-region-ordering-callee-4.rs - -fn ordering5<'a, 'b>(a: &'a usize, b: &'b usize, x: Option<&'a &'b usize>) { - let z: Option<&'a &'b usize> = None; -} - -fn main() {} diff --git a/src/test/compile-fail/regions-free-region-ordering-caller.rs b/src/test/compile-fail/regions-free-region-ordering-caller.rs deleted file mode 100644 index 66b16744cc7..00000000000 --- a/src/test/compile-fail/regions-free-region-ordering-caller.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test various ways to construct a pointer with a longer lifetime -// than the thing it points at and ensure that they result in -// errors. See also regions-free-region-ordering-callee.rs - -struct Paramd<'a> { x: &'a usize } - -fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'b &'a usize> = None;//~ ERROR E0623 -} - -fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { - let y: Paramd<'a> = Paramd { x: a }; - let z: Option<&'b Paramd<'a>> = None;//~ ERROR E0623 -} - -fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'a &'b usize> = None;//~ ERROR E0623 -} - -fn main() {} diff --git a/src/test/compile-fail/regions-free-region-ordering-caller1.rs b/src/test/compile-fail/regions-free-region-ordering-caller1.rs deleted file mode 100644 index b29518ccdab..00000000000 --- a/src/test/compile-fail/regions-free-region-ordering-caller1.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test various ways to construct a pointer with a longer lifetime -// than the thing it points at and ensure that they result in -// errors. See also regions-free-region-ordering-callee.rs - -fn call1<'a>(x: &'a usize) { - // Test that creating a pointer like - // &'a &'z usize requires that 'a <= 'z: - let y: usize = 3; - let z: &'a & usize = &(&y); - //~^ ERROR borrowed value does not live long enough - //~^^ ERROR `y` does not live long enough -} - -fn main() {} diff --git a/src/test/compile-fail/regions-free-region-ordering-incorrect.rs b/src/test/compile-fail/regions-free-region-ordering-incorrect.rs deleted file mode 100644 index 9cb61c24922..00000000000 --- a/src/test/compile-fail/regions-free-region-ordering-incorrect.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that free regions ordering only goes one way. That is, -// we have `&'a Node<'b, T>`, which implies that `'a <= 'b`, -// but not `'b <= 'a`. Hence returning `&self.val` (which has lifetime -// `'a`) where `'b` is expected yields an error. -// -// This test began its life as a test for issue #4325. - -struct Node<'b, T:'b> { - val: T, - next: Option<&'b Node<'b, T>> -} - -impl<'b, T> Node<'b, T> { - fn get<'a>(&'a self) -> &'b T { - match self.next { - Some(ref next) => next.get(), - None => &self.val //~ ERROR cannot infer - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/regions-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs deleted file mode 100644 index 843c5f512f8..00000000000 --- a/src/test/compile-fail/regions-glb-free-free.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod argparse { - pub struct Flag<'a> { - name: &'a str, - pub desc: &'a str, - max_count: usize, - value: usize - } - - pub fn flag<'r>(name: &'r str, desc: &'r str) -> Flag<'r> { - Flag { name: name, desc: desc, max_count: 1, value: 0 } - } - - impl<'a> Flag<'a> { - pub fn set_desc(self, s: &str) -> Flag<'a> { - Flag { //~ ERROR 25:13: 30:14: explicit lifetime required in the type of `s` [E0621] - name: self.name, - desc: s, - max_count: self.max_count, - value: self.value - } - } - } -} - -fn main () { - let f : argparse::Flag = argparse::flag("flag", "My flag"); - let updated_flag = f.set_desc("My new flag"); - assert_eq!(updated_flag.desc, "My new flag"); -} diff --git a/src/test/compile-fail/regions-implied-bounds-projection-gap-1.rs b/src/test/compile-fail/regions-implied-bounds-projection-gap-1.rs deleted file mode 100644 index 65594ab8f2e..00000000000 --- a/src/test/compile-fail/regions-implied-bounds-projection-gap-1.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Illustrates the "projection gap": in this test, even though we know -// that `T::Foo: 'x`, that does not tell us that `T: 'x`, because -// there might be other ways for the caller of `func` to show that -// `T::Foo: 'x` holds (e.g., where-clause). - -trait Trait1<'x> { - type Foo; -} - -// calling this fn should trigger a check that the type argument -// supplied is well-formed. -fn wf() { } - -fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) -{ - wf::<&'x T>(); - //~^ ERROR the parameter type `T` may not live long enough -} - -fn caller2<'x, T:Trait1<'x>>(t: &'x T) -{ - wf::<&'x T::Foo>(); // OK -} - -fn caller3<'x, T:Trait1<'x>>(t: &'x T::Foo) -{ - wf::<&'x T::Foo>(); // OK -} - -fn main() { } diff --git a/src/test/compile-fail/regions-implied-bounds-projection-gap-2.rs b/src/test/compile-fail/regions-implied-bounds-projection-gap-2.rs deleted file mode 100644 index b3037a1e187..00000000000 --- a/src/test/compile-fail/regions-implied-bounds-projection-gap-2.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Along with the other tests in this series, illustrates the -// "projection gap": in this test, we know that `T: 'x`, and that is -// enough to conclude that `T::Foo: 'x`. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -trait Trait1<'x> { - type Foo; -} - -// calling this fn should trigger a check that the type argument -// supplied is well-formed. -fn wf() { } - -fn func<'x, T:Trait1<'x>>(t: &'x T) -{ - wf::<&'x T::Foo>(); -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/regions-implied-bounds-projection-gap-3.rs b/src/test/compile-fail/regions-implied-bounds-projection-gap-3.rs deleted file mode 100644 index a2e6de21376..00000000000 --- a/src/test/compile-fail/regions-implied-bounds-projection-gap-3.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Along with the other tests in this series, illustrates the -// "projection gap": in this test, we know that `T::Foo: 'x`, and that -// is (naturally) enough to conclude that `T::Foo: 'x`. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -trait Trait1<'x> { - type Foo; -} - -// calling this fn should trigger a check that the type argument -// supplied is well-formed. -fn wf() { } - -fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) -{ - wf::<&'x T::Foo>(); -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/regions-implied-bounds-projection-gap-4.rs b/src/test/compile-fail/regions-implied-bounds-projection-gap-4.rs deleted file mode 100644 index b8582f8c26b..00000000000 --- a/src/test/compile-fail/regions-implied-bounds-projection-gap-4.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Along with the other tests in this series, illustrates the -// "projection gap": in this test, we know that `T: 'x`, and that -// is (naturally) enough to conclude that `T: 'x`. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -trait Trait1<'x> { - type Foo; -} - -// calling this fn should trigger a check that the type argument -// supplied is well-formed. -fn wf() { } - -fn func<'x, T:Trait1<'x>>(t: &'x T) -{ - wf::<&'x T>(); -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs b/src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs deleted file mode 100644 index fd186d16559..00000000000 --- a/src/test/compile-fail/regions-implied-bounds-projection-gap-hr-1.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The "projection gap" is particularly "fun" around higher-ranked -// projections. This is because the current code is hard-coded to say -// that a projection that contains escaping regions, like `>::Foo` where `'z` is bound, can only be found to -// outlive a region if all components that appear free (`'y`, where) -// outlive that region. However, we DON'T add those components to the -// implied bounds set, but rather we treat projections with escaping -// regions as opaque entities, just like projections without escaping -// regions. - -trait Trait1 { } - -trait Trait2<'a, 'b> { - type Foo; -} - -// As a side-effect of the conservative process above, the type of -// this argument `t` is not automatically considered well-formed, -// since for it to be WF, we would need to know that `'y: 'x`, but we -// do not infer that. -fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< >::Foo >) - //~^ ERROR reference has a longer lifetime than the data it references -{ -} - -fn main() { } diff --git a/src/test/compile-fail/regions-in-enums-anon.rs b/src/test/compile-fail/regions-in-enums-anon.rs deleted file mode 100644 index 305bf88c4d5..00000000000 --- a/src/test/compile-fail/regions-in-enums-anon.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that anonymous lifetimes are not permitted in enum declarations - -enum Foo { - Bar(&isize) //~ ERROR missing lifetime specifier -} - -fn main() {} diff --git a/src/test/compile-fail/regions-in-enums.rs b/src/test/compile-fail/regions-in-enums.rs deleted file mode 100644 index 613a90dda67..00000000000 --- a/src/test/compile-fail/regions-in-enums.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that lifetimes must be declared for use on enums. -// See also regions-undeclared.rs - -enum yes0<'lt> { - X3(&'lt usize) -} - -enum yes1<'a> { - X4(&'a usize) -} - -enum no0 { - X5(&'foo usize) //~ ERROR use of undeclared lifetime name `'foo` -} - -enum no1 { - X6(&'a usize) //~ ERROR use of undeclared lifetime name `'a` -} - -fn main() {} diff --git a/src/test/compile-fail/regions-in-structs-anon.rs b/src/test/compile-fail/regions-in-structs-anon.rs deleted file mode 100644 index b85928b1b9f..00000000000 --- a/src/test/compile-fail/regions-in-structs-anon.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that anonymous lifetimes are not permitted in struct declarations - -struct Foo { - x: &isize //~ ERROR missing lifetime specifier -} - -fn main() {} diff --git a/src/test/compile-fail/regions-in-structs.rs b/src/test/compile-fail/regions-in-structs.rs deleted file mode 100644 index c231d3a913e..00000000000 --- a/src/test/compile-fail/regions-in-structs.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct yes1<'a> { - x: &'a usize, -} - -struct yes2<'a> { - x: &'a usize, -} - -struct StructDecl { - a: &'a isize, //~ ERROR use of undeclared lifetime name `'a` - b: &'a isize, //~ ERROR use of undeclared lifetime name `'a` -} - - -fn main() {} diff --git a/src/test/compile-fail/regions-infer-at-fn-not-param.rs b/src/test/compile-fail/regions-infer-at-fn-not-param.rs deleted file mode 100644 index ec73bf90b6e..00000000000 --- a/src/test/compile-fail/regions-infer-at-fn-not-param.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct parameterized1<'a> { - g: Box -} - -struct not_parameterized1 { - g: Box -} - -struct not_parameterized2 { - g: Box -} - -fn take1<'a>(p: parameterized1) -> parameterized1<'a> { p } -//~^ ERROR explicit lifetime required in the type of `p` - -fn take3(p: not_parameterized1) -> not_parameterized1 { p } -fn take4(p: not_parameterized2) -> not_parameterized2 { p } - -fn main() {} diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs deleted file mode 100644 index 2628e6a1ce2..00000000000 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct point { - x: isize, - y: isize, -} - -fn x_coord<'r>(p: &'r point) -> &'r isize { - return &p.x; -} - -fn foo<'a>(p: Box) -> &'a isize { - let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough - assert_eq!(*xc, 3); - return xc; -} - -fn main() {} diff --git a/src/test/compile-fail/regions-infer-bound-from-trait-self.rs b/src/test/compile-fail/regions-infer-bound-from-trait-self.rs deleted file mode 100644 index 23b8ebfe54b..00000000000 --- a/src/test/compile-fail/regions-infer-bound-from-trait-self.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can derive lifetime bounds on `Self` from trait -// inheritance. - -trait Static : 'static { } - -trait Is<'a> : 'a { } - -struct Inv<'a> { - x: Option<&'a mut &'a isize> -} - -fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } - -// In these case, `Self` inherits `'static`. - -trait InheritsFromStatic : Sized + 'static { - fn foo1<'a>(self, x: Inv<'a>) { - check_bound(x, self) - } -} -trait InheritsFromStaticIndirectly : Sized + Static { - fn foo1<'a>(self, x: Inv<'a>) { - check_bound(x, self) - } -} - - -// In these case, `Self` inherits `'a`. - -trait InheritsFromIs<'a> : Sized + 'a { - fn foo(self, x: Inv<'a>) { - check_bound(x, self) - } -} - -trait InheritsFromIsIndirectly<'a> : Sized + Is<'a> { - fn foo(self, x: Inv<'a>) { - check_bound(x, self) - } -} - -// In this case, `Self` inherits nothing. - -trait InheritsFromNothing<'a> : Sized { - fn foo(self, x: Inv<'a>) { - check_bound(x, self) - //~^ ERROR parameter type `Self` may not live long enough - } -} - -fn main() { } diff --git a/src/test/compile-fail/regions-infer-bound-from-trait.rs b/src/test/compile-fail/regions-infer-bound-from-trait.rs deleted file mode 100644 index f7a91054766..00000000000 --- a/src/test/compile-fail/regions-infer-bound-from-trait.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can derive lifetime bounds on type parameters -// from trait inheritance. - -trait Static : 'static { } - -trait Is<'a> : 'a { } - -struct Inv<'a> { - x: Option<&'a mut &'a isize> -} - -fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } - -// In all of these cases, we can derive a bound for A that is longer -// than 'a based on the trait bound of A: - -fn foo1<'a,A:Static>(x: Inv<'a>, a: A) { - check_bound(x, a) -} - -fn foo2<'a,A:Static>(x: Inv<'static>, a: A) { - check_bound(x, a) -} - -fn foo3<'a,A:Is<'a>>(x: Inv<'a>, a: A) { - check_bound(x, a) -} - -// In these cases, there is no trait bound, so we cannot derive any -// bound for A and we get an error: - -fn bar1<'a,A>(x: Inv<'a>, a: A) { - check_bound(x, a) //~ ERROR parameter type `A` may not live long enough -} - -fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { - check_bound(x, a) //~ ERROR parameter type `A` may not live long enough -} - -fn main() { } diff --git a/src/test/compile-fail/regions-infer-call-3.rs b/src/test/compile-fail/regions-infer-call-3.rs deleted file mode 100644 index 95783a420b6..00000000000 --- a/src/test/compile-fail/regions-infer-call-3.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn select<'r>(x: &'r isize, y: &'r isize) -> &'r isize { x } - -fn with(f: F) -> T where F: FnOnce(&isize) -> T { - f(&20) -} - -fn manip<'a>(x: &'a isize) -> isize { - let z = with(|y| { select(x, y) }); - //~^ ERROR cannot infer - *z -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs deleted file mode 100644 index 6e1c765724b..00000000000 --- a/src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a type which is contravariant with respect to its region -// parameter yields an error when used in a covariant way. -// -// Note: see variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -use std::marker; - -// This is contravariant with respect to 'a, meaning that -// Contravariant<'foo> <: Contravariant<'static> because -// 'foo <= 'static -struct Contravariant<'a> { - marker: marker::PhantomData<&'a()> -} - -fn use_<'short,'long>(c: Contravariant<'short>, - s: &'short isize, - l: &'long isize, - _where:Option<&'short &'long ()>) { - - // Test whether Contravariant<'short> <: Contravariant<'long>. Since - // 'short <= 'long, this would be true if the Contravariant type were - // covariant with respect to its parameter 'a. - - let _: Contravariant<'long> = c; //~ ERROR E0623 -} - -fn main() {} diff --git a/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs deleted file mode 100644 index 1ab8ba4439b..00000000000 --- a/src/test/compile-fail/regions-infer-covariance-due-to-decl.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a type which is covariant with respect to its region -// parameter yields an error when used in a contravariant way. -// -// Note: see variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -use std::marker; - -struct Covariant<'a> { - marker: marker::PhantomData -} - -fn use_<'short,'long>(c: Covariant<'long>, - s: &'short isize, - l: &'long isize, - _where:Option<&'short &'long ()>) { - - // Test whether Covariant<'long> <: Covariant<'short>. Since - // 'short <= 'long, this would be true if the Covariant type were - // contravariant with respect to its parameter 'a. - - let _: Covariant<'short> = c; //~ ERROR E0623 -} - -fn main() {} diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs b/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs deleted file mode 100644 index 8c191fbd5bb..00000000000 --- a/src/test/compile-fail/regions-infer-invariance-due-to-decl.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker; - -struct invariant<'a> { - marker: marker::PhantomData<*mut &'a()> -} - -fn to_same_lifetime<'r>(b_isize: invariant<'r>) { - let bj: invariant<'r> = b_isize; -} - -fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { - b_isize //~ ERROR mismatched types -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs deleted file mode 100644 index f280e4d978e..00000000000 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct invariant<'a> { - f: Box, -} - -fn to_same_lifetime<'r>(b_isize: invariant<'r>) { - let bj: invariant<'r> = b_isize; -} - -fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { - b_isize //~ ERROR mismatched types -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs deleted file mode 100644 index 87b5efbfadd..00000000000 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct Invariant<'a> { - f: Box *mut &'a isize + 'static>, -} - -fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { - let bj: Invariant<'r> = b_isize; -} - -fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - b_isize //~ ERROR mismatched types -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-infer-not-param.rs b/src/test/compile-fail/regions-infer-not-param.rs deleted file mode 100644 index 131b7170951..00000000000 --- a/src/test/compile-fail/regions-infer-not-param.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct direct<'a> { - f: &'a isize -} - -struct indirect1 { - // Here the lifetime parameter of direct is bound by the fn() - g: Box -} - -struct indirect2<'a> { - // But here it is set to 'a - g: Box) + 'static> -} - -fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types - -fn take_indirect1(p: indirect1) -> indirect1 { p } - -fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types -//~| expected type `indirect2<'b>` -//~| found type `indirect2<'a>` -//~| ERROR mismatched types -//~| expected type `indirect2<'b>` -//~| found type `indirect2<'a>` - -fn main() {} diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs deleted file mode 100644 index c559992c865..00000000000 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// Check that we correctly infer that b and c must be region -// parameterized because they reference a which requires a region. - -type a<'a> = &'a isize; -type b<'a> = Box>; - -struct c<'a> { - f: Box> -} - -trait set_f<'a> { - fn set_f_ok(&mut self, b: Box>); - fn set_f_bad(&mut self, b: Box); -} - -impl<'a> set_f<'a> for c<'a> { - fn set_f_ok(&mut self, b: Box>) { - self.f = b; - } - - fn set_f_bad(&mut self, b: Box) { - self.f = b; - //~^ ERROR mismatched types - //~| expected type `std::boxed::Box>` - //~| found type `std::boxed::Box>` - //~| lifetime mismatch - } -} - -fn main() {} diff --git a/src/test/compile-fail/regions-infer-proc-static-upvar.rs b/src/test/compile-fail/regions-infer-proc-static-upvar.rs deleted file mode 100644 index ee5d5cad0a3..00000000000 --- a/src/test/compile-fail/regions-infer-proc-static-upvar.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that, when a variable of type `&T` is captured inside a proc, -// we correctly infer/require that its lifetime is 'static. - -fn foo(_p: F) { } - -static i: isize = 3; - -fn capture_local() { - let x = 3; - let y = &x; //~ ERROR `x` does not live long enough - foo(move|| { - let _a = *y; - }); -} - -fn capture_static() { - // Legal because &i can have static lifetime: - let y = &i; - foo(move|| { - let _a = *y; - }); -} - -fn main() { } diff --git a/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs b/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs deleted file mode 100644 index 5955619ea92..00000000000 --- a/src/test/compile-fail/regions-lifetime-bounds-on-fns.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { - // Note: this is legal because of the `'b:'a` declaration. - *x = *y; -} - -fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { - // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 -} - -fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { - // Here we try to call `foo` but do not know that `'a` and `'b` are - // related as required. - a(x, y); //~ ERROR 24:7: 24:8: lifetime mismatch [E0623] -} - -fn d() { - // 'a and 'b are early bound in the function `a` because they appear - // inconstraints: - let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types -} - -fn e() { - // 'a and 'b are late bound in the function `b` because there are - // no constraints: - let _: fn(&mut &isize, &mut &isize) = b; -} - -fn main() { } diff --git a/src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs b/src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs deleted file mode 100644 index 46c486c63a3..00000000000 --- a/src/test/compile-fail/regions-lifetime-of-struct-or-enum-variant.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This tests verifies that unary structs and enum variants -// are treated as rvalues and their lifetime is not bounded to -// the static scope. - -fn id(x: T) -> T { x } - -struct Test; - -enum MyEnum { - Variant1 -} - -fn structLifetime<'a>() -> &'a Test { - let testValue = &id(Test); - //~^ ERROR borrowed value does not live long enough - testValue -} - -fn variantLifetime<'a>() -> &'a MyEnum { - let testValue = &id(MyEnum::Variant1); - //~^ ERROR borrowed value does not live long enough - testValue -} - - -fn main() {} diff --git a/src/test/compile-fail/regions-name-duplicated.rs b/src/test/compile-fail/regions-name-duplicated.rs deleted file mode 100644 index b4b9cfd75cb..00000000000 --- a/src/test/compile-fail/regions-name-duplicated.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo<'a, 'a> { //~ ERROR lifetime name `'a` declared twice - x: &'a isize -} - -fn main() {} diff --git a/src/test/compile-fail/regions-name-static.rs b/src/test/compile-fail/regions-name-static.rs deleted file mode 100644 index 69d63f3820c..00000000000 --- a/src/test/compile-fail/regions-name-static.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo<'static> { //~ ERROR invalid lifetime parameter name: `'static` - x: &'static isize -} - -fn main() {} diff --git a/src/test/compile-fail/regions-name-undeclared.rs b/src/test/compile-fail/regions-name-undeclared.rs deleted file mode 100644 index a61d3094933..00000000000 --- a/src/test/compile-fail/regions-name-undeclared.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that lifetime resolver enforces the lifetime name scoping -// rules correctly in various scenarios. - -struct Foo<'a> { - x: &'a isize -} - -impl<'a> Foo<'a> { - // &'a is inherited: - fn m1(&self, arg: &'a isize) { } - fn m2(&'a self) { } - fn m3(&self, arg: Foo<'a>) { } - - // &'b is not: - fn m4(&self, arg: &'b isize) { } //~ ERROR undeclared lifetime - fn m5(&'b self) { } //~ ERROR undeclared lifetime - fn m6(&self, arg: Foo<'b>) { } //~ ERROR undeclared lifetime -} - -fn bar<'a>(x: &'a isize) { - // &'a is visible to code: - let y: &'a isize = x; - - // &'a is not visible to *items*: - type X = Option<&'a isize>; //~ ERROR undeclared lifetime - enum E { - E1(&'a isize) //~ ERROR undeclared lifetime - } - struct S { - f: &'a isize //~ ERROR undeclared lifetime - } - fn f(a: &'a isize) { } //~ ERROR undeclared lifetime - - // &'a CAN be declared on functions and used then: - fn g<'a>(a: &'a isize) { } // OK - fn h(a: Box FnOnce(&'a isize)>) { } // OK -} - -// Test nesting of lifetimes in fn type declarations -fn fn_types(a: &'a isize, //~ ERROR undeclared lifetime - b: Box FnOnce(&'a isize, - &'b isize, //~ ERROR undeclared lifetime - Box FnOnce(&'a isize, - &'b isize)>, - &'b isize)>, //~ ERROR undeclared lifetime - c: &'a isize) //~ ERROR undeclared lifetime -{ -} - -pub fn main() {} diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs deleted file mode 100644 index 010b7d17688..00000000000 --- a/src/test/compile-fail/regions-nested-fns.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn ignore(t: T) {} - -fn nested<'x>(x: &'x isize) { - let y = 3; - let mut ay = &y; //~ ERROR E0495 - - ignore:: FnMut(&'z isize)>>(Box::new(|z| { - ay = x; - ay = &y; - ay = z; - })); - - ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - if false { return x; } //~ ERROR E0312 - if false { return ay; } - return z; - })); -} - -fn main() {} diff --git a/src/test/compile-fail/regions-normalize-in-where-clause-list.rs b/src/test/compile-fail/regions-normalize-in-where-clause-list.rs deleted file mode 100644 index 68642598ed2..00000000000 --- a/src/test/compile-fail/regions-normalize-in-where-clause-list.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to normalize in the list of where-clauses, -// even if `'a: 'b` is required. - -trait Project<'a, 'b> { - type Item; -} - -impl<'a, 'b> Project<'a, 'b> for () - where 'a: 'b -{ - type Item = (); -} - -// No error here, we have 'a: 'b. We used to report an error here -// though, see https://github.com/rust-lang/rust/issues/45937. -fn foo<'a: 'b, 'b>() - where <() as Project<'a, 'b>>::Item : Eq -{ -} - -// Here we get an error: we need `'a: 'b`. -fn bar<'a, 'b>() //~ ERROR cannot infer - where <() as Project<'a, 'b>>::Item : Eq -{ -} - -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs deleted file mode 100644 index db25a0698fe..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-enum-region-rev.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod rev_variant_struct_region { - struct Foo<'a> { - x: fn(&'a i32), - } - enum Bar<'a,'b> { - V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs deleted file mode 100644 index 403757042d2..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-enum-region.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod variant_struct_region { - struct Foo<'a> { - x: &'a i32, - } - enum Bar<'a,'b> { - V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-enum-type-rev.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-type-rev.rs deleted file mode 100644 index cc294651db7..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-enum-type-rev.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod rev_variant_struct_type { - struct Foo { - x: fn(T) - } - enum Bar<'a,'b> { - V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-enum-type.rs b/src/test/compile-fail/regions-outlives-nominal-type-enum-type.rs deleted file mode 100644 index e269767cc16..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-enum-type.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod variant_struct_type { - struct Foo { - x: T - } - enum Bar<'a,'b> { - F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-region-rev.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-region-rev.rs deleted file mode 100644 index c7e6ace8b92..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-struct-region-rev.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod rev_variant_struct_region { - struct Foo<'a> { - x: fn(&'a i32), - } - struct Bar<'a,'b> { - f: &'a Foo<'b> //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-region.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-region.rs deleted file mode 100644 index 2fe6444c33a..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-struct-region.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod variant_struct_region { - struct Foo<'a> { - x: &'a i32, - } - struct Bar<'a,'b> { - f: &'a Foo<'b> //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-type-rev.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-type-rev.rs deleted file mode 100644 index c4b631bce98..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-struct-type-rev.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod rev_variant_struct_type { - struct Foo { - x: fn(T) - } - struct Bar<'a,'b> { - f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-nominal-type-struct-type.rs b/src/test/compile-fail/regions-outlives-nominal-type-struct-type.rs deleted file mode 100644 index 1c9489444a6..00000000000 --- a/src/test/compile-fail/regions-outlives-nominal-type-struct-type.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod variant_struct_type { - struct Foo { - x: T - } - struct Bar<'a,'b> { - f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/regions-outlives-projection-container-hrtb.rs b/src/test/compile-fail/regions-outlives-projection-container-hrtb.rs deleted file mode 100644 index ec0631a881a..00000000000 --- a/src/test/compile-fail/regions-outlives-projection-container-hrtb.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that structs with higher-ranked where clauses don't generate -// "outlives" requirements. Issue #22246. - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -/////////////////////////////////////////////////////////////////////////// - -pub trait TheTrait<'b> { - type TheAssocType; -} - -pub struct TheType<'b> { - m: [fn(&'b()); 0] -} - -impl<'a,'b> TheTrait<'a> for TheType<'b> { - type TheAssocType = &'b (); -} - -/////////////////////////////////////////////////////////////////////////// - -pub struct WithHrAssoc - where for<'a> T : TheTrait<'a> -{ - m: [T; 0] -} - -fn with_assoc<'a,'b>() { - // We get an error because 'b:'a does not hold: - - let _: &'a WithHrAssoc> = loop { }; - //~^ ERROR reference has a longer lifetime -} - -/////////////////////////////////////////////////////////////////////////// - -pub trait TheSubTrait : for<'a> TheTrait<'a> { -} - -impl<'b> TheSubTrait for TheType<'b> { } - -pub struct WithHrAssocSub - where T : TheSubTrait -{ - m: [T; 0] -} - -fn with_assoc_sub<'a,'b>() { - // The error here is just because `'b:'a` must hold for the type - // below to be well-formed, it is not related to the HR relation. - - let _: &'a WithHrAssocSub> = loop { }; - //~^ ERROR reference has a longer lifetime -} - -#[rustc_error] -fn main() { -} diff --git a/src/test/compile-fail/regions-outlives-projection-container-wc.rs b/src/test/compile-fail/regions-outlives-projection-container-wc.rs deleted file mode 100644 index 71606ba812f..00000000000 --- a/src/test/compile-fail/regions-outlives-projection-container-wc.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are imposing the requirement that every associated -// type of a bound that appears in the where clause on a struct must -// outlive the location in which the type appears, even when the -// constraint is in a where clause not a bound. Issue #22246. - -#![allow(dead_code)] - -/////////////////////////////////////////////////////////////////////////// - -pub trait TheTrait { - type TheAssocType; -} - -pub struct TheType<'b> { - m: [fn(&'b()); 0] -} - -impl<'b> TheTrait for TheType<'b> { - type TheAssocType = &'b (); -} - -/////////////////////////////////////////////////////////////////////////// - -pub struct WithAssoc where T : TheTrait { - m: [T; 0] -} - -fn with_assoc<'a,'b>() { - // For this type to be valid, the rules require that all - // associated types of traits that appear in `WithAssoc` must - // outlive 'a. In this case, that means TheType<'b>::TheAssocType, - // which is &'b (), must outlive 'a. - - let _: &'a WithAssoc> = loop { }; - //~^ ERROR reference has a longer lifetime -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-outlives-projection-container.rs b/src/test/compile-fail/regions-outlives-projection-container.rs deleted file mode 100644 index 957e56fe510..00000000000 --- a/src/test/compile-fail/regions-outlives-projection-container.rs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are imposing the requirement that every associated -// type of a bound that appears in the where clause on a struct must -// outlive the location in which the type appears. Issue #22246. - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -/////////////////////////////////////////////////////////////////////////// - -pub trait TheTrait { - type TheAssocType; -} - -pub struct TheType<'b> { - m: [fn(&'b()); 0] -} - -impl<'b> TheTrait for TheType<'b> { - type TheAssocType = &'b (); -} - -/////////////////////////////////////////////////////////////////////////// - -pub struct WithAssoc { - m: [T; 0] -} - -pub struct WithoutAssoc { - m: [T; 0] -} - -fn with_assoc<'a,'b>() { - // For this type to be valid, the rules require that all - // associated types of traits that appear in `WithAssoc` must - // outlive 'a. In this case, that means TheType<'b>::TheAssocType, - // which is &'b (), must outlive 'a. - - let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime -} - -fn with_assoc1<'a,'b>() where 'b : 'a { - // For this type to be valid, the rules require that all - // associated types of traits that appear in `WithAssoc` must - // outlive 'a. In this case, that means TheType<'b>::TheAssocType, - // which is &'b (), must outlive 'a, so 'b : 'a must hold, and - // that is in the where clauses, so we're fine. - - let _: &'a WithAssoc> = loop { }; -} - -fn without_assoc<'a,'b>() { - // Here there are no associated types but there is a requirement - // that `'b:'a` holds because the `'b` appears in `TheType<'b>`. - - let _: &'a WithoutAssoc> = loop { }; //~ ERROR reference has a longer lifetime -} - -fn call_with_assoc<'a,'b>() { - // As `with_assoc`, but just checking that we impose the same rule - // on the value supplied for the type argument, even when there is - // no data. - - call::<&'a WithAssoc>>(); - //~^ ERROR reference has a longer lifetime -} - -fn call_without_assoc<'a,'b>() { - // As `without_assoc`, but in a distinct scenario. - - call::<&'a WithoutAssoc>>(); //~ ERROR reference has a longer lifetime -} - -fn call() { } - -fn main() { -} diff --git a/src/test/compile-fail/regions-outlives-projection-hrtype.rs b/src/test/compile-fail/regions-outlives-projection-hrtype.rs deleted file mode 100644 index 2d271b7be73..00000000000 --- a/src/test/compile-fail/regions-outlives-projection-hrtype.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for the outlives relation when applied to a projection on a -// type with bound regions. In this case, we are checking that -// ` fn(&'r T) as TheTrait>::TheType: 'a` If we're not -// careful, we could wind up with a constraint that `'r:'a`, but since -// `'r` is bound, that leads to badness. This test checks that -// everything works. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait TheTrait { - type TheType; -} - -fn wf() { } - -type FnType = for<'r> fn(&'r T); - -fn foo<'a,'b,T>() - where FnType: TheTrait -{ - wf::< as TheTrait>::TheType >(); -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/regions-outlives-projection-trait-def.rs b/src/test/compile-fail/regions-outlives-projection-trait-def.rs deleted file mode 100644 index 04682a77297..00000000000 --- a/src/test/compile-fail/regions-outlives-projection-trait-def.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that `>::Type: 'b`, where `trait Foo<'a> { Type: -// 'a; }`, does not require that `F: 'b`. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait SomeTrait<'a> { - type Type: 'a; -} - -impl<'a: 'c, 'c, T> SomeTrait<'a> for &'c T where T: SomeTrait<'a> { - type Type = >::Type; - // ~~~~~~~~~~~~~~~~~~~~~~~~~~ - // | - // Note that this type must outlive 'a, due to the trait - // definition. If we fall back to OutlivesProjectionComponents - // here, then we would require that `T:'a`, which is too strong. -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/regions-outlives-scalar.rs b/src/test/compile-fail/regions-outlives-scalar.rs deleted file mode 100644 index 94f7a350cf7..00000000000 --- a/src/test/compile-fail/regions-outlives-scalar.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that scalar values outlive all regions. -// Rule OutlivesScalar from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct Foo<'a> { - x: &'a i32, - y: &'static i32 -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs b/src/test/compile-fail/regions-pattern-typing-issue-19552.rs deleted file mode 100644 index 3401dd1becd..00000000000 --- a/src/test/compile-fail/regions-pattern-typing-issue-19552.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn assert_static(_t: T) {} - -fn main() { - let line = String::new(); - match [&*line] { //~ ERROR `line` does not live long enough - [ word ] => { assert_static(word); } - } -} diff --git a/src/test/compile-fail/regions-pattern-typing-issue-19997.rs b/src/test/compile-fail/regions-pattern-typing-issue-19997.rs deleted file mode 100644 index 1f23dcbb725..00000000000 --- a/src/test/compile-fail/regions-pattern-typing-issue-19997.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -fn main() { - let a0 = 0; - let f = 1; - let mut a1 = &a0; - match (&a1,) { - (&ref b0,) => { - a1 = &f; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `a1` because it is borrowed - drop(b0); - } - } -} diff --git a/src/test/compile-fail/regions-proc-bound-capture.rs b/src/test/compile-fail/regions-proc-bound-capture.rs deleted file mode 100644 index dd7b2bf9635..00000000000 --- a/src/test/compile-fail/regions-proc-bound-capture.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { - // This is legal, because the region bound on `proc` - // states that it captures `x`. - Box::new(move|| { *x }) -} - -fn static_proc(x: &isize) -> Box(isize) + 'static> { - // This is illegal, because the region bound on `proc` is 'static. - Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621] -} - -fn main() { } diff --git a/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs b/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs deleted file mode 100644 index f6f1a189e5e..00000000000 --- a/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref-mut-ref.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #8624. Test for reborrowing with 3 levels, not just two. - -fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { - &mut ***p //~ ERROR 14:5: 14:14: lifetime mismatch [E0623] -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref.rs b/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref.rs deleted file mode 100644 index 7270b477d2d..00000000000 --- a/src/test/compile-fail/regions-reborrow-from-shorter-mut-ref.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #8624. Tests that reborrowing the contents of an `&'b mut` -// pointer which is backed by another `&'a mut` can only be done -// for `'a` (which must be a sublifetime of `'b`). - -fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { - &mut **p //~ ERROR 16:5: 16:13: lifetime mismatch [E0623] -} - -fn main() { - let mut x = 1; - let mut y = &mut x; - let z = copy_borrowed_ptr(&mut y); - *y += 1; - *z += 1; -} diff --git a/src/test/compile-fail/regions-ref-in-fn-arg.rs b/src/test/compile-fail/regions-ref-in-fn-arg.rs deleted file mode 100644 index bc8060e3915..00000000000 --- a/src/test/compile-fail/regions-ref-in-fn-arg.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_patterns)] -#![feature(box_syntax)] - -fn arg_item(box ref x: Box) -> &'static isize { - x //~^ ERROR borrowed value does not live long enough -} - -fn with(f: F) -> R where F: FnOnce(Box) -> R { f(box 3) } - -fn arg_closure() -> &'static isize { - with(|box ref x| x) //~ ERROR borrowed value does not live long enough -} - -fn main() {} diff --git a/src/test/compile-fail/regions-ret-borrowed-1.rs b/src/test/compile-fail/regions-ret-borrowed-1.rs deleted file mode 100644 index b8cebe66518..00000000000 --- a/src/test/compile-fail/regions-ret-borrowed-1.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Similar to regions-ret-borrowed.rs, but using a named lifetime. At -// some point regions-ret-borrowed reported an error but this file did -// not, due to special hardcoding around the anonymous region. - -fn with(f: F) -> R where F: for<'a> FnOnce(&'a isize) -> R { - f(&3) -} - -fn return_it<'a>() -> &'a isize { - with(|o| o) - //~^ ERROR cannot infer -} - -fn main() { - let x = return_it(); - println!("foo={}", *x); -} diff --git a/src/test/compile-fail/regions-ret-borrowed.rs b/src/test/compile-fail/regions-ret-borrowed.rs deleted file mode 100644 index 40909ddd4ad..00000000000 --- a/src/test/compile-fail/regions-ret-borrowed.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Ensure that you cannot use generic types to return a region outside -// of its bound. Here, in the `return_it()` fn, we call with() but -// with R bound to &isize from the return_it. Meanwhile, with() -// provides a value that is only good within its own stack frame. This -// used to successfully compile because we failed to account for the -// fact that fn(x: &isize) rebound the region &. - -fn with(f: F) -> R where F: FnOnce(&isize) -> R { - f(&3) -} - -fn return_it<'a>() -> &'a isize { - with(|o| o) - //~^ ERROR cannot infer -} - -fn main() { - let x = return_it(); - println!("foo={}", *x); -} diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs deleted file mode 100644 index c7cd3ced98d..00000000000 --- a/src/test/compile-fail/regions-ret.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn id(x: T) -> T { x } - -fn f(_x: &isize) -> &isize { - return &id(3); //~ ERROR borrowed value does not live long enough -} - -fn main() { -} diff --git a/src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs b/src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs deleted file mode 100644 index 99e5cc03153..00000000000 --- a/src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that closures cannot subvert aliasing restrictions - -fn main() { - // Unboxed closure case - { - let mut x = 0; - let mut f = || &mut x; //~ ERROR cannot infer - let x = f(); - let y = f(); - } -} diff --git a/src/test/compile-fail/regions-return-stack-allocated-vec.rs b/src/test/compile-fail/regions-return-stack-allocated-vec.rs deleted file mode 100644 index b5d4e07d04b..00000000000 --- a/src/test/compile-fail/regions-return-stack-allocated-vec.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we cannot return a stack allocated slice - -fn function(x: isize) -> &'static [isize] { - &[x] //~ ERROR borrowed value does not live long enough -} - -fn main() { - let x = function(1); - let y = x[0]; -} diff --git a/src/test/compile-fail/regions-static-bound.rs b/src/test/compile-fail/regions-static-bound.rs deleted file mode 100644 index 0a37df4f0c7..00000000000 --- a/src/test/compile-fail/regions-static-bound.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ll nll -//[nll] compile-flags:-Zborrowck=mir - -fn static_id<'a,'b>(t: &'a ()) -> &'static () - where 'a: 'static { t } -fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () - where 'a: 'b, 'b: 'static { t } -fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { - t //[ll]~ ERROR E0312 - //[nll]~^ WARNING not reporting region error due to nll - //[nll]~| ERROR unsatisfied lifetime constraints -} - -fn error(u: &(), v: &()) { - static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] - //[nll]~^ WARNING not reporting region error due to nll - //[nll]~| ERROR explicit lifetime required in the type of `u` [E0621] - static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] - //[nll]~^ WARNING not reporting region error due to nll - //[nll]~| ERROR explicit lifetime required in the type of `v` [E0621] -} - -fn main() {} diff --git a/src/test/compile-fail/regions-steal-closure.rs b/src/test/compile-fail/regions-steal-closure.rs deleted file mode 100644 index 7ca63b9896f..00000000000 --- a/src/test/compile-fail/regions-steal-closure.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(fn_traits)] - -struct closure_box<'a> { - cl: Box, -} - -fn box_it<'r>(x: Box) -> closure_box<'r> { - closure_box {cl: x} -} - -fn main() { - let mut cl_box = { - let mut i = 3; - box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough - }; - cl_box.cl.call_mut(()); -} diff --git a/src/test/compile-fail/regions-struct-not-wf.rs b/src/test/compile-fail/regions-struct-not-wf.rs deleted file mode 100644 index 9106f1f0ba6..00000000000 --- a/src/test/compile-fail/regions-struct-not-wf.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various examples of structs whose fields are not well-formed. - -// revisions:lexical nll - -#![allow(dead_code)] -#![cfg_attr(nll, feature(nll))] - -struct Ref<'a, T> { - field: &'a T - //[lexical]~^ ERROR the parameter type `T` may not live long enough - //[nll]~^^ ERROR the parameter type `T` may not live long enough -} - -struct RefOk<'a, T:'a> { - field: &'a T -} - -struct RefIndirect<'a, T> { - field: RefOk<'a, T> - //[lexical]~^ ERROR the parameter type `T` may not live long enough - //[nll]~^^ ERROR the parameter type `T` may not live long enough -} - -struct DoubleRef<'a, 'b, T> { - field: &'a &'b T - //[lexical]~^ ERROR reference has a longer lifetime than the data it references - //[nll]~^^ ERROR reference has a longer lifetime than the data it references -} - -fn main() { } diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs deleted file mode 100644 index 9cd08656b62..00000000000 --- a/src/test/compile-fail/regions-trait-1.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct ctxt { v: usize } - -trait get_ctxt { - // Here the `&` is bound in the method definition: - fn get_ctxt(&self) -> &ctxt; -} - -struct has_ctxt<'a> { c: &'a ctxt } - -impl<'a> get_ctxt for has_ctxt<'a> { - - // Here an error occurs because we used `&self` but - // the definition used `&`: - fn get_ctxt(&self) -> &'a ctxt { //~ ERROR method not compatible with trait - self.c - } - -} - -fn get_v(gc: Box) -> usize { - gc.get_ctxt().v -} - -fn main() { - let ctxt = ctxt { v: 22 }; - let hc = has_ctxt { c: &ctxt }; - assert_eq!(get_v(box hc as Box), 22); -} diff --git a/src/test/compile-fail/regions-trait-object-subtyping.rs b/src/test/compile-fail/regions-trait-object-subtyping.rs deleted file mode 100644 index 948fb7e1ef6..00000000000 --- a/src/test/compile-fail/regions-trait-object-subtyping.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Dummy { fn dummy(&self); } - -fn foo1<'a:'b,'b>(x: &'a mut (Dummy+'a)) -> &'b mut (Dummy+'b) { - // Here, we are able to coerce - x -} - -fn foo2<'a:'b,'b>(x: &'b mut (Dummy+'a)) -> &'b mut (Dummy+'b) { - // Here, we are able to coerce - x -} - -fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { - // Without knowing 'a:'b, we can't coerce - x //~ ERROR lifetime bound not satisfied - //~^ ERROR cannot infer an appropriate lifetime -} - -struct Wrapper(T); -fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { - // We can't coerce because it is packed in `Wrapper` - x //~ ERROR mismatched types -} - -fn main() {} diff --git a/src/test/compile-fail/regions-trait-variance.rs b/src/test/compile-fail/regions-trait-variance.rs deleted file mode 100644 index 9ba4ef4e358..00000000000 --- a/src/test/compile-fail/regions-trait-variance.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -// Issue #12470. - -trait X { - fn get_i(&self) -> isize; -} - -struct B { - i: isize -} - -impl X for B { - fn get_i(&self) -> isize { - self.i - } -} - -impl Drop for B { - fn drop(&mut self) { - println!("drop"); - } -} - -struct A<'r> { - p: &'r (X+'r) -} - -fn make_a(p:&X) -> A { - A{p:p} -} - -fn make_make_a<'a>() -> A<'a> { - let b: Box = box B { - i: 1, - }; - let bb: &B = &*b; //~ ERROR `*b` does not live long enough - make_a(bb) -} - -fn main() { - let a = make_make_a(); - println!("{}", a.p.get_i()); -} diff --git a/src/test/compile-fail/regions-undeclared.rs b/src/test/compile-fail/regions-undeclared.rs deleted file mode 100644 index 31908751580..00000000000 --- a/src/test/compile-fail/regions-undeclared.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static c_x: &'blk isize = &22; //~ ERROR use of undeclared lifetime name `'blk` - -enum EnumDecl { - Foo(&'a isize), //~ ERROR use of undeclared lifetime name `'a` - Bar(&'a isize), //~ ERROR use of undeclared lifetime name `'a` -} - -fn fnDecl(x: &'a isize, //~ ERROR use of undeclared lifetime name `'a` - y: &'a isize) //~ ERROR use of undeclared lifetime name `'a` -{} - -fn main() { -} diff --git a/src/test/compile-fail/regions-var-type-out-of-scope.rs b/src/test/compile-fail/regions-var-type-out-of-scope.rs deleted file mode 100644 index 031091c4523..00000000000 --- a/src/test/compile-fail/regions-var-type-out-of-scope.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn id(x: T) -> T { x } - -fn foo(cond: bool) { - // Here we will infer a type that uses the - // region of the if stmt then block: - let mut x; - - if cond { - x = &id(3); //~ ERROR borrowed value does not live long enough - assert_eq!(*x, 3); - } -} - -fn main() {} diff --git a/src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs b/src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs deleted file mode 100644 index 1dfebd54ec3..00000000000 --- a/src/test/compile-fail/regions-variance-contravariant-use-covariant-in-second-position.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a type which is covariant with respect to its region -// parameter yields an error when used in a contravariant way. -// -// Note: see variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -// `S` is contravariant with respect to both parameters. -struct S<'a, 'b> { - f: &'a isize, - g: &'b isize, -} - -fn use_<'short,'long>(c: S<'long, 'short>, - s: &'short isize, - l: &'long isize, - _where:Option<&'short &'long ()>) { - - let _: S<'long, 'short> = c; // OK - let _: S<'short, 'short> = c; // OK - - // Test whether S<_,'short> <: S<_,'long>. Since - // 'short <= 'long, this would be true if the Contravariant type were - // covariant with respect to its parameter 'a. - - let _: S<'long, 'long> = c; //~ ERROR E0623 -} - -fn main() {} diff --git a/src/test/compile-fail/regions-variance-contravariant-use-covariant.rs b/src/test/compile-fail/regions-variance-contravariant-use-covariant.rs deleted file mode 100644 index caf6a86fc0b..00000000000 --- a/src/test/compile-fail/regions-variance-contravariant-use-covariant.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a type which is covariant with respect to its region -// parameter yields an error when used in a contravariant way. -// -// Note: see variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -// This is contravariant with respect to 'a, meaning that -// Contravariant<'long> <: Contravariant<'short> iff -// 'short <= 'long -struct Contravariant<'a> { - f: &'a isize -} - -fn use_<'short,'long>(c: Contravariant<'short>, - s: &'short isize, - l: &'long isize, - _where:Option<&'short &'long ()>) { - - // Test whether Contravariant<'short> <: Contravariant<'long>. Since - // 'short <= 'long, this would be true if the Contravariant type were - // covariant with respect to its parameter 'a. - - let _: Contravariant<'long> = c; //~ ERROR E0623 -} - -fn main() {} diff --git a/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs b/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs deleted file mode 100644 index 60dc3d94a2e..00000000000 --- a/src/test/compile-fail/regions-variance-covariant-use-contravariant.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a type which is covariant with respect to its region -// parameter yields an error when used in a contravariant way. -// -// Note: see variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -// This is covariant with respect to 'a, meaning that -// Covariant<'foo> <: Covariant<'static> because -// 'foo <= 'static -struct Covariant<'a> { - f: extern "Rust" fn(&'a isize) -} - -fn use_<'short,'long>(c: Covariant<'long>, - s: &'short isize, - l: &'long isize, - _where:Option<&'short &'long ()>) { - - // Test whether Covariant<'long> <: Covariant<'short>. Since - // 'short <= 'long, this would be true if the Covariant type were - // contravariant with respect to its parameter 'a. - - let _: Covariant<'short> = c; //~ ERROR E0623 -} - -fn main() {} diff --git a/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs b/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs deleted file mode 100644 index 96478fa5909..00000000000 --- a/src/test/compile-fail/regions-variance-invariant-use-contravariant.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an invariant region parameter used in a contravariant way -// yields an error. -// -// Note: see variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -struct Invariant<'a> { - f: &'a mut &'a isize -} - -fn use_<'short,'long>(c: Invariant<'long>, - s: &'short isize, - l: &'long isize, - _where:Option<&'short &'long ()>) { - - // Test whether Invariant<'long> <: Invariant<'short>. Since - // 'short <= 'long, this would be true if the Invariant type were - // contravariant with respect to its parameter 'a. - - let _: Invariant<'short> = c; //~ ERROR E0623 -} - -fn main() { } diff --git a/src/test/compile-fail/regions-variance-invariant-use-covariant.rs b/src/test/compile-fail/regions-variance-invariant-use-covariant.rs deleted file mode 100644 index bd944a8b52c..00000000000 --- a/src/test/compile-fail/regions-variance-invariant-use-covariant.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a type which is invariant with respect to its region -// parameter used in a covariant way yields an error. -// -// Note: see variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -struct Invariant<'a> { - f: &'a mut &'a isize -} - -fn use_<'b>(c: Invariant<'b>) { - - // For this assignment to be legal, Invariant<'b> <: Invariant<'static>. - // Since 'b <= 'static, this would be true if Invariant were covariant - // with respect to its parameter 'a. - - let _: Invariant<'static> = c; //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/regions-wf-trait-object.rs b/src/test/compile-fail/regions-wf-trait-object.rs deleted file mode 100644 index 39b8482cfa3..00000000000 --- a/src/test/compile-fail/regions-wf-trait-object.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that the explicit lifetime bound (`'b`, in this example) must -// outlive all the superbound from the trait (`'a`, in this example). - -trait TheTrait<'t>: 't { } - -struct Foo<'a,'b> { - x: Box+'b> //~ ERROR E0478 -} - -fn main() { } diff --git a/src/test/compile-fail/reject-specialized-drops-8142.rs b/src/test/compile-fail/reject-specialized-drops-8142.rs deleted file mode 100644 index 1ea956bbd54..00000000000 --- a/src/test/compile-fail/reject-specialized-drops-8142.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue 8142: Test that Drop impls cannot be specialized beyond the -// predicates attached to the struct/enum definition itself. - -trait Bound { fn foo(&self) { } } -struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } -struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } -struct M<'m> { x: &'m i8 } -struct N<'n> { x: &'n i8 } -struct O { x: *const To } -struct P { x: *const Tp } -struct Q { x: *const Tq } -struct R { x: *const Tr } -struct S { x: *const Ts } -struct T<'t,Ts:'t> { x: &'t Ts } -struct U; -struct V { x: *const Tva, y: *const Tvb } -struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } - -impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT - //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl. - fn drop(&mut self) { } } - -impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT - //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl. - fn drop(&mut self) { } } - -impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT - -impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT -//~^ ERROR mismatched types -//~| expected type `N<'n>` -//~| found type `N<'static>` - -impl Drop for O { fn drop(&mut self) { } } // ACCEPT - -impl Drop for P { fn drop(&mut self) { } } // REJECT -//~^ ERROR Implementations of Drop cannot be specialized - -impl Drop for Q { fn drop(&mut self) { } } // REJECT -//~^ ERROR The requirement `Adds_bnd: Bound` is added only by the Drop impl. - -impl<'rbnd,Adds_rbnd:'rbnd> Drop for R { fn drop(&mut self) { } } // REJECT -//~^ ERROR The requirement `Adds_rbnd : 'rbnd` is added only by the Drop impl. - -impl Drop for S { fn drop(&mut self) { } } // ACCEPT - -impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT - -impl Drop for U { fn drop(&mut self) { } } // ACCEPT - -impl Drop for V { fn drop(&mut self) { } } // REJECT -//~^ ERROR Implementations of Drop cannot be specialized - -impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT -//~^ ERROR cannot infer an appropriate lifetime - -pub fn main() { } diff --git a/src/test/compile-fail/repeat-to-run-dtor-twice.rs b/src/test/compile-fail/repeat-to-run-dtor-twice.rs deleted file mode 100644 index 88441594a7e..00000000000 --- a/src/test/compile-fail/repeat-to-run-dtor-twice.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that one can't run a destructor twice with the repeated vector -// literal syntax. - -struct Foo { - x: isize, - -} - -impl Drop for Foo { - fn drop(&mut self) { - println!("Goodbye!"); - } -} - -fn main() { - let a = Foo { x: 3 }; - let _ = [ a; 5 ]; - //~^ ERROR `Foo: std::marker::Copy` is not satisfied -} diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs deleted file mode 100644 index a716f3e29d4..00000000000 --- a/src/test/compile-fail/repeat_count.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #3645 - -fn main() { - let n = 1; - let a = [0; n]; - //~^ ERROR attempt to use a non-constant value in a constant [E0435] - let b = [0; ()]; - //~^ ERROR mismatched types - //~| expected type `usize` - //~| found type `()` - //~| expected usize, found () - let c = [0; true]; - //~^ ERROR mismatched types - //~| expected usize, found bool - let d = [0; 0.5]; - //~^ ERROR mismatched types - //~| expected type `usize` - //~| found type `{float}` - //~| expected usize, found floating-point variable - let e = [0; "foo"]; - //~^ ERROR mismatched types - //~| expected type `usize` - //~| found type `&'static str` - //~| expected usize, found reference - let f = [0; -4_isize]; - //~^ ERROR mismatched types - //~| expected usize, found isize - let f = [0_usize; -1_isize]; - //~^ ERROR mismatched types - //~| expected usize, found isize - struct G { - g: (), - } - let g = [0; G { g: () }]; - //~^ ERROR mismatched types - //~| expected type `usize` - //~| found type `main::G` - //~| expected usize, found struct `main::G` -} diff --git a/src/test/compile-fail/repr-align.rs b/src/test/compile-fail/repr-align.rs deleted file mode 100644 index 9b0408de2a4..00000000000 --- a/src/test/compile-fail/repr-align.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![allow(dead_code)] - -#[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer -struct A(i32); - -#[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two -struct B(i32); - -#[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29 -struct C(i32); - -#[repr(align(536870912))] // ok: this is the largest accepted alignment -struct D(i32); - -fn main() {} diff --git a/src/test/compile-fail/repr-packed-contains-align.rs b/src/test/compile-fail/repr-packed-contains-align.rs deleted file mode 100644 index 27890333a51..00000000000 --- a/src/test/compile-fail/repr-packed-contains-align.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![feature(untagged_unions)] -#![allow(dead_code)] - -#[repr(align(16))] -struct SA(i32); - -struct SB(SA); - -#[repr(align(16))] -union UA { - i: i32 -} - -union UB { - a: UA -} - -#[repr(packed)] -struct SC(SA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - -#[repr(packed)] -struct SD(SB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - -#[repr(packed)] -struct SE(UA); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - -#[repr(packed)] -struct SF(UB); //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - -#[repr(packed)] -union UC { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - a: UA -} - -#[repr(packed)] -union UD { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - n: UB -} - -#[repr(packed)] -union UE { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - a: SA -} - -#[repr(packed)] -union UF { //~ ERROR: packed type cannot transitively contain a `[repr(align)]` type - n: SB -} - -fn main() {} diff --git a/src/test/compile-fail/repr-transparent-other-items.rs b/src/test/compile-fail/repr-transparent-other-items.rs deleted file mode 100644 index 685d62dc3a9..00000000000 --- a/src/test/compile-fail/repr-transparent-other-items.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// See also repr-transparent.rs - -#[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum -enum Void {} //~| ERROR should be applied to struct - -#[repr(transparent)] //~ ERROR should be applied to struct -enum FieldlessEnum { - Foo, - Bar, -} - -#[repr(transparent)] //~ ERROR should be applied to struct -enum Enum { - Foo(String), - Bar(u32), -} - -#[repr(transparent)] //~ ERROR should be applied to struct -union Foo { - u: u32, - s: i32 -} - -#[repr(transparent)] //~ ERROR should be applied to struct -fn cant_repr_this() {} - -#[repr(transparent)] //~ ERROR should be applied to struct -static CANT_REPR_THIS: u32 = 0; diff --git a/src/test/compile-fail/repr-transparent-other-reprs.rs b/src/test/compile-fail/repr-transparent-other-reprs.rs deleted file mode 100644 index a391c0ae1f8..00000000000 --- a/src/test/compile-fail/repr-transparent-other-reprs.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_align, attr_literals)] - -// See also repr-transparent.rs - -#[repr(transparent, C)] //~ ERROR cannot have other repr -struct TransparentPlusC { - ptr: *const u8 -} - -#[repr(transparent, packed)] //~ ERROR cannot have other repr -struct TransparentPlusPacked(*const u8); - -#[repr(transparent, align(2))] //~ ERROR cannot have other repr -struct TransparentPlusAlign(u8); - -#[repr(transparent)] //~ ERROR cannot have other repr -#[repr(C)] -struct SeparateAttributes(*mut u8); diff --git a/src/test/compile-fail/repr-transparent.rs b/src/test/compile-fail/repr-transparent.rs deleted file mode 100644 index 4d8ec4cdb40..00000000000 --- a/src/test/compile-fail/repr-transparent.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This file tests repr(transparent)-related errors reported during typeck. Other errors -// that are reported earlier and therefore preempt these are tested in: -// - repr-transparent-other-reprs.rs -// - repr-transparent-other-items.rs - -#![feature(repr_align, attr_literals)] - -use std::marker::PhantomData; - -#[repr(transparent)] -struct NoFields; //~ ERROR needs exactly one non-zero-sized field - -#[repr(transparent)] -struct ContainsOnlyZst(()); //~ ERROR needs exactly one non-zero-sized field - -#[repr(transparent)] -struct ContainsOnlyZstArray([bool; 0]); //~ ERROR needs exactly one non-zero-sized field - -#[repr(transparent)] -struct ContainsMultipleZst(PhantomData<*const i32>, NoFields); -//~^ ERROR needs exactly one non-zero-sized field - -#[repr(transparent)] -struct MultipleNonZst(u8, u8); //~ ERROR needs exactly one non-zero-sized field - -trait Mirror { type It: ?Sized; } -impl Mirror for T { type It = Self; } - -#[repr(transparent)] -pub struct StructWithProjection(f32, ::It); -//~^ ERROR needs exactly one non-zero-sized field - -#[repr(transparent)] -struct NontrivialAlignZst(u32, [u16; 0]); //~ ERROR alignment larger than 1 - -#[repr(align(32))] -struct ZstAlign32(PhantomData); - -#[repr(transparent)] -struct GenericAlign(ZstAlign32, u32); //~ ERROR alignment larger than 1 diff --git a/src/test/compile-fail/required-lang-item.rs b/src/test/compile-fail/required-lang-item.rs deleted file mode 100644 index ce40702b3dc..00000000000 --- a/src/test/compile-fail/required-lang-item.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(lang_items, no_core)] -#![no_core] - -#[lang="copy"] pub trait Copy { } -#[lang="sized"] pub trait Sized { } - -// error-pattern:requires `start` lang_item - -fn main() {} diff --git a/src/test/compile-fail/reserved-attr-on-macro.rs b/src/test/compile-fail/reserved-attr-on-macro.rs deleted file mode 100644 index db8f82a70e1..00000000000 --- a/src/test/compile-fail/reserved-attr-on-macro.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved -macro_rules! foo { - () => (()); -} - -fn main() { - foo!(); -} diff --git a/src/test/compile-fail/reserved-become.rs b/src/test/compile-fail/reserved-become.rs deleted file mode 100644 index bcda61e363d..00000000000 --- a/src/test/compile-fail/reserved-become.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let become = 0; - //~^ ERROR expected pattern, found reserved keyword `become` -} diff --git a/src/test/compile-fail/resolve-bad-import-prefix.rs b/src/test/compile-fail/resolve-bad-import-prefix.rs deleted file mode 100644 index 370782fc7d9..00000000000 --- a/src/test/compile-fail/resolve-bad-import-prefix.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod m {} -enum E {} -struct S; -trait Tr {} - -use {}; // OK -use ::{}; // OK -use m::{}; // OK -use E::{}; // OK -use S::{}; //~ ERROR expected module or enum, found struct `S` -use Tr::{}; //~ ERROR expected module or enum, found trait `Tr` -use Nonexistent::{}; //~ ERROR cannot find module or enum `Nonexistent` in the crate root - -fn main () {} diff --git a/src/test/compile-fail/resolve-bad-visibility.rs b/src/test/compile-fail/resolve-bad-visibility.rs deleted file mode 100644 index 420a45a2147..00000000000 --- a/src/test/compile-fail/resolve-bad-visibility.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum E {} -trait Tr {} - -pub(in E) struct S; //~ ERROR expected module, found enum `E` -pub(in Tr) struct Z; //~ ERROR expected module, found trait `Tr` -pub(in std::vec) struct F; //~ ERROR visibilities can only be restricted to ancestor modules -pub(in nonexistent) struct G; //~ ERROR cannot find module `nonexistent` in the crate root -pub(in too_soon) struct H; //~ ERROR cannot find module `too_soon` in the crate root - -// Visibilities are resolved eagerly without waiting for modules becoming fully populated. -// Visibilities can only use ancestor modules legally which are always available in time, -// so the worst thing that can happen due to eager resolution is a suboptimal error message. -mod too_soon {} - -fn main () {} diff --git a/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs deleted file mode 100644 index 6a04a2c3704..00000000000 --- a/src/test/compile-fail/resolve-conflict-extern-crate-vs-extern-crate.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[allow(unused_extern_crates)] -extern crate std; -//~^ ERROR the name `std` is defined multiple times - -fn main(){} diff --git a/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs deleted file mode 100644 index 91cf1d35954..00000000000 --- a/src/test/compile-fail/resolve-conflict-import-vs-extern-crate.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::slice as std; //~ ERROR the name `std` is defined multiple times - -fn main() { -} diff --git a/src/test/compile-fail/resolve-conflict-import-vs-import.rs b/src/test/compile-fail/resolve-conflict-import-vs-import.rs deleted file mode 100644 index 8db9023310e..00000000000 --- a/src/test/compile-fail/resolve-conflict-import-vs-import.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem::transmute; -use std::mem::transmute; -//~^ ERROR the name `transmute` is defined multiple times - -fn main() { -} diff --git a/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs b/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs deleted file mode 100644 index b50a60d39c8..00000000000 --- a/src/test/compile-fail/resolve-conflict-item-vs-extern-crate.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn std() {} -mod std {} //~ ERROR the name `std` is defined multiple times - -fn main() { -} diff --git a/src/test/compile-fail/resolve-conflict-type-vs-import.rs b/src/test/compile-fail/resolve-conflict-type-vs-import.rs deleted file mode 100644 index bbb6ee622b1..00000000000 --- a/src/test/compile-fail/resolve-conflict-type-vs-import.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::slice::Iter; - -struct Iter; -//~^ ERROR the name `Iter` is defined multiple times - -fn main() { -} diff --git a/src/test/compile-fail/resolve-inconsistent-binding-mode.rs b/src/test/compile-fail/resolve-inconsistent-binding-mode.rs deleted file mode 100644 index 63d33a9e5fa..00000000000 --- a/src/test/compile-fail/resolve-inconsistent-binding-mode.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum opts { - a(isize), b(isize), c(isize) -} - -fn matcher1(x: opts) { - match x { - opts::a(ref i) | opts::b(i) => {} - //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm - //~^^ ERROR mismatched types - opts::c(_) => {} - } -} - -fn matcher2(x: opts) { - match x { - opts::a(ref i) | opts::b(i) => {} - //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm - //~^^ ERROR mismatched types - opts::c(_) => {} - } -} - -fn matcher4(x: opts) { - match x { - opts::a(ref mut i) | opts::b(ref i) => {} - //~^ ERROR variable `i` is bound in inconsistent ways within the same match arm - //~^^ ERROR mismatched types - opts::c(_) => {} - } -} - - -fn matcher5(x: opts) { - match x { - opts::a(ref i) | opts::b(ref i) => {} - opts::c(_) => {} - } -} - -fn main() {} diff --git a/src/test/compile-fail/resolve-label.rs b/src/test/compile-fail/resolve-label.rs deleted file mode 100644 index 6695e972f33..00000000000 --- a/src/test/compile-fail/resolve-label.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() { - 'l: loop { - fn g() { - loop { - break 'l; //~ ERROR use of undeclared label - } - } - } - - loop { 'w: while break 'w { } } -} - -fn main() {} diff --git a/src/test/compile-fail/resolve-primitive-fallback.rs b/src/test/compile-fail/resolve-primitive-fallback.rs deleted file mode 100644 index c1584b0bdcd..00000000000 --- a/src/test/compile-fail/resolve-primitive-fallback.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - // Make sure primitive type fallback doesn't work in value namespace - std::mem::size_of(u16); - //~^ ERROR expected value, found builtin type `u16` - //~| ERROR this function takes 0 parameters but 1 parameter was supplied - - // Make sure primitive type fallback doesn't work with global paths - let _: ::u8; - //~^ ERROR cannot find type `u8` in the crate root -} diff --git a/src/test/compile-fail/resolve-self-in-impl-2.rs b/src/test/compile-fail/resolve-self-in-impl-2.rs deleted file mode 100644 index adc208a0202..00000000000 --- a/src/test/compile-fail/resolve-self-in-impl-2.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S(T); -trait Tr {} - -impl Self for S {} //~ ERROR expected trait, found self type `Self` -impl Self::N for S {} //~ ERROR cannot find trait `N` in `Self` - -fn main() {} diff --git a/src/test/compile-fail/resolve-self-in-impl.rs b/src/test/compile-fail/resolve-self-in-impl.rs deleted file mode 100644 index 2a894c57b8d..00000000000 --- a/src/test/compile-fail/resolve-self-in-impl.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(associated_type_defaults)] - -struct S(T); -trait Tr { - type A = (); -} - -impl Tr for S {} // OK -impl> Tr for S {} // OK -impl Tr for S where Self: Copy {} // OK -impl Tr for S where S: Copy {} // OK -impl Tr for S where Self::A: Copy {} // OK - -impl Tr for Self {} //~ ERROR cycle detected -impl Tr for S {} //~ ERROR cycle detected -impl Self {} //~ ERROR cycle detected -impl S {} //~ ERROR cycle detected -impl Tr for S {} //~ ERROR cycle detected - -fn main() {} diff --git a/src/test/compile-fail/resolve-type-param-in-item-in-trait.rs b/src/test/compile-fail/resolve-type-param-in-item-in-trait.rs deleted file mode 100644 index a1572b85666..00000000000 --- a/src/test/compile-fail/resolve-type-param-in-item-in-trait.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #14603: Check for references to type parameters from the -// outer scope (in this case, the trait) used on items in an inner -// scope (in this case, the enum). - -trait TraitA { - fn outer(&self) { - enum Foo { - Variance(A) - //~^ ERROR can't use type parameters from outer function - } - } -} - -trait TraitB { - fn outer(&self) { - struct Foo(A); - //~^ ERROR can't use type parameters from outer function - } -} - -trait TraitC { - fn outer(&self) { - struct Foo { a: A } - //~^ ERROR can't use type parameters from outer function - } -} - -trait TraitD { - fn outer(&self) { - fn foo(a: A) { } - //~^ ERROR can't use type parameters from outer function - } -} - -fn main() { } diff --git a/src/test/compile-fail/resolve-unknown-trait.rs b/src/test/compile-fail/resolve-unknown-trait.rs deleted file mode 100644 index 9432e727fa5..00000000000 --- a/src/test/compile-fail/resolve-unknown-trait.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -trait NewTrait : SomeNonExistentTrait {} -//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope - -impl SomeNonExistentTrait for isize {} -//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope - -fn f() {} -//~^ ERROR cannot find trait `SomeNonExistentTrait` in this scope diff --git a/src/test/compile-fail/resolve-variant-assoc-item.rs b/src/test/compile-fail/resolve-variant-assoc-item.rs deleted file mode 100644 index 869eed5a8d7..00000000000 --- a/src/test/compile-fail/resolve-variant-assoc-item.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum E { V } -use E::V; - -fn main() { - E::V::associated_item; //~ ERROR failed to resolve. Not a module `V` - V::associated_item; //~ ERROR failed to resolve. Not a module `V` -} diff --git a/src/test/compile-fail/resolve_self_super_hint.rs b/src/test/compile-fail/resolve_self_super_hint.rs deleted file mode 100644 index a89fd802baf..00000000000 --- a/src/test/compile-fail/resolve_self_super_hint.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(alloc)] -#![allow(unused_extern_crates)] - -mod a { - extern crate alloc; - use alloc::HashMap; - //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `self::alloc`? - mod b { - use alloc::HashMap; - //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `a::alloc`? - mod c { - use alloc::HashMap; - //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `a::alloc`? - mod d { - use alloc::HashMap; - //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `a::alloc`? - } - } - } -} diff --git a/src/test/compile-fail/ret-non-nil.rs b/src/test/compile-fail/ret-non-nil.rs deleted file mode 100644 index 6be98fbd827..00000000000 --- a/src/test/compile-fail/ret-non-nil.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: `return;` in a function whose return type is not `()` - -fn f() { return; } - -fn g() -> isize { return; } - -fn main() { f(); g(); } diff --git a/src/test/compile-fail/retslot-cast.rs b/src/test/compile-fail/retslot-cast.rs deleted file mode 100644 index c5e26a26744..00000000000 --- a/src/test/compile-fail/retslot-cast.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(warnings)] - -pub fn fail(x: Option<&(Iterator+Send)>) - -> Option<&Iterator> { - // This call used to trigger an LLVM assertion because the return - // slot had type "Option<&Iterator>"* instead of - // "Option<&(Iterator+Send)>"* -- but this now yields a - // compilation error and I'm not sure how to create a comparable - // test. To ensure that this PARTICULAR failure doesn't occur - // again, though, I've left this test here, so if this ever starts - // to compile again, we can adjust the test appropriately (clearly - // it should never ICE...). -nmatsakis - inner(x) //~ ERROR mismatched types -} - -pub fn inner(x: Option<&(Iterator+Send)>) - -> Option<&(Iterator+Send)> { - x -} - -#[rustc_error] -fn main() {} diff --git a/src/test/compile-fail/return-from-diverging.rs b/src/test/compile-fail/return-from-diverging.rs deleted file mode 100644 index cec59faa918..00000000000 --- a/src/test/compile-fail/return-from-diverging.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that return another type in place of ! raises a type mismatch. - -fn fail() -> ! { - return "wow"; //~ ERROR mismatched types -} - -fn main() { -} - diff --git a/src/test/compile-fail/return-unit-from-diverging.rs b/src/test/compile-fail/return-unit-from-diverging.rs deleted file mode 100644 index ae2a325b24a..00000000000 --- a/src/test/compile-fail/return-unit-from-diverging.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we get the usual error that we'd get for any other return type and not something about -// diverging functions not being able to return. - -fn fail() -> ! { - return; //~ ERROR in a function whose return type is not -} - -fn main() { -} - diff --git a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-i32.rs b/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-i32.rs deleted file mode 100644 index 49f5621de1b..00000000000 --- a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-main-i32.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() -> i32 { -//~^ ERROR `main` has invalid return type `i32` -//~| NOTE `main` can only return types that implement `std::process::Termination` -//~| HELP consider using `()`, or a `Result` - 0 -} diff --git a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs b/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs deleted file mode 100644 index b5f5472b492..00000000000 --- a/src/test/compile-fail/rfc-1937-termination-trait/termination-trait-not-satisfied.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct ReturnType {} - -fn main() -> ReturnType { //~ ERROR `main` has invalid return type `ReturnType` - ReturnType {} -} diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/enums.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/enums.rs deleted file mode 100644 index 12d1bf9ea91..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/enums.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(non_exhaustive)] - -#[non_exhaustive] -pub enum NonExhaustiveEnum { - Unit, - Tuple(u32), - Struct { field: u32 } -} diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/structs.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/structs.rs deleted file mode 100644 index 4d083cc5315..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/structs.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(non_exhaustive)] - -#[non_exhaustive] -pub struct NormalStruct { - pub first_field: u16, - pub second_field: u16, -} - -#[non_exhaustive] -pub struct UnitStruct; - -#[non_exhaustive] -pub struct TupleStruct(pub u16, pub u16); - -#[derive(Debug)] -#[non_exhaustive] -pub struct FunctionalRecord { - pub first_field: u16, - pub second_field: u16, - pub third_field: bool -} - -impl Default for FunctionalRecord { - fn default() -> FunctionalRecord { - FunctionalRecord { first_field: 640, second_field: 480, third_field: false } - } -} diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/variants.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/variants.rs deleted file mode 100644 index d04c1073ad9..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/auxiliary/variants.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(non_exhaustive)] - -pub enum NonExhaustiveVariants { - #[non_exhaustive] Unit, - #[non_exhaustive] Tuple(u32), - #[non_exhaustive] Struct { field: u32 } -} diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/enum.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/enum.rs deleted file mode 100644 index 0c19210e4a0..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/enum.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:enums.rs -extern crate enums; - -use enums::NonExhaustiveEnum; - -fn main() { - let enum_unit = NonExhaustiveEnum::Unit; - - match enum_unit { - //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] - NonExhaustiveEnum::Unit => "first", - NonExhaustiveEnum::Tuple(_) => "second", - NonExhaustiveEnum::Struct { .. } => "third" - }; -} diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/invalid-attribute.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/invalid-attribute.rs deleted file mode 100644 index df4fe1e77e9..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/invalid-attribute.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(non_exhaustive)] - -#[non_exhaustive(anything)] -//~^ ERROR attribute should be empty [E0702] -struct Foo; - -#[non_exhaustive] -//~^ ERROR attribute can only be applied to a struct or enum [E0701] -trait Bar { } - -#[non_exhaustive] -//~^ ERROR attribute can only be applied to a struct or enum [E0701] -union Baz { - f1: u16, - f2: u16 -} - -fn main() { } diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/structs.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/structs.rs deleted file mode 100644 index 74c9c7c61ac..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/structs.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:structs.rs -extern crate structs; - -use structs::{NormalStruct, UnitStruct, TupleStruct, FunctionalRecord}; - -fn main() { - let fr = FunctionalRecord { - //~^ ERROR cannot create non-exhaustive struct - first_field: 1920, - second_field: 1080, - ..FunctionalRecord::default() - }; - - let ns = NormalStruct { first_field: 640, second_field: 480 }; - //~^ ERROR cannot create non-exhaustive struct - - let NormalStruct { first_field, second_field } = ns; - //~^ ERROR `..` required with struct marked as non-exhaustive - - let ts = TupleStruct(640, 480); - //~^ ERROR expected function, found struct `TupleStruct` [E0423] - - let ts_explicit = structs::TupleStruct(640, 480); - //~^ ERROR tuple struct `TupleStruct` is private [E0603] - - let TupleStruct { 0: first_field, 1: second_field } = ts; - //~^ ERROR `..` required with struct marked as non-exhaustive - - let us = UnitStruct; - //~^ ERROR expected value, found struct `UnitStruct` [E0423] - - let us_explicit = structs::UnitStruct; - //~^ ERROR unit struct `UnitStruct` is private [E0603] - - let UnitStruct { } = us; - //~^ ERROR `..` required with struct marked as non-exhaustive -} diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/variants.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/variants.rs deleted file mode 100644 index d1b65ac1f3e..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/variants.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:variants.rs -extern crate variants; - -use variants::NonExhaustiveVariants; - -/* - * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for - * variants. See issue #44109 and PR 45394. - */ -// ignore-test - -fn main() { - let variant_struct = NonExhaustiveVariants::Struct { field: 640 }; - //~^ ERROR cannot create non-exhaustive variant - - let variant_tuple = NonExhaustiveVariants::Tuple { 0: 640 }; - //~^ ERROR cannot create non-exhaustive variant - - match variant_struct { - NonExhaustiveVariants::Unit => "", - NonExhaustiveVariants::Tuple(fe_tpl) => "", - //~^ ERROR `..` required with variant marked as non-exhaustive - NonExhaustiveVariants::Struct { field } => "" - //~^ ERROR `..` required with variant marked as non-exhaustive - }; -} diff --git a/src/test/compile-fail/rfc-2008-non-exhaustive/variants_create.rs b/src/test/compile-fail/rfc-2008-non-exhaustive/variants_create.rs deleted file mode 100644 index f4e4b1bb84b..00000000000 --- a/src/test/compile-fail/rfc-2008-non-exhaustive/variants_create.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(non_exhaustive)] - -/* - * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for - * variants. See issue #44109 and PR 45394. - */ - -pub enum NonExhaustiveVariants { - #[non_exhaustive] Unit, - //~^ ERROR #[non_exhaustive] is not yet supported on variants - #[non_exhaustive] Tuple(u32), - //~^ ERROR #[non_exhaustive] is not yet supported on variants - #[non_exhaustive] Struct { field: u32 } - //~^ ERROR #[non_exhaustive] is not yet supported on variants -} - -fn main() { } diff --git a/src/test/compile-fail/rfc-2126-crate-paths/crate-path-non-absolute.rs b/src/test/compile-fail/rfc-2126-crate-paths/crate-path-non-absolute.rs deleted file mode 100644 index 65f11c063ed..00000000000 --- a/src/test/compile-fail/rfc-2126-crate-paths/crate-path-non-absolute.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(crate_in_paths)] - -struct S; - -pub mod m { - fn f() { - let s = ::m::crate::S; //~ ERROR failed to resolve - let s2 = crate::S; // no error - } -} - -fn main() {} diff --git a/src/test/compile-fail/rfc-2126-crate-paths/keyword-crate-as-identifier.rs b/src/test/compile-fail/rfc-2126-crate-paths/keyword-crate-as-identifier.rs deleted file mode 100644 index bdd03be4356..00000000000 --- a/src/test/compile-fail/rfc-2126-crate-paths/keyword-crate-as-identifier.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(crate_in_paths)] - -fn main() { - let crate = 0; //~ ERROR failed to resolve. `crate` in paths can only be used in start position -} diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs deleted file mode 100644 index c3da4a51872..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Debug)] -pub struct S; - -#[derive(Debug)] -pub struct Z; diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs deleted file mode 100644 index 826bf675bd6..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -use xcrate::S; //~ ERROR can't find crate for `xcrate` - -fn main() {} diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs deleted file mode 100644 index 053bf92f4d1..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-2.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -fn main() { - let s = ::xcrate::S; //~ ERROR can't find crate for `xcrate` -} diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs deleted file mode 100644 index 1b9e5a75e83..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/non-existent-3.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -use ycrate; //~ ERROR can't find crate for `ycrate` - -fn main() {} diff --git a/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs b/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs deleted file mode 100644 index 69fc4b4f7f8..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-absolute-paths/single-segment.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:xcrate.rs -// edition:2018 - -use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` -use *; //~ ERROR cannot glob-import all possible crates - -fn main() { - let s = ::xcrate; //~ ERROR expected value, found module `xcrate` - //~^ NOTE not a value -} diff --git a/src/test/compile-fail/rfc-2126-extern-in-paths/auxiliary/xcrate.rs b/src/test/compile-fail/rfc-2126-extern-in-paths/auxiliary/xcrate.rs deleted file mode 100644 index c3da4a51872..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-in-paths/auxiliary/xcrate.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Debug)] -pub struct S; - -#[derive(Debug)] -pub struct Z; diff --git a/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-1.rs b/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-1.rs deleted file mode 100644 index 7eba02ed444..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(extern_in_paths)] - -use extern::xcrate::S; //~ ERROR can't find crate for `xcrate` - -fn main() {} diff --git a/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-2.rs b/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-2.rs deleted file mode 100644 index 4d09a05253e..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-2.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(extern_in_paths)] - -fn main() { - let s = extern::xcrate::S; //~ ERROR can't find crate for `xcrate` -} diff --git a/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-3.rs b/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-3.rs deleted file mode 100644 index 402d294b2e3..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-in-paths/non-existent-3.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(extern_in_paths)] - -use extern::ycrate; //~ ERROR can't find crate for `ycrate` - -fn main() {} diff --git a/src/test/compile-fail/rfc-2126-extern-in-paths/single-segment.rs b/src/test/compile-fail/rfc-2126-extern-in-paths/single-segment.rs deleted file mode 100644 index 017844a0252..00000000000 --- a/src/test/compile-fail/rfc-2126-extern-in-paths/single-segment.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:xcrate.rs - -#![feature(extern_in_paths)] - -use extern; //~ ERROR unresolved import `extern` - //~^ NOTE no `extern` in the root -use extern::*; //~ ERROR cannot glob-import all possible crates - -fn main() { - let s = extern::xcrate; //~ ERROR expected value, found module `extern::xcrate` - //~^ NOTE not a value -} diff --git a/src/test/compile-fail/rfc1445/feature-gate.rs b/src/test/compile-fail/rfc1445/feature-gate.rs deleted file mode 100644 index f729220eabb..00000000000 --- a/src/test/compile-fail/rfc1445/feature-gate.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that structural match is only permitted with a feature gate, -// and that if a feature gate is supplied, it permits the type to be -// used in a match. - -// revisions: with_gate no_gate - -// gate-test-structural_match - -#![allow(unused)] -#![feature(rustc_attrs)] -#![cfg_attr(with_gate, feature(structural_match))] - -#[structural_match] //[no_gate]~ ERROR semantics of constant patterns is not yet settled -struct Foo { - x: u32 -} - -const FOO: Foo = Foo { x: 0 }; - -#[rustc_error] -fn main() { //[with_gate]~ ERROR compilation successful - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} diff --git a/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs b/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs deleted file mode 100644 index ca9af78dd99..00000000000 --- a/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::f32; - -#[derive(PartialEq)] -struct Foo { - x: u32 -} - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => { } - } - - let x = 0.0; - match x { - f32::INFINITY => { } - //~^ WARNING floating-point types cannot be used in patterns - //~| WARNING will become a hard error in a future release - _ => { } - } -} diff --git a/src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs b/src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs deleted file mode 100644 index e02f9153e7e..00000000000 --- a/src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Eq)] -struct Foo { - x: u32 -} - -impl PartialEq for Foo { - fn eq(&self, _: &Foo) -> bool { - false // ha ha sucker! - } -} - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` - _ => { } - } -} diff --git a/src/test/compile-fail/rfc1623.rs b/src/test/compile-fail/rfc1623.rs deleted file mode 100644 index 579fa378a1c..00000000000 --- a/src/test/compile-fail/rfc1623.rs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![allow(dead_code)] - -fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { - a -} - -// the boundaries of elision -static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = -//~^ ERROR missing lifetime specifier [E0106] - &(non_elidable as fn(&u8, &u8) -> &u8); - //~^ ERROR missing lifetime specifier [E0106] - -struct SomeStruct<'x, 'y, 'z: 'x> { - foo: &'x Foo<'z>, - bar: &'x Bar<'z>, - f: &'y for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>, -} - -fn id(t: T) -> T { - t -} - -static SOME_STRUCT: &SomeStruct = SomeStruct { - foo: &Foo { bools: &[false, true] }, - bar: &Bar { bools: &[true, true] }, - f: &id, -}; - -// very simple test for a 'static static with default lifetime -static STATIC_STR: &'static str = "&'static str"; -const CONST_STR: &'static str = "&'static str"; - -// this should be the same as without default: -static EXPLICIT_STATIC_STR: &'static str = "&'static str"; -const EXPLICIT_CONST_STR: &'static str = "&'static str"; - -// a function that elides to an unbound lifetime for both in- and output -fn id_u8_slice(arg: &[u8]) -> &[u8] { - arg -} - -// one with a function, argument elided -static STATIC_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); -const CONST_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); - -// this should be the same as without elision -static STATIC_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); - -// another function that elides, each to a different unbound lifetime -fn multi_args(a: &u8, b: &u8, c: &u8) {} - -static STATIC_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); -const CONST_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); - -struct Foo<'a> { - bools: &'a [bool], -} - -static STATIC_FOO: Foo<'static> = Foo { bools: &[true, false] }; -const CONST_FOO: Foo<'static> = Foo { bools: &[true, false] }; - -type Bar<'a> = Foo<'a>; - -static STATIC_BAR: Bar<'static> = Bar { bools: &[true, false] }; -const CONST_BAR: Bar<'static> = Bar { bools: &[true, false] }; - -type Baz<'a> = fn(&'a [u8]) -> Option; - -fn baz(e: &[u8]) -> Option { - e.first().map(|x| *x) -} - -static STATIC_BAZ: &'static Baz<'static> = &(baz as Baz); -const CONST_BAZ: &'static Baz<'static> = &(baz as Baz); - -static BYTES: &'static [u8] = &[1, 2, 3]; - -fn main() { - let x = &[1u8, 2, 3]; - let y = x; - - // this works, so lifetime < `'static` is valid - assert_eq!(Some(1), STATIC_BAZ(y)); - assert_eq!(Some(1), CONST_BAZ(y)); - - let y = &[1u8, 2, 3]; - - STATIC_BAZ(BYTES); // BYTES has static lifetime - CONST_BAZ(y); // interestingly this does not get reported -} diff --git a/src/test/compile-fail/rfc1717/missing-link-attr.rs b/src/test/compile-fail/rfc1717/missing-link-attr.rs deleted file mode 100644 index 810efdedfd6..00000000000 --- a/src/test/compile-fail/rfc1717/missing-link-attr.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -l foo:bar -// error-pattern: renaming of the library `foo` was specified - -#![crate_type = "lib"] diff --git a/src/test/compile-fail/rfc1717/multiple-renames.rs b/src/test/compile-fail/rfc1717/multiple-renames.rs deleted file mode 100644 index e75c1a14b24..00000000000 --- a/src/test/compile-fail/rfc1717/multiple-renames.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -l foo:bar -l foo:baz -// error-pattern: multiple renamings were specified for library - -#![crate_type = "lib"] - -#[link(name = "foo")] -extern "C" {} diff --git a/src/test/compile-fail/rfc1717/rename-to-empty.rs b/src/test/compile-fail/rfc1717/rename-to-empty.rs deleted file mode 100644 index ab8c238bc27..00000000000 --- a/src/test/compile-fail/rfc1717/rename-to-empty.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -l foo: -// error-pattern: an empty renaming target was specified for library - -#![crate_type = "lib"] - -#[link(name = "foo")] -extern "C" {} diff --git a/src/test/compile-fail/rmeta-lib-pass.rs b/src/test/compile-fail/rmeta-lib-pass.rs deleted file mode 100644 index 2df6a659724..00000000000 --- a/src/test/compile-fail/rmeta-lib-pass.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --emit=metadata -// aux-build:rmeta_rlib.rs -// no-prefer-dynamic -// compile-pass - -// Check that building a metadata crate works with a dependent, rlib crate. -// This is a cfail test since there is no executable to run. - -extern crate rmeta_rlib; -use rmeta_rlib::Foo; - -pub fn main() { - let _ = Foo { field: 42 }; -} diff --git a/src/test/compile-fail/rmeta-pass.rs b/src/test/compile-fail/rmeta-pass.rs deleted file mode 100644 index 6ee914c5e5b..00000000000 --- a/src/test/compile-fail/rmeta-pass.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --emit=metadata -// aux-build:rmeta_meta.rs -// no-prefer-dynamic -// compile-pass - -// Check that building a metadata crate works with a dependent, metadata-only -// crate. -// This is a cfail test since there is no executable to run. - -extern crate rmeta_meta; -use rmeta_meta::Foo; - -pub fn main() { - let _ = Foo { field: 42 }; -} diff --git a/src/test/compile-fail/rmeta-priv-warn.rs b/src/test/compile-fail/rmeta-priv-warn.rs deleted file mode 100644 index bcf869c9432..00000000000 --- a/src/test/compile-fail/rmeta-priv-warn.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --emit=metadata -// no-prefer-dynamic -// compile-pass - -#[deny(warnings)] - -// Test that we don't get warnings for non-pub main when only emitting metadata. -// (#38273) - -fn main() { -} diff --git a/src/test/compile-fail/rmeta.rs b/src/test/compile-fail/rmeta.rs deleted file mode 100644 index 962fe9f66aa..00000000000 --- a/src/test/compile-fail/rmeta.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: --emit=metadata - -// Check that building a metadata crate finds an error. - -fn main() { - let _ = Foo; //~ ERROR cannot find value `Foo` in this scope -} diff --git a/src/test/compile-fail/rmeta_lib.rs b/src/test/compile-fail/rmeta_lib.rs deleted file mode 100644 index a61ff05e8c8..00000000000 --- a/src/test/compile-fail/rmeta_lib.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:rmeta_meta.rs -// no-prefer-dynamic -// error-pattern: crate `rmeta_meta` required to be available in rlib format, but was not found - -// Check that building a non-metadata crate fails if a dependent crate is -// metadata-only. - -extern crate rmeta_meta; -use rmeta_meta::Foo; - -fn main() { - let _ = Foo { field: 42 }; -} diff --git a/src/test/compile-fail/rmeta_meta_main.rs b/src/test/compile-fail/rmeta_meta_main.rs deleted file mode 100644 index ffeb5bc3b85..00000000000 --- a/src/test/compile-fail/rmeta_meta_main.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --emit=metadata -// aux-build:rmeta_meta.rs -// no-prefer-dynamic - -// Check that building a metadata crate finds an error with a dependent, -// metadata-only crate. - - -extern crate rmeta_meta; -use rmeta_meta::Foo; - -fn main() { - let _ = Foo { field2: 42 }; //~ ERROR struct `rmeta_meta::Foo` has no field named `field2` -} diff --git a/src/test/compile-fail/rust-unstable-column-gated.rs b/src/test/compile-fail/rust-unstable-column-gated.rs deleted file mode 100644 index abc92c86eec..00000000000 --- a/src/test/compile-fail/rust-unstable-column-gated.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("{}", __rust_unstable_column!()); - //~^ERROR the __rust_unstable_column macro is unstable -} diff --git a/src/test/compile-fail/rustc-args-required-const.rs b/src/test/compile-fail/rustc-args-required-const.rs deleted file mode 100644 index aac9299eaaf..00000000000 --- a/src/test/compile-fail/rustc-args-required-const.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(attr_literals, rustc_attrs, const_fn)] - -#[rustc_args_required_const(0)] -fn foo(_a: i32) { -} - -#[rustc_args_required_const(1)] -fn bar(_a: i32, _b: i32) { -} - -const A: i32 = 3; - -const fn baz() -> i32 { - 3 -} - -fn main() { - foo(2); - foo(2 + 3); - foo(baz()); - let a = 4; - foo(A); - foo(a); //~ ERROR: argument 1 is required to be a constant - bar(a, 3); - bar(a, a); //~ ERROR: argument 2 is required to be a constant -} diff --git a/src/test/compile-fail/rustc-args-required-const2.rs b/src/test/compile-fail/rustc-args-required-const2.rs deleted file mode 100644 index aa63019307b..00000000000 --- a/src/test/compile-fail/rustc-args-required-const2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(attr_literals, rustc_attrs, const_fn)] - -#[rustc_args_required_const(0)] -fn foo(_a: i32) { -} - -fn main() { - let a = foo; //~ ERROR: this function can only be invoked directly - a(2); -} diff --git a/src/test/compile-fail/rustc-error.rs b/src/test/compile-fail/rustc-error.rs deleted file mode 100644 index 82f32cbcd14..00000000000 --- a/src/test/compile-fail/rustc-error.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -#[rustc_error] -fn main() { - //~^ ERROR compilation successful -} diff --git a/src/test/compile-fail/safe-extern-statics-mut.rs b/src/test/compile-fail/safe-extern-statics-mut.rs deleted file mode 100644 index 35ea6dd52c4..00000000000 --- a/src/test/compile-fail/safe-extern-statics-mut.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:extern-statics.rs - -extern crate extern_statics; -use extern_statics::*; - -extern { - static mut B: u8; -} - -fn main() { - let b = B; //~ ERROR use of mutable static is unsafe - let rb = &B; //~ ERROR use of mutable static is unsafe - let xb = XB; //~ ERROR use of mutable static is unsafe - let xrb = &XB; //~ ERROR use of mutable static is unsafe -} diff --git a/src/test/compile-fail/safe-extern-statics.rs b/src/test/compile-fail/safe-extern-statics.rs deleted file mode 100644 index 83aa4b3316d..00000000000 --- a/src/test/compile-fail/safe-extern-statics.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:extern-statics.rs - -#![allow(unused)] - -extern crate extern_statics; -use extern_statics::*; - -extern { - static A: u8; -} - -fn main() { - let a = A; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler - let ra = &A; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler - let xa = XA; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler - let xra = &XA; //~ ERROR use of extern static is unsafe - //~^ WARN this was previously accepted by the compiler -} diff --git a/src/test/compile-fail/self-infer.rs b/src/test/compile-fail/self-infer.rs deleted file mode 100644 index fd011318a48..00000000000 --- a/src/test/compile-fail/self-infer.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S; - -impl S { - fn f(self: _) {} //~ERROR the type placeholder `_` is not allowed within types on item sig - fn g(self: &_) {} //~ERROR the type placeholder `_` is not allowed within types on item sig -} - -fn main() {} diff --git a/src/test/compile-fail/self-vs-path-ambiguity.rs b/src/test/compile-fail/self-vs-path-ambiguity.rs deleted file mode 100644 index b2dba3bd61b..00000000000 --- a/src/test/compile-fail/self-vs-path-ambiguity.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that `self::foo` is parsed as a general pattern and not a self argument. - -struct S; - -impl S { - fn f(self::S: S) {} - fn g(&self::S: &S) {} - fn h(&mut self::S: &mut S) {} - fn i(&'a self::S: &S) {} //~ ERROR unexpected lifetime `'a` in pattern -} - -fn main() {} diff --git a/src/test/compile-fail/self_type_keyword-2.rs b/src/test/compile-fail/self_type_keyword-2.rs deleted file mode 100644 index 8331ae0b307..00000000000 --- a/src/test/compile-fail/self_type_keyword-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use self::Self as Foo; //~ ERROR unresolved import `self::Self` - -pub fn main() { - let Self = 5; - //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope - - match 15 { - Self => (), - //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope - Foo { x: Self } => (), - //~^ ERROR cannot find unit struct/variant or constant `Self` in this scope - } -} diff --git a/src/test/compile-fail/self_type_keyword.rs b/src/test/compile-fail/self_type_keyword.rs deleted file mode 100644 index 20d2e2ca9cf..00000000000 --- a/src/test/compile-fail/self_type_keyword.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error - -mod foo { - struct Self; - //~^ ERROR expected identifier, found keyword `Self` -} - -struct Bar<'Self>; -//~^ ERROR lifetimes cannot use keyword names - -struct Foo; - -pub fn main() { - match 15 { - ref Self => (), - //~^ ERROR expected identifier, found keyword `Self` - mut Self => (), - //~^ ERROR expected identifier, found keyword `Self` - ref mut Self => (), - //~^ ERROR expected identifier, found keyword `Self` - Self!() => (), - //~^ ERROR cannot find macro `Self!` in this scope - Foo { Self } => (), - //~^ ERROR expected identifier, found keyword `Self` - } -} - -mod m1 { - extern crate core as Self; - //~^ ERROR expected identifier, found keyword `Self` -} - -mod m2 { - use std::option::Option as Self; - //~^ ERROR expected identifier, found keyword `Self` -} - -mod m3 { - trait Self {} - //~^ ERROR expected identifier, found keyword `Self` -} diff --git a/src/test/compile-fail/seq-args.rs b/src/test/compile-fail/seq-args.rs deleted file mode 100644 index 44b049d6561..00000000000 --- a/src/test/compile-fail/seq-args.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { -trait seq { } - -impl seq for Vec { //~ ERROR wrong number of type arguments - /* ... */ -} -impl seq for u32 { //~ ERROR wrong number of type arguments - /* Treat the integer as a sequence of bits */ -} - -} diff --git a/src/test/compile-fail/shadowed-trait-methods.rs b/src/test/compile-fail/shadowed-trait-methods.rs deleted file mode 100644 index 3146017a0b4..00000000000 --- a/src/test/compile-fail/shadowed-trait-methods.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that methods from shadowed traits cannot be used - -mod foo { - pub trait T { fn f(&self) {} } - impl T for () {} -} - -mod bar { pub use foo::T; } - -fn main() { - pub use bar::*; - struct T; - ().f() //~ ERROR no method -} diff --git a/src/test/compile-fail/shadowed-use-visibility.rs b/src/test/compile-fail/shadowed-use-visibility.rs deleted file mode 100644 index e7e57a73de0..00000000000 --- a/src/test/compile-fail/shadowed-use-visibility.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub fn f() {} - - use foo as bar; - pub use self::f as bar; -} - -mod bar { - use foo::bar::f as g; //~ ERROR module `bar` is private - - use foo as f; - pub use foo::*; -} - -use bar::f::f; //~ ERROR module `f` is private -fn main() {} diff --git a/src/test/compile-fail/shadowing-in-the-same-pattern.rs b/src/test/compile-fail/shadowing-in-the-same-pattern.rs deleted file mode 100644 index e847d332416..00000000000 --- a/src/test/compile-fail/shadowing-in-the-same-pattern.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for issue #14581. - -fn f((a, a): (isize, isize)) {} //~ ERROR identifier `a` is bound more than once - -fn main() { - let (a, a) = (1, 1); //~ ERROR identifier `a` is bound more than once -} diff --git a/src/test/compile-fail/shift-various-bad-types.rs b/src/test/compile-fail/shift-various-bad-types.rs deleted file mode 100644 index 2d06161111e..00000000000 --- a/src/test/compile-fail/shift-various-bad-types.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can do shifts by any integral type. - -struct Panolpy { - char: char, - str: &'static str, -} - -fn foo(p: &Panolpy) { - 22 >> p.char; - //~^ ERROR E0277 - - 22 >> p.str; - //~^ ERROR E0277 - - 22 >> p; - //~^ ERROR E0277 - - let x; - 22 >> x; // ambiguity error winds up being suppressed - - 22 >> 1; - // Integer literal types are OK - - // Type of the result follows the LHS, not the RHS: - let _: i32 = 22_i64 >> 1_i32; - //~^ ERROR mismatched types - //~| expected i32, found i64 -} - -fn main() { -} diff --git a/src/test/compile-fail/should-fail-no_gate_irrefutable_if_let_pattern.rs b/src/test/compile-fail/should-fail-no_gate_irrefutable_if_let_pattern.rs deleted file mode 100644 index 8c9a24f4e72..00000000000 --- a/src/test/compile-fail/should-fail-no_gate_irrefutable_if_let_pattern.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// should-fail-irrefutable_let_patterns -fn main() { - if let _ = 5 {} - //~^ ERROR irrefutable if-let pattern [E0162] -} diff --git a/src/test/compile-fail/should-fail-with_gate_irrefutable_pattern_deny.rs b/src/test/compile-fail/should-fail-with_gate_irrefutable_pattern_deny.rs deleted file mode 100644 index 6f95f10c0d9..00000000000 --- a/src/test/compile-fail/should-fail-with_gate_irrefutable_pattern_deny.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(irrefutable_let_patterns)] - -// should-fail-irrefutable_let_patterns_with_gate -fn main() { - if let _ = 5 {} - //~^ ERROR irrefutable if-let pattern [irrefutable_let_patterns] -} diff --git a/src/test/compile-fail/simd-intrinsic-declaration-type.rs b/src/test/compile-fail/simd-intrinsic-declaration-type.rs deleted file mode 100644 index ef1f4d6f230..00000000000 --- a/src/test/compile-fail/simd-intrinsic-declaration-type.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); -#[repr(simd)] -struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16); - -#[repr(simd)] -struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, - i8, i8, i8, i8, i8, i8, i8, i8); -#[repr(simd)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -struct f32x4(f32, f32, f32, f32); -#[repr(simd)] -struct i64x2(i64, i64); - -// correct signatures work well -mod right { - use {i16x8, u16x8}; - extern "platform-intrinsic" { - fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; - fn x86_mm_adds_epu16(x: u16x8, y: u16x8) -> u16x8; - } -} -// but incorrect ones don't. - -mod signedness { - use {i16x8, u16x8}; - // signedness matters - extern "platform-intrinsic" { - fn x86_mm_adds_epi16(x: u16x8, y: u16x8) -> u16x8; - //~^ ERROR intrinsic argument 1 has wrong type - //~^^ ERROR intrinsic argument 2 has wrong type - //~^^^ ERROR intrinsic return value has wrong type - fn x86_mm_adds_epu16(x: i16x8, y: i16x8) -> i16x8; - //~^ ERROR intrinsic argument 1 has wrong type - //~^^ ERROR intrinsic argument 2 has wrong type - //~^^^ ERROR intrinsic return value has wrong type - } -} -// as do lengths -extern "platform-intrinsic" { - fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; - //~^ ERROR intrinsic argument 1 has wrong type - //~^^ ERROR intrinsic argument 2 has wrong type - //~^^^ ERROR intrinsic return value has wrong type -} -// and so does int vs. float: -extern "platform-intrinsic" { - fn x86_mm_max_ps(x: i32x4, y: i32x4) -> i32x4; - //~^ ERROR intrinsic argument 1 has wrong type - //~^^ ERROR intrinsic argument 2 has wrong type - //~^^^ ERROR intrinsic return value has wrong type -} - - -fn main() {} diff --git a/src/test/compile-fail/simd-intrinsic-generic-arithmetic.rs b/src/test/compile-fail/simd-intrinsic-generic-arithmetic.rs deleted file mode 100644 index ee08ca05e80..00000000000 --- a/src/test/compile-fail/simd-intrinsic-generic-arithmetic.rs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics)] -#![allow(non_camel_case_types)] -#[repr(simd)] -#[derive(Copy, Clone)] -pub struct i32x4(pub i32, pub i32, pub i32, pub i32); - -#[repr(simd)] -#[derive(Copy, Clone)] -pub struct u32x4(pub u32, pub u32, pub u32, pub u32); - -#[repr(simd)] -#[derive(Copy, Clone)] -pub struct f32x4(pub f32, pub f32, pub f32, pub f32); - -extern "platform-intrinsic" { - fn simd_add(x: T, y: T) -> T; - fn simd_sub(x: T, y: T) -> T; - fn simd_mul(x: T, y: T) -> T; - fn simd_div(x: T, y: T) -> T; - fn simd_rem(x: T, y: T) -> T; - fn simd_shl(x: T, y: T) -> T; - fn simd_shr(x: T, y: T) -> T; - fn simd_and(x: T, y: T) -> T; - fn simd_or(x: T, y: T) -> T; - fn simd_xor(x: T, y: T) -> T; -} - -fn main() { - let x = i32x4(0, 0, 0, 0); - let y = u32x4(0, 0, 0, 0); - let z = f32x4(0.0, 0.0, 0.0, 0.0); - - unsafe { - simd_add(x, x); - simd_add(y, y); - simd_add(z, z); - simd_sub(x, x); - simd_sub(y, y); - simd_sub(z, z); - simd_mul(x, x); - simd_mul(y, y); - simd_mul(z, z); - simd_div(x, x); - simd_div(y, y); - simd_div(z, z); - simd_rem(x, x); - simd_rem(y, y); - simd_rem(z, z); - - simd_shl(x, x); - simd_shl(y, y); - simd_shr(x, x); - simd_shr(y, y); - simd_and(x, x); - simd_and(y, y); - simd_or(x, x); - simd_or(y, y); - simd_xor(x, x); - simd_xor(y, y); - - - simd_add(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_sub(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_mul(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_div(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_shl(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_shr(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_and(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_or(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_xor(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - - - simd_shl(z, z); -//~^ ERROR unsupported operation on `f32x4` with element `f32` - simd_shr(z, z); -//~^ ERROR unsupported operation on `f32x4` with element `f32` - simd_and(z, z); -//~^ ERROR unsupported operation on `f32x4` with element `f32` - simd_or(z, z); -//~^ ERROR unsupported operation on `f32x4` with element `f32` - simd_xor(z, z); -//~^ ERROR unsupported operation on `f32x4` with element `f32` - } -} diff --git a/src/test/compile-fail/simd-intrinsic-generic-cast.rs b/src/test/compile-fail/simd-intrinsic-generic-cast.rs deleted file mode 100644 index 4999b790b13..00000000000 --- a/src/test/compile-fail/simd-intrinsic-generic-cast.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i32x8(i32, i32, i32, i32, - i32, i32, i32, i32); - -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct f32x4(f32, f32, f32, f32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct f32x8(f32, f32, f32, f32, - f32, f32, f32, f32); - - -extern "platform-intrinsic" { - fn simd_cast(x: T) -> U; -} - -fn main() { - let x = i32x4(0, 0, 0, 0); - - unsafe { - simd_cast::(0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_cast::(0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_cast::(x); - //~^ ERROR expected SIMD return type, found non-SIMD `i32` - simd_cast::<_, i32x8>(x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 - } -} diff --git a/src/test/compile-fail/simd-intrinsic-generic-comparison.rs b/src/test/compile-fail/simd-intrinsic-generic-comparison.rs deleted file mode 100644 index 617b03a8711..00000000000 --- a/src/test/compile-fail/simd-intrinsic-generic-comparison.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i16x8(i16, i16, i16, i16, - i16, i16, i16, i16); - -extern "platform-intrinsic" { - fn simd_eq(x: T, y: T) -> U; - fn simd_ne(x: T, y: T) -> U; - fn simd_lt(x: T, y: T) -> U; - fn simd_le(x: T, y: T) -> U; - fn simd_gt(x: T, y: T) -> U; - fn simd_ge(x: T, y: T) -> U; -} - -fn main() { - let x = i32x4(0, 0, 0, 0); - - unsafe { - simd_eq::(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_ne::(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_lt::(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_le::(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_gt::(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_ge::(0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - - simd_eq::<_, i32>(x, x); - //~^ ERROR expected SIMD return type, found non-SIMD `i32` - simd_ne::<_, i32>(x, x); - //~^ ERROR expected SIMD return type, found non-SIMD `i32` - simd_lt::<_, i32>(x, x); - //~^ ERROR expected SIMD return type, found non-SIMD `i32` - simd_le::<_, i32>(x, x); - //~^ ERROR expected SIMD return type, found non-SIMD `i32` - simd_gt::<_, i32>(x, x); - //~^ ERROR expected SIMD return type, found non-SIMD `i32` - simd_ge::<_, i32>(x, x); - //~^ ERROR expected SIMD return type, found non-SIMD `i32` - - simd_eq::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - simd_ne::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - simd_lt::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - simd_le::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - simd_gt::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - simd_ge::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - } -} diff --git a/src/test/compile-fail/simd-intrinsic-generic-elements.rs b/src/test/compile-fail/simd-intrinsic-generic-elements.rs deleted file mode 100644 index 78f7d42e25a..00000000000 --- a/src/test/compile-fail/simd-intrinsic-generic-elements.rs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics, rustc_attrs)] - -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i32x2(i32, i32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i32x3(i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct i32x8(i32, i32, i32, i32, - i32, i32, i32, i32); - -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct f32x2(f32, f32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct f32x3(f32, f32, f32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct f32x4(f32, f32, f32, f32); -#[repr(simd)] -#[derive(Copy, Clone)] -#[allow(non_camel_case_types)] -struct f32x8(f32, f32, f32, f32, - f32, f32, f32, f32); - -extern "platform-intrinsic" { - fn simd_insert(x: T, idx: u32, y: E) -> T; - fn simd_extract(x: T, idx: u32) -> E; - - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; - fn simd_shuffle3(x: T, y: T, idx: [u32; 3]) -> U; - fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; - fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; -} - -fn main() { - let x = i32x4(0, 0, 0, 0); - - unsafe { - simd_insert(0, 0, 0); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_insert(x, 0, 1.0); - //~^ ERROR expected inserted type `i32` (element of input `i32x4`), found `f64` - simd_extract::<_, f32>(x, 0); - //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32` - - simd_shuffle2::(0, 0, [0; 2]); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_shuffle3::(0, 0, [0; 3]); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_shuffle4::(0, 0, [0; 4]); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_shuffle8::(0, 0, [0; 8]); - //~^ ERROR expected SIMD input type, found non-SIMD `i32` - - simd_shuffle2::<_, f32x2>(x, x, [0; 2]); -//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - simd_shuffle3::<_, f32x3>(x, x, [0; 3]); -//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32` - simd_shuffle4::<_, f32x4>(x, x, [0; 4]); -//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - simd_shuffle8::<_, f32x8>(x, x, [0; 8]); -//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - - simd_shuffle2::<_, i32x8>(x, x, [0; 2]); - //~^ ERROR expected return type of length 2, found `i32x8` with length 8 - simd_shuffle3::<_, i32x4>(x, x, [0; 3]); - //~^ ERROR expected return type of length 3, found `i32x4` with length 4 - simd_shuffle4::<_, i32x3>(x, x, [0; 4]); - //~^ ERROR expected return type of length 4, found `i32x3` with length 3 - simd_shuffle8::<_, i32x2>(x, x, [0; 8]); - //~^ ERROR expected return type of length 8, found `i32x2` with length 2 - } -} diff --git a/src/test/compile-fail/simd-intrinsic-generic-reduction.rs b/src/test/compile-fail/simd-intrinsic-generic-reduction.rs deleted file mode 100644 index 725960a866b..00000000000 --- a/src/test/compile-fail/simd-intrinsic-generic-reduction.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-emscripten - -// Test that the simd_reduce_{op} intrinsics produce ok-ish error -// messages when misused. - -#![feature(repr_simd, platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] -#[derive(Copy, Clone)] -pub struct f32x4(pub f32, pub f32, pub f32, pub f32); - -#[repr(simd)] -#[derive(Copy, Clone)] -pub struct u32x4(pub u32, pub u32, pub u32, pub u32); - - -extern "platform-intrinsic" { - fn simd_reduce_add_ordered(x: T, y: U) -> U; - fn simd_reduce_mul_ordered(x: T, y: U) -> U; - fn simd_reduce_and(x: T) -> U; - fn simd_reduce_or(x: T) -> U; - fn simd_reduce_xor(x: T) -> U; - fn simd_reduce_all(x: T) -> bool; - fn simd_reduce_any(x: T) -> bool; -} - -fn main() { - let x = u32x4(0, 0, 0, 0); - let z = f32x4(0.0, 0.0, 0.0, 0.0); - - unsafe { - simd_reduce_add_ordered(z, 0_f32); - simd_reduce_mul_ordered(z, 1_f32); - - simd_reduce_add_ordered(z, 2_f32); - //~^ ERROR accumulator of simd_reduce_add_ordered is not 0.0 - simd_reduce_mul_ordered(z, 3_f32); - //~^ ERROR accumulator of simd_reduce_mul_ordered is not 1.0 - - let _: f32 = simd_reduce_and(x); - //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` - let _: f32 = simd_reduce_or(x); - //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` - let _: f32 = simd_reduce_xor(x); - //~^ ERROR expected return type `u32` (element of input `u32x4`), found `f32` - - let _: f32 = simd_reduce_and(z); - //~^ ERROR unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` - let _: f32 = simd_reduce_or(z); - //~^ ERROR unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` - let _: f32 = simd_reduce_xor(z); - //~^ ERROR unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` - - let _: bool = simd_reduce_all(z); - //~^ ERROR unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` - let _: bool = simd_reduce_any(z); - //~^ ERROR unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` - - foo(0_f32); - } -} - -#[inline(never)] -unsafe fn foo(x: f32) { - let z = f32x4(0.0, 0.0, 0.0, 0.0); - simd_reduce_add_ordered(z, x); - //~^ ERROR accumulator of simd_reduce_add_ordered is not a constant - simd_reduce_mul_ordered(z, x); - //~^ ERROR accumulator of simd_reduce_mul_ordered is not a constant -} diff --git a/src/test/compile-fail/simd-intrinsic-generic-select.rs b/src/test/compile-fail/simd-intrinsic-generic-select.rs deleted file mode 100644 index d74d6815d5f..00000000000 --- a/src/test/compile-fail/simd-intrinsic-generic-select.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the simd_select intrinsic produces ok-ish error -// messages when misused. - -#![feature(repr_simd, platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] -#[derive(Copy, Clone)] -pub struct f32x4(pub f32, pub f32, pub f32, pub f32); - -#[repr(simd)] -#[derive(Copy, Clone)] -pub struct u32x4(pub u32, pub u32, pub u32, pub u32); - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq)] -struct b8x4(pub i8, pub i8, pub i8, pub i8); - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq)] -struct b8x8(pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8); - -extern "platform-intrinsic" { - fn simd_select(x: T, a: U, b: U) -> U; -} - -fn main() { - let m4 = b8x4(0, 0, 0, 0); - let m8 = b8x8(0, 0, 0, 0, 0, 0, 0, 0); - let x = u32x4(0, 0, 0, 0); - let z = f32x4(0.0, 0.0, 0.0, 0.0); - - unsafe { - simd_select(m4, x, x); - - simd_select(m8, x, x); - //~^ ERROR mismatched lengths: mask length `8` != other vector length `4` - - simd_select(x, x, x); - //~^ ERROR mask element type is `u32`, expected `i_` - - simd_select(z, z, z); - //~^ ERROR mask element type is `f32`, expected `i_` - } -} diff --git a/src/test/compile-fail/simd-intrinsic-single-nominal-type.rs b/src/test/compile-fail/simd-intrinsic-single-nominal-type.rs deleted file mode 100644 index 0d0bf240f72..00000000000 --- a/src/test/compile-fail/simd-intrinsic-single-nominal-type.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -struct A(i16, i16, i16, i16, i16, i16, i16, i16); -#[repr(simd)] -struct B(i16, i16, i16, i16, i16, i16, i16, i16); - -// each intrinsic definition has to use the same nominal type for any -// vector structure throughout that declaration (i.e. every instance -// of i16x8 in each `fn ...;` needs to be either A or B) - -extern "platform-intrinsic" { - fn x86_mm_adds_epi16(x: A, y: A) -> B; - //~^ ERROR intrinsic return value has wrong type: found `B`, expected `A` - fn x86_mm_subs_epi16(x: A, y: B) -> A; - //~^ ERROR intrinsic argument 2 has wrong type: found `B`, expected `A` - - // ok: - fn x86_mm_max_epi16(x: B, y: B) -> B; - fn x86_mm_min_epi16(x: A, y: A) -> A; -} - -fn main() {} diff --git a/src/test/compile-fail/simd-type-generic-monomorphisation.rs b/src/test/compile-fail/simd-type-generic-monomorphisation.rs deleted file mode 100644 index 336855eb5e1..00000000000 --- a/src/test/compile-fail/simd-type-generic-monomorphisation.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd, platform_intrinsics)] - -// error-pattern:monomorphising SIMD type `Simd2` with a non-machine element type `X` - -struct X(Vec); -#[repr(simd)] -struct Simd2(T, T); - -fn main() { - let _ = Simd2(X(vec![]), X(vec![])); -} diff --git a/src/test/compile-fail/simd-type.rs b/src/test/compile-fail/simd-type.rs deleted file mode 100644 index cde63aa0cd1..00000000000 --- a/src/test/compile-fail/simd-type.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_simd)] - -#[repr(simd)] -struct empty; //~ ERROR SIMD vector cannot be empty - -#[repr(simd)] -struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous - -#[repr(simd)] -struct int4(isize, isize, isize, isize); //~ ERROR SIMD vector element type should be machine type - -fn main() {} diff --git a/src/test/compile-fail/single-primitive-inherent-impl.rs b/src/test/compile-fail/single-primitive-inherent-impl.rs deleted file mode 100644 index 0a0f9ce4bd1..00000000000 --- a/src/test/compile-fail/single-primitive-inherent-impl.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#![crate_type = "lib"] -#![feature(lang_items)] -#![no_std] - -// OK -#[lang = "str_alloc"] -impl str {} - -impl str { -//~^ error: only a single inherent implementation marked with `#[lang = "str"]` is allowed for the `str` primitive -} diff --git a/src/test/compile-fail/sized-cycle-note.rs b/src/test/compile-fail/sized-cycle-note.rs deleted file mode 100644 index 712b4ac22f0..00000000000 --- a/src/test/compile-fail/sized-cycle-note.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test the error message resulting from a cycle in solving `Foo: -// Sized`. The specifics of the message will of course but the main -// thing we want to preserve is that: -// -// 1. the message should appear attached to one of the structs -// defined in this file; -// 2. it should elaborate the steps that led to the cycle. - -struct Baz { q: Option } -//~^ ERROR recursive type `Baz` has infinite size -struct Foo { q: Option } -//~^ ERROR recursive type `Foo` has infinite size - -impl Foo { fn bar(&self) {} } - -fn main() {} diff --git a/src/test/compile-fail/slice-2.rs b/src/test/compile-fail/slice-2.rs deleted file mode 100644 index 44b9d94c566..00000000000 --- a/src/test/compile-fail/slice-2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that slicing syntax gives errors if we have not implemented the trait. - -struct Foo; - -fn main() { - let x = Foo; - &x[..]; //~ ERROR cannot index into a value of type `Foo` - &x[Foo..]; //~ ERROR cannot index into a value of type `Foo` - &x[..Foo]; //~ ERROR cannot index into a value of type `Foo` - &x[Foo..Foo]; //~ ERROR cannot index into a value of type `Foo` -} diff --git a/src/test/compile-fail/slice-mut-2.rs b/src/test/compile-fail/slice-mut-2.rs deleted file mode 100644 index e20e968a012..00000000000 --- a/src/test/compile-fail/slice-mut-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test mutability and slicing syntax. - -fn main() { - let x: &[isize] = &[1, 2, 3, 4, 5]; - // Can't mutably slice an immutable slice - let slice: &mut [isize] = &mut [0, 1]; - let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable -} diff --git a/src/test/compile-fail/slice-mut.rs b/src/test/compile-fail/slice-mut.rs deleted file mode 100644 index bee3704a353..00000000000 --- a/src/test/compile-fail/slice-mut.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test mutability and slicing syntax. - -fn main() { - let x: &[isize] = &[1, 2, 3, 4, 5]; - // Immutable slices are not mutable. - - let y: &mut[_] = &x[2..4]; - //~^ ERROR mismatched types - //~| expected type `&mut [_]` - //~| found type `&[isize]` - //~| types differ in mutability -} diff --git a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs b/src/test/compile-fail/slightly-nice-generic-literal-messages.rs deleted file mode 100644 index 2eba7c2e534..00000000000 --- a/src/test/compile-fail/slightly-nice-generic-literal-messages.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker; - -struct Foo(T, marker::PhantomData); - -fn main() { - match Foo(1.1, marker::PhantomData) { - 1 => {} - //~^ ERROR mismatched types - //~| expected type `Foo<{float}, _>` - //~| found type `{integer}` - //~| expected struct `Foo`, found integral variable - } - -} diff --git a/src/test/compile-fail/specialization/README.md b/src/test/compile-fail/specialization/README.md deleted file mode 100644 index f2b4bf946c5..00000000000 --- a/src/test/compile-fail/specialization/README.md +++ /dev/null @@ -1,21 +0,0 @@ -This directory contains the test for incorrect usage of specialization that -should lead to compile failure. Those tests break down into a few categories: - -- Feature gating - - [On use of the `default` keyword](specialization-feature-gate-default.rs) - - [On overlapping impls](specialization-feature-gate-overlap.rs) - -- Overlap checking with specialization enabled - - [Basic overlap scenarios](specialization-overlap.rs) - - Includes purely structural overlap - - Includes purely trait-based overlap - - Includes mix - - [Overlap with differing polarity](specialization-overlap-negative.rs) - -- [Attempt to specialize without using `default`](specialization-no-default.rs) - -- [Attempt to change impl polarity in a specialization](specialization-polarity.rs) - -- Attempt to rely on projection of a `default` type - - [Rely on it externally in both generic and monomorphic contexts](specialization-default-projection.rs) - - [Rely on it both within an impl and outside it](specialization-default-types.rs) diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-feature-gate-default.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-feature-gate-default.rs deleted file mode 100644 index 5bab4c5438e..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-feature-gate-default.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that specialization must be ungated to use the `default` keyword - -trait Foo { - fn foo(&self); -} - -default impl Foo for T { //~ ERROR specialization is unstable - fn foo(&self) {} -} - -fn main() {} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-no-default.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-no-default.rs deleted file mode 100644 index 2874108157d..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-no-default.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Check a number of scenarios in which one impl tries to override another, -// without correctly using `default`. - -//////////////////////////////////////////////////////////////////////////////// -// Test 1: one layer of specialization, multiple methods, missing `default` -//////////////////////////////////////////////////////////////////////////////// - -trait Foo { - fn foo(&self); - fn bar(&self); -} - -impl Foo for T { - fn foo(&self) {} - fn bar(&self) {} -} - -impl Foo for u8 {} -impl Foo for u16 { - fn foo(&self) {} //~ ERROR E0520 -} -impl Foo for u32 { - fn bar(&self) {} //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 2: one layer of specialization, missing `default` on associated type -//////////////////////////////////////////////////////////////////////////////// - -trait Bar { - type T; -} - -impl Bar for T { - type T = u8; -} - -impl Bar for u8 { - type T = (); //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 3a: multiple layers of specialization, missing interior `default` -//////////////////////////////////////////////////////////////////////////////// - -trait Baz { - fn baz(&self); -} - -default impl Baz for T { - fn baz(&self) {} -} - -impl Baz for T { - fn baz(&self) {} -} - -impl Baz for i32 { - fn baz(&self) {} //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 3b: multiple layers of specialization, missing interior `default`, -// redundant `default` in bottom layer. -//////////////////////////////////////////////////////////////////////////////// - -trait Redundant { - fn redundant(&self); -} - -default impl Redundant for T { - fn redundant(&self) {} -} - -impl Redundant for T { - fn redundant(&self) {} -} - -default impl Redundant for i32 { - fn redundant(&self) {} //~ ERROR E0520 -} - -fn main() {} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-item-not-implemented.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-trait-item-not-implemented.rs deleted file mode 100644 index eacec2e40f0..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-item-not-implemented.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that default impls do not have to supply all items but regular impls do. - -#![feature(specialization)] - -trait Foo { - fn foo_one(&self) -> &'static str; - fn foo_two(&self) -> &'static str; -} - -struct MyStruct; - -default impl Foo for T { - fn foo_one(&self) -> &'static str { - "generic" - } -} - -impl Foo for MyStruct {} -//~^ ERROR not all trait items implemented, missing: `foo_two` [E0046] - -fn main() { - println!("{}", MyStruct.foo_one()); -} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-not-implemented.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-trait-not-implemented.rs deleted file mode 100644 index 04ddf9ebb17..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-trait-not-implemented.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that: -// - default impls do not have to supply all items and -// - a default impl does not count as an impl (in this case, an incomplete default impl). - -#![feature(specialization)] - -trait Foo { - fn foo_one(&self) -> &'static str; - fn foo_two(&self) -> &'static str; -} - -struct MyStruct; - -default impl Foo for T { - fn foo_one(&self) -> &'static str { - "generic" - } -} - - -fn main() { - println!("{}", MyStruct.foo_one()); - //~^ ERROR no method named `foo_one` found for type `MyStruct` in the current scope -} diff --git a/src/test/compile-fail/specialization/defaultimpl/specialization-wfcheck.rs b/src/test/compile-fail/specialization/defaultimpl/specialization-wfcheck.rs deleted file mode 100644 index 445a59a373e..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/specialization-wfcheck.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that a default impl still has to have a WF trait ref. - -#![feature(specialization)] - -trait Foo<'a, T: Eq + 'a> { } - -default impl Foo<'static, U> for () {} -//~^ ERROR the trait bound `U: std::cmp::Eq` is not satisfied - -fn main(){} diff --git a/src/test/compile-fail/specialization/defaultimpl/validation.rs b/src/test/compile-fail/specialization/defaultimpl/validation.rs deleted file mode 100644 index 26b8b737f34..00000000000 --- a/src/test/compile-fail/specialization/defaultimpl/validation.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(specialization)] - -struct S; -struct Z; - -default impl S {} //~ ERROR inherent impls cannot be default - -default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be default -default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default - -trait Tr {} -default impl !Tr for S {} //~ ERROR negative impls are only allowed for auto traits diff --git a/src/test/compile-fail/specialization/issue-52050.rs b/src/test/compile-fail/specialization/issue-52050.rs deleted file mode 100644 index 70cdb4899c4..00000000000 --- a/src/test/compile-fail/specialization/issue-52050.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Regression test for #52050: when inserting the blanket impl `I` -// into the tree, we had to replace the child node for `Foo`, which -// led to the struture of the tree being messed up. - -use std::iter::Iterator; - -trait IntoPyDictPointer { } - -struct Foo { } - -impl Iterator for Foo { - type Item = (); - fn next(&mut self) -> Option<()> { - None - } -} - -impl IntoPyDictPointer for Foo { } - -impl IntoPyDictPointer for I -where - I: Iterator, -{ -} - -impl IntoPyDictPointer for () //~ ERROR conflicting implementations -{ -} - -fn main() { } diff --git a/src/test/compile-fail/specialization/specialization-default-projection.rs b/src/test/compile-fail/specialization/specialization-default-projection.rs deleted file mode 100644 index 96cbd7a4852..00000000000 --- a/src/test/compile-fail/specialization/specialization-default-projection.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Make sure we can't project defaulted associated types - -trait Foo { - type Assoc; -} - -impl Foo for T { - default type Assoc = (); -} - -impl Foo for u8 { - type Assoc = String; -} - -fn generic() -> ::Assoc { - // `T` could be some downstream crate type that specializes (or, - // for that matter, `u8`). - - () //~ ERROR mismatched types -} - -fn monomorphic() -> () { - // Even though we know that `()` is not specialized in a - // downstream crate, typeck refuses to project here. - - generic::<()>() //~ ERROR mismatched types -} - -fn main() { - // No error here, we CAN project from `u8`, as there is no `default` - // in that impl. - let s: String = generic::(); - println!("{}", s); // bad news if this all compiles -} diff --git a/src/test/compile-fail/specialization/specialization-default-types.rs b/src/test/compile-fail/specialization/specialization-default-types.rs deleted file mode 100644 index 18acecb4229..00000000000 --- a/src/test/compile-fail/specialization/specialization-default-types.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// It should not be possible to use the concrete value of a defaulted -// associated type in the impl defining it -- otherwise, what happens -// if it's overridden? - -#![feature(specialization)] - -trait Example { - type Output; - fn generate(self) -> Self::Output; -} - -impl Example for T { - default type Output = Box; - default fn generate(self) -> Self::Output { - Box::new(self) //~ ERROR mismatched types - } -} - -impl Example for bool { - type Output = bool; - fn generate(self) -> bool { self } -} - -fn trouble(t: T) -> Box { - Example::generate(t) //~ ERROR mismatched types -} - -fn weaponize() -> bool { - let b: Box = trouble(true); - *b -} - -fn main() { - weaponize(); -} diff --git a/src/test/compile-fail/specialization/specialization-no-default.rs b/src/test/compile-fail/specialization/specialization-no-default.rs deleted file mode 100644 index 96156168543..00000000000 --- a/src/test/compile-fail/specialization/specialization-no-default.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Check a number of scenarios in which one impl tries to override another, -// without correctly using `default`. - -//////////////////////////////////////////////////////////////////////////////// -// Test 1: one layer of specialization, multiple methods, missing `default` -//////////////////////////////////////////////////////////////////////////////// - -trait Foo { - fn foo(&self); - fn bar(&self); -} - -impl Foo for T { - fn foo(&self) {} - fn bar(&self) {} -} - -impl Foo for u8 {} -impl Foo for u16 { - fn foo(&self) {} //~ ERROR E0520 -} -impl Foo for u32 { - fn bar(&self) {} //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 2: one layer of specialization, missing `default` on associated type -//////////////////////////////////////////////////////////////////////////////// - -trait Bar { - type T; -} - -impl Bar for T { - type T = u8; -} - -impl Bar for u8 { - type T = (); //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 3a: multiple layers of specialization, missing interior `default` -//////////////////////////////////////////////////////////////////////////////// - -trait Baz { - fn baz(&self); -} - -impl Baz for T { - default fn baz(&self) {} -} - -impl Baz for T { - fn baz(&self) {} -} - -impl Baz for i32 { - fn baz(&self) {} //~ ERROR E0520 -} - -//////////////////////////////////////////////////////////////////////////////// -// Test 3b: multiple layers of specialization, missing interior `default`, -// redundant `default` in bottom layer. -//////////////////////////////////////////////////////////////////////////////// - -trait Redundant { - fn redundant(&self); -} - -impl Redundant for T { - default fn redundant(&self) {} -} - -impl Redundant for T { - fn redundant(&self) {} -} - -impl Redundant for i32 { - default fn redundant(&self) {} //~ ERROR E0520 -} - -fn main() {} diff --git a/src/test/compile-fail/specialization/specialization-overlap-negative.rs b/src/test/compile-fail/specialization/specialization-overlap-negative.rs deleted file mode 100644 index 62a6d8d9b50..00000000000 --- a/src/test/compile-fail/specialization/specialization-overlap-negative.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(specialization)] - -trait MyTrait {} - -struct TestType(::std::marker::PhantomData); - -unsafe impl Send for TestType {} -impl !Send for TestType {} //~ ERROR E0119 - -fn main() {} diff --git a/src/test/compile-fail/specialization/specialization-overlap.rs b/src/test/compile-fail/specialization/specialization-overlap.rs deleted file mode 100644 index ff12a82db5b..00000000000 --- a/src/test/compile-fail/specialization/specialization-overlap.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -trait Foo { fn foo() {} } -impl Foo for T {} -impl Foo for Vec {} //~ ERROR E0119 - -trait Bar { fn bar() {} } -impl Bar for (T, u8) {} -impl Bar for (u8, T) {} //~ ERROR E0119 - -trait Baz { fn baz() {} } -impl Baz for u8 {} -impl Baz for T {} //~ ERROR E0119 - -trait Qux { fn qux() {} } -impl Qux for T {} -impl Qux for T {} //~ ERROR E0119 - -fn main() {} diff --git a/src/test/compile-fail/specialization/specialization-polarity.rs b/src/test/compile-fail/specialization/specialization-polarity.rs deleted file mode 100644 index b28a63c8293..00000000000 --- a/src/test/compile-fail/specialization/specialization-polarity.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Make sure specialization cannot change impl polarity - -#![feature(optin_builtin_traits)] -#![feature(specialization)] - -auto trait Foo {} - -impl Foo for T {} -impl !Foo for u8 {} //~ ERROR E0119 - -auto trait Bar {} - -impl !Bar for T {} -impl Bar for u8 {} //~ ERROR E0119 - -fn main() {} diff --git a/src/test/compile-fail/stability-attribute-issue-43027.rs b/src/test/compile-fail/stability-attribute-issue-43027.rs deleted file mode 100644 index dac50db3fd9..00000000000 --- a/src/test/compile-fail/stability-attribute-issue-43027.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(staged_api)] -#![stable(feature = "test", since = "0")] - -#[stable(feature = "test", since = "0")] -pub struct Reverse(pub T); //~ ERROR This node does not have a stability attribute - -fn main() { - // Make sure the field is used to fill the stability cache - Reverse(0).0; -} diff --git a/src/test/compile-fail/stability-attribute-issue.rs b/src/test/compile-fail/stability-attribute-issue.rs deleted file mode 100644 index 754c6f792f9..00000000000 --- a/src/test/compile-fail/stability-attribute-issue.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:stability_attribute_issue.rs -// ignore-tidy-linelength - -#![deny(deprecated)] - -extern crate stability_attribute_issue; -use stability_attribute_issue::*; - -fn main() { - unstable(); - //~^ ERROR use of unstable library feature 'unstable_test_feature' (see issue #1) - unstable_msg(); - //~^ ERROR use of unstable library feature 'unstable_test_feature': message (see issue #2) -} diff --git a/src/test/compile-fail/stability-attribute-non-staged-force-unstable.rs b/src/test/compile-fail/stability-attribute-non-staged-force-unstable.rs deleted file mode 100644 index 512fb24a0c2..00000000000 --- a/src/test/compile-fail/stability-attribute-non-staged-force-unstable.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags:-Zforce-unstable-if-unmarked - -#[unstable] //~ ERROR: stability attributes may not be used -#[stable] //~ ERROR: stability attributes may not be used -#[rustc_deprecated] //~ ERROR: stability attributes may not be used -fn main() { } diff --git a/src/test/compile-fail/stability-attribute-non-staged.rs b/src/test/compile-fail/stability-attribute-non-staged.rs deleted file mode 100644 index 35256f21f92..00000000000 --- a/src/test/compile-fail/stability-attribute-non-staged.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[unstable] //~ ERROR: stability attributes may not be used -#[stable] //~ ERROR: stability attributes may not be used -#[rustc_deprecated] //~ ERROR: stability attributes may not be used -fn main() { } diff --git a/src/test/compile-fail/stability-attribute-sanity-2.rs b/src/test/compile-fail/stability-attribute-sanity-2.rs deleted file mode 100644 index 9c54315bfd0..00000000000 --- a/src/test/compile-fail/stability-attribute-sanity-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// More checks that stability attributes are used correctly - -#![feature(staged_api)] - -#![stable(feature = "stable_test_feature", since = "1.0.0")] - -#[stable(feature = "a", feature = "b", since = "1.0.0")] //~ ERROR multiple 'feature' items -fn f1() { } - -#[stable(feature = "a", sinse = "1.0.0")] //~ ERROR unknown meta item 'sinse' -fn f2() { } - -#[unstable(feature = "a", issue = "no")] //~ ERROR incorrect 'issue' -fn f3() { } - -fn main() { } diff --git a/src/test/compile-fail/stability-attribute-sanity-3.rs b/src/test/compile-fail/stability-attribute-sanity-3.rs deleted file mode 100644 index d4821e009f2..00000000000 --- a/src/test/compile-fail/stability-attribute-sanity-3.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// More checks that stability attributes are used correctly - -#![feature(staged_api)] - -#![stable(feature = "stable_test_feature", since = "1.0.0")] - -#[macro_export] -macro_rules! mac { //~ ERROR This node does not have a stability attribute - () => () -} - -fn main() { } diff --git a/src/test/compile-fail/stability-attribute-sanity.rs b/src/test/compile-fail/stability-attribute-sanity.rs deleted file mode 100644 index 794ae1ca087..00000000000 --- a/src/test/compile-fail/stability-attribute-sanity.rs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various checks that stability attributes are used correctly, per RFC 507 - -#![feature(const_fn, staged_api, rustc_const_unstable)] - -#![stable(feature = "rust1", since = "1.0.0")] - -mod bogus_attribute_types_1 { - #[stable(feature = "a", since = "b", reason)] //~ ERROR unknown meta item 'reason' [E0541] - fn f1() { } - - #[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539] - fn f2() { } - - #[stable(feature, since = "a")] //~ ERROR incorrect meta item [E0539] - fn f3() { } - - #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539] - fn f5() { } - - #[stable(feature(b), since = "a")] //~ ERROR incorrect meta item [E0539] - fn f6() { } -} - -mod bogus_attribute_types_2 { - #[unstable] //~ ERROR incorrect stability attribute type [E0548] - fn f1() { } - - #[unstable = "b"] //~ ERROR incorrect stability attribute type [E0548] - fn f2() { } - - #[stable] //~ ERROR incorrect stability attribute type [E0548] - fn f3() { } - - #[stable = "a"] //~ ERROR incorrect stability attribute type [E0548] - fn f4() { } - - #[stable(feature = "a", since = "b")] - #[rustc_deprecated] //~ ERROR incorrect stability attribute type [E0548] - fn f5() { } - - #[stable(feature = "a", since = "b")] - #[rustc_deprecated = "a"] //~ ERROR incorrect stability attribute type [E0548] - fn f6() { } -} - -mod missing_feature_names { - #[unstable(issue = "0")] //~ ERROR missing 'feature' [E0546] - fn f1() { } - - #[unstable(feature = "b")] //~ ERROR missing 'issue' [E0547] - fn f2() { } - - #[stable(since = "a")] //~ ERROR missing 'feature' [E0546] - fn f3() { } -} - -mod missing_version { - #[stable(feature = "a")] //~ ERROR missing 'since' [E0542] - fn f1() { } - - #[stable(feature = "a", since = "b")] - #[rustc_deprecated(reason = "a")] //~ ERROR missing 'since' [E0542] - fn f2() { } -} - -#[unstable(feature = "b", issue = "0")] -#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544] -fn multiple1() { } - -#[unstable(feature = "b", issue = "0")] -#[unstable(feature = "b", issue = "0")] //~ ERROR multiple stability levels [E0544] -fn multiple2() { } - -#[stable(feature = "a", since = "b")] -#[stable(feature = "a", since = "b")] //~ ERROR multiple stability levels [E0544] -fn multiple3() { } - -#[stable(feature = "a", since = "b")] -#[rustc_deprecated(since = "b", reason = "text")] -#[rustc_deprecated(since = "b", reason = "text")] -#[rustc_const_unstable(feature = "c")] -#[rustc_const_unstable(feature = "d")] -pub const fn multiple4() { } //~ ERROR multiple rustc_deprecated attributes [E0540] -//~^ ERROR Invalid stability or deprecation version found -//~| ERROR multiple rustc_const_unstable attributes - -#[rustc_deprecated(since = "a", reason = "text")] -fn deprecated_without_unstable_or_stable() { } -//~^ ERROR rustc_deprecated attribute must be paired with either stable or unstable attribute - -fn main() { } diff --git a/src/test/compile-fail/stable-features.rs b/src/test/compile-fail/stable-features.rs deleted file mode 100644 index 32991dd6499..00000000000 --- a/src/test/compile-fail/stable-features.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Testing that the stable_features lint catches use of stable -// language and lib features. - -#![deny(stable_features)] - -#![feature(test_accepted_feature)] -//~^ ERROR the feature `test_accepted_feature` has been stable since 1.0.0 - -#![feature(rust1)] -//~^ ERROR the feature `rust1` has been stable since 1.0.0 - -fn main() { - let _foo: Vec<()> = Vec::new(); -} diff --git a/src/test/compile-fail/static-closures.rs b/src/test/compile-fail/static-closures.rs deleted file mode 100644 index 8593eb5333e..00000000000 --- a/src/test/compile-fail/static-closures.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - static || {}; - //~^ ERROR closures cannot be static -} diff --git a/src/test/compile-fail/static-drop-scope.rs b/src/test/compile-fail/static-drop-scope.rs deleted file mode 100644 index e22eb7e4484..00000000000 --- a/src/test/compile-fail/static-drop-scope.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(const_fn)] - -struct WithDtor; - -impl Drop for WithDtor { - fn drop(&mut self) {} -} - -static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); -//~^ ERROR destructors cannot be evaluated at compile-time -//~| ERROR borrowed value does not live long enoug - -const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); -//~^ ERROR destructors cannot be evaluated at compile-time -//~| ERROR borrowed value does not live long enoug - -static EARLY_DROP_S: i32 = (WithDtor, 0).1; -//~^ ERROR destructors cannot be evaluated at compile-time - -const EARLY_DROP_C: i32 = (WithDtor, 0).1; -//~^ ERROR destructors cannot be evaluated at compile-time - -const fn const_drop(_: T) {} -//~^ ERROR destructors cannot be evaluated at compile-time - -const fn const_drop2(x: T) { - (x, ()).1 - //~^ ERROR destructors cannot be evaluated at compile-time -} - -fn main () {} diff --git a/src/test/compile-fail/static-items-cant-move.rs b/src/test/compile-fail/static-items-cant-move.rs deleted file mode 100644 index c8fddeb1214..00000000000 --- a/src/test/compile-fail/static-items-cant-move.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Verifies that static items can't be moved - -struct B; - -struct Foo { - foo: isize, - b: B, -} - -static BAR: Foo = Foo { foo: 5, b: B }; - - -fn test(f: Foo) { - let _f = Foo{foo: 4, ..f}; -} - -fn main() { - test(BAR); //~ ERROR cannot move out of static item -} diff --git a/src/test/compile-fail/static-lifetime-bound.rs b/src/test/compile-fail/static-lifetime-bound.rs deleted file mode 100644 index 38534ab0a36..00000000000 --- a/src/test/compile-fail/static-lifetime-bound.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a` - -fn main() { - let x = 0; - f(&x); //~ERROR does not live long enough -} diff --git a/src/test/compile-fail/static-method-privacy.rs b/src/test/compile-fail/static-method-privacy.rs deleted file mode 100644 index 5e175aa0fee..00000000000 --- a/src/test/compile-fail/static-method-privacy.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub struct S; - impl S { - fn new() -> S { S } - } -} - -fn main() { - let _ = a::S::new(); //~ ERROR method `new` is private -} diff --git a/src/test/compile-fail/static-mut-bad-types.rs b/src/test/compile-fail/static-mut-bad-types.rs deleted file mode 100644 index 088c8ef3ab8..00000000000 --- a/src/test/compile-fail/static-mut-bad-types.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static mut a: isize = 3; - -fn main() { - unsafe { - a = true; //~ ERROR: mismatched types - } -} diff --git a/src/test/compile-fail/static-mut-foreign-requires-unsafe.rs b/src/test/compile-fail/static-mut-foreign-requires-unsafe.rs deleted file mode 100644 index c6d744fa64d..00000000000 --- a/src/test/compile-fail/static-mut-foreign-requires-unsafe.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - static mut a: i32; -} - -fn main() { - a += 3; //~ ERROR: requires unsafe - a = 4; //~ ERROR: requires unsafe - let _b = a; //~ ERROR: requires unsafe -} diff --git a/src/test/compile-fail/static-mut-not-constant.rs b/src/test/compile-fail/static-mut-not-constant.rs deleted file mode 100644 index 7e6ced12fe6..00000000000 --- a/src/test/compile-fail/static-mut-not-constant.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -static mut a: Box = box 3; -//~^ ERROR allocations are not allowed in statics - -fn main() {} diff --git a/src/test/compile-fail/static-mut-not-pat.rs b/src/test/compile-fail/static-mut-not-pat.rs deleted file mode 100644 index 351a47fdf39..00000000000 --- a/src/test/compile-fail/static-mut-not-pat.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Constants (static variables) can be used to match in patterns, but mutable -// statics cannot. This ensures that there's some form of error if this is -// attempted. - -static mut a: isize = 3; - -fn main() { - // If they can't be matched against, then it's possible to capture the same - // name as a variable, hence this should be an unreachable pattern situation - // instead of spitting out a custom error about some identifier collisions - // (we should allow shadowing) - match 4 { - a => {} //~ ERROR match bindings cannot shadow statics - _ => {} - } -} - -struct NewBool(bool); -enum Direction { - North, - East, - South, - West -} -const NEW_FALSE: NewBool = NewBool(false); -struct Foo { - bar: Option, - baz: NewBool -} - -static mut STATIC_MUT_FOO: Foo = Foo { bar: Some(Direction::West), baz: NEW_FALSE }; - -fn mutable_statics() { - match (Foo { bar: Some(Direction::North), baz: NewBool(true) }) { - Foo { bar: None, baz: NewBool(true) } => (), - STATIC_MUT_FOO => (), - //~^ ERROR match bindings cannot shadow statics - Foo { bar: Some(Direction::South), .. } => (), - Foo { bar: Some(EAST), .. } => (), - Foo { bar: Some(Direction::North), baz: NewBool(true) } => (), - Foo { bar: Some(EAST), baz: NewBool(false) } => () - } -} diff --git a/src/test/compile-fail/static-mut-requires-unsafe.rs b/src/test/compile-fail/static-mut-requires-unsafe.rs deleted file mode 100644 index f6ad46a0527..00000000000 --- a/src/test/compile-fail/static-mut-requires-unsafe.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static mut a: isize = 3; - -fn main() { - a += 3; //~ ERROR: requires unsafe - a = 4; //~ ERROR: requires unsafe - let _b = a; //~ ERROR: requires unsafe -} diff --git a/src/test/compile-fail/static-priv-by-default.rs b/src/test/compile-fail/static-priv-by-default.rs deleted file mode 100644 index 14299a9b639..00000000000 --- a/src/test/compile-fail/static-priv-by-default.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:static_priv_by_default.rs - -extern crate static_priv_by_default; - -mod child { - pub mod childs_child { - static private: isize = 0; - pub static public: isize = 0; - } -} - -fn foo(_: isize) {} - -fn full_ref() { - foo(static_priv_by_default::private); //~ ERROR: static `private` is private - foo(static_priv_by_default::public); - foo(child::childs_child::private); //~ ERROR: static `private` is private - foo(child::childs_child::public); -} - -fn medium_ref() { - use child::childs_child; - foo(childs_child::private); //~ ERROR: static `private` is private - foo(childs_child::public); -} - -fn main() {} diff --git a/src/test/compile-fail/static-priv-by-default2.rs b/src/test/compile-fail/static-priv-by-default2.rs deleted file mode 100644 index 577e4f7542d..00000000000 --- a/src/test/compile-fail/static-priv-by-default2.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:static_priv_by_default.rs - -extern crate static_priv_by_default; - -mod child { - pub mod childs_child { - static private: isize = 0; - pub static public: isize = 0; - } -} - -fn foo(_: T) {} - -fn test1() { - use child::childs_child::private; - //~^ ERROR: static `private` is private - use child::childs_child::public; - - foo(private); -} - -fn test2() { - use static_priv_by_default::private; - //~^ ERROR: static `private` is private - use static_priv_by_default::public; - - foo(private); -} - -fn main() {} diff --git a/src/test/compile-fail/static-reference-to-fn-1.rs b/src/test/compile-fail/static-reference-to-fn-1.rs deleted file mode 100644 index cf8ee1ecb41..00000000000 --- a/src/test/compile-fail/static-reference-to-fn-1.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct A<'a> { - func: &'a fn() -> Option -} - -impl<'a> A<'a> { - fn call(&self) -> Option { - (*self.func)() - } -} - -fn foo() -> Option { - None -} - -fn create() -> A<'static> { - A { - func: &foo, //~ ERROR mismatched types - } -} - -fn main() { - let a = create(); - a.call(); -} diff --git a/src/test/compile-fail/static-reference-to-fn-2.rs b/src/test/compile-fail/static-reference-to-fn-2.rs deleted file mode 100644 index 8d9f442b81d..00000000000 --- a/src/test/compile-fail/static-reference-to-fn-2.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn id(x: T) -> T { x } - -struct StateMachineIter<'a> { - statefn: &'a StateMachineFunc<'a> -} - -type StateMachineFunc<'a> = fn(&mut StateMachineIter<'a>) -> Option<&'static str>; - -impl<'a> Iterator for StateMachineIter<'a> { - type Item = &'static str; - - fn next(&mut self) -> Option<&'static str> { - return (*self.statefn)(self); - } -} - -fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { - self_.statefn = &id(state2 as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough - return Some("state1"); -} - -fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { - self_.statefn = &id(state3 as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough - return Some("state2"); -} - -fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { - self_.statefn = &id(finished as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough - return Some("state3"); -} - -fn finished(_: &mut StateMachineIter) -> Option<(&'static str)> { - return None; -} - -fn state_iter() -> StateMachineIter<'static> { - StateMachineIter { - statefn: &id(state1 as StateMachineFunc) - //~^ ERROR borrowed value does not live long enough - } -} - - -fn main() { - let mut it = state_iter(); - println!("{:?}",it.next()); - println!("{:?}",it.next()); - println!("{:?}",it.next()); - println!("{:?}",it.next()); - println!("{:?}",it.next()); -} diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs deleted file mode 100644 index 90ed401659c..00000000000 --- a/src/test/compile-fail/static-region-bound.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -fn id(x: T) -> T { x } - -fn f(_: T) {} - -fn main() { - let x: Box<_> = box 3; - f(x); - let x = &id(3); //~ ERROR borrowed value does not live long enough - f(x); -} diff --git a/src/test/compile-fail/static-vec-repeat-not-constant.rs b/src/test/compile-fail/static-vec-repeat-not-constant.rs deleted file mode 100644 index a533a5bd54d..00000000000 --- a/src/test/compile-fail/static-vec-repeat-not-constant.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo() -> isize { 23 } - -static a: [isize; 2] = [foo(); 2]; -//~^ ERROR: E0015 - -fn main() {} diff --git a/src/test/compile-fail/staticness-mismatch.rs b/src/test/compile-fail/staticness-mismatch.rs deleted file mode 100644 index 2dfc9b79ee2..00000000000 --- a/src/test/compile-fail/staticness-mismatch.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait foo { - fn dummy(&self) { } - fn bar(); -} - -impl foo for isize { - fn bar(&self) {} - //~^ ERROR method `bar` has a `&self` declaration in the impl, but not in the trait -} - -fn main() {} diff --git a/src/test/compile-fail/std-uncopyable-atomics.rs b/src/test/compile-fail/std-uncopyable-atomics.rs deleted file mode 100644 index 35877db610e..00000000000 --- a/src/test/compile-fail/std-uncopyable-atomics.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #8380 - - -use std::sync::atomic::*; -use std::ptr; - -fn main() { - let x = AtomicBool::new(false); - let x = *&x; //~ ERROR: cannot move out of borrowed content - let x = AtomicIsize::new(0); - let x = *&x; //~ ERROR: cannot move out of borrowed content - let x = AtomicUsize::new(0); - let x = *&x; //~ ERROR: cannot move out of borrowed content - let x: AtomicPtr = AtomicPtr::new(ptr::null_mut()); - let x = *&x; //~ ERROR: cannot move out of borrowed content -} diff --git a/src/test/compile-fail/stmt_expr_attrs_no_feature.rs b/src/test/compile-fail/stmt_expr_attrs_no_feature.rs deleted file mode 100644 index 896817bb858..00000000000 --- a/src/test/compile-fail/stmt_expr_attrs_no_feature.rs +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(custom_attribute)] - -macro_rules! stmt_mac { - () => { - fn b() {} - } -} - -fn main() { - #[attr] - fn a() {} - - #[attr] //~ ERROR attributes on expressions are experimental - { - - } - - #[attr] - 5; - - #[attr] - stmt_mac!(); -} - -// Check that cfg works right - -#[cfg(unset)] -fn c() { - #[attr] - 5; -} - -#[cfg(not(unset))] -fn j() { - #[attr] - 5; -} - -#[cfg_attr(not(unset), cfg(unset))] -fn d() { - #[attr] - 8; -} - -#[cfg_attr(not(unset), cfg(not(unset)))] -fn i() { - #[attr] - 8; -} - -// check that macro expansion and cfg works right - -macro_rules! item_mac { - ($e:ident) => { - fn $e() { - #[attr] - 42; - - #[cfg(unset)] - fn f() { - #[attr] - 5; - } - - #[cfg(not(unset))] - fn k() { - #[attr] - 5; - } - - #[cfg_attr(not(unset), cfg(unset))] - fn g() { - #[attr] - 8; - } - - #[cfg_attr(not(unset), cfg(not(unset)))] - fn h() { - #[attr] - 8; - } - - } - } -} - -item_mac!(e); - -// check that the gate visitor works right: - -extern { - #[cfg(unset)] - fn x(a: [u8; #[attr] 5]); - fn y(a: [u8; #[attr] 5]); //~ ERROR 15701 -} - -struct Foo; -impl Foo { - #[cfg(unset)] - const X: u8 = #[attr] 5; - const Y: u8 = #[attr] 5; //~ ERROR 15701 -} - -trait Bar { - #[cfg(unset)] - const X: [u8; #[attr] 5]; - const Y: [u8; #[attr] 5]; //~ ERROR 15701 -} - -struct Joyce { - #[cfg(unset)] - field: [u8; #[attr] 5], - field2: [u8; #[attr] 5] //~ ERROR 15701 -} - -struct Walky( - #[cfg(unset)] [u8; #[attr] 5], - [u8; #[attr] 5] //~ ERROR 15701 -); - -enum Mike { - Happy( - #[cfg(unset)] [u8; #[attr] 5], - [u8; #[attr] 5] //~ ERROR 15701 - ), - Angry { - #[cfg(unset)] - field: [u8; #[attr] 5], - field2: [u8; #[attr] 5] //~ ERROR 15701 - } -} - -fn pat() { - match 5 { - #[cfg(unset)] - 5 => #[attr] (), - 6 => #[attr] (), //~ ERROR 15701 - _ => (), - } -} diff --git a/src/test/compile-fail/str-idx.rs b/src/test/compile-fail/str-idx.rs deleted file mode 100644 index b5f1ffb977e..00000000000 --- a/src/test/compile-fail/str-idx.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - let s: &str = "hello"; - let c: u8 = s[4]; //~ ERROR the type `str` cannot be indexed by `{integer}` -} diff --git a/src/test/compile-fail/str-mut-idx.rs b/src/test/compile-fail/str-mut-idx.rs deleted file mode 100644 index 136bfaefa71..00000000000 --- a/src/test/compile-fail/str-mut-idx.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn bot() -> T { loop {} } - -fn mutate(s: &mut str) { - s[1..2] = bot(); - //~^ ERROR the size for values of type - //~| ERROR the size for values of type - s[1usize] = bot(); - //~^ ERROR the type `str` cannot be mutably indexed by `usize` -} - -pub fn main() {} diff --git a/src/test/compile-fail/struct-base-wrong-type-2.rs b/src/test/compile-fail/struct-base-wrong-type-2.rs deleted file mode 100644 index 7e5510edb2c..00000000000 --- a/src/test/compile-fail/struct-base-wrong-type-2.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that `base` in `Fru { field: expr, ..base }` must have right type. -// -// See also struct-base-wrong-type.rs, which tests same condition -// within a const expression. - -struct Foo { a: isize, b: isize } -struct Bar { x: isize } - -fn main() { - let b = Bar { x: 5 }; - let f = Foo { a: 2, ..b }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `Bar` - //~| expected struct `Foo`, found struct `Bar` - let f__isize = Foo { a: 2, ..4 }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `{integer}` - //~| expected struct `Foo`, found integral variable -} diff --git a/src/test/compile-fail/struct-base-wrong-type.rs b/src/test/compile-fail/struct-base-wrong-type.rs deleted file mode 100644 index 3703b15d4db..00000000000 --- a/src/test/compile-fail/struct-base-wrong-type.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that `base` in `Fru { field: expr, ..base }` must have right type. -// -// See also struct-base-wrong-type-2.rs, which tests same condition -// within a function body. - -struct Foo { a: isize, b: isize } -struct Bar { x: isize } - -static bar: Bar = Bar { x: 5 }; -static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `Bar` - //~| expected struct `Foo`, found struct `Bar` -static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types - //~| expected type `Foo` - //~| found type `{integer}` - //~| expected struct `Foo`, found integral variable - -fn main() { - let b = Bar { x: 5 }; - // errors below are no longer caught since error above causes - // compilation to abort before we bother checking function bodies. - // See also struct-base-wrong-type-2.rs, which checks that we - // would catch these errors eventually. - let f = Foo { a: 2, ..b }; - let f__isize = Foo { a: 2, ..4 }; -} diff --git a/src/test/compile-fail/struct-field-cfg.rs b/src/test/compile-fail/struct-field-cfg.rs deleted file mode 100644 index 974d500d9cb..00000000000 --- a/src/test/compile-fail/struct-field-cfg.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - present: (), -} - -fn main() { - let foo = Foo { #[cfg(all())] present: () }; - let _ = Foo { #[cfg(any())] present: () }; - //~^ ERROR missing field `present` in initializer of `Foo` - let _ = Foo { present: (), #[cfg(any())] absent: () }; - let _ = Foo { present: (), #[cfg(all())] absent: () }; - //~^ ERROR struct `Foo` has no field named `absent` - let Foo { #[cfg(all())] present: () } = foo; - let Foo { #[cfg(any())] present: () } = foo; - //~^ ERROR pattern does not mention field `present` - let Foo { present: (), #[cfg(any())] absent: () } = foo; - let Foo { present: (), #[cfg(all())] absent: () } = foo; - //~^ ERROR struct `Foo` does not have a field named `absent` -} diff --git a/src/test/compile-fail/struct-field-privacy.rs b/src/test/compile-fail/struct-field-privacy.rs deleted file mode 100644 index f487ef62aa4..00000000000 --- a/src/test/compile-fail/struct-field-privacy.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:struct_field_privacy.rs - -extern crate struct_field_privacy as xc; - -struct A { - a: isize, -} - -mod inner { - pub struct A { - a: isize, - pub b: isize, - } - pub struct B { - pub a: isize, - b: isize, - } - pub struct Z(pub isize, isize); -} - -fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B, z: inner::Z) { - a.a; - b.a; //~ ERROR: field `a` of struct `inner::A` is private - b.b; - c.a; - c.b; //~ ERROR: field `b` of struct `inner::B` is private - - d.a; //~ ERROR: field `a` of struct `xc::A` is private - d.b; - - e.a; - e.b; //~ ERROR: field `b` of struct `xc::B` is private - - z.0; - z.1; //~ ERROR: field `1` of struct `inner::Z` is private -} - -fn main() {} diff --git a/src/test/compile-fail/struct-fields-dupe.rs b/src/test/compile-fail/struct-fields-dupe.rs deleted file mode 100644 index 578091f5e9a..00000000000 --- a/src/test/compile-fail/struct-fields-dupe.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct BuildData { - foo: isize, -} - -fn main() { - let foo = BuildData { - foo: 0, - foo: 0 //~ ERROR field `foo` specified more than once - }; -} diff --git a/src/test/compile-fail/struct-fields-missing.rs b/src/test/compile-fail/struct-fields-missing.rs deleted file mode 100644 index d5ab13affaf..00000000000 --- a/src/test/compile-fail/struct-fields-missing.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct BuildData { - foo: isize, - bar: Box, -} - -fn main() { - let foo = BuildData { //~ ERROR missing field `bar` in initializer of `BuildData` - foo: 0 - }; -} diff --git a/src/test/compile-fail/struct-fields-shorthand-unresolved.rs b/src/test/compile-fail/struct-fields-shorthand-unresolved.rs deleted file mode 100644 index 984f337fb3d..00000000000 --- a/src/test/compile-fail/struct-fields-shorthand-unresolved.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - x: i32, - y: i32 -} - -fn main() { - let x = 0; - let foo = Foo { - x, - y //~ ERROR cannot find value `y` in this scope - }; -} diff --git a/src/test/compile-fail/struct-fields-shorthand.rs b/src/test/compile-fail/struct-fields-shorthand.rs deleted file mode 100644 index e46ae73f1a1..00000000000 --- a/src/test/compile-fail/struct-fields-shorthand.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - x: i32, - y: i32 -} - -fn main() { - let (x, y, z) = (0, 1, 2); - let foo = Foo { - x, y, z //~ ERROR struct `Foo` has no field named `z` - }; -} - diff --git a/src/test/compile-fail/struct-fields-typo.rs b/src/test/compile-fail/struct-fields-typo.rs deleted file mode 100644 index 0e30c1e86e4..00000000000 --- a/src/test/compile-fail/struct-fields-typo.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct BuildData { - foo: isize, - bar: f32 -} - -fn main() { - let foo = BuildData { - foo: 0, - bar: 0.5, - }; - let x = foo.baa;//~ no field `baa` on type `BuildData` - //~^ did you mean `bar`? - println!("{}", x); -} diff --git a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs b/src/test/compile-fail/struct-like-enum-nonexhaustive.rs deleted file mode 100644 index a14e43f4c94..00000000000 --- a/src/test/compile-fail/struct-like-enum-nonexhaustive.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum A { - B { x: Option }, - C -} - -fn main() { - let x = A::B { x: Some(3) }; - match x { //~ ERROR non-exhaustive patterns - A::C => {} - A::B { x: None } => {} - } -} diff --git a/src/test/compile-fail/struct-pat-derived-error.rs b/src/test/compile-fail/struct-pat-derived-error.rs deleted file mode 100644 index d3130c4e831..00000000000 --- a/src/test/compile-fail/struct-pat-derived-error.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct a { - b: usize, - c: usize -} - -impl a { - fn foo(&self) { - let a { x, y } = self.d; //~ ERROR no field `d` on type `&a` - //~^ ERROR struct `a` does not have fields named `x`, `y` - //~| ERROR pattern does not mention fields `b`, `c` - } -} - -fn main() {} diff --git a/src/test/compile-fail/struct-path-alias-bounds.rs b/src/test/compile-fail/struct-path-alias-bounds.rs deleted file mode 100644 index 1b6e51e3703..00000000000 --- a/src/test/compile-fail/struct-path-alias-bounds.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// issue #36286 - -struct S { a: T } - -struct NoClone; -type A = S; - -fn main() { - let s = A { a: NoClone }; - //~^ ERROR the trait bound `NoClone: std::clone::Clone` is not satisfied -} diff --git a/src/test/compile-fail/struct-path-associated-type.rs b/src/test/compile-fail/struct-path-associated-type.rs deleted file mode 100644 index 660ac44ce0b..00000000000 --- a/src/test/compile-fail/struct-path-associated-type.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S; - -trait Tr { - type A; -} - -impl Tr for S { - type A = S; -} - -fn f() { - let s = T::A {}; - //~^ ERROR expected struct, variant or union type, found associated type - let z = T::A:: {}; - //~^ ERROR expected struct, variant or union type, found associated type - //~| ERROR type parameters are not allowed on this type - match S { - T::A {} => {} - //~^ ERROR expected struct, variant or union type, found associated type - } -} - -fn g>() { - let s = T::A {}; // OK - let z = T::A:: {}; //~ ERROR type parameters are not allowed on this type - match S { - T::A {} => {} // OK - } -} - -fn main() { - let s = S::A {}; //~ ERROR ambiguous associated type - let z = S::A:: {}; //~ ERROR ambiguous associated type - //~^ ERROR type parameters are not allowed on this type - match S { - S::A {} => {} //~ ERROR ambiguous associated type - } -} diff --git a/src/test/compile-fail/struct-path-self.rs b/src/test/compile-fail/struct-path-self.rs deleted file mode 100644 index 067d6ac22dc..00000000000 --- a/src/test/compile-fail/struct-path-self.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S; - -trait Tr { - fn f() { - let s = Self {}; - //~^ ERROR expected struct, variant or union type, found Self - let z = Self:: {}; - //~^ ERROR expected struct, variant or union type, found Self - //~| ERROR type parameters are not allowed on this type - match s { - Self { .. } => {} - //~^ ERROR expected struct, variant or union type, found Self - } - } -} - -impl Tr for S { - fn f() { - let s = Self {}; // OK - let z = Self:: {}; //~ ERROR type parameters are not allowed on this type - match s { - Self { .. } => {} // OK - } - } -} - -impl S { - fn g() { - let s = Self {}; // OK - let z = Self:: {}; //~ ERROR type parameters are not allowed on this type - match s { - Self { .. } => {} // OK - } - } -} - -fn main() {} diff --git a/src/test/compile-fail/struct-pattern-match-useless.rs b/src/test/compile-fail/struct-pattern-match-useless.rs deleted file mode 100644 index dda30141b4a..00000000000 --- a/src/test/compile-fail/struct-pattern-match-useless.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unreachable_patterns)] - -struct Foo { - x: isize, - y: isize, -} - -pub fn main() { - let a = Foo { x: 1, y: 2 }; - match a { - Foo { x: _x, y: _y } => (), - Foo { .. } => () //~ ERROR unreachable pattern - } - -} diff --git a/src/test/compile-fail/struct-variant-privacy-xc.rs b/src/test/compile-fail/struct-variant-privacy-xc.rs deleted file mode 100644 index 8507acd26ce..00000000000 --- a/src/test/compile-fail/struct-variant-privacy-xc.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:struct_variant_privacy.rs -extern crate struct_variant_privacy; - -fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private - match b { - struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private - } -} - -fn main() {} diff --git a/src/test/compile-fail/struct-variant-privacy.rs b/src/test/compile-fail/struct-variant-privacy.rs deleted file mode 100644 index 7de4ca62555..00000000000 --- a/src/test/compile-fail/struct-variant-privacy.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -mod foo { - enum Bar { - Baz { a: isize } - } -} - -fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private - match b { - foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private - } -} - -fn main() {} diff --git a/src/test/compile-fail/structure-constructor-type-mismatch.rs b/src/test/compile-fail/structure-constructor-type-mismatch.rs deleted file mode 100644 index 87fc5ba93ae..00000000000 --- a/src/test/compile-fail/structure-constructor-type-mismatch.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Point { - x: T, - y: T, -} - -type PointF = Point; - -struct Pair { - x: T, - y: U, -} - -type PairF = Pair; - -fn main() { - let pt = PointF { - x: 1, - //~^ ERROR mismatched types - //~| expected f32, found integral variable - y: 2, - //~^ ERROR mismatched types - //~| expected f32, found integral variable - }; - - let pt2 = Point:: { - x: 3, - //~^ ERROR mismatched types - //~| expected f32, found integral variable - y: 4, - //~^ ERROR mismatched types - //~| expected f32, found integral variable - }; - - let pair = PairF { - x: 5, - //~^ ERROR mismatched types - //~| expected f32, found integral variable - y: 6, - }; - - let pair2 = PairF:: { - x: 7, - //~^ ERROR mismatched types - //~| expected f32, found integral variable - y: 8, - }; - - let pt3 = PointF:: { //~ ERROR wrong number of type arguments - x: 9, //~ ERROR mismatched types - y: 10, //~ ERROR mismatched types - }; - - match (Point { x: 1, y: 2 }) { - PointF:: { .. } => {} //~ ERROR wrong number of type arguments - //~^ ERROR mismatched types - } - - match (Point { x: 1, y: 2 }) { - PointF { .. } => {} //~ ERROR mismatched types - } - - match (Point { x: 1.0, y: 2.0 }) { - PointF { .. } => {} // ok - } - - match (Pair { x: 1, y: 2 }) { - PairF:: { .. } => {} //~ ERROR mismatched types - } - - match (Pair { x: 1.0, y: 2 }) { - PairF:: { .. } => {} // ok - } -} diff --git a/src/test/compile-fail/substs-ppaux.rs b/src/test/compile-fail/substs-ppaux.rs deleted file mode 100644 index d0e9a7f4a40..00000000000 --- a/src/test/compile-fail/substs-ppaux.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// revisions: verbose normal -// -//[verbose] compile-flags: -Z verbose - -trait Foo<'b, 'c, S=u32> { - fn bar<'a, T>() where T: 'a {} - fn baz() {} -} - -impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} - -fn main() {} - -fn foo<'z>() where &'z (): Sized { - let x: () = >::bar::<'static, char>; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected type `()` - //[verbose]~| found type `fn() {>::bar::}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected type `()` - //[normal]~| found type `fn() {>::bar::<'static, char>}` - - - let x: () = >::bar::<'static, char>; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected type `()` - //[verbose]~| found type `fn() {>::bar::}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected type `()` - //[normal]~| found type `fn() {>::bar::<'static, char>}` - - let x: () = >::baz; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected type `()` - //[verbose]~| found type `fn() {>::baz}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected type `()` - //[normal]~| found type `fn() {>::baz}` - - let x: () = foo::<'static>; - //[verbose]~^ ERROR mismatched types - //[verbose]~| expected type `()` - //[verbose]~| found type `fn() {foo::}` - //[normal]~^^^^ ERROR mismatched types - //[normal]~| expected type `()` - //[normal]~| found type `fn() {foo::<'static>}` - - >::bar; - //[verbose]~^ ERROR the size for values of type - //[normal]~^^ ERROR the size for values of type -} diff --git a/src/test/compile-fail/suffixed-literal-meta.rs b/src/test/compile-fail/suffixed-literal-meta.rs deleted file mode 100644 index bf55b7bdcb1..00000000000 --- a/src/test/compile-fail/suffixed-literal-meta.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(attr_literals)] - -#[path = 1usize] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1u8] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1u16] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1u32] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1u64] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1isize] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1i8] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1i16] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1i32] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1i64] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes -#[path = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes -fn main() { } diff --git a/src/test/compile-fail/super-at-top-level.rs b/src/test/compile-fail/super-at-top-level.rs deleted file mode 100644 index c607711c44f..00000000000 --- a/src/test/compile-fail/super-at-top-level.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::f; //~ ERROR There are too many initial `super`s - -fn main() { -} diff --git a/src/test/compile-fail/suppressed-error.rs b/src/test/compile-fail/suppressed-error.rs deleted file mode 100644 index 9a4a52ced20..00000000000 --- a/src/test/compile-fail/suppressed-error.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let (x, y) = (); -//~^ ERROR mismatched types -//~| expected type `()` -//~| found type `(_, _)` -//~| expected (), found tuple - return x; -} diff --git a/src/test/compile-fail/symbol-names/basic.rs b/src/test/compile-fail/symbol-names/basic.rs deleted file mode 100644 index 0095774fcb8..00000000000 --- a/src/test/compile-fail/symbol-names/basic.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -#[rustc_symbol_name] //~ ERROR _ZN5basic4main -#[rustc_item_path] //~ ERROR item-path(main) -fn main() { -} diff --git a/src/test/compile-fail/symbol-names/impl1.rs b/src/test/compile-fail/symbol-names/impl1.rs deleted file mode 100644 index 93fa48b880f..00000000000 --- a/src/test/compile-fail/symbol-names/impl1.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod foo { - pub struct Foo { x: u32 } - - impl Foo { - #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar - #[rustc_item_path] //~ ERROR item-path(foo::Foo::bar) - fn bar() { } - } -} - -mod bar { - use foo::Foo; - - impl Foo { - #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz - #[rustc_item_path] //~ ERROR item-path(bar::::baz) - fn baz() { } - } -} - -fn main() { -} diff --git a/src/test/compile-fail/syntax-extension-minor.rs b/src/test/compile-fail/syntax-extension-minor.rs deleted file mode 100644 index 96adfea43f3..00000000000 --- a/src/test/compile-fail/syntax-extension-minor.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(concat_idents)] - -pub fn main() { - struct Foo; - let _: concat_idents!(F, oo) = Foo; // Test that `concat_idents!` can be used in type positions - - let asdf_fdsa = "<.<".to_string(); - // this now fails (correctly, I claim) because hygiene prevents - // the assembled identifier from being a reference to the binding. - assert!(concat_idents!(asd, f_f, dsa) == "<.<".to_string()); - //~^ ERROR cannot find value `asdf_fdsa` in this scope - - assert_eq!(stringify!(use_mention_distinction), "use_mention_distinction"); -} diff --git a/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs b/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs deleted file mode 100644 index 8d5e89cc66f..00000000000 --- a/src/test/compile-fail/syntax-trait-polarity-feature-gate.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker::Send; - -struct TestType; - -trait TestTrait {} - -impl !Send for TestType {} -//~^ ERROR negative trait bounds - -fn main() {} diff --git a/src/test/compile-fail/syntax-trait-polarity.rs b/src/test/compile-fail/syntax-trait-polarity.rs deleted file mode 100644 index 1a5d058cb9a..00000000000 --- a/src/test/compile-fail/syntax-trait-polarity.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -struct TestType; - -impl !TestType {} -//~^ ERROR inherent impls cannot be negative - -trait TestTrait {} - -unsafe impl !Send for TestType {} -//~^ ERROR negative impls cannot be unsafe -impl !TestTrait for TestType {} -//~^ ERROR negative impls are only allowed for auto traits - -struct TestType2(T); - -impl !TestType2 {} -//~^ ERROR inherent impls cannot be negative - -unsafe impl !Send for TestType2 {} -//~^ ERROR negative impls cannot be unsafe -impl !TestTrait for TestType2 {} -//~^ ERROR negative impls are only allowed for auto traits - -fn main() {} diff --git a/src/test/compile-fail/synthetic-param.rs b/src/test/compile-fail/synthetic-param.rs deleted file mode 100644 index 337cae1369e..00000000000 --- a/src/test/compile-fail/synthetic-param.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -fn func<#[rustc_synthetic] T>(_: T) {} - -struct Foo; - -impl Foo { - pub fn func<#[rustc_synthetic] T>(_: T) {} -} - -struct Bar { - t: S -} - -impl Bar { - pub fn func<#[rustc_synthetic] T>(_: T) {} -} - -fn main() { - func::(42); //~ ERROR cannot provide explicit type parameters - func(42); // Ok - - Foo::func::(42); //~ ERROR cannot provide explicit type parameters - Foo::func(42); // Ok - - Bar::::func::(42); //~ ERROR cannot provide explicit type parameters - Bar::::func(42); // Ok -} diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs deleted file mode 100644 index 8f420f1ce4b..00000000000 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #876 - -#![no_implicit_prelude] -use std::vec::Vec; - -fn last(v: Vec<&T> ) -> std::option::Option { - panic!(); -} - -fn main() { - let y; - let x : char = last(y); - //~^ ERROR mismatched types - //~| expected type `char` - //~| found type `std::option::Option<_>` - //~| expected char, found enum `std::option::Option` -} diff --git a/src/test/compile-fail/tag-type-args.rs b/src/test/compile-fail/tag-type-args.rs deleted file mode 100644 index 5785a13b006..00000000000 --- a/src/test/compile-fail/tag-type-args.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:wrong number of type arguments - -enum quux { bar } - -fn foo(c: quux) { assert!((false)); } - -fn main() { panic!(); } diff --git a/src/test/compile-fail/tag-variant-cast-non-nullary.rs b/src/test/compile-fail/tag-variant-cast-non-nullary.rs deleted file mode 100644 index 220537633ea..00000000000 --- a/src/test/compile-fail/tag-variant-cast-non-nullary.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum non_nullary { - nullary, - other(isize), -} - -fn main() { - let v = non_nullary::nullary; - let val = v as isize; //~ ERROR non-primitive cast: `non_nullary` as `isize` [E0605] -} diff --git a/src/test/compile-fail/tag-variant-disr-dup.rs b/src/test/compile-fail/tag-variant-disr-dup.rs deleted file mode 100644 index 5da5bb85409..00000000000 --- a/src/test/compile-fail/tag-variant-disr-dup.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//error-pattern:discriminant value - -// black and white have the same discriminator value ... - -enum color { - red = 0xff0000, - green = 0x00ff00, - blue = 0x0000ff, - black = 0x000000, - white = 0x000000, -} - -fn main() { } diff --git a/src/test/compile-fail/tail-typeck.rs b/src/test/compile-fail/tail-typeck.rs deleted file mode 100644 index 5c1270aa0e4..00000000000 --- a/src/test/compile-fail/tail-typeck.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -fn f() -> isize { return g(); } - -fn g() -> usize { return 0; } - -fn main() { let y = f(); } diff --git a/src/test/compile-fail/terr-in-field.rs b/src/test/compile-fail/terr-in-field.rs deleted file mode 100644 index 4a21e133981..00000000000 --- a/src/test/compile-fail/terr-in-field.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct foo { - a: isize, - b: isize, -} - -struct bar { - a: isize, - b: usize, -} - -fn want_foo(f: foo) {} -fn have_bar(b: bar) { - want_foo(b); //~ ERROR mismatched types - //~| expected type `foo` - //~| found type `bar` - //~| expected struct `foo`, found struct `bar` -} - -fn main() {} diff --git a/src/test/compile-fail/terr-sorts.rs b/src/test/compile-fail/terr-sorts.rs deleted file mode 100644 index fd92a26d0fc..00000000000 --- a/src/test/compile-fail/terr-sorts.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -struct foo { - a: isize, - b: isize, -} - -type bar = Box; - -fn want_foo(f: foo) {} -fn have_bar(b: bar) { - want_foo(b); //~ ERROR mismatched types - //~| expected type `foo` - //~| found type `std::boxed::Box` -} - -fn main() {} diff --git a/src/test/compile-fail/test-cfg.rs b/src/test/compile-fail/test-cfg.rs deleted file mode 100644 index 71cae0b6df9..00000000000 --- a/src/test/compile-fail/test-cfg.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --cfg foo - -#[cfg(all(foo, bar))] // foo AND bar -fn foo() {} - -fn main() { - foo(); //~ ERROR cannot find function `foo` in this scope -} diff --git a/src/test/compile-fail/test-warns-dead-code.rs b/src/test/compile-fail/test-warns-dead-code.rs deleted file mode 100644 index 0e25f1e965a..00000000000 --- a/src/test/compile-fail/test-warns-dead-code.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: --test - -#![deny(dead_code)] - -fn dead() {} //~ error: function is never used: `dead` - -fn main() {} diff --git a/src/test/compile-fail/thread-local-in-ctfe.rs b/src/test/compile-fail/thread-local-in-ctfe.rs deleted file mode 100644 index 62e26f28b06..00000000000 --- a/src/test/compile-fail/thread-local-in-ctfe.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(const_fn, thread_local)] - -#[thread_local] -static A: u32 = 1; - -static B: u32 = A; -//~^ ERROR thread-local statics cannot be accessed at compile-time - -static C: &u32 = &A; -//~^ ERROR thread-local statics cannot be accessed at compile-time - -const D: u32 = A; -//~^ ERROR thread-local statics cannot be accessed at compile-time - -const E: &u32 = &A; -//~^ ERROR thread-local statics cannot be accessed at compile-time - -const fn f() -> u32 { - A - //~^ ERROR thread-local statics cannot be accessed at compile-time -} - -fn main() {} diff --git a/src/test/compile-fail/tool_lints.rs b/src/test/compile-fail/tool_lints.rs deleted file mode 100644 index ea1efab4cb6..00000000000 --- a/src/test/compile-fail/tool_lints.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Don't allow tool_lints, which aren't scoped - -#![feature(tool_lints)] -#![deny(unknown_lints)] - -#![deny(clippy)] //~ ERROR: unknown lint: `clippy` - -fn main() {} diff --git a/src/test/compile-fail/trace_macros-format.rs b/src/test/compile-fail/trace_macros-format.rs deleted file mode 100644 index 95cb17c215b..00000000000 --- a/src/test/compile-fail/trace_macros-format.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(trace_macros)] - -fn main() { - trace_macros!(); //~ ERROR trace_macros! accepts only `true` or `false` - trace_macros!(1); //~ ERROR trace_macros! accepts only `true` or `false` - trace_macros!(ident); //~ ERROR trace_macros! accepts only `true` or `false` - trace_macros!(for); //~ ERROR trace_macros! accepts only `true` or `false` - trace_macros!(true,); //~ ERROR trace_macros! accepts only `true` or `false` - trace_macros!(false 1); //~ ERROR trace_macros! accepts only `true` or `false` - - - // should be fine: - macro_rules! expando { - ($x: ident) => { trace_macros!($x) } - } - - expando!(true); -} diff --git a/src/test/compile-fail/trace_macros-gate.rs b/src/test/compile-fail/trace_macros-gate.rs deleted file mode 100644 index d4a7c4ed0e0..00000000000 --- a/src/test/compile-fail/trace_macros-gate.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the trace_macros feature gate is on. - -fn main() { - trace_macros!(); //~ ERROR `trace_macros` is not stable - trace_macros!(1); //~ ERROR `trace_macros` is not stable - trace_macros!(ident); //~ ERROR `trace_macros` is not stable - trace_macros!(for); //~ ERROR `trace_macros` is not stable - trace_macros!(true,); //~ ERROR `trace_macros` is not stable - trace_macros!(false 1); //~ ERROR `trace_macros` is not stable - - // Errors are signalled early for the above, before expansion. - // See trace_macros-gate2 and trace_macros-gate3. for examples - // of the below being caught. - - macro_rules! expando { - ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable - } - - expando!(true); -} diff --git a/src/test/compile-fail/trait-alias.rs b/src/test/compile-fail/trait-alias.rs deleted file mode 100644 index 7aca227a76c..00000000000 --- a/src/test/compile-fail/trait-alias.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// gate-test-trait_alias - -trait Alias1 = Default where T: Clone; // ok - //~^ERROR trait aliases are not yet fully implemented -trait Alias2 = Default; - //~^ERROR type parameters on the left side of a trait alias cannot be bounded - //~^^ERROR type parameters on the left side of a trait alias cannot have defaults - //~^^^ERROR trait aliases are not yet fully implemented - -impl Alias1 { //~ERROR expected type, found trait alias -} - -impl Alias1 for () { //~ERROR expected trait, found trait alias -} - -fn main() {} - diff --git a/src/test/compile-fail/trait-as-struct-constructor.rs b/src/test/compile-fail/trait-as-struct-constructor.rs deleted file mode 100644 index 49d58580da5..00000000000 --- a/src/test/compile-fail/trait-as-struct-constructor.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait TraitNotAStruct {} - -fn main() { - TraitNotAStruct{ value: 0 }; - //~^ ERROR expected struct, variant or union type, found trait `TraitNotAStruct` -} diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs deleted file mode 100644 index 9c38d8a9e2a..00000000000 --- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -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 -} - -fn main() { } diff --git a/src/test/compile-fail/trait-bounds-not-on-struct.rs b/src/test/compile-fail/trait-bounds-not-on-struct.rs deleted file mode 100644 index 76bbca60658..00000000000 --- a/src/test/compile-fail/trait-bounds-not-on-struct.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(bare_trait_objects)] - -struct Foo; - -fn foo(_x: Box) { } //~ ERROR expected trait, found struct `Foo` - -type A = Box>; //~ ERROR expected trait, found struct `Vec` - -fn main() { } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs deleted file mode 100644 index 6a271a7b749..00000000000 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait {} - -struct Foo { - x: T, -} - -enum Bar { - ABar(isize), - BBar(T), - CBar(usize), -} - -fn explode(x: Foo) {} -//~^ ERROR E0277 - -fn kaboom(y: Bar) {} -//~^ ERROR E0277 - -fn main() { -} diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs deleted file mode 100644 index 77abe6f7f74..00000000000 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait {} - -struct Foo { - x: T, -} - -enum Bar { - ABar(isize), - BBar(T), - CBar(usize), -} - -trait PolyTrait -{ - fn whatever(&self, t: T) {} -} - -struct Struct; - -impl PolyTrait> for Struct { -//~^ ERROR E0277 -} - -fn main() { -} diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs deleted file mode 100644 index 9e680d17fb9..00000000000 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait { - fn dummy(&self) { } -} - -struct Foo { - x: T, -} - -fn main() { - let foo = Foo { - //~^ ERROR E0277 - x: 3 - }; - - let baz: Foo = loop { }; - //~^ ERROR E0277 -} diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs deleted file mode 100644 index 2b59fdcae35..00000000000 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait { - fn dummy(&self) { } -} - -struct Foo { - x: T, -} - -static X: Foo = Foo { -//~^ ERROR E0277 - x: 1, -}; - -fn main() { -} diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs deleted file mode 100644 index 975de00d02a..00000000000 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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) {} -//~^ ERROR E0277 - -fn kaboom(y: Bar) {} -//~^ ERROR E0277 - -fn main() { -} diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs deleted file mode 100644 index 515684bcf42..00000000000 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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 = return; - //~^ ERROR E0277 - let _ = bar; -} diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs deleted file mode 100644 index 24e2418e8d4..00000000000 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait {} - -struct Foo { - x: T, -} - -enum Bar { - ABar(isize), - BBar(T), - CBar(usize), -} - -impl Foo { -//~^ ERROR `T: Trait` is not satisfied - fn uhoh() {} -} - -struct Baz { - a: Foo, //~ ERROR E0277 -} - -enum Boo { - Quux(Bar), //~ ERROR E0277 -} - -struct Badness { - b: Foo, //~ ERROR E0277 -} - -enum MoreBadness { - EvenMoreBadness(Bar), //~ ERROR E0277 -} - -struct TupleLike( - Foo, //~ ERROR E0277 -); - -enum Enum { - DictionaryLike { field: Bar }, //~ ERROR E0277 -} - -fn main() { -} diff --git a/src/test/compile-fail/trait-bounds-sugar.rs b/src/test/compile-fail/trait-bounds-sugar.rs deleted file mode 100644 index 0a36fcbed69..00000000000 --- a/src/test/compile-fail/trait-bounds-sugar.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests for "default" bounds inferred for traits with no bounds list. - -trait Foo {} - -fn a(_x: Box) { -} - -fn b(_x: &'static (Foo+'static)) { -} - -fn c(x: Box) { - a(x); //~ ERROR mismatched types -} - -fn d(x: &'static (Foo+Sync)) { - b(x); -} - -fn main() {} diff --git a/src/test/compile-fail/trait-coercion-generic-bad.rs b/src/test/compile-fail/trait-coercion-generic-bad.rs deleted file mode 100644 index 3839e90ed9f..00000000000 --- a/src/test/compile-fail/trait-coercion-generic-bad.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Struct { - person: &'static str -} - -trait Trait { - 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> = Box::new(Struct { person: "Fred" }); - //~^ ERROR `Struct: Trait` is not satisfied - s.f(1); -} diff --git a/src/test/compile-fail/trait-coercion-generic-regions.rs b/src/test/compile-fail/trait-coercion-generic-regions.rs deleted file mode 100644 index 18d3ded77f8..00000000000 --- a/src/test/compile-fail/trait-coercion-generic-regions.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Struct { - person: &'static str -} - -trait Trait { - 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> = Box::new(Struct { person: person }); -} diff --git a/src/test/compile-fail/trait-impl-1.rs b/src/test/compile-fail/trait-impl-1.rs deleted file mode 100644 index e682d3c81e7..00000000000 --- a/src/test/compile-fail/trait-impl-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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> T+'a { - fn foo(&self) {} -} - -impl T for i32 {} - -fn main() { - let x = &42i32; - x.foo(); //~ERROR: no method named `foo` found for type `&i32` in the current scope -} diff --git a/src/test/compile-fail/trait-impl-can-not-have-untraitful-items.rs b/src/test/compile-fail/trait-impl-can-not-have-untraitful-items.rs deleted file mode 100644 index cc143a6209d..00000000000 --- a/src/test/compile-fail/trait-impl-can-not-have-untraitful-items.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -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/compile-fail/trait-impl-different-num-params.rs b/src/test/compile-fail/trait-impl-different-num-params.rs deleted file mode 100644 index 647dd4e05fa..00000000000 --- a/src/test/compile-fail/trait-impl-different-num-params.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -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/compile-fail/trait-impl-for-module.rs b/src/test/compile-fail/trait-impl-for-module.rs deleted file mode 100644 index 1fe8f6294da..00000000000 --- a/src/test/compile-fail/trait-impl-for-module.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { -} - -trait A { -} - -impl A for a { //~ ERROR expected type, found module -} - -fn main() { -} diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs deleted file mode 100644 index a05e007d6b7..00000000000 --- a/src/test/compile-fail/trait-impl-method-mismatch.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -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 type `fn - //~| found type `unsafe fn -} - -fn main() {} diff --git a/src/test/compile-fail/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs b/src/test/compile-fail/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs deleted file mode 100644 index 44c53e70f86..00000000000 --- a/src/test/compile-fail/trait-impl-of-supertrait-has-wrong-lifetime-parameters.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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/compile-fail/trait-item-privacy.rs b/src/test/compile-fail/trait-item-privacy.rs deleted file mode 100644 index f8e4f0d596e..00000000000 --- a/src/test/compile-fail/trait-item-privacy.rs +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![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 for type `S` in the current scope - S.b(); //~ ERROR no method named `b` found for type `S` in the current scope - S.c(); // OK - // a, b, c are resolved as inherent items, their traits don't need to be in scope - let c = &S as &C; - c.a(); //~ ERROR method `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 for type `S` - S::b(&S); - //~^ ERROR no function or associated item named `b` found for type `S` - 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 method `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 for type `S` in the current scope - S::B; //~ ERROR no associated item named `B` found for type `S` in the current scope - 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 - //~| ERROR the trait bound `dyn assoc_const::C: assoc_const::A` is not satisfied - C::B; // ERROR the trait `assoc_const::C` cannot be made into an object - //~^ ERROR the trait bound `dyn assoc_const::C: assoc_const::B` is not satisfied - C::C; // OK -} - -fn check_assoc_ty() { - // 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 _: assoc_ty::B< - B = u8, // OK - >; - let _: C< - A = u8, //~ ERROR associated type `A` is private - B = u8, // OK - C = u8, // OK - >; -} - -fn main() {} diff --git a/src/test/compile-fail/trait-matching-lifetimes.rs b/src/test/compile-fail/trait-matching-lifetimes.rs deleted file mode 100644 index 5ab80065572..00000000000 --- a/src/test/compile-fail/trait-matching-lifetimes.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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/compile-fail/trait-object-macro-matcher.rs b/src/test/compile-fail/trait-object-macro-matcher.rs deleted file mode 100644 index 8497a699e97..00000000000 --- a/src/test/compile-fail/trait-object-macro-matcher.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// `ty` matcher accepts trait object types - -macro_rules! m { - ($t: ty) => ( let _: $t; ) -} - -fn main() { - m!(Copy + Send + 'static); //~ ERROR the trait `std::marker::Copy` cannot be made into an object - m!('static + Send); - m!('static +); //~ ERROR at least one non-builtin trait is required for an object type -} diff --git a/src/test/compile-fail/trait-object-safety.rs b/src/test/compile-fail/trait-object-safety.rs deleted file mode 100644 index baf239f5956..00000000000 --- a/src/test/compile-fail/trait-object-safety.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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 _: &Tr = &St; //~ ERROR E0038 - //~^ ERROR E0038 -} diff --git a/src/test/compile-fail/trait-object-vs-lifetime-2.rs b/src/test/compile-fail/trait-object-vs-lifetime-2.rs deleted file mode 100644 index 9801cac4714..00000000000 --- a/src/test/compile-fail/trait-object-vs-lifetime-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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. - -// compile-flags: -Z continue-parse-after-error - -// `'static` is a lifetime, `'static +` is a type, `'a` is a type -fn g() where - 'static: 'static, - 'static +: 'static + Copy, - //~^ ERROR at least one non-builtin trait is required for an object type -{} - -fn main() {} diff --git a/src/test/compile-fail/trait-object-vs-lifetime.rs b/src/test/compile-fail/trait-object-vs-lifetime.rs deleted file mode 100644 index a70141edc29..00000000000 --- a/src/test/compile-fail/trait-object-vs-lifetime.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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. - -// compile-flags: -Z continue-parse-after-error - -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, 'static +>; - //~^ at least one non-builtin trait is required for an object type - let _: S<'static, 'static>; - //~^ ERROR wrong number of lifetime parameters: expected 1, found 2 - //~| ERROR wrong number of type arguments: expected 1, found 0 - let _: S<'static +, 'static>; - //~^ ERROR lifetime parameters must be declared prior to type parameters - //~| ERROR at least one non-builtin trait is required for an object type -} diff --git a/src/test/compile-fail/trait-or-new-type-instead.rs b/src/test/compile-fail/trait-or-new-type-instead.rs deleted file mode 100644 index b1e4d06affe..00000000000 --- a/src/test/compile-fail/trait-or-new-type-instead.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -impl Option { -//~^ ERROR cannot define inherent `impl` for a type outside of the crate where the type is defined - pub fn foo(&self) { } -} - -fn main() { } diff --git a/src/test/compile-fail/trait-privacy.rs b/src/test/compile-fail/trait-privacy.rs deleted file mode 100644 index 5f9e8ba6c0a..00000000000 --- a/src/test/compile-fail/trait-privacy.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs, get_type_id)] -#![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.get_type_id(); // Regression test for #21670 -} - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/trait-resolution-in-overloaded-op.rs b/src/test/compile-fail/trait-resolution-in-overloaded-op.rs deleted file mode 100644 index 1f57c4cf93a..00000000000 --- a/src/test/compile-fail/trait-resolution-in-overloaded-op.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// #12402 Operator overloading only considers the method name, not which trait is implemented - -trait MyMul { - fn mul(&self, rhs: &Rhs) -> Res; -} - -fn foo>(a: &T, b: f64) -> f64 { - a * b //~ ERROR binary operation `*` cannot be applied to type `&T` -} - -fn main() {} diff --git a/src/test/compile-fail/trait-safety-inherent-impl.rs b/src/test/compile-fail/trait-safety-inherent-impl.rs deleted file mode 100644 index 059fdc100c9..00000000000 --- a/src/test/compile-fail/trait-safety-inherent-impl.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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/compile-fail/trait-safety-trait-impl-cc.rs b/src/test/compile-fail/trait-safety-trait-impl-cc.rs deleted file mode 100644 index f30c8f521bd..00000000000 --- a/src/test/compile-fail/trait-safety-trait-impl-cc.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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/compile-fail/trait-safety-trait-impl.rs b/src/test/compile-fail/trait-safety-trait-impl.rs deleted file mode 100644 index e846b660c2a..00000000000 --- a/src/test/compile-fail/trait-safety-trait-impl.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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/compile-fail/trait-static-method-generic-inference.rs b/src/test/compile-fail/trait-static-method-generic-inference.rs deleted file mode 100644 index 0e357d9d4d5..00000000000 --- a/src/test/compile-fail/trait-static-method-generic-inference.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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 { - fn new() -> T; - fn dummy(&self) { } - } - - pub struct Foo { - dummy: (), - } - - impl HasNew for Foo { - fn new() -> Foo { - Foo { dummy: () } - } - } -} - -pub fn foo() { - let _f: base::Foo = base::HasNew::new(); - //~^ ERROR type annotations required -} - -fn main() { } diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs deleted file mode 100644 index b08aab6da85..00000000000 --- a/src/test/compile-fail/trait-test-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -trait bar { fn dup(&self) -> Self; fn blah(&self); } -impl bar for i32 { fn dup(&self) -> i32 { *self } fn blah(&self) {} } -impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah(&self) {} } - -fn main() { - 10.dup::(); //~ ERROR expected at most 0 type parameters, found 1 type parameter - 10.blah::(); //~ ERROR expected at most 1 type parameter, found 2 type parameters - (box 10 as Box).dup(); - //~^ ERROR E0038 - //~| ERROR E0038 - //~| ERROR E0277 -} diff --git a/src/test/compile-fail/trait-test.rs b/src/test/compile-fail/trait-test.rs deleted file mode 100644 index d53e353d9d9..00000000000 --- a/src/test/compile-fail/trait-test.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait foo { fn foo(&self); } - -impl isize for usize { fn foo(&self) {} } //~ ERROR trait - -fn main() {} diff --git a/src/test/compile-fail/traits-assoc-type-in-supertrait-bad.rs b/src/test/compile-fail/traits-assoc-type-in-supertrait-bad.rs deleted file mode 100644 index 971869ba85b..00000000000 --- a/src/test/compile-fail/traits-assoc-type-in-supertrait-bad.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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::Key> { - type Key; -} - -impl Foo for IntoIter { //~ ERROR type mismatch - type Key = u32; -} - -fn main() { -} diff --git a/src/test/compile-fail/traits-inductive-overflow-simultaneous.rs b/src/test/compile-fail/traits-inductive-overflow-simultaneous.rs deleted file mode 100644 index 777746a189c..00000000000 --- a/src/test/compile-fail/traits-inductive-overflow-simultaneous.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for #33344, initial version. This example allowed -// arbitrary trait bounds to be synthesized. - -trait Tweedledum: IntoIterator {} -trait Tweedledee: IntoIterator {} - -impl Tweedledee for T {} -impl Tweedledum for T {} - -trait Combo: IntoIterator {} -impl Combo for T {} - -fn is_ee(t: T) { - t.into_iter(); -} - -fn main() { - is_ee(4); - //~^ ERROR overflow evaluating the requirement `{integer}: Tweedle -} diff --git a/src/test/compile-fail/traits-inductive-overflow-supertrait-oibit.rs b/src/test/compile-fail/traits-inductive-overflow-supertrait-oibit.rs deleted file mode 100644 index 59d5dc6c58b..00000000000 --- a/src/test/compile-fail/traits-inductive-overflow-supertrait-oibit.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// OIBIT-based version of #29859, supertrait version. Test that using -// a simple OIBIT `..` impl alone still doesn't allow arbitrary bounds -// to be synthesized. - -#![feature(optin_builtin_traits)] - -auto trait Magic: Copy {} //~ ERROR E0568 - -fn copy(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/compile-fail/traits-inductive-overflow-supertrait.rs b/src/test/compile-fail/traits-inductive-overflow-supertrait.rs deleted file mode 100644 index c717ae9639f..00000000000 --- a/src/test/compile-fail/traits-inductive-overflow-supertrait.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for #29859, supertrait version. This example -// allowed arbitrary trait bounds to be synthesized. - -trait Magic: Copy {} -impl Magic for T {} - -fn copy(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/compile-fail/traits-inductive-overflow-two-traits.rs b/src/test/compile-fail/traits-inductive-overflow-two-traits.rs deleted file mode 100644 index c622dca2b4d..00000000000 --- a/src/test/compile-fail/traits-inductive-overflow-two-traits.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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 Magic for T { - type X = Self; -} - -fn check() {} - -fn wizard() { check::<::X>(); } - -fn main() { - wizard::<*mut ()>(); //~ ERROR E0275 - // check::<*mut ()>(); -} diff --git a/src/test/compile-fail/traits-issue-23003-overflow.rs b/src/test/compile-fail/traits-issue-23003-overflow.rs deleted file mode 100644 index 80d2884ee60..00000000000 --- a/src/test/compile-fail/traits-issue-23003-overflow.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -use std::marker::PhantomData; - -trait Async { - type Cancel; -} - -struct Receipt { - marker: PhantomData, -} - -struct Complete { - core: Option, -} - -impl Async for Complete { - type Cancel = Receipt>>; -} - -fn foo(_: Receipt>) { } - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/traits-multidispatch-bad.rs b/src/test/compile-fail/traits-multidispatch-bad.rs deleted file mode 100644 index 392eccf0f31..00000000000 --- a/src/test/compile-fail/traits-multidispatch-bad.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we detect an illegal combination of types. - -trait Convert { - fn convert(&self) -> Target; -} - -impl Convert for i32 { - fn convert(&self) -> u32 { - *self as u32 - } -} - -fn test(_: T, _: U) -where T : Convert -{ -} - -fn a() { - test(22i32, 44i32); //~ ERROR mismatched types -} - -fn main() {} diff --git a/src/test/compile-fail/traits-negative-impls.rs b/src/test/compile-fail/traits-negative-impls.rs deleted file mode 100644 index a272686c535..00000000000 --- a/src/test/compile-fail/traits-negative-impls.rs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The dummy functions are used to avoid adding new cfail files. -// What happens is that the compiler attempts to squash duplicates and some -// errors are not reported. This way, we make sure that, for each function, different -// typeck phases are involved and all errors are reported. - -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -struct Outer(T); - -struct Outer2(T); - -unsafe impl Sync for Outer2 {} - -fn is_send(_: T) {} -fn is_sync(_: T) {} - -fn dummy() { - struct TestType; - impl !Send for TestType {} - - Outer(TestType); - //~^ ERROR `dummy::TestType` cannot be sent between threads safely - //~| ERROR `dummy::TestType` cannot be sent between threads safely -} - -fn dummy1b() { - struct TestType; - impl !Send for TestType {} - - is_send(TestType); - //~^ ERROR `dummy1b::TestType` cannot be sent between threads safely -} - -fn dummy1c() { - struct TestType; - impl !Send for TestType {} - - is_send((8, TestType)); - //~^ ERROR `dummy1c::TestType` cannot be sent between threads safely -} - -fn dummy2() { - struct TestType; - impl !Send for TestType {} - - is_send(Box::new(TestType)); - //~^ ERROR `dummy2::TestType` cannot be sent between threads safely -} - -fn dummy3() { - struct TestType; - impl !Send for TestType {} - - is_send(Box::new(Outer2(TestType))); - //~^ ERROR `dummy3::TestType` cannot be sent between threads safely -} - -fn main() { - struct TestType; - impl !Send for TestType {} - - // This will complain about a missing Send impl because `Sync` is implement *just* - // for T that are `Send`. Look at #20366 and #19950 - is_sync(Outer2(TestType)); - //~^ ERROR `main::TestType` cannot be sent between threads safely -} diff --git a/src/test/compile-fail/traits-repeated-supertrait-ambig.rs b/src/test/compile-fail/traits-repeated-supertrait-ambig.rs deleted file mode 100644 index 559871af72e..00000000000 --- a/src/test/compile-fail/traits-repeated-supertrait-ambig.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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 { - fn same_as(&self, t: T) -> bool; -} - -trait CompareToInts : CompareTo + CompareTo { -} - -impl CompareTo for i64 { - fn same_as(&self, t: i64) -> bool { *self == t } -} - -impl CompareTo for i64 { - fn same_as(&self, t: u64) -> bool { *self == (t as i64) } -} - -impl CompareToInts for i64 { } - -fn with_obj(c: &CompareToInts) -> bool { - c.same_as(22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied -} - -fn with_trait(c: &C) -> bool { - c.same_as(22) //~ ERROR `C: CompareTo` is not satisfied -} - -fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22) //~ ERROR `dyn CompareToInts: CompareTo` is not satisfied -} - -fn with_ufcs2(c: &C) -> bool { - CompareTo::same_as(c, 22) //~ ERROR `C: CompareTo` is not satisfied -} - -fn main() { - assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64: CompareTo` is not satisfied -} diff --git a/src/test/compile-fail/transmute-different-sizes.rs b/src/test/compile-fail/transmute-different-sizes.rs deleted file mode 100644 index 113e2ed4c80..00000000000 --- a/src/test/compile-fail/transmute-different-sizes.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that `transmute` cannot be called on types of different size. - -#![allow(warnings)] -#![feature(specialization)] - -use std::mem::transmute; - -unsafe fn f() { - let _: i8 = transmute(16i16); - //~^ ERROR transmute called with types of different sizes -} - -unsafe fn g(x: &T) { - let _: i8 = transmute(x); - //~^ ERROR transmute called with types of different sizes -} - -trait Specializable { type Output; } - -impl Specializable for T { - default type Output = u16; -} - -unsafe fn specializable(x: u16) -> ::Output { - transmute(x) - //~^ ERROR transmute called with types of different sizes -} - -fn main() {} diff --git a/src/test/compile-fail/transmute-fat-pointers.rs b/src/test/compile-fail/transmute-fat-pointers.rs deleted file mode 100644 index 59027fc7787..00000000000 --- a/src/test/compile-fail/transmute-fat-pointers.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that are conservative around thin/fat pointer mismatches. - -#![allow(dead_code)] - -use std::mem::transmute; - -fn a(x: &[T]) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes -} - -fn b(x: &T) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes -} - -fn c(x: &T) -> &U { - unsafe { transmute(x) } -} - -fn d(x: &[T]) -> &[U] { - unsafe { transmute(x) } -} - -fn e(x: &T) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes -} - -fn f(x: &T) -> &U { - unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes -} - -fn main() { } diff --git a/src/test/compile-fail/transmute-impl.rs b/src/test/compile-fail/transmute-impl.rs deleted file mode 100644 index 2f8f9e46e1a..00000000000 --- a/src/test/compile-fail/transmute-impl.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that are conservative around thin/fat pointer mismatches. - -#![allow(dead_code)] - -use std::mem::transmute; - -struct Foo { - t: Box -} - -impl Foo { - fn m(x: &T) -> &isize where T : Sized { - // OK here, because T : Sized is in scope. - unsafe { transmute(x) } - } - - fn n(x: &T) -> &isize { - // Not OK here, because T : Sized is not in scope. - unsafe { transmute(x) } //~ ERROR transmute called with types of different sizes - } -} - -fn main() { } diff --git a/src/test/compile-fail/transmute-imut-to-mut.rs b/src/test/compile-fail/transmute-imut-to-mut.rs deleted file mode 100644 index 62db4c5d366..00000000000 --- a/src/test/compile-fail/transmute-imut-to-mut.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that transmuting from &T to &mut T is Undefined Behavior. - -use std::mem::transmute; - -fn main() { - let _a: &mut u8 = unsafe { transmute(&1u8) }; - //~^ ERROR mutating transmuted &mut T from &T may cause undefined behavior -} - diff --git a/src/test/compile-fail/trivial_casts.rs b/src/test/compile-fail/trivial_casts.rs deleted file mode 100644 index 3f2bd2ffabf..00000000000 --- a/src/test/compile-fail/trivial_casts.rs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test the trivial_casts and trivial_numeric_casts lints. For each error we also -// check that the cast can be done using just coercion. - -#![deny(trivial_casts, trivial_numeric_casts)] - -trait Foo { - fn foo(&self) {} -} - -pub struct Bar; - -impl Foo for Bar {} - -pub fn main() { - // Numeric - let _ = 42_i32 as i32; //~ ERROR trivial numeric cast: `i32` as `i32` - let _: i32 = 42_i32; - - let _ = 42_u8 as u8; //~ ERROR trivial numeric cast: `u8` as `u8` - let _: u8 = 42_u8; - - // & to * pointers - let x: &u32 = &42; - let _ = x as *const u32; //~ERROR trivial cast: `&u32` as `*const u32` - let _: *const u32 = x; - - let x: &mut u32 = &mut 42; - let _ = x as *mut u32; //~ERROR trivial cast: `&mut u32` as `*mut u32` - let _: *mut u32 = x; - - // unsize array - let x: &[u32; 3] = &[42, 43, 44]; - let _ = x as &[u32]; //~ERROR trivial cast: `&[u32; 3]` as `&[u32]` - let _ = x as *const [u32]; //~ERROR trivial cast: `&[u32; 3]` as `*const [u32]` - let _: &[u32] = x; - let _: *const [u32] = x; - - let x: &mut [u32; 3] = &mut [42, 43, 44]; - let _ = x as &mut [u32]; //~ERROR trivial cast: `&mut [u32; 3]` as `&mut [u32]` - let _ = x as *mut [u32]; //~ERROR trivial cast: `&mut [u32; 3]` as `*mut [u32]` - let _: &mut [u32] = x; - let _: *mut [u32] = x; - - let x: Box<[u32; 3]> = Box::new([42, 43, 44]); - let _ = x as Box<[u32]>; - //~^ ERROR trivial cast: `std::boxed::Box<[u32; 3]>` as `std::boxed::Box<[u32]>` - let x: Box<[u32; 3]> = Box::new([42, 43, 44]); - let _: Box<[u32]> = x; - - // unsize trait - let x: &Bar = &Bar; - let _ = x as &Foo; //~ERROR trivial cast: `&Bar` as `&dyn Foo` - let _ = x as *const Foo; //~ERROR trivial cast: `&Bar` as `*const dyn Foo` - let _: &Foo = x; - let _: *const Foo = x; - - let x: &mut Bar = &mut Bar; - let _ = x as &mut Foo; //~ERROR trivial cast: `&mut Bar` as `&mut dyn Foo` - let _ = x as *mut Foo; //~ERROR trivial cast: `&mut Bar` as `*mut dyn Foo` - let _: &mut Foo = x; - let _: *mut Foo = x; - - let x: Box = Box::new(Bar); - let _ = x as Box; //~ERROR `std::boxed::Box` as `std::boxed::Box` - let x: Box = Box::new(Bar); - let _: Box = x; - - // functions - fn baz(_x: i32) {} - let _ = &baz as &Fn(i32); //~ERROR `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` - let _: &Fn(i32) = &baz; - let x = |_x: i32| {}; - let _ = &x as &Fn(i32); //~ERROR trivial cast - let _: &Fn(i32) = &x; -} - -// subtyping -pub fn test_subtyping<'a, 'b: 'a>(a: &'a Bar, b: &'b Bar) { - let _ = a as &'a Bar; //~ERROR trivial cast - let _: &'a Bar = a; - let _ = b as &'a Bar; //~ERROR trivial cast - let _: &'a Bar = b; - let _ = b as &'b Bar; //~ERROR trivial cast - let _: &'b Bar = b; -} diff --git a/src/test/compile-fail/tuple-arity-mismatch.rs b/src/test/compile-fail/tuple-arity-mismatch.rs deleted file mode 100644 index a71f4410294..00000000000 --- a/src/test/compile-fail/tuple-arity-mismatch.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #6155 - -fn first((value, _): (isize, f64)) -> isize { value } - -fn main() { - let y = first ((1,2.0,3)); - //~^ ERROR mismatched types - //~| expected type `(isize, f64)` - //~| found type `(isize, f64, {integer})` - //~| expected a tuple with 2 elements, found one with 3 elements - - let y = first ((1,)); - //~^ ERROR mismatched types - //~| expected type `(isize, f64)` - //~| found type `(isize,)` - //~| expected a tuple with 2 elements, found one with 1 elements -} diff --git a/src/test/compile-fail/tuple-index-not-tuple.rs b/src/test/compile-fail/tuple-index-not-tuple.rs deleted file mode 100644 index 471104d6872..00000000000 --- a/src/test/compile-fail/tuple-index-not-tuple.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Point { x: isize, y: isize } -struct Empty; - -fn main() { - let origin = Point { x: 0, y: 0 }; - origin.0; - //~^ ERROR no field `0` on type `Point` - Empty.0; - //~^ ERROR no field `0` on type `Empty` -} diff --git a/src/test/compile-fail/tuple-index-out-of-bounds.rs b/src/test/compile-fail/tuple-index-out-of-bounds.rs deleted file mode 100644 index 35b843676b4..00000000000 --- a/src/test/compile-fail/tuple-index-out-of-bounds.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Point(i32, i32); - -fn main() { - let origin = Point(0, 0); - origin.0; - origin.1; - origin.2; - //~^ ERROR no field `2` on type `Point` - let tuple = (0, 0); - tuple.0; - tuple.1; - tuple.2; - //~^ ERROR no field `2` on type `({integer}, {integer})` -} diff --git a/src/test/compile-fail/tuple-struct-nonexhaustive.rs b/src/test/compile-fail/tuple-struct-nonexhaustive.rs deleted file mode 100644 index e4fda6dd534..00000000000 --- a/src/test/compile-fail/tuple-struct-nonexhaustive.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo(isize, isize); - -fn main() { - let x = Foo(1, 2); - match x { //~ ERROR non-exhaustive - Foo(1, b) => println!("{}", b), - Foo(2, b) => println!("{}", b) - } -} diff --git a/src/test/compile-fail/tutorial-suffix-inference-test.rs b/src/test/compile-fail/tutorial-suffix-inference-test.rs deleted file mode 100644 index dadf7eb91d8..00000000000 --- a/src/test/compile-fail/tutorial-suffix-inference-test.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x = 3; - let y: i32 = 3; - - fn identity_u8(n: u8) -> u8 { n } - fn identity_u16(n: u16) -> u16 { n } - - identity_u8(x); // after this, `x` is assumed to have type `u8` - identity_u16(x); - //~^ ERROR mismatched types - //~| expected u16, found u8 - identity_u16(y); - //~^ ERROR mismatched types - //~| expected u16, found i32 - - let a = 3; - - fn identity_i(n: isize) -> isize { n } - - identity_i(a); // ok - identity_u16(a); - //~^ ERROR mismatched types - //~| expected u16, found isize -} diff --git a/src/test/compile-fail/type-arg-out-of-scope.rs b/src/test/compile-fail/type-arg-out-of-scope.rs deleted file mode 100644 index 04cd961e97f..00000000000 --- a/src/test/compile-fail/type-arg-out-of-scope.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:can't use type parameters from outer function -fn foo(x: T) { - fn bar(f: Box T>) { } -} -fn main() { foo(1); } diff --git a/src/test/compile-fail/type-ascription-precedence.rs b/src/test/compile-fail/type-ascription-precedence.rs deleted file mode 100644 index bb7a8bc3ddf..00000000000 --- a/src/test/compile-fail/type-ascription-precedence.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Operator precedence of type ascription -// Type ascription has very high precedence, the same as operator `as` - -#![feature(type_ascription)] - -use std::ops::*; - -struct S; -struct Z; - -impl Add for S { - type Output = S; - fn add(self, _rhs: Z) -> S { panic!() } -} -impl Mul for S { - type Output = S; - fn mul(self, _rhs: Z) -> S { panic!() } -} -impl Neg for S { - type Output = Z; - fn neg(self) -> Z { panic!() } -} -impl Deref for S { - type Target = Z; - fn deref(&self) -> &Z { panic!() } -} - -fn main() { - &S: &S; // OK - (&S): &S; // OK - &(S: &S); //~ ERROR mismatched types - - *S: Z; // OK - (*S): Z; // OK - *(S: Z); //~ ERROR mismatched types - //~^ ERROR type `Z` cannot be dereferenced - - -S: Z; // OK - (-S): Z; // OK - -(S: Z); //~ ERROR mismatched types - //~^ ERROR cannot apply unary operator `-` to type `Z` - - S + Z: Z; // OK - S + (Z: Z); // OK - (S + Z): Z; //~ ERROR mismatched types - - S * Z: Z; // OK - S * (Z: Z); // OK - (S * Z): Z; //~ ERROR mismatched types - - S .. S: S; // OK - S .. (S: S); // OK - (S .. S): S; //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/type-ascription-soundness.rs b/src/test/compile-fail/type-ascription-soundness.rs deleted file mode 100644 index 2d882e87ab8..00000000000 --- a/src/test/compile-fail/type-ascription-soundness.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Type ascription doesn't lead to unsoundness - -#![feature(type_ascription)] - -fn main() { - let arr = &[1u8, 2, 3]; - let ref x = arr: &[u8]; //~ ERROR mismatched types - let ref mut x = arr: &[u8]; //~ ERROR mismatched types - match arr: &[u8] { //~ ERROR mismatched types - ref x => {} - } - let _len = (arr: &[u8]).len(); //~ ERROR mismatched types -} diff --git a/src/test/compile-fail/type-mismatch-multiple.rs b/src/test/compile-fail/type-mismatch-multiple.rs deleted file mode 100644 index 9359c035956..00000000000 --- a/src/test/compile-fail/type-mismatch-multiple.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checking that the compiler reports multiple type errors at once - -fn main() { let a: bool = 1; let b: i32 = true; } -//~^ ERROR mismatched types -//~| expected type `bool` -//~| found type `{integer}` -//~| expected bool, found integral variable -//~| ERROR mismatched types -//~| expected i32, found bool - diff --git a/src/test/compile-fail/type-mismatch-same-crate-name.rs b/src/test/compile-fail/type-mismatch-same-crate-name.rs deleted file mode 100644 index 7e93f626cfc..00000000000 --- a/src/test/compile-fail/type-mismatch-same-crate-name.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:crate_a1.rs -// aux-build:crate_a2.rs - -// This tests the extra note reported when a type error deals with -// seemingly identical types. -// The main use case of this error is when there are two crates -// (generally different versions of the same crate) with the same name -// causing a type mismatch. Here, we simulate that error using block-scoped -// aliased `extern crate` declarations. - -fn main() { - let foo2 = {extern crate crate_a2 as a; a::Foo}; - let bar2 = {extern crate crate_a2 as a; a::bar()}; - { - extern crate crate_a1 as a; - a::try_foo(foo2); - //~^ ERROR mismatched types - //~| Perhaps two different versions of crate `crate_a1` - //~| expected struct `main::a::Foo` - //~| expected type `main::a::Foo` - //~| found type `main::a::Foo` - a::try_bar(bar2); - //~^ ERROR mismatched types - //~| Perhaps two different versions of crate `crate_a1` - //~| expected trait `main::a::Bar` - //~| expected type `std::boxed::Box<(dyn main::a::Bar + 'static)>` - //~| found type `std::boxed::Box` - } -} diff --git a/src/test/compile-fail/type-parameter-defaults-referencing-Self-ppaux.rs b/src/test/compile-fail/type-parameter-defaults-referencing-Self-ppaux.rs deleted file mode 100644 index 08988353886..00000000000 --- a/src/test/compile-fail/type-parameter-defaults-referencing-Self-ppaux.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a default that references `Self` which is then used in an -// object type. Issue #18956. In this case, the value is supplied by -// the user, but pretty-printing the type during the error message -// caused an ICE. - -trait MyAdd { fn add(&self, other: &Rhs) -> Self; } - -impl MyAdd for i32 { - fn add(&self, other: &i32) -> i32 { *self + *other } -} - -fn main() { - let x: i32 = 5; - let y = x as MyAdd; - //~^ ERROR E0038 - //~| ERROR cast to unsized type: `i32` as `dyn MyAdd` -} diff --git a/src/test/compile-fail/type-parameter-defaults-referencing-Self.rs b/src/test/compile-fail/type-parameter-defaults-referencing-Self.rs deleted file mode 100644 index 9982d485024..00000000000 --- a/src/test/compile-fail/type-parameter-defaults-referencing-Self.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test a default that references `Self` which is then used in an object type. -// Issue #18956. - -#![feature(default_type_params)] - -trait Foo { - fn method(&self); -} - -fn foo(x: &Foo) { } -//~^ ERROR the type parameter `T` must be explicitly specified - -fn main() { } diff --git a/src/test/compile-fail/type-parameter-names.rs b/src/test/compile-fail/type-parameter-names.rs deleted file mode 100644 index 11a2fc2665c..00000000000 --- a/src/test/compile-fail/type-parameter-names.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we print out the names of type parameters correctly in -// our error messages. - -fn foo(x: Foo) -> Bar { - x -//~^ ERROR mismatched types -//~| expected type `Bar` -//~| found type `Foo` -//~| expected type parameter, found a different type parameter -} - -fn main() {} diff --git a/src/test/compile-fail/type-params-in-different-spaces-1.rs b/src/test/compile-fail/type-params-in-different-spaces-1.rs deleted file mode 100644 index 26eac6adde2..00000000000 --- a/src/test/compile-fail/type-params-in-different-spaces-1.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Add; - -trait BrokenAdd: Copy + Add { - fn broken_add(&self, rhs: T) -> Self { - *self + rhs //~ ERROR mismatched types - //~| expected type `Self` - //~| found type `T` - //~| expected Self, found type parameter - } -} - -impl> BrokenAdd for T {} - -pub fn main() { - let foo: u8 = 0; - let x: u8 = foo.broken_add("hello darkness my old friend".to_string()); - println!("{}", x); -} diff --git a/src/test/compile-fail/type-params-in-different-spaces-2.rs b/src/test/compile-fail/type-params-in-different-spaces-2.rs deleted file mode 100644 index 7de061eaf07..00000000000 --- a/src/test/compile-fail/type-params-in-different-spaces-2.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test static calls to make sure that we align the Self and input -// type parameters on a trait correctly. - -trait Tr : Sized { - fn op(_: T) -> Self; -} - -trait A: Tr { - fn test(u: U) -> Self { - Tr::op(u) //~ ERROR E0277 - } -} - -trait B: Tr { - fn test(u: U) -> Self { - Tr::op(u) //~ ERROR E0277 - } -} - -fn main() { -} diff --git a/src/test/compile-fail/type-params-in-different-spaces-3.rs b/src/test/compile-fail/type-params-in-different-spaces-3.rs deleted file mode 100644 index 3ad1e9ab538..00000000000 --- a/src/test/compile-fail/type-params-in-different-spaces-3.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Tr : Sized { - fn test(u: X) -> Self { - u //~ ERROR mismatched types - } -} - -fn main() {} diff --git a/src/test/compile-fail/type-path-err-node-types.rs b/src/test/compile-fail/type-path-err-node-types.rs deleted file mode 100644 index 7ef099d0410..00000000000 --- a/src/test/compile-fail/type-path-err-node-types.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Type arguments in unresolved entities (reporting errors before type checking) -// should have their types recorded. - -trait Tr {} - -fn local_type() { - let _: Nonexistent; //~ ERROR cannot find type `Nonexistent` in this scope -} - -fn ufcs_trait() { - >::nonexistent(); //~ ERROR cannot find method or associated constant `nonexistent` -} - -fn ufcs_item() { - NonExistent::Assoc::; //~ ERROR undeclared type or module `NonExistent` -} - -fn method() { - nonexistent.nonexistent::(); //~ ERROR cannot find value `nonexistent` -} - -fn closure() { - let _ = |a, b: _| -> _ { 0 }; // OK -} - -fn main() {} diff --git a/src/test/compile-fail/type-shadow.rs b/src/test/compile-fail/type-shadow.rs deleted file mode 100644 index 6d8c0fe22bd..00000000000 --- a/src/test/compile-fail/type-shadow.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - type X = isize; - type Y = X; - if true { - type X = &'static str; - let y: Y = "hello"; //~ ERROR mismatched types - } -} diff --git a/src/test/compile-fail/type_length_limit.rs b/src/test/compile-fail/type_length_limit.rs deleted file mode 100644 index d283f392d76..00000000000 --- a/src/test/compile-fail/type_length_limit.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: reached the type-length limit while instantiating - -// Test that the type length limit can be changed. - -#![allow(dead_code)] -#![type_length_limit="256"] - -macro_rules! link { - ($id:ident, $t:ty) => { - pub type $id = ($t, $t, $t); - } -} - -link! { A, B } -link! { B, C } -link! { C, D } -link! { D, E } -link! { E, F } -link! { F, G } - -pub struct G; - -fn main() { - drop::>(None); -} diff --git a/src/test/compile-fail/typeck-auto-trait-no-supertraits-2.rs b/src/test/compile-fail/typeck-auto-trait-no-supertraits-2.rs deleted file mode 100644 index fa63088d000..00000000000 --- a/src/test/compile-fail/typeck-auto-trait-no-supertraits-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -auto trait Magic : Sized where Option : Magic {} //~ ERROR E0568 -impl Magic for T {} - -fn copy(x: T) -> (T, T) { (x, x) } - -#[derive(Debug)] -struct NoClone; - -fn main() { - let (a, b) = copy(NoClone); - println!("{:?} {:?}", a, b); -} diff --git a/src/test/compile-fail/typeck-auto-trait-no-supertraits.rs b/src/test/compile-fail/typeck-auto-trait-no-supertraits.rs deleted file mode 100644 index c8cf96f52fc..00000000000 --- a/src/test/compile-fail/typeck-auto-trait-no-supertraits.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test is for #29859, we need to ensure auto traits, -// (also known previously as default traits), do not have -// supertraits. Since the compiler synthesizes these -// instances on demand, we are essentially enabling -// users to write axioms if we view trait selection, -// as a proof system. -// -// For example the below test allows us to add the rule: -// forall (T : Type), T : Copy -// -// Providing a copy instance for *any* type, which -// is most definitely unsound. Imagine copying a -// type that contains a mutable reference, enabling -// mutable aliasing. -// -// You can imagine an even more dangerous test, -// which currently compiles on nightly. -// -// fn main() { -// let mut i = 10; -// let (a, b) = copy(&mut i); -// println!("{:?} {:?}", a, b); -// } - -#![feature(optin_builtin_traits)] - -auto trait Magic: Copy {} //~ ERROR E0568 -impl Magic for T {} - -fn copy(x: T) -> (T, T) { (x, x) } - -#[derive(Debug)] -struct NoClone; - -fn main() { - let (a, b) = copy(NoClone); - println!("{:?} {:?}", a, b); -} diff --git a/src/test/compile-fail/typeck-cast-pointer-to-float.rs b/src/test/compile-fail/typeck-cast-pointer-to-float.rs deleted file mode 100644 index 3f8b8f49cb3..00000000000 --- a/src/test/compile-fail/typeck-cast-pointer-to-float.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x : i16 = 22; - ((&x) as *const i16) as f32; - //~^ ERROR casting `*const i16` as `f32` is invalid -} diff --git a/src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs b/src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs deleted file mode 100644 index f8342c333a3..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we do not consider associated types to be sendable without -// some applicable trait bound (and we don't ICE). - -trait Trait { - type AssocType; - fn dummy(&self) { } -} -fn bar() { - is_send::(); //~ ERROR E0277 -} - -fn is_send() { -} - -fn main() { } diff --git a/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs b/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs deleted file mode 100644 index 6e7c9afb674..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -auto trait MyTrait {} - -struct MyS; - -struct MyS2; - -impl !MyTrait for MyS2 {} - -fn is_mytrait() {} - -fn main() { - is_mytrait::(); - - is_mytrait::<(MyS2, MyS)>(); - //~^ ERROR `MyS2: MyTrait` is not satisfied -} diff --git a/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs b/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs deleted file mode 100644 index 4660ecf4fb4..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -auto trait MyTrait {} - -impl !MyTrait for *mut T {} - -struct MyS; - -struct MyS2; - -impl !MyTrait for MyS2 {} - -struct MyS3; - -fn is_mytrait() {} - -fn main() { - is_mytrait::(); - - is_mytrait::(); - //~^ ERROR `MyS2: MyTrait` is not satisfied -} diff --git a/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs b/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs deleted file mode 100644 index b918b0dde47..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-cross-crate-coherence.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:tdticc_coherence_lib.rs - -// Test that we do not consider associated types to be sendable without -// some applicable trait bound (and we don't ICE). - -#![feature(optin_builtin_traits)] - -extern crate tdticc_coherence_lib as lib; - -use lib::DefaultedTrait; - -struct A; -impl DefaultedTrait for (A,) { } //~ ERROR E0117 - -struct B; -impl !DefaultedTrait for (B,) { } //~ ERROR E0117 - -struct C; -struct D(T); -impl DefaultedTrait for Box { } //~ ERROR E0321 -impl DefaultedTrait for lib::Something { } //~ ERROR E0117 -impl DefaultedTrait for D { } // OK - -fn main() { } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs b/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs deleted file mode 100644 index 65438e5df8e..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -struct MySendable { - t: *mut u8 -} - -unsafe impl Send for MySendable {} - -struct MyNotSendable { - t: *mut u8 -} - -impl !Send for MyNotSendable {} - -fn is_send() {} - -fn main() { - is_send::(); - is_send::(); - //~^ ERROR `MyNotSendable` cannot be sent between threads safely -} diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs b/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs deleted file mode 100644 index c829ba3dcc3..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#![feature(optin_builtin_traits)] - -struct Managed; -impl !Send for Managed {} -impl !Sync for Managed {} - -use std::cell::UnsafeCell; - -struct MySync { - t: *mut u8 -} - -unsafe impl Sync for MySync {} - -struct MyNotSync { - t: *mut u8 -} - -impl !Sync for MyNotSync {} - -struct MyTypeWUnsafe { - t: UnsafeCell -} - -struct MyTypeManaged { - t: Managed -} - -fn is_sync() {} - -fn main() { - is_sync::(); - is_sync::(); - //~^ ERROR `MyNotSync` cannot be shared between threads safely [E0277] - - is_sync::(); - //~^ ERROR `std::cell::UnsafeCell` cannot be shared between threads safely [E0277] - - is_sync::(); - //~^ ERROR `Managed` cannot be shared between threads safely [E0277] -} diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation.rs b/src/test/compile-fail/typeck-default-trait-impl-negation.rs deleted file mode 100644 index b28cdd8aa24..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-negation.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -auto trait MyTrait {} - -unsafe auto trait MyUnsafeTrait {} - -struct ThisImplsTrait; - -impl !MyUnsafeTrait for ThisImplsTrait {} - - -struct ThisImplsUnsafeTrait; - -impl !MyTrait for ThisImplsUnsafeTrait {} - -fn is_my_trait() {} -fn is_my_unsafe_trait() {} - -fn main() { - is_my_trait::(); - is_my_trait::(); - //~^ ERROR `ThisImplsUnsafeTrait: MyTrait` is not satisfied - - is_my_unsafe_trait::(); - //~^ ERROR `ThisImplsTrait: MyUnsafeTrait` is not satisfied - - is_my_unsafe_trait::(); -} diff --git a/src/test/compile-fail/typeck-default-trait-impl-precedence.rs b/src/test/compile-fail/typeck-default-trait-impl-precedence.rs deleted file mode 100644 index d63d70bad22..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-precedence.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that declaring that `&T` is `Defaulted` if `T:Signed` implies -// that other `&T` is NOT `Defaulted` if `T:Signed` does not hold. In -// other words, the auto impl only applies if there are no existing -// impls whose types unify. - -#![feature(optin_builtin_traits)] - -auto trait Defaulted { } -impl<'a,T:Signed> Defaulted for &'a T { } -impl<'a,T:Signed> Defaulted for &'a mut T { } -fn is_defaulted() { } - -trait Signed { } -impl Signed for i32 { } - -fn main() { - is_defaulted::<&'static i32>(); - is_defaulted::<&'static u32>(); - //~^ ERROR `u32: Signed` is not satisfied -} diff --git a/src/test/compile-fail/typeck-default-trait-impl-send-param.rs b/src/test/compile-fail/typeck-default-trait-impl-send-param.rs deleted file mode 100644 index 0c548b3bd99..00000000000 --- a/src/test/compile-fail/typeck-default-trait-impl-send-param.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we do not consider parameter types to be sendable without -// an explicit trait bound. - -fn foo() { - is_send::() //~ ERROR E0277 -} - -fn is_send() { -} - -fn main() { } diff --git a/src/test/compile-fail/typeck-negative-impls-builtin.rs b/src/test/compile-fail/typeck-negative-impls-builtin.rs deleted file mode 100644 index d6d8fb6235d..00000000000 --- a/src/test/compile-fail/typeck-negative-impls-builtin.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] - -struct TestType; - -trait TestTrait { - fn dummy(&self) { } -} - -impl !TestTrait for TestType {} -//~^ ERROR negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) - -fn main() {} diff --git a/src/test/compile-fail/typeck-unsafe-always-share.rs b/src/test/compile-fail/typeck-unsafe-always-share.rs deleted file mode 100644 index fcfc8574b21..00000000000 --- a/src/test/compile-fail/typeck-unsafe-always-share.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Verify that UnsafeCell is *always* !Sync regardless if `T` is sync. - -#![feature(optin_builtin_traits)] - -use std::cell::UnsafeCell; -use std::marker::Sync; - -struct MySync { - u: UnsafeCell -} - -struct NoSync; -impl !Sync for NoSync {} - -fn test(s: T) {} - -fn main() { - let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0)}); - test(us); - //~^ ERROR `std::cell::UnsafeCell>` cannot be shared between threads safely - - let uns = UnsafeCell::new(NoSync); - test(uns); - //~^ ERROR `std::cell::UnsafeCell` cannot be shared between threads safely [E0277] - - let ms = MySync{u: uns}; - test(ms); - //~^ ERROR `std::cell::UnsafeCell` cannot be shared between threads safely [E0277] - - test(NoSync); - //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] -} diff --git a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs b/src/test/compile-fail/typeck_type_placeholder_mismatch.rs deleted file mode 100644 index 91e3c38322e..00000000000 --- a/src/test/compile-fail/typeck_type_placeholder_mismatch.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test checks that genuine type errors with partial -// type hints are understandable. - -use std::marker::PhantomData; - -struct Foo(PhantomData); -struct Bar(PhantomData); - -pub fn main() { -} - -fn test1() { - let x: Foo<_> = Bar::(PhantomData); - //~^ ERROR mismatched types - //~| expected type `Foo<_>` - //~| found type `Bar` - //~| expected struct `Foo`, found struct `Bar` - let y: Foo = x; -} - -fn test2() { - let x: Foo<_> = Bar::(PhantomData); - //~^ ERROR mismatched types - //~| expected type `Foo<_>` - //~| found type `Bar` - //~| expected struct `Foo`, found struct `Bar` -} diff --git a/src/test/compile-fail/ufcs-explicit-self-bad.rs b/src/test/compile-fail/ufcs-explicit-self-bad.rs deleted file mode 100644 index a0d1f2dc331..00000000000 --- a/src/test/compile-fail/ufcs-explicit-self-bad.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct Foo { - f: isize, -} - -impl Foo { - fn foo(self: isize, x: isize) -> isize { - //~^ ERROR invalid `self` type - self.f + x - } -} - -struct Bar { - f: T, -} - -impl Bar { - fn foo(self: Bar, x: isize) -> isize { - //~^ ERROR invalid `self` type - x - } - fn bar(self: &Bar, x: isize) -> isize { - //~^ ERROR invalid `self` type - x - } -} - -trait SomeTrait { - fn dummy1(&self); - fn dummy2(&self); - fn dummy3(&self); -} - -impl<'a, T> SomeTrait for &'a Bar { - fn dummy1(self: &&'a Bar) { } - fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver - //~^ ERROR mismatched method receiver - fn dummy3(self: &&Bar) {} - //~^ ERROR mismatched method receiver - //~| expected type `&'a Bar` - //~| found type `&Bar` - //~| lifetime mismatch - //~| ERROR mismatched method receiver - //~| expected type `&'a Bar` - //~| found type `&Bar` - //~| lifetime mismatch -} - -fn main() { - let foo = box Foo { - f: 1, - }; - println!("{}", foo.foo(2)); - let bar = box Bar { - f: 1, - }; - println!("{} {}", bar.foo(2), bar.bar(2)); -} diff --git a/src/test/compile-fail/ufcs-partially-resolved.rs b/src/test/compile-fail/ufcs-partially-resolved.rs deleted file mode 100644 index f7120ddb114..00000000000 --- a/src/test/compile-fail/ufcs-partially-resolved.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(associated_type_defaults)] - -trait Tr { - type Y = u16; - fn Y() {} -} -impl Tr for u8 {} - -trait Dr { - type X = u16; - fn Z() {} -} -impl Dr for u8 {} - -enum E { Y } -type A = u32; - -fn main() { - let _: ::N; //~ ERROR cannot find associated type `N` in trait `Tr` - let _: ::N; //~ ERROR cannot find associated type `N` in enum `E` - let _: ::N; //~ ERROR cannot find associated type `N` in `A` - ::N; //~ ERROR cannot find method or associated constant `N` in trait `Tr` - ::N; //~ ERROR cannot find method or associated constant `N` in enum `E` - ::N; //~ ERROR cannot find method or associated constant `N` in `A` - let _: ::Y; // OK - let _: ::Y; //~ ERROR expected associated type, found variant `E::Y` - ::Y; // OK - ::Y; //~ ERROR expected method or associated constant, found unit variant `E::Y` - - let _: ::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` - let _: ::N::NN; //~ ERROR cannot find associated type `N` in enum `E` - let _: ::N::NN; //~ ERROR cannot find associated type `N` in `A` - ::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` - ::N::NN; //~ ERROR cannot find associated type `N` in enum `E` - ::N::NN; //~ ERROR cannot find associated type `N` in `A` - let _: ::Y::NN; //~ ERROR ambiguous associated type - let _: ::Y::NN; //~ ERROR expected associated type, found variant `E::Y` - ::Y::NN; //~ ERROR no associated item named `NN` found for type `::Y` - ::Y::NN; //~ ERROR expected associated type, found variant `E::Y` - - let _: ::NN; //~ ERROR cannot find associated type `NN` in `Tr::N` - let _: ::NN; //~ ERROR cannot find associated type `NN` in `E::N` - let _: ::NN; //~ ERROR cannot find associated type `NN` in `A::N` - ::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::N` - ::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N` - ::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N` - let _: ::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y` - let _: ::NN; //~ ERROR failed to resolve. Not a module `Y` - ::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y` - ::NN; //~ ERROR failed to resolve. Not a module `Y` - - let _: ::Z; //~ ERROR expected associated type, found method `Dr::Z` - ::X; //~ ERROR expected method or associated constant, found associated type `Dr::X` - let _: ::Z::N; //~ ERROR expected associated type, found method `Dr::Z` - ::X::N; //~ ERROR no associated item named `N` found for type `::X` -} diff --git a/src/test/compile-fail/ufcs-qpath-missing-params.rs b/src/test/compile-fail/ufcs-qpath-missing-params.rs deleted file mode 100644 index 5c108e05216..00000000000 --- a/src/test/compile-fail/ufcs-qpath-missing-params.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::borrow::Cow; - -pub trait IntoCow<'a, B: ?Sized> where B: ToOwned { - fn into_cow(self) -> Cow<'a, B>; -} - -impl<'a> IntoCow<'a, str> for String { - fn into_cow(self) -> Cow<'a, str> { - Cow::Owned(self) - } -} - -fn main() { - ::into_cow("foo".to_string()); - //~^ ERROR too few type parameters provided: expected 1 type parameter -} diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs deleted file mode 100644 index caf510071bd..00000000000 --- a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Add; - -fn main() { - >::add(1, 2); - //~^ ERROR cannot add `u32` to `i32` - >::add(1u32, 2); - //~^ ERROR mismatched types - >::add(1, 2u32); - //~^ ERROR mismatched types -} diff --git a/src/test/compile-fail/unboxed-closure-feature-gate.rs b/src/test/compile-fail/unboxed-closure-feature-gate.rs deleted file mode 100644 index 3a3ea058b4e..00000000000 --- a/src/test/compile-fail/unboxed-closure-feature-gate.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that parenthetical notation is feature-gated except with the -// `Fn` traits. - -use std::marker; - -trait Foo { - type Output; - - fn dummy(&self, a: A) { } -} - -fn main() { - let x: Box; - //~^ ERROR parenthetical notation is only stable when used with `Fn`-family - - // No errors with these: - let x: Box; - let x: Box; - let x: Box; -} diff --git a/src/test/compile-fail/unboxed-closure-illegal-move.rs b/src/test/compile-fail/unboxed-closure-illegal-move.rs deleted file mode 100644 index 427be560760..00000000000 --- a/src/test/compile-fail/unboxed-closure-illegal-move.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] - -// Tests that we can't move out of an unboxed closure environment -// if the upvar is captured by ref or the closure takes self by -// reference. - -fn to_fn>(f: F) -> F { f } -fn to_fn_mut>(f: F) -> F { f } -fn to_fn_once>(f: F) -> F { f } - -fn main() { - // By-ref cases - { - let x = Box::new(0); - let f = to_fn(|| drop(x)); //~ ERROR cannot move - } - { - let x = Box::new(0); - let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move - } - { - let x = Box::new(0); - let f = to_fn_once(|| drop(x)); // OK -- FnOnce - } - // By-value cases - { - let x = Box::new(0); - let f = to_fn(move || drop(x)); //~ ERROR cannot move - } - { - let x = Box::new(0); - let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move - } - { - let x = Box::new(0); - let f = to_fn_once(move || drop(x)); // this one is ok - } -} diff --git a/src/test/compile-fail/unboxed-closure-immutable-capture.rs b/src/test/compile-fail/unboxed-closure-immutable-capture.rs deleted file mode 100644 index 2d998374229..00000000000 --- a/src/test/compile-fail/unboxed-closure-immutable-capture.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that even unboxed closures that are capable of mutating their -// environment cannot mutate captured variables that have not been -// declared mutable (#18335) - -fn set(x: &mut usize) { *x = 0; } - -fn main() { - let x = 0; - move || x = 1; //~ ERROR cannot assign - move || set(&mut x); //~ ERROR cannot borrow - move || x = 1; //~ ERROR cannot assign - move || set(&mut x); //~ ERROR cannot borrow - || x = 1; //~ ERROR cannot assign - // FIXME: this should be `cannot borrow` (issue #18330) - || set(&mut x); //~ ERROR cannot assign - || x = 1; //~ ERROR cannot assign - // FIXME: this should be `cannot borrow` (issue #18330) - || set(&mut x); //~ ERROR cannot assign -} diff --git a/src/test/compile-fail/unboxed-closure-region.rs b/src/test/compile-fail/unboxed-closure-region.rs deleted file mode 100644 index 1c86dda3378..00000000000 --- a/src/test/compile-fail/unboxed-closure-region.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an unboxed closure that captures a free variable by -// reference cannot escape the region of that variable. -fn main() { - let _f = { - let x = 0; - || x //~ ERROR `x` does not live long enough - }; -} diff --git a/src/test/compile-fail/unboxed-closure-sugar-default.rs b/src/test/compile-fail/unboxed-closure-sugar-default.rs deleted file mode 100644 index 849f7e0573c..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-default.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test interaction between unboxed closure sugar and default type -// parameters (should be exactly as if angle brackets were used). - -#![feature(unboxed_closures)] -#![allow(dead_code)] - -trait Foo { - type Output; - fn dummy(&self, t: T, v: V); -} - -trait Eq { fn same_types(&self, x: &X) -> bool { true } } -impl Eq for X { } -fn eq() where A : Eq { } - -fn test<'a,'b>() { - // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); - - // In angle version, we supply something other than the default - eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); - //~^ ERROR E0277 - - // Supply default explicitly. - eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >(); -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs deleted file mode 100644 index 0cf44a2ca61..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the unboxed closure sugar can be used with an arbitrary -// struct type and that it is equivalent to the same syntax using -// angle brackets. This test covers only simple types and in -// particular doesn't test bound regions. - -#![feature(unboxed_closures)] -#![allow(dead_code)] - -trait Foo { - type Output; - fn dummy(&self, t: T, u: Self::Output); -} - -trait Eq { } -impl Eq for X { } -fn eq>() { } - -fn test<'a,'b>() { - // No errors expected: - eq::< Foo<(),Output=()>, Foo() >(); - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); - eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >(); - eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >(); - eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >(); - - // Test that anonymous regions in `()` form are equivalent - // to fresh bound regions, and that we can intermingle - // named and anonymous as we choose: - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'x> Foo(&'x isize,&usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'y> Foo(&isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - Foo(&isize,&usize) -> usize >(); - - // lifetime elision - eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>, - Foo(&isize) -> &isize >(); - - // Errors expected: - eq::< Foo<(),Output=()>, - Foo(char) >(); - //~^^ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs b/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs deleted file mode 100644 index a6f59b78823..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-lifetime-elision.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the unboxed closure sugar can be used with an arbitrary -// struct type and that it is equivalent to the same syntax using -// angle brackets. This test covers only simple types and in -// particular doesn't test bound regions. - -#![feature(unboxed_closures)] -#![allow(dead_code)] - -use std::marker; - -trait Foo { - type Output; - fn dummy(&self, t: T); -} - -trait Eq { } -impl Eq for X { } -fn eq>() { } - -fn main() { - eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>, - Foo(&isize) -> &isize >(); - eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, - Foo(&isize) -> (&isize, &isize) >(); - - let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier -} diff --git a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs deleted file mode 100644 index ed27a4d0b2a..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// Test that the `Fn` traits require `()` form without a feature gate. - -fn bar1(x: &Fn<(), Output=()>) { - //~^ ERROR of `Fn`-family traits' type parameters is subject to change -} - -fn bar2(x: &T) where T: Fn<()> { - //~^ ERROR of `Fn`-family traits' type parameters is subject to change -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-region.rs b/src/test/compile-fail/unboxed-closure-sugar-region.rs deleted file mode 100644 index 18a1185d695..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-region.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test interaction between unboxed closure sugar and region -// parameters (should be exactly as if angle brackets were used -// and regions omitted). - -#![feature(unboxed_closures)] -#![allow(dead_code)] - -use std::marker; - -trait Foo<'a,T> { - type Output; - fn dummy(&'a self) -> &'a (T,Self::Output); -} - -trait Eq { fn is_of_eq_type(&self, x: &X) -> bool { true } } -impl Eq for X { } -fn eq>() { } - -fn same_type>(a: A, b: B) { } - -fn test<'a,'b>() { - // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); - - // Here we specify 'static explicitly in angle-bracket version. - // Parenthesized winds up getting inferred. - eq::< Foo<'static, (isize,),Output=()>, Foo(isize) >(); -} - -fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { -//~^ ERROR wrong number of lifetime parameters: expected 1, found 0 - // Here, the omitted lifetimes are expanded to distinct things. - same_type(x, y) -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs deleted file mode 100644 index 3f88f16d2c3..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// Test that parentheses form doesn't work with struct types appearing in local variables. - -struct Bar { - f: A -} - -fn bar() { - let x: Box = panic!(); - //~^ ERROR parenthesized parameters may only be used with a trait -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs deleted file mode 100644 index 42fffe546c2..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct-3.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that parentheses form parses in expression paths. - -struct Bar { - f: A, r: R -} - -impl Bar { - fn new() -> Bar { panic!() } -} - -fn bar() { - let b = Bar::::new(); // OK - - let b = Bar::(isize, usize)::new(); // OK too (for the parser) - //~^ ERROR parenthesized parameters may only be used with a trait -} - -fn main() {} diff --git a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs b/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs deleted file mode 100644 index 5fcde4facbe..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-used-on-struct.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that parentheses form doesn't work with struct types appearing in argument types. - -struct Bar { - f: A -} - -fn foo(b: Box) { - //~^ ERROR parenthesized parameters may only be used with a trait - //~| ERROR the type placeholder `_` is not allowed within types on item signatures -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs deleted file mode 100644 index bb7e02d0d8b..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] - -trait One { fn foo(&self) -> A; } - -fn foo(_: &One()) //~ ERROR associated type `Output` not found for `One<()>` -{} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs deleted file mode 100644 index 20fdd52b82a..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] - -trait Three { fn dummy(&self) -> (A,B,C); } - -fn foo(_: &Three()) -//~^ ERROR wrong number of type arguments -//~| ERROR associated type `Output` not found -{} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs b/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs deleted file mode 100644 index 027fa6b0fe3..00000000000 --- a/src/test/compile-fail/unboxed-closure-sugar-wrong-number-number-type-parameters.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] - -trait Zero { fn dummy(&self); } - -fn foo(_: Zero()) - //~^ ERROR wrong number of type arguments - //~| ERROR associated type `Output` not found for `Zero` -{} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-borrow-conflict.rs b/src/test/compile-fail/unboxed-closures-borrow-conflict.rs deleted file mode 100644 index ad7e6784a0a..00000000000 --- a/src/test/compile-fail/unboxed-closures-borrow-conflict.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an unboxed closure that mutates a free variable will -// cause borrow conflicts. - -fn main() { - let mut x = 0; - let f = || x += 1; - let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed -} diff --git a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-1.rs b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-1.rs deleted file mode 100644 index ce60521034e..00000000000 --- a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-1.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various unsuccessful attempts to put the unboxed closure kind -// inference into an awkward position that might require fixed point -// iteration (basically where inferring the kind of a closure `c` -// would require knowing the kind of `c`). I currently believe this is -// impossible. - -fn a() { - // This case of recursion wouldn't even require fixed-point - // iteration, but it still doesn't work. The weird structure with - // the `Option` is to avoid giving any useful hints about the `Fn` - // kind via the expected type. - let mut factorial: Option u32>> = None; - - let f = |x: u32| -> u32 { - let g = factorial.as_ref().unwrap(); - //~^ ERROR `factorial` does not live long enough - if x == 0 {1} else {x * g(x-1)} - }; - - factorial = Some(Box::new(f)); -} - -fn b() { - let mut factorial: Option u32 + 'static>> = None; - - let f = |x: u32| -> u32 { - //~^ ERROR closure may outlive the current function, but it borrows `factorial` - let g = factorial.as_ref().unwrap(); - if x == 0 {1} else {x * g(x-1)} - }; - - factorial = Some(Box::new(f)); -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs deleted file mode 100644 index 8f5bf827fcf..00000000000 --- a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Various unsuccessful attempts to put the unboxed closure kind -// inference into an awkward position that might require fixed point -// iteration (basically where inferring the kind of a closure `c` -// would require knowing the kind of `c`). I currently believe this is -// impossible. - -fn a() { - let mut closure0 = None; - let vec = vec![1, 2, 3]; - - loop { - { - let closure1 = || { - match closure0.take() { - Some(c) => { - return c(); - //~^ ERROR type annotations needed - } - None => { } - } - }; - closure1(); - } - - closure0 = || vec; - } -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs deleted file mode 100644 index 2e865b2aac8..00000000000 --- a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks that the Fn trait hierarchy rules do not permit -// Fn to be used where FnMut is implemented. - -#![feature(fn_traits, unboxed_closures)] -#![feature(overloaded_calls)] - -use std::ops::{Fn,FnMut,FnOnce}; - -struct S; - -impl FnMut<(isize,)> for S { - extern "rust-call" fn call_mut(&mut self, (x,): (isize,)) -> isize { - x * x - } -} - -impl FnOnce<(isize,)> for S { - type Output = isize; - - extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) } -} - -fn call_itisize>(f: &F, x: isize) -> isize { - f.call((x,)) -} - -fn main() { - let x = call_it(&S, 22); - //~^ ERROR E0277 -} diff --git a/src/test/compile-fail/unboxed-closures-infer-argument-types-two-region-pointers.rs b/src/test/compile-fail/unboxed-closures-infer-argument-types-two-region-pointers.rs deleted file mode 100644 index bfb24c58722..00000000000 --- a/src/test/compile-fail/unboxed-closures-infer-argument-types-two-region-pointers.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(fn_traits)] - -// That a closure whose expected argument types include two distinct -// bound regions. - -use std::cell::Cell; - -fn doit(val: T, f: &F) - where F : Fn(&Cell<&T>, &T) -{ - let x = Cell::new(&val); - f.call((&x,&val)) -} - -pub fn main() { - doit(0, &|x, y| { - x.set(y); //~ ERROR E0312 - }); -} diff --git a/src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs b/src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs deleted file mode 100644 index 7c5ea031596..00000000000 --- a/src/test/compile-fail/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnMut`). - -fn main() { - let mut counter = 0; - - // Here this must be inferred to FnMut so that it can mutate counter, - // but we forgot the mut. - let tick1 = || { - counter += 1; - }; - - // In turn, tick2 must be inferred to FnMut so that it can call - // tick1, but we forgot the mut. The error message we currently - // get seems... suboptimal. - let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` - tick1(); - }; - - tick2(); //~ ERROR cannot borrow -} diff --git a/src/test/compile-fail/unboxed-closures-infer-fnmut-missing-mut.rs b/src/test/compile-fail/unboxed-closures-infer-fnmut-missing-mut.rs deleted file mode 100644 index 9e4ed307996..00000000000 --- a/src/test/compile-fail/unboxed-closures-infer-fnmut-missing-mut.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnMut`). - -fn main() { - let mut counter = 0; - let tick = || counter += 1; - tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable -} diff --git a/src/test/compile-fail/unboxed-closures-infer-fnmut-move-missing-mut.rs b/src/test/compile-fail/unboxed-closures-infer-fnmut-move-missing-mut.rs deleted file mode 100644 index de17d25b4c3..00000000000 --- a/src/test/compile-fail/unboxed-closures-infer-fnmut-move-missing-mut.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnMut`). - -fn main() { - let mut counter = 0; - let tick = move || counter += 1; - tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable -} diff --git a/src/test/compile-fail/unboxed-closures-infer-fnonce-call-twice.rs b/src/test/compile-fail/unboxed-closures-infer-fnonce-call-twice.rs deleted file mode 100644 index 0050fbdde26..00000000000 --- a/src/test/compile-fail/unboxed-closures-infer-fnonce-call-twice.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnMut`). - -use std::mem; - -fn main() { - let mut counter: Vec = Vec::new(); - let tick = || mem::drop(counter); - tick(); - tick(); //~ ERROR use of moved value: `tick` -} diff --git a/src/test/compile-fail/unboxed-closures-infer-fnonce-move-call-twice.rs b/src/test/compile-fail/unboxed-closures-infer-fnonce-move-call-twice.rs deleted file mode 100644 index f9709b8c596..00000000000 --- a/src/test/compile-fail/unboxed-closures-infer-fnonce-move-call-twice.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnMut`). - -use std::mem; - -fn main() { - let mut counter: Vec = Vec::new(); - let tick = move || mem::drop(counter); - tick(); - tick(); //~ ERROR use of moved value: `tick` -} diff --git a/src/test/compile-fail/unboxed-closures-mutate-upvar.rs b/src/test/compile-fail/unboxed-closures-mutate-upvar.rs deleted file mode 100644 index 35052ec0bd5..00000000000 --- a/src/test/compile-fail/unboxed-closures-mutate-upvar.rs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we cannot mutate an outer variable that is not declared -// as `mut` through a closure. Also test that we CAN mutate a moved copy, -// unless this is a `Fn` closure. Issue #16749. - -#![feature(unboxed_closures)] - -use std::mem; - -fn to_fn>(f: F) -> F { f } -fn to_fn_mut>(f: F) -> F { f } - -fn a() { - let n = 0; - let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign - n += 1; - }); -} - -fn b() { - let mut n = 0; - let mut f = to_fn_mut(|| { - n += 1; // OK - }); -} - -fn c() { - let n = 0; - let mut f = to_fn_mut(move || { - // If we just did a straight-forward desugaring, this would - // compile, but we do something a bit more subtle, and hence - // we get an error. - n += 1; //~ ERROR cannot assign - }); -} - -fn d() { - let mut n = 0; - let mut f = to_fn_mut(move || { - n += 1; // OK - }); -} - -fn e() { - let n = 0; - let mut f = to_fn(move || { - n += 1; //~ ERROR cannot assign - }); -} - -fn f() { - let mut n = 0; - let mut f = to_fn(move || { - n += 1; //~ ERROR cannot assign - }); -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs b/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs deleted file mode 100644 index f20719ec7fa..00000000000 --- a/src/test/compile-fail/unboxed-closures-mutated-upvar-from-fn-closure.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Test that a by-ref `FnMut` closure gets an error when it tries to -// mutate a value. - -fn call(f: F) where F : Fn() { - f(); -} - -fn main() { - let mut counter = 0; - call(|| { - counter += 1; - //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure - //[mir]~^^ ERROR cannot assign to `counter` - }); -} diff --git a/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs b/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs deleted file mode 100644 index 433c0c839c5..00000000000 --- a/src/test/compile-fail/unboxed-closures-recursive-fn-using-fn-mut.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(core, fn_traits, unboxed_closures)] - -use std::marker::PhantomData; - -// An erroneous variant of `run-pass/unboxed_closures-infer-recursive-fn.rs` -// where we attempt to perform mutation in the recursive function. This fails to compile -// because it winds up requiring `FnMut` which enforces linearity. - -struct YCombinator { - func: F, - marker: PhantomData<(A,R)>, -} - -impl YCombinator { - fn new(f: F) -> YCombinator { - YCombinator { func: f, marker: PhantomData } - } -} - -impl R, A) -> R> FnMut<(A,)> for YCombinator { - extern "rust-call" fn call_mut(&mut self, (arg,): (A,)) -> R { - (self.func)(self, arg) - //~^ ERROR cannot borrow `*self` as mutable more than once at a time - } -} - -impl R, A) -> R> FnOnce<(A,)> for YCombinator { - type Output = R; - extern "rust-call" fn call_once(mut self, args: (A,)) -> R { - self.call_mut(args) - } -} - -fn main() { - let mut counter = 0; - let factorial = |recur: &mut FnMut(u32) -> u32, arg: u32| -> u32 { - counter += 1; - if arg == 0 {1} else {arg * recur(arg-1)} - }; - let mut factorial: YCombinator<_,u32,u32> = YCombinator::new(factorial); - let mut r = factorial(10); - assert_eq!(3628800, r); -} diff --git a/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs b/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs deleted file mode 100644 index 1c133fbfcdb..00000000000 --- a/src/test/compile-fail/unboxed-closures-static-call-wrong-trait.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unboxed_closures)] - -fn to_fn_mut>(f: F) -> F { f } - -fn main() { - let mut_ = to_fn_mut(|x| x); - mut_.call((0, )); //~ ERROR no method named `call` found -} diff --git a/src/test/compile-fail/unboxed-closures-type-mismatch.rs b/src/test/compile-fail/unboxed-closures-type-mismatch.rs deleted file mode 100644 index dba4c8cc2e9..00000000000 --- a/src/test/compile-fail/unboxed-closures-type-mismatch.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::FnMut; - -pub fn main() { - let mut f = |x: isize, y: isize| -> isize { x + y }; - let z = f(1_usize, 2); //~ ERROR mismatched types - println!("{}", z); -} diff --git a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs b/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs deleted file mode 100644 index 5ba93bf483f..00000000000 --- a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that unsafe extern fn pointers do not implement any Fn traits. - -use std::ops::{Fn,FnMut,FnOnce}; - -unsafe fn square(x: &isize) -> isize { (*x) * (*x) } - -fn call_itisize>(_: &F, _: isize) -> isize { 0 } -fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } -fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } - -fn a() { - let x = call_it(&square, 22); - //~^ ERROR E0277 -} - -fn b() { - let y = call_it_mut(&mut square, 22); - //~^ ERROR E0277 -} - -fn c() { - let z = call_it_once(square, 22); - //~^ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-wrong-abi.rs b/src/test/compile-fail/unboxed-closures-wrong-abi.rs deleted file mode 100644 index ff06f7c559b..00000000000 --- a/src/test/compile-fail/unboxed-closures-wrong-abi.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that unsafe extern fn pointers do not implement any Fn traits. - -use std::ops::{Fn,FnMut,FnOnce}; - -extern "C" fn square(x: &isize) -> isize { (*x) * (*x) } - -fn call_itisize>(_: &F, _: isize) -> isize { 0 } -fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } -fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } - -fn a() { - let x = call_it(&square, 22); - //~^ ERROR E0277 -} - -fn b() { - let y = call_it_mut(&mut square, 22); - //~^ ERROR E0277 -} - -fn c() { - let z = call_it_once(square, 22); - //~^ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs b/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs deleted file mode 100644 index d77750d2a04..00000000000 --- a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that unsafe extern fn pointers do not implement any Fn traits. - -use std::ops::{Fn,FnMut,FnOnce}; - -unsafe fn square(x: isize) -> isize { x * x } -// note: argument type here is `isize`, not `&isize` - -fn call_itisize>(_: &F, _: isize) -> isize { 0 } -fn call_it_mutisize>(_: &mut F, _: isize) -> isize { 0 } -fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } - -fn a() { - let x = call_it(&square, 22); - //~^ ERROR E0277 -} - -fn b() { - let y = call_it_mut(&mut square, 22); - //~^ ERROR E0277 -} - -fn c() { - let z = call_it_once(square, 22); - //~^ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/underscore-lifetime-binders.rs b/src/test/compile-fail/underscore-lifetime-binders.rs deleted file mode 100644 index 6a6698957d9..00000000000 --- a/src/test/compile-fail/underscore-lifetime-binders.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo<'a>(&'a u8); -struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier - -impl Foo<'_> { //~ ERROR missing lifetime specifier - fn x() {} -} - -fn foo<'_> //~ ERROR invalid lifetime parameter name: `'_` -(_: Foo<'_>) {} - -trait Meh<'a> {} -impl<'a> Meh<'a> for u8 {} - -fn meh() -> Box Meh<'_>> //~ ERROR invalid lifetime parameter name: `'_` -//~^ ERROR missing lifetime specifier -{ - Box::new(5u8) -} - -fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } //~ ERROR missing lifetime specifier - -fn main() { - let x = 5; - foo(Foo(&x)); - let _ = meh(); -} diff --git a/src/test/compile-fail/underscore-lifetime-elison-mismatch.rs b/src/test/compile-fail/underscore-lifetime-elison-mismatch.rs deleted file mode 100644 index b36c8eb324e..00000000000 --- a/src/test/compile-fail/underscore-lifetime-elison-mismatch.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch - -fn main() {} diff --git a/src/test/compile-fail/uninhabited-enum-cast.rs b/src/test/compile-fail/uninhabited-enum-cast.rs deleted file mode 100644 index 2a5d25e6b98..00000000000 --- a/src/test/compile-fail/uninhabited-enum-cast.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum E {} - -fn f(e: E) { - println!("{}", (e as isize).to_string()); //~ ERROR non-primitive cast -} - -fn main() {} diff --git a/src/test/compile-fail/uninhabited-irrefutable.rs b/src/test/compile-fail/uninhabited-irrefutable.rs deleted file mode 100644 index 05a97b855e7..00000000000 --- a/src/test/compile-fail/uninhabited-irrefutable.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] -#![feature(exhaustive_patterns)] - -mod foo { - pub struct SecretlyEmpty { - _priv: !, - } - - pub struct NotSoSecretlyEmpty { - pub _pub: !, - } -} - -struct NotSoSecretlyEmpty { - _priv: !, -} - -enum Foo { - A(foo::SecretlyEmpty), - B(foo::NotSoSecretlyEmpty), - C(NotSoSecretlyEmpty), - D(u32), -} - -fn main() { - let x: Foo = Foo::D(123); - let Foo::D(_y) = x; //~ ERROR refutable pattern in local binding: `A(_)` not covered -} - diff --git a/src/test/compile-fail/uninhabited-matches-feature-gated.rs b/src/test/compile-fail/uninhabited-matches-feature-gated.rs deleted file mode 100644 index 1d3f8ff12d8..00000000000 --- a/src/test/compile-fail/uninhabited-matches-feature-gated.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Void {} - -fn main() { - let x: Result = Ok(23); - let _ = match x { //~ ERROR non-exhaustive - Ok(n) => n, - }; - - let x: &Void = unsafe { std::mem::uninitialized() }; - let _ = match x {}; //~ ERROR non-exhaustive - - let x: (Void,) = unsafe { std::mem::uninitialized() }; - let _ = match x {}; //~ ERROR non-exhaustive - - let x: [Void; 1] = unsafe { std::mem::uninitialized() }; - let _ = match x {}; //~ ERROR non-exhaustive - - let x: &[Void] = unsafe { std::mem::uninitialized() }; - let _ = match x { //~ ERROR non-exhaustive - &[] => (), - }; - - let x: Void = unsafe { std::mem::uninitialized() }; - let _ = match x {}; // okay - - let x: Result = Ok(23); - let _ = match x { //~ ERROR non-exhaustive - Ok(x) => x, - }; - - let x: Result = Ok(23); - let Ok(x) = x; - //~^ ERROR refutable -} diff --git a/src/test/compile-fail/uninhabited-patterns.rs b/src/test/compile-fail/uninhabited-patterns.rs deleted file mode 100644 index 2cf4b78bdff..00000000000 --- a/src/test/compile-fail/uninhabited-patterns.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_patterns)] -#![feature(box_syntax)] -#![feature(never_type)] -#![feature(exhaustive_patterns)] -#![feature(slice_patterns)] -#![deny(unreachable_patterns)] - -mod foo { - pub struct SecretlyEmpty { - _priv: !, - } -} - -struct NotSoSecretlyEmpty { - _priv: !, -} - -fn foo() -> Option { - None -} - -fn main() { - let x: &[!] = &[]; - - match x { - &[] => (), - &[..] => (), //~ ERROR unreachable pattern - }; - - let x: Result, &[Result]> = Err(&[]); - match x { - Ok(box _) => (), //~ ERROR unreachable pattern - Err(&[]) => (), - Err(&[..]) => (), //~ ERROR unreachable pattern - } - - let x: Result> = Err(Err(123)); - match x { - Ok(_y) => (), - Err(Err(_y)) => (), - Err(Ok(_y)) => (), //~ ERROR unreachable pattern - } - - while let Some(_y) = foo() { - //~^ ERROR unreachable pattern - } -} - diff --git a/src/test/compile-fail/union-ub-fat-ptr.rs b/src/test/compile-fail/union-ub-fat-ptr.rs deleted file mode 100644 index 935e69d2e22..00000000000 --- a/src/test/compile-fail/union-ub-fat-ptr.rs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[repr(C)] -#[derive(Copy, Clone)] -struct SliceRepr { - ptr: *const u8, - len: usize, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct BadSliceRepr { - ptr: *const u8, - len: &'static u8, -} - -union SliceTransmute { - repr: SliceRepr, - bad: BadSliceRepr, - slice: &'static [u8], - str: &'static str, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct DynRepr { - ptr: *const u8, - vtable: *const u8, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct DynRepr2 { - ptr: *const u8, - vtable: *const u64, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct BadDynRepr { - ptr: *const u8, - vtable: usize, -} - -union DynTransmute { - repr: DynRepr, - repr2: DynRepr2, - bad: BadDynRepr, - rust: &'static Trait, -} - -trait Trait {} - -// OK -const A: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.str}; -// should lint -const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; -// bad -const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; -//~^ ERROR this constant likely exhibits undefined behavior - -// OK -const A2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.slice}; -// should lint -const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; -// bad -const C2: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; -//~^ ERROR this constant likely exhibits undefined behavior - -// bad -const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; -//~^ ERROR this constant likely exhibits undefined behavior -// bad -const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; -//~^ ERROR this constant likely exhibits undefined behavior -// bad -const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; -//~^ ERROR this constant likely exhibits undefined behavior - -fn main() { -} diff --git a/src/test/compile-fail/union/union-borrow-move-parent-sibling.rs b/src/test/compile-fail/union/union-borrow-move-parent-sibling.rs deleted file mode 100644 index 5f504feabb2..00000000000 --- a/src/test/compile-fail/union/union-borrow-move-parent-sibling.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] -#![allow(unused)] - -#[allow(unions_with_drop_fields)] -union U { - x: ((Vec, Vec), Vec), - y: Box>, -} - -unsafe fn parent_sibling_borrow() { - let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - let a = &mut u.x.0; - let a = &u.y; //~ ERROR cannot borrow `u.y` -} - -unsafe fn parent_sibling_move() { - let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - let a = u.x.0; - let a = u.y; //~ ERROR use of moved value: `u.y` -} - -unsafe fn grandparent_sibling_borrow() { - let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - let a = &mut (u.x.0).0; - let a = &u.y; //~ ERROR cannot borrow `u.y` -} - -unsafe fn grandparent_sibling_move() { - let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - let a = (u.x.0).0; - let a = u.y; //~ ERROR use of moved value: `u.y` -} - -unsafe fn deref_sibling_borrow() { - let mut u = U { y: Box::default() }; - let a = &mut *u.y; - let a = &u.x; //~ ERROR cannot borrow `u` (via `u.x`) -} - -unsafe fn deref_sibling_move() { - let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - let a = *u.y; - let a = u.x; //~ ERROR use of moved value: `u.x` -} - - -fn main() {} diff --git a/src/test/compile-fail/union/union-const-pat.rs b/src/test/compile-fail/union/union-const-pat.rs deleted file mode 100644 index 5f75e3cc4a2..00000000000 --- a/src/test/compile-fail/union/union-const-pat.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -union U { - a: usize, - b: usize, -} - -const C: U = U { a: 10 }; - -fn main() { - match C { - C => {} //~ ERROR cannot use unions in constant patterns - _ => {} - } -} diff --git a/src/test/compile-fail/union/union-copy.rs b/src/test/compile-fail/union/union-copy.rs deleted file mode 100644 index 9014b3f2956..00000000000 --- a/src/test/compile-fail/union/union-copy.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] - -#[derive(Clone)] -union U { - a: u8 -} - -#[derive(Clone)] -union W { - a: String -} - -impl Copy for U {} // OK -impl Copy for W {} //~ ERROR the trait `Copy` may not be implemented for this type - -fn main() {} diff --git a/src/test/compile-fail/union/union-derive-clone.rs b/src/test/compile-fail/union/union-derive-clone.rs deleted file mode 100644 index 6e226d7d79f..00000000000 --- a/src/test/compile-fail/union/union-derive-clone.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] - -#[derive(Clone)] //~ ERROR the trait bound `U1: std::marker::Copy` is not satisfied -union U1 { - a: u8, -} - -#[derive(Clone)] -union U2 { - a: u8, // OK -} - -impl Copy for U2 {} - -#[derive(Clone, Copy)] -union U3 { - a: u8, // OK -} - -#[derive(Clone, Copy)] -union U4 { - a: T, // OK -} - -#[derive(Clone)] -struct CloneNoCopy; - -fn main() { - let u = U4 { a: CloneNoCopy }; - let w = u.clone(); //~ ERROR no method named `clone` found for type `U4` -} diff --git a/src/test/compile-fail/union/union-derive.rs b/src/test/compile-fail/union/union-derive.rs deleted file mode 100644 index ffd290fb073..00000000000 --- a/src/test/compile-fail/union/union-derive.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Most traits cannot be derived for unions. - -#[derive( - PartialEq, //~ ERROR this trait cannot be derived for unions - PartialOrd, //~ ERROR this trait cannot be derived for unions - Ord, //~ ERROR this trait cannot be derived for unions - Hash, //~ ERROR this trait cannot be derived for unions - Default, //~ ERROR this trait cannot be derived for unions - Debug, //~ ERROR this trait cannot be derived for unions -)] -union U { - a: u8, - b: u16, -} - -fn main() {} diff --git a/src/test/compile-fail/union/union-empty.rs b/src/test/compile-fail/union/union-empty.rs deleted file mode 100644 index 1f499c49a68..00000000000 --- a/src/test/compile-fail/union/union-empty.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -union U {} //~ ERROR unions cannot have zero fields - -fn main() {} diff --git a/src/test/compile-fail/union/union-generic.rs b/src/test/compile-fail/union/union-generic.rs deleted file mode 100644 index 8bd422b42d8..00000000000 --- a/src/test/compile-fail/union/union-generic.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::rc::Rc; - -union U { - a: T -} - -fn main() { - let u = U { a: Rc::new(0u32) }; - //~^ ERROR the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied - let u = U::> { a: Default::default() }; - //~^ ERROR the trait bound `std::rc::Rc: std::marker::Copy` is not satisfied -} diff --git a/src/test/compile-fail/union/union-lint-dead-code.rs b/src/test/compile-fail/union/union-lint-dead-code.rs deleted file mode 100644 index a64187c5f23..00000000000 --- a/src/test/compile-fail/union/union-lint-dead-code.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(dead_code)] - -union Foo { - x: usize, - b: bool, //~ ERROR: field is never used - _unused: u16, -} - -fn field_read(f: Foo) -> usize { - unsafe { f.x } -} - -fn main() { - let _ = field_read(Foo { x: 2 }); -} diff --git a/src/test/compile-fail/union/union-nonrepresentable.rs b/src/test/compile-fail/union/union-nonrepresentable.rs deleted file mode 100644 index cb4683c2a0e..00000000000 --- a/src/test/compile-fail/union/union-nonrepresentable.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] - -union U { //~ ERROR recursive type `U` has infinite size - a: u8, - b: U, -} - -fn main() {} diff --git a/src/test/compile-fail/union/union-repr-c.rs b/src/test/compile-fail/union/union-repr-c.rs deleted file mode 100644 index 36c42ce1104..00000000000 --- a/src/test/compile-fail/union/union-repr-c.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] -#![deny(improper_ctypes)] - -#[repr(C)] -union U { - a: u8, -} - -union W { - a: u8, -} - -extern "C" { - static FOREIGN1: U; // OK - static FOREIGN2: W; //~ ERROR union has unspecified layout -} - -fn main() {} diff --git a/src/test/compile-fail/union/union-unsafe.rs b/src/test/compile-fail/union/union-unsafe.rs deleted file mode 100644 index d993816e6f4..00000000000 --- a/src/test/compile-fail/union/union-unsafe.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] - -union U1 { - a: u8 -} - -union U2 { - a: String -} - -union U3 { - a: T -} - -union U4 { - a: T -} - -fn generic_noncopy() { - let mut u3 = U3 { a: T::default() }; - u3.a = T::default(); //~ ERROR assignment to non-`Copy` union field is unsafe -} - -fn generic_copy() { - let mut u3 = U3 { a: T::default() }; - u3.a = T::default(); // OK - let mut u4 = U4 { a: T::default() }; - u4.a = T::default(); // OK -} - -fn main() { - let mut u1 = U1 { a: 10 }; // OK - let a = u1.a; //~ ERROR access to union field is unsafe - u1.a = 11; // OK - let U1 { a } = u1; //~ ERROR access to union field is unsafe - if let U1 { a: 12 } = u1 {} //~ ERROR access to union field is unsafe - // let U1 { .. } = u1; // OK - - let mut u2 = U2 { a: String::from("old") }; // OK - u2.a = String::from("new"); //~ ERROR assignment to non-`Copy` union field is unsafe - let mut u3 = U3 { a: 0 }; // OK - u3.a = 1; // OK - let mut u3 = U3 { a: String::from("old") }; // OK - u3.a = String::from("new"); //~ ERROR assignment to non-`Copy` union field is unsafe -} diff --git a/src/test/compile-fail/union/union-unsized.rs b/src/test/compile-fail/union/union-unsized.rs deleted file mode 100644 index d79c2ed710e..00000000000 --- a/src/test/compile-fail/union/union-unsized.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] - -union U { - a: str, - //~^ ERROR the size for values of type - - b: u8, -} - -union W { - a: u8, - b: str, - //~^ ERROR the size for values of type -} - -fn main() {} diff --git a/src/test/compile-fail/union/union-with-drop-fields-lint.rs b/src/test/compile-fail/union/union-with-drop-fields-lint.rs deleted file mode 100644 index 87a72efbe08..00000000000 --- a/src/test/compile-fail/union/union-with-drop-fields-lint.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(untagged_unions)] -#![allow(dead_code)] -#![deny(unions_with_drop_fields)] - -union U { - a: u8, // OK -} - -union W { - a: String, //~ ERROR union contains a field with possibly non-trivial drop code - b: String, // OK, only one field is reported -} - -struct S(String); - -// `S` doesn't implement `Drop` trait, but still has non-trivial destructor -union Y { - a: S, //~ ERROR union contains a field with possibly non-trivial drop code -} - -// We don't know if `T` is trivially-destructable or not until trans -union J { - a: T, //~ ERROR union contains a field with possibly non-trivial drop code -} - -union H { - a: T, // OK, `T` is `Copy`, no destructor -} - -fn main() {} diff --git a/src/test/compile-fail/unique-object-noncopyable.rs b/src/test/compile-fail/unique-object-noncopyable.rs deleted file mode 100644 index c44718c4fc9..00000000000 --- a/src/test/compile-fail/unique-object-noncopyable.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -trait Foo { - fn f(&self); -} - -struct Bar { - x: isize, -} - -impl Drop for Bar { - fn drop(&mut self) {} -} - -impl Foo for Bar { - fn f(&self) { - println!("hi"); - } -} - -fn main() { - let x = box Bar { x: 10 }; - let y: Box = x as Box; - let _z = y.clone(); //~ ERROR no method named `clone` found -} diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs deleted file mode 100644 index c09feec1d4a..00000000000 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Debug)] -struct r { - b: bool, -} - -impl Drop for r { - fn drop(&mut self) {} -} - -fn main() { - let i = Box::new(r { b: true }); - let _j = i.clone(); //~ ERROR no method named `clone` found - println!("{:?}", i); -} diff --git a/src/test/compile-fail/unknown-lint-tool-name.rs b/src/test/compile-fail/unknown-lint-tool-name.rs deleted file mode 100644 index 78b736edceb..00000000000 --- a/src/test/compile-fail/unknown-lint-tool-name.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(tool_lints)] - -#![deny(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` - -#[allow(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` -fn main() {} diff --git a/src/test/compile-fail/unknown-tool-name.rs b/src/test/compile-fail/unknown-tool-name.rs deleted file mode 100644 index 99c336c28cd..00000000000 --- a/src/test/compile-fail/unknown-tool-name.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(proc_macro_path_invoc)] - -#[foo::bar] //~ ERROR failed to resolve. Use of undeclared type or module `foo` -fn main() {} diff --git a/src/test/compile-fail/unop-move-semantics.rs b/src/test/compile-fail/unop-move-semantics.rs deleted file mode 100644 index 94656667598..00000000000 --- a/src/test/compile-fail/unop-move-semantics.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that move restrictions are enforced on overloaded unary operations - -use std::ops::Not; - -fn move_then_borrow + Clone>(x: T) { - !x; - - x.clone(); //~ ERROR: use of moved value -} - -fn move_borrowed>(x: T, mut y: T) { - let m = &x; - let n = &mut y; - - !x; //~ ERROR: cannot move out of `x` because it is borrowed - - !y; //~ ERROR: cannot move out of `y` because it is borrowed -} - -fn illegal_dereference>(mut x: T, y: T) { - let m = &mut x; - let n = &y; - - !*m; //~ ERROR: cannot move out of borrowed content - - !*n; //~ ERROR: cannot move out of borrowed content -} - -fn main() {} diff --git a/src/test/compile-fail/unop-neg-bool.rs b/src/test/compile-fail/unop-neg-bool.rs deleted file mode 100644 index 316e17c54ad..00000000000 --- a/src/test/compile-fail/unop-neg-bool.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - -true; //~ ERROR cannot apply unary operator `-` to type `bool` -} diff --git a/src/test/compile-fail/unreachable-arm.rs b/src/test/compile-fail/unreachable-arm.rs deleted file mode 100644 index df827d2c784..00000000000 --- a/src/test/compile-fail/unreachable-arm.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_patterns)] -#![feature(box_syntax)] -#![allow(dead_code)] -#![deny(unreachable_patterns)] - -enum Foo { A(Box, isize), B(usize), } - -fn main() { - match Foo::B(1) { - Foo::B(_) | Foo::A(box _, 1) => { } - Foo::A(_, 1) => { } //~ ERROR unreachable pattern - _ => { } - } -} - diff --git a/src/test/compile-fail/unreachable-code.rs b/src/test/compile-fail/unreachable-code.rs deleted file mode 100644 index dd08eed5df9..00000000000 --- a/src/test/compile-fail/unreachable-code.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unreachable_code)] -#![allow(unused_variables)] - -fn main() { - loop{} - - let a = 3; //~ ERROR: unreachable statement -} diff --git a/src/test/compile-fail/unreachable-in-call.rs b/src/test/compile-fail/unreachable-in-call.rs deleted file mode 100644 index 72462468432..00000000000 --- a/src/test/compile-fail/unreachable-in-call.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![deny(unreachable_code)] - -fn diverge() -> ! { panic!() } - -fn get_u8() -> u8 { - 1 -} -fn call(_: u8, _: u8) { - -} -fn diverge_first() { - call(diverge(), - get_u8()); //~ ERROR unreachable expression -} -fn diverge_second() { - call( //~ ERROR unreachable expression - get_u8(), - diverge()); -} - -fn main() {} diff --git a/src/test/compile-fail/unreachable-loop-patterns.rs b/src/test/compile-fail/unreachable-loop-patterns.rs deleted file mode 100644 index cfd829e416e..00000000000 --- a/src/test/compile-fail/unreachable-loop-patterns.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] -#![feature(exhaustive_patterns)] -#![deny(unreachable_patterns)] - -fn main() { - let x: &[!] = &[]; - - for _ in x {} - //~^ ERROR unreachable pattern -} - diff --git a/src/test/compile-fail/unreachable-try-pattern.rs b/src/test/compile-fail/unreachable-try-pattern.rs deleted file mode 100644 index df340095bb4..00000000000 --- a/src/test/compile-fail/unreachable-try-pattern.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(never_type)] -#![feature(exhaustive_patterns, rustc_attrs)] -#![warn(unreachable_code)] -#![warn(unreachable_patterns)] - -enum Void {} - -impl From for i32 { - fn from(v: Void) -> i32 { - match v {} - } -} - -fn bar(x: Result) -> Result { - x? -} - -fn foo(x: Result) -> Result { - let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?; - //~^ WARN unreachable pattern - //~| WARN unreachable expression - Ok(y) -} - -fn qux(x: Result) -> Result { - Ok(x?) -} - -fn vom(x: Result) -> Result { - let y = (match x { Ok(n) => Ok(n), Err(e) => Err(e) })?; - //~^ WARN unreachable pattern - Ok(y) -} - -#[rustc_error] -fn main() { //~ ERROR: compilation successful - let _ = bar(Err(123)); - let _ = foo(Err(123)); - let _ = qux(Ok(123)); - let _ = vom(Ok(123)); -} - diff --git a/src/test/compile-fail/unreachable-variant.rs b/src/test/compile-fail/unreachable-variant.rs deleted file mode 100644 index 5983c83f8b4..00000000000 --- a/src/test/compile-fail/unreachable-variant.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:unreachable_variant.rs - -extern crate unreachable_variant as other; - -fn main() { - let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private -} diff --git a/src/test/compile-fail/unresolved-extern-mod-suggestion.rs b/src/test/compile-fail/unresolved-extern-mod-suggestion.rs deleted file mode 100644 index 714b73ec739..00000000000 --- a/src/test/compile-fail/unresolved-extern-mod-suggestion.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate core; -use core; -//~^ ERROR the name `core` is defined multiple times - -fn main() {} diff --git a/src/test/compile-fail/unresolved-import-recovery.rs b/src/test/compile-fail/unresolved-import-recovery.rs deleted file mode 100644 index 8173f69191d..00000000000 --- a/src/test/compile-fail/unresolved-import-recovery.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that unresolved imports do not create additional errors and ICEs - -mod m { - pub use unresolved; //~ ERROR unresolved import `unresolved` - - fn f() { - let unresolved = 0; // OK - } -} - -fn main() { - match 0u8 { - m::unresolved => {} // OK - m::unresolved(..) => {} // OK - m::unresolved{..} => {} // OK - } -} diff --git a/src/test/compile-fail/unresolved-import.rs b/src/test/compile-fail/unresolved-import.rs deleted file mode 100644 index a3eeb6de96b..00000000000 --- a/src/test/compile-fail/unresolved-import.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013-2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -use foo::bar; //~ ERROR unresolved import `foo` [E0432] - //~^ Maybe a missing `extern crate foo;`? - -use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432] - //~^ no `Baz` in `bar`. Did you mean to use `Bar`? - -use food::baz; //~ ERROR unresolved import `food::baz` - //~^ no `baz` in `food`. Did you mean to use `bag`? - -use food::{beens as Foo}; //~ ERROR unresolved import `food::beens` [E0432] - //~^ no `beens` in `food`. Did you mean to use `beans`? - -mod bar { - pub struct Bar; -} - -mod food { - pub use self::zug::baz::{self as bag, foobar as beans}; - - mod zug { - pub mod baz { - pub struct foobar; - } - } -} - -mod m { - enum MyEnum { - MyVariant - } - - use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432] - //~^ Did you mean `self::MyEnum`? -} - -mod items { - enum Enum { - Variant - } - - use Enum::*; //~ ERROR unresolved import `Enum` [E0432] - //~^ Did you mean `self::Enum`? - - fn item() {} -} diff --git a/src/test/compile-fail/unsafe-around-compiler-generated-unsafe.rs b/src/test/compile-fail/unsafe-around-compiler-generated-unsafe.rs deleted file mode 100644 index 484a8979d71..00000000000 --- a/src/test/compile-fail/unsafe-around-compiler-generated-unsafe.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// issue #12418 - -#![deny(unused_unsafe)] - -fn main() { - unsafe { println!("foo"); } //~ ERROR unnecessary `unsafe` -} diff --git a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs b/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs deleted file mode 100644 index baf2002a94f..00000000000 --- a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs +++ /dev/null @@ -1,19 +0,0 @@ - -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn f(p: *mut u8) { - *p = 0; //~ ERROR dereference of raw pointer is unsafe - return; -} - -fn main() { -} diff --git a/src/test/compile-fail/unsafe-fn-autoderef.rs b/src/test/compile-fail/unsafe-fn-autoderef.rs deleted file mode 100644 index 15b304c69ba..00000000000 --- a/src/test/compile-fail/unsafe-fn-autoderef.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Rec { - f: isize -} - -fn f(p: *const Rec) -> isize { - - // Test that * ptrs do not autoderef. There is a deeper reason for - // prohibiting this, beyond making unsafe things annoying (which doesn't - // actually seem desirable to me). The deeper reason is that if you - // have a type like: - // - // enum foo = *foo; - // - // you end up with an infinite auto-deref chain, which is - // currently impossible (in all other cases, infinite auto-derefs - // are prohibited by various checks, such as that the enum is - // instantiable and so forth). - - return p.f; //~ ERROR no field `f` on type `*const Rec` -} - -fn main() { -} diff --git a/src/test/compile-fail/unsafe-fn-called-from-safe.rs b/src/test/compile-fail/unsafe-fn-called-from-safe.rs deleted file mode 100644 index 46f28da43d0..00000000000 --- a/src/test/compile-fail/unsafe-fn-called-from-safe.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -unsafe fn f() { return; } - -fn main() { - f(); //~ ERROR call to unsafe function is unsafe -} diff --git a/src/test/compile-fail/unsafe-fn-deref-ptr.rs b/src/test/compile-fail/unsafe-fn-deref-ptr.rs deleted file mode 100644 index 8e3ce8ff9b5..00000000000 --- a/src/test/compile-fail/unsafe-fn-deref-ptr.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn f(p: *const u8) -> u8 { - return *p; //~ ERROR dereference of raw pointer is unsafe -} - -fn main() { -} diff --git a/src/test/compile-fail/unsafe-fn-used-as-value.rs b/src/test/compile-fail/unsafe-fn-used-as-value.rs deleted file mode 100644 index f09a0c7107a..00000000000 --- a/src/test/compile-fail/unsafe-fn-used-as-value.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -unsafe fn f() { return; } - -fn main() { - let x = f; - x(); //~ ERROR call to unsafe function is unsafe -} diff --git a/src/test/compile-fail/unsafe-move-val-init.rs b/src/test/compile-fail/unsafe-move-val-init.rs deleted file mode 100644 index b4e425e7bbf..00000000000 --- a/src/test/compile-fail/unsafe-move-val-init.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(core_intrinsics)] - -use std::intrinsics; - -// `move_val_init` has an odd desugaring, check that it is still treated -// as unsafe. -fn main() { - intrinsics::move_val_init(1 as *mut u32, 1); - //~^ ERROR dereference of raw pointer is unsafe -} diff --git a/src/test/compile-fail/unsafe-subtyping.rs b/src/test/compile-fail/unsafe-subtyping.rs deleted file mode 100644 index f4867636819..00000000000 --- a/src/test/compile-fail/unsafe-subtyping.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that safe fns are not a subtype of unsafe fns. - -fn foo(x: Option) -> Option { - x //~ ERROR mismatched types -} - -fn bar(x: fn(i32)) -> unsafe fn(i32) { - x // OK, coercion! -} - -fn main() { } diff --git a/src/test/compile-fail/unsafe-trait-impl.rs b/src/test/compile-fail/unsafe-trait-impl.rs deleted file mode 100644 index fb4652affd0..00000000000 --- a/src/test/compile-fail/unsafe-trait-impl.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that safe fns are not a subtype of unsafe fns. - -trait Foo { - unsafe fn len(&self) -> u32; -} - -impl Foo for u32 { - fn len(&self) -> u32 { *self } - //~^ ERROR method `len` has an incompatible type for trait - //~| expected type `unsafe fn(&u32) -> u32` - //~| found type `fn(&u32) -> u32` -} - -fn main() { } diff --git a/src/test/compile-fail/unsized-bare-typaram.rs b/src/test/compile-fail/unsized-bare-typaram.rs deleted file mode 100644 index 498bdded350..00000000000 --- a/src/test/compile-fail/unsized-bare-typaram.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn bar() { } -fn foo() { bar::() } -//~^ ERROR the size for values of type -fn main() { } diff --git a/src/test/compile-fail/unsized-enum.rs b/src/test/compile-fail/unsized-enum.rs deleted file mode 100644 index 4a6a5557c95..00000000000 --- a/src/test/compile-fail/unsized-enum.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn is_sized() { } -fn not_sized() { } - -enum Foo { FooSome(U), FooNone } -fn foo1() { not_sized::>() } // Hunky dory. -fn foo2() { not_sized::>() } -//~^ ERROR the size for values of type -// -// Not OK: `T` is not sized. - -fn main() { } diff --git a/src/test/compile-fail/unsized-inherent-impl-self-type.rs b/src/test/compile-fail/unsized-inherent-impl-self-type.rs deleted file mode 100644 index a679bf77015..00000000000 --- a/src/test/compile-fail/unsized-inherent-impl-self-type.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test sized-ness checking in substitution in impls. - -// impl - struct - -struct S5(Y); - -impl S5 { - //~^ ERROR the size for values of type -} - -fn main() { } diff --git a/src/test/compile-fail/unsized-struct.rs b/src/test/compile-fail/unsized-struct.rs deleted file mode 100644 index f2c63455c51..00000000000 --- a/src/test/compile-fail/unsized-struct.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn is_sized() { } -fn not_sized() { } - -struct Foo { data: T } -fn foo1() { not_sized::>() } // Hunky dory. -fn foo2() { not_sized::>() } -//~^ ERROR the size for values of type -// -// Not OK: `T` is not sized. - -struct Bar { data: T } -fn bar1() { not_sized::>() } -fn bar2() { is_sized::>() } -//~^ ERROR the size for values of type -// -// Not OK: `Bar` is not sized, but it should be. - -fn main() { } diff --git a/src/test/compile-fail/unsized-trait-impl-self-type.rs b/src/test/compile-fail/unsized-trait-impl-self-type.rs deleted file mode 100644 index 5c0b8f12402..00000000000 --- a/src/test/compile-fail/unsized-trait-impl-self-type.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test sized-ness checking in substitution in impls. - -// impl - struct -trait T3 { - fn foo(&self, z: &Z); -} - -struct S5(Y); - -impl T3 for S5 { - //~^ ERROR the size for values of type -} - -fn main() { } diff --git a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs deleted file mode 100644 index 875a52e11c0..00000000000 --- a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test sized-ness checking in substitution in impls. - -// impl - unbounded -trait T2 { - fn foo(&self, z: Z); -} -struct S4(Box); -impl T2 for S4 { - //~^ ERROR the size for values of type -} - -fn main() { } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs deleted file mode 100644 index 2e346e473ca..00000000000 --- a/src/test/compile-fail/unsized3.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test sized-ness checking in substitution within fn bodies.. - -use std::marker; - -// Unbounded. -fn f1(x: &X) { - f2::(x); - //~^ ERROR the size for values of type -} -fn f2(x: &X) { -} - -// Bounded. -trait T { - fn foo(&self) { } -} -fn f3(x: &X) { - f4::(x); - //~^ ERROR the size for values of type -} -fn f4(x: &X) { -} - -fn f5(x: &Y) {} -fn f6(x: &X) {} - -// Test with unsized struct. -struct S { - x: X, -} - -fn f8(x1: &S, x2: &S) { - f5(x1); - //~^ ERROR the size for values of type - f6(x2); // ok -} - -// Test some tuples. -fn f9(x1: Box>) { - f5(&(*x1, 34)); - //~^ ERROR the size for values of type -} - -fn f10(x1: Box>) { - f5(&(32, *x1)); - //~^ ERROR the size for values of type - //~| ERROR the size for values of type -} - -pub fn main() { -} diff --git a/src/test/compile-fail/unsized5.rs b/src/test/compile-fail/unsized5.rs deleted file mode 100644 index a50786e306a..00000000000 --- a/src/test/compile-fail/unsized5.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test `?Sized` types not allowed in fields (except the last one). - -struct S1 { - f1: X, - //~^ ERROR the size for values of type - f2: isize, -} -struct S2 { - f: isize, - g: X, - //~^ ERROR the size for values of type - h: isize, -} -struct S3 { - f: str, - //~^ ERROR the size for values of type - g: [usize] -} -struct S4 { - f: [u8], - //~^ ERROR the size for values of type - g: usize -} -enum E { - V1(X, isize), - //~^ ERROR the size for values of type -} -enum F { - V2{f1: X, f: isize}, - //~^ ERROR the size for values of type -} - -pub fn main() { -} diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs deleted file mode 100644 index 1a57f2caf8d..00000000000 --- a/src/test/compile-fail/unsized6.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test `?Sized` local variables. - -trait T {} - -fn f1(x: &X) { - let _: W; // <-- this is OK, no bindings created, no initializer. - let _: (isize, (X, isize)); - //~^ ERROR the size for values of type - let y: Y; - //~^ ERROR the size for values of type - let y: (isize, (Z, usize)); - //~^ ERROR the size for values of type -} -fn f2(x: &X) { - let y: X; - //~^ ERROR the size for values of type - let y: (isize, (Y, isize)); - //~^ ERROR the size for values of type -} - -fn f3(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; - //~^ ERROR the size for values of type - let y = *x2; - //~^ ERROR the size for values of type - let (y, z) = (*x3, 4); - //~^ ERROR the size for values of type -} -fn f4(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; - //~^ ERROR the size for values of type - let y = *x2; - //~^ ERROR the size for values of type - let (y, z) = (*x3, 4); - //~^ ERROR the size for values of type -} - -fn g1(x: X) {} -//~^ ERROR the size for values of type -fn g2(x: X) {} -//~^ ERROR the size for values of type - -pub fn main() { -} diff --git a/src/test/compile-fail/unsized7.rs b/src/test/compile-fail/unsized7.rs deleted file mode 100644 index 07b4ae4c394..00000000000 --- a/src/test/compile-fail/unsized7.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test sized-ness checking in substitution in impls. - -trait T {} - -// I would like these to fail eventually. -// impl - bounded -trait T1 { - fn dummy(&self) -> Z; -} - -struct S3(Box); -impl T1 for S3 { - //~^ ERROR the size for values of type -} - -fn main() { } diff --git a/src/test/compile-fail/unspecified-self-in-trait-ref.rs b/src/test/compile-fail/unspecified-self-in-trait-ref.rs deleted file mode 100644 index cf8f3e91602..00000000000 --- a/src/test/compile-fail/unspecified-self-in-trait-ref.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Foo { - fn foo(&self); -} - -pub trait Bar { - fn foo(&self); -} - -fn main() { - let a = Foo::lol(); - //~^ ERROR no function or associated item named - let b = Foo::<_>::lol(); - //~^ ERROR no function or associated item named - let c = Bar::lol(); - //~^ ERROR no function or associated item named - let d = Bar::::lol(); - //~^ ERROR no function or associated item named - let e = Bar::::lol(); - //~^ ERROR must be explicitly specified -} diff --git a/src/test/compile-fail/unsupported-cast.rs b/src/test/compile-fail/unsupported-cast.rs deleted file mode 100644 index 5137663a269..00000000000 --- a/src/test/compile-fail/unsupported-cast.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:casting - -struct A; - -fn main() { - println!("{:?}", 1.0 as *const A); // Can't cast float to foreign. -} diff --git a/src/test/compile-fail/unused-attr.rs b/src/test/compile-fail/unused-attr.rs deleted file mode 100644 index e20d03478ec..00000000000 --- a/src/test/compile-fail/unused-attr.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_attributes)] -#![allow(dead_code, unused_imports, unused_extern_crates)] -#![feature(custom_attribute)] - -#![foo] //~ ERROR unused attribute - -#[foo] //~ ERROR unused attribute -extern crate core; - -#[foo] //~ ERROR unused attribute -use std::collections; - -#[foo] //~ ERROR unused attribute -extern "C" { - #[foo] //~ ERROR unused attribute - fn foo(); -} - -#[foo] //~ ERROR unused attribute -mod foo { - #[foo] //~ ERROR unused attribute - pub enum Foo { - #[foo] //~ ERROR unused attribute - Bar, - } -} - -#[foo] //~ ERROR unused attribute -fn bar(f: foo::Foo) { - match f { - #[foo] //~ ERROR unused attribute - foo::Foo::Bar => {} - } -} - -#[foo] //~ ERROR unused attribute -struct Foo { - #[foo] //~ ERROR unused attribute - a: isize -} - -#[foo] //~ ERROR unused attribute -trait Baz { - #[foo] //~ ERROR unused attribute - fn blah(&self); - #[foo] //~ ERROR unused attribute - fn blah2(&self) {} -} - -fn main() {} diff --git a/src/test/compile-fail/unused-macro-rules.rs b/src/test/compile-fail/unused-macro-rules.rs deleted file mode 100644 index 5e401c09bda..00000000000 --- a/src/test/compile-fail/unused-macro-rules.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_macros)] - -// Most simple case -macro_rules! unused { //~ ERROR: unused macro definition - () => {}; -} - -// Test macros created by macros -macro_rules! create_macro { - () => { - macro_rules! m { //~ ERROR: unused macro definition - () => {}; - } - }; -} -create_macro!(); - -#[allow(unused_macros)] -mod bar { - // Test that putting the #[deny] close to the macro's definition - // works. - - #[deny(unused_macros)] - macro_rules! unused { //~ ERROR: unused macro definition - () => {}; - } -} - -fn main() {} diff --git a/src/test/compile-fail/unused-macro-with-bad-frag-spec.rs b/src/test/compile-fail/unused-macro-with-bad-frag-spec.rs deleted file mode 100644 index 28a69e6f9e2..00000000000 --- a/src/test/compile-fail/unused-macro-with-bad-frag-spec.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_macros)] - -// Issue #21370 - -macro_rules! test { - ($wrong:t_ty) => () //~ ERROR invalid fragment specifier `t_ty` -} - -fn main() { } diff --git a/src/test/compile-fail/unused-macro-with-follow-violation.rs b/src/test/compile-fail/unused-macro-with-follow-violation.rs deleted file mode 100644 index dda0d3fc955..00000000000 --- a/src/test/compile-fail/unused-macro-with-follow-violation.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_macros)] - -macro_rules! test { - ($e:expr +) => () //~ ERROR not allowed for `expr` fragments -} - -fn main() { } diff --git a/src/test/compile-fail/unused-macro.rs b/src/test/compile-fail/unused-macro.rs deleted file mode 100644 index 9e32f01724d..00000000000 --- a/src/test/compile-fail/unused-macro.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(decl_macro)] -#![deny(unused_macros)] - -// Most simple case -macro unused { //~ ERROR: unused macro definition - () => {} -} - -#[allow(unused_macros)] -mod bar { - // Test that putting the #[deny] close to the macro's definition - // works. - - #[deny(unused_macros)] - macro unused { //~ ERROR: unused macro definition - () => {} - } -} - -mod boo { - pub(crate) macro unused { //~ ERROR: unused macro definition - () => {} - } -} - -fn main() {} diff --git a/src/test/compile-fail/unused-mut-warning-captured-var.rs b/src/test/compile-fail/unused-mut-warning-captured-var.rs deleted file mode 100644 index d4dc58864ad..00000000000 --- a/src/test/compile-fail/unused-mut-warning-captured-var.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![forbid(unused_mut)] - -fn main() { - let mut x = 1; - //~^ ERROR: variable does not need to be mutable - move|| { println!("{}", x); }; -} diff --git a/src/test/compile-fail/unused-result.rs b/src/test/compile-fail/unused-result.rs deleted file mode 100644 index 363ab6220bd..00000000000 --- a/src/test/compile-fail/unused-result.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![deny(unused_results, unused_must_use)] -//~^ NOTE: lint level defined here -//~| NOTE: lint level defined here - -#[must_use] -enum MustUse { Test } - -#[must_use = "some message"] -enum MustUseMsg { Test2 } - -fn foo() -> T { panic!() } - -fn bar() -> isize { return foo::(); } -fn baz() -> MustUse { return foo::(); } -fn qux() -> MustUseMsg { return foo::(); } - -#[allow(unused_results)] -fn test() { - foo::(); - foo::(); //~ ERROR: unused `MustUse` which must be used - foo::(); //~ ERROR: unused `MustUseMsg` which must be used - //~^ NOTE: some message -} - -#[allow(unused_results, unused_must_use)] -fn test2() { - foo::(); - foo::(); - foo::(); -} - -fn main() { - foo::(); //~ ERROR: unused result - foo::(); //~ ERROR: unused `MustUse` which must be used - foo::(); //~ ERROR: unused `MustUseMsg` which must be used - //~^ NOTE: some message - - let _ = foo::(); - let _ = foo::(); - let _ = foo::(); -} diff --git a/src/test/compile-fail/use-after-move-based-on-type.rs b/src/test/compile-fail/use-after-move-based-on-type.rs deleted file mode 100644 index e2167ca446f..00000000000 --- a/src/test/compile-fail/use-after-move-based-on-type.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x = "Hello!".to_string(); - let _y = x; - println!("{}", x); //~ ERROR use of moved value -} diff --git a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs deleted file mode 100644 index addc5721752..00000000000 --- a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -use std::fmt; - -struct Number { - n: i64 -} - -impl fmt::Display for Number { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.n) - } -} - -struct List { - list: Vec> } - -impl List { - fn push(&mut self, n: Box) { - self.list.push(n); - } -} - -fn main() { - let n: Box<_> = box Number { n: 42 }; - let mut l: Box<_> = box List { list: Vec::new() }; - l.push(n); - let x = n.to_string(); - //~^ ERROR: use of moved value: `n` -} diff --git a/src/test/compile-fail/use-after-move-self-based-on-type.rs b/src/test/compile-fail/use-after-move-self-based-on-type.rs deleted file mode 100644 index 810fc68a0f4..00000000000 --- a/src/test/compile-fail/use-after-move-self-based-on-type.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S { - x: isize, -} - -impl Drop for S { - fn drop(&mut self) {} -} - -impl S { - pub fn foo(self) -> isize { - self.bar(); - return self.x; //~ ERROR use of moved value: `self.x` - } - - pub fn bar(self) {} -} - -fn main() { - let x = S { x: 1 }; - println!("{}", x.foo()); -} diff --git a/src/test/compile-fail/use-after-move-self.rs b/src/test/compile-fail/use-after-move-self.rs deleted file mode 100644 index e9ffb26aba5..00000000000 --- a/src/test/compile-fail/use-after-move-self.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -struct S { - x: Box, -} - -impl S { - pub fn foo(self) -> isize { - self.bar(); - return *self.x; //~ ERROR use of moved value: `*self.x` - } - - pub fn bar(self) {} -} - -fn main() { - let x = S { x: box 1 }; - println!("{}", x.foo()); -} diff --git a/src/test/compile-fail/use-from-trait-xc.rs b/src/test/compile-fail/use-from-trait-xc.rs deleted file mode 100644 index 3848b6814d9..00000000000 --- a/src/test/compile-fail/use-from-trait-xc.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:use_from_trait_xc.rs - -extern crate use_from_trait_xc; - -use use_from_trait_xc::Trait::foo; -//~^ ERROR `foo` is not directly importable - -use use_from_trait_xc::Trait::Assoc; -//~^ ERROR `Assoc` is not directly importable - -use use_from_trait_xc::Trait::CONST; -//~^ ERROR `CONST` is not directly importable - -use use_from_trait_xc::Foo::new; //~ ERROR struct `Foo` is private -//~^ ERROR unresolved import `use_from_trait_xc::Foo` - -use use_from_trait_xc::Foo::C; //~ ERROR struct `Foo` is private -//~^ ERROR unresolved import `use_from_trait_xc::Foo` - -use use_from_trait_xc::Bar::new as bnew; -//~^ ERROR unresolved import `use_from_trait_xc::Bar` - -use use_from_trait_xc::Baz::new as baznew; -//~^ ERROR unresolved import `use_from_trait_xc::Baz::new` - -fn main() {} diff --git a/src/test/compile-fail/use-from-trait.rs b/src/test/compile-fail/use-from-trait.rs deleted file mode 100644 index 29db949acd0..00000000000 --- a/src/test/compile-fail/use-from-trait.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use Trait::foo; -//~^ ERROR `foo` is not directly importable -use Trait::Assoc; -//~^ ERROR `Assoc` is not directly importable -use Trait::C; -//~^ ERROR `C` is not directly importable - -use Foo::new; -//~^ ERROR unresolved import `Foo` [E0432] -//~| Not a module `Foo` - -use Foo::C2; -//~^ ERROR unresolved import `Foo` [E0432] -//~| Not a module `Foo` - -pub trait Trait { - fn foo(); - type Assoc; - const C: u32; -} - -struct Foo; - -impl Foo { - fn new() {} - const C2: u32 = 0; -} - -fn main() {} diff --git a/src/test/compile-fail/use-keyword.rs b/src/test/compile-fail/use-keyword.rs deleted file mode 100644 index aff54f18c19..00000000000 --- a/src/test/compile-fail/use-keyword.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that imports with nakes super and self don't fail during parsing -// FIXME: this shouldn't fail during name resolution either - -mod a { - mod b { - use self as A; - //~^ ERROR `self` imports are only allowed within a { } list - use super as B; - //~^ ERROR unresolved import `super` [E0432] - //~| no `super` in the root - use super::{self as C}; - //~^ ERROR unresolved import `super` [E0432] - //~| no `super` in the root - } -} - -fn main() {} diff --git a/src/test/compile-fail/use-meta-mismatch.rs b/src/test/compile-fail/use-meta-mismatch.rs deleted file mode 100644 index 6b7b9c89149..00000000000 --- a/src/test/compile-fail/use-meta-mismatch.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:can't find crate for `extra` - -extern crate fake_crate as extra; - -fn main() { } diff --git a/src/test/compile-fail/use-mod-2.rs b/src/test/compile-fail/use-mod-2.rs deleted file mode 100644 index 5f8842a521a..00000000000 --- a/src/test/compile-fail/use-mod-2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - use self::{self}; - //~^ ERROR unresolved import `self` [E0432] - //~| no `self` in the root - - use super::{self}; - //~^ ERROR unresolved import `super` [E0432] - //~| no `super` in the root -} - -fn main() {} diff --git a/src/test/compile-fail/use-mod-3.rs b/src/test/compile-fail/use-mod-3.rs deleted file mode 100644 index cce500800ca..00000000000 --- a/src/test/compile-fail/use-mod-3.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use foo::bar::{ - self //~ ERROR module `bar` is private -}; -use foo::bar::{ - Bar //~ ERROR module `bar` is private -}; - -mod foo { - mod bar { pub type Bar = isize; } -} - -fn main() {} diff --git a/src/test/compile-fail/use-mod-4.rs b/src/test/compile-fail/use-mod-4.rs deleted file mode 100644 index 275e5ff1da6..00000000000 --- a/src/test/compile-fail/use-mod-4.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use foo::self; //~ ERROR unresolved import `foo` -//~^ ERROR `self` imports are only allowed within a { } list - -use std::mem::self; -//~^ ERROR `self` imports are only allowed within a { } list - -fn main() {} diff --git a/src/test/compile-fail/use-paths-as-items.rs b/src/test/compile-fail/use-paths-as-items.rs deleted file mode 100644 index db69bb33ae2..00000000000 --- a/src/test/compile-fail/use-paths-as-items.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Each path node in a `use` declaration must be treated as an item. If not, the following code -// will trigger an ICE. -// -// Related issue: #25763 - -use std::{mem, ptr}; -use std::mem; //~ ERROR the name `mem` is defined multiple times - -fn main() {} diff --git a/src/test/compile-fail/use-self-type.rs b/src/test/compile-fail/use-self-type.rs deleted file mode 100644 index 6b5286bf0a7..00000000000 --- a/src/test/compile-fail/use-self-type.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S; - -impl S { - fn f() {} - fn g() { - use Self::f; //~ ERROR unresolved import - pub(in Self::f) struct Z; //~ ERROR Use of undeclared type or module `Self` - } -} - -fn main() {} diff --git a/src/test/compile-fail/use-super-global-path.rs b/src/test/compile-fail/use-super-global-path.rs deleted file mode 100644 index fc1a72f6f2b..00000000000 --- a/src/test/compile-fail/use-super-global-path.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] - -struct S; -struct Z; - -mod foo { - use ::super::{S, Z}; //~ ERROR global paths cannot start with `super` - - pub fn g() { - use ::super::main; //~ ERROR global paths cannot start with `super` - main(); //~ ERROR cannot find function `main` in this scope - } -} - -fn main() { foo::g(); } diff --git a/src/test/compile-fail/used.rs b/src/test/compile-fail/used.rs deleted file mode 100644 index f170d9c25f5..00000000000 --- a/src/test/compile-fail/used.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(used)] - -#[used] -static FOO: u32 = 0; // OK - -#[used] //~ ERROR attribute must be applied to a `static` variable -fn foo() {} - -#[used] //~ ERROR attribute must be applied to a `static` variable -struct Foo {} - -#[used] //~ ERROR attribute must be applied to a `static` variable -trait Bar {} - -#[used] //~ ERROR attribute must be applied to a `static` variable -impl Bar for Foo {} - -fn main() {} diff --git a/src/test/compile-fail/useless-pub.rs b/src/test/compile-fail/useless-pub.rs deleted file mode 100644 index 064062df753..00000000000 --- a/src/test/compile-fail/useless-pub.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct A { pub i: isize } - -pub trait E { - fn foo(&self); -} - -impl E for A { - pub fn foo(&self) {} //~ ERROR: unnecessary visibility qualifier -} - -enum Foo { - V1 { pub f: i32 }, //~ ERROR unnecessary visibility qualifier - V2(pub i32), //~ ERROR unnecessary visibility qualifier -} - -fn main() {} diff --git a/src/test/compile-fail/useless_comment.rs b/src/test/compile-fail/useless_comment.rs deleted file mode 100644 index 645514971da..00000000000 --- a/src/test/compile-fail/useless_comment.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(unused_doc_comments)] - -fn foo() { - /// a //~ ERROR doc comment not used by rustdoc - let x = 12; - - /// b //~ doc comment not used by rustdoc - match x { - /// c //~ ERROR doc comment not used by rustdoc - 1 => {}, - _ => {} - } - - /// foo //~ ERROR doc comment not used by rustdoc - unsafe {} -} - -fn main() { - foo(); -} diff --git a/src/test/compile-fail/user-defined-macro-rules.rs b/src/test/compile-fail/user-defined-macro-rules.rs deleted file mode 100644 index 02e1a585fa8..00000000000 --- a/src/test/compile-fail/user-defined-macro-rules.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_macros)] - -macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules` diff --git a/src/test/compile-fail/utf8_idents.rs b/src/test/compile-fail/utf8_idents.rs deleted file mode 100644 index 8594c35f8dd..00000000000 --- a/src/test/compile-fail/utf8_idents.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// - -fn foo< - 'β, //~ ERROR non-ascii idents are not fully supported - γ //~ ERROR non-ascii idents are not fully supported ->() {} - -struct X { - δ: usize //~ ERROR non-ascii idents are not fully supported -} - -pub fn main() { - let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported -} diff --git a/src/test/compile-fail/variadic-ffi-2.rs b/src/test/compile-fail/variadic-ffi-2.rs deleted file mode 100644 index ec5669f6392..00000000000 --- a/src/test/compile-fail/variadic-ffi-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-arm stdcall isn't suppported - -fn baz(f: extern "stdcall" fn(usize, ...)) { - //~^ ERROR: variadic function must have C or cdecl calling convention - f(22, 44); -} - -fn main() {} diff --git a/src/test/compile-fail/variadic-ffi.rs b/src/test/compile-fail/variadic-ffi.rs deleted file mode 100644 index f245306f4d8..00000000000 --- a/src/test/compile-fail/variadic-ffi.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-arm stdcall isn't suppported -// ignore-aarch64 stdcall isn't suppported - -extern "stdcall" { - fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling -} - -extern { - fn foo(f: isize, x: u8, ...); -} - -extern "C" fn bar(f: isize, x: u8) {} - -fn main() { - // errors below are no longer checked because error above aborts - // compilation; see variadic-ffi-3.rs for corresponding test. - unsafe { - foo(); - foo(1); - - let x: unsafe extern "C" fn(f: isize, x: u8) = foo; - let y: extern "C" fn(f: isize, x: u8, ...) = bar; - - foo(1, 2, 3f32); - foo(1, 2, true); - foo(1, 2, 1i8); - foo(1, 2, 1u8); - foo(1, 2, 1i16); - foo(1, 2, 1u16); - } -} diff --git a/src/test/compile-fail/variance-associated-types.rs b/src/test/compile-fail/variance-associated-types.rs deleted file mode 100644 index 7dbfc6ac125..00000000000 --- a/src/test/compile-fail/variance-associated-types.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the variance computation considers types/regions that -// appear in projections to be invariant. - -#![feature(rustc_attrs)] - -trait Trait<'a> { - type Type; - - fn method(&'a self) { } -} - -#[rustc_variance] -struct Foo<'a, T : Trait<'a>> { //~ ERROR [-, +] - field: (T, &'a ()) -} - -#[rustc_variance] -struct Bar<'a, T : Trait<'a>> { //~ ERROR [o, o] - field: >::Type -} - -fn main() { } diff --git a/src/test/compile-fail/variance-btree-invariant-types.rs b/src/test/compile-fail/variance-btree-invariant-types.rs deleted file mode 100644 index e9607de00a3..00000000000 --- a/src/test/compile-fail/variance-btree-invariant-types.rs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] - -use std::collections::btree_map::{IterMut, OccupiedEntry, VacantEntry}; - -fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> { - v //~ ERROR mismatched types -} -fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> { - v //~ ERROR mismatched types -} -fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> { - v //~ ERROR mismatched types -} -fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> { - v //~ ERROR mismatched types -} - -fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>) - -> OccupiedEntry<'a, &'new (), ()> { - v //~ ERROR mismatched types -} -fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>) - -> OccupiedEntry<'a, (), &'new ()> { - v //~ ERROR mismatched types -} -fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>) - -> OccupiedEntry<'a, &'static (), ()> { - v //~ ERROR mismatched types -} -fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>) - -> OccupiedEntry<'a, (), &'static ()> { - v //~ ERROR mismatched types -} - -fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>) - -> VacantEntry<'a, &'new (), ()> { - v //~ ERROR mismatched types -} -fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>) - -> VacantEntry<'a, (), &'new ()> { - v //~ ERROR mismatched types -} -fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>) - -> VacantEntry<'a, &'static (), ()> { - v //~ ERROR mismatched types -} -fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>) - -> VacantEntry<'a, (), &'static ()> { - v //~ ERROR mismatched types -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/variance-cell-is-invariant.rs b/src/test/compile-fail/variance-cell-is-invariant.rs deleted file mode 100644 index 1ddbcf4ab84..00000000000 --- a/src/test/compile-fail/variance-cell-is-invariant.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that Cell is considered invariant with respect to its -// type. - -use std::cell::Cell; - -struct Foo<'a> { - x: Cell>, -} - -fn use_<'short,'long>(c: Foo<'short>, - s: &'short isize, - l: &'long isize, - _where:Option<&'short &'long ()>) { - let _: Foo<'long> = c; //~ ERROR E0623 -} - -fn main() { -} diff --git a/src/test/compile-fail/variance-contravariant-arg-object.rs b/src/test/compile-fail/variance-contravariant-arg-object.rs deleted file mode 100644 index 1795ac95358..00000000000 --- a/src/test/compile-fail/variance-contravariant-arg-object.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// Test that even when `T` is only used in contravariant position, it -// is treated as invariant. - -trait Get : 'static { - fn get(&self, t: T); -} - -fn get_min_from_max<'min, 'max>(v: Box>) - -> Box> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>(v: Box>) - -> Box> - where 'max : 'min -{ - // Previously OK: - v //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/variance-contravariant-arg-trait-match.rs b/src/test/compile-fail/variance-contravariant-arg-trait-match.rs deleted file mode 100644 index 9b6e3c9de3b..00000000000 --- a/src/test/compile-fail/variance-contravariant-arg-trait-match.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// Test that even when `T` is only used in contravariant position, it -// is treated as invariant. - -trait Get { - fn get(&self, t: T); -} - -fn get_min_from_max<'min, 'max, G>() - where 'max : 'min, G : Get<&'max i32> -{ - impls_get::() //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>() - where 'max : 'min, G : Get<&'min i32> -{ - // Previously OK, but now an error because traits are invariant: - - impls_get::() //~ ERROR mismatched types -} - -fn impls_get() where G : Get { } - -fn main() { } diff --git a/src/test/compile-fail/variance-contravariant-self-trait-match.rs b/src/test/compile-fail/variance-contravariant-self-trait-match.rs deleted file mode 100644 index 6d9d1e61fed..00000000000 --- a/src/test/compile-fail/variance-contravariant-self-trait-match.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// Test that even when `Self` is only used in contravariant position, it -// is treated as invariant. - -trait Get { - fn get(&self); -} - -fn get_min_from_max<'min, 'max, G>() - where 'max : 'min, G : 'max, &'max G : Get -{ - impls_get::<&'min G>(); //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>() - where 'max : 'min, G : 'max, &'min G : Get -{ - // Previously OK, but now error because traits are invariant with - // respect to all inputs. - - impls_get::<&'max G>(); //~ ERROR mismatched types -} - -fn impls_get() where G : Get { } - -fn main() { } diff --git a/src/test/compile-fail/variance-covariant-arg-object.rs b/src/test/compile-fail/variance-covariant-arg-object.rs deleted file mode 100644 index ad059a467f5..00000000000 --- a/src/test/compile-fail/variance-covariant-arg-object.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// Test that even when `T` is only used in covariant position, it -// is treated as invariant. - -trait Get : 'static { - fn get(&self) -> T; -} - -fn get_min_from_max<'min, 'max>(v: Box>) - -> Box> - where 'max : 'min -{ - // Previously OK, now an error as traits are invariant. - v //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>(v: Box>) - -> Box> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/variance-covariant-arg-trait-match.rs b/src/test/compile-fail/variance-covariant-arg-trait-match.rs deleted file mode 100644 index c42a845b3b5..00000000000 --- a/src/test/compile-fail/variance-covariant-arg-trait-match.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// Test that even when `T` is only used in covariant position, it -// is treated as invariant. - -trait Get { - fn get(&self) -> T; -} - -fn get_min_from_max<'min, 'max, G>() - where 'max : 'min, G : Get<&'max i32> -{ - // Previously OK, now an error as traits are invariant. - impls_get::() //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>() - where 'max : 'min, G : Get<&'min i32> -{ - impls_get::() //~ ERROR mismatched types -} - -fn impls_get() where G : Get { } - -fn main() { } diff --git a/src/test/compile-fail/variance-covariant-self-trait-match.rs b/src/test/compile-fail/variance-covariant-self-trait-match.rs deleted file mode 100644 index 25148dfc020..00000000000 --- a/src/test/compile-fail/variance-covariant-self-trait-match.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// Test that even when `Self` is only used in covariant position, it -// is treated as invariant. - -trait Get { - fn get() -> Self; -} - -fn get_min_from_max<'min, 'max, G>() - where 'max : 'min, G : 'max, &'max G : Get -{ - // Previously OK, now an error as traits are invariant. - impls_get::<&'min G>(); //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>() - where 'max : 'min, G : 'max, &'min G : Get -{ - impls_get::<&'max G>(); //~ ERROR mismatched types -} - -fn impls_get() where G : Get { } - -fn main() { } diff --git a/src/test/compile-fail/variance-invariant-arg-object.rs b/src/test/compile-fail/variance-invariant-arg-object.rs deleted file mode 100644 index 9edb510b826..00000000000 --- a/src/test/compile-fail/variance-invariant-arg-object.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -trait Get : 'static { - fn get(&self, t: T) -> T; -} - -fn get_min_from_max<'min, 'max>(v: Box>) - -> Box> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>(v: Box>) - -> Box> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/variance-invariant-arg-trait-match.rs b/src/test/compile-fail/variance-invariant-arg-trait-match.rs deleted file mode 100644 index 45fed0b083d..00000000000 --- a/src/test/compile-fail/variance-invariant-arg-trait-match.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -trait Get { - fn get(&self, t: T) -> T; -} - -fn get_min_from_max<'min, 'max, G>() - where 'max : 'min, G : Get<&'max i32> -{ - impls_get::() //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>() - where 'max : 'min, G : Get<&'min i32> -{ - impls_get::() //~ ERROR mismatched types -} - -fn impls_get() where G : Get { } - -fn main() { } diff --git a/src/test/compile-fail/variance-invariant-self-trait-match.rs b/src/test/compile-fail/variance-invariant-self-trait-match.rs deleted file mode 100644 index fe61dee23bc..00000000000 --- a/src/test/compile-fail/variance-invariant-self-trait-match.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -trait Get { - fn get(&self) -> Self; -} - -fn get_min_from_max<'min, 'max, G>() - where 'max : 'min, &'max G : Get, G : 'max -{ - impls_get::<&'min G>(); //~ ERROR mismatched types -} - -fn get_max_from_min<'min, 'max, G>() - where 'max : 'min, &'min G : Get, G : 'min -{ - impls_get::<&'max G>(); //~ ERROR mismatched types -} - -fn impls_get() where G : Get { } - -fn main() { } diff --git a/src/test/compile-fail/variance-issue-20533.rs b/src/test/compile-fail/variance-issue-20533.rs deleted file mode 100644 index 60690012485..00000000000 --- a/src/test/compile-fail/variance-issue-20533.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #20533. At some point, only 1 out of the -// 3 errors below were being reported. - -use std::marker::PhantomData; - -fn foo<'a, T>(_x: &'a T) -> PhantomData<&'a ()> { - PhantomData -} - -struct Wrap(T); - -fn bar<'a, T>(_x: &'a T) -> Wrap> { - Wrap(PhantomData) -} - -struct Baked<'a>(PhantomData<&'a ()>); - -fn baz<'a, T>(_x: &'a T) -> Baked<'a> { - Baked(PhantomData) -} - -struct AffineU32(u32); - -fn main() { - { - let a = AffineU32(1); - let x = foo(&a); - drop(a); //~ ERROR cannot move out of `a` - drop(x); - } - { - let a = AffineU32(1); - let x = bar(&a); - drop(a); //~ ERROR cannot move out of `a` - drop(x); - } - { - let a = AffineU32(1); - let x = baz(&a); - drop(a); //~ ERROR cannot move out of `a` - drop(x); - } -} diff --git a/src/test/compile-fail/variance-object-types.rs b/src/test/compile-fail/variance-object-types.rs deleted file mode 100644 index 1f54771e367..00000000000 --- a/src/test/compile-fail/variance-object-types.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that Cell is considered invariant with respect to its -// type. - -#![feature(rustc_attrs)] - -use std::cell::Cell; - -// For better or worse, associated types are invariant, and hence we -// get an invariant result for `'a`. -#[rustc_variance] -struct Foo<'a> { //~ ERROR [o] - x: Box &'a i32 + 'static> -} - -fn main() { -} diff --git a/src/test/compile-fail/variance-regions-direct.rs b/src/test/compile-fail/variance-regions-direct.rs deleted file mode 100644 index cd047cc580f..00000000000 --- a/src/test/compile-fail/variance-regions-direct.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we correctly infer variance for region parameters in -// various self-contained types. - -#![feature(rustc_attrs)] - -// Regions that just appear in normal spots are contravariant: - -#[rustc_variance] -struct Test2<'a, 'b, 'c> { //~ ERROR [-, -, -] - x: &'a isize, - y: &'b [isize], - c: &'c str -} - -// Those same annotations in function arguments become covariant: - -#[rustc_variance] -struct Test3<'a, 'b, 'c> { //~ ERROR [+, +, +] - x: extern "Rust" fn(&'a isize), - y: extern "Rust" fn(&'b [isize]), - c: extern "Rust" fn(&'c str), -} - -// Mutability induces invariance: - -#[rustc_variance] -struct Test4<'a, 'b:'a> { //~ ERROR [-, o] - x: &'a mut &'b isize, -} - -// Mutability induces invariance, even when in a -// contravariant context: - -#[rustc_variance] -struct Test5<'a, 'b:'a> { //~ ERROR [+, o] - x: extern "Rust" fn(&'a mut &'b isize), -} - -// Invariance is a trap from which NO ONE CAN ESCAPE. -// In other words, even though the `&'b isize` occurs in -// an argument list (which is contravariant), that -// argument list occurs in an invariant context. - -#[rustc_variance] -struct Test6<'a, 'b:'a> { //~ ERROR [-, o] - x: &'a mut extern "Rust" fn(&'b isize), -} - -// No uses at all is bivariant: - -#[rustc_variance] -struct Test7<'a> { //~ ERROR [*] - x: isize -} - -// Try enums too. - -#[rustc_variance] -enum Test8<'a, 'b, 'c:'b> { //~ ERROR [+, -, o] - Test8A(extern "Rust" fn(&'a isize)), - Test8B(&'b [isize]), - Test8C(&'b mut &'c str), -} - -fn main() {} diff --git a/src/test/compile-fail/variance-regions-indirect.rs b/src/test/compile-fail/variance-regions-indirect.rs deleted file mode 100644 index 60d4d73fe88..00000000000 --- a/src/test/compile-fail/variance-regions-indirect.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we correctly infer variance for region parameters in -// case that involve multiple intricate types. -// Try enums too. - -#![feature(rustc_attrs)] - -#[rustc_variance] -enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR [+, -, o, *] - Test8A(extern "Rust" fn(&'a isize)), - Test8B(&'b [isize]), - Test8C(&'b mut &'c str), -} - -#[rustc_variance] -struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR [*, o, -, +] - f: Base<'z, 'y, 'x, 'w> -} - -#[rustc_variance] // Combine - and + to yield o -struct Derived2<'a, 'b:'a, 'c> { //~ ERROR [o, o, *] - f: Base<'a, 'a, 'b, 'c> -} - -#[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here) -struct Derived3<'a:'b, 'b, 'c> { //~ ERROR [o, -, *] - f: Base<'a, 'b, 'a, 'c> -} - -#[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here) -struct Derived4<'a, 'b, 'c:'b> { //~ ERROR [+, -, o] - f: Base<'a, 'b, 'c, 'a> -} - -fn main() {} diff --git a/src/test/compile-fail/variance-regions-unused-direct.rs b/src/test/compile-fail/variance-regions-unused-direct.rs deleted file mode 100644 index 037fff72c80..00000000000 --- a/src/test/compile-fail/variance-regions-unused-direct.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that disallow lifetime parameters that are unused. - -use std::marker; - -struct Bivariant<'a>; //~ ERROR parameter `'a` is never used - -struct Struct<'a, 'd> { //~ ERROR parameter `'d` is never used - field: &'a [i32] -} - -trait Trait<'a, 'd> { // OK on traits - fn method(&'a self); -} - -fn main() {} diff --git a/src/test/compile-fail/variance-regions-unused-indirect.rs b/src/test/compile-fail/variance-regions-unused-indirect.rs deleted file mode 100644 index 2d234ed7b57..00000000000 --- a/src/test/compile-fail/variance-regions-unused-indirect.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that disallow lifetime parameters that are unused. - -enum Foo<'a> { //~ ERROR parameter `'a` is never used - Foo1(Bar<'a>) -} - -enum Bar<'a> { //~ ERROR parameter `'a` is never used - Bar1(Foo<'a>) -} - -fn main() {} diff --git a/src/test/compile-fail/variance-trait-bounds.rs b/src/test/compile-fail/variance-trait-bounds.rs deleted file mode 100644 index ff446f175b7..00000000000 --- a/src/test/compile-fail/variance-trait-bounds.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -// Check that bounds on type parameters (other than `Self`) do not -// influence variance. - -trait Getter { - fn get(&self) -> T; -} - -trait Setter { - fn get(&self, _: T); -} - -#[rustc_variance] -struct TestStruct> { //~ ERROR [+, +] - t: T, u: U -} - -#[rustc_variance] -enum TestEnum> { //~ ERROR [*, +] - Foo(T) -} - -#[rustc_variance] -struct TestContraStruct> { //~ ERROR [*, +] - t: T -} - -#[rustc_variance] -struct TestBox+Setter> { //~ ERROR [*, +] - t: T -} - -pub fn main() { } diff --git a/src/test/compile-fail/variance-trait-matching.rs b/src/test/compile-fail/variance-trait-matching.rs deleted file mode 100644 index bc9eab2be82..00000000000 --- a/src/test/compile-fail/variance-trait-matching.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] - -// Get is covariant in T -trait Get { - fn get(&self) -> T; -} - -struct Cloner { - t: T -} - -impl Get for Cloner { - fn get(&self) -> T { - self.t.clone() - } -} - -fn get<'a, G>(get: &G) -> i32 - where G : Get<&'a i32> -{ - // This fails to type-check because, without variance, we can't - // use `G : Get<&'a i32>` as evidence that `G : Get<&'b i32>`, - // even if `'a : 'b`. - pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] -} - -fn pick<'b, G>(get: &'b G, if_odd: &'b i32) -> i32 - where G : Get<&'b i32> -{ - let v = *get.get(); - if v % 2 != 0 { v } else { *if_odd } -} - -fn main() { - let x = Cloner { t: &23 }; - let y = get(&x); - assert_eq!(y, 23); -} diff --git a/src/test/compile-fail/variance-trait-object-bound.rs b/src/test/compile-fail/variance-trait-object-bound.rs deleted file mode 100644 index b120588ecab..00000000000 --- a/src/test/compile-fail/variance-trait-object-bound.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks that regions which appear in a trait object type are -// observed by the variance inference algorithm (and hence -// `TOption` is contavariant w/r/t `'a` and not bivariant). -// -// Issue #18262. - -#![feature(rustc_attrs)] - -use std::mem; - -trait T { fn foo(&self); } - -#[rustc_variance] -struct TOption<'a> { //~ ERROR [-] - v: Option>, -} - -fn main() { } diff --git a/src/test/compile-fail/variance-types-bounds.rs b/src/test/compile-fail/variance-types-bounds.rs deleted file mode 100644 index 5075dd2ceed..00000000000 --- a/src/test/compile-fail/variance-types-bounds.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we correctly infer variance for type parameters in -// various types and traits. - -#![feature(rustc_attrs)] - -#[rustc_variance] -struct TestImm { //~ ERROR [+, +] - x: A, - y: B, -} - -#[rustc_variance] -struct TestMut { //~ ERROR [+, o] - x: A, - y: &'static mut B, -} - -#[rustc_variance] -struct TestIndirect { //~ ERROR [+, o] - m: TestMut -} - -#[rustc_variance] -struct TestIndirect2 { //~ ERROR [o, o] - n: TestMut, - m: TestMut -} - -trait Getter { - fn get(&self) -> A; -} - -trait Setter { - fn set(&mut self, a: A); -} - -#[rustc_variance] -struct TestObject { //~ ERROR [o, o] - n: Box+Send>, - m: Box+Send>, -} - -fn main() {} diff --git a/src/test/compile-fail/variance-types.rs b/src/test/compile-fail/variance-types.rs deleted file mode 100644 index 7667972c9d2..00000000000 --- a/src/test/compile-fail/variance-types.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -use std::cell::Cell; - -// Check that a type parameter which is only used in a trait bound is -// not considered bivariant. - -#[rustc_variance] -struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR [-, o, o] - t: &'a mut (A,B) -} - -#[rustc_variance] -struct InvariantCell { //~ ERROR [o] - t: Cell -} - -#[rustc_variance] -struct InvariantIndirect { //~ ERROR [o] - t: InvariantCell -} - -#[rustc_variance] -struct Covariant { //~ ERROR [+] - t: A, u: fn() -> A -} - -#[rustc_variance] -struct Contravariant { //~ ERROR [-] - t: fn(A) -} - -#[rustc_variance] -enum Enum { //~ ERROR [+, -, o] - Foo(Covariant), - Bar(Contravariant), - Zed(Covariant,Contravariant) -} - -pub fn main() { } diff --git a/src/test/compile-fail/variance-unused-region-param.rs b/src/test/compile-fail/variance-unused-region-param.rs deleted file mode 100644 index 407282e5ce0..00000000000 --- a/src/test/compile-fail/variance-unused-region-param.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we report an error for unused type parameters in types. - -struct SomeStruct<'a> { x: u32 } //~ ERROR parameter `'a` is never used -enum SomeEnum<'a> { Nothing } //~ ERROR parameter `'a` is never used -trait SomeTrait<'a> { fn foo(&self); } // OK on traits. - -fn main() {} diff --git a/src/test/compile-fail/variance-use-contravariant-struct-1.rs b/src/test/compile-fail/variance-use-contravariant-struct-1.rs deleted file mode 100644 index d2fd2978750..00000000000 --- a/src/test/compile-fail/variance-use-contravariant-struct-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test various uses of structs with distint variances to make sure -// they permit lifetimes to be approximated as expected. - -#![feature(rustc_attrs)] - -struct SomeStruct(fn(T)); - -fn foo<'min,'max>(v: SomeStruct<&'max ()>) - -> SomeStruct<&'min ()> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/variance-use-contravariant-struct-2.rs b/src/test/compile-fail/variance-use-contravariant-struct-2.rs deleted file mode 100644 index b38fd0e9ffc..00000000000 --- a/src/test/compile-fail/variance-use-contravariant-struct-2.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test various uses of structs with distint variances to make sure -// they permit lifetimes to be approximated as expected. - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -struct SomeStruct(fn(T)); - -fn bar<'min,'max>(v: SomeStruct<&'min ()>) - -> SomeStruct<&'max ()> - where 'max : 'min -{ - v -} - -#[rustc_error] -fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/variance-use-covariant-struct-1.rs b/src/test/compile-fail/variance-use-covariant-struct-1.rs deleted file mode 100644 index 2631cfc05e8..00000000000 --- a/src/test/compile-fail/variance-use-covariant-struct-1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a covariant struct does not permit the lifetime of a -// reference to be enlarged. - -struct SomeStruct(T); - -fn foo<'min,'max>(v: SomeStruct<&'min ()>) - -> SomeStruct<&'max ()> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -fn main() { } diff --git a/src/test/compile-fail/variance-use-covariant-struct-2.rs b/src/test/compile-fail/variance-use-covariant-struct-2.rs deleted file mode 100644 index d8e1a5f5f1c..00000000000 --- a/src/test/compile-fail/variance-use-covariant-struct-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a covariant struct permits the lifetime of a reference to -// be shortened. - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -struct SomeStruct(T); - -fn foo<'min,'max>(v: SomeStruct<&'max ()>) - -> SomeStruct<&'min ()> - where 'max : 'min -{ - v -} - -#[rustc_error] fn main() { } //~ ERROR compilation successful diff --git a/src/test/compile-fail/variance-use-invariant-struct-1.rs b/src/test/compile-fail/variance-use-invariant-struct-1.rs deleted file mode 100644 index c89436b2094..00000000000 --- a/src/test/compile-fail/variance-use-invariant-struct-1.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test various uses of structs with distint variances to make sure -// they permit lifetimes to be approximated as expected. - -#![feature(rustc_attrs)] - -struct SomeStruct(*mut T); - -fn foo<'min,'max>(v: SomeStruct<&'max ()>) - -> SomeStruct<&'min ()> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -fn bar<'min,'max>(v: SomeStruct<&'min ()>) - -> SomeStruct<&'max ()> - where 'max : 'min -{ - v //~ ERROR mismatched types -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/variant-namespacing.rs b/src/test/compile-fail/variant-namespacing.rs deleted file mode 100644 index 58bfd91550e..00000000000 --- a/src/test/compile-fail/variant-namespacing.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:variant-namespacing.rs - -enum E { - Struct { a: u8 }, - Tuple(u8), - Unit, -} - -type Struct = u8; -type Tuple = u8; -type Unit = u8; -type XStruct = u8; -type XTuple = u8; -type XUnit = u8; - -const Struct: u8 = 0; -const Tuple: u8 = 0; -const Unit: u8 = 0; -const XStruct: u8 = 0; -const XTuple: u8 = 0; -const XUnit: u8 = 0; - -extern crate variant_namespacing; -pub use variant_namespacing::XE::{XStruct, XTuple, XUnit}; -//~^ ERROR the name `XStruct` is defined multiple times -//~| ERROR the name `XTuple` is defined multiple times -//~| ERROR the name `XUnit` is defined multiple times -pub use E::{Struct, Tuple, Unit}; -//~^ ERROR the name `Struct` is defined multiple times -//~| ERROR the name `Tuple` is defined multiple times -//~| ERROR the name `Unit` is defined multiple times - -fn main() {} diff --git a/src/test/compile-fail/variant-size-differences.rs b/src/test/compile-fail/variant-size-differences.rs deleted file mode 100644 index f2cffeefe90..00000000000 --- a/src/test/compile-fail/variant-size-differences.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(variant_size_differences)] - -enum _En { - V0(u8), - VBig([u8; 1024]), //~ ERROR variant is more than three times larger -} - -fn main() {} diff --git a/src/test/compile-fail/variant-used-as-type.rs b/src/test/compile-fail/variant-used-as-type.rs deleted file mode 100644 index c889b7d28f8..00000000000 --- a/src/test/compile-fail/variant-used-as-type.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test error message when enum variants are used as types - - -// issue 21225 -enum Ty { - A, - B(Ty::A), - //~^ ERROR expected type, found variant `Ty::A` -} - - -// issue 19197 -enum E { - A -} - -impl E::A {} -//~^ ERROR expected type, found variant `E::A` - -fn main() {} diff --git a/src/test/compile-fail/vec-macro-with-comma-only.rs b/src/test/compile-fail/vec-macro-with-comma-only.rs deleted file mode 100644 index c79e67a3768..00000000000 --- a/src/test/compile-fail/vec-macro-with-comma-only.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() { - vec![,]; //~ ERROR no rules expected the token `,` -} diff --git a/src/test/compile-fail/vec-mut-iter-borrow.rs b/src/test/compile-fail/vec-mut-iter-borrow.rs deleted file mode 100644 index 571634e3992..00000000000 --- a/src/test/compile-fail/vec-mut-iter-borrow.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let mut xs: Vec = vec![]; - - for x in &mut xs { - xs.push(1) //~ ERROR cannot borrow `xs` - } -} diff --git a/src/test/compile-fail/vec-res-add.rs b/src/test/compile-fail/vec-res-add.rs deleted file mode 100644 index 27f6fc51164..00000000000 --- a/src/test/compile-fail/vec-res-add.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Debug)] -struct r { - i:isize -} - -fn r(i:isize) -> r { r { i: i } } - -impl Drop for r { - fn drop(&mut self) {} -} - -fn main() { - // This can't make sense as it would copy the classes - let i = vec![r(0)]; - let j = vec![r(1)]; - let k = i + j; - //~^ ERROR binary operation `+` cannot be applied to type - println!("{:?}", j); -} diff --git a/src/test/compile-fail/vector-cast-weirdness.rs b/src/test/compile-fail/vector-cast-weirdness.rs deleted file mode 100644 index 26c59c440d4..00000000000 --- a/src/test/compile-fail/vector-cast-weirdness.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #14893. Tests that casts from vectors don't behave strangely in the -// presence of the `_` type shorthand notation. -// Update: after a change to the way casts are done, we have more type information -// around and so the errors here are no longer exactly the same. - -struct X { - y: [u8; 2], -} - -fn main() { - let x1 = X { y: [0, 0] }; - - // No longer a type mismatch - the `_` can be fully resolved by type inference. - let p1: *const u8 = &x1.y as *const _; - let t1: *const [u8; 2] = &x1.y as *const _; - let h1: *const [u8; 2] = &x1.y as *const [u8; 2]; - - let mut x1 = X { y: [0, 0] }; - - // This is still an error since we don't allow casts from &mut [T; n] to *mut T. - let p1: *mut u8 = &mut x1.y as *mut _; //~ ERROR casting - let t1: *mut [u8; 2] = &mut x1.y as *mut _; - let h1: *mut [u8; 2] = &mut x1.y as *mut [u8; 2]; -} diff --git a/src/test/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs deleted file mode 100644 index 8b3e9369ece..00000000000 --- a/src/test/compile-fail/vtable-res-trait-param.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait TraitA { - fn method_a(&self) -> isize; -} - -trait TraitB { - fn gimme_an_a(&self, a: A) -> isize; -} - -impl TraitB for isize { - fn gimme_an_a(&self, a: A) -> isize { - a.method_a() + *self - } -} - -fn call_it(b: B) -> isize { - let y = 4; - b.gimme_an_a(y) //~ ERROR `{integer}: TraitA` is not satisfied -} - -fn main() { - let x = 3; - assert_eq!(call_it(x), 22); -} diff --git a/src/test/compile-fail/walk-struct-literal-with.rs b/src/test/compile-fail/walk-struct-literal-with.rs deleted file mode 100644 index 10503084b9d..00000000000 --- a/src/test/compile-fail/walk-struct-literal-with.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Mine{ - test: String, - other_val: isize -} - -impl Mine{ - fn make_string_bar(mut self) -> Mine{ - self.test = "Bar".to_string(); - self - } -} - -fn main(){ - let start = Mine{test:"Foo".to_string(), other_val:0}; - let end = Mine{other_val:1, ..start.make_string_bar()}; - println!("{}", start.test); //~ ERROR use of moved value: `start.test` -} diff --git a/src/test/compile-fail/warn-path-statement.rs b/src/test/compile-fail/warn-path-statement.rs deleted file mode 100644 index 892d82d0934..00000000000 --- a/src/test/compile-fail/warn-path-statement.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -D path-statements -fn main() { - - let x = 10; - x; //~ ERROR path statement with no effect -} diff --git a/src/test/compile-fail/weak-lang-item.rs b/src/test/compile-fail/weak-lang-item.rs deleted file mode 100644 index 42972c40674..00000000000 --- a/src/test/compile-fail/weak-lang-item.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:weak-lang-items.rs -// error-pattern: `#[panic_implementation]` function required, but not found -// error-pattern: language item required, but not found: `eh_personality` -// ignore-wasm32-bare compiled with panic=abort, personality not required - -#![no_std] - -extern crate core; -extern crate weak_lang_items; - -fn main() {} diff --git a/src/test/compile-fail/wf-array-elem-sized.rs b/src/test/compile-fail/wf-array-elem-sized.rs deleted file mode 100644 index 946341a1a75..00000000000 --- a/src/test/compile-fail/wf-array-elem-sized.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that array elemen types must be Sized. Issue #25692. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct Foo { - foo: [[u8]], //~ ERROR E0277 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-const-type.rs b/src/test/compile-fail/wf-const-type.rs deleted file mode 100644 index c3015afd8dd..00000000000 --- a/src/test/compile-fail/wf-const-type.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check the types of constants are well-formed. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct IsCopy { t: T } -struct NotCopy; - -const FOO: IsCopy> = IsCopy { t: None }; -//~^ ERROR E0277 - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-enum-bound.rs b/src/test/compile-fail/wf-enum-bound.rs deleted file mode 100644 index e3e79fdd940..00000000000 --- a/src/test/compile-fail/wf-enum-bound.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check enum bounds for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -enum SomeEnum //~ ERROR E0277 - where T: ExtraCopy -{ - SomeVariant(T,U) -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-enum-fields-struct-variant.rs b/src/test/compile-fail/wf-enum-fields-struct-variant.rs deleted file mode 100644 index 5eb53e7edde..00000000000 --- a/src/test/compile-fail/wf-enum-fields-struct-variant.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check struct fields for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct IsCopy { - value: T -} - -enum AnotherEnum { - AnotherVariant { - f: IsCopy //~ ERROR E0277 - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-enum-fields.rs b/src/test/compile-fail/wf-enum-fields.rs deleted file mode 100644 index 76ad40f8457..00000000000 --- a/src/test/compile-fail/wf-enum-fields.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check struct fields for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct IsCopy { - value: T -} - -enum SomeEnum { - SomeVariant(IsCopy) //~ ERROR E0277 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-fn-where-clause.rs b/src/test/compile-fail/wf-fn-where-clause.rs deleted file mode 100644 index 3ed9e5d9f1e..00000000000 --- a/src/test/compile-fail/wf-fn-where-clause.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check where-clauses on fn items. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -fn foo() where T: ExtraCopy //~ ERROR E0277 -{ -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-impl-associated-type-region.rs b/src/test/compile-fail/wf-impl-associated-type-region.rs deleted file mode 100644 index a319b676eeb..00000000000 --- a/src/test/compile-fail/wf-impl-associated-type-region.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we require that associated types in an impl are well-formed. - -#![feature(rustc_attrs)] - -pub trait Foo<'a> { - type Bar; -} - -impl<'a, T> Foo<'a> for T { - type Bar = &'a T; //~ ERROR E0309 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-impl-associated-type-trait.rs b/src/test/compile-fail/wf-impl-associated-type-trait.rs deleted file mode 100644 index 1e82f609d2a..00000000000 --- a/src/test/compile-fail/wf-impl-associated-type-trait.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we require that associated types in an impl are well-formed. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -pub trait MyHash { } - -pub struct MySet { - data: Vec -} - -pub trait Foo { - type Bar; -} - -impl Foo for T { - type Bar = MySet; - //~^ ERROR the trait bound `T: MyHash` is not satisfied -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-arg.rs b/src/test/compile-fail/wf-in-fn-arg.rs deleted file mode 100644 index e302cac0006..00000000000 --- a/src/test/compile-fail/wf-in-fn-arg.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions also for argument types in fn items. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct MustBeCopy { - t: T -} - -fn bar(_: &MustBeCopy) //~ ERROR E0277 -{ -} - -fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-ret.rs b/src/test/compile-fail/wf-in-fn-ret.rs deleted file mode 100644 index 719bc9282ad..00000000000 --- a/src/test/compile-fail/wf-in-fn-ret.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions also for return types in fn items. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct MustBeCopy { - t: T -} - -fn bar() -> MustBeCopy //~ ERROR E0277 -{ -} - -fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-type-arg.rs b/src/test/compile-fail/wf-in-fn-type-arg.rs deleted file mode 100644 index 08ee0e954ac..00000000000 --- a/src/test/compile-fail/wf-in-fn-type-arg.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions also for types in fns. - -struct MustBeCopy { - t: T -} - -struct Bar { - // needs T: Copy - x: fn(MustBeCopy) //~ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-type-ret.rs b/src/test/compile-fail/wf-in-fn-type-ret.rs deleted file mode 100644 index 6942f786060..00000000000 --- a/src/test/compile-fail/wf-in-fn-type-ret.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions also for types in fns. - -struct MustBeCopy { - t: T -} - -struct Foo { - // needs T: 'static - x: fn() -> MustBeCopy //~ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-type-static.rs b/src/test/compile-fail/wf-in-fn-type-static.rs deleted file mode 100644 index 8e3bca09758..00000000000 --- a/src/test/compile-fail/wf-in-fn-type-static.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions related to regions also for -// types in fns. - -#![allow(dead_code)] -#![feature(rustc_attrs)] - -struct MustBeCopy { - t: T -} - -struct Foo { - // needs T: 'static - x: fn() -> &'static T //~ ERROR E0310 -} - -struct Bar { - // needs T: Copy - x: fn(&'static T) //~ ERROR E0310 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-in-fn-where-clause.rs b/src/test/compile-fail/wf-in-fn-where-clause.rs deleted file mode 100644 index c2f66a2a460..00000000000 --- a/src/test/compile-fail/wf-in-fn-where-clause.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions also for where clauses in fn items. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait MustBeCopy { -} - -fn bar() //~ ERROR E0277 - where T: MustBeCopy -{ -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-in-obj-type-static.rs b/src/test/compile-fail/wf-in-obj-type-static.rs deleted file mode 100644 index 11535fb9f9e..00000000000 --- a/src/test/compile-fail/wf-in-obj-type-static.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions also for types in fns. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait Object { } - -struct MustBeCopy { - t: T -} - -struct Foo { - // needs T: 'static - x: Object<&'static T> //~ ERROR E0310 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-in-obj-type-trait.rs b/src/test/compile-fail/wf-in-obj-type-trait.rs deleted file mode 100644 index add48219c1d..00000000000 --- a/src/test/compile-fail/wf-in-obj-type-trait.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we enforce WF conditions also for types in fns. - -trait Object { } - -struct MustBeCopy { - t: T -} - -struct Bar { - // needs T: Copy - x: Object> //~ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/wf-inherent-impl-method-where-clause.rs b/src/test/compile-fail/wf-inherent-impl-method-where-clause.rs deleted file mode 100644 index 78e12c47e24..00000000000 --- a/src/test/compile-fail/wf-inherent-impl-method-where-clause.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check where-clauses on inherent impl methods. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -struct Foo(T,U); - -impl Foo { - fn foo(self) where T: ExtraCopy //~ ERROR E0277 - {} -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-inherent-impl-where-clause.rs b/src/test/compile-fail/wf-inherent-impl-where-clause.rs deleted file mode 100644 index 7edbb11e245..00000000000 --- a/src/test/compile-fail/wf-inherent-impl-where-clause.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check where-clauses on inherent impls. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -struct Foo(T,U); - -impl Foo where T: ExtraCopy //~ ERROR E0277 -{ -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-misc-methods-issue-28609.rs b/src/test/compile-fail/wf-misc-methods-issue-28609.rs deleted file mode 100644 index 055c86a03a7..00000000000 --- a/src/test/compile-fail/wf-misc-methods-issue-28609.rs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// check that misc. method calls are well-formed - -use std::marker::PhantomData; -use std::ops::{Deref, Shl}; - -#[derive(Copy, Clone)] -struct S<'a, 'b: 'a> { - marker: PhantomData<&'a &'b ()>, - bomb: Option<&'b u32> -} - -type S2<'a> = S<'a, 'a>; - -impl<'a, 'b> S<'a, 'b> { - fn transmute_inherent(&self, a: &'b u32) -> &'a u32 { - a - } -} - -fn return_dangling_pointer_inherent(s: S2) -> &u32 { - let s = s; - s.transmute_inherent(&mut 42) //~ ERROR does not live long enough -} - -impl<'a, 'b> Deref for S<'a, 'b> { - type Target = &'a u32; - fn deref(&self) -> &&'a u32 { - self.bomb.as_ref().unwrap() - } -} - -fn return_dangling_pointer_coerce(s: S2) -> &u32 { - let four = 4; - let mut s = s; - s.bomb = Some(&four); //~ ERROR does not live long enough - &s -} - -fn return_dangling_pointer_unary_op(s: S2) -> &u32 { - let four = 4; - let mut s = s; - s.bomb = Some(&four); //~ ERROR does not live long enough - &*s -} - -impl<'a, 'b> Shl<&'b u32> for S<'a, 'b> { - type Output = &'a u32; - fn shl(self, t: &'b u32) -> &'a u32 { t } -} - -fn return_dangling_pointer_binary_op(s: S2) -> &u32 { - let s = s; - s << &mut 3 //~ ERROR does not live long enough -} - -fn return_dangling_pointer_method(s: S2) -> &u32 { - let s = s; - s.shl(&mut 3) //~ ERROR does not live long enough -} - -fn return_dangling_pointer_ufcs(s: S2) -> &u32 { - let s = s; - S2::shl(s, &mut 3) //~ ERROR does not live long enough -} - -fn main() { - let s = S { marker: PhantomData, bomb: None }; - let _inherent_dp = return_dangling_pointer_inherent(s); - let _coerce_dp = return_dangling_pointer_coerce(s); - let _unary_dp = return_dangling_pointer_unary_op(s); - let _binary_dp = return_dangling_pointer_binary_op(s); - let _method_dp = return_dangling_pointer_method(s); - let _ufcs_dp = return_dangling_pointer_ufcs(s); -} diff --git a/src/test/compile-fail/wf-object-safe.rs b/src/test/compile-fail/wf-object-safe.rs deleted file mode 100644 index 92c0a8c5be8..00000000000 --- a/src/test/compile-fail/wf-object-safe.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that object-safe traits are not WF when used as object types. -// Issue #21953. - -trait A { - fn foo(&self, _x: &Self); -} - -fn main() { - let _x: &A; //~ ERROR E0038 -} diff --git a/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs b/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs deleted file mode 100644 index c11b2e4c544..00000000000 --- a/src/test/compile-fail/wf-outlives-ty-in-fn-or-trait.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that an appearance of `T` in fn args or in a trait object must -// still meet the outlives bounds. Since this is a new requirement, -// this is currently only a warning, not a hard error. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait Trait { } - -struct Foo<'a,T> { - f: &'a fn(T), - //~^ ERROR E0309 -} - -struct Bar<'a,T> { - f: &'a Trait, - //~^ ERROR E0309 -} - -#[rustc_error] -fn main() { } - diff --git a/src/test/compile-fail/wf-static-method.rs b/src/test/compile-fail/wf-static-method.rs deleted file mode 100644 index e99957c7914..00000000000 --- a/src/test/compile-fail/wf-static-method.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// check that static methods don't get to assume their trait-ref -// is well-formed. -// FIXME(#27579): this is just a bug. However, our checking with -// static inherent methods isn't quite working - need to -// fix that before removing the check. - -trait Foo<'a, 'b, T>: Sized { - fn make_me() -> Self { loop {} } - fn static_evil(u: &'b u32) -> &'a u32; -} - -struct Evil<'a, 'b: 'a>(Option<&'a &'b ()>); - -impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { - fn make_me() -> Self { } - fn static_evil(u: &'b u32) -> &'a u32 { - u //~ ERROR E0312 - } -} - -struct IndirectEvil<'a, 'b: 'a>(Option<&'a &'b ()>); - -impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { - fn make_me() -> Self { IndirectEvil(None) } - fn static_evil(u: &'b u32) -> &'a u32 { - let me = Self::make_me(); //~ ERROR lifetime bound not satisfied - loop {} // (`me` could be used for the lifetime transmute). - } -} - -impl<'a, 'b> Evil<'a, 'b> { - fn inherent_evil(u: &'b u32) -> &'a u32 { - u //~ ERROR E0312 - } -} - -// while static methods don't get to *assume* this, we still -// *check* that they hold. - -fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { - <()>::static_evil(b) //~ ERROR cannot infer an appropriate lifetime -} - -fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { - ::static_evil(b) - //~^ ERROR cannot infer an appropriate lifetime -} - -fn inherent_evil<'a, 'b>(b: &'b u32) -> &'a u32 { - ::inherent_evil(b) // bug? shouldn't this be an error -} - - -fn main() {} diff --git a/src/test/compile-fail/wf-static-type.rs b/src/test/compile-fail/wf-static-type.rs deleted file mode 100644 index ba02c5dca3e..00000000000 --- a/src/test/compile-fail/wf-static-type.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check the types of statics are well-formed. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct IsCopy { t: T } -struct NotCopy; - -static FOO: IsCopy> = IsCopy { t: None }; -//~^ ERROR E0277 - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-struct-bound.rs b/src/test/compile-fail/wf-struct-bound.rs deleted file mode 100644 index e263b251aa3..00000000000 --- a/src/test/compile-fail/wf-struct-bound.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check struct bounds for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -struct SomeStruct //~ ERROR E0277 - where T: ExtraCopy -{ - data: (T,U) -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-struct-field.rs b/src/test/compile-fail/wf-struct-field.rs deleted file mode 100644 index 8a631a6c335..00000000000 --- a/src/test/compile-fail/wf-struct-field.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check struct fields for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct IsCopy { - value: T -} - -struct SomeStruct { - data: IsCopy //~ ERROR E0277 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-associated-type-bound.rs b/src/test/compile-fail/wf-trait-associated-type-bound.rs deleted file mode 100644 index 8420edd66a1..00000000000 --- a/src/test/compile-fail/wf-trait-associated-type-bound.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check associated type bounds for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -trait SomeTrait { //~ ERROR E0277 - type Type1: ExtraCopy; -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-associated-type-region.rs b/src/test/compile-fail/wf-trait-associated-type-region.rs deleted file mode 100644 index 95d9ffdf9d3..00000000000 --- a/src/test/compile-fail/wf-trait-associated-type-region.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check associated type default values for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait SomeTrait<'a> { - type Type1; - type Type2 = &'a Self::Type1; - //~^ ERROR E0309 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-associated-type-trait.rs b/src/test/compile-fail/wf-trait-associated-type-trait.rs deleted file mode 100644 index 902cbe2676b..00000000000 --- a/src/test/compile-fail/wf-trait-associated-type-trait.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check associated type default values for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -struct IsCopy { x: T } - -trait SomeTrait { - type Type1; - type Type2 = IsCopy; - //~^ ERROR E0277 -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-bound.rs b/src/test/compile-fail/wf-trait-bound.rs deleted file mode 100644 index ca15a6ab648..00000000000 --- a/src/test/compile-fail/wf-trait-bound.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check supertrait bounds for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -trait SomeTrait //~ ERROR E0277 - where T: ExtraCopy -{ -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-default-fn-arg.rs b/src/test/compile-fail/wf-trait-default-fn-arg.rs deleted file mode 100644 index 453aa2428ce..00000000000 --- a/src/test/compile-fail/wf-trait-default-fn-arg.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we test WF conditions for fn arguments. Because the -// current code is so goofy, this is only a warning for now. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -struct Bar { value: Box } - -trait Foo { - fn bar(&self, x: &Bar) { - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-default-fn-ret.rs b/src/test/compile-fail/wf-trait-default-fn-ret.rs deleted file mode 100644 index d94708d3e06..00000000000 --- a/src/test/compile-fail/wf-trait-default-fn-ret.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we test WF conditions for fn arguments. Because the -// current code is so goofy, this is only a warning for now. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -struct Bar { value: Box } - -trait Foo { - fn bar(&self) -> Bar { - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. - loop { } - } -} - -fn main() { } diff --git a/src/test/compile-fail/wf-trait-default-fn-where-clause.rs b/src/test/compile-fail/wf-trait-default-fn-where-clause.rs deleted file mode 100644 index 29c85250583..00000000000 --- a/src/test/compile-fail/wf-trait-default-fn-where-clause.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we test WF conditions for fn arguments. Because the -// current code is so goofy, this is only a warning for now. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -trait Bar { } - -trait Foo { - fn bar(&self) where A: Bar { - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-fn-arg.rs b/src/test/compile-fail/wf-trait-fn-arg.rs deleted file mode 100644 index d88e36faeec..00000000000 --- a/src/test/compile-fail/wf-trait-fn-arg.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we test WF conditions for fn arguments in a trait definition. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -struct Bar { value: Box } - -trait Foo { - fn bar(&self, x: &Bar); - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. -} - -fn main() { } diff --git a/src/test/compile-fail/wf-trait-fn-ret.rs b/src/test/compile-fail/wf-trait-fn-ret.rs deleted file mode 100644 index c368ff9a4a8..00000000000 --- a/src/test/compile-fail/wf-trait-fn-ret.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we test WF conditions for fn return types in a trait definition. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -struct Bar { value: Box } - -trait Foo { - fn bar(&self) -> &Bar; - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. -} - -fn main() { } diff --git a/src/test/compile-fail/wf-trait-fn-where-clause.rs b/src/test/compile-fail/wf-trait-fn-where-clause.rs deleted file mode 100644 index f46a54504a0..00000000000 --- a/src/test/compile-fail/wf-trait-fn-where-clause.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that we test WF conditions for fn where clauses in a trait definition. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![allow(unused_variables)] - -struct Bar { value: Box } - -trait Foo { - fn bar(&self) where Self: Sized, Bar: Copy; - //~^ ERROR E0277 - // - // Here, Eq ought to be implemented. -} - -#[rustc_error] -fn main() { } diff --git a/src/test/compile-fail/wf-trait-superbound.rs b/src/test/compile-fail/wf-trait-superbound.rs deleted file mode 100644 index ea8b2fdf3a1..00000000000 --- a/src/test/compile-fail/wf-trait-superbound.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we check supertrait bounds for WFedness. - -#![feature(associated_type_defaults)] -#![feature(rustc_attrs)] -#![allow(dead_code)] - -trait ExtraCopy { } - -trait SomeTrait: ExtraCopy { //~ ERROR E0277 -} - -fn main() { } diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs deleted file mode 100644 index 458ee669424..00000000000 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn require_copy(x: T) {} - -struct Foo { x: T } - -// Ensure constraints are only attached to methods locally -impl Foo { - fn needs_copy(self) where T: Copy { - require_copy(self.x); - - } - - fn fails_copy(self) { - require_copy(self.x); - //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied - } -} - -fn main() {} diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs deleted file mode 100644 index b3f99f2ae25..00000000000 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn require_copy(x: T) {} - -struct Bar { x: T } - -trait Foo { - fn needs_copy(self) where T: Copy; - fn fails_copy(self); -} - -// Ensure constraints are only attached to methods locally -impl Foo for Bar { - fn needs_copy(self) where T: Copy { - require_copy(self.x); - - } - - fn fails_copy(self) { - require_copy(self.x); - //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied - } -} - -fn main() {} diff --git a/src/test/compile-fail/where-clause-method-substituion.rs b/src/test/compile-fail/where-clause-method-substituion.rs deleted file mode 100644 index 05a58daf906..00000000000 --- a/src/test/compile-fail/where-clause-method-substituion.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - fn dummy(&self, t: T) { } -} - -trait Bar { - fn method(&self) where A: Foo; -} - -struct S; -struct X; - -// Remove this impl causing the below resolution to fail // impl Foo for X {} - -impl Bar for isize { - fn method(&self) where X: Foo { - } -} - -fn main() { - 1.method::(); - //~^ ERROR the trait bound `X: Foo` is not satisfied -} diff --git a/src/test/compile-fail/where-clauses-method-unsatisfied.rs b/src/test/compile-fail/where-clauses-method-unsatisfied.rs deleted file mode 100644 index 1ac03330afd..00000000000 --- a/src/test/compile-fail/where-clauses-method-unsatisfied.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a where clause attached to a method allows us to add -// additional constraints to a parameter out of scope. - -struct Foo { - value: T -} - -struct Bar; // does not implement Eq - -impl Foo { - fn equals(&self, u: &Foo) -> bool where T : Eq { - self.value == u.value - } -} - -fn main() { - let x = Foo { value: Bar }; - x.equals(&x); - //~^ ERROR `Bar: std::cmp::Eq` is not satisfied -} diff --git a/src/test/compile-fail/where-clauses-unsatisfied.rs b/src/test/compile-fail/where-clauses-unsatisfied.rs deleted file mode 100644 index ffc39008c4e..00000000000 --- a/src/test/compile-fail/where-clauses-unsatisfied.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn equal(a: &T, b: &T) -> bool where T : Eq { a == b } - -struct Struct; - -fn main() { - drop(equal(&Struct, &Struct)) - //~^ ERROR the trait bound `Struct: std::cmp::Eq` is not satisfied -} diff --git a/src/test/compile-fail/where-equality-constraints.rs b/src/test/compile-fail/where-equality-constraints.rs deleted file mode 100644 index e449a736c75..00000000000 --- a/src/test/compile-fail/where-equality-constraints.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() where u8 = u16 {} -//~^ ERROR equality constraints are not yet supported in where clauses -fn g() where for<'a> &'static (u8,) == u16, {} -//~^ ERROR equality constraints are not yet supported in where clauses - -fn main() {} diff --git a/src/test/compile-fail/where-for-self-2.rs b/src/test/compile-fail/where-for-self-2.rs deleted file mode 100644 index bf8fc292173..00000000000 --- a/src/test/compile-fail/where-for-self-2.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can quantify lifetimes outside a constraint (i.e., including -// the self type) in a where clause. Specifically, test that implementing for a -// specific lifetime is not enough to satisify the `for<'a> ...` constraint, which -// should require *all* lifetimes. - -static X: &'static u32 = &42; - -trait Bar { - fn bar(&self); -} - -impl Bar for &'static u32 { - fn bar(&self) {} -} - -fn foo(x: &T) - where for<'a> &'a T: Bar -{} - -fn main() { - foo(&X); - //~^ error: `for<'a> &'a _: Bar` is not satisfied -} diff --git a/src/test/compile-fail/where-for-self.rs b/src/test/compile-fail/where-for-self.rs deleted file mode 100644 index 8f447face4e..00000000000 --- a/src/test/compile-fail/where-for-self.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we can quantify lifetimes outside a constraint (i.e., including -// the self type) in a where clause. Specifically, test that we cannot nest -// quantification in constraints (to be clear, there is no reason this should not -// we're testing we don't crash or do something stupid). - -trait Bar<'a> { - fn bar(&self); -} - -impl<'a, 'b> Bar<'b> for &'a u32 { - fn bar(&self) {} -} - -fn foo(x: &T) - where for<'a> &'a T: for<'b> Bar<'b> - //~^ error: nested quantification of lifetimes -{} - -fn main() {} diff --git a/src/test/compile-fail/where-lifetime-resolution.rs b/src/test/compile-fail/where-lifetime-resolution.rs deleted file mode 100644 index 1204cc0df47..00000000000 --- a/src/test/compile-fail/where-lifetime-resolution.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait1<'a> {} -trait Trait2<'a, 'b> {} - -fn f() where - for<'a> Trait1<'a>: Trait1<'a>, // OK - (for<'a> Trait1<'a>): Trait1<'a>, - //~^ ERROR use of undeclared lifetime name `'a` - for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, - //~^ ERROR use of undeclared lifetime name `'b` - //~| ERROR nested quantification of lifetimes -{} - -fn main() {} diff --git a/src/test/compile-fail/while-let.rs b/src/test/compile-fail/while-let.rs deleted file mode 100644 index a70dcccd4e8..00000000000 --- a/src/test/compile-fail/while-let.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn macros() { - macro_rules! foo{ - ($p:pat, $e:expr, $b:block) => {{ - while let $p = $e $b - }} - } - macro_rules! bar{ - ($p:pat, $e:expr, $b:block) => {{ - foo!($p, $e, $b) - }} - } - - foo!(a, 1, { //~ ERROR irrefutable while-let - println!("irrefutable pattern"); - }); - bar!(a, 1, { //~ ERROR irrefutable while-let - println!("irrefutable pattern"); - }); -} - -pub fn main() { - while let a = 1 { //~ ERROR irrefutable while-let - println!("irrefutable pattern"); - } -} diff --git a/src/test/compile-fail/while-type-error.rs b/src/test/compile-fail/while-type-error.rs deleted file mode 100644 index ecab746373a..00000000000 --- a/src/test/compile-fail/while-type-error.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types - -fn main() { while main { } } diff --git a/src/test/compile-fail/windows-subsystem-invalid.rs b/src/test/compile-fail/windows-subsystem-invalid.rs deleted file mode 100644 index 7772cfd6a2c..00000000000 --- a/src/test/compile-fail/windows-subsystem-invalid.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: invalid windows subsystem `wrong`, only `windows` and `console` are allowed - -#![windows_subsystem = "wrong"] - -fn main() {} diff --git a/src/test/compile-fail/write-to-static-mut-in-static.rs b/src/test/compile-fail/write-to-static-mut-in-static.rs deleted file mode 100644 index 1ea74f73723..00000000000 --- a/src/test/compile-fail/write-to-static-mut-in-static.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(const_let)] - -pub static mut A: u32 = 0; -pub static mut B: () = unsafe { A = 1; }; -//~^ ERROR statements in statics are unstable - -pub static mut C: u32 = unsafe { C = 1; 0 }; -//~^ ERROR statements in statics are unstable - -pub static D: u32 = D; - -fn main() {} diff --git a/src/test/compile-fail/writing-to-immutable-vec.rs b/src/test/compile-fail/writing-to-immutable-vec.rs deleted file mode 100644 index f289b85992e..00000000000 --- a/src/test/compile-fail/writing-to-immutable-vec.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -fn main() { - let v: Vec = vec![1, 2, 3]; - v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable -} diff --git a/src/test/compile-fail/wrong-mul-method-signature.rs b/src/test/compile-fail/wrong-mul-method-signature.rs deleted file mode 100644 index 069fd2dec99..00000000000 --- a/src/test/compile-fail/wrong-mul-method-signature.rs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test is to make sure we don't just ICE if the trait -// method for an operator is not implemented properly. -// (In this case the mul method should take &f64 and not f64) -// See: #11450 - -use std::ops::Mul; - -struct Vec1 { - x: f64 -} - -// Expecting value in input signature -impl Mul for Vec1 { - type Output = Vec1; - - fn mul(self, s: &f64) -> Vec1 { - //~^ ERROR method `mul` has an incompatible type for trait - Vec1 { - x: self.x * *s - } - } -} - -struct Vec2 { - x: f64, - y: f64 -} - -// Wrong type parameter ordering -impl Mul for Vec2 { - type Output = f64; - - fn mul(self, s: f64) -> Vec2 { - //~^ ERROR method `mul` has an incompatible type for trait - Vec2 { - x: self.x * s, - y: self.y * s - } - } -} - -struct Vec3 { - x: f64, - y: f64, - z: f64 -} - -// Unexpected return type -impl Mul for Vec3 { - type Output = i32; - - fn mul(self, s: f64) -> f64 { - //~^ ERROR method `mul` has an incompatible type for trait - s - } -} - -pub fn main() { - // Check that the usage goes from the trait declaration: - - let x: Vec1 = Vec1 { x: 1.0 } * 2.0; // this is OK - - let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order - // (we no longer signal a compile error here, since the - // error in the trait signature will cause compilation to - // abort before we bother looking at function bodies.) - - let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0; -} diff --git a/src/test/compile-fail/wrong-ret-type.rs b/src/test/compile-fail/wrong-ret-type.rs deleted file mode 100644 index 6db11fcffd2..00000000000 --- a/src/test/compile-fail/wrong-ret-type.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mismatched types -fn mk_int() -> usize { let i: isize = 3; return i; } -fn main() { } diff --git a/src/test/compile-fail/xc-private-method.rs b/src/test/compile-fail/xc-private-method.rs deleted file mode 100644 index edc0e31040d..00000000000 --- a/src/test/compile-fail/xc-private-method.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:xc_private_method_lib.rs - -extern crate xc_private_method_lib; - -fn main() { - let _ = xc_private_method_lib::Struct::static_meth_struct(); - //~^ ERROR: method `static_meth_struct` is private - - let _ = xc_private_method_lib::Enum::static_meth_enum(); - //~^ ERROR: method `static_meth_enum` is private -} diff --git a/src/test/compile-fail/xc-private-method2.rs b/src/test/compile-fail/xc-private-method2.rs deleted file mode 100644 index 26e055d7cbb..00000000000 --- a/src/test/compile-fail/xc-private-method2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:xc_private_method_lib.rs - -extern crate xc_private_method_lib; - -fn main() { - let _ = xc_private_method_lib::Struct{ x: 10 }.meth_struct(); - //~^ ERROR method `meth_struct` is private - - let _ = xc_private_method_lib::Enum::Variant1(20).meth_enum(); - //~^ ERROR method `meth_enum` is private -} diff --git a/src/test/compile-fail/xcrate-private-by-default.rs b/src/test/compile-fail/xcrate-private-by-default.rs deleted file mode 100644 index 7dd4d970945..00000000000 --- a/src/test/compile-fail/xcrate-private-by-default.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:static_priv_by_default.rs - -extern crate static_priv_by_default; - -fn foo() {} - -fn main() { - // Actual public items should be public - static_priv_by_default::a; - static_priv_by_default::b; - static_priv_by_default::c; - foo::(); - foo::(); - - // publicly re-exported items should be available - static_priv_by_default::bar::e; - static_priv_by_default::bar::f; - static_priv_by_default::bar::g; - foo::(); - foo::(); - - // private items at the top should be inaccessible - static_priv_by_default::j; - //~^ ERROR: static `j` is private - static_priv_by_default::k; - //~^ ERROR: function `k` is private - static_priv_by_default::l; - //~^ ERROR: struct `l` is private - foo::(); - //~^ ERROR: enum `m` is private - foo::(); - //~^ ERROR: type alias `n` is private - - // public items in a private mod should be inaccessible - static_priv_by_default::foo::a; - //~^ ERROR: module `foo` is private - static_priv_by_default::foo::b; - //~^ ERROR: module `foo` is private - static_priv_by_default::foo::c; - //~^ ERROR: module `foo` is private - foo::(); - //~^ ERROR: module `foo` is private - foo::(); - //~^ ERROR: module `foo` is private -} diff --git a/src/test/compile-fail/xcrate-unit-struct.rs b/src/test/compile-fail/xcrate-unit-struct.rs deleted file mode 100644 index 04af7133000..00000000000 --- a/src/test/compile-fail/xcrate-unit-struct.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:xcrate_unit_struct.rs - -// Make sure that when we have cross-crate unit structs we don't accidentally -// make values out of cross-crate structs that aren't unit. - -extern crate xcrate_unit_struct; - -fn main() { - let _ = xcrate_unit_struct::StructWithFields; - //~^ ERROR expected value, found struct `xcrate_unit_struct::StructWithFields` - let _ = xcrate_unit_struct::Struct; -} diff --git a/src/test/ui/compile-fail-migration/.gitattributes b/src/test/ui/compile-fail-migration/.gitattributes new file mode 100644 index 00000000000..825f664bf9f --- /dev/null +++ b/src/test/ui/compile-fail-migration/.gitattributes @@ -0,0 +1 @@ +trailing-carriage-return-in-string.rs -text \ No newline at end of file diff --git a/src/test/ui/compile-fail-migration/E0501.ast.nll.stderr b/src/test/ui/compile-fail-migration/E0501.ast.nll.stderr new file mode 100644 index 00000000000..a9abc79400e --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0501.ast.nll.stderr @@ -0,0 +1,31 @@ +error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access + --> $DIR/E0501.rs:28:23 + | +LL | let bar = || { + | -- closure construction occurs here +LL | inside_closure(a) + | - first borrow occurs due to use of `a` in closure +LL | }; +LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access + | ^ borrow occurs here +... +LL | drop(bar); + | --- borrow later used here + +error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access + --> $DIR/E0501.rs:31:23 + | +LL | let bar = || { + | -- closure construction occurs here +LL | inside_closure(a) + | - first borrow occurs due to use of `a` in closure +... +LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access + | ^ borrow occurs here +... +LL | drop(bar); + | --- borrow later used here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/compile-fail-migration/E0501.ast.stderr b/src/test/ui/compile-fail-migration/E0501.ast.stderr new file mode 100644 index 00000000000..229b1665017 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0501.ast.stderr @@ -0,0 +1,31 @@ +error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access + --> $DIR/E0501.rs:28:23 + | +LL | let bar = || { + | -- closure construction occurs here +LL | inside_closure(a) + | - previous borrow occurs due to use of `a` in closure +LL | }; +LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access + | ^ borrow occurs here +... +LL | } + | - borrow from closure ends here + +error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access + --> $DIR/E0501.rs:31:23 + | +LL | let bar = || { + | -- closure construction occurs here +LL | inside_closure(a) + | - previous borrow occurs due to use of `a` in closure +... +LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access + | ^ borrow occurs here +... +LL | } + | - borrow from closure ends here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/compile-fail-migration/E0501.mir.stderr b/src/test/ui/compile-fail-migration/E0501.mir.stderr new file mode 100644 index 00000000000..a9abc79400e --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0501.mir.stderr @@ -0,0 +1,31 @@ +error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access + --> $DIR/E0501.rs:28:23 + | +LL | let bar = || { + | -- closure construction occurs here +LL | inside_closure(a) + | - first borrow occurs due to use of `a` in closure +LL | }; +LL | outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access + | ^ borrow occurs here +... +LL | drop(bar); + | --- borrow later used here + +error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access + --> $DIR/E0501.rs:31:23 + | +LL | let bar = || { + | -- closure construction occurs here +LL | inside_closure(a) + | - first borrow occurs due to use of `a` in closure +... +LL | outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access + | ^ borrow occurs here +... +LL | drop(bar); + | --- borrow later used here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/compile-fail-migration/E0501.rs b/src/test/ui/compile-fail-migration/E0501.rs new file mode 100644 index 00000000000..5643e1ef091 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0501.rs @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn inside_closure(x: &mut i32) { +} + +fn outside_closure_1(x: &mut i32) { +} + +fn outside_closure_2(x: &i32) { +} + +fn foo(a: &mut i32) { + let bar = || { + inside_closure(a) + }; + outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access + //[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access + + outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access + //[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access + + drop(bar); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/E0506.ast.nll.stderr b/src/test/ui/compile-fail-migration/E0506.ast.nll.stderr new file mode 100644 index 00000000000..cf6b8d9c8d1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0506.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `fancy_num` because it is borrowed + --> $DIR/E0506.rs:21:5 + | +LL | let fancy_ref = &fancy_num; + | ---------- borrow of `fancy_num` occurs here +LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here +... +LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); + | ------------- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/E0506.ast.stderr b/src/test/ui/compile-fail-migration/E0506.ast.stderr new file mode 100644 index 00000000000..54b4e163681 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0506.ast.stderr @@ -0,0 +1,11 @@ +error[E0506]: cannot assign to `fancy_num` because it is borrowed + --> $DIR/E0506.rs:21:5 + | +LL | let fancy_ref = &fancy_num; + | --------- borrow of `fancy_num` occurs here +LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/E0506.mir.stderr b/src/test/ui/compile-fail-migration/E0506.mir.stderr new file mode 100644 index 00000000000..cf6b8d9c8d1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0506.mir.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `fancy_num` because it is borrowed + --> $DIR/E0506.rs:21:5 + | +LL | let fancy_ref = &fancy_num; + | ---------- borrow of `fancy_num` occurs here +LL | fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here +... +LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); + | ------------- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/E0506.rs b/src/test/ui/compile-fail-migration/E0506.rs new file mode 100644 index 00000000000..c4a7f257394 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0506.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct FancyNum { + num: u8, +} + +fn main() { + let mut fancy_num = FancyNum { num: 5 }; + let fancy_ref = &fancy_num; + fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 + //[mir]~^ ERROR [E0506] + + println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); +} diff --git a/src/test/ui/compile-fail-migration/E0508.ast.stderr b/src/test/ui/compile-fail-migration/E0508.ast.stderr new file mode 100644 index 00000000000..5878b795b77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0508.ast.stderr @@ -0,0 +1,12 @@ +error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array + --> $DIR/E0508.rs:18:18 + | +LL | let _value = array[0]; //[ast]~ ERROR [E0508] + | ^^^^^^^^ + | | + | cannot move out of here + | help: consider using a reference instead: `&array[0]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/compile-fail-migration/E0508.mir.stderr b/src/test/ui/compile-fail-migration/E0508.mir.stderr new file mode 100644 index 00000000000..5878b795b77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0508.mir.stderr @@ -0,0 +1,12 @@ +error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array + --> $DIR/E0508.rs:18:18 + | +LL | let _value = array[0]; //[ast]~ ERROR [E0508] + | ^^^^^^^^ + | | + | cannot move out of here + | help: consider using a reference instead: `&array[0]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/compile-fail-migration/E0508.rs b/src/test/ui/compile-fail-migration/E0508.rs new file mode 100644 index 00000000000..0c3dce6b034 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0508.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct NonCopy; + +fn main() { + let array = [NonCopy; 1]; + let _value = array[0]; //[ast]~ ERROR [E0508] + //[mir]~^ ERROR [E0508] +} diff --git a/src/test/ui/compile-fail-migration/E0583.rs b/src/test/ui/compile-fail-migration/E0583.rs new file mode 100644 index 00000000000..3a5255d0f5f --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0583.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod module_that_doesnt_exist; //~ ERROR E0583 + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/E0583.stderr b/src/test/ui/compile-fail-migration/E0583.stderr new file mode 100644 index 00000000000..82e1cccbb68 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0583.stderr @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `module_that_doesnt_exist` + --> $DIR/E0583.rs:11:5 + | +LL | mod module_that_doesnt_exist; //~ ERROR E0583 + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: name the file either module_that_doesnt_exist.rs or module_that_doesnt_exist/mod.rs inside the directory "$DIR" + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0583`. diff --git a/src/test/ui/compile-fail-migration/E0594.ast.nll.stderr b/src/test/ui/compile-fail-migration/E0594.ast.nll.stderr new file mode 100644 index 00000000000..f96eb01abe4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0594.ast.nll.stderr @@ -0,0 +1,9 @@ +error[E0594]: cannot assign to immutable static item `NUM` + --> $DIR/E0594.rs:17:5 + | +LL | NUM = 20; //[ast]~ ERROR E0594 + | ^^^^^^^^ cannot assign + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/E0594.ast.stderr b/src/test/ui/compile-fail-migration/E0594.ast.stderr new file mode 100644 index 00000000000..f84c1f56ad0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0594.ast.stderr @@ -0,0 +1,9 @@ +error[E0594]: cannot assign to immutable static item + --> $DIR/E0594.rs:17:5 + | +LL | NUM = 20; //[ast]~ ERROR E0594 + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/E0594.mir.stderr b/src/test/ui/compile-fail-migration/E0594.mir.stderr new file mode 100644 index 00000000000..f96eb01abe4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0594.mir.stderr @@ -0,0 +1,9 @@ +error[E0594]: cannot assign to immutable static item `NUM` + --> $DIR/E0594.rs:17:5 + | +LL | NUM = 20; //[ast]~ ERROR E0594 + | ^^^^^^^^ cannot assign + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/E0594.rs b/src/test/ui/compile-fail-migration/E0594.rs new file mode 100644 index 00000000000..e5e96451d13 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0594.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +static NUM: i32 = 18; + +fn main() { + NUM = 20; //[ast]~ ERROR E0594 + //[mir]~^ ERROR cannot assign to immutable static item `NUM` +} diff --git a/src/test/ui/compile-fail-migration/E0596.ast.nll.stderr b/src/test/ui/compile-fail-migration/E0596.ast.nll.stderr new file mode 100644 index 00000000000..589db4a032d --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0596.ast.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/E0596.rs:16:13 + | +LL | let x = 1; + | - help: consider changing this to be mutable: `mut x` +LL | let y = &mut x; //[ast]~ ERROR [E0596] + | ^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/E0596.ast.stderr b/src/test/ui/compile-fail-migration/E0596.ast.stderr new file mode 100644 index 00000000000..d88530b2164 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0596.ast.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable local variable `x` as mutable + --> $DIR/E0596.rs:16:18 + | +LL | let x = 1; + | - consider changing this to `mut x` +LL | let y = &mut x; //[ast]~ ERROR [E0596] + | ^ cannot borrow mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/E0596.mir.stderr b/src/test/ui/compile-fail-migration/E0596.mir.stderr new file mode 100644 index 00000000000..589db4a032d --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0596.mir.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/E0596.rs:16:13 + | +LL | let x = 1; + | - help: consider changing this to be mutable: `mut x` +LL | let y = &mut x; //[ast]~ ERROR [E0596] + | ^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/E0596.rs b/src/test/ui/compile-fail-migration/E0596.rs new file mode 100644 index 00000000000..52bdff55d86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/E0596.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn main() { + let x = 1; + let y = &mut x; //[ast]~ ERROR [E0596] + //[mir]~^ ERROR [E0596] +} diff --git a/src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.rs b/src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.rs new file mode 100644 index 00000000000..fe052f2f47f --- /dev/null +++ b/src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.rs @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_imports)] + +mod foo {} + +use foo::{ + ::bar, //~ ERROR crate root in paths can only be used in start position + super::bar, //~ ERROR `super` in paths can only be used in start position + self::bar, //~ ERROR `self` in paths can only be used in start position +}; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.stderr b/src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.stderr new file mode 100644 index 00000000000..e88d26718a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/absolute-paths-in-nested-use-groups.stderr @@ -0,0 +1,21 @@ +error[E0433]: failed to resolve. crate root in paths can only be used in start position + --> $DIR/absolute-paths-in-nested-use-groups.rs:16:5 + | +LL | ::bar, //~ ERROR crate root in paths can only be used in start position + | ^ crate root in paths can only be used in start position + +error[E0433]: failed to resolve. `super` in paths can only be used in start position + --> $DIR/absolute-paths-in-nested-use-groups.rs:17:5 + | +LL | super::bar, //~ ERROR `super` in paths can only be used in start position + | ^^^^^ `super` in paths can only be used in start position + +error[E0433]: failed to resolve. `self` in paths can only be used in start position + --> $DIR/absolute-paths-in-nested-use-groups.rs:18:5 + | +LL | self::bar, //~ ERROR `self` in paths can only be used in start position + | ^^^^ `self` in paths can only be used in start position + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/access-mode-in-closures.nll.stderr b/src/test/ui/compile-fail-migration/access-mode-in-closures.nll.stderr new file mode 100644 index 00000000000..2aa8f1c3813 --- /dev/null +++ b/src/test/ui/compile-fail-migration/access-mode-in-closures.nll.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/access-mode-in-closures.rs:19:15 + | +LL | match *s { sty(v) => v } //~ ERROR cannot move out + | ^^ - move occurs because v has type `std::vec::Vec`, which does not implement the `Copy` trait + | | + | cannot move out of borrowed content + | help: consider removing this dereference operator: `s` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/access-mode-in-closures.rs b/src/test/ui/compile-fail-migration/access-mode-in-closures.rs new file mode 100644 index 00000000000..bad192fc2cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/access-mode-in-closures.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct sty(Vec ); + +fn unpack(_unpack: F) where F: FnOnce(&sty) -> Vec {} + +fn main() { + let _foo = unpack(|s| { + // Test that `s` is moved here. + match *s { sty(v) => v } //~ ERROR cannot move out + }); +} diff --git a/src/test/ui/compile-fail-migration/access-mode-in-closures.stderr b/src/test/ui/compile-fail-migration/access-mode-in-closures.stderr new file mode 100644 index 00000000000..daecbb6ed29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/access-mode-in-closures.stderr @@ -0,0 +1,11 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/access-mode-in-closures.rs:19:15 + | +LL | match *s { sty(v) => v } //~ ERROR cannot move out + | ^^ - hint: to prevent move, use `ref v` or `ref mut v` + | | + | cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.rs b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.rs new file mode 100644 index 00000000000..e398f16a065 --- /dev/null +++ b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(alloc_error_handler, panic_implementation)] +#![no_std] +#![no_main] + +use core::alloc::Layout; + +#[alloc_error_handler] +fn oom( + info: &Layout, //~ ERROR argument should be `Layout` +) -> () //~ ERROR return type should be `!` +{ + loop {} +} + +#[panic_implementation] +fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.stderr b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.stderr new file mode 100644 index 00000000000..6dd905ceab4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-1.stderr @@ -0,0 +1,14 @@ +error: return type should be `!` + --> $DIR/alloc-error-handler-bad-signature-1.rs:22:6 + | +LL | ) -> () //~ ERROR return type should be `!` + | ^^ + +error: argument should be `Layout` + --> $DIR/alloc-error-handler-bad-signature-1.rs:21:11 + | +LL | info: &Layout, //~ ERROR argument should be `Layout` + | ^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.rs b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.rs new file mode 100644 index 00000000000..4fee9d27e51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(alloc_error_handler, panic_implementation)] +#![no_std] +#![no_main] + +struct Layout; + +#[alloc_error_handler] +fn oom( + info: Layout, //~ ERROR argument should be `Layout` +) { //~ ERROR return type should be `!` + loop {} +} + +#[panic_implementation] +fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.stderr b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.stderr new file mode 100644 index 00000000000..c1fcdc75833 --- /dev/null +++ b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-2.stderr @@ -0,0 +1,14 @@ +error: return type should be `!` + --> $DIR/alloc-error-handler-bad-signature-2.rs:22:3 + | +LL | ) { //~ ERROR return type should be `!` + | ^ + +error: argument should be `Layout` + --> $DIR/alloc-error-handler-bad-signature-2.rs:21:11 + | +LL | info: Layout, //~ ERROR argument should be `Layout` + | ^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.rs b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.rs new file mode 100644 index 00000000000..828a78055d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.rs @@ -0,0 +1,25 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![feature(alloc_error_handler, panic_implementation)] +#![no_std] +#![no_main] + +struct Layout; + +#[alloc_error_handler] +fn oom() -> ! { //~ ERROR function should have one argument + loop {} +} + +#[panic_implementation] +fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.stderr b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.stderr new file mode 100644 index 00000000000..9b792c46c24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/alloc-error-handler-bad-signature-3.stderr @@ -0,0 +1,10 @@ +error: function should have one argument + --> $DIR/alloc-error-handler-bad-signature-3.rs:20:1 + | +LL | / fn oom() -> ! { //~ ERROR function should have one argument +LL | | loop {} +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator.rs b/src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator.rs new file mode 100644 index 00000000000..e5650d5b7b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +use std::alloc::System; + +#[global_allocator] +static A: System = System; diff --git a/src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator2.rs b/src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator2.rs new file mode 100644 index 00000000000..e5650d5b7b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/auxiliary/system-allocator2.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +use std::alloc::System; + +#[global_allocator] +static A: System = System; diff --git a/src/test/ui/compile-fail-migration/allocator/function-allocator.rs b/src/test/ui/compile-fail-migration/allocator/function-allocator.rs new file mode 100644 index 00000000000..989c102b86e --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/function-allocator.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#[global_allocator] +fn foo() {} //~ ERROR: allocators must be statics + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/allocator/function-allocator.stderr b/src/test/ui/compile-fail-migration/allocator/function-allocator.stderr new file mode 100644 index 00000000000..8649b6b1244 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/function-allocator.stderr @@ -0,0 +1,8 @@ +error: allocators must be statics + --> $DIR/function-allocator.rs:13:1 + | +LL | fn foo() {} //~ ERROR: allocators must be statics + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/allocator/not-an-allocator.rs b/src/test/ui/compile-fail-migration/allocator/not-an-allocator.rs new file mode 100644 index 00000000000..6559335960a --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/not-an-allocator.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[global_allocator] +static A: usize = 0; +//~^ the trait bound `usize: +//~| the trait bound `usize: +//~| the trait bound `usize: +//~| the trait bound `usize: + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/allocator/not-an-allocator.stderr b/src/test/ui/compile-fail-migration/allocator/not-an-allocator.stderr new file mode 100644 index 00000000000..757c5066a66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/not-an-allocator.stderr @@ -0,0 +1,35 @@ +error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied + --> $DIR/not-an-allocator.rs:12:1 + | +LL | static A: usize = 0; + | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize` + | + = note: required by `std::alloc::GlobalAlloc::alloc` + +error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied + --> $DIR/not-an-allocator.rs:12:1 + | +LL | static A: usize = 0; + | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize` + | + = note: required by `std::alloc::GlobalAlloc::dealloc` + +error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied + --> $DIR/not-an-allocator.rs:12:1 + | +LL | static A: usize = 0; + | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize` + | + = note: required by `std::alloc::GlobalAlloc::realloc` + +error[E0277]: the trait bound `usize: std::alloc::GlobalAlloc` is not satisfied + --> $DIR/not-an-allocator.rs:12:1 + | +LL | static A: usize = 0; + | ^^^^^^^^^^^^^^^^^^^^ the trait `std::alloc::GlobalAlloc` is not implemented for `usize` + | + = note: required by `std::alloc::GlobalAlloc::alloc_zeroed` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/allocator/two-allocators.rs b/src/test/ui/compile-fail-migration/allocator/two-allocators.rs new file mode 100644 index 00000000000..7a97a11df20 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/two-allocators.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::alloc::System; + +#[global_allocator] +static A: System = System; +#[global_allocator] +static B: System = System; +//~^ ERROR: cannot define more than one #[global_allocator] + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/allocator/two-allocators.stderr b/src/test/ui/compile-fail-migration/allocator/two-allocators.stderr new file mode 100644 index 00000000000..5285ee93f2d --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/two-allocators.stderr @@ -0,0 +1,8 @@ +error: cannot define more than one #[global_allocator] + --> $DIR/two-allocators.rs:16:1 + | +LL | static B: System = System; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/allocator/two-allocators2.rs b/src/test/ui/compile-fail-migration/allocator/two-allocators2.rs new file mode 100644 index 00000000000..e747140dfe5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/two-allocators2.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:system-allocator.rs +// no-prefer-dynamic +// error-pattern: the #[global_allocator] in + +extern crate system_allocator; + +use std::alloc::System; + +#[global_allocator] +static A: System = System; + +fn main() {} + diff --git a/src/test/ui/compile-fail-migration/allocator/two-allocators2.stderr b/src/test/ui/compile-fail-migration/allocator/two-allocators2.stderr new file mode 100644 index 00000000000..2b23ce38ede --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/two-allocators2.stderr @@ -0,0 +1,4 @@ +error: the #[global_allocator] in this crate conflicts with global allocator in: system_allocator + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/allocator/two-allocators3.rs b/src/test/ui/compile-fail-migration/allocator/two-allocators3.rs new file mode 100644 index 00000000000..dd86b02bd20 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/two-allocators3.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:system-allocator.rs +// aux-build:system-allocator2.rs +// no-prefer-dynamic +// error-pattern: the #[global_allocator] in + + +extern crate system_allocator; +extern crate system_allocator2; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/allocator/two-allocators3.stderr b/src/test/ui/compile-fail-migration/allocator/two-allocators3.stderr new file mode 100644 index 00000000000..86e385a96a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/allocator/two-allocators3.stderr @@ -0,0 +1,4 @@ +error: the #[global_allocator] in system_allocator conflicts with this global allocator in: system_allocator2 + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/anon-params-deprecated.rs b/src/test/ui/compile-fail-migration/anon-params-deprecated.rs new file mode 100644 index 00000000000..4d37ba920f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/anon-params-deprecated.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![forbid(anonymous_parameters)] +// Test for the anonymous_parameters deprecation lint (RFC 1685) + +trait T { + fn foo(i32); //~ ERROR anonymous parameters are deprecated + //~| WARNING hard error + + fn bar_with_default_impl(String, String) {} + //~^ ERROR anonymous parameters are deprecated + //~| WARNING hard error + //~| ERROR anonymous parameters are deprecated + //~| WARNING hard error +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/anon-params-deprecated.stderr b/src/test/ui/compile-fail-migration/anon-params-deprecated.stderr new file mode 100644 index 00000000000..fa13b8d97e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/anon-params-deprecated.stderr @@ -0,0 +1,34 @@ +error: anonymous parameters are deprecated and will be removed in the next edition. + --> $DIR/anon-params-deprecated.rs:15:12 + | +LL | fn foo(i32); //~ ERROR anonymous parameters are deprecated + | ^^^ help: Try naming the parameter or explicitly ignoring it: `_: i32` + | +note: lint level defined here + --> $DIR/anon-params-deprecated.rs:11:11 + | +LL | #![forbid(anonymous_parameters)] + | ^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41686 + +error: anonymous parameters are deprecated and will be removed in the next edition. + --> $DIR/anon-params-deprecated.rs:18:30 + | +LL | fn bar_with_default_impl(String, String) {} + | ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41686 + +error: anonymous parameters are deprecated and will be removed in the next edition. + --> $DIR/anon-params-deprecated.rs:18:38 + | +LL | fn bar_with_default_impl(String, String) {} + | ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #41686 + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/compile-fail-migration/arg-count-mismatch.rs b/src/test/ui/compile-fail-migration/arg-count-mismatch.rs new file mode 100644 index 00000000000..673314ec4c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/arg-count-mismatch.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: parameters were supplied + +fn f(x: isize) { } + +fn main() { let i: (); i = f(); } diff --git a/src/test/ui/compile-fail-migration/arg-count-mismatch.stderr b/src/test/ui/compile-fail-migration/arg-count-mismatch.stderr new file mode 100644 index 00000000000..699e36f3472 --- /dev/null +++ b/src/test/ui/compile-fail-migration/arg-count-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0061]: this function takes 1 parameter but 0 parameters were supplied + --> $DIR/arg-count-mismatch.rs:15:28 + | +LL | fn f(x: isize) { } + | -------------- defined here +LL | +LL | fn main() { let i: (); i = f(); } + | ^^^ expected 1 parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/src/test/ui/compile-fail-migration/arg-type-mismatch.rs b/src/test/ui/compile-fail-migration/arg-type-mismatch.rs new file mode 100644 index 00000000000..1f657ca5832 --- /dev/null +++ b/src/test/ui/compile-fail-migration/arg-type-mismatch.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// error-pattern: mismatched types + +fn f(x: isize) { } + +fn main() { let i: (); i = f(()); } diff --git a/src/test/ui/compile-fail-migration/arg-type-mismatch.stderr b/src/test/ui/compile-fail-migration/arg-type-mismatch.stderr new file mode 100644 index 00000000000..2b24d9db3f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/arg-type-mismatch.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/arg-type-mismatch.rs:16:30 + | +LL | fn main() { let i: (); i = f(()); } + | ^^ expected isize, found () + | + = note: expected type `isize` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/array-not-vector.rs b/src/test/ui/compile-fail-migration/array-not-vector.rs new file mode 100644 index 00000000000..47e1c09f380 --- /dev/null +++ b/src/test/ui/compile-fail-migration/array-not-vector.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let _x: i32 = [1, 2, 3]; + //~^ ERROR mismatched types + //~| expected type `i32` + //~| found type `[{integer}; 3]` + //~| expected i32, found array of 3 elements + + let x: &[i32] = &[1, 2, 3]; + let _y: &i32 = x; + //~^ ERROR mismatched types + //~| expected type `&i32` + //~| found type `&[i32]` + //~| expected i32, found slice +} diff --git a/src/test/ui/compile-fail-migration/array-not-vector.stderr b/src/test/ui/compile-fail-migration/array-not-vector.stderr new file mode 100644 index 00000000000..83bf058c449 --- /dev/null +++ b/src/test/ui/compile-fail-migration/array-not-vector.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/array-not-vector.rs:12:19 + | +LL | let _x: i32 = [1, 2, 3]; + | ^^^^^^^^^ expected i32, found array of 3 elements + | + = note: expected type `i32` + found type `[{integer}; 3]` + +error[E0308]: mismatched types + --> $DIR/array-not-vector.rs:19:20 + | +LL | let _y: &i32 = x; + | ^ expected i32, found slice + | + = note: expected type `&i32` + found type `&[i32]` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/array_const_index-0.rs b/src/test/ui/compile-fail-migration/array_const_index-0.rs new file mode 100644 index 00000000000..91007fcd63a --- /dev/null +++ b/src/test/ui/compile-fail-migration/array_const_index-0.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const A: &'static [i32] = &[]; +const B: i32 = (&A)[1]; +//~^ index out of bounds: the len is 0 but the index is 1 +//~| ERROR this constant cannot be used + +fn main() { + let _ = B; +} diff --git a/src/test/ui/compile-fail-migration/array_const_index-0.stderr b/src/test/ui/compile-fail-migration/array_const_index-0.stderr new file mode 100644 index 00000000000..b71d224f4f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/array_const_index-0.stderr @@ -0,0 +1,12 @@ +error: this constant cannot be used + --> $DIR/array_const_index-0.rs:12:1 + | +LL | const B: i32 = (&A)[1]; + | ^^^^^^^^^^^^^^^-------^ + | | + | index out of bounds: the len is 0 but the index is 1 + | + = note: #[deny(const_err)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/array_const_index-1.rs b/src/test/ui/compile-fail-migration/array_const_index-1.rs new file mode 100644 index 00000000000..66739d308a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/array_const_index-1.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const A: [i32; 0] = []; +const B: i32 = A[1]; +//~^ index out of bounds: the len is 0 but the index is 1 +//~| ERROR this constant cannot be used + +fn main() { + let _ = B; +} diff --git a/src/test/ui/compile-fail-migration/array_const_index-1.stderr b/src/test/ui/compile-fail-migration/array_const_index-1.stderr new file mode 100644 index 00000000000..02f86a693af --- /dev/null +++ b/src/test/ui/compile-fail-migration/array_const_index-1.stderr @@ -0,0 +1,12 @@ +error: this constant cannot be used + --> $DIR/array_const_index-1.rs:12:1 + | +LL | const B: i32 = A[1]; + | ^^^^^^^^^^^^^^^----^ + | | + | index out of bounds: the len is 0 but the index is 1 + | + = note: #[deny(const_err)] on by default + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/asm-bad-clobber.rs b/src/test/ui/compile-fail-migration/asm-bad-clobber.rs new file mode 100644 index 00000000000..c2b54e37e39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-bad-clobber.rs @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-android +// ignore-arm +// ignore-aarch64 +// ignore-s390x +// ignore-emscripten +// ignore-powerpc +// ignore-powerpc64 +// ignore-powerpc64le +// ignore-sparc +// ignore-sparc64 +// ignore-mips +// ignore-mips64 + +#![feature(asm, rustc_attrs)] + +#[cfg(any(target_arch = "x86", + target_arch = "x86_64"))] +#[rustc_error] +pub fn main() { + unsafe { + // clobber formatted as register input/output + asm!("xor %eax, %eax" : : : "{eax}"); + //~^ ERROR clobber should not be surrounded by braces + } +} diff --git a/src/test/ui/compile-fail-migration/asm-bad-clobber.stderr b/src/test/ui/compile-fail-migration/asm-bad-clobber.stderr new file mode 100644 index 00000000000..81ab006a18a --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-bad-clobber.stderr @@ -0,0 +1,9 @@ +error[E0664]: clobber should not be surrounded by braces + --> $DIR/asm-bad-clobber.rs:32:37 + | +LL | asm!("xor %eax, %eax" : : : "{eax}"); + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0664`. diff --git a/src/test/ui/compile-fail-migration/asm-in-bad-modifier.rs b/src/test/ui/compile-fail-migration/asm-in-bad-modifier.rs new file mode 100644 index 00000000000..2eefd4235bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-in-bad-modifier.rs @@ -0,0 +1,44 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-s390x +// ignore-emscripten +// ignore-powerpc +// ignore-powerpc64 +// ignore-powerpc64le +// ignore-sparc +// ignore-sparc64 +// ignore-mips +// ignore-mips64 + +#![feature(asm)] + +fn foo(x: isize) { println!("{}", x); } + +#[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64"))] +pub fn main() { + let x: isize; + let y: isize; + unsafe { + asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '=' + asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+' + } + foo(x); + foo(y); +} + +#[cfg(not(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64")))] +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/asm-in-bad-modifier.stderr b/src/test/ui/compile-fail-migration/asm-in-bad-modifier.stderr new file mode 100644 index 00000000000..dcb11bd1e76 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-in-bad-modifier.stderr @@ -0,0 +1,16 @@ +error[E0662]: input operand constraint contains '=' + --> $DIR/asm-in-bad-modifier.rs:33:39 + | +LL | asm!("mov $1, $0" : "=r"(x) : "=r"(5)); //~ ERROR operand constraint contains '=' + | ^^^^ + +error[E0663]: input operand constraint contains '+' + --> $DIR/asm-in-bad-modifier.rs:34:39 + | +LL | asm!("mov $1, $0" : "=r"(y) : "+r"(5)); //~ ERROR operand constraint contains '+' + | ^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0662, E0663. +For more information about an error, try `rustc --explain E0662`. diff --git a/src/test/ui/compile-fail-migration/asm-misplaced-option.rs b/src/test/ui/compile-fail-migration/asm-misplaced-option.rs new file mode 100644 index 00000000000..bfc1fd68fe0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-misplaced-option.rs @@ -0,0 +1,47 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-android +// ignore-arm +// ignore-aarch64 +// ignore-s390x +// ignore-emscripten +// ignore-powerpc +// ignore-powerpc64 +// ignore-powerpc64le +// ignore-sparc +// ignore-sparc64 +// ignore-mips +// ignore-mips64 + +#![feature(asm, rustc_attrs)] + +#![allow(dead_code, non_upper_case_globals)] + +#[cfg(any(target_arch = "x86", + target_arch = "x86_64"))] +#[rustc_error] +pub fn main() { //~ ERROR compilation successful + // assignment not dead + let mut x: isize = 0; + unsafe { + // extra colon + asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc"); + //~^ WARNING unrecognized option + } + assert_eq!(x, 5); + + unsafe { + // comma in place of a colon + asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile"); + //~^ WARNING expected a clobber, found an option + } + assert_eq!(x, 13); +} diff --git a/src/test/ui/compile-fail-migration/asm-misplaced-option.stderr b/src/test/ui/compile-fail-migration/asm-misplaced-option.stderr new file mode 100644 index 00000000000..46723918a3a --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-misplaced-option.stderr @@ -0,0 +1,26 @@ +warning: unrecognized option + --> $DIR/asm-misplaced-option.rs:36:64 + | +LL | asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc"); + | ^^^^ + +warning: expected a clobber, found an option + --> $DIR/asm-misplaced-option.rs:43:80 + | +LL | asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile"); + | ^^^^^^^^^^ + +error: compilation successful + --> $DIR/asm-misplaced-option.rs:31:1 + | +LL | / pub fn main() { //~ ERROR compilation successful +LL | | // assignment not dead +LL | | let mut x: isize = 0; +LL | | unsafe { +... | +LL | | assert_eq!(x, 13); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/asm-out-no-modifier.rs b/src/test/ui/compile-fail-migration/asm-out-no-modifier.rs new file mode 100644 index 00000000000..40d2ded8a88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-out-no-modifier.rs @@ -0,0 +1,41 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-s390x +// ignore-emscripten +// ignore-powerpc +// ignore-powerpc64 +// ignore-powerpc64le +// ignore-sparc +// ignore-sparc64 +// ignore-mips +// ignore-mips64 + +#![feature(asm)] + +fn foo(x: isize) { println!("{}", x); } + +#[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64"))] +pub fn main() { + let x: isize; + unsafe { + asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '=' + } + foo(x); +} + +#[cfg(not(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64")))] +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/asm-out-no-modifier.stderr b/src/test/ui/compile-fail-migration/asm-out-no-modifier.stderr new file mode 100644 index 00000000000..4e9d7b884b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-out-no-modifier.stderr @@ -0,0 +1,9 @@ +error[E0661]: output operand constraint lacks '=' or '+' + --> $DIR/asm-out-no-modifier.rs:32:29 + | +LL | asm!("mov $1, $0" : "r"(x) : "r"(5)); //~ ERROR output operand constraint lacks '=' + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0661`. diff --git a/src/test/ui/compile-fail-migration/asm-out-read-uninit.ast.stderr b/src/test/ui/compile-fail-migration/asm-out-read-uninit.ast.stderr new file mode 100644 index 00000000000..5f6685e5c1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-out-read-uninit.ast.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/asm-out-read-uninit.rs:35:43 + | +LL | asm!("mov $1, $0" : "=r"(x) : "r"(x)); + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/asm-out-read-uninit.mir.stderr b/src/test/ui/compile-fail-migration/asm-out-read-uninit.mir.stderr new file mode 100644 index 00000000000..5f6685e5c1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-out-read-uninit.mir.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/asm-out-read-uninit.rs:35:43 + | +LL | asm!("mov $1, $0" : "=r"(x) : "r"(x)); + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/asm-out-read-uninit.rs b/src/test/ui/compile-fail-migration/asm-out-read-uninit.rs new file mode 100644 index 00000000000..c308a9f0850 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-out-read-uninit.rs @@ -0,0 +1,46 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-s390x +// ignore-emscripten +// ignore-powerpc +// ignore-powerpc64 +// ignore-powerpc64le +// ignore-sparc +// ignore-sparc64 +// ignore-mips +// ignore-mips64 + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(asm)] + +fn foo(x: isize) { println!("{}", x); } + +#[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64"))] +pub fn main() { + let x: isize; + unsafe { + asm!("mov $1, $0" : "=r"(x) : "r"(x)); + //[ast]~^ ERROR use of possibly uninitialized variable: `x` + //[mir]~^^ ERROR use of possibly uninitialized variable: `x` + } + foo(x); +} + +#[cfg(not(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64")))] +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.rs b/src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.rs new file mode 100644 index 00000000000..6c5c5b00776 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// WONTFIX(#20184) Needs landing pads (not present in stage1) or the compiler hangs. +// ignore-stage1 +// compile-flags: -C codegen-units=2 +// ignore-emscripten + +#![feature(asm)] + +fn main() { + unsafe { + asm!("nowayisthisavalidinstruction"); //~ ERROR instruction + } +} diff --git a/src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.stderr b/src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.stderr new file mode 100644 index 00000000000..5bd42690156 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-src-loc-codegen-units.stderr @@ -0,0 +1,11 @@ +error: :1:2: error: invalid instruction mnemonic 'nowayisthisavalidinstruction' + nowayisthisavalidinstruction + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + --> $DIR/asm-src-loc-codegen-units.rs:20:9 + | +LL | asm!("nowayisthisavalidinstruction"); //~ ERROR instruction + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/asm-src-loc.rs b/src/test/ui/compile-fail-migration/asm-src-loc.rs new file mode 100644 index 00000000000..59b47c2408d --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-src-loc.rs @@ -0,0 +1,19 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-emscripten + +#![feature(asm)] + +fn main() { + unsafe { + asm!("nowayisthisavalidinstruction"); //~ ERROR instruction + } +} diff --git a/src/test/ui/compile-fail-migration/asm-src-loc.stderr b/src/test/ui/compile-fail-migration/asm-src-loc.stderr new file mode 100644 index 00000000000..4f79ec6ad64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/asm-src-loc.stderr @@ -0,0 +1,11 @@ +error: :1:2: error: invalid instruction mnemonic 'nowayisthisavalidinstruction' + nowayisthisavalidinstruction + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + --> $DIR/asm-src-loc.rs:17:9 + | +LL | asm!("nowayisthisavalidinstruction"); //~ ERROR instruction + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.nll.stderr b/src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.nll.stderr new file mode 100644 index 00000000000..6d415eb7333 --- /dev/null +++ b/src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/assign-imm-local-twice.rs:20:5 + | +LL | let v: isize; + | - consider changing this to `mut v` +LL | //[mir]~^ NOTE consider changing this to `mut v` +LL | v = 1; //[ast]~ NOTE first assignment + | ----- first assignment to `v` +... +LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.stderr b/src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.stderr new file mode 100644 index 00000000000..32752621e14 --- /dev/null +++ b/src/test/ui/compile-fail-migration/assign-imm-local-twice.ast.stderr @@ -0,0 +1,12 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/assign-imm-local-twice.rs:20:5 + | +LL | v = 1; //[ast]~ NOTE first assignment + | ----- first assignment to `v` +... +LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/assign-imm-local-twice.mir.stderr b/src/test/ui/compile-fail-migration/assign-imm-local-twice.mir.stderr new file mode 100644 index 00000000000..6d415eb7333 --- /dev/null +++ b/src/test/ui/compile-fail-migration/assign-imm-local-twice.mir.stderr @@ -0,0 +1,15 @@ +error[E0384]: cannot assign twice to immutable variable `v` + --> $DIR/assign-imm-local-twice.rs:20:5 + | +LL | let v: isize; + | - consider changing this to `mut v` +LL | //[mir]~^ NOTE consider changing this to `mut v` +LL | v = 1; //[ast]~ NOTE first assignment + | ----- first assignment to `v` +... +LL | v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + | ^^^^^ cannot assign twice to immutable variable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/assign-imm-local-twice.rs b/src/test/ui/compile-fail-migration/assign-imm-local-twice.rs new file mode 100644 index 00000000000..ee9dafdd49e --- /dev/null +++ b/src/test/ui/compile-fail-migration/assign-imm-local-twice.rs @@ -0,0 +1,28 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Zborrowck=mir + +fn test() { + let v: isize; + //[mir]~^ NOTE consider changing this to `mut v` + v = 1; //[ast]~ NOTE first assignment + //[mir]~^ NOTE first assignment + println!("v={}", v); + v = 2; //[ast]~ ERROR cannot assign twice to immutable variable + //[mir]~^ ERROR cannot assign twice to immutable variable `v` + //[ast]~| NOTE cannot assign twice to immutable + //[mir]~| NOTE cannot assign twice to immutable + println!("v={}", v); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/assign-to-method.rs b/src/test/ui/compile-fail-migration/assign-to-method.rs new file mode 100644 index 00000000000..4518ce36b6d --- /dev/null +++ b/src/test/ui/compile-fail-migration/assign-to-method.rs @@ -0,0 +1,31 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct cat { + meows : usize, + + how_hungry : isize, +} + +impl cat { + pub fn speak(&self) { self.meows += 1; } +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +fn main() { + let nyan : cat = cat(52, 99); + nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method +} diff --git a/src/test/ui/compile-fail-migration/assign-to-method.stderr b/src/test/ui/compile-fail-migration/assign-to-method.stderr new file mode 100644 index 00000000000..930b4512572 --- /dev/null +++ b/src/test/ui/compile-fail-migration/assign-to-method.stderr @@ -0,0 +1,11 @@ +error[E0615]: attempted to take value of method `speak` on type `cat` + --> $DIR/assign-to-method.rs:30:8 + | +LL | nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method + | ^^^^^ + | + = help: maybe a `()` to call it is missing? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0615`. diff --git a/src/test/ui/compile-fail-migration/assignment-operator-unimplemented.rs b/src/test/ui/compile-fail-migration/assignment-operator-unimplemented.rs new file mode 100644 index 00000000000..5b24c6bd79f --- /dev/null +++ b/src/test/ui/compile-fail-migration/assignment-operator-unimplemented.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo; + +fn main() { + let mut a = Foo; + let ref b = Foo; + a += *b; //~ Error: binary assignment operation `+=` cannot be applied to type `Foo` +} diff --git a/src/test/ui/compile-fail-migration/assignment-operator-unimplemented.stderr b/src/test/ui/compile-fail-migration/assignment-operator-unimplemented.stderr new file mode 100644 index 00000000000..983d698c63e --- /dev/null +++ b/src/test/ui/compile-fail-migration/assignment-operator-unimplemented.stderr @@ -0,0 +1,13 @@ +error[E0368]: binary assignment operation `+=` cannot be applied to type `Foo` + --> $DIR/assignment-operator-unimplemented.rs:16:3 + | +LL | a += *b; //~ Error: binary assignment operation `+=` cannot be applied to type `Foo` + | -^^^^^^ + | | + | cannot use `+=` on type `Foo` + | + = note: an implementation of `std::ops::AddAssign` might be missing for `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0368`. diff --git a/src/test/ui/compile-fail-migration/assoc-inherent.rs b/src/test/ui/compile-fail-migration/assoc-inherent.rs new file mode 100644 index 00000000000..7eab831258f --- /dev/null +++ b/src/test/ui/compile-fail-migration/assoc-inherent.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test associated types are forbidden in inherent impls. + +struct Foo; + +impl Foo { + type Bar = isize; //~ERROR associated types are not allowed in inherent impls +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/assoc-inherent.stderr b/src/test/ui/compile-fail-migration/assoc-inherent.stderr new file mode 100644 index 00000000000..11497cba0ff --- /dev/null +++ b/src/test/ui/compile-fail-migration/assoc-inherent.stderr @@ -0,0 +1,9 @@ +error[E0202]: associated types are not allowed in inherent impls + --> $DIR/assoc-inherent.rs:16:5 + | +LL | type Bar = isize; //~ERROR associated types are not allowed in inherent impls + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0202`. diff --git a/src/test/ui/compile-fail-migration/associated-const-ambiguity-report.rs b/src/test/ui/compile-fail-migration/associated-const-ambiguity-report.rs new file mode 100644 index 00000000000..5051e78d1ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-ambiguity-report.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +trait Foo { + const ID: i32; +} + +trait Bar { + const ID: i32; +} + +impl Foo for i32 { + const ID: i32 = 1; +} + +impl Bar for i32 { + const ID: i32 = 3; +} + +const X: i32 = ::ID; //~ ERROR E0034 + +fn main() { + assert_eq!(1, X); +} diff --git a/src/test/ui/compile-fail-migration/associated-const-ambiguity-report.stderr b/src/test/ui/compile-fail-migration/associated-const-ambiguity-report.stderr new file mode 100644 index 00000000000..0832b1a2605 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-ambiguity-report.stderr @@ -0,0 +1,20 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/associated-const-ambiguity-report.rs:28:16 + | +LL | const X: i32 = ::ID; //~ ERROR E0034 + | ^^^^^^^^^ multiple `ID` found + | +note: candidate #1 is defined in an impl of the trait `Foo` for the type `i32` + --> $DIR/associated-const-ambiguity-report.rs:21:5 + | +LL | const ID: i32 = 1; + | ^^^^^^^^^^^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `Bar` for the type `i32` + --> $DIR/associated-const-ambiguity-report.rs:25:5 + | +LL | const ID: i32 = 3; + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/src/test/ui/compile-fail-migration/associated-const-array-len.rs b/src/test/ui/compile-fail-migration/associated-const-array-len.rs new file mode 100644 index 00000000000..2cc10f0f956 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-array-len.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +trait Foo { + const ID: usize; +} + +const X: [i32; ::ID] = [0, 1, 2]; +//~^ ERROR the trait bound `i32: Foo` is not satisfied + +fn main() { + assert_eq!(1, X); +} diff --git a/src/test/ui/compile-fail-migration/associated-const-array-len.stderr b/src/test/ui/compile-fail-migration/associated-const-array-len.stderr new file mode 100644 index 00000000000..5504af8fecd --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-array-len.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/associated-const-array-len.rs:16:16 + | +LL | const X: [i32; ::ID] = [0, 1, 2]; + | ^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `i32` + | +note: required by `Foo::ID` + --> $DIR/associated-const-array-len.rs:13:5 + | +LL | const ID: usize; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-const-dead-code.rs b/src/test/ui/compile-fail-migration/associated-const-dead-code.rs new file mode 100644 index 00000000000..42db13f4f3b --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-dead-code.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(dead_code)] + +struct MyFoo; + +impl MyFoo { + const BAR: u32 = 1; + //~^ ERROR associated const is never used: `BAR` +} + +fn main() { + let _: MyFoo = MyFoo; +} diff --git a/src/test/ui/compile-fail-migration/associated-const-dead-code.stderr b/src/test/ui/compile-fail-migration/associated-const-dead-code.stderr new file mode 100644 index 00000000000..ee065812183 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-dead-code.stderr @@ -0,0 +1,14 @@ +error: associated const is never used: `BAR` + --> $DIR/associated-const-dead-code.rs:16:5 + | +LL | const BAR: u32 = 1; + | ^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/associated-const-dead-code.rs:11:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-const-generic-obligations.rs b/src/test/ui/compile-fail-migration/associated-const-generic-obligations.rs new file mode 100644 index 00000000000..45f53418dca --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-generic-obligations.rs @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +trait Foo { + type Out: Sized; +} + +impl Foo for String { + type Out = String; +} + +trait Bar: Foo { + const FROM: Self::Out; +} + +impl Bar for T { + const FROM: &'static str = "foo"; + //~^ ERROR the trait bound `T: Foo` is not satisfied [E0277] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-const-generic-obligations.stderr b/src/test/ui/compile-fail-migration/associated-const-generic-obligations.stderr new file mode 100644 index 00000000000..97986a27c64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-generic-obligations.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/associated-const-generic-obligations.rs:25:5 + | +LL | const FROM: &'static str = "foo"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | + = help: consider adding a `where T: Foo` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-const-in-trait.rs b/src/test/ui/compile-fail-migration/associated-const-in-trait.rs new file mode 100644 index 00000000000..f837d9ab8e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-in-trait.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// #29924 + +#![feature(const_fn, associated_consts)] + +trait Trait { + const N: usize; +} + +impl Trait { + //~^ ERROR the trait `Trait` cannot be made into an object [E0038] + const fn n() -> usize { Self::N } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-const-in-trait.stderr b/src/test/ui/compile-fail-migration/associated-const-in-trait.stderr new file mode 100644 index 00000000000..7804e44f2d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-in-trait.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `Trait` cannot be made into an object + --> $DIR/associated-const-in-trait.rs:19:6 + | +LL | impl Trait { + | ^^^^^ the trait `Trait` cannot be made into an object + | + = note: the trait cannot contain associated consts like `N` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/associated-const-no-item.rs b/src/test/ui/compile-fail-migration/associated-const-no-item.rs new file mode 100644 index 00000000000..f9a57cd6d75 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-no-item.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +trait Foo { + const ID: i32; +} + +const X: i32 = ::ID; +//~^ ERROR no associated item named `ID` found for type `i32` + +fn main() { + assert_eq!(1, X); +} diff --git a/src/test/ui/compile-fail-migration/associated-const-no-item.stderr b/src/test/ui/compile-fail-migration/associated-const-no-item.stderr new file mode 100644 index 00000000000..a09c04ea0b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-no-item.stderr @@ -0,0 +1,13 @@ +error[E0599]: no associated item named `ID` found for type `i32` in the current scope + --> $DIR/associated-const-no-item.rs:16:16 + | +LL | const X: i32 = ::ID; + | ^^^^^^^^^ associated item not found in `i32` + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `ID`, perhaps you need to implement it: + candidate #1: `Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/associated-const-private-impl.rs b/src/test/ui/compile-fail-migration/associated-const-private-impl.rs new file mode 100644 index 00000000000..b5accfff5bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-private-impl.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +mod bar1 { + pub use self::bar2::Foo; + mod bar2 { + pub struct Foo; + + impl Foo { + const ID: i32 = 1; + } + } +} + +fn main() { + assert_eq!(1, bar1::Foo::ID); + //~^ERROR associated constant `ID` is private +} diff --git a/src/test/ui/compile-fail-migration/associated-const-private-impl.stderr b/src/test/ui/compile-fail-migration/associated-const-private-impl.stderr new file mode 100644 index 00000000000..65be3753bac --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-private-impl.stderr @@ -0,0 +1,9 @@ +error[E0624]: associated constant `ID` is private + --> $DIR/associated-const-private-impl.rs:24:19 + | +LL | assert_eq!(1, bar1::Foo::ID); + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.rs b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.rs new file mode 100644 index 00000000000..630a234fa66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.rs @@ -0,0 +1,40 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub enum EFoo { A, B, C, D } + +pub trait Foo { + const X: EFoo; +} + +struct Abc; + +impl Foo for Abc { + const X: EFoo = EFoo::B; +} + +struct Def; +impl Foo for Def { + const X: EFoo = EFoo::D; +} + +pub fn test(arg: EFoo) { + match arg { + A::X => println!("A::X"), + //~^ error: associated consts cannot be referenced in patterns [E0158] + B::X => println!("B::X"), + //~^ error: associated consts cannot be referenced in patterns [E0158] + _ => (), + } +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.stderr b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.stderr new file mode 100644 index 00000000000..a88dd4d9955 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arms.stderr @@ -0,0 +1,15 @@ +error[E0158]: associated consts cannot be referenced in patterns + --> $DIR/associated-const-type-parameter-arms.rs:31:9 + | +LL | A::X => println!("A::X"), + | ^^^^ + +error[E0158]: associated consts cannot be referenced in patterns + --> $DIR/associated-const-type-parameter-arms.rs:33:9 + | +LL | B::X => println!("B::X"), + | ^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0158`. diff --git a/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.rs b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.rs new file mode 100644 index 00000000000..d196cf22156 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub trait Foo { + const Y: usize; +} + +struct Abc; +impl Foo for Abc { + const Y: usize = 8; +} + +struct Def; +impl Foo for Def { + const Y: usize = 33; +} + +pub fn test() { + let _array = [4; ::Y]; + //~^ ERROR the trait bound `A: Foo` is not satisfied [E0277] +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.stderr b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.stderr new file mode 100644 index 00000000000..a440f1f82f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays-2.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `A: Foo` is not satisfied + --> $DIR/associated-const-type-parameter-arrays-2.rs:27:22 + | +LL | let _array = [4; ::Y]; + | ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `A` + | + = help: consider adding a `where A: Foo` bound +note: required by `Foo::Y` + --> $DIR/associated-const-type-parameter-arrays-2.rs:13:5 + | +LL | const Y: usize; + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.rs b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.rs new file mode 100644 index 00000000000..0b24cab2a68 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub trait Foo { + const Y: usize; +} + +struct Abc; +impl Foo for Abc { + const Y: usize = 8; +} + +struct Def; +impl Foo for Def { + const Y: usize = 33; +} + +pub fn test() { + let _array: [u32; ::Y]; + //~^ ERROR the trait bound `A: Foo` is not satisfied [E0277] +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.stderr b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.stderr new file mode 100644 index 00000000000..48891546360 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-type-parameter-arrays.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `A: Foo` is not satisfied + --> $DIR/associated-const-type-parameter-arrays.rs:27:23 + | +LL | let _array: [u32; ::Y]; + | ^^^^^^^^^^^^^ the trait `Foo` is not implemented for `A` + | + = help: consider adding a `where A: Foo` bound +note: required by `Foo::Y` + --> $DIR/associated-const-type-parameter-arrays.rs:13:5 + | +LL | const Y: usize; + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-const-upper-case-lint.rs b/src/test/ui/compile-fail-migration/associated-const-upper-case-lint.rs new file mode 100644 index 00000000000..497ff426b2f --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-upper-case-lint.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(non_upper_case_globals)] +#![allow(dead_code)] + +struct Foo; + +impl Foo { + const not_upper: bool = true; +} +//~^^ ERROR associated constant `not_upper` should have an upper case name such as `NOT_UPPER` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-const-upper-case-lint.stderr b/src/test/ui/compile-fail-migration/associated-const-upper-case-lint.stderr new file mode 100644 index 00000000000..7a5cad69094 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-const-upper-case-lint.stderr @@ -0,0 +1,14 @@ +error: associated constant `not_upper` should have an upper case name such as `NOT_UPPER` + --> $DIR/associated-const-upper-case-lint.rs:17:5 + | +LL | const not_upper: bool = true; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/associated-const-upper-case-lint.rs:11:9 + | +LL | #![deny(non_upper_case_globals)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.rs b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.rs new file mode 100644 index 00000000000..85ea949b9c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct Foo; + +impl Foo { + const bar: bool = true; + fn bar() {} //~ ERROR duplicate definitions +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.stderr b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.stderr new file mode 100644 index 00000000000..3b9be8976b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-2.stderr @@ -0,0 +1,11 @@ +error[E0201]: duplicate definitions with name `bar`: + --> $DIR/associated-item-duplicate-names-2.rs:16:5 + | +LL | const bar: bool = true; + | ----------------------- previous definition of `bar` here +LL | fn bar() {} //~ ERROR duplicate definitions + | ^^^^^^^^^^^ duplicate definition + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0201`. diff --git a/src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.rs b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.rs new file mode 100644 index 00000000000..12cab13d0b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Before the introduction of the "duplicate associated type" error, the +// program below used to result in the "ambiguous associated type" error E0223, +// which is unexpected. + +trait Foo { + type Bar; +} + +struct Baz; + +impl Foo for Baz { + type Bar = i16; + type Bar = u16; //~ ERROR duplicate definitions +} + +fn main() { + let x: Baz::Bar = 5; +} diff --git a/src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.stderr b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.stderr new file mode 100644 index 00000000000..3edf59f2010 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-item-duplicate-names-3.stderr @@ -0,0 +1,11 @@ +error[E0201]: duplicate definitions with name `Bar`: + --> $DIR/associated-item-duplicate-names-3.rs:23:5 + | +LL | type Bar = i16; + | --------------- previous definition of `Bar` here +LL | type Bar = u16; //~ ERROR duplicate definitions + | ^^^^^^^^^^^^^^^ duplicate definition + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0201`. diff --git a/src/test/ui/compile-fail-migration/associated-item-duplicate-names.rs b/src/test/ui/compile-fail-migration/associated-item-duplicate-names.rs new file mode 100644 index 00000000000..a2fc1bc0177 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-item-duplicate-names.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for issue #23969 + + +trait Foo { + type Ty; + const BAR: u32; +} + +impl Foo for () { + type Ty = (); + type Ty = usize; //~ ERROR duplicate definitions + const BAR: u32 = 7; + const BAR: u32 = 8; //~ ERROR duplicate definitions +} + +fn main() { + let _: <() as Foo>::Ty = (); + let _: u32 = <() as Foo>::BAR; +} diff --git a/src/test/ui/compile-fail-migration/associated-item-duplicate-names.stderr b/src/test/ui/compile-fail-migration/associated-item-duplicate-names.stderr new file mode 100644 index 00000000000..4b060a991f9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-item-duplicate-names.stderr @@ -0,0 +1,19 @@ +error[E0201]: duplicate definitions with name `Ty`: + --> $DIR/associated-item-duplicate-names.rs:21:5 + | +LL | type Ty = (); + | ------------- previous definition of `Ty` here +LL | type Ty = usize; //~ ERROR duplicate definitions + | ^^^^^^^^^^^^^^^^ duplicate definition + +error[E0201]: duplicate definitions with name `BAR`: + --> $DIR/associated-item-duplicate-names.rs:23:5 + | +LL | const BAR: u32 = 7; + | ------------------- previous definition of `BAR` here +LL | const BAR: u32 = 8; //~ ERROR duplicate definitions + | ^^^^^^^^^^^^^^^^^^^ duplicate definition + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0201`. diff --git a/src/test/ui/compile-fail-migration/associated-path-shl.rs b/src/test/ui/compile-fail-migration/associated-path-shl.rs new file mode 100644 index 00000000000..7daf0d3c4e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-path-shl.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that associated paths starting with `<<` are successfully parsed. + +fn main() { + let _: <::B>::C; //~ ERROR cannot find type `A` in this scope + let _ = <::B>::C; //~ ERROR cannot find type `A` in this scope + let <::B>::C; //~ ERROR cannot find type `A` in this scope + let 0 ..= <::B>::C; //~ ERROR cannot find type `A` in this scope + //~^ ERROR only char and numeric types are allowed in range patterns + <::B>::C; //~ ERROR cannot find type `A` in this scope +} diff --git a/src/test/ui/compile-fail-migration/associated-path-shl.stderr b/src/test/ui/compile-fail-migration/associated-path-shl.stderr new file mode 100644 index 00000000000..fa41d4abff4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-path-shl.stderr @@ -0,0 +1,43 @@ +error[E0412]: cannot find type `A` in this scope + --> $DIR/associated-path-shl.rs:14:14 + | +LL | let _: <::B>::C; //~ ERROR cannot find type `A` in this scope + | ^ not found in this scope + +error[E0412]: cannot find type `A` in this scope + --> $DIR/associated-path-shl.rs:15:15 + | +LL | let _ = <::B>::C; //~ ERROR cannot find type `A` in this scope + | ^ not found in this scope + +error[E0412]: cannot find type `A` in this scope + --> $DIR/associated-path-shl.rs:16:11 + | +LL | let <::B>::C; //~ ERROR cannot find type `A` in this scope + | ^ not found in this scope + +error[E0412]: cannot find type `A` in this scope + --> $DIR/associated-path-shl.rs:17:17 + | +LL | let 0 ..= <::B>::C; //~ ERROR cannot find type `A` in this scope + | ^ not found in this scope + +error[E0412]: cannot find type `A` in this scope + --> $DIR/associated-path-shl.rs:19:7 + | +LL | <::B>::C; //~ ERROR cannot find type `A` in this scope + | ^ not found in this scope + +error[E0029]: only char and numeric types are allowed in range patterns + --> $DIR/associated-path-shl.rs:17:15 + | +LL | let 0 ..= <::B>::C; //~ ERROR cannot find type `A` in this scope + | ^^^^^^^^^^^ ranges require char or numeric types + | + = note: start type: {integer} + = note: end type: [type error] + +error: aborting due to 6 previous errors + +Some errors occurred: E0029, E0412. +For more information about an error, try `rustc --explain E0029`. diff --git a/src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.rs b/src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.rs new file mode 100644 index 00000000000..ce97019a2b2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.rs @@ -0,0 +1,52 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test equality constraints in a where clause where the type being +// equated appears in a supertrait. + +pub trait Vehicle { + type Color; + + fn go(&self) { } +} + +pub trait Box { + type Color; + + fn mail(&self) { } +} + +fn a(_: C::Color) { + //~^ ERROR ambiguous associated type `Color` in bounds of `C` +} + +fn b(_: C::Color) where C : Vehicle+Box { + //~^ ERROR ambiguous associated type `Color` in bounds of `C` +} + +fn c(_: C::Color) where C : Vehicle, C : Box { + //~^ ERROR ambiguous associated type `Color` in bounds of `C` +} + +struct D; +impl D where X : Vehicle { + fn d(&self, _: X::Color) where X : Box { } + //~^ ERROR ambiguous associated type `Color` in bounds of `X` +} + +trait E { + fn e(&self, _: X::Color) where X : Box; + //~^ ERROR ambiguous associated type `Color` in bounds of `X` + + fn f(&self, _: X::Color) where X : Box { } + //~^ ERROR ambiguous associated type `Color` in bounds of `X` +} + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.stderr b/src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.stderr new file mode 100644 index 00000000000..2706dda1c52 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-type-projection-ambig-between-bound-and-where-clause.stderr @@ -0,0 +1,75 @@ +error[E0221]: ambiguous associated type `Color` in bounds of `C` + --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:26:24 + | +LL | type Color; + | ----------- ambiguous `Color` from `Vehicle` +... +LL | type Color; + | ----------- ambiguous `Color` from `Box` +... +LL | fn a(_: C::Color) { + | ^^^^^^^^ ambiguous associated type `Color` + +error[E0221]: ambiguous associated type `Color` in bounds of `C` + --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:30:12 + | +LL | type Color; + | ----------- ambiguous `Color` from `Vehicle` +... +LL | type Color; + | ----------- ambiguous `Color` from `Box` +... +LL | fn b(_: C::Color) where C : Vehicle+Box { + | ^^^^^^^^ ambiguous associated type `Color` + +error[E0221]: ambiguous associated type `Color` in bounds of `C` + --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:34:12 + | +LL | type Color; + | ----------- ambiguous `Color` from `Vehicle` +... +LL | type Color; + | ----------- ambiguous `Color` from `Box` +... +LL | fn c(_: C::Color) where C : Vehicle, C : Box { + | ^^^^^^^^ ambiguous associated type `Color` + +error[E0221]: ambiguous associated type `Color` in bounds of `X` + --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:45:20 + | +LL | type Color; + | ----------- ambiguous `Color` from `Vehicle` +... +LL | type Color; + | ----------- ambiguous `Color` from `Box` +... +LL | fn e(&self, _: X::Color) where X : Box; + | ^^^^^^^^ ambiguous associated type `Color` + +error[E0221]: ambiguous associated type `Color` in bounds of `X` + --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:48:20 + | +LL | type Color; + | ----------- ambiguous `Color` from `Vehicle` +... +LL | type Color; + | ----------- ambiguous `Color` from `Box` +... +LL | fn f(&self, _: X::Color) where X : Box { } + | ^^^^^^^^ ambiguous associated type `Color` + +error[E0221]: ambiguous associated type `Color` in bounds of `X` + --> $DIR/associated-type-projection-ambig-between-bound-and-where-clause.rs:40:20 + | +LL | type Color; + | ----------- ambiguous `Color` from `Vehicle` +... +LL | type Color; + | ----------- ambiguous `Color` from `Box` +... +LL | fn d(&self, _: X::Color) where X : Box { } + | ^^^^^^^^ ambiguous associated type `Color` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0221`. diff --git a/src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.rs b/src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.rs new file mode 100644 index 00000000000..b388b6a28e3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.rs @@ -0,0 +1,54 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test equality constraints in a where clause where the type being +// equated appears in a supertrait. + +pub trait Vehicle { + type Color; + + fn go(&self) { } +} + +pub trait Car : Vehicle { + fn honk(&self) { } + fn chip_paint(&self, c: Self::Color) { } +} + +/////////////////////////////////////////////////////////////////////////// + +struct Black; +struct ModelT; +impl Vehicle for ModelT { type Color = Black; } +impl Car for ModelT { } + +/////////////////////////////////////////////////////////////////////////// + +struct Blue; +struct ModelU; +impl Vehicle for ModelU { type Color = Blue; } +impl Car for ModelU { } + +/////////////////////////////////////////////////////////////////////////// + +fn dent(c: C, color: C::Color) { c.chip_paint(color) } +fn a() { dent(ModelT, Black); } +fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types +fn c() { dent(ModelU, Black); } //~ ERROR mismatched types +fn d() { dent(ModelU, Blue); } + +/////////////////////////////////////////////////////////////////////////// + +fn e() { ModelT.chip_paint(Black); } +fn f() { ModelT.chip_paint(Blue); } //~ ERROR mismatched types +fn g() { ModelU.chip_paint(Black); } //~ ERROR mismatched types +fn h() { ModelU.chip_paint(Blue); } + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.stderr b/src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.stderr new file mode 100644 index 00000000000..4bc09b624c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-type-projection-from-supertrait.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/associated-type-projection-from-supertrait.rs:43:23 + | +LL | fn b() { dent(ModelT, Blue); } //~ ERROR mismatched types + | ^^^^ expected struct `Black`, found struct `Blue` + | + = note: expected type `Black` + found type `Blue` + +error[E0308]: mismatched types + --> $DIR/associated-type-projection-from-supertrait.rs:44:23 + | +LL | fn c() { dent(ModelU, Black); } //~ ERROR mismatched types + | ^^^^^ expected struct `Blue`, found struct `Black` + | + = note: expected type `Blue` + found type `Black` + +error[E0308]: mismatched types + --> $DIR/associated-type-projection-from-supertrait.rs:50:28 + | +LL | fn f() { ModelT.chip_paint(Blue); } //~ ERROR mismatched types + | ^^^^ expected struct `Black`, found struct `Blue` + | + = note: expected type `Black` + found type `Blue` + +error[E0308]: mismatched types + --> $DIR/associated-type-projection-from-supertrait.rs:51:28 + | +LL | fn g() { ModelU.chip_paint(Black); } //~ ERROR mismatched types + | ^^^^^ expected struct `Blue`, found struct `Black` + | + = note: expected type `Blue` + found type `Black` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.rs b/src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.rs new file mode 100644 index 00000000000..b1194154911 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.rs @@ -0,0 +1,51 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test equality constraints in a where clause where the type being +// equated appears in a supertrait. + +pub trait Vehicle { + type Color; + + fn go(&self) { } +} + +pub trait Car : Vehicle { + fn honk(&self) { } +} + +/////////////////////////////////////////////////////////////////////////// + +struct Black; +struct ModelT; +impl Vehicle for ModelT { type Color = Black; } +impl Car for ModelT { } + +/////////////////////////////////////////////////////////////////////////// + +struct Blue; +struct ModelU; +impl Vehicle for ModelU { type Color = Blue; } +impl Car for ModelU { } + +/////////////////////////////////////////////////////////////////////////// + +fn black_car>(c: C) { +} + +fn blue_car>(c: C) { +} + +fn a() { black_car(ModelT); } +fn b() { blue_car(ModelT); } //~ ERROR type mismatch +fn c() { black_car(ModelU); } //~ ERROR type mismatch +fn d() { blue_car(ModelU); } + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.stderr b/src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.stderr new file mode 100644 index 00000000000..c43ff1ae4cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-binding-to-type-defined-in-supertrait.stderr @@ -0,0 +1,31 @@ +error[E0271]: type mismatch resolving `::Color == Blue` + --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:47:10 + | +LL | fn b() { blue_car(ModelT); } //~ ERROR type mismatch + | ^^^^^^^^ expected struct `Black`, found struct `Blue` + | + = note: expected type `Black` + found type `Blue` +note: required by `blue_car` + --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:43:1 + | +LL | fn blue_car>(c: C) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0271]: type mismatch resolving `::Color == Black` + --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:48:10 + | +LL | fn c() { black_car(ModelU); } //~ ERROR type mismatch + | ^^^^^^^^^ expected struct `Blue`, found struct `Black` + | + = note: expected type `Blue` + found type `Black` +note: required by `black_car` + --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:40:1 + | +LL | fn black_car>(c: C) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/associated-types-bound-failure.rs b/src/test/ui/compile-fail-migration/associated-types-bound-failure.rs new file mode 100644 index 00000000000..cd21fb949cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-bound-failure.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test equality constraints on associated types in a where clause. + +pub trait ToInt { + fn to_int(&self) -> isize; +} + +pub trait GetToInt +{ + type R; + + fn get(&self) -> ::R; +} + +fn foo(g: G) -> isize + where G : GetToInt +{ + ToInt::to_int(&g.get()) //~ ERROR E0277 +} + +fn bar(g: G) -> isize + where G::R : ToInt +{ + ToInt::to_int(&g.get()) // OK +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-types-bound-failure.stderr b/src/test/ui/compile-fail-migration/associated-types-bound-failure.stderr new file mode 100644 index 00000000000..067dfeb454c --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-bound-failure.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `::R: ToInt` is not satisfied + --> $DIR/associated-types-bound-failure.rs:27:5 + | +LL | ToInt::to_int(&g.get()) //~ ERROR E0277 + | ^^^^^^^^^^^^^ the trait `ToInt` is not implemented for `::R` + | + = help: consider adding a `where ::R: ToInt` bound +note: required by `ToInt::to_int` + --> $DIR/associated-types-bound-failure.rs:14:5 + | +LL | fn to_int(&self) -> isize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-coherence-failure.rs b/src/test/ui/compile-fail-migration/associated-types-coherence-failure.rs new file mode 100644 index 00000000000..786a25500a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-coherence-failure.rs @@ -0,0 +1,59 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that coherence detects overlap when some of the types in the +// impls are projections of associated type. Issue #20624. + +use std::marker::PhantomData; +use std::ops::Deref; + +pub struct Cow<'a, B: ?Sized>(PhantomData<(&'a (),B)>); + +/// Trait for moving into a `Cow` +pub trait IntoCow<'a, B: ?Sized> { + /// Moves `self` into `Cow` + fn into_cow(self) -> Cow<'a, B>; +} + +impl<'a, B: ?Sized> IntoCow<'a, B> for ::Owned where B: ToOwned { + fn into_cow(self) -> Cow<'a, B> { + Cow(PhantomData) + } +} + +impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned { +//~^ ERROR E0119 + fn into_cow(self) -> Cow<'a, B> { + self + } +} + +impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned { +//~^ ERROR E0119 + fn into_cow(self) -> Cow<'a, B> { + Cow(PhantomData) + } +} + +impl ToOwned for u8 { + type Owned = &'static u8; + fn to_owned(&self) -> &'static u8 { panic!() } +} + +/// A generalization of Clone to borrowed data. +pub trait ToOwned { + type Owned; + + /// Create owned data from borrowed data, usually by copying. + fn to_owned(&self) -> Self::Owned; +} + + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-coherence-failure.stderr b/src/test/ui/compile-fail-migration/associated-types-coherence-failure.stderr new file mode 100644 index 00000000000..85d4bf78458 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-coherence-failure.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `Cow<'_, _>`: + --> $DIR/associated-types-coherence-failure.rs:31:1 + | +LL | impl<'a, B: ?Sized> IntoCow<'a, B> for ::Owned where B: ToOwned { + | ----------------------------------------------------------------------------- first implementation here +... +LL | impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Cow<'_, _>` + +error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `&_`: + --> $DIR/associated-types-coherence-failure.rs:38:1 + | +LL | impl<'a, B: ?Sized> IntoCow<'a, B> for ::Owned where B: ToOwned { + | ----------------------------------------------------------------------------- first implementation here +... +LL | impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-1.rs b/src/test/ui/compile-fail-migration/associated-types-eq-1.rs new file mode 100644 index 00000000000..6f2ee854543 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-1.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test equality constraints on associated types. Check that unsupported syntax +// does not ICE. + +pub trait Foo { + type A; + fn boo(&self) -> ::A; +} + +fn foo2(x: I) { + let _: A = x.boo(); //~ ERROR cannot find type `A` in this scope +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-1.stderr b/src/test/ui/compile-fail-migration/associated-types-eq-1.stderr new file mode 100644 index 00000000000..81bb2ae4ce2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-1.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `A` in this scope + --> $DIR/associated-types-eq-1.rs:20:12 + | +LL | let _: A = x.boo(); //~ ERROR cannot find type `A` in this scope + | ^ did you mean `I`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-2.rs b/src/test/ui/compile-fail-migration/associated-types-eq-2.rs new file mode 100644 index 00000000000..755a9f2d73f --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-2.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test equality constraints on associated types. Check we get an error when an +// equality constraint is used in a qualified path. + +pub trait Foo { + type A; + fn boo(&self) -> ::A; +} + +struct Bar; + +impl Foo for isize { + type A = usize; + fn boo(&self) -> usize { 42 } +} + +fn baz(x: &>::A) {} +//~^ ERROR associated type bindings are not allowed here + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-2.stderr b/src/test/ui/compile-fail-migration/associated-types-eq-2.stderr new file mode 100644 index 00000000000..0b80f3472dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-2.stderr @@ -0,0 +1,9 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/associated-types-eq-2.rs:26:30 + | +LL | fn baz(x: &>::A) {} + | ^^^^^ associated type not allowed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0229`. diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-3.rs b/src/test/ui/compile-fail-migration/associated-types-eq-3.rs new file mode 100644 index 00000000000..cb952f6534f --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-3.rs @@ -0,0 +1,54 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test equality constraints on associated types. Check we get type errors +// where we should. + +pub trait Foo { + type A; + fn boo(&self) -> ::A; +} + +struct Bar; + +impl Foo for isize { + type A = usize; + fn boo(&self) -> usize { + 42 + } +} + +fn foo1>(x: I) { + let _: Bar = x.boo(); +} + +fn foo2(x: I) { + let _: Bar = x.boo(); + //~^ ERROR mismatched types + //~| expected type `Bar` + //~| found type `::A` + //~| expected struct `Bar`, found associated type +} + + +pub fn baz(x: &Foo) { + let _: Bar = x.boo(); +} + + +pub fn main() { + let a = 42; + foo1(a); + //~^ ERROR type mismatch resolving + //~| expected usize, found struct `Bar` + baz(&a); + //~^ ERROR type mismatch resolving + //~| expected usize, found struct `Bar` +} diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-3.stderr b/src/test/ui/compile-fail-migration/associated-types-eq-3.stderr new file mode 100644 index 00000000000..d8b2be0e1b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-3.stderr @@ -0,0 +1,37 @@ +error[E0308]: mismatched types + --> $DIR/associated-types-eq-3.rs:33:18 + | +LL | let _: Bar = x.boo(); + | ^^^^^^^ expected struct `Bar`, found associated type + | + = note: expected type `Bar` + found type `::A` + +error[E0271]: type mismatch resolving `::A == Bar` + --> $DIR/associated-types-eq-3.rs:48:5 + | +LL | foo1(a); + | ^^^^ expected usize, found struct `Bar` + | + = note: expected type `usize` + found type `Bar` +note: required by `foo1` + --> $DIR/associated-types-eq-3.rs:28:1 + | +LL | fn foo1>(x: I) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0271]: type mismatch resolving `::A == Bar` + --> $DIR/associated-types-eq-3.rs:51:9 + | +LL | baz(&a); + | ^^ expected usize, found struct `Bar` + | + = note: expected type `usize` + found type `Bar` + = note: required for the cast to the object type `dyn Foo` + +error: aborting due to 3 previous errors + +Some errors occurred: E0271, E0308. +For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-expr-path.rs b/src/test/ui/compile-fail-migration/associated-types-eq-expr-path.rs new file mode 100644 index 00000000000..847393ba2b8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-expr-path.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that an associated type cannot be bound in an expression path. + +trait Foo { + type A; + fn bar() -> isize; +} + +impl Foo for isize { + type A = usize; + fn bar() -> isize { 42 } +} + +pub fn main() { + let x: isize = Foo::::bar(); + //~^ ERROR associated type bindings are not allowed here +} diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-expr-path.stderr b/src/test/ui/compile-fail-migration/associated-types-eq-expr-path.stderr new file mode 100644 index 00000000000..36c31cd3f05 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-expr-path.stderr @@ -0,0 +1,9 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/associated-types-eq-expr-path.rs:24:26 + | +LL | let x: isize = Foo::::bar(); + | ^^^^^^^ associated type not allowed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0229`. diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-hr.rs b/src/test/ui/compile-fail-migration/associated-types-eq-hr.rs new file mode 100644 index 00000000000..52a2ca9082d --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-hr.rs @@ -0,0 +1,109 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check testing of equality constraints in a higher-ranked context. + +pub trait TheTrait { + type A; + + fn get(&self, t: T) -> Self::A; +} + +struct IntStruct { + x: isize +} + +impl<'a> TheTrait<&'a isize> for IntStruct { + type A = &'a isize; + + fn get(&self, t: &'a isize) -> &'a isize { + t + } +} + +struct UintStruct { + x: isize +} + +impl<'a> TheTrait<&'a isize> for UintStruct { + type A = &'a usize; + + fn get(&self, t: &'a isize) -> &'a usize { + panic!() + } +} + +struct Tuple { +} + +impl<'a> TheTrait<(&'a isize, &'a isize)> for Tuple { + type A = &'a isize; + + fn get(&self, t: (&'a isize, &'a isize)) -> &'a isize { + t.0 + } +} + +fn foo() + where T : for<'x> TheTrait<&'x isize, A = &'x isize> +{ + // ok for IntStruct, but not UintStruct +} + +fn bar() + where T : for<'x> TheTrait<&'x isize, A = &'x usize> +{ + // ok for UintStruct, but not IntStruct +} + +fn tuple_one() + where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> +{ + // not ok for tuple, two lifetimes and we pick first +} + +fn tuple_two() + where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> +{ + // not ok for tuple, two lifetimes and we pick second +} + +fn tuple_three() + where T : for<'x> TheTrait<(&'x isize, &'x isize), A = &'x isize> +{ + // ok for tuple +} + +fn tuple_four() + where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)> +{ + // not ok for tuple, two lifetimes, and lifetime matching is invariant +} + +pub fn main() { + foo::(); + foo::(); //~ ERROR type mismatch + + bar::(); //~ ERROR type mismatch + bar::(); + + tuple_one::(); + //~^ ERROR E0277 + //~| ERROR type mismatch + + tuple_two::(); + //~^ ERROR E0277 + //~| ERROR type mismatch + + tuple_three::(); + + tuple_four::(); + //~^ ERROR E0277 +} diff --git a/src/test/ui/compile-fail-migration/associated-types-eq-hr.stderr b/src/test/ui/compile-fail-migration/associated-types-eq-hr.stderr new file mode 100644 index 00000000000..5081a2649d1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-eq-hr.stderr @@ -0,0 +1,126 @@ +error[E0271]: type mismatch resolving `for<'x> >::A == &'x isize` + --> $DIR/associated-types-eq-hr.rs:92:5 + | +LL | foo::(); //~ ERROR type mismatch + | ^^^^^^^^^^^^^^^^^ expected usize, found isize + | + = note: expected type `&usize` + found type `&isize` +note: required by `foo` + --> $DIR/associated-types-eq-hr.rs:54:1 + | +LL | / fn foo() +LL | | where T : for<'x> TheTrait<&'x isize, A = &'x isize> +LL | | { +LL | | // ok for IntStruct, but not UintStruct +LL | | } + | |_^ + +error[E0271]: type mismatch resolving `for<'x> >::A == &'x usize` + --> $DIR/associated-types-eq-hr.rs:94:5 + | +LL | bar::(); //~ ERROR type mismatch + | ^^^^^^^^^^^^^^^^ expected isize, found usize + | + = note: expected type `&isize` + found type `&usize` +note: required by `bar` + --> $DIR/associated-types-eq-hr.rs:60:1 + | +LL | / fn bar() +LL | | where T : for<'x> TheTrait<&'x isize, A = &'x usize> +LL | | { +LL | | // ok for UintStruct, but not IntStruct +LL | | } + | |_^ + +error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied + --> $DIR/associated-types-eq-hr.rs:97:5 + | +LL | tuple_one::(); + | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` + | + = help: the following implementations were found: + > +note: required by `tuple_one` + --> $DIR/associated-types-eq-hr.rs:66:1 + | +LL | / fn tuple_one() +LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> +LL | | { +LL | | // not ok for tuple, two lifetimes and we pick first +LL | | } + | |_^ + +error[E0271]: type mismatch resolving `for<'x, 'y> >::A == &'x isize` + --> $DIR/associated-types-eq-hr.rs:97:5 + | +LL | tuple_one::(); + | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime + | +note: required by `tuple_one` + --> $DIR/associated-types-eq-hr.rs:66:1 + | +LL | / fn tuple_one() +LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize> +LL | | { +LL | | // not ok for tuple, two lifetimes and we pick first +LL | | } + | |_^ + +error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied + --> $DIR/associated-types-eq-hr.rs:101:5 + | +LL | tuple_two::(); + | ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` + | + = help: the following implementations were found: + > +note: required by `tuple_two` + --> $DIR/associated-types-eq-hr.rs:72:1 + | +LL | / fn tuple_two() +LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> +LL | | { +LL | | // not ok for tuple, two lifetimes and we pick second +LL | | } + | |_^ + +error[E0271]: type mismatch resolving `for<'x, 'y> >::A == &'y isize` + --> $DIR/associated-types-eq-hr.rs:101:5 + | +LL | tuple_two::(); + | ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime + | +note: required by `tuple_two` + --> $DIR/associated-types-eq-hr.rs:72:1 + | +LL | / fn tuple_two() +LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize> +LL | | { +LL | | // not ok for tuple, two lifetimes and we pick second +LL | | } + | |_^ + +error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied + --> $DIR/associated-types-eq-hr.rs:107:5 + | +LL | tuple_four::(); + | ^^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple` + | + = help: the following implementations were found: + > +note: required by `tuple_four` + --> $DIR/associated-types-eq-hr.rs:84:1 + | +LL | / fn tuple_four() +LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)> +LL | | { +LL | | // not ok for tuple, two lifetimes, and lifetime matching is invariant +LL | | } + | |_^ + +error: aborting due to 7 previous errors + +Some errors occurred: E0271, E0277. +For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.rs b/src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.rs new file mode 100644 index 00000000000..a6fcb9cff13 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Get { + type Value; + fn get(&self) -> ::Value; +} + +trait Other { + fn uhoh(&self, foo: U, bar: ::Value) {} + //~^ ERROR the trait bound `Self: Get` is not satisfied +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.stderr b/src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.stderr new file mode 100644 index 00000000000..e6c15e465b6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-for-unimpl-trait.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Self: Get` is not satisfied + --> $DIR/associated-types-for-unimpl-trait.rs:17:5 + | +LL | fn uhoh(&self, foo: U, bar: ::Value) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | + = help: consider adding a `where Self: Get` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-incomplete-object.rs b/src/test/ui/compile-fail-migration/associated-types-incomplete-object.rs new file mode 100644 index 00000000000..c1feb8ac459 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-incomplete-object.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that the user gets an errror if they omit a binding from an +// object type. + +pub trait Foo { + type A; + type B; + fn boo(&self) -> ::A; +} + +struct Bar; + +impl Foo for isize { + type A = usize; + type B = char; + fn boo(&self) -> usize { + 42 + } +} + +pub fn main() { + let a = &42isize as &Foo; + + let b = &42isize as &Foo; + //~^ ERROR the value of the associated type `B` (from the trait `Foo`) must be specified + + let c = &42isize as &Foo; + //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified + + let d = &42isize as &Foo; + //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified + //~| ERROR the value of the associated type `B` (from the trait `Foo`) must be specified +} diff --git a/src/test/ui/compile-fail-migration/associated-types-incomplete-object.stderr b/src/test/ui/compile-fail-migration/associated-types-incomplete-object.stderr new file mode 100644 index 00000000000..95b1c631250 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-incomplete-object.stderr @@ -0,0 +1,27 @@ +error[E0191]: the value of the associated type `B` (from the trait `Foo`) must be specified + --> $DIR/associated-types-incomplete-object.rs:33:26 + | +LL | let b = &42isize as &Foo; + | ^^^^^^^^^^^^ missing associated type `B` value + +error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified + --> $DIR/associated-types-incomplete-object.rs:36:26 + | +LL | let c = &42isize as &Foo; + | ^^^^^^^^^^^ missing associated type `A` value + +error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified + --> $DIR/associated-types-incomplete-object.rs:39:26 + | +LL | let d = &42isize as &Foo; + | ^^^ missing associated type `A` value + +error[E0191]: the value of the associated type `B` (from the trait `Foo`) must be specified + --> $DIR/associated-types-incomplete-object.rs:39:26 + | +LL | let d = &42isize as &Foo; + | ^^^ missing associated type `B` value + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0191`. diff --git a/src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.rs b/src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.rs new file mode 100644 index 00000000000..83726a1676d --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we report an error if the trait ref in a qualified type +// uses invalid type arguments. + +trait Foo { + type Bar; + fn get_bar(&self) -> Self::Bar; +} + +fn f>(t: &T) { + let u: >::Bar = t.get_bar(); + //~^ ERROR the trait bound `T: Foo` is not satisfied +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.stderr b/src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.stderr new file mode 100644 index 00000000000..40cba5e6834 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-invalid-trait-ref-issue-18865.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/associated-types-invalid-trait-ref-issue-18865.rs:20:12 + | +LL | let u: >::Bar = t.get_bar(); + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `T` + | + = help: consider adding a `where T: Foo` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-issue-17359.rs b/src/test/ui/compile-fail-migration/associated-types-issue-17359.rs new file mode 100644 index 00000000000..82258f124d3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-issue-17359.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we do not ICE when an impl is missing an associated type (and that we report +// a useful error, of course). + +trait Trait { + type Type; +} + +impl Trait for isize {} //~ ERROR missing: `Type` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-issue-17359.stderr b/src/test/ui/compile-fail-migration/associated-types-issue-17359.stderr new file mode 100644 index 00000000000..8ba8194bded --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-issue-17359.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `Type` + --> $DIR/associated-types-issue-17359.rs:18:1 + | +LL | type Type; + | ---------- `Type` from trait +... +LL | impl Trait for isize {} //~ ERROR missing: `Type` + | ^^^^^^^^^^^^^^^^^^^^ missing `Type` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/compile-fail-migration/associated-types-issue-20346.rs b/src/test/ui/compile-fail-migration/associated-types-issue-20346.rs new file mode 100644 index 00000000000..a00aa8364bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-issue-20346.rs @@ -0,0 +1,45 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we reliably check the value of the associated type. + +#![crate_type = "lib"] +#![no_implicit_prelude] + +use std::option::Option::{self, None, Some}; +use std::vec::Vec; + +trait Iterator { + type Item; + + fn next(&mut self) -> Option; +} + +fn is_iterator_of>(_: &I) {} + +struct Adapter { + iter: I, + found_none: bool, +} + +impl Iterator for Adapter where I: Iterator> { + type Item = T; + + fn next(&mut self) -> Option { + loop {} + } +} + +fn test_adapter>>(it: I) { + is_iterator_of::, _>(&it); // Sanity check + let adapter = Adapter { iter: it, found_none: false }; + is_iterator_of::(&adapter); // OK + is_iterator_of::, _>(&adapter); //~ ERROR type mismatch +} diff --git a/src/test/ui/compile-fail-migration/associated-types-issue-20346.stderr b/src/test/ui/compile-fail-migration/associated-types-issue-20346.stderr new file mode 100644 index 00000000000..6f3dfbe0898 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-issue-20346.stderr @@ -0,0 +1,17 @@ +error[E0271]: type mismatch resolving ` as Iterator>::Item == std::option::Option` + --> $DIR/associated-types-issue-20346.rs:44:5 + | +LL | is_iterator_of::, _>(&adapter); //~ ERROR type mismatch + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter, found enum `std::option::Option` + | + = note: expected type `T` + found type `std::option::Option` +note: required by `is_iterator_of` + --> $DIR/associated-types-issue-20346.rs:25:1 + | +LL | fn is_iterator_of>(_: &I) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.rs b/src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.rs new file mode 100644 index 00000000000..9436f825de8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.rs @@ -0,0 +1,56 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { + type X; + type Y; +} + +fn have_x_want_x>(t: &T) +{ + want_x(t); +} + +fn have_x_want_y>(t: &T) +{ + want_y(t); //~ ERROR type mismatch +} + +fn have_y_want_x>(t: &T) +{ + want_x(t); //~ ERROR type mismatch +} + +fn have_y_want_y>(t: &T) +{ + want_y(t); +} + +fn have_xy_want_x>(t: &T) +{ + want_x(t); +} + +fn have_xy_want_y>(t: &T) +{ + want_y(t); +} + +fn have_xy_want_xy>(t: &T) +{ + want_x(t); + want_y(t); +} + +fn want_x>(t: &T) { } + +fn want_y>(t: &T) { } + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.stderr b/src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.stderr new file mode 100644 index 00000000000..c38a5f6e7f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-multiple-types-one-trait.stderr @@ -0,0 +1,31 @@ +error[E0271]: type mismatch resolving `::Y == i32` + --> $DIR/associated-types-multiple-types-one-trait.rs:23:5 + | +LL | want_y(t); //~ ERROR type mismatch + | ^^^^^^ expected associated type, found i32 + | + = note: expected type `::Y` + found type `i32` +note: required by `want_y` + --> $DIR/associated-types-multiple-types-one-trait.rs:54:1 + | +LL | fn want_y>(t: &T) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0271]: type mismatch resolving `::X == u32` + --> $DIR/associated-types-multiple-types-one-trait.rs:28:5 + | +LL | want_x(t); //~ ERROR type mismatch + | ^^^^^^ expected associated type, found u32 + | + = note: expected type `::X` + found type `u32` +note: required by `want_x` + --> $DIR/associated-types-multiple-types-one-trait.rs:52:1 + | +LL | fn want_x>(t: &T) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.rs b/src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.rs new file mode 100644 index 00000000000..baf56ffec86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Get { + type Value; + fn get(&self) -> ::Value; +} + +struct Struct { + x: isize, +} + +impl Struct { + fn uhoh(foo: ::Value) {} + //~^ ERROR the trait bound `T: Get` is not satisfied +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.stderr b/src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.stderr new file mode 100644 index 00000000000..84802d49caa --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-no-suitable-bound.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `T: Get` is not satisfied + --> $DIR/associated-types-no-suitable-bound.rs:21:5 + | +LL | fn uhoh(foo: ::Value) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `T` + | + = help: consider adding a `where T: Get` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.rs b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.rs new file mode 100644 index 00000000000..e0f0f3c47ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we get an error when you use `::Value` in +// the trait definition but `Self` does not, in fact, implement `Get`. +// +// See also associated-types-no-suitable-supertrait.rs, which checks +// that we see the same error when making this mistake on an impl +// rather than the default method impl. +// +// See also run-pass/associated-types-projection-to-unrelated-trait.rs, +// which checks that the trait interface itself is not considered an +// error as long as all impls satisfy the constraint. + +trait Get { + type Value; +} + +trait Other { + fn uhoh(&self, foo: U, bar: ::Value) {} + //~^ ERROR the trait bound `Self: Get` is not satisfied +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.stderr b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.stderr new file mode 100644 index 00000000000..712b95f8e54 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait-2.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Self: Get` is not satisfied + --> $DIR/associated-types-no-suitable-supertrait-2.rs:27:5 + | +LL | fn uhoh(&self, foo: U, bar: ::Value) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | + = help: consider adding a `where Self: Get` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.rs b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.rs new file mode 100644 index 00000000000..ec38595e8fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we get an error when you use `::Value` in +// the trait definition but `Self` does not, in fact, implement `Get`. +// +// See also associated-types-no-suitable-supertrait-2.rs, which checks +// that we see the same error if we get around to checking the default +// method body. +// +// See also run-pass/associated-types-projection-to-unrelated-trait.rs, +// which checks that the trait interface itself is not considered an +// error as long as all impls satisfy the constraint. + +trait Get { + type Value; +} + +trait Other { + fn uhoh(&self, foo: U, bar: ::Value) {} + //~^ ERROR the trait bound `Self: Get` is not satisfied +} + +impl Other for T { + fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} + //~^ ERROR the trait bound `(T, U): Get` is not satisfied +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.stderr b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.stderr new file mode 100644 index 00000000000..6927146ffbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-no-suitable-supertrait.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `Self: Get` is not satisfied + --> $DIR/associated-types-no-suitable-supertrait.rs:27:5 + | +LL | fn uhoh(&self, foo: U, bar: ::Value) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | + = help: consider adding a `where Self: Get` bound + +error[E0277]: the trait bound `(T, U): Get` is not satisfied + --> $DIR/associated-types-no-suitable-supertrait.rs:32:5 + | +LL | fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `(T, U)` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-outlives.nll.stderr b/src/test/ui/compile-fail-migration/associated-types-outlives.nll.stderr new file mode 100644 index 00000000000..384ed8f3284 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-outlives.nll.stderr @@ -0,0 +1,13 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/associated-types-outlives.rs:32:14 + | +LL | 's: loop { y = denormalise(&x); break } + | -- borrow of `x` occurs here +LL | drop(x); //~ ERROR cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here +LL | return f(y); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/associated-types-outlives.rs b/src/test/ui/compile-fail-migration/associated-types-outlives.rs new file mode 100644 index 00000000000..f070ab6799c --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-outlives.rs @@ -0,0 +1,38 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #24622. The older associated types code +// was erroneously assuming that all projections outlived the current +// fn body, causing this (invalid) code to be accepted. + +pub trait Foo<'a> { + type Bar; +} + +impl<'a, T:'a> Foo<'a> for T { + type Bar = &'a T; +} + +fn denormalise<'a, T>(t: &'a T) -> >::Bar { + t +} + +pub fn free_and_use Foo<'a>, + F: for<'a> FnOnce(>::Bar)>(x: T, f: F) { + let y; + 'body: loop { // lifetime annotations added for clarity + 's: loop { y = denormalise(&x); break } + drop(x); //~ ERROR cannot move out of `x` because it is borrowed + return f(y); + } +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-types-outlives.stderr b/src/test/ui/compile-fail-migration/associated-types-outlives.stderr new file mode 100644 index 00000000000..6d46392d94b --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-outlives.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/associated-types-outlives.rs:32:14 + | +LL | 's: loop { y = denormalise(&x); break } + | - borrow of `x` occurs here +LL | drop(x); //~ ERROR cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/associated-types-overridden-default.rs b/src/test/ui/compile-fail-migration/associated-types-overridden-default.rs new file mode 100644 index 00000000000..946a4b2f73a --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-overridden-default.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_type_defaults)] + +pub trait Tr { + type Assoc = u8; + type Assoc2 = Self::Assoc; + const C: u8 = 11; + fn foo(&self) {} +} + +impl Tr for () { + type Assoc = (); + //~^ ERROR need to be reimplemented as `Assoc` was overridden: `Assoc2`, `C`, `foo` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-overridden-default.stderr b/src/test/ui/compile-fail-migration/associated-types-overridden-default.stderr new file mode 100644 index 00000000000..e9a480be067 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-overridden-default.stderr @@ -0,0 +1,9 @@ +error[E0399]: the following trait items need to be reimplemented as `Assoc` was overridden: `Assoc2`, `C`, `foo` + --> $DIR/associated-types-overridden-default.rs:21:5 + | +LL | type Assoc = (); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0399`. diff --git a/src/test/ui/compile-fail-migration/associated-types-path-1.rs b/src/test/ui/compile-fail-migration/associated-types-path-1.rs new file mode 100644 index 00000000000..ab061ca4d8d --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-path-1.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we have one and only one associated type per ref. + +pub trait Foo { + type A; +} +pub trait Bar { + type A; +} + +pub fn f1(a: T, x: T::A) {} //~ERROR associated type `A` not found +pub fn f2(a: T, x: T::A) {} //~ERROR ambiguous associated type `A` + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-path-1.stderr b/src/test/ui/compile-fail-migration/associated-types-path-1.stderr new file mode 100644 index 00000000000..04147922d9c --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-path-1.stderr @@ -0,0 +1,22 @@ +error[E0220]: associated type `A` not found for `T` + --> $DIR/associated-types-path-1.rs:20:23 + | +LL | pub fn f1(a: T, x: T::A) {} //~ERROR associated type `A` not found + | ^^^^ associated type `A` not found + +error[E0221]: ambiguous associated type `A` in bounds of `T` + --> $DIR/associated-types-path-1.rs:21:34 + | +LL | type A; + | ------- ambiguous `A` from `Foo` +... +LL | type A; + | ------- ambiguous `A` from `Bar` +... +LL | pub fn f2(a: T, x: T::A) {} //~ERROR ambiguous associated type `A` + | ^^^^ ambiguous associated type `A` + +error: aborting due to 2 previous errors + +Some errors occurred: E0220, E0221. +For more information about an error, try `rustc --explain E0220`. diff --git a/src/test/ui/compile-fail-migration/associated-types-path-2.rs b/src/test/ui/compile-fail-migration/associated-types-path-2.rs new file mode 100644 index 00000000000..d62f6b0f1a3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-path-2.rs @@ -0,0 +1,56 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test type checking of uses of associated types via sugary paths. + +pub trait Foo { + type A; + + fn dummy(&self) { } +} + +impl Foo for i32 { + type A = u32; +} + +pub fn f1(a: T, x: T::A) {} +pub fn f2(a: T) -> T::A { + panic!(); +} + +pub fn f1_int_int() { + f1(2i32, 4i32); + //~^ ERROR mismatched types + //~| expected u32, found i32 +} + +pub fn f1_int_uint() { + f1(2i32, 4u32); +} + +pub fn f1_uint_uint() { + f1(2u32, 4u32); + //~^ ERROR `u32: Foo` is not satisfied + //~| ERROR `u32: Foo` is not satisfied +} + +pub fn f1_uint_int() { + f1(2u32, 4i32); + //~^ ERROR `u32: Foo` is not satisfied + //~| ERROR `u32: Foo` is not satisfied +} + +pub fn f2_int() { + let _: i32 = f2(2i32); + //~^ ERROR mismatched types + //~| expected i32, found u32 +} + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-path-2.stderr b/src/test/ui/compile-fail-migration/associated-types-path-2.stderr new file mode 100644 index 00000000000..403b4fd4d8e --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-path-2.stderr @@ -0,0 +1,52 @@ +error[E0308]: mismatched types + --> $DIR/associated-types-path-2.rs:29:14 + | +LL | f1(2i32, 4i32); + | ^^^^ expected u32, found i32 + +error[E0277]: the trait bound `u32: Foo` is not satisfied + --> $DIR/associated-types-path-2.rs:39:5 + | +LL | f1(2u32, 4u32); + | ^^ the trait `Foo` is not implemented for `u32` + | +note: required by `f1` + --> $DIR/associated-types-path-2.rs:23:1 + | +LL | pub fn f1(a: T, x: T::A) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `u32: Foo` is not satisfied + --> $DIR/associated-types-path-2.rs:39:5 + | +LL | f1(2u32, 4u32); + | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `u32` + +error[E0277]: the trait bound `u32: Foo` is not satisfied + --> $DIR/associated-types-path-2.rs:45:5 + | +LL | f1(2u32, 4i32); + | ^^ the trait `Foo` is not implemented for `u32` + | +note: required by `f1` + --> $DIR/associated-types-path-2.rs:23:1 + | +LL | pub fn f1(a: T, x: T::A) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `u32: Foo` is not satisfied + --> $DIR/associated-types-path-2.rs:45:5 + | +LL | f1(2u32, 4i32); + | ^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `u32` + +error[E0308]: mismatched types + --> $DIR/associated-types-path-2.rs:51:18 + | +LL | let _: i32 = f2(2i32); + | ^^^^^^^^ expected i32, found u32 + +error: aborting due to 6 previous errors + +Some errors occurred: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.nll.stderr b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.nll.stderr new file mode 100644 index 00000000000..5b8223ff292 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.nll.stderr @@ -0,0 +1,30 @@ +warning: not reporting region error due to nll + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:12 + | +LL | let z: I::A = if cond { x } else { y }; + | ^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:29 + | +LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | let z: I::A = if cond { x } else { y }; + | ^ assignment requires that `'a` must outlive `'b` + +error: unsatisfied lifetime constraints + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:40 + | +LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | let z: I::A = if cond { x } else { y }; + | ^ assignment requires that `'b` must outlive `'a` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.rs b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.rs new file mode 100644 index 00000000000..5451a20d816 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check projection of an associated type out of a higher-ranked +// trait-bound in the context of a function body. + +pub trait Foo { + type A; + + fn get(&self, t: T) -> Self::A; +} + +fn foo<'a, I : for<'x> Foo<&'x isize>>( + x: >::A) +{ + let y: I::A = x; +} + +fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( + x: >::A, + y: >::A, + cond: bool) +{ + // x and y here have two distinct lifetimes: + let z: I::A = if cond { x } else { y }; + //~^ ERROR lifetime mismatch +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.stderr b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.stderr new file mode 100644 index 00000000000..12bbfb24910 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn-body.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:40 + | +LL | x: >::A, + | --------- these two types are declared with different lifetimes... +LL | y: >::A, + | --------- +... +LL | let z: I::A = if cond { x } else { y }; + | ^ ...but data from `x` flows into `y` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.rs b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.rs new file mode 100644 index 00000000000..a79d5c4649a --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.rs @@ -0,0 +1,45 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check projection of an associated type out of a higher-ranked trait-bound +// in the context of a function signature. + +pub trait Foo { + type A; + + fn get(&self, t: T) -> Self::A; +} + +fn foo2 Foo<&'x isize>>( + x: I::A) + //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context +{ + // This case is illegal because we have to instantiate `'x`, and + // we don't know what region to instantiate it with. + // + // This could perhaps be made equivalent to the examples below, + // specifically for fn signatures. +} + +fn foo3 Foo<&'x isize>>( + x: >::A) +{ + // OK, in this case we spelled out the precise regions involved, though we left one of + // them anonymous. +} + +fn foo4<'a, I : for<'x> Foo<&'x isize>>( + x: >::A) +{ + // OK, in this case we spelled out the precise regions involved. +} + + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.stderr b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.stderr new file mode 100644 index 00000000000..399f4d9409a --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-fn.stderr @@ -0,0 +1,9 @@ +error[E0212]: cannot extract an associated type from a higher-ranked trait bound in this context + --> $DIR/associated-types-project-from-hrtb-in-fn.rs:21:8 + | +LL | x: I::A) + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0212`. diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.rs b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.rs new file mode 100644 index 00000000000..e6251a0d318 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check projection of an associated type out of a higher-ranked trait-bound +// in the context of a struct definition. + +pub trait Foo { + type A; + + fn get(&self, t: T) -> Self::A; +} + +struct SomeStruct Foo<&'x isize>> { + field: I::A + //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context +} + +// FIXME(eddyb) This one doesn't even compile because of the unsupported syntax. + +// struct AnotherStruct Foo<&'x isize>> { +// field: Foo<&'y isize>>::A +// } + +struct YetAnotherStruct<'a, I : for<'x> Foo<&'x isize>> { + field: >::A +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.stderr b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.stderr new file mode 100644 index 00000000000..05c0c38c79f --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-struct.stderr @@ -0,0 +1,9 @@ +error[E0212]: cannot extract an associated type from a higher-ranked trait bound in this context + --> $DIR/associated-types-project-from-hrtb-in-struct.rs:21:12 + | +LL | field: I::A + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0212`. diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.rs b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.rs new file mode 100644 index 00000000000..af46a1b42d0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check projection of an associated type out of a higher-ranked trait-bound +// in the context of a method definition in a trait. + +pub trait Foo { + type A; + + fn get(&self, t: T) -> Self::A; +} + +trait SomeTrait Foo<&'x isize>> { + fn some_method(&self, arg: I::A); + //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context +} + +trait AnotherTrait Foo<&'x isize>> { + fn some_method(&self, arg: >::A); +} + +trait YetAnotherTrait Foo<&'x isize>> { + fn some_method<'a>(&self, arg: >::A); +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.stderr b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.stderr new file mode 100644 index 00000000000..ccd568b6253 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-project-from-hrtb-in-trait-method.stderr @@ -0,0 +1,9 @@ +error[E0212]: cannot extract an associated type from a higher-ranked trait bound in this context + --> $DIR/associated-types-project-from-hrtb-in-trait-method.rs:21:32 + | +LL | fn some_method(&self, arg: I::A); + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0212`. diff --git a/src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.rs b/src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.rs new file mode 100644 index 00000000000..3f72391ff90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.rs @@ -0,0 +1,39 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we get an error when you use `::Value` in +// the trait definition even if there is no default method. + +trait Get { + type Value; +} + +trait Other { + fn okay(&self, foo: U, bar: ::Value); + //~^ ERROR E0277 +} + +impl Get for () { + type Value = f32; +} + +impl Get for f64 { + type Value = u32; +} + +impl Other for () { + fn okay(&self, _foo: U, _bar: ::Value) { } +} + +impl Other for f64 { + fn okay(&self, _foo: U, _bar: ::Value) { } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr b/src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr new file mode 100644 index 00000000000..e7e68dcf852 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-projection-to-unrelated-trait-in-method-without-default.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `Self: Get` is not satisfied + --> $DIR/associated-types-projection-to-unrelated-trait-in-method-without-default.rs:19:5 + | +LL | fn okay(&self, foo: U, bar: ::Value); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self` + | + = help: consider adding a `where Self: Get` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types-subtyping-1.rs b/src/test/ui/compile-fail-migration/associated-types-subtyping-1.rs new file mode 100644 index 00000000000..64dcdd39e7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-subtyping-1.rs @@ -0,0 +1,55 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] + +trait Trait<'a> { + type Type; + + fn method(&'a self) { } +} + +fn method1<'a,'b,T>(x: &'a T, y: &'b T) + where T : for<'z> Trait<'z>, 'a : 'b +{ + // Note that &'static T <: &'a T. + let a: >::Type = loop { }; + let b: >::Type = loop { }; + let _: >::Type = a; +} + +fn method2<'a,'b,T>(x: &'a T, y: &'b T) + where T : for<'z> Trait<'z>, 'a : 'b +{ + // Note that &'static T <: &'a T. + let a: >::Type = loop { }; + let b: >::Type = loop { }; + let _: >::Type = a; //~ ERROR E0623 +} + +fn method3<'a,'b,T>(x: &'a T, y: &'b T) + where T : for<'z> Trait<'z>, 'a : 'b +{ + // Note that &'static T <: &'a T. + let a: >::Type = loop { }; + let b: >::Type = loop { }; + let _: >::Type = b; //~ ERROR E0623 +} + +fn method4<'a,'b,T>(x: &'a T, y: &'b T) + where T : for<'z> Trait<'z>, 'a : 'b +{ + // Note that &'static T <: &'a T. + let a: >::Type = loop { }; + let b: >::Type = loop { }; + let _: >::Type = b; +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/associated-types-subtyping-1.stderr b/src/test/ui/compile-fail-migration/associated-types-subtyping-1.stderr new file mode 100644 index 00000000000..d9e8d66e6a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-subtyping-1.stderr @@ -0,0 +1,21 @@ +error[E0623]: lifetime mismatch + --> $DIR/associated-types-subtyping-1.rs:34:37 + | +LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T) + | ----- ----- these two types are declared with different lifetimes... +... +LL | let _: >::Type = a; //~ ERROR E0623 + | ^ ...but data from `y` flows into `x` here + +error[E0623]: lifetime mismatch + --> $DIR/associated-types-subtyping-1.rs:43:37 + | +LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T) + | ----- ----- these two types are declared with different lifetimes... +... +LL | let _: >::Type = b; //~ ERROR E0623 + | ^ ...but data from `y` flows into `x` here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/associated-types-unconstrained.rs b/src/test/ui/compile-fail-migration/associated-types-unconstrained.rs new file mode 100644 index 00000000000..aecbf217a5b --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-unconstrained.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that an associated type cannot be bound in an expression path. + +trait Foo { + type A; + fn bar() -> isize; +} + +impl Foo for isize { + type A = usize; + fn bar() -> isize { 42 } +} + +pub fn main() { + let x: isize = Foo::bar(); + //~^ ERROR type annotations required +} diff --git a/src/test/ui/compile-fail-migration/associated-types-unconstrained.stderr b/src/test/ui/compile-fail-migration/associated-types-unconstrained.stderr new file mode 100644 index 00000000000..abb220c96c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-unconstrained.stderr @@ -0,0 +1,9 @@ +error[E0284]: type annotations required: cannot resolve `<_ as Foo>::A == _` + --> $DIR/associated-types-unconstrained.rs:24:20 + | +LL | let x: isize = Foo::bar(); + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/src/test/ui/compile-fail-migration/associated-types-unsized.rs b/src/test/ui/compile-fail-migration/associated-types-unsized.rs new file mode 100644 index 00000000000..c561ae861ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-unsized.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Get { + type Value: ?Sized; + fn get(&self) -> ::Value; +} + +fn foo(t: T) { + let x = t.get(); //~ ERROR the size for values of type +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/associated-types-unsized.stderr b/src/test/ui/compile-fail-migration/associated-types-unsized.stderr new file mode 100644 index 00000000000..4b9d1ea8fac --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types-unsized.stderr @@ -0,0 +1,14 @@ +error[E0277]: the size for values of type `::Value` cannot be known at compilation time + --> $DIR/associated-types-unsized.rs:17:9 + | +LL | let x = t.get(); //~ ERROR the size for values of type + | ^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `::Value` + = note: to learn more, visit + = help: consider adding a `where ::Value: std::marker::Sized` bound + = note: all local variables must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.clause.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.clause.stderr new file mode 100644 index 00000000000..23a67b5b064 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.clause.stderr @@ -0,0 +1,15 @@ +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-constrained.rs:48:63 + | +LL | fn clause1() where T: for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32 { + | ^^^^^^^ + +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-constrained.rs:53:42 + | +LL | fn clause2() where T: for<'a> Fn() -> <() as Foo<'a>>::Item { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0582`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.func.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.func.stderr new file mode 100644 index 00000000000..c969baeaefe --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.func.stderr @@ -0,0 +1,15 @@ +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/bound-lifetime-constrained.rs:26:50 + | +LL | fn func1(_: for<'a> fn(<() as Foo<'a>>::Item) -> &'a i32) { + | ^^^^^^^ + +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/bound-lifetime-constrained.rs:33:29 + | +LL | fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0581`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.object.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.object.stderr new file mode 100644 index 00000000000..f24fed0f02e --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.object.stderr @@ -0,0 +1,15 @@ +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-constrained.rs:38:56 + | +LL | fn object1(_: Box Fn(<() as Foo<'a>>::Item) -> &'a i32>) { + | ^^^^^^^ + +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-constrained.rs:43:35 + | +LL | fn object2(_: Box Fn() -> <() as Foo<'a>>::Item>) { + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0582`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.rs b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.rs new file mode 100644 index 00000000000..9ba5045f2a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-constrained.rs @@ -0,0 +1,58 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: func object clause + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +trait Foo<'a> { + type Item; +} + +impl<'a> Foo<'a> for() { + type Item = (); +} + +// Check that appearing in a projection input in the argument is not enough: +#[cfg(func)] +fn func1(_: for<'a> fn(<() as Foo<'a>>::Item) -> &'a i32) { + //[func]~^ ERROR E0581 +} + +// Check that appearing in a projection input in the return still +// causes an error: +#[cfg(func)] +fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) { + //[func]~^ ERROR E0581 +} + +#[cfg(object)] +fn object1(_: Box Fn(<() as Foo<'a>>::Item) -> &'a i32>) { + //[object]~^ ERROR E0582 +} + +#[cfg(object)] +fn object2(_: Box Fn() -> <() as Foo<'a>>::Item>) { + //[object]~^ ERROR E0582 +} + +#[cfg(clause)] +fn clause1() where T: for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32 { + //[clause]~^ ERROR `Output` references lifetime `'a` +} + +#[cfg(clause)] +fn clause2() where T: for<'a> Fn() -> <() as Foo<'a>>::Item { + //[clause]~^ ERROR `Output` references lifetime `'a` +} + +#[rustc_error] +fn main() { } //[ok]~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.angle.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.angle.stderr new file mode 100644 index 00000000000..5df8a828012 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.angle.stderr @@ -0,0 +1,27 @@ +error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:22:25 + | +LL | fn angle Foo>() { + | ^^^^^^^^^^^^ + +error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:27:37 + | +LL | fn angle1() where T: for<'a> Foo { + | ^^^^^^^^^^^^ + +error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:32:37 + | +LL | fn angle2() where for<'a> T: Foo { + | ^^^^^^^^^^^^ + +error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:37:27 + | +LL | fn angle3(_: &for<'a> Foo) { + | ^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0582`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.elision.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.elision.stderr new file mode 100644 index 00000000000..0a12aa76a78 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.elision.stderr @@ -0,0 +1,12 @@ +error[E0106]: missing lifetime specifier + --> $DIR/bound-lifetime-in-binding-only.rs:62:23 + | +LL | fn elision &i32>() { + | ^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from + = help: consider giving it a 'static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.ok.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.ok.stderr new file mode 100644 index 00000000000..53594cb83fc --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.ok.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/bound-lifetime-in-binding-only.rs:81:1 + | +LL | fn main() { } //[ok]~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.paren.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.paren.stderr new file mode 100644 index 00000000000..39a5366080b --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.paren.stderr @@ -0,0 +1,27 @@ +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:42:29 + | +LL | fn paren Fn() -> &'a i32>() { + | ^^^^^^^ + +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:47:41 + | +LL | fn paren1() where T: for<'a> Fn() -> &'a i32 { + | ^^^^^^^ + +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:52:41 + | +LL | fn paren2() where for<'a> T: Fn() -> &'a i32 { + | ^^^^^^^ + +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/bound-lifetime-in-binding-only.rs:57:31 + | +LL | fn paren3(_: &for<'a> Fn() -> &'a i32) { + | ^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0582`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.rs b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.rs new file mode 100644 index 00000000000..7cb0623315e --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-binding-only.rs @@ -0,0 +1,81 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: angle paren ok elision + +#![allow(dead_code)] +#![feature(rustc_attrs)] +#![feature(unboxed_closures)] + +trait Foo { + type Item; +} + +#[cfg(angle)] +fn angle Foo>() { + //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` +} + +#[cfg(angle)] +fn angle1() where T: for<'a> Foo { + //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` +} + +#[cfg(angle)] +fn angle2() where for<'a> T: Foo { + //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` +} + +#[cfg(angle)] +fn angle3(_: &for<'a> Foo) { + //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` +} + +#[cfg(paren)] +fn paren Fn() -> &'a i32>() { + //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` +} + +#[cfg(paren)] +fn paren1() where T: for<'a> Fn() -> &'a i32 { + //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` +} + +#[cfg(paren)] +fn paren2() where for<'a> T: Fn() -> &'a i32 { + //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` +} + +#[cfg(paren)] +fn paren3(_: &for<'a> Fn() -> &'a i32) { + //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` +} + +#[cfg(elision)] +fn elision &i32>() { + //[elision]~^ ERROR E0106 +} + +struct Parameterized<'a> { x: &'a str } + +#[cfg(ok)] +fn ok1 Fn(&Parameterized<'a>) -> &'a i32>() { +} + +#[cfg(ok)] +fn ok2 Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() { +} + +#[cfg(ok)] +fn ok3() where for<'a> Parameterized<'a>: Foo { +} + +#[rustc_error] +fn main() { } //[ok]~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.elision.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.elision.stderr new file mode 100644 index 00000000000..8fefdfd4d19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.elision.stderr @@ -0,0 +1,12 @@ +error[E0106]: missing lifetime specifier + --> $DIR/bound-lifetime-in-return-only.rs:44:23 + | +LL | fn elision(_: fn() -> &i32) { + | ^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from + = help: consider giving it a 'static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.local.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.local.stderr new file mode 100644 index 00000000000..ce2cfa6765d --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.local.stderr @@ -0,0 +1,9 @@ +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/bound-lifetime-in-return-only.rs:33:28 + | +LL | let _: for<'a> fn() -> &'a i32 = loop { }; + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0581`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.ok.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.ok.stderr new file mode 100644 index 00000000000..21bef7e5e52 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.ok.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/bound-lifetime-in-return-only.rs:59:1 + | +LL | fn main() { } //[ok]~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.rs b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.rs new file mode 100644 index 00000000000..b9b1317cef5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.rs @@ -0,0 +1,59 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: sig local structure ok elision + +#![allow(dead_code)] +#![feature(rustc_attrs)] +#![feature(unboxed_closures)] + +trait Foo { + type Item; +} + +#[cfg(sig)] +fn sig1(_: for<'a> fn() -> &'a i32) { + //[sig]~^ ERROR return type references lifetime `'a` +} + +#[cfg(sig)] +fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32) { + //[sig]~^ ERROR return type references lifetime `'a` +} + +#[cfg(local)] +fn local1() { + let _: for<'a> fn() -> &'a i32 = loop { }; + //[local]~^ ERROR return type references lifetime `'a` +} + +#[cfg(structure)] +struct Struct1 { + x: for<'a> fn() -> &'a i32 + //[structure]~^ ERROR return type references lifetime `'a` +} + +#[cfg(elision)] +fn elision(_: fn() -> &i32) { + //[elision]~^ ERROR E0106 +} + +struct Parameterized<'a> { x: &'a str } + +#[cfg(ok)] +fn ok1(_: &for<'a> Fn(&Parameterized<'a>) -> &'a i32) { +} + +#[cfg(ok)] +fn ok2(_: &for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { +} + +#[rustc_error] +fn main() { } //[ok]~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.sig.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.sig.stderr new file mode 100644 index 00000000000..26a1585463a --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.sig.stderr @@ -0,0 +1,15 @@ +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/bound-lifetime-in-return-only.rs:22:28 + | +LL | fn sig1(_: for<'a> fn() -> &'a i32) { + | ^^^^^^^ + +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/bound-lifetime-in-return-only.rs:27:39 + | +LL | fn sig2(_: for<'a, 'b> fn(&'b i32) -> &'a i32) { + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0581`. diff --git a/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.structure.stderr b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.structure.stderr new file mode 100644 index 00000000000..db52e4de69b --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/bound-lifetime-in-return-only.structure.stderr @@ -0,0 +1,9 @@ +error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types + --> $DIR/bound-lifetime-in-return-only.rs:39:24 + | +LL | x: for<'a> fn() -> &'a i32 + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0581`. diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.rs b/src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.rs new file mode 100644 index 00000000000..a753527ea53 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.rs @@ -0,0 +1,39 @@ +// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(warnings)] + +pub type ParseResult = Result; + +pub enum Item<'a> { Literal(&'a str), + } + +pub fn colon_or_space(s: &str) -> ParseResult<&str> { + unimplemented!() +} + +pub fn timezone_offset_zulu(s: &str, colon: F) -> ParseResult<(&str, i32)> + where F: FnMut(&str) -> ParseResult<&str> { + unimplemented!() +} + +pub fn parse<'a, I>(mut s: &str, items: I) -> ParseResult<()> + where I: Iterator> { + macro_rules! try_consume { + ($e:expr) => ({ let (s_, v) = try!($e); s = s_; v }) + } + let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space)); + let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space)); + Ok(()) +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.stderr new file mode 100644 index 00000000000..99281e74565 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/chrono-scan.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/chrono-scan.rs:39:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/elision.rs b/src/test/ui/compile-fail-migration/associated-types/cache/elision.rs new file mode 100644 index 00000000000..d1117328c86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/elision.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(warnings)] + +// Check that you are allowed to implement using elision but write +// trait without elision (a bug in this cropped up during +// bootstrapping, so this is a regression test). + +pub struct SplitWhitespace<'a> { + x: &'a u8 +} + +pub trait UnicodeStr { + fn split_whitespace<'a>(&'a self) -> SplitWhitespace<'a>; +} + +impl UnicodeStr for str { + #[inline] + fn split_whitespace(&self) -> SplitWhitespace { + unimplemented!() + } +} + +#[rustc_error] +fn main() { } //~ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/elision.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/elision.stderr new file mode 100644 index 00000000000..c5314b58002 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/elision.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/elision.rs:34:1 + | +LL | fn main() { } //~ ERROR compilation successful + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr new file mode 100644 index 00000000000..89a7bb00f74 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr @@ -0,0 +1,35 @@ +warning: not reporting region error due to nll + --> $DIR/project-fn-ret-contravariant.rs:53:16 + | +LL | let a = bar(foo, y); + | ^^^ + +warning: not reporting region error due to nll + --> $DIR/project-fn-ret-contravariant.rs:54:16 + | +LL | let b = bar(foo, x); + | ^^^ + +error: unsatisfied lifetime constraints + --> $DIR/project-fn-ret-contravariant.rs:53:12 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let a = bar(foo, y); + | ^^^^^^^^^^^ argument requires that `'b` must outlive `'a` + +error: unsatisfied lifetime constraints + --> $DIR/project-fn-ret-contravariant.rs:54:12 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let a = bar(foo, y); +LL | let b = bar(foo, x); + | ^^^^^^^^^^^ argument requires that `'a` must outlive `'b` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr new file mode 100644 index 00000000000..6cecf68ffff --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr @@ -0,0 +1,25 @@ +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-contravariant.rs:55:5 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | ------- ------------------ + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | (a, b) //[krisskross]~ ERROR 55:5: 55:6: lifetime mismatch [E0623] + | ^ ...but data from `y` is returned here + +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-contravariant.rs:55:8 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | ------- ------------------ + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | (a, b) //[krisskross]~ ERROR 55:5: 55:6: lifetime mismatch [E0623] + | ^ ...but data from `x` is returned here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.ok.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.ok.stderr new file mode 100644 index 00000000000..c92aa37a60f --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.ok.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/project-fn-ret-contravariant.rs:60:1 + | +LL | fn main() { } + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr new file mode 100644 index 00000000000..c92aa37a60f --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.oneuse.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/project-fn-ret-contravariant.rs:60:1 + | +LL | fn main() { } + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.rs b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.rs new file mode 100644 index 00000000000..a5e8f4068e6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.rs @@ -0,0 +1,62 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] +#![feature(rustc_attrs)] + +// Test for projection cache. We should be able to project distinct +// lifetimes from `foo` as we reinstantiate it multiple times, but not +// if we do it just once. In this variant, the region `'a` is used in +// an contravariant position, which affects the results. + +// revisions: ok oneuse transmute krisskross + +#![allow(dead_code, unused_variables)] + +fn foo<'a>() -> &'a u32 { loop { } } + +fn bar(t: T, x: T::Output) -> T::Output + where T: FnOnce<()> +{ + t() +} + +#[cfg(ok)] // two instantiations: OK +fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let a = bar(foo, x); + let b = bar(foo, y); + (a, b) +} + +#[cfg(oneuse)] // one instantiation: OK (surprisingly) +fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let f /* : fn() -> &'static u32 */ = foo; // <-- inferred type annotated + let a = bar(f, x); // this is considered ok because fn args are contravariant... + let b = bar(f, y); // ...and hence we infer T to distinct values in each call. + (a, b) +} + +#[cfg(transmute)] // one instantiations: BAD +fn baz<'a,'b>(x: &'a u32) -> &'static u32 { + bar(foo, x) //[transmute]~ ERROR E0495 +} + +#[cfg(krisskross)] // two instantiations, mixing and matching: BAD +fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + let a = bar(foo, y); + let b = bar(foo, x); + (a, b) //[krisskross]~ ERROR 55:5: 55:6: lifetime mismatch [E0623] + //[krisskross]~^ ERROR 55:8: 55:9: lifetime mismatch [E0623] +} + +#[rustc_error] +fn main() { } +//[ok]~^ ERROR compilation successful +//[oneuse]~^^ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr new file mode 100644 index 00000000000..793209b7cbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr @@ -0,0 +1,16 @@ +warning: not reporting region error due to nll + --> $DIR/project-fn-ret-contravariant.rs:48:8 + | +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^^^ + +error: borrowed data escapes outside of function + --> $DIR/project-fn-ret-contravariant.rs:48:4 + | +LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { + | - `x` is a reference that is only valid in the function body +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^^^^^^^^^^^ `x` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.stderr new file mode 100644 index 00000000000..9d42c8e3c63 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-contravariant.transmute.stderr @@ -0,0 +1,26 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/project-fn-ret-contravariant.rs:48:8 + | +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 47:8... + --> $DIR/project-fn-ret-contravariant.rs:47:8 + | +LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/project-fn-ret-contravariant.rs:48:13 + | +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^ + = note: but, the lifetime must be valid for the static lifetime... +note: ...so that reference does not outlive borrowed content + --> $DIR/project-fn-ret-contravariant.rs:48:4 + | +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr new file mode 100644 index 00000000000..dedce312156 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr @@ -0,0 +1,35 @@ +warning: not reporting region error due to nll + --> $DIR/project-fn-ret-invariant.rs:63:16 + | +LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623 + | ^^^ + +warning: not reporting region error due to nll + --> $DIR/project-fn-ret-invariant.rs:64:16 + | +LL | let b = bar(foo, x); + | ^^^ + +error: unsatisfied lifetime constraints + --> $DIR/project-fn-ret-invariant.rs:63:12 + | +LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623 + | ^^^^^^^^^^^ argument requires that `'b` must outlive `'a` + +error: unsatisfied lifetime constraints + --> $DIR/project-fn-ret-invariant.rs:64:12 + | +LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623 +LL | let b = bar(foo, x); + | ^^^^^^^^^^^ argument requires that `'a` must outlive `'b` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.stderr new file mode 100644 index 00000000000..e867ac4baac --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.krisskross.stderr @@ -0,0 +1,24 @@ +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-invariant.rs:63:21 + | +LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | -------- -------------------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623 + | ^ ...but data from `x` is returned here + +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-invariant.rs:65:8 + | +LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | -------- -------------------- + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | (a, b) //[krisskross]~ ERROR E0623 + | ^ ...but data from `x` is returned here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.ok.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.ok.stderr new file mode 100644 index 00000000000..e3e620ea3a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.ok.stderr @@ -0,0 +1,8 @@ +error: compilation successful + --> $DIR/project-fn-ret-invariant.rs:69:1 + | +LL | fn main() { } + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr new file mode 100644 index 00000000000..a669c7ac73b --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr @@ -0,0 +1,30 @@ +warning: not reporting region error due to nll + --> $DIR/project-fn-ret-invariant.rs:47:12 + | +LL | let f = foo; // <-- No consistent type can be inferred for `f` here. + | ^^^ + +error: unsatisfied lifetime constraints + --> $DIR/project-fn-ret-invariant.rs:48:12 + | +LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let f = foo; // <-- No consistent type can be inferred for `f` here. +LL | let a = bar(f, x); + | ^^^^^^^^^ argument requires that `'a` must outlive `'b` + +error: unsatisfied lifetime constraints + --> $DIR/project-fn-ret-invariant.rs:49:12 + | +LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | let b = bar(f, y); //[oneuse]~ ERROR 49:19: 49:20: lifetime mismatch [E0623] + | ^^^^^^^^^ argument requires that `'b` must outlive `'a` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.stderr new file mode 100644 index 00000000000..7c86e20fe64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.oneuse.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/project-fn-ret-invariant.rs:49:19 + | +LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | -------- -------------------- + | | + | this parameter and the return type are declared with different lifetimes... +... +LL | let b = bar(f, y); //[oneuse]~ ERROR 49:19: 49:20: lifetime mismatch [E0623] + | ^ ...but data from `x` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.rs b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.rs new file mode 100644 index 00000000000..6e4bdd4b21c --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.rs @@ -0,0 +1,70 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] +#![feature(rustc_attrs)] + +// Test for projection cache. We should be able to project distinct +// lifetimes from `foo` as we reinstantiate it multiple times, but not +// if we do it just once. In this variant, the region `'a` is used in +// an invariant position, which affects the results. + +// revisions: ok oneuse transmute krisskross + +#![allow(dead_code, unused_variables)] + +use std::marker::PhantomData; + +struct Type<'a> { + // Invariant + data: PhantomData &'a u32> +} + +fn foo<'a>() -> Type<'a> { loop { } } + +fn bar(t: T, x: T::Output) -> T::Output + where T: FnOnce<()> +{ + t() +} + +#[cfg(ok)] // two instantiations: OK +fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let a = bar(foo, x); + let b = bar(foo, y); + (a, b) +} + +#[cfg(oneuse)] // one instantiation: BAD +fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let f = foo; // <-- No consistent type can be inferred for `f` here. + let a = bar(f, x); + let b = bar(f, y); //[oneuse]~ ERROR 49:19: 49:20: lifetime mismatch [E0623] + (a, b) +} + +#[cfg(transmute)] // one instantiations: BAD +fn baz<'a,'b>(x: Type<'a>) -> Type<'static> { + // Cannot instantiate `foo` with any lifetime other than `'a`, + // since it is provided as input. + + bar(foo, x) //[transmute]~ ERROR E0495 +} + +#[cfg(krisskross)] // two instantiations, mixing and matching: BAD +fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + let a = bar(foo, y); //[krisskross]~ ERROR E0623 + let b = bar(foo, x); + (a, b) //[krisskross]~ ERROR E0623 +} + +#[rustc_error] +fn main() { } +//[ok]~^ ERROR compilation successful diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr new file mode 100644 index 00000000000..ed3f2a07aa2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/project-fn-ret-invariant.rs:58:8 + | +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^^^ + +error: borrowed data escapes outside of function + --> $DIR/project-fn-ret-invariant.rs:58:4 + | +LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> { + | - `x` is a reference that is only valid in the function body +... +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^^^^^^^^^^^ `x` escapes the function body here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.stderr b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.stderr new file mode 100644 index 00000000000..6432ab9e57d --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/cache/project-fn-ret-invariant.transmute.stderr @@ -0,0 +1,22 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/project-fn-ret-invariant.rs:58:8 + | +LL | bar(foo, x) //[transmute]~ ERROR E0495 + | ^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 54:8... + --> $DIR/project-fn-ret-invariant.rs:54:8 + | +LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> { + | ^^ + = note: ...so that the expression is assignable: + expected Type<'_> + found Type<'a> + = note: but, the lifetime must be valid for the static lifetime... + = note: ...so that the expression is assignable: + expected Type<'static> + found Type<'_> + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.bad.stderr b/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.bad.stderr new file mode 100644 index 00000000000..1351d14fe00 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.bad.stderr @@ -0,0 +1,17 @@ +error[E0271]: type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _` + --> $DIR/higher-ranked-projection.rs:35:5 + | +LL | foo(()); + | ^^^ expected bound lifetime parameter 'a, found concrete lifetime + | +note: required by `foo` + --> $DIR/higher-ranked-projection.rs:24:1 + | +LL | / fn foo(_t: T) +LL | | where for<'a> &'a T: Mirror +LL | | {} + | |__^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.good.stderr b/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.good.stderr new file mode 100644 index 00000000000..861827f329b --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.good.stderr @@ -0,0 +1,12 @@ +error: compilation successful + --> $DIR/higher-ranked-projection.rs:34:1 + | +LL | / fn main() { //[good]~ ERROR compilation successful +LL | | foo(()); +LL | | //[bad]~^ ERROR type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _` +LL | | //[bad]~| expected bound lifetime parameter 'a, found concrete lifetime +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.rs b/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.rs new file mode 100644 index 00000000000..12341fa8db3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/higher-ranked-projection.rs @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +// revisions: good bad + +trait Mirror { + type Image; +} + +impl Mirror for T { + type Image = T; +} + +#[cfg(bad)] +fn foo(_t: T) + where for<'a> &'a T: Mirror +{} + +#[cfg(good)] +fn foo(_t: T) + where for<'a> &'a T: Mirror +{} + +#[rustc_error] +fn main() { //[good]~ ERROR compilation successful + foo(()); + //[bad]~^ ERROR type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _` + //[bad]~| expected bound lifetime parameter 'a, found concrete lifetime +} diff --git a/src/test/ui/compile-fail-migration/associated-types/issue-36499.rs b/src/test/ui/compile-fail-migration/associated-types/issue-36499.rs new file mode 100644 index 00000000000..b5b3ecbb580 --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/issue-36499.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: aborting due to previous error + +fn main() { + 2 + +2; +} diff --git a/src/test/ui/compile-fail-migration/associated-types/issue-36499.stderr b/src/test/ui/compile-fail-migration/associated-types/issue-36499.stderr new file mode 100644 index 00000000000..5167c47a6cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/associated-types/issue-36499.stderr @@ -0,0 +1,8 @@ +error: expected expression, found `+` + --> $DIR/issue-36499.rs:14:9 + | +LL | 2 + +2; + | ^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/attempted-access-non-fatal.rs b/src/test/ui/compile-fail-migration/attempted-access-non-fatal.rs new file mode 100644 index 00000000000..3d6c46f5ce3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/attempted-access-non-fatal.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that bogus field access is non-fatal +fn main() { + let x = 0; + let _ = x.foo; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610] + let _ = x.bar; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610] +} diff --git a/src/test/ui/compile-fail-migration/attempted-access-non-fatal.stderr b/src/test/ui/compile-fail-migration/attempted-access-non-fatal.stderr new file mode 100644 index 00000000000..d056a3eff6f --- /dev/null +++ b/src/test/ui/compile-fail-migration/attempted-access-non-fatal.stderr @@ -0,0 +1,15 @@ +error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields + --> $DIR/attempted-access-non-fatal.rs:14:15 + | +LL | let _ = x.foo; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610] + | ^^^ + +error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields + --> $DIR/attempted-access-non-fatal.rs:15:15 + | +LL | let _ = x.bar; //~ `{integer}` is a primitive type and therefore doesn't have fields [E0610] + | ^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0610`. diff --git a/src/test/ui/compile-fail-migration/attr-bad-crate-attr.rc b/src/test/ui/compile-fail-migration/attr-bad-crate-attr.rc new file mode 100644 index 00000000000..4ab07f4fa99 --- /dev/null +++ b/src/test/ui/compile-fail-migration/attr-bad-crate-attr.rc @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: expected item + +#![attr = "val"] +#[attr = "val"] // Unterminated diff --git a/src/test/ui/compile-fail-migration/attr-usage-inline.rs b/src/test/ui/compile-fail-migration/attr-usage-inline.rs new file mode 100644 index 00000000000..250905dbdcd --- /dev/null +++ b/src/test/ui/compile-fail-migration/attr-usage-inline.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] + +#[inline] +fn f() {} + +#[inline] //~ ERROR: attribute should be applied to function or closure +struct S; + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/attr-usage-inline.stderr b/src/test/ui/compile-fail-migration/attr-usage-inline.stderr new file mode 100644 index 00000000000..171bd949e10 --- /dev/null +++ b/src/test/ui/compile-fail-migration/attr-usage-inline.stderr @@ -0,0 +1,11 @@ +error[E0518]: attribute should be applied to function or closure + --> $DIR/attr-usage-inline.rs:16:1 + | +LL | #[inline] //~ ERROR: attribute should be applied to function or closure + | ^^^^^^^^^ +LL | struct S; + | --------- not a function or closure + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0518`. diff --git a/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.rs b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.rs new file mode 100644 index 00000000000..ec7885f1f44 --- /dev/null +++ b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test checks variations on `<#[attr] 'a, #[oops]>`, where +// `#[oops]` is left dangling (that is, it is unattached, with no +// formal binding following it). + +#![feature(rustc_attrs)] + +struct RefIntPair<'a, 'b>(&'a u32, &'b u32); + +impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { + //~^ ERROR trailing attribute after lifetime parameters +} + +fn main() { + +} diff --git a/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.stderr b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.stderr new file mode 100644 index 00000000000..afab999b02e --- /dev/null +++ b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-1.stderr @@ -0,0 +1,8 @@ +error: trailing attribute after lifetime parameters + --> $DIR/attrs-with-no-formal-in-generics-1.rs:19:25 + | +LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> { + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.rs b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.rs new file mode 100644 index 00000000000..efe2d5561a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test checks variations on `<#[attr] 'a, #[oops]>`, where +// `#[oops]` is left dangling (that is, it is unattached, with no +// formal binding following it). + +#![feature(rustc_attrs)] + +struct RefAny<'a, T>(&'a T); + +impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} +//~^ ERROR trailing attribute after type parameters + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.stderr b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.stderr new file mode 100644 index 00000000000..8bff45ea989 --- /dev/null +++ b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-2.stderr @@ -0,0 +1,8 @@ +error: trailing attribute after type parameters + --> $DIR/attrs-with-no-formal-in-generics-2.rs:19:35 + | +LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {} + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.rs b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.rs new file mode 100644 index 00000000000..e7d5b94d242 --- /dev/null +++ b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test checks variations on `<#[attr] 'a, #[oops]>`, where +// `#[oops]` is left dangling (that is, it is unattached, with no +// formal binding following it). + +struct RefIntPair<'a, 'b>(&'a u32, &'b u32); + +fn hof_lt(_: Q) + where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32 + //~^ ERROR trailing attribute after lifetime parameters +{ + +} + +fn main() { + +} diff --git a/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.stderr b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.stderr new file mode 100644 index 00000000000..351c788f84f --- /dev/null +++ b/src/test/ui/compile-fail-migration/attrs-with-no-formal-in-generics-3.stderr @@ -0,0 +1,8 @@ +error: trailing attribute after lifetime parameters + --> $DIR/attrs-with-no-formal-in-generics-3.rs:18:38 + | +LL | where Q: for <#[rustc_1] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32 + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.rs b/src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.rs new file mode 100644 index 00000000000..324e9259647 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.rs @@ -0,0 +1,38 @@ +// Copyright 2012-14 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn main() { + + // Testing that method lookup does not automatically borrow + // vectors to slices then automatically create a self reference. + + let mut a = vec![0]; + a.test_mut(); //~ ERROR no method named `test_mut` found + a.test(); //~ ERROR no method named `test` found + + ([1]).test(); //~ ERROR no method named `test` found + (&[1]).test(); //~ ERROR no method named `test` found +} + +trait MyIter { + fn test_mut(&mut self); + fn test(&self); +} + +impl<'a> MyIter for &'a [isize] { + fn test_mut(&mut self) { } + fn test(&self) { } +} + +impl<'a> MyIter for &'a str { + fn test_mut(&mut self) { } + fn test(&self) { } +} diff --git a/src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.stderr b/src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.stderr new file mode 100644 index 00000000000..f62ac84a185 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auto-ref-slice-plus-ref.stderr @@ -0,0 +1,44 @@ +error[E0599]: no method named `test_mut` found for type `std::vec::Vec<{integer}>` in the current scope + --> $DIR/auto-ref-slice-plus-ref.rs:18:7 + | +LL | a.test_mut(); //~ ERROR no method named `test_mut` found + | ^^^^^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `test_mut`, perhaps you need to implement it: + candidate #1: `MyIter` + = help: did you mean `get_mut`? + +error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` in the current scope + --> $DIR/auto-ref-slice-plus-ref.rs:19:7 + | +LL | a.test(); //~ ERROR no method named `test` found + | ^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `test`, perhaps you need to implement it: + candidate #1: `MyIter` + +error[E0599]: no method named `test` found for type `[{integer}; 1]` in the current scope + --> $DIR/auto-ref-slice-plus-ref.rs:21:11 + | +LL | ([1]).test(); //~ ERROR no method named `test` found + | ^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `test`, perhaps you need to implement it: + candidate #1: `MyIter` + +error[E0599]: no method named `test` found for type `&[{integer}; 1]` in the current scope + --> $DIR/auto-ref-slice-plus-ref.rs:22:12 + | +LL | (&[1]).test(); //~ ERROR no method named `test` found + | ^^^^ + | + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `test`, perhaps you need to implement it: + candidate #1: `MyIter` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/auto-trait-validation.rs b/src/test/ui/compile-fail-migration/auto-trait-validation.rs new file mode 100644 index 00000000000..92b222e1322 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auto-trait-validation.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +auto trait Generic {} +//~^ auto traits cannot have generic parameters [E0567] +auto trait Bound : Copy {} +//~^ auto traits cannot have super traits [E0568] +auto trait MyTrait { fn foo() {} } +//~^ auto traits cannot have methods or associated items [E0380] +fn main() {} diff --git a/src/test/ui/compile-fail-migration/auto-trait-validation.stderr b/src/test/ui/compile-fail-migration/auto-trait-validation.stderr new file mode 100644 index 00000000000..a6bd887021e --- /dev/null +++ b/src/test/ui/compile-fail-migration/auto-trait-validation.stderr @@ -0,0 +1,22 @@ +error[E0567]: auto traits cannot have generic parameters + --> $DIR/auto-trait-validation.rs:13:1 + | +LL | auto trait Generic {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0568]: auto traits cannot have super traits + --> $DIR/auto-trait-validation.rs:15:1 + | +LL | auto trait Bound : Copy {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0380]: auto traits cannot have methods or associated items + --> $DIR/auto-trait-validation.rs:17:1 + | +LL | auto trait MyTrait { fn foo() {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0380, E0567, E0568. +For more information about an error, try `rustc --explain E0380`. diff --git a/src/test/ui/compile-fail-migration/autoderef-full-lval.rs b/src/test/ui/compile-fail-migration/autoderef-full-lval.rs new file mode 100644 index 00000000000..c152fdd9296 --- /dev/null +++ b/src/test/ui/compile-fail-migration/autoderef-full-lval.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct clam { + x: Box, + y: Box, +} + +struct fish { + a: Box, +} + +fn main() { + let a: clam = clam{x: box 1, y: box 2}; + let b: clam = clam{x: box 10, y: box 20}; + let z: isize = a.x + b.y; + //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box` + println!("{}", z); + assert_eq!(z, 21); + let forty: fish = fish{a: box 40}; + let two: fish = fish{a: box 2}; + let answer: isize = forty.a + two.a; + //~^ ERROR binary operation `+` cannot be applied to type `std::boxed::Box` + println!("{}", answer); + assert_eq!(answer, 42); +} diff --git a/src/test/ui/compile-fail-migration/autoderef-full-lval.stderr b/src/test/ui/compile-fail-migration/autoderef-full-lval.stderr new file mode 100644 index 00000000000..df8eeb5d171 --- /dev/null +++ b/src/test/ui/compile-fail-migration/autoderef-full-lval.stderr @@ -0,0 +1,19 @@ +error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` + --> $DIR/autoderef-full-lval.rs:25:20 + | +LL | let z: isize = a.x + b.y; + | ^^^^^^^^^ + | + = note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box` + +error[E0369]: binary operation `+` cannot be applied to type `std::boxed::Box` + --> $DIR/autoderef-full-lval.rs:31:25 + | +LL | let answer: isize = forty.a + two.a; + | ^^^^^^^^^^^^^^^ + | + = note: an implementation of `std::ops::Add` might be missing for `std::boxed::Box` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/auxiliary/ambig_impl_2_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/ambig_impl_2_lib.rs new file mode 100644 index 00000000000..4ba0ccdba9b --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/ambig_impl_2_lib.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait me { + fn me(&self) -> usize; +} +impl me for usize { fn me(&self) -> usize { *self } } diff --git a/src/test/ui/compile-fail-migration/auxiliary/cci_class.rs b/src/test/ui/compile-fail-migration/auxiliary/cci_class.rs new file mode 100644 index 00000000000..08a13fd8bcc --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/cci_class.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/cci_class_5.rs b/src/test/ui/compile-fail-migration/auxiliary/cci_class_5.rs new file mode 100644 index 00000000000..7fe608f1634 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/cci_class_5.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitties { + pub struct cat { + meows : usize, + pub how_hungry : isize, + } + + impl cat { + fn nap(&self) {} + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/cdylib-dep.rs b/src/test/ui/compile-fail-migration/auxiliary/cdylib-dep.rs new file mode 100644 index 00000000000..a3d0222a14c --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/cdylib-dep.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] diff --git a/src/test/ui/compile-fail-migration/auxiliary/coherence_copy_like_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/coherence_copy_like_lib.rs new file mode 100644 index 00000000000..d3d389c6a8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/coherence_copy_like_lib.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(fundamental)] + +pub trait MyCopy { } +impl MyCopy for i32 { } + +pub struct MyStruct(T); + +#[fundamental] +pub struct MyFundamentalStruct(T); diff --git a/src/test/ui/compile-fail-migration/auxiliary/coherence_inherent_cc_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/coherence_inherent_cc_lib.rs new file mode 100644 index 00000000000..0458636a401 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/coherence_inherent_cc_lib.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// See coherence_inherent_cc.rs + +pub trait TheTrait { + fn the_fn(&self); +} + +pub struct TheStruct; + +impl TheTrait for TheStruct { + fn the_fn(&self) {} +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/coherence_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/coherence_lib.rs new file mode 100644 index 00000000000..daa123849e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/coherence_lib.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub trait Remote { + fn foo(&self) { } +} + +pub trait Remote1 { + fn foo(&self, t: T) { } +} + +pub trait Remote2 { + fn foo(&self, t: T, u: U) { } +} + +pub struct Pair(T,U); diff --git a/src/test/ui/compile-fail-migration/auxiliary/coherence_orphan_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/coherence_orphan_lib.rs new file mode 100644 index 00000000000..b22d12300c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/coherence_orphan_lib.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait TheTrait { + fn the_fn(&self); +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/const_fn_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/const_fn_lib.rs new file mode 100644 index 00000000000..b0d5a6b1272 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/const_fn_lib.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Crate that exports a const fn. Used for testing cross-crate. + +#![crate_type="rlib"] +#![feature(const_fn)] + +pub const fn foo() -> usize { 22 } //~ ERROR const fn is unstable diff --git a/src/test/ui/compile-fail-migration/auxiliary/crate_a1.rs b/src/test/ui/compile-fail-migration/auxiliary/crate_a1.rs new file mode 100644 index 00000000000..70f7cac94de --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/crate_a1.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo; + +pub trait Bar{} + +pub fn bar() -> Box { + unimplemented!() +} + + +pub fn try_foo(x: Foo){} +pub fn try_bar(x: Box){} diff --git a/src/test/ui/compile-fail-migration/auxiliary/crate_a2.rs b/src/test/ui/compile-fail-migration/auxiliary/crate_a2.rs new file mode 100644 index 00000000000..d801f25ba2e --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/crate_a2.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo; + +pub trait Bar{} + +pub fn bar() -> Box { + unimplemented!() +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-1.rs b/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-1.rs new file mode 100644 index 00000000000..050f2fe7329 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-1.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C extra-filename=-1 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 10 } diff --git a/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-2.rs b/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-2.rs new file mode 100644 index 00000000000..d19b3bafba5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-2.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C extra-filename=-2 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 20 } diff --git a/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-3.rs b/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-3.rs new file mode 100644 index 00000000000..c5096ac49a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/crateresolve1-3.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C extra-filename=-3 +#![crate_name = "crateresolve1"] +#![crate_type = "lib"] + +pub fn f() -> isize { 30 } diff --git a/src/test/ui/compile-fail-migration/auxiliary/default_ty_param_cross_crate_crate.rs b/src/test/ui/compile-fail-migration/auxiliary/default_ty_param_cross_crate_crate.rs new file mode 100644 index 00000000000..4bd8ecacb96 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/default_ty_param_cross_crate_crate.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![crate_name = "default_param_test"] +#![feature(default_type_parameter_fallback)] + +use std::marker::PhantomData; + +pub struct Foo(PhantomData<(A, B)>); + +pub fn bleh() -> Foo { Foo(PhantomData) } + diff --git a/src/test/ui/compile-fail-migration/auxiliary/define_macro.rs b/src/test/ui/compile-fail-migration/auxiliary/define_macro.rs new file mode 100644 index 00000000000..6b6b14a896b --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/define_macro.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_export] +macro_rules! define_macro { + ($i:ident) => { + macro_rules! $i { () => {} } + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/deprecation-lint.rs b/src/test/ui/compile-fail-migration/auxiliary/deprecation-lint.rs new file mode 100644 index 00000000000..17510289875 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/deprecation-lint.rs @@ -0,0 +1,108 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(deprecated)] + +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated() {} +#[deprecated(since = "1.0.0", note = "text")] +pub fn deprecated_text() {} + +pub struct MethodTester; + +impl MethodTester { + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated(&self) {} + #[deprecated(since = "1.0.0", note = "text")] + pub fn method_deprecated_text(&self) {} +} + +pub trait Trait { + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated(&self) {} + #[deprecated(since = "1.0.0", note = "text")] + fn trait_deprecated_text(&self) {} +} + +#[deprecated(since = "1.0.0", note = "text")] +pub trait DeprecatedTrait { fn dummy(&self) { } } + +impl Trait for MethodTester {} + +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedStruct { + pub i: isize +} + +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedUnitStruct; + +pub enum Enum { + #[deprecated(since = "1.0.0", note = "text")] + DeprecatedVariant, +} + +#[deprecated(since = "1.0.0", note = "text")] +pub struct DeprecatedTupleStruct(pub isize); + +pub mod nested { + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedStruct { + pub i: isize + } + + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedUnitStruct; + + pub enum Enum { + #[deprecated(since = "1.0.0", note = "text")] + DeprecatedVariant, + } + + #[deprecated(since = "1.0.0", note = "text")] + pub struct DeprecatedTupleStruct(pub isize); +} + +pub struct Stable { + #[deprecated(since = "1.0.0", note = "text")] + pub override2: u8, +} + +pub struct Stable2(pub u8, pub u8, #[deprecated(since = "1.0.0", note = "text")] pub u8); + +#[deprecated(since = "1.0.0", note = "text")] +pub struct Deprecated { + pub inherit: u8, +} + +#[deprecated(since = "1.0.0", note = "text")] +pub struct Deprecated2(pub u8, + pub u8, + pub u8); + +#[deprecated(since = "1.0.0", note = "text")] +pub mod deprecated_mod { + pub fn deprecated() {} +} + +#[macro_export] +macro_rules! macro_test { + () => (deprecated()); +} + +#[macro_export] +macro_rules! macro_test_arg { + ($func:expr) => ($func); +} + +#[macro_export] +macro_rules! macro_test_arg_nested { + ($func:ident) => (macro_test_arg!($func())); +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/edition-extern-crate-allowed.rs b/src/test/ui/compile-fail-migration/auxiliary/edition-extern-crate-allowed.rs new file mode 100644 index 00000000000..d26ab6d3518 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/edition-extern-crate-allowed.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// intentionally empty diff --git a/src/test/ui/compile-fail-migration/auxiliary/empty-struct.rs b/src/test/ui/compile-fail-migration/auxiliary/empty-struct.rs new file mode 100644 index 00000000000..4a302865634 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/empty-struct.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct XEmpty1 {} +pub struct XEmpty2; +pub struct XEmpty6(); + +pub enum XE { + XEmpty3 {}, + XEmpty4, + XEmpty5(), +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/extern-statics.rs b/src/test/ui/compile-fail-migration/auxiliary/extern-statics.rs new file mode 100644 index 00000000000..07f70b177b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/extern-statics.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + pub static XA: u8; + pub static mut XB: u8; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/go_trait.rs b/src/test/ui/compile-fail-migration/auxiliary/go_trait.rs new file mode 100644 index 00000000000..044bb606b40 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/go_trait.rs @@ -0,0 +1,53 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. + +pub trait Go { + fn go(&self, arg: isize); +} + +pub fn go(this: &G, arg: isize) { + this.go(arg) +} + +pub trait GoMut { + fn go_mut(&mut self, arg: isize); +} + +pub fn go_mut(this: &mut G, arg: isize) { + this.go_mut(arg) +} + +pub trait GoOnce { + fn go_once(self, arg: isize); +} + +pub fn go_once(this: G, arg: isize) { + this.go_once(arg) +} + +impl GoMut for G + where G : Go +{ + default fn go_mut(&mut self, arg: isize) { + go(&*self, arg) + } +} + +impl GoOnce for G + where G : GoMut +{ + default fn go_once(mut self, arg: isize) { + go_mut(&mut self, arg) + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/import_crate_var.rs b/src/test/ui/compile-fail-migration/auxiliary/import_crate_var.rs new file mode 100644 index 00000000000..a8a55afa41a --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/import_crate_var.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn f() {} + +#[macro_export] +macro_rules! m { () => { + use $crate; + import_crate_var::f(); +} } diff --git a/src/test/ui/compile-fail-migration/auxiliary/inherited_stability.rs b/src/test/ui/compile-fail-migration/auxiliary/inherited_stability.rs new file mode 100644 index 00000000000..f690cbd029d --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/inherited_stability.rs @@ -0,0 +1,56 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![crate_name="inherited_stability"] +#![crate_type = "lib"] +#![unstable(feature = "unstable_test_feature", issue = "0")] +#![feature(staged_api)] + +pub fn unstable() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub fn stable() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub mod stable_mod { + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn unstable() {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn stable() {} +} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub mod unstable_mod { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn deprecated() {} + + pub fn unstable() {} +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub trait Stable { + #[unstable(feature = "unstable_test_feature", issue = "0")] + fn unstable(&self); + + #[stable(feature = "rust1", since = "1.0.0")] + fn stable(&self); +} + +impl Stable for usize { + fn unstable(&self) {} + fn stable(&self) {} +} + +pub enum Unstable { + UnstableVariant, + #[stable(feature = "rust1", since = "1.0.0")] + StableVariant +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/internal_unstable.rs b/src/test/ui/compile-fail-migration/auxiliary/internal_unstable.rs new file mode 100644 index 00000000000..a4cd487eb65 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/internal_unstable.rs @@ -0,0 +1,102 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(staged_api, allow_internal_unstable)] +#![stable(feature = "stable", since = "1.0.0")] + +#[unstable(feature = "function", issue = "0")] +pub fn unstable() {} + + +#[stable(feature = "stable", since = "1.0.0")] +pub struct Foo { + #[unstable(feature = "struct_field", issue = "0")] + pub x: u8 +} + +impl Foo { + #[unstable(feature = "method", issue = "0")] + pub fn method(&self) {} +} + +#[stable(feature = "stable", since = "1.0.0")] +pub struct Bar { + #[unstable(feature = "struct2_field", issue = "0")] + pub x: u8 +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! call_unstable_allow { + () => { $crate::unstable() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! construct_unstable_allow { + ($e: expr) => { + $crate::Foo { x: $e } + } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! call_method_allow { + ($e: expr) => { $e.method() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! access_field_allow { + ($e: expr) => { $e.x } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[allow_internal_unstable] +#[macro_export] +macro_rules! pass_through_allow { + ($e: expr) => { $e } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! call_unstable_noallow { + () => { $crate::unstable() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! construct_unstable_noallow { + ($e: expr) => { + $crate::Foo { x: $e } + } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! call_method_noallow { + ($e: expr) => { $e.method() } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! access_field_noallow { + ($e: expr) => { $e.x } +} + +#[stable(feature = "stable", since = "1.0.0")] +#[macro_export] +macro_rules! pass_through_noallow { + ($e: expr) => { $e } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue-19163.rs b/src/test/ui/compile-fail-migration/auxiliary/issue-19163.rs new file mode 100644 index 00000000000..76c5cdafd7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue-19163.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[macro_export] +macro_rules! mywrite { + ($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*))) +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue-21146-inc.rs b/src/test/ui/compile-fail-migration/auxiliary/issue-21146-inc.rs new file mode 100644 index 00000000000..1b740d112e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue-21146-inc.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// include file for issue-21146.rs + +parse_error diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue-29181.rs b/src/test/ui/compile-fail-migration/auxiliary/issue-29181.rs new file mode 100644 index 00000000000..361f1ea5509 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue-29181.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub mod foo { + pub use super::*; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue-30535.rs b/src/test/ui/compile-fail-migration/auxiliary/issue-30535.rs new file mode 100644 index 00000000000..8d44e8d1016 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue-30535.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub enum Foo { + FooV { data: () } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue-36881-aux.rs b/src/test/ui/compile-fail-migration/auxiliary/issue-36881-aux.rs new file mode 100644 index 00000000000..33ac11feb2d --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue-36881-aux.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue-52489.rs b/src/test/ui/compile-fail-migration/auxiliary/issue-52489.rs new file mode 100644 index 00000000000..68d1ef8d776 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue-52489.rs @@ -0,0 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![unstable(feature = "issue_52489_unstable", issue = "0")] +#![feature(staged_api)] diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_11680.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_11680.rs new file mode 100644 index 00000000000..18f78750b15 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_11680.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Foo { + Bar(isize) +} + +pub mod test { + enum Foo { + Bar(isize) + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_16725.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_16725.rs new file mode 100644 index 00000000000..b3b04b4a5ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_16725.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn bar(); +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_17718_const_privacy.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_17718_const_privacy.rs new file mode 100644 index 00000000000..3901d73382f --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_17718_const_privacy.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use foo::FOO2; + +pub const FOO: usize = 3; +const BAR: usize = 3; + +mod foo { + pub const FOO2: usize = 3; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_1920.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_1920.rs new file mode 100644 index 00000000000..55065174ca7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_1920.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Just exporting some type to test for correct diagnostics when this +// crate is pulled in at a non-root location in client crate. + +pub struct S; diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_21202.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_21202.rs new file mode 100644 index 00000000000..afdbf78aa82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_21202.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod A { + pub struct Foo; + impl Foo { + fn foo(&self) { } + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_30123_aux.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_30123_aux.rs new file mode 100644 index 00000000000..f60311a9400 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_30123_aux.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker::PhantomData; + +pub struct Directed; +pub struct Undirected; + +pub struct Graph { + nodes: Vec>, + edges: Vec>, + ty: PhantomData, +} + + +impl Graph { + pub fn new() -> Self { + Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData} + } +} + +impl Graph { + pub fn new_undirected() -> Self { + Graph{nodes: Vec::new(), edges: Vec::new(), ty: PhantomData} + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_41549.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_41549.rs new file mode 100644 index 00000000000..5a6db789282 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_41549.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub trait Trait { + const CONST: u32; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/issue_5844_aux.rs b/src/test/ui/compile-fail-migration/auxiliary/issue_5844_aux.rs new file mode 100644 index 00000000000..7fa937e93b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/issue_5844_aux.rs @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern "C" { + pub fn rand() -> u32; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lifetime_bound_will_change_warning_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/lifetime_bound_will_change_warning_lib.rs new file mode 100644 index 00000000000..95f8b39c487 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lifetime_bound_will_change_warning_lib.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +// Helper for testing that we get suitable warnings when lifetime +// bound change will cause breakage. + +pub fn just_ref(x: &Fn()) { +} + +pub fn ref_obj(x: &Box) { + // this will change to &Box... +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_output_format.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_output_format.rs new file mode 100644 index 00000000000..6ba66f3e45f --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_output_format.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="lint_output_format"] +#![crate_type = "lib"] +#![feature(staged_api)] +#![unstable(feature = "unstable_test_feature", issue = "0")] + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub fn foo() -> usize { + 20 +} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub fn bar() -> usize { + 40 +} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub fn baz() -> usize { + 30 +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_stability.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_stability.rs new file mode 100644 index 00000000000..5547458abbe --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_stability.rs @@ -0,0 +1,198 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="lint_stability"] +#![crate_type = "lib"] +#![feature(staged_api)] +#![feature(associated_type_defaults)] +#![stable(feature = "lint_stability", since = "1.0.0")] + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub fn deprecated() {} +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub fn deprecated_text() {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "99.99.99", reason = "text")] +pub fn deprecated_future() {} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub fn deprecated_unstable() {} +#[unstable(feature = "unstable_test_feature", issue = "0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub fn deprecated_unstable_text() {} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub fn unstable() {} +#[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] +pub fn unstable_text() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub fn stable() {} +#[stable(feature = "rust1", since = "1.0.0")] +pub fn stable_text() {} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct MethodTester; + +impl MethodTester { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated(&self) {} + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + pub fn method_deprecated_unstable_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub fn method_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + pub fn method_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + pub fn method_stable_text(&self) {} +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait Trait { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated(&self) {} + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + fn trait_deprecated_unstable_text(&self) {} + + #[unstable(feature = "unstable_test_feature", issue = "0")] + fn trait_unstable(&self) {} + #[unstable(feature = "unstable_test_feature", reason = "text", issue = "0")] + fn trait_unstable_text(&self) {} + + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable(&self) {} + #[stable(feature = "rust1", since = "1.0.0")] + fn trait_stable_text(&self) {} +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub trait TraitWithAssociatedTypes { + #[unstable(feature = "unstable_test_feature", issue = "0")] + type TypeUnstable = u8; + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + type TypeDeprecated = u8; +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +impl Trait for MethodTester {} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub trait UnstableTrait { fn dummy(&self) { } } + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub trait DeprecatedTrait { + #[stable(feature = "stable_test_feature", since = "1.0.0")] fn dummy(&self) { } +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct DeprecatedStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[unstable(feature = "unstable_test_feature", issue = "0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct DeprecatedUnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub struct UnstableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[stable(feature = "rust1", since = "1.0.0")] +pub struct StableStruct { + #[stable(feature = "stable_test_feature", since = "1.0.0")] pub i: isize +} +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub enum UnstableEnum {} +#[stable(feature = "rust1", since = "1.0.0")] +pub enum StableEnum {} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct DeprecatedUnitStruct; +#[unstable(feature = "unstable_test_feature", issue = "0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct DeprecatedUnstableUnitStruct; +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub struct UnstableUnitStruct; +#[stable(feature = "rust1", since = "1.0.0")] +pub struct StableUnitStruct; + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +pub enum Enum { + #[stable(feature = "stable_test_feature", since = "1.0.0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + DeprecatedVariant, + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] + DeprecatedUnstableVariant, + #[unstable(feature = "unstable_test_feature", issue = "0")] + UnstableVariant, + + #[stable(feature = "rust1", since = "1.0.0")] + StableVariant, +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct DeprecatedTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); +#[unstable(feature = "unstable_test_feature", issue = "0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct DeprecatedUnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub struct UnstableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); +#[stable(feature = "rust1", since = "1.0.0")] +pub struct StableTupleStruct(#[stable(feature = "rust1", since = "1.0.0")] pub isize); + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[macro_export] +macro_rules! macro_test { + () => (deprecated()); +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[macro_export] +macro_rules! macro_test_arg { + ($func:expr) => ($func); +} + +#[stable(feature = "stable_test_feature", since = "1.0.0")] +#[macro_export] +macro_rules! macro_test_arg_nested { + ($func:ident) => (macro_test_arg!($func())); +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_stability_fields.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_stability_fields.rs new file mode 100644 index 00000000000..6b79c36fc05 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_stability_fields.rs @@ -0,0 +1,61 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(staged_api)] +#![stable(feature = "rust1", since = "1.0.0")] + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Stable { + #[stable(feature = "rust1", since = "1.0.0")] + pub inherit: u8, // it's a lie (stable doesn't inherit) + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub override1: u8, + #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub override2: u8, +} + +#[stable(feature = "rust1", since = "1.0.0")] +pub struct Stable2(#[stable(feature = "rust1", since = "1.0.0")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8); + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub struct Unstable { + pub inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + pub override1: u8, + #[rustc_deprecated(since = "1.0.0", reason = "text")] + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub override2: u8, +} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +pub struct Unstable2(pub u8, + #[stable(feature = "rust1", since = "1.0.0")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + #[rustc_deprecated(since = "1.0.0", reason = "text")] pub u8); + +#[unstable(feature = "unstable_test_feature", issue = "0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct Deprecated { + pub inherit: u8, + #[stable(feature = "rust1", since = "1.0.0")] + pub override1: u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] + pub override2: u8, +} + +#[unstable(feature = "unstable_test_feature", issue = "0")] +#[rustc_deprecated(since = "1.0.0", reason = "text")] +pub struct Deprecated2(pub u8, + #[stable(feature = "rust1", since = "1.0.0")] pub u8, + #[unstable(feature = "unstable_test_feature", issue = "0")] pub u8); diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate.rs new file mode 100644 index 00000000000..2661b1f4eb4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate2.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate2.rs new file mode 100644 index 00000000000..b61667cfd88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate2.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate3.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate3.rs new file mode 100644 index 00000000000..b61667cfd88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate3.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate4.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate4.rs new file mode 100644 index 00000000000..fc4bca865c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate4.rs @@ -0,0 +1,9 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate5.rs b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate5.rs new file mode 100644 index 00000000000..fc4bca865c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lint_unused_extern_crate5.rs @@ -0,0 +1,9 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols1.rs b/src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols1.rs new file mode 100644 index 00000000000..ea09327bd19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols1.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +#[no_mangle] +pub extern fn foo() {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols2.rs b/src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols2.rs new file mode 100644 index 00000000000..ea09327bd19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/lto-duplicate-symbols2.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +#[no_mangle] +pub extern fn foo() {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/macro_crate_nonterminal.rs b/src/test/ui/compile-fail-migration/auxiliary/macro_crate_nonterminal.rs new file mode 100644 index 00000000000..4f75e2b5d75 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/macro_crate_nonterminal.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn increment(x: usize) -> usize { + x + 1 +} + +#[macro_export] +macro_rules! increment { + ($x:expr) => ($crate::increment($x)) +} + +pub fn check_local() { + assert_eq!(increment!(3), 4); +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/namespace-mix.rs b/src/test/ui/compile-fail-migration/auxiliary/namespace-mix.rs new file mode 100644 index 00000000000..d82e9bb7022 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/namespace-mix.rs @@ -0,0 +1,76 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod c { + pub struct S {} + pub struct TS(); + pub struct US; + pub enum E { + V {}, + TV(), + UV, + } + + pub struct Item; +} + +pub mod xm1 { + pub use ::c::*; + pub type S = ::c::Item; +} +pub mod xm2 { + pub use ::c::*; + pub const S: ::c::Item = ::c::Item; +} + +pub mod xm3 { + pub use ::c::*; + pub type TS = ::c::Item; +} +pub mod xm4 { + pub use ::c::*; + pub const TS: ::c::Item = ::c::Item; +} + +pub mod xm5 { + pub use ::c::*; + pub type US = ::c::Item; +} +pub mod xm6 { + pub use ::c::*; + pub const US: ::c::Item = ::c::Item; +} + +pub mod xm7 { + pub use ::c::E::*; + pub type V = ::c::Item; +} +pub mod xm8 { + pub use ::c::E::*; + pub const V: ::c::Item = ::c::Item; +} + +pub mod xm9 { + pub use ::c::E::*; + pub type TV = ::c::Item; +} +pub mod xmA { + pub use ::c::E::*; + pub const TV: ::c::Item = ::c::Item; +} + +pub mod xmB { + pub use ::c::E::*; + pub type UV = ::c::Item; +} +pub mod xmC { + pub use ::c::E::*; + pub const UV: ::c::Item = ::c::Item; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/namespaced_enums.rs b/src/test/ui/compile-fail-migration/auxiliary/namespaced_enums.rs new file mode 100644 index 00000000000..3bf39b788db --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/namespaced_enums.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} + pub fn bar(&self) {} +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/noexporttypelib.rs b/src/test/ui/compile-fail-migration/auxiliary/noexporttypelib.rs new file mode 100644 index 00000000000..5ae8e0d298e --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/noexporttypelib.rs @@ -0,0 +1,12 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub type oint = Option; +pub fn foo() -> oint { Some(3) } diff --git a/src/test/ui/compile-fail-migration/auxiliary/orphan_check_diagnostics.rs b/src/test/ui/compile-fail-migration/auxiliary/orphan_check_diagnostics.rs new file mode 100644 index 00000000000..cf3e9903b5a --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/orphan_check_diagnostics.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait RemoteTrait { fn dummy(&self) { } } diff --git a/src/test/ui/compile-fail-migration/auxiliary/privacy_tuple_struct.rs b/src/test/ui/compile-fail-migration/auxiliary/privacy_tuple_struct.rs new file mode 100644 index 00000000000..141b6bdd604 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/privacy_tuple_struct.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct A(()); +pub struct B(isize); +pub struct C(pub isize, isize); +pub struct D(pub isize); diff --git a/src/test/ui/compile-fail-migration/auxiliary/private-inferred-type.rs b/src/test/ui/compile-fail-migration/auxiliary/private-inferred-type.rs new file mode 100644 index 00000000000..fc43765f63c --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/private-inferred-type.rs @@ -0,0 +1,46 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(decl_macro)] + +fn priv_fn() {} +static PRIV_STATIC: u8 = 0; +enum PrivEnum { Variant } +pub enum PubEnum { Variant } +trait PrivTrait { fn method() {} } +impl PrivTrait for u8 {} +pub trait PubTrait { fn method() {} } +impl PubTrait for u8 {} +struct PrivTupleStruct(u8); +pub struct PubTupleStruct(u8); +impl PubTupleStruct { fn method() {} } + +struct Priv; +pub type Alias = Priv; +pub struct Pub(pub T); + +impl Pub { + pub fn static_method() {} +} +impl Pub { + fn priv_method(&self) {} +} + +pub macro m() { + priv_fn; + PRIV_STATIC; + PrivEnum::Variant; + PubEnum::Variant; + ::method; + ::method; + PrivTupleStruct; + PubTupleStruct; + Pub(0u8).priv_method(); +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/private_trait_xc.rs b/src/test/ui/compile-fail-migration/auxiliary/private_trait_xc.rs new file mode 100644 index 00000000000..37ee10c8d37 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/private_trait_xc.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/rbmtp_cross_crate_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/rbmtp_cross_crate_lib.rs new file mode 100644 index 00000000000..f49ac4fc8e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/rbmtp_cross_crate_lib.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that method bounds declared on traits/impls in a cross-crate +// scenario work. This is the library portion of the test. + +pub enum MaybeOwned<'a> { + Owned(isize), + Borrowed(&'a isize) +} + +pub struct Inv<'a> { // invariant w/r/t 'a + x: &'a mut &'a isize +} + +// I encountered a bug at some point with encoding the IntoMaybeOwned +// trait, so I'll use that as the template for this test. +pub trait IntoMaybeOwned<'a> { + fn into_maybe_owned(self) -> MaybeOwned<'a>; + + // Note: without this `into_inv` method, the trait is + // contravariant w/r/t `'a`, since if you look strictly at the + // interface, it only returns `'a`. This complicates the + // downstream test since it wants invariance to force an error. + // Hence we add this method. + fn into_inv(self) -> Inv<'a>; + + fn bigger_region<'b:'a>(self, b: Inv<'b>); +} + +impl<'a> IntoMaybeOwned<'a> for Inv<'a> { + fn into_maybe_owned(self) -> MaybeOwned<'a> { panic!() } + fn into_inv(self) -> Inv<'a> { panic!() } + fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/recursive_reexports.rs b/src/test/ui/compile-fail-migration/auxiliary/recursive_reexports.rs new file mode 100644 index 00000000000..1186e3d62f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/recursive_reexports.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod foo { + pub use foo; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/rmeta_meta.rs b/src/test/ui/compile-fail-migration/auxiliary/rmeta_meta.rs new file mode 100644 index 00000000000..4207fc2373b --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/rmeta_meta.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: --emit=metadata + +#![crate_type="rlib"] + +pub struct Foo { + pub field: i32, +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/rmeta_rlib.rs b/src/test/ui/compile-fail-migration/auxiliary/rmeta_rlib.rs new file mode 100644 index 00000000000..6096c4df05b --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/rmeta_rlib.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +pub struct Foo { + pub field: i32, +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/some-panic-impl.rs b/src/test/ui/compile-fail-migration/auxiliary/some-panic-impl.rs new file mode 100644 index 00000000000..db16ac325ac --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/some-panic-impl.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![feature(panic_implementation)] +#![no_std] + +use core::panic::PanicInfo; + +#[panic_implementation] +fn panic(info: &PanicInfo) -> ! { + loop {} +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/stability_attribute_issue.rs b/src/test/ui/compile-fail-migration/auxiliary/stability_attribute_issue.rs new file mode 100644 index 00000000000..1ee623c34fb --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/stability_attribute_issue.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(staged_api)] +#![stable(feature = "stable_test_feature", since = "1.2.0")] + + +#[unstable(feature = "unstable_test_feature", issue = "1")] +pub fn unstable() {} + +#[unstable(feature = "unstable_test_feature", reason = "message", issue = "2")] +pub fn unstable_msg() {} diff --git a/src/test/ui/compile-fail-migration/auxiliary/stability_cfg1.rs b/src/test/ui/compile-fail-migration/auxiliary/stability_cfg1.rs new file mode 100644 index 00000000000..c839993b047 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/stability_cfg1.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![cfg_attr(foo, experimental)] +#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] +#![feature(staged_api)] diff --git a/src/test/ui/compile-fail-migration/auxiliary/stability_cfg2.rs b/src/test/ui/compile-fail-migration/auxiliary/stability_cfg2.rs new file mode 100644 index 00000000000..a59f4b4e8f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/stability_cfg2.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:--cfg foo + +#![cfg_attr(foo, unstable(feature = "unstable_test_feature", issue = "0"))] +#![cfg_attr(not(foo), stable(feature = "test_feature", since = "1.0.0"))] +#![feature(staged_api)] diff --git a/src/test/ui/compile-fail-migration/auxiliary/static_priv_by_default.rs b/src/test/ui/compile-fail-migration/auxiliary/static_priv_by_default.rs new file mode 100644 index 00000000000..73597e51f08 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/static_priv_by_default.rs @@ -0,0 +1,61 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +static private: isize = 0; +pub static public: isize = 0; + +pub struct A(()); + +impl A { + fn foo() {} +} + +mod foo { + pub static a: isize = 0; + pub fn b() {} + pub struct c; + pub enum d {} + pub type e = isize; + + pub struct A(()); + + impl A { + fn foo() {} + } + + // these are public so the parent can re-export them. + pub static reexported_a: isize = 0; + pub fn reexported_b() {} + pub struct reexported_c; + pub enum reexported_d {} + pub type reexported_e = isize; +} + +pub mod bar { + pub use foo::reexported_a as e; + pub use foo::reexported_b as f; + pub use foo::reexported_c as g; + pub use foo::reexported_d as h; + pub use foo::reexported_e as i; +} + +pub static a: isize = 0; +pub fn b() {} +pub struct c; +pub enum d {} +pub type e = isize; + +static j: isize = 0; +fn k() {} +struct l; +enum m {} +type n = isize; diff --git a/src/test/ui/compile-fail-migration/auxiliary/struct_field_privacy.rs b/src/test/ui/compile-fail-migration/auxiliary/struct_field_privacy.rs new file mode 100644 index 00000000000..5fea97da03e --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/struct_field_privacy.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct A { + a: isize, + pub b: isize, +} + +pub struct B { + pub a: isize, + b: isize, +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/struct_variant_privacy.rs b/src/test/ui/compile-fail-migration/auxiliary/struct_variant_privacy.rs new file mode 100644 index 00000000000..40868fa3f70 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/struct_variant_privacy.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Bar { + Baz { a: isize } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/tdticc_coherence_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/tdticc_coherence_lib.rs new file mode 100644 index 00000000000..f6f7a250174 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/tdticc_coherence_lib.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits, core)] +#![crate_type = "rlib"] + +pub auto trait DefaultedTrait { } + +pub struct Something { t: T } diff --git a/src/test/ui/compile-fail-migration/auxiliary/trait_bounds_on_structs_and_enums_xc.rs b/src/test/ui/compile-fail-migration/auxiliary/trait_bounds_on_structs_and_enums_xc.rs new file mode 100644 index 00000000000..29cb0bc176a --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/trait_bounds_on_structs_and_enums_xc.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Trait { + fn dummy(&self) { } +} + +pub struct Foo { + pub x: T, +} + +pub enum Bar { + ABar(isize), + BBar(T), + CBar(usize), +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/trait_impl_conflict.rs b/src/test/ui/compile-fail-migration/auxiliary/trait_impl_conflict.rs new file mode 100644 index 00000000000..3190ce430ad --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/trait_impl_conflict.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo { + fn foo() {} +} + +impl Foo for isize { +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/trait_safety_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/trait_safety_lib.rs new file mode 100644 index 00000000000..585a756fd07 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/trait_safety_lib.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Simple smoke test that unsafe traits can be compiled etc. + +pub unsafe trait Foo { + fn foo(&self) -> isize; +} + +unsafe impl Foo for isize { + fn foo(&self) -> isize { *self } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/trait_superkinds_in_metadata.rs b/src/test/ui/compile-fail-migration/auxiliary/trait_superkinds_in_metadata.rs new file mode 100644 index 00000000000..0fa2d3459f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/trait_superkinds_in_metadata.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test library crate for cross-crate usages of traits inheriting +// from the builtin kinds. Mostly tests metadata correctness. + +#![crate_type="lib"] + +pub trait RequiresShare : Sync { } +pub trait RequiresRequiresShareAndSend : RequiresShare + Send { } +pub trait RequiresCopy : Copy { } diff --git a/src/test/ui/compile-fail-migration/auxiliary/two_macros.rs b/src/test/ui/compile-fail-migration/auxiliary/two_macros.rs new file mode 100644 index 00000000000..060960f0dbc --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/two_macros.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_export] +macro_rules! macro_one { () => ("one") } + +#[macro_export] +macro_rules! macro_two { () => ("two") } diff --git a/src/test/ui/compile-fail-migration/auxiliary/unreachable_variant.rs b/src/test/ui/compile-fail-migration/auxiliary/unreachable_variant.rs new file mode 100644 index 00000000000..8ca85f20ab2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/unreachable_variant.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod super_sekrit { + pub enum sooper_sekrit { + quux, baz + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/unstable-macros.rs b/src/test/ui/compile-fail-migration/auxiliary/unstable-macros.rs new file mode 100644 index 00000000000..836164a721a --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/unstable-macros.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(staged_api)] +#![stable(feature = "unit_test", since = "1.0.0")] + +#[unstable(feature = "unstable_macros", issue = "0")] +#[macro_export] +macro_rules! unstable_macro{ () => () } diff --git a/src/test/ui/compile-fail-migration/auxiliary/use_from_trait_xc.rs b/src/test/ui/compile-fail-migration/auxiliary/use_from_trait_xc.rs new file mode 100644 index 00000000000..9a6d176d088 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/use_from_trait_xc.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub use self::sub::{Bar, Baz}; + +pub trait Trait { + fn foo(&self); + type Assoc; + const CONST: u32; +} + +struct Foo; + +impl Foo { + pub fn new() {} + + pub const C: u32 = 0; +} + +mod sub { + pub struct Bar; + + impl Bar { + pub fn new() {} + } + + pub enum Baz {} + + impl Baz { + pub fn new() {} + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/variant-namespacing.rs b/src/test/ui/compile-fail-migration/auxiliary/variant-namespacing.rs new file mode 100644 index 00000000000..d7fd2968495 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/variant-namespacing.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum XE { + XStruct { a: u8 }, + XTuple(u8), + XUnit, +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/weak-lang-items.rs b/src/test/ui/compile-fail-migration/auxiliary/weak-lang-items.rs new file mode 100644 index 00000000000..6434e62b6f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/weak-lang-items.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +// This aux-file will require the eh_personality function to be codegen'd, but +// it hasn't been defined just yet. Make sure we don't explode. + +#![no_std] +#![crate_type = "rlib"] + +struct A; + +impl core::ops::Drop for A { + fn drop(&mut self) {} +} + +pub fn foo() { + let _a = A; + panic!("wut"); +} + +mod std { + pub use core::{option, fmt}; +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/xc_private_method_lib.rs b/src/test/ui/compile-fail-migration/auxiliary/xc_private_method_lib.rs new file mode 100644 index 00000000000..5e7bc61943b --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/xc_private_method_lib.rs @@ -0,0 +1,43 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub struct Struct { + pub x: isize +} + +impl Struct { + fn static_meth_struct() -> Struct { + Struct { x: 1 } + } + + fn meth_struct(&self) -> isize { + self.x + } +} + +pub enum Enum { + Variant1(isize), + Variant2(isize) +} + +impl Enum { + fn static_meth_enum() -> Enum { + Enum::Variant2(10) + } + + fn meth_enum(&self) -> isize { + match *self { + Enum::Variant1(x) | + Enum::Variant2(x) => x + } + } +} diff --git a/src/test/ui/compile-fail-migration/auxiliary/xcrate_unit_struct.rs b/src/test/ui/compile-fail-migration/auxiliary/xcrate_unit_struct.rs new file mode 100644 index 00000000000..7a69be2b06c --- /dev/null +++ b/src/test/ui/compile-fail-migration/auxiliary/xcrate_unit_struct.rs @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +// used by the rpass test + +#[derive(Copy, Clone)] +pub struct Struct; + +#[derive(Copy, Clone)] +pub enum Unit { + UnitVariant, + Argument(Struct) +} + +#[derive(Copy, Clone)] +pub struct TupleStruct(pub usize, pub &'static str); + +// used by the cfail test + +#[derive(Copy, Clone)] +pub struct StructWithFields { + foo: isize, +} + +#[derive(Copy, Clone)] +pub enum EnumWithVariants { + EnumVariant, + EnumVariantArg(isize) +} diff --git a/src/test/ui/compile-fail-migration/bad-const-type.rs b/src/test/ui/compile-fail-migration/bad-const-type.rs new file mode 100644 index 00000000000..5547d19868d --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-const-type.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static i: String = 10; +//~^ ERROR mismatched types +//~| expected type `std::string::String` +//~| found type `{integer}` +//~| expected struct `std::string::String`, found integral variable +fn main() { println!("{}", i); } diff --git a/src/test/ui/compile-fail-migration/bad-const-type.stderr b/src/test/ui/compile-fail-migration/bad-const-type.stderr new file mode 100644 index 00000000000..fbde1573200 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-const-type.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/bad-const-type.rs:11:20 + | +LL | static i: String = 10; + | ^^ + | | + | expected struct `std::string::String`, found integral variable + | help: try using a conversion method: `10.to_string()` + | + = note: expected type `std::string::String` + found type `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/bad-env-capture.rs b/src/test/ui/compile-fail-migration/bad-env-capture.rs new file mode 100644 index 00000000000..6a5e4cfef89 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-env-capture.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: can't capture dynamic environment in a fn item +fn foo() { + let x: isize; + fn bar() { log(debug, x); } +} +fn main() { foo(); } diff --git a/src/test/ui/compile-fail-migration/bad-env-capture.stderr b/src/test/ui/compile-fail-migration/bad-env-capture.stderr new file mode 100644 index 00000000000..bf460d2a81e --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-env-capture.stderr @@ -0,0 +1,24 @@ +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/bad-env-capture.rs:14:27 + | +LL | fn bar() { log(debug, x); } + | ^ + | + = help: use the `|| { ... }` closure form instead + +error[E0425]: cannot find function `log` in this scope + --> $DIR/bad-env-capture.rs:14:16 + | +LL | fn bar() { log(debug, x); } + | ^^^ not found in this scope + +error[E0425]: cannot find value `debug` in this scope + --> $DIR/bad-env-capture.rs:14:20 + | +LL | fn bar() { log(debug, x); } + | ^^^^^ not found in this scope + +error: aborting due to 3 previous errors + +Some errors occurred: E0425, E0434. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/bad-env-capture2.rs b/src/test/ui/compile-fail-migration/bad-env-capture2.rs new file mode 100644 index 00000000000..cf67c73c539 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-env-capture2.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: can't capture dynamic environment in a fn item +fn foo(x: isize) { + fn bar() { log(debug, x); } +} +fn main() { foo(2); } diff --git a/src/test/ui/compile-fail-migration/bad-env-capture2.stderr b/src/test/ui/compile-fail-migration/bad-env-capture2.stderr new file mode 100644 index 00000000000..8d5703d29f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-env-capture2.stderr @@ -0,0 +1,24 @@ +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/bad-env-capture2.rs:13:27 + | +LL | fn bar() { log(debug, x); } + | ^ + | + = help: use the `|| { ... }` closure form instead + +error[E0425]: cannot find function `log` in this scope + --> $DIR/bad-env-capture2.rs:13:16 + | +LL | fn bar() { log(debug, x); } + | ^^^ not found in this scope + +error[E0425]: cannot find value `debug` in this scope + --> $DIR/bad-env-capture2.rs:13:20 + | +LL | fn bar() { log(debug, x); } + | ^^^^^ not found in this scope + +error: aborting due to 3 previous errors + +Some errors occurred: E0425, E0434. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/bad-env-capture3.rs b/src/test/ui/compile-fail-migration/bad-env-capture3.rs new file mode 100644 index 00000000000..a30c6770b87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-env-capture3.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: can't capture dynamic environment in a fn item +fn foo(x: isize) { + fn mth() { + fn bar() { log(debug, x); } + } +} + +fn main() { foo(2); } diff --git a/src/test/ui/compile-fail-migration/bad-env-capture3.stderr b/src/test/ui/compile-fail-migration/bad-env-capture3.stderr new file mode 100644 index 00000000000..258f7d43b56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-env-capture3.stderr @@ -0,0 +1,24 @@ +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/bad-env-capture3.rs:14:31 + | +LL | fn bar() { log(debug, x); } + | ^ + | + = help: use the `|| { ... }` closure form instead + +error[E0425]: cannot find function `log` in this scope + --> $DIR/bad-env-capture3.rs:14:20 + | +LL | fn bar() { log(debug, x); } + | ^^^ not found in this scope + +error[E0425]: cannot find value `debug` in this scope + --> $DIR/bad-env-capture3.rs:14:24 + | +LL | fn bar() { log(debug, x); } + | ^^^^^ not found in this scope + +error: aborting due to 3 previous errors + +Some errors occurred: E0425, E0434. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/bad-expr-lhs.rs b/src/test/ui/compile-fail-migration/bad-expr-lhs.rs new file mode 100644 index 00000000000..c7d2f2c472f --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-expr-lhs.rs @@ -0,0 +1,20 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + 1 = 2; //~ ERROR invalid left-hand side expression + 1 += 2; //~ ERROR invalid left-hand side expression + (1, 2) = (3, 4); //~ ERROR invalid left-hand side expression + + let (a, b) = (1, 2); + (a, b) = (3, 4); //~ ERROR invalid left-hand side expression + + None = Some(3); //~ ERROR invalid left-hand side expression +} diff --git a/src/test/ui/compile-fail-migration/bad-expr-lhs.stderr b/src/test/ui/compile-fail-migration/bad-expr-lhs.stderr new file mode 100644 index 00000000000..5937beef9c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-expr-lhs.stderr @@ -0,0 +1,34 @@ +error[E0070]: invalid left-hand side expression + --> $DIR/bad-expr-lhs.rs:12:5 + | +LL | 1 = 2; //~ ERROR invalid left-hand side expression + | ^^^^^ left-hand of expression not valid + +error[E0067]: invalid left-hand side expression + --> $DIR/bad-expr-lhs.rs:13:5 + | +LL | 1 += 2; //~ ERROR invalid left-hand side expression + | ^ invalid expression for left-hand side + +error[E0070]: invalid left-hand side expression + --> $DIR/bad-expr-lhs.rs:14:5 + | +LL | (1, 2) = (3, 4); //~ ERROR invalid left-hand side expression + | ^^^^^^^^^^^^^^^ left-hand of expression not valid + +error[E0070]: invalid left-hand side expression + --> $DIR/bad-expr-lhs.rs:17:5 + | +LL | (a, b) = (3, 4); //~ ERROR invalid left-hand side expression + | ^^^^^^^^^^^^^^^ left-hand of expression not valid + +error[E0070]: invalid left-hand side expression + --> $DIR/bad-expr-lhs.rs:19:5 + | +LL | None = Some(3); //~ ERROR invalid left-hand side expression + | ^^^^^^^^^^^^^^ left-hand of expression not valid + +error: aborting due to 5 previous errors + +Some errors occurred: E0067, E0070. +For more information about an error, try `rustc --explain E0067`. diff --git a/src/test/ui/compile-fail-migration/bad-expr-path.rs b/src/test/ui/compile-fail-migration/bad-expr-path.rs new file mode 100644 index 00000000000..bd62dc66377 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-expr-path.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m1 {} + +fn main(arguments: Vec) { //~ ERROR main function has wrong type + log(debug, m1::arguments); + //~^ ERROR cannot find function `log` in this scope + //~| ERROR cannot find value `debug` in this scope + //~| ERROR cannot find value `arguments` in module `m1` +} diff --git a/src/test/ui/compile-fail-migration/bad-expr-path.stderr b/src/test/ui/compile-fail-migration/bad-expr-path.stderr new file mode 100644 index 00000000000..a1ac17c78d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-expr-path.stderr @@ -0,0 +1,31 @@ +error[E0425]: cannot find function `log` in this scope + --> $DIR/bad-expr-path.rs:14:5 + | +LL | log(debug, m1::arguments); + | ^^^ not found in this scope + +error[E0425]: cannot find value `debug` in this scope + --> $DIR/bad-expr-path.rs:14:9 + | +LL | log(debug, m1::arguments); + | ^^^^^ not found in this scope + +error[E0425]: cannot find value `arguments` in module `m1` + --> $DIR/bad-expr-path.rs:14:20 + | +LL | log(debug, m1::arguments); + | ^^^^^^^^^ not found in `m1` + +error[E0580]: main function has wrong type + --> $DIR/bad-expr-path.rs:13:1 + | +LL | fn main(arguments: Vec) { //~ ERROR main function has wrong type + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected type `fn()` + found type `fn(std::vec::Vec)` + +error: aborting due to 4 previous errors + +Some errors occurred: E0425, E0580. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/bad-expr-path2.rs b/src/test/ui/compile-fail-migration/bad-expr-path2.rs new file mode 100644 index 00000000000..06b72d1ed47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-expr-path2.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod m1 { + pub mod arguments {} +} + +fn main(arguments: Vec) { //~ ERROR main function has wrong type + log(debug, m1::arguments); + //~^ ERROR cannot find function `log` in this scope + //~| ERROR cannot find value `debug` in this scope + //~| ERROR expected value, found module `m1::arguments` +} diff --git a/src/test/ui/compile-fail-migration/bad-expr-path2.stderr b/src/test/ui/compile-fail-migration/bad-expr-path2.stderr new file mode 100644 index 00000000000..bb7d01c72fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-expr-path2.stderr @@ -0,0 +1,31 @@ +error[E0425]: cannot find function `log` in this scope + --> $DIR/bad-expr-path2.rs:16:5 + | +LL | log(debug, m1::arguments); + | ^^^ not found in this scope + +error[E0425]: cannot find value `debug` in this scope + --> $DIR/bad-expr-path2.rs:16:9 + | +LL | log(debug, m1::arguments); + | ^^^^^ not found in this scope + +error[E0423]: expected value, found module `m1::arguments` + --> $DIR/bad-expr-path2.rs:16:16 + | +LL | log(debug, m1::arguments); + | ^^^^^^^^^^^^^ not a value + +error[E0580]: main function has wrong type + --> $DIR/bad-expr-path2.rs:15:1 + | +LL | fn main(arguments: Vec) { //~ ERROR main function has wrong type + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected type `fn()` + found type `fn(std::vec::Vec)` + +error: aborting due to 4 previous errors + +Some errors occurred: E0423, E0425, E0580. +For more information about an error, try `rustc --explain E0423`. diff --git a/src/test/ui/compile-fail-migration/bad-extern-link-attrs.rs b/src/test/ui/compile-fail-migration/bad-extern-link-attrs.rs new file mode 100644 index 00000000000..ff63d4b739a --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-extern-link-attrs.rs @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link()] //~ ERROR: specified without `name = +#[link(name = "")] //~ ERROR: with empty name +#[link(name = "foo")] +#[link(name = "foo", kind = "bar")] //~ ERROR: unknown kind +extern {} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/bad-extern-link-attrs.stderr b/src/test/ui/compile-fail-migration/bad-extern-link-attrs.stderr new file mode 100644 index 00000000000..5e58bcd0094 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-extern-link-attrs.stderr @@ -0,0 +1,24 @@ +error[E0459]: #[link(...)] specified without `name = "foo"` + --> $DIR/bad-extern-link-attrs.rs:11:1 + | +LL | #[link()] //~ ERROR: specified without `name = + | ^^^^^^^^^ missing `name` argument + +error[E0454]: #[link(name = "")] given with empty name + --> $DIR/bad-extern-link-attrs.rs:12:1 + | +LL | #[link(name = "")] //~ ERROR: with empty name + | ^^^^^^^^^^^^^^^^^^ empty name given + +error[E0458]: unknown kind: `bar` + --> $DIR/bad-extern-link-attrs.rs:14:1 + | +LL | #[link(name = "foo", kind = "bar")] //~ ERROR: unknown kind + | ^^^^^^^^^^^^^^^^^^^^^------------^^ + | | + | unknown kind + +error: aborting due to 3 previous errors + +Some errors occurred: E0454, E0458, E0459. +For more information about an error, try `rustc --explain E0454`. diff --git a/src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.rs b/src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.rs new file mode 100644 index 00000000000..2fe94d43acd --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.rs @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_simd, platform_intrinsics, core_intrinsics)] +#![allow(warnings)] +#![crate_type = "rlib"] + +// Bad monomorphizations could previously cause LLVM asserts even though the +// error was caught in the compiler. + +extern "platform-intrinsic" { + fn simd_add(x: T, y: T) -> T; +} + +use std::intrinsics; + +#[derive(Copy, Clone)] +pub struct Foo(i64); + +pub unsafe fn test_cttz(v: Foo) -> Foo { + intrinsics::cttz(v) + //~^ ERROR `cttz` intrinsic: expected basic integer type, found `Foo` +} + +pub unsafe fn test_fadd_fast(a: Foo, b: Foo) -> Foo { + intrinsics::fadd_fast(a, b) + //~^ ERROR `fadd_fast` intrinsic: expected basic float type, found `Foo` +} + +pub unsafe fn test_simd_add(a: Foo, b: Foo) -> Foo { + simd_add(a, b) + //~^ ERROR `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` +} diff --git a/src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.stderr b/src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.stderr new file mode 100644 index 00000000000..a088dd0aa43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-intrinsic-monomorphization.stderr @@ -0,0 +1,21 @@ +error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo` + --> $DIR/bad-intrinsic-monomorphization.rs:28:5 + | +LL | intrinsics::cttz(v) + | ^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic float type, found `Foo` + --> $DIR/bad-intrinsic-monomorphization.rs:33:5 + | +LL | intrinsics::fadd_fast(a, b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` + --> $DIR/bad-intrinsic-monomorphization.rs:38:5 + | +LL | simd_add(a, b) + | ^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/compile-fail-migration/bad-lint-cap.rs b/src/test/ui/compile-fail-migration/bad-lint-cap.rs new file mode 100644 index 00000000000..cb9c347af60 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-lint-cap.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --cap-lints test +// error-pattern: unknown lint level: `test` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/bad-lint-cap.stderr b/src/test/ui/compile-fail-migration/bad-lint-cap.stderr new file mode 100644 index 00000000000..f284dbf8479 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-lint-cap.stderr @@ -0,0 +1,2 @@ +error: unknown lint level: `test` + diff --git a/src/test/ui/compile-fail-migration/bad-lint-cap2.rs b/src/test/ui/compile-fail-migration/bad-lint-cap2.rs new file mode 100644 index 00000000000..cb9fb973a01 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-lint-cap2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --cap-lints deny + +#![warn(unused)] +#![deny(warnings)] + +use std::option; //~ ERROR + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/bad-lint-cap2.stderr b/src/test/ui/compile-fail-migration/bad-lint-cap2.stderr new file mode 100644 index 00000000000..7471aa21e58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-lint-cap2.stderr @@ -0,0 +1,15 @@ +error: unused import: `std::option` + --> $DIR/bad-lint-cap2.rs:16:5 + | +LL | use std::option; //~ ERROR + | ^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/bad-lint-cap2.rs:14:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: #[deny(unused_imports)] implied by #[deny(warnings)] + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/bad-lint-cap3.rs b/src/test/ui/compile-fail-migration/bad-lint-cap3.rs new file mode 100644 index 00000000000..c9394954c5f --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-lint-cap3.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --cap-lints warn + +#![warn(unused)] +#![deny(warnings)] +#![feature(rustc_attrs)] + +use std::option; //~ WARN + +#[rustc_error] +fn main() {} //~ ERROR: compilation successful + diff --git a/src/test/ui/compile-fail-migration/bad-lint-cap3.stderr b/src/test/ui/compile-fail-migration/bad-lint-cap3.stderr new file mode 100644 index 00000000000..d3224607314 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-lint-cap3.stderr @@ -0,0 +1,21 @@ +warning: unused import: `std::option` + --> $DIR/bad-lint-cap3.rs:17:5 + | +LL | use std::option; //~ WARN + | ^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/bad-lint-cap3.rs:14:9 + | +LL | #![deny(warnings)] + | ^^^^^^^^ + = note: #[warn(unused_imports)] implied by #[warn(warnings)] + +error: compilation successful + --> $DIR/bad-lint-cap3.rs:20:1 + | +LL | fn main() {} //~ ERROR: compilation successful + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/bad-main.rs b/src/test/ui/compile-fail-migration/bad-main.rs new file mode 100644 index 00000000000..b73b4a6af6e --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-main.rs @@ -0,0 +1,11 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main(x: isize) { } //~ ERROR: main function has wrong type [E0580] diff --git a/src/test/ui/compile-fail-migration/bad-main.stderr b/src/test/ui/compile-fail-migration/bad-main.stderr new file mode 100644 index 00000000000..3388e0866e5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-main.stderr @@ -0,0 +1,12 @@ +error[E0580]: main function has wrong type + --> $DIR/bad-main.rs:11:1 + | +LL | fn main(x: isize) { } //~ ERROR: main function has wrong type [E0580] + | ^^^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected type `fn()` + found type `fn(isize)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0580`. diff --git a/src/test/ui/compile-fail-migration/bad-method-typaram-kind.rs b/src/test/ui/compile-fail-migration/bad-method-typaram-kind.rs new file mode 100644 index 00000000000..7cef3f13dfc --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-method-typaram-kind.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() { + 1.bar::(); //~ ERROR `T` cannot be sent between threads safely +} + +trait bar { + fn bar(&self); +} + +impl bar for usize { + fn bar(&self) { + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/bad-method-typaram-kind.stderr b/src/test/ui/compile-fail-migration/bad-method-typaram-kind.stderr new file mode 100644 index 00000000000..ed0c49a4f66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-method-typaram-kind.stderr @@ -0,0 +1,12 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/bad-method-typaram-kind.rs:12:7 + | +LL | 1.bar::(); //~ ERROR `T` cannot be sent between threads safely + | ^^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/bad-mid-path-type-params.rs b/src/test/ui/compile-fail-migration/bad-mid-path-type-params.rs new file mode 100644 index 00000000000..20ac757354f --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-mid-path-type-params.rs @@ -0,0 +1,53 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S { + contents: T, +} + +impl S { + fn new(x: T, _: U) -> S { + S { + contents: x, + } + } +} + +trait Trait { + fn new(x: T, y: U) -> Self; +} + +struct S2 { + contents: isize, +} + +impl Trait for S2 { + fn new(x: isize, _: U) -> S2 { + S2 { + contents: x, + } + } +} + +fn foo<'a>() { + let _ = S::new::(1, 1.0); + //~^ ERROR too many type parameters provided + + let _ = S::<'a,isize>::new::(1, 1.0); + //~^ ERROR wrong number of lifetime parameters + + let _: S2 = Trait::new::(1, 1.0); + //~^ ERROR too many type parameters provided + + let _: S2 = Trait::<'a,isize>::new::(1, 1.0); + //~^ ERROR too many lifetime parameters provided +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/bad-mid-path-type-params.stderr b/src/test/ui/compile-fail-migration/bad-mid-path-type-params.stderr new file mode 100644 index 00000000000..d2b002ebee9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-mid-path-type-params.stderr @@ -0,0 +1,28 @@ +error[E0087]: too many type parameters provided: expected at most 1 type parameter, found 2 type parameters + --> $DIR/bad-mid-path-type-params.rs:40:28 + | +LL | let _ = S::new::(1, 1.0); + | ^^^ expected 1 type parameter + +error[E0107]: wrong number of lifetime parameters: expected 0, found 1 + --> $DIR/bad-mid-path-type-params.rs:43:13 + | +LL | let _ = S::<'a,isize>::new::(1, 1.0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected lifetime parameter + +error[E0087]: too many type parameters provided: expected at most 1 type parameter, found 2 type parameters + --> $DIR/bad-mid-path-type-params.rs:46:36 + | +LL | let _: S2 = Trait::new::(1, 1.0); + | ^^^ expected 1 type parameter + +error[E0088]: too many lifetime parameters provided: expected at most 0 lifetime parameters, found 1 lifetime parameter + --> $DIR/bad-mid-path-type-params.rs:49:25 + | +LL | let _: S2 = Trait::<'a,isize>::new::(1, 1.0); + | ^^ expected 0 lifetime parameters + +error: aborting due to 4 previous errors + +Some errors occurred: E0087, E0088, E0107. +For more information about an error, try `rustc --explain E0087`. diff --git a/src/test/ui/compile-fail-migration/bad-module.rs b/src/test/ui/compile-fail-migration/bad-module.rs new file mode 100644 index 00000000000..6987d06ef12 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-module.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let foo = thing::len(Vec::new()); + //~^ ERROR failed to resolve. Use of undeclared type or module `thing` + + let foo = foo::bar::baz(); + //~^ ERROR failed to resolve. Use of undeclared type or module `foo` +} diff --git a/src/test/ui/compile-fail-migration/bad-module.stderr b/src/test/ui/compile-fail-migration/bad-module.stderr new file mode 100644 index 00000000000..8c19922dcab --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-module.stderr @@ -0,0 +1,15 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `thing` + --> $DIR/bad-module.rs:12:15 + | +LL | let foo = thing::len(Vec::new()); + | ^^^^^ Use of undeclared type or module `thing` + +error[E0433]: failed to resolve. Use of undeclared type or module `foo` + --> $DIR/bad-module.rs:15:15 + | +LL | let foo = foo::bar::baz(); + | ^^^ Use of undeclared type or module `foo` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/compile-fail-migration/bad-sized.rs b/src/test/ui/compile-fail-migration/bad-sized.rs new file mode 100644 index 00000000000..a58aebee77b --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-sized.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Trait {} + +pub fn main() { + let x: Vec = Vec::new(); + //~^ ERROR only auto traits can be used as additional traits in a trait object + //~| ERROR the size for values of type + //~| ERROR the size for values of type +} diff --git a/src/test/ui/compile-fail-migration/bad-sized.stderr b/src/test/ui/compile-fail-migration/bad-sized.stderr new file mode 100644 index 00000000000..12873d40b57 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-sized.stderr @@ -0,0 +1,30 @@ +error[E0225]: only auto traits can be used as additional traits in a trait object + --> $DIR/bad-sized.rs:14:24 + | +LL | let x: Vec = Vec::new(); + | ^^^^^ non-auto additional trait + +error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time + --> $DIR/bad-sized.rs:14:12 + | +LL | let x: Vec = Vec::new(); + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` + = note: to learn more, visit + = note: required by `std::vec::Vec` + +error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time + --> $DIR/bad-sized.rs:14:33 + | +LL | let x: Vec = Vec::new(); + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` + = note: to learn more, visit + = note: required by `>::new` + +error: aborting due to 3 previous errors + +Some errors occurred: E0225, E0277. +For more information about an error, try `rustc --explain E0225`. diff --git a/src/test/ui/compile-fail-migration/bad-type-env-capture.rs b/src/test/ui/compile-fail-migration/bad-type-env-capture.rs new file mode 100644 index 00000000000..c1547dd82b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-type-env-capture.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() { + fn bar(b: T) { } //~ ERROR can't use type parameters from outer +} +fn main() { } diff --git a/src/test/ui/compile-fail-migration/bad-type-env-capture.stderr b/src/test/ui/compile-fail-migration/bad-type-env-capture.stderr new file mode 100644 index 00000000000..3cb087ab09a --- /dev/null +++ b/src/test/ui/compile-fail-migration/bad-type-env-capture.stderr @@ -0,0 +1,13 @@ +error[E0401]: can't use type parameters from outer function + --> $DIR/bad-type-env-capture.rs:12:15 + | +LL | fn foo() { + | - type variable from outer function +LL | fn bar(b: T) { } //~ ERROR can't use type parameters from outer + | --- ^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0401`. diff --git a/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.rs b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.rs new file mode 100644 index 00000000000..2a5c7136dc3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct X { x: (), } + +impl Drop for X { + fn drop(&mut self) { + println!("destructor runs"); + } +} + +fn main() { + let x = Some((X { x: () }, X { x: () })); + match x { + Some((ref _y, _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern + None => panic!() + } +} diff --git a/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.stderr b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.stderr new file mode 100644 index 00000000000..2f05755eabd --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-2.stderr @@ -0,0 +1,11 @@ +error[E0009]: cannot bind by-move and by-ref in the same pattern + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-2.rs:22:23 + | +LL | Some((ref _y, _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern + | ------ ^^ by-move pattern here + | | + | both by-ref and by-move used + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0009`. diff --git a/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.rs b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.rs new file mode 100644 index 00000000000..3d3ccb606bf --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.rs @@ -0,0 +1,28 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct X { x: (), } + +impl Drop for X { + fn drop(&mut self) { + println!("destructor runs"); + } +} + +enum double_option { some2(T,U), none2 } + +fn main() { + let x = double_option::some2(X { x: () }, X { x: () }); + match x { + double_option::some2(ref _y, _z) => { }, + //~^ ERROR cannot bind by-move and by-ref in the same pattern + double_option::none2 => panic!() + } +} diff --git a/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.stderr b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.stderr new file mode 100644 index 00000000000..a573b9a04ba --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-3.stderr @@ -0,0 +1,11 @@ +error[E0009]: cannot bind by-move and by-ref in the same pattern + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-3.rs:24:38 + | +LL | double_option::some2(ref _y, _z) => { }, + | ------ ^^ by-move pattern here + | | + | both by-ref and by-move used + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0009`. diff --git a/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.rs b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.rs new file mode 100644 index 00000000000..8c7542fbe6b --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct X { x: (), } + +impl Drop for X { + fn drop(&mut self) { + println!("destructor runs"); + } +} + +fn main() { + let x = Some((X { x: () }, X { x: () })); + match x { + Some((_y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern + None => panic!() + } +} diff --git a/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.stderr b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.stderr new file mode 100644 index 00000000000..e38916b8b27 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-neither-can-live-while-the-other-survives-4.stderr @@ -0,0 +1,11 @@ +error[E0009]: cannot bind by-move and by-ref in the same pattern + --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-4.rs:22:15 + | +LL | Some((_y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern + | ^^ ------ both by-ref and by-move used + | | + | by-move pattern here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0009`. diff --git a/src/test/ui/compile-fail-migration/bind-by-move-no-guards.rs b/src/test/ui/compile-fail-migration/bind-by-move-no-guards.rs new file mode 100644 index 00000000000..bb6060f2543 --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-no-guards.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::sync::mpsc::channel; + +fn main() { + let (tx, rx) = channel(); + let x = Some(rx); + tx.send(false); + match x { + Some(z) if z.recv().unwrap() => { panic!() }, + //~^ ERROR cannot bind by-move into a pattern guard + Some(z) => { assert!(!z.recv().unwrap()); }, + None => panic!() + } +} diff --git a/src/test/ui/compile-fail-migration/bind-by-move-no-guards.stderr b/src/test/ui/compile-fail-migration/bind-by-move-no-guards.stderr new file mode 100644 index 00000000000..ed516cd559e --- /dev/null +++ b/src/test/ui/compile-fail-migration/bind-by-move-no-guards.stderr @@ -0,0 +1,9 @@ +error[E0008]: cannot bind by-move into a pattern guard + --> $DIR/bind-by-move-no-guards.rs:18:14 + | +LL | Some(z) if z.recv().unwrap() => { panic!() }, + | ^ moves value into pattern guard + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/compile-fail-migration/binop-bitxor-str.rs b/src/test/ui/compile-fail-migration/binop-bitxor-str.rs new file mode 100644 index 00000000000..3f26e3ce904 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-bitxor-str.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:`^` cannot be applied to type `std::string::String` + +fn main() { let x = "a".to_string() ^ "b".to_string(); } diff --git a/src/test/ui/compile-fail-migration/binop-bitxor-str.stderr b/src/test/ui/compile-fail-migration/binop-bitxor-str.stderr new file mode 100644 index 00000000000..a6804a6d42c --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-bitxor-str.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `^` cannot be applied to type `std::string::String` + --> $DIR/binop-bitxor-str.rs:13:21 + | +LL | fn main() { let x = "a".to_string() ^ "b".to_string(); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: an implementation of `std::ops::BitXor` might be missing for `std::string::String` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/binop-consume-args.rs b/src/test/ui/compile-fail-migration/binop-consume-args.rs new file mode 100644 index 00000000000..c525a67c7e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-consume-args.rs @@ -0,0 +1,75 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that binary operators consume their arguments + +use std::ops::{Add, Sub, Mul, Div, Rem, BitAnd, BitXor, BitOr, Shl, Shr}; + +fn add, B>(lhs: A, rhs: B) { + lhs + rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn sub, B>(lhs: A, rhs: B) { + lhs - rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn mul, B>(lhs: A, rhs: B) { + lhs * rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn div, B>(lhs: A, rhs: B) { + lhs / rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn rem, B>(lhs: A, rhs: B) { + lhs % rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn bitand, B>(lhs: A, rhs: B) { + lhs & rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn bitor, B>(lhs: A, rhs: B) { + lhs | rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn bitxor, B>(lhs: A, rhs: B) { + lhs ^ rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn shl, B>(lhs: A, rhs: B) { + lhs << rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn shr, B>(lhs: A, rhs: B) { + lhs >> rhs; + drop(lhs); //~ ERROR use of moved value: `lhs` + drop(rhs); //~ ERROR use of moved value: `rhs` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/binop-consume-args.stderr b/src/test/ui/compile-fail-migration/binop-consume-args.stderr new file mode 100644 index 00000000000..07627d3711b --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-consume-args.stderr @@ -0,0 +1,213 @@ +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:17:10 + | +LL | lhs + rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:18:10 + | +LL | lhs + rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:23:10 + | +LL | lhs - rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:24:10 + | +LL | lhs - rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:29:10 + | +LL | lhs * rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:30:10 + | +LL | lhs * rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:35:10 + | +LL | lhs / rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:36:10 + | +LL | lhs / rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:41:10 + | +LL | lhs % rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:42:10 + | +LL | lhs % rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:47:10 + | +LL | lhs & rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:48:10 + | +LL | lhs & rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:53:10 + | +LL | lhs | rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:54:10 + | +LL | lhs | rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:59:10 + | +LL | lhs ^ rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:60:10 + | +LL | lhs ^ rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:65:10 + | +LL | lhs << rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:66:10 + | +LL | lhs << rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `lhs` + --> $DIR/binop-consume-args.rs:71:10 + | +LL | lhs >> rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` + | ^^^ value used here after move + | + = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `rhs` + --> $DIR/binop-consume-args.rs:72:10 + | +LL | lhs >> rhs; + | --- value moved here +LL | drop(lhs); //~ ERROR use of moved value: `lhs` +LL | drop(rhs); //~ ERROR use of moved value: `rhs` + | ^^^ value used here after move + | + = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + +error: aborting due to 20 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/binop-logic-float.rs b/src/test/ui/compile-fail-migration/binop-logic-float.rs new file mode 100644 index 00000000000..f3fb5a08c85 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-logic-float.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { let x = 1.0_f32 || 2.0_f32; } +//~^ ERROR mismatched types +//~| ERROR mismatched types + diff --git a/src/test/ui/compile-fail-migration/binop-logic-float.stderr b/src/test/ui/compile-fail-migration/binop-logic-float.stderr new file mode 100644 index 00000000000..947ee4e2427 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-logic-float.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/binop-logic-float.rs:11:21 + | +LL | fn main() { let x = 1.0_f32 || 2.0_f32; } + | ^^^^^^^ expected bool, found f32 + +error[E0308]: mismatched types + --> $DIR/binop-logic-float.rs:11:32 + | +LL | fn main() { let x = 1.0_f32 || 2.0_f32; } + | ^^^^^^^ expected bool, found f32 + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/binop-logic-int.rs b/src/test/ui/compile-fail-migration/binop-logic-int.rs new file mode 100644 index 00000000000..f5e53f84c16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-logic-int.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { let x = 1 && 2; } +//~^ ERROR mismatched types +//~| ERROR mismatched types diff --git a/src/test/ui/compile-fail-migration/binop-logic-int.stderr b/src/test/ui/compile-fail-migration/binop-logic-int.stderr new file mode 100644 index 00000000000..56f7601ace2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-logic-int.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/binop-logic-int.rs:11:21 + | +LL | fn main() { let x = 1 && 2; } + | ^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/binop-logic-int.rs:11:26 + | +LL | fn main() { let x = 1 && 2; } + | ^ expected bool, found integral variable + | + = note: expected type `bool` + found type `{integer}` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/binop-move-semantics.nll.stderr b/src/test/ui/compile-fail-migration/binop-move-semantics.nll.stderr new file mode 100644 index 00000000000..98762a0f6cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-move-semantics.nll.stderr @@ -0,0 +1,68 @@ +error[E0382]: use of moved value: `x` + --> $DIR/binop-move-semantics.rs:18:5 + | +LL | x + | - value moved here +LL | + +LL | x; //~ ERROR: use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x` + --> $DIR/binop-move-semantics.rs:24:5 + | +LL | x + | - value moved here +LL | + +LL | x.clone(); //~ ERROR: use of moved value + | ^ value borrowed here after move + | + = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of borrowed content + --> $DIR/binop-move-semantics.rs:40:5 + | +LL | *m //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/binop-move-semantics.rs:42:5 + | +LL | *n; //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable + --> $DIR/binop-move-semantics.rs:64:5 + | +LL | &mut f + | ------ + | | + | _____mutable borrow occurs here + | | +LL | | + +LL | | &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable + | | ^- + | |_____|| + | |borrow later used here + | immutable borrow occurs here + +error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable + --> $DIR/binop-move-semantics.rs:72:5 + | +LL | &f + | -- + | | + | _____immutable borrow occurs here + | | +LL | | + +LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable + | | ^^^^^- + | |_____|____| + | | borrow later used here + | mutable borrow occurs here + +error: aborting due to 6 previous errors + +Some errors occurred: E0382, E0502, E0507. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/binop-move-semantics.rs b/src/test/ui/compile-fail-migration/binop-move-semantics.rs new file mode 100644 index 00000000000..cff0064497a --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-move-semantics.rs @@ -0,0 +1,75 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that move restrictions are enforced on overloaded binary operations + +use std::ops::Add; + +fn double_move>(x: T) { + x + + + x; //~ ERROR: use of moved value +} + +fn move_then_borrow + Clone>(x: T) { + x + + + x.clone(); //~ ERROR: use of moved value +} + +fn move_borrowed>(x: T, mut y: T) { + let m = &x; + let n = &mut y; + + x //~ ERROR: cannot move out of `x` because it is borrowed + + + y; //~ ERROR: cannot move out of `y` because it is borrowed +} + +fn illegal_dereference>(mut x: T, y: T) { + let m = &mut x; + let n = &y; + + *m //~ ERROR: cannot move out of borrowed content + + + *n; //~ ERROR: cannot move out of borrowed content +} + +struct Foo; + +impl<'a, 'b> Add<&'b Foo> for &'a mut Foo { + type Output = (); + + fn add(self, _: &Foo) {} +} + +impl<'a, 'b> Add<&'b mut Foo> for &'a Foo { + type Output = (); + + fn add(self, _: &mut Foo) {} +} + +fn mut_plus_immut() { + let mut f = Foo; + + &mut f + + + &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable +} + +fn immut_plus_mut() { + let mut f = Foo; + + &f + + + &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/binop-move-semantics.stderr b/src/test/ui/compile-fail-migration/binop-move-semantics.stderr new file mode 100644 index 00000000000..81b8a336a20 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-move-semantics.stderr @@ -0,0 +1,80 @@ +error[E0382]: use of moved value: `x` + --> $DIR/binop-move-semantics.rs:18:5 + | +LL | x + | - value moved here +LL | + +LL | x; //~ ERROR: use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/binop-move-semantics.rs:24:5 + | +LL | x + | - value moved here +LL | + +LL | x.clone(); //~ ERROR: use of moved value + | ^ value used here after move + | + = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/binop-move-semantics.rs:31:5 + | +LL | let m = &x; + | - borrow of `x` occurs here +... +LL | x //~ ERROR: cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here + +error[E0505]: cannot move out of `y` because it is borrowed + --> $DIR/binop-move-semantics.rs:33:5 + | +LL | let n = &mut y; + | - borrow of `y` occurs here +... +LL | y; //~ ERROR: cannot move out of `y` because it is borrowed + | ^ move out of `y` occurs here + +error[E0507]: cannot move out of borrowed content + --> $DIR/binop-move-semantics.rs:40:5 + | +LL | *m //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/binop-move-semantics.rs:42:5 + | +LL | *n; //~ ERROR: cannot move out of borrowed content + | ^^ cannot move out of borrowed content + +error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable + --> $DIR/binop-move-semantics.rs:64:6 + | +LL | &mut f + | - mutable borrow occurs here +LL | + +LL | &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable + | ^ + | | + | immutable borrow occurs here + | mutable borrow ends here + +error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable + --> $DIR/binop-move-semantics.rs:72:10 + | +LL | &f + | - immutable borrow occurs here +LL | + +LL | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable + | ^ + | | + | mutable borrow occurs here + | immutable borrow ends here + +error: aborting due to 8 previous errors + +Some errors occurred: E0382, E0502, E0505, E0507. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/binop-mul-bool.rs b/src/test/ui/compile-fail-migration/binop-mul-bool.rs new file mode 100644 index 00000000000..a36477fc183 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-mul-bool.rs @@ -0,0 +1,13 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:`*` cannot be applied to type `bool` + +fn main() { let x = true * false; } diff --git a/src/test/ui/compile-fail-migration/binop-mul-bool.stderr b/src/test/ui/compile-fail-migration/binop-mul-bool.stderr new file mode 100644 index 00000000000..1df50876c26 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-mul-bool.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `*` cannot be applied to type `bool` + --> $DIR/binop-mul-bool.rs:13:21 + | +LL | fn main() { let x = true * false; } + | ^^^^^^^^^^^^ + | + = note: an implementation of `std::ops::Mul` might be missing for `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/binop-typeck.rs b/src/test/ui/compile-fail-migration/binop-typeck.rs new file mode 100644 index 00000000000..8f17288e991 --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-typeck.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// issue #500 + +fn main() { + let x = true; + let y = 1; + let z = x + y; + //~^ ERROR binary operation `+` cannot be applied to type `bool` +} diff --git a/src/test/ui/compile-fail-migration/binop-typeck.stderr b/src/test/ui/compile-fail-migration/binop-typeck.stderr new file mode 100644 index 00000000000..1ff81779f3d --- /dev/null +++ b/src/test/ui/compile-fail-migration/binop-typeck.stderr @@ -0,0 +1,11 @@ +error[E0369]: binary operation `+` cannot be applied to type `bool` + --> $DIR/binop-typeck.rs:16:13 + | +LL | let z = x + y; + | ^^^^^ + | + = note: an implementation of `std::ops::Add` might be missing for `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0369`. diff --git a/src/test/ui/compile-fail-migration/blind-item-block-item-shadow.rs b/src/test/ui/compile-fail-migration/blind-item-block-item-shadow.rs new file mode 100644 index 00000000000..eeadecf627d --- /dev/null +++ b/src/test/ui/compile-fail-migration/blind-item-block-item-shadow.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { pub struct Bar; } + +fn main() { + { + struct Bar; + use foo::Bar; + //~^ ERROR the name `Bar` is defined multiple times + } +} diff --git a/src/test/ui/compile-fail-migration/blind-item-block-item-shadow.stderr b/src/test/ui/compile-fail-migration/blind-item-block-item-shadow.stderr new file mode 100644 index 00000000000..5adc953e405 --- /dev/null +++ b/src/test/ui/compile-fail-migration/blind-item-block-item-shadow.stderr @@ -0,0 +1,17 @@ +error[E0255]: the name `Bar` is defined multiple times + --> $DIR/blind-item-block-item-shadow.rs:16:13 + | +LL | struct Bar; + | ----------- previous definition of the type `Bar` here +LL | use foo::Bar; + | ^^^^^^^^ `Bar` reimported here + | + = note: `Bar` must be defined only once in the type namespace of this block +help: You can use `as` to change the binding name of the import + | +LL | use foo::Bar as OtherBar; + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0255`. diff --git a/src/test/ui/compile-fail-migration/blind-item-block-middle.rs b/src/test/ui/compile-fail-migration/blind-item-block-middle.rs new file mode 100644 index 00000000000..a501a5cd3ec --- /dev/null +++ b/src/test/ui/compile-fail-migration/blind-item-block-middle.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { pub struct bar; } + +fn main() { + let bar = 5; + //~^ ERROR mismatched types + use foo::bar; +} diff --git a/src/test/ui/compile-fail-migration/blind-item-block-middle.stderr b/src/test/ui/compile-fail-migration/blind-item-block-middle.stderr new file mode 100644 index 00000000000..0123fd01173 --- /dev/null +++ b/src/test/ui/compile-fail-migration/blind-item-block-middle.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/blind-item-block-middle.rs:14:9 + | +LL | let bar = 5; + | ^^^ expected integral variable, found struct `foo::bar` + | + = note: expected type `{integer}` + found type `foo::bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.nll.stderr b/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.nll.stderr new file mode 100644 index 00000000000..631add3e62d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.nll.stderr @@ -0,0 +1,76 @@ +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:25:27 + | +LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign + | ^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/borrow-immutable-upvar-mutation.rs:25:24 + | +LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign + | ^^^^^^^^^ + +error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:28:31 + | +LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/borrow-immutable-upvar-mutation.rs:28:24 + | +LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow + | ^^^^^^^^^^^^^^ + +error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:31:55 + | +LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign + | ^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/borrow-immutable-upvar-mutation.rs:31:52 + | +LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign + | ^^^^^^^^^ + +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:37:32 + | +LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign + | ^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/borrow-immutable-upvar-mutation.rs:37:24 + | +LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign + | ^^^^^^^^^^^^^^ + +error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:40:36 + | +LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/borrow-immutable-upvar-mutation.rs:40:24 + | +LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow + | ^^^^^^^^^^^^^^^^^^^ + +error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:43:65 + | +LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign + | ^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/borrow-immutable-upvar-mutation.rs:43:57 + | +LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign + | ^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.rs b/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.rs new file mode 100644 index 00000000000..00f51973a41 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.rs @@ -0,0 +1,45 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +// Tests that we can't assign to or mutably borrow upvars from `Fn` +// closures (issue #17780) + +fn set(x: &mut usize) { *x = 5; } + +fn to_fn>(f: F) -> F { f } +fn to_fn_mut>(f: F) -> F { f } + +fn main() { + // By-ref captures + { + let mut x = 0; + let _f = to_fn(|| x = 42); //~ ERROR cannot assign + + let mut y = 0; + let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow + + let mut z = 0; + let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign + } + + // By-value captures + { + let mut x = 0; + let _f = to_fn(move || x = 42); //~ ERROR cannot assign + + let mut y = 0; + let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow + + let mut z = 0; + let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign + } +} diff --git a/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.stderr b/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.stderr new file mode 100644 index 00000000000..740e1820f4f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrow-immutable-upvar-mutation.stderr @@ -0,0 +1,78 @@ +error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:25:27 + | +LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign + | ^^^^^^ + | +help: consider changing this closure to take self by mutable reference + --> $DIR/borrow-immutable-upvar-mutation.rs:25:24 + | +LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign + | ^^^^^^^^^ + +error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:28:36 + | +LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow + | ^ + | +help: consider changing this closure to take self by mutable reference + --> $DIR/borrow-immutable-upvar-mutation.rs:28:24 + | +LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow + | ^^^^^^^^^^^^^^ + +error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:31:55 + | +LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign + | ^^^^^^ + | +help: consider changing this closure to take self by mutable reference + --> $DIR/borrow-immutable-upvar-mutation.rs:31:52 + | +LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign + | ^^^^^^^^^ + +error[E0594]: cannot assign to captured outer variable in an `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:37:32 + | +LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign + | ^^^^^^ + | + = note: `Fn` closures cannot capture their enclosing environment for modifications +help: consider changing this closure to take self by mutable reference + --> $DIR/borrow-immutable-upvar-mutation.rs:37:24 + | +LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign + | ^^^^^^^^^^^^^^ + +error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable + --> $DIR/borrow-immutable-upvar-mutation.rs:40:41 + | +LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow + | ^ + | +help: consider changing this closure to take self by mutable reference + --> $DIR/borrow-immutable-upvar-mutation.rs:40:24 + | +LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow + | ^^^^^^^^^^^^^^^^^^^ + +error[E0594]: cannot assign to captured outer variable in an `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:43:65 + | +LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign + | ^^^^^^ + | + = note: `Fn` closures cannot capture their enclosing environment for modifications +help: consider changing this closure to take self by mutable reference + --> $DIR/borrow-immutable-upvar-mutation.rs:43:57 + | +LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign + | ^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +Some errors occurred: E0387, E0594, E0596. +For more information about an error, try `rustc --explain E0387`. diff --git a/src/test/ui/compile-fail-migration/borrow-tuple-fields.rs b/src/test/ui/compile-fail-migration/borrow-tuple-fields.rs new file mode 100644 index 00000000000..f3417fafe90 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrow-tuple-fields.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct Foo(Box, isize); + +struct Bar(isize, isize); + +fn main() { + let x: (Box<_>, _) = (box 1, 2); + let r = &x.0; + let y = x; //~ ERROR cannot move out of `x` because it is borrowed + + let mut x = (1, 2); + let a = &x.0; + let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as + + let mut x = (1, 2); + let a = &mut x.0; + let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time + + + let x = Foo(box 1, 2); + let r = &x.0; + let y = x; //~ ERROR cannot move out of `x` because it is borrowed + + let mut x = Bar(1, 2); + let a = &x.0; + let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as + + let mut x = Bar(1, 2); + let a = &mut x.0; + let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time +} diff --git a/src/test/ui/compile-fail-migration/borrow-tuple-fields.stderr b/src/test/ui/compile-fail-migration/borrow-tuple-fields.stderr new file mode 100644 index 00000000000..71dc21123e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrow-tuple-fields.stderr @@ -0,0 +1,63 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrow-tuple-fields.rs:20:9 + | +LL | let r = &x.0; + | --- borrow of `x.0` occurs here +LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here + +error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable + --> $DIR/borrow-tuple-fields.rs:24:18 + | +LL | let a = &x.0; + | --- immutable borrow occurs here +LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as + | ^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0499]: cannot borrow `x.0` as mutable more than once at a time + --> $DIR/borrow-tuple-fields.rs:28:18 + | +LL | let a = &mut x.0; + | --- first mutable borrow occurs here +LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time + | ^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrow-tuple-fields.rs:33:9 + | +LL | let r = &x.0; + | --- borrow of `x.0` occurs here +LL | let y = x; //~ ERROR cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here + +error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable + --> $DIR/borrow-tuple-fields.rs:37:18 + | +LL | let a = &x.0; + | --- immutable borrow occurs here +LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as + | ^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0499]: cannot borrow `x.0` as mutable more than once at a time + --> $DIR/borrow-tuple-fields.rs:41:18 + | +LL | let a = &mut x.0; + | --- first mutable borrow occurs here +LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time + | ^^^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error: aborting due to 6 previous errors + +Some errors occurred: E0499, E0502, E0505. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.nll.stderr new file mode 100644 index 00000000000..0df5e0c6e66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.nll.stderr @@ -0,0 +1,53 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/borrowck-access-permissions.rs:22:19 + | +LL | let x = 1; + | - help: consider changing this to be mutable: `mut x` +... +LL | let _y1 = &mut x; //[ast]~ ERROR [E0596] + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable static item `static_x` as mutable + --> $DIR/borrowck-access-permissions.rs:28:19 + | +LL | let _y1 = &mut static_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable + --> $DIR/borrowck-access-permissions.rs:37:19 + | +LL | let box_x = Box::new(1); + | ----- help: consider changing this to be mutable: `mut box_x` +... +LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-access-permissions.rs:46:19 + | +LL | let ref_x = &x; + | -- help: consider changing this to be a mutable reference: `&mut x` +... +LL | let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + +error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer + --> $DIR/borrowck-access-permissions.rs:56:23 + | +LL | let ptr_x : *const _ = &x; + | -- help: consider changing this to be a mutable pointer: `&mut x` +... +LL | let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable + +error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-access-permissions.rs:66:18 + | +LL | let foo_ref = &foo; + | ---- help: consider changing this to be a mutable reference: `&mut foo` +LL | let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] + | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.stderr new file mode 100644 index 00000000000..b17245673e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.ast.stderr @@ -0,0 +1,46 @@ +error[E0596]: cannot borrow immutable local variable `x` as mutable + --> $DIR/borrowck-access-permissions.rs:22:24 + | +LL | let x = 1; + | - consider changing this to `mut x` +... +LL | let _y1 = &mut x; //[ast]~ ERROR [E0596] + | ^ cannot borrow mutably + +error[E0596]: cannot borrow immutable static item as mutable + --> $DIR/borrowck-access-permissions.rs:28:24 + | +LL | let _y1 = &mut static_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^ + +error[E0596]: cannot borrow immutable `Box` content `*box_x` as mutable + --> $DIR/borrowck-access-permissions.rs:37:24 + | +LL | let box_x = Box::new(1); + | ----- consider changing this to `mut box_x` +... +LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content `*ref_x` as mutable + --> $DIR/borrowck-access-permissions.rs:46:24 + | +LL | let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable dereference of raw pointer `*ptr_x` as mutable + --> $DIR/borrowck-access-permissions.rs:56:28 + | +LL | let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] + | ^^^^^^ cannot borrow as mutable + +error[E0389]: cannot borrow data mutably in a `&` reference + --> $DIR/borrowck-access-permissions.rs:66:23 + | +LL | let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] + | ^^^^^^^^^^ assignment into an immutable reference + +error: aborting due to 6 previous errors + +Some errors occurred: E0389, E0596. +For more information about an error, try `rustc --explain E0389`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.mir.stderr new file mode 100644 index 00000000000..0df5e0c6e66 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.mir.stderr @@ -0,0 +1,53 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/borrowck-access-permissions.rs:22:19 + | +LL | let x = 1; + | - help: consider changing this to be mutable: `mut x` +... +LL | let _y1 = &mut x; //[ast]~ ERROR [E0596] + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable static item `static_x` as mutable + --> $DIR/borrowck-access-permissions.rs:28:19 + | +LL | let _y1 = &mut static_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable + --> $DIR/borrowck-access-permissions.rs:37:19 + | +LL | let box_x = Box::new(1); + | ----- help: consider changing this to be mutable: `mut box_x` +... +LL | let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-access-permissions.rs:46:19 + | +LL | let ref_x = &x; + | -- help: consider changing this to be a mutable reference: `&mut x` +... +LL | let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable + +error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer + --> $DIR/borrowck-access-permissions.rs:56:23 + | +LL | let ptr_x : *const _ = &x; + | -- help: consider changing this to be a mutable pointer: `&mut x` +... +LL | let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] + | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable + +error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-access-permissions.rs:66:18 + | +LL | let foo_ref = &foo; + | ---- help: consider changing this to be a mutable reference: `&mut foo` +LL | let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] + | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.rs new file mode 100644 index 00000000000..00a3da86074 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-access-permissions.rs @@ -0,0 +1,70 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +static static_x : i32 = 1; +static mut static_x_mut : i32 = 1; + +fn main() { + let x = 1; + let mut x_mut = 1; + + { // borrow of local + let _y1 = &mut x; //[ast]~ ERROR [E0596] + //[mir]~^ ERROR [E0596] + let _y2 = &mut x_mut; // No error + } + + { // borrow of static + let _y1 = &mut static_x; //[ast]~ ERROR [E0596] + //[mir]~^ ERROR [E0596] + unsafe { let _y2 = &mut static_x_mut; } // No error + } + + { // borrow of deref to box + let box_x = Box::new(1); + let mut box_x_mut = Box::new(1); + + let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] + //[mir]~^ ERROR [E0596] + let _y2 = &mut *box_x_mut; // No error + } + + { // borrow of deref to reference + let ref_x = &x; + let ref_x_mut = &mut x_mut; + + let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] + //[mir]~^ ERROR [E0596] + let _y2 = &mut *ref_x_mut; // No error + } + + { // borrow of deref to pointer + let ptr_x : *const _ = &x; + let ptr_mut_x : *mut _ = &mut x_mut; + + unsafe { + let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] + //[mir]~^ ERROR [E0596] + let _y2 = &mut *ptr_mut_x; // No error + } + } + + { // borrowing mutably through an immutable reference + struct Foo<'a> { f: &'a mut i32, g: &'a i32 }; + let mut foo = Foo { f: &mut x_mut, g: &x }; + let foo_ref = &foo; + let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] + //[mir]~^ ERROR [E0596] + // FIXME: Wrong error in MIR + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.nll.stderr new file mode 100644 index 00000000000..0b1b157f3e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `i` + --> $DIR/borrowck-and-init.rs:15:20 + | +LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + | ^ use of possibly uninitialized `i` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.rs new file mode 100644 index 00000000000..92f16d8ffce --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let i: isize; + + println!("{}", false && { i = 5; true }); + println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.stderr new file mode 100644 index 00000000000..2cbc57d66e9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-and-init.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `i` + --> $DIR/borrowck-and-init.rs:15:20 + | +LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + | ^ use of possibly uninitialized `i` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.nll.stderr new file mode 100644 index 00000000000..0fe9106249b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.nll.stderr @@ -0,0 +1,40 @@ +error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-anon-fields-struct.rs:23:19 + | +LL | Y(ref mut a, _) => a + | --------- mutable borrow occurs here +... +LL | let b = match y { + | ^ immutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-anon-fields-struct.rs:38:19 + | +LL | Y(ref mut a, _) => a + | --------- mutable borrow occurs here +... +LL | let b = match y { + | ^ immutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error[E0499]: cannot borrow `y.0` as mutable more than once at a time + --> $DIR/borrowck-anon-fields-struct.rs:39:11 + | +LL | Y(ref mut a, _) => a + | --------- first mutable borrow occurs here +... +LL | Y(ref mut b, _) => b //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error: aborting due to 3 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.rs new file mode 100644 index 00000000000..5ee2b89dd98 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.rs @@ -0,0 +1,47 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that we are able to distinguish when loans borrow different +// anonymous fields of a tuple vs the same anonymous field. + +struct Y(usize, usize); + +fn distinct_variant() { + let mut y = Y(1, 2); + + let a = match y { + Y(ref mut a, _) => a + }; + + let b = match y { + Y(_, ref mut b) => b + }; + + *a += 1; + *b += 1; +} + +fn same_variant() { + let mut y = Y(1, 2); + + let a = match y { + Y(ref mut a, _) => a + }; + + let b = match y { + Y(ref mut b, _) => b //~ ERROR cannot borrow + }; + + *a += 1; + *b += 1; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.stderr new file mode 100644 index 00000000000..e635a2392e1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-struct.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `y.0` as mutable more than once at a time + --> $DIR/borrowck-anon-fields-struct.rs:39:11 + | +LL | Y(ref mut a, _) => a + | --------- first mutable borrow occurs here +... +LL | Y(ref mut b, _) => b //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.nll.stderr new file mode 100644 index 00000000000..015174a9e45 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.nll.stderr @@ -0,0 +1,40 @@ +error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-anon-fields-tuple.rs:21:19 + | +LL | (ref mut a, _) => a + | --------- mutable borrow occurs here +... +LL | let b = match y { + | ^ immutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-anon-fields-tuple.rs:36:19 + | +LL | (ref mut a, _) => a + | --------- mutable borrow occurs here +... +LL | let b = match y { + | ^ immutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error[E0499]: cannot borrow `y.0` as mutable more than once at a time + --> $DIR/borrowck-anon-fields-tuple.rs:37:10 + | +LL | (ref mut a, _) => a + | --------- first mutable borrow occurs here +... +LL | (ref mut b, _) => b //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error: aborting due to 3 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.rs new file mode 100644 index 00000000000..ebaed01756f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.rs @@ -0,0 +1,45 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that we are able to distinguish when loans borrow different +// anonymous fields of a tuple vs the same anonymous field. + +fn distinct_variant() { + let mut y = (1, 2); + + let a = match y { + (ref mut a, _) => a + }; + + let b = match y { + (_, ref mut b) => b + }; + + *a += 1; + *b += 1; +} + +fn same_variant() { + let mut y = (1, 2); + + let a = match y { + (ref mut a, _) => a + }; + + let b = match y { + (ref mut b, _) => b //~ ERROR cannot borrow + }; + + *a += 1; + *b += 1; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.stderr new file mode 100644 index 00000000000..d05d1c31f9d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-tuple.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `y.0` as mutable more than once at a time + --> $DIR/borrowck-anon-fields-tuple.rs:37:10 + | +LL | (ref mut a, _) => a + | --------- first mutable borrow occurs here +... +LL | (ref mut b, _) => b //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.nll.stderr new file mode 100644 index 00000000000..e4b9f2f2329 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.nll.stderr @@ -0,0 +1,40 @@ +error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-anon-fields-variant.rs:26:19 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- mutable borrow occurs here +... +LL | let b = match y { + | ^ immutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-anon-fields-variant.rs:43:19 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- mutable borrow occurs here +... +LL | let b = match y { + | ^ immutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error[E0499]: cannot borrow `y.0` as mutable more than once at a time + --> $DIR/borrowck-anon-fields-variant.rs:44:14 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- first mutable borrow occurs here +... +LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +... +LL | *a += 1; + | ------- borrow later used here + +error: aborting due to 3 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.rs new file mode 100644 index 00000000000..4e1b85283a6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.rs @@ -0,0 +1,53 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that we are able to distinguish when loans borrow different +// anonymous fields of an enum variant vs the same anonymous field. + +enum Foo { + X, Y(usize, usize) +} + +fn distinct_variant() { + let mut y = Foo::Y(1, 2); + + let a = match y { + Foo::Y(ref mut a, _) => a, + Foo::X => panic!() + }; + + let b = match y { + Foo::Y(_, ref mut b) => b, + Foo::X => panic!() + }; + + *a += 1; + *b += 1; +} + +fn same_variant() { + let mut y = Foo::Y(1, 2); + + let a = match y { + Foo::Y(ref mut a, _) => a, + Foo::X => panic!() + }; + + let b = match y { + Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow + Foo::X => panic!() + }; + + *a += 1; + *b += 1; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.stderr new file mode 100644 index 00000000000..817d0154a63 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-anon-fields-variant.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `y.0` as mutable more than once at a time + --> $DIR/borrowck-anon-fields-variant.rs:44:14 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- first mutable borrow occurs here +... +LL | Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.nll.stderr new file mode 100644 index 00000000000..4470566eabb --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.nll.stderr @@ -0,0 +1,35 @@ +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable + --> $DIR/borrowck-argument.rs:20:5 + | +LL | fn func(arg: S) { + | --- help: consider changing this to be mutable: `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument + | ^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable + --> $DIR/borrowck-argument.rs:25:9 + | +LL | fn method(&self, arg: S) { + | --- help: consider changing this to be mutable: `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument + | ^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable + --> $DIR/borrowck-argument.rs:31:9 + | +LL | fn default(&self, arg: S) { + | --- help: consider changing this to be mutable: `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument + | ^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable + --> $DIR/borrowck-argument.rs:42:17 + | +LL | (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument + | --- ^^^ cannot borrow as mutable + | | + | help: consider changing this to be mutable: `mut arg` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.rs new file mode 100644 index 00000000000..3230689e53c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.rs @@ -0,0 +1,43 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Copy, Clone)] +struct S; + +impl S { + fn mutate(&mut self) { + } +} + +fn func(arg: S) { + arg.mutate(); //~ ERROR: cannot borrow immutable argument +} + +impl S { + fn method(&self, arg: S) { + arg.mutate(); //~ ERROR: cannot borrow immutable argument + } +} + +trait T { + fn default(&self, arg: S) { + arg.mutate(); //~ ERROR: cannot borrow immutable argument + } +} + +impl T for S {} + +fn main() { + let s = S; + func(s); + s.method(s); + s.default(s); + (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.stderr new file mode 100644 index 00000000000..2a7a7b3ffee --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-argument.stderr @@ -0,0 +1,35 @@ +error[E0596]: cannot borrow immutable argument `arg` as mutable + --> $DIR/borrowck-argument.rs:20:5 + | +LL | fn func(arg: S) { + | --- consider changing this to `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument + | ^^^ cannot borrow mutably + +error[E0596]: cannot borrow immutable argument `arg` as mutable + --> $DIR/borrowck-argument.rs:25:9 + | +LL | fn method(&self, arg: S) { + | --- consider changing this to `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument + | ^^^ cannot borrow mutably + +error[E0596]: cannot borrow immutable argument `arg` as mutable + --> $DIR/borrowck-argument.rs:31:9 + | +LL | fn default(&self, arg: S) { + | --- consider changing this to `mut arg` +LL | arg.mutate(); //~ ERROR: cannot borrow immutable argument + | ^^^ cannot borrow mutably + +error[E0596]: cannot borrow immutable argument `arg` as mutable + --> $DIR/borrowck-argument.rs:42:17 + | +LL | (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument + | --- ^^^ cannot borrow mutably + | | + | consider changing this to `mut arg` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.nll.stderr new file mode 100644 index 00000000000..6936d32a789 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.nll.stderr @@ -0,0 +1,79 @@ +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-asm.rs:37:17 + | +LL | asm!("nop" : : "r"(x)); + | - value moved here +LL | } +LL | let z = x; //[ast]~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-asm.rs:45:32 + | +LL | let y = &mut x; + | ------ borrow of `x` occurs here +LL | unsafe { +LL | asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use + | ^ use of borrowed `x` +... +LL | let z = y; + | - borrow later used here + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-asm.rs:54:13 + | +LL | let x = 3; + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | unsafe { +LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice + | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-asm.rs:70:13 + | +LL | let x = 3; + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | unsafe { +LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice + | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-asm.rs:78:13 + | +LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable + | ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `x` + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-asm.rs:87:13 + | +LL | let y = &*x; + | --- borrow of `x` occurs here +LL | unsafe { +LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed + | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here +... +LL | let z = y; + | - borrow later used here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-asm.rs:96:40 + | +LL | asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value + | - ^ value used here after move + | | + | value moved here + | + = note: move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait + +error: aborting due to 7 previous errors + +Some errors occurred: E0381, E0382, E0384, E0503, E0506. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.stderr new file mode 100644 index 00000000000..e2e54aa9b8a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.ast.stderr @@ -0,0 +1,76 @@ +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-asm.rs:37:13 + | +LL | asm!("nop" : : "r"(x)); + | - value moved here +LL | } +LL | let z = x; //[ast]~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-asm.rs:45:32 + | +LL | let y = &mut x; + | - borrow of `x` occurs here +LL | unsafe { +LL | asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use + | ^ use of borrowed `x` + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-asm.rs:54:13 + | +LL | let x = 3; + | - first assignment to `x` +LL | unsafe { +LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice + | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error[E0506]: cannot assign to `a` because it is borrowed + --> $DIR/borrowck-asm.rs:60:13 + | +LL | let b = &*a; + | -- borrow of `a` occurs here +LL | unsafe { +LL | asm!("nop" : "=r"(a)); //[ast]~ ERROR cannot assign to `a` because it is borrowed + | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `a` occurs here + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-asm.rs:70:13 + | +LL | let x = 3; + | - first assignment to `x` +LL | unsafe { +LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice + | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-asm.rs:78:32 + | +LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable + | ^ use of possibly uninitialized `x` + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-asm.rs:87:13 + | +LL | let y = &*x; + | -- borrow of `x` occurs here +LL | unsafe { +LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed + | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-asm.rs:96:40 + | +LL | asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value + | - ^ value used here after move + | | + | value moved here + | + = note: move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait + +error: aborting due to 8 previous errors + +Some errors occurred: E0381, E0382, E0384, E0503, E0506. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.mir.stderr new file mode 100644 index 00000000000..6936d32a789 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.mir.stderr @@ -0,0 +1,79 @@ +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-asm.rs:37:17 + | +LL | asm!("nop" : : "r"(x)); + | - value moved here +LL | } +LL | let z = x; //[ast]~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-asm.rs:45:32 + | +LL | let y = &mut x; + | ------ borrow of `x` occurs here +LL | unsafe { +LL | asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use + | ^ use of borrowed `x` +... +LL | let z = y; + | - borrow later used here + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-asm.rs:54:13 + | +LL | let x = 3; + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | unsafe { +LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice + | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-asm.rs:70:13 + | +LL | let x = 3; + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | unsafe { +LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice + | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-asm.rs:78:13 + | +LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable + | ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `x` + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-asm.rs:87:13 + | +LL | let y = &*x; + | --- borrow of `x` occurs here +LL | unsafe { +LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed + | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here +... +LL | let z = y; + | - borrow later used here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-asm.rs:96:40 + | +LL | asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value + | - ^ value used here after move + | | + | value moved here + | + = note: move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait + +error: aborting due to 7 previous errors + +Some errors occurred: E0381, E0382, E0384, E0503, E0506. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.rs new file mode 100644 index 00000000000..d9816401b33 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-asm.rs @@ -0,0 +1,102 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-s390x +// ignore-emscripten +// ignore-powerpc +// ignore-powerpc64 +// ignore-powerpc64le +// ignore-sparc +// ignore-sparc64 + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(asm)] + +#[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "mips", + target_arch = "mips64"))] +mod test_cases { + fn is_move() { + let y: &mut isize; + let x = &mut 0isize; + unsafe { + asm!("nop" : : "r"(x)); + } + let z = x; //[ast]~ ERROR use of moved value: `x` + //[mir]~^ ERROR use of moved value: `x` + } + + fn in_is_read() { + let mut x = 3; + let y = &mut x; + unsafe { + asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use + //[mir]~^ ERROR cannot use + } + let z = y; + } + + fn out_is_assign() { + let x = 3; + unsafe { + asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice + //[mir]~^ ERROR cannot assign twice + } + let mut a = &mut 3; + let b = &*a; + unsafe { + asm!("nop" : "=r"(a)); //[ast]~ ERROR cannot assign to `a` because it is borrowed + // No MIR error, this is a shallow write. + } + let c = b; + let d = *a; + } + + fn rw_is_assign() { + let x = 3; + unsafe { + asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice + //[mir]~^ ERROR cannot assign twice + } + } + + fn indirect_is_not_init() { + let x: i32; + unsafe { + asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable + //[mir]~^ ERROR use of possibly uninitialized variable + } + } + + fn rw_is_read() { + let mut x = &mut 3; + let y = &*x; + unsafe { + asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed + //[mir]~^ ERROR cannot assign to `x` because it is borrowed + } + let z = y; + } + + fn two_moves() { + let x = &mut 2; + unsafe { + asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value + //[mir]~^ ERROR use of moved value + } + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.nll.stderr new file mode 100644 index 00000000000..f4568d7c9eb --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.nll.stderr @@ -0,0 +1,27 @@ +error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-assign-comp-idx.rs:22:5 + | +LL | let q: &isize = &p[0]; + | - immutable borrow occurs here +LL | +LL | p[0] = 5; //~ ERROR cannot borrow + | ^ mutable borrow occurs here +LL | +LL | println!("{}", *q); + | -- borrow later used here + +error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-assign-comp-idx.rs:37:9 + | +LL | / borrow( +LL | | &p, + | | -- immutable borrow occurs here +LL | | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable + | |_________^^_-_______- borrow later used here + | | | + | | second borrow occurs due to use of `p` in closure + | mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.rs new file mode 100644 index 00000000000..1e665a12a19 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.rs @@ -0,0 +1,49 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Point { + x: isize, + y: isize, +} + +fn a() { + let mut p = vec![1]; + + // Create an immutable pointer into p's contents: + let q: &isize = &p[0]; + + p[0] = 5; //~ ERROR cannot borrow + + println!("{}", *q); +} + +fn borrow(_x: &[isize], _f: F) where F: FnOnce() {} + +fn b() { + // here we alias the mutable vector into an imm slice and try to + // modify the original: + + let mut p = vec![1]; + + borrow( + &p, + || p[0] = 5); //~ ERROR cannot borrow `p` as mutable +} + +fn c() { + // Legal because the scope of the borrow does not include the + // modification: + let mut p = vec![1]; + borrow(&p, ||{}); + p[0] = 5; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.stderr new file mode 100644 index 00000000000..69a69b36fc7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp-idx.stderr @@ -0,0 +1,26 @@ +error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-assign-comp-idx.rs:22:5 + | +LL | let q: &isize = &p[0]; + | - immutable borrow occurs here +LL | +LL | p[0] = 5; //~ ERROR cannot borrow + | ^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-assign-comp-idx.rs:37:9 + | +LL | &p, + | - immutable borrow occurs here +LL | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable + | ^^ - - immutable borrow ends here + | | | + | | borrow occurs due to use of `p` in closure + | mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.nll.stderr new file mode 100644 index 00000000000..2a1fbfd43bf --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.nll.stderr @@ -0,0 +1,37 @@ +error[E0506]: cannot assign to `p.x` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:23:5 + | +LL | let q = &p; + | -- borrow of `p.x` occurs here +... +LL | p.x = 5; //[ast]~ ERROR cannot assign to `p.x` + | ^^^^^^^ assignment to borrowed `p.x` occurs here +LL | //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed +LL | q.x; + | --- borrow later used here + +error[E0506]: cannot assign to `p` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:34:5 + | +LL | let q = &p.y; + | ---- borrow of `p` occurs here +LL | p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` + | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here +... +LL | *q; // stretch loan + | -- borrow later used here + +error[E0506]: cannot assign to `p.y` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:46:5 + | +LL | let q = &p.y; + | ---- borrow of `p.y` occurs here +LL | p.y = 5; //[ast]~ ERROR cannot assign to `p.y` + | ^^^^^^^ assignment to borrowed `p.y` occurs here +LL | //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed +LL | *q; + | -- borrow later used here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.stderr new file mode 100644 index 00000000000..9e5e0e197a9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.ast.stderr @@ -0,0 +1,28 @@ +error[E0506]: cannot assign to `p.x` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:23:5 + | +LL | let q = &p; + | - borrow of `p.x` occurs here +... +LL | p.x = 5; //[ast]~ ERROR cannot assign to `p.x` + | ^^^^^^^ assignment to borrowed `p.x` occurs here + +error[E0506]: cannot assign to `p` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:34:5 + | +LL | let q = &p.y; + | --- borrow of `p` occurs here +LL | p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` + | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here + +error[E0506]: cannot assign to `p.y` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:46:5 + | +LL | let q = &p.y; + | --- borrow of `p.y` occurs here +LL | p.y = 5; //[ast]~ ERROR cannot assign to `p.y` + | ^^^^^^^ assignment to borrowed `p.y` occurs here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.mir.stderr new file mode 100644 index 00000000000..2a1fbfd43bf --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.mir.stderr @@ -0,0 +1,37 @@ +error[E0506]: cannot assign to `p.x` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:23:5 + | +LL | let q = &p; + | -- borrow of `p.x` occurs here +... +LL | p.x = 5; //[ast]~ ERROR cannot assign to `p.x` + | ^^^^^^^ assignment to borrowed `p.x` occurs here +LL | //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed +LL | q.x; + | --- borrow later used here + +error[E0506]: cannot assign to `p` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:34:5 + | +LL | let q = &p.y; + | ---- borrow of `p` occurs here +LL | p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` + | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here +... +LL | *q; // stretch loan + | -- borrow later used here + +error[E0506]: cannot assign to `p.y` because it is borrowed + --> $DIR/borrowck-assign-comp.rs:46:5 + | +LL | let q = &p.y; + | ---- borrow of `p.y` occurs here +LL | p.y = 5; //[ast]~ ERROR cannot assign to `p.y` + | ^^^^^^^ assignment to borrowed `p.y` occurs here +LL | //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed +LL | *q; + | -- borrow later used here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.rs new file mode 100644 index 00000000000..d68420eb205 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-comp.rs @@ -0,0 +1,52 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct point { x: isize, y: isize } + +fn a() { + let mut p = point {x: 3, y: 4}; + let q = &p; + + // This assignment is illegal because the field x is not + // inherently mutable; since `p` was made immutable, `p.x` is now + // immutable. Otherwise the type of &_q.x (&isize) would be wrong. + p.x = 5; //[ast]~ ERROR cannot assign to `p.x` + //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed + q.x; +} + +fn c() { + // this is sort of the opposite. We take a loan to the interior of `p` + // and then try to overwrite `p` as a whole. + + let mut p = point {x: 3, y: 4}; + let q = &p.y; + p = point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` + //[mir]~^ ERROR cannot assign to `p` because it is borrowed + p.x; // silence warning + *q; // stretch loan +} + +fn d() { + // just for completeness's sake, the easy case, where we take the + // address of a subcomponent and then modify that subcomponent: + + let mut p = point {x: 3, y: 4}; + let q = &p.y; + p.y = 5; //[ast]~ ERROR cannot assign to `p.y` + //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed + *q; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr new file mode 100644 index 00000000000..eb4c1ff025b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr @@ -0,0 +1,19 @@ +error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference + --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:19:5 + | +LL | fn a(s: &S) { + | -- help: consider changing this to be a mutable reference: `&mut S<'_>` +LL | *s.pointer += 1; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written + +error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference + --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:27:5 + | +LL | fn c(s: & &mut S) { + | -------- help: consider changing this to be a mutable reference: `&mut &mut S<'_>` +LL | *s.pointer += 1; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs new file mode 100644 index 00000000000..d66cdb99a74 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that assignments to an `&mut` pointer which is found in a +// borrowed (but otherwise non-aliasable) location is illegal. + +struct S<'a> { + pointer: &'a mut isize +} + +fn a(s: &S) { + *s.pointer += 1; //~ ERROR cannot assign +} + +fn b(s: &mut S) { + *s.pointer += 1; +} + +fn c(s: & &mut S) { + *s.pointer += 1; //~ ERROR cannot assign +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr new file mode 100644 index 00000000000..4fb65988eee --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr @@ -0,0 +1,19 @@ +error[E0389]: cannot assign to data in a `&` reference + --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:19:5 + | +LL | fn a(s: &S) { + | -- use `&mut S` here to make mutable +LL | *s.pointer += 1; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^ assignment into an immutable reference + +error[E0389]: cannot assign to data in a `&` reference + --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:27:5 + | +LL | fn c(s: & &mut S) { + | -------- use `&mut &mut S` here to make mutable +LL | *s.pointer += 1; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^ assignment into an immutable reference + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0389`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr new file mode 100644 index 00000000000..8ca7229b42a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr @@ -0,0 +1,24 @@ +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed + --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:28:9 + | +LL | let z = copy_borrowed_ptr(&mut y); + | ------ borrow of `y` occurs here +LL | *y.pointer += 1; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^ use of borrowed `y` +LL | *z.pointer += 1; + | --------------- borrow later used here + +error[E0506]: cannot assign to `*y.pointer` because it is borrowed + --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:28:9 + | +LL | let z = copy_borrowed_ptr(&mut y); + | ------ borrow of `*y.pointer` occurs here +LL | *y.pointer += 1; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here +LL | *z.pointer += 1; + | --------------- borrow later used here + +error: aborting due to 2 previous errors + +Some errors occurred: E0503, E0506. +For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs new file mode 100644 index 00000000000..77aa57ef1b5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs @@ -0,0 +1,31 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that assignments to an `&mut` pointer which is found in a +// borrowed (but otherwise non-aliasable) location is illegal. + +struct S<'a> { + pointer: &'a mut isize +} + +fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> { + S { pointer: &mut *p.pointer } +} + +fn main() { + let mut x = 1; + + { + let mut y = S { pointer: &mut x }; + let z = copy_borrowed_ptr(&mut y); + *y.pointer += 1; //~ ERROR cannot assign + *z.pointer += 1; + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr new file mode 100644 index 00000000000..9a7c8330505 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr @@ -0,0 +1,11 @@ +error[E0506]: cannot assign to `*y.pointer` because it is borrowed + --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:28:9 + | +LL | let z = copy_borrowed_ptr(&mut y); + | - borrow of `*y.pointer` occurs here +LL | *y.pointer += 1; //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.nll.stderr new file mode 100644 index 00000000000..861fe2f2c50 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.nll.stderr @@ -0,0 +1,9 @@ +error[E0594]: cannot assign to immutable static item `foo` + --> $DIR/borrowck-assign-to-constants.rs:18:5 + | +LL | foo = 6; //[ast]~ ERROR cannot assign to immutable static item + | ^^^^^^^ cannot assign + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.stderr new file mode 100644 index 00000000000..09ddf8387ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.ast.stderr @@ -0,0 +1,9 @@ +error[E0594]: cannot assign to immutable static item + --> $DIR/borrowck-assign-to-constants.rs:18:5 + | +LL | foo = 6; //[ast]~ ERROR cannot assign to immutable static item + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.mir.stderr new file mode 100644 index 00000000000..861fe2f2c50 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.mir.stderr @@ -0,0 +1,9 @@ +error[E0594]: cannot assign to immutable static item `foo` + --> $DIR/borrowck-assign-to-constants.rs:18:5 + | +LL | foo = 6; //[ast]~ ERROR cannot assign to immutable static item + | ^^^^^^^ cannot assign + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.rs new file mode 100644 index 00000000000..57002dd40fc --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-assign-to-constants.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +static foo: isize = 5; + +fn main() { + // assigning to various global constants + foo = 6; //[ast]~ ERROR cannot assign to immutable static item + //[mir]~^ ERROR cannot assign to immutable static item `foo` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr new file mode 100644 index 00000000000..b41d5cd3623 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:25:5 + | +LL | let x = Foo { x: 3 }; + | - help: consider changing this to be mutable: `mut x` +LL | x.printme(); //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.rs new file mode 100644 index 00000000000..ea020dc0685 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that auto-ref can't create mutable aliases to immutable memory. + +struct Foo { + x: isize +} + +impl Foo { + pub fn printme(&mut self) { + println!("{}", self.x); + } +} + +fn main() { + let x = Foo { x: 3 }; + x.printme(); //~ ERROR cannot borrow +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr new file mode 100644 index 00000000000..ca6b86e5ca6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable local variable `x` as mutable + --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:25:5 + | +LL | let x = Foo { x: 3 }; + | - consider changing this to `mut x` +LL | x.printme(); //~ ERROR cannot borrow + | ^ cannot borrow mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.nll.stderr new file mode 100644 index 00000000000..eb26676cde2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.nll.stderr @@ -0,0 +1,22 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-autoref-3261.rs:25:9 + | +LL | (&mut x).with( + | -------- + | | + | _____first mutable borrow occurs here + | | +LL | | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time + | | ^^^^^ second mutable borrow occurs here +LL | | match opt { +LL | | &Either::Right(ref f) => { +LL | | x = X(Either::Left((0, 0))); + | | - second borrow occurs due to use of `x` in closure +... | +LL | | } +LL | | }) + | |__________- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.rs new file mode 100644 index 00000000000..d5f09305808 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Either { Left(T), Right(U) } + +struct X(Either<(usize,usize), fn()>); + +impl X { + pub fn with(&self, blk: F) where F: FnOnce(&Either<(usize, usize), fn()>) { + let X(ref e) = *self; + blk(e) + } +} + +fn main() { + let mut x = X(Either::Right(main as fn())); + (&mut x).with( + |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time + match opt { + &Either::Right(ref f) => { + x = X(Either::Left((0, 0))); + (*f)() + }, + _ => panic!() + } + }) +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.stderr new file mode 100644 index 00000000000..c9e649dee0c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-autoref-3261.stderr @@ -0,0 +1,17 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-autoref-3261.rs:25:9 + | +LL | (&mut x).with( + | - first mutable borrow occurs here +LL | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time + | ^^^^^ second mutable borrow occurs here +... +LL | x = X(Either::Left((0, 0))); + | - borrow occurs due to use of `x` in closure +... +LL | }) + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.nll.stderr new file mode 100644 index 00000000000..73f533a6b96 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.nll.stderr @@ -0,0 +1,25 @@ +error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:35:17 + | +LL | / add( +LL | | &*a, + | | --- immutable borrow occurs here +LL | | rewrite(&mut a)); //~ ERROR cannot borrow + | |_________________^^^^^^_- borrow later used here + | | + | mutable borrow occurs here + +error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:42:17 + | +LL | / add( +LL | | &*a, + | | --- immutable borrow occurs here +LL | | rewrite(&mut a)); //~ ERROR cannot borrow + | |_________________^^^^^^_- borrow later used here + | | + | mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.rs new file mode 100644 index 00000000000..7913f9ac903 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.rs @@ -0,0 +1,45 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we detect nested calls that could free pointers evaluated +// for earlier arguments. + +#![feature(box_syntax)] + +fn rewrite(v: &mut Box) -> usize { + *v = box 22; + **v +} + +fn add(v: &usize, w: usize) -> usize { + *v + w +} + +fn implicit() { + let mut a: Box<_> = box 1; + + // Note the danger here: + // + // the pointer for the first argument has already been + // evaluated, but it gets freed when evaluating the second + // argument! + add( + &*a, + rewrite(&mut a)); //~ ERROR cannot borrow +} + +fn explicit() { + let mut a: Box<_> = box 1; + add( + &*a, + rewrite(&mut a)); //~ ERROR cannot borrow +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.stderr new file mode 100644 index 00000000000..461d2fec589 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-free.stderr @@ -0,0 +1,23 @@ +error[E0502]: cannot borrow `a` as mutable because `*a` is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:35:22 + | +LL | &*a, + | -- immutable borrow occurs here +LL | rewrite(&mut a)); //~ ERROR cannot borrow + | ^ - immutable borrow ends here + | | + | mutable borrow occurs here + +error[E0502]: cannot borrow `a` as mutable because `*a` is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:42:22 + | +LL | &*a, + | -- immutable borrow occurs here +LL | rewrite(&mut a)); //~ ERROR cannot borrow + | ^ - immutable borrow ends here + | | + | mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.nll.stderr new file mode 100644 index 00000000000..ecb70068fed --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.nll.stderr @@ -0,0 +1,25 @@ +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/borrowck-bad-nested-calls-move.rs:35:9 + | +LL | / add( +LL | | &*a, + | | --- borrow of `*a` occurs here +LL | | a); //~ ERROR cannot move + | |_________^- borrow later used here + | | + | move out of `a` occurs here + +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/borrowck-bad-nested-calls-move.rs:42:9 + | +LL | / add( +LL | | &*a, + | | --- borrow of `*a` occurs here +LL | | a); //~ ERROR cannot move + | |_________^- borrow later used here + | | + | move out of `a` occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.rs new file mode 100644 index 00000000000..e24d4e87add --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.rs @@ -0,0 +1,45 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we detect nested calls that could free pointers evaluated +// for earlier arguments. + +#![feature(box_syntax)] + +fn rewrite(v: &mut Box) -> usize { + *v = box 22; + **v +} + +fn add(v: &usize, w: Box) -> usize { + *v + *w +} + +fn implicit() { + let mut a: Box<_> = box 1; + + // Note the danger here: + // + // the pointer for the first argument has already been + // evaluated, but it gets moved when evaluating the second + // argument! + add( + &*a, + a); //~ ERROR cannot move +} + +fn explicit() { + let mut a: Box<_> = box 1; + add( + &*a, + a); //~ ERROR cannot move +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.stderr new file mode 100644 index 00000000000..7ed1f2c6583 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-bad-nested-calls-move.stderr @@ -0,0 +1,19 @@ +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/borrowck-bad-nested-calls-move.rs:35:9 + | +LL | &*a, + | -- borrow of `*a` occurs here +LL | a); //~ ERROR cannot move + | ^ move out of `a` occurs here + +error[E0505]: cannot move out of `a` because it is borrowed + --> $DIR/borrowck-bad-nested-calls-move.rs:42:9 + | +LL | &*a, + | -- borrow of `*a` occurs here +LL | a); //~ ERROR cannot move + | ^ move out of `a` occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.nll.stderr new file mode 100644 index 00000000000..f3246c12bd9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.nll.stderr @@ -0,0 +1,11 @@ +error[E0381]: borrow of possibly uninitialized variable: `x` + --> $DIR/borrowck-block-unint.rs:14:11 + | +LL | force(|| { //~ ERROR capture of possibly uninitialized variable: `x` + | ^^ use of possibly uninitialized `x` +LL | println!("{}", x); + | - borrow occurs due to use in closure + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.rs new file mode 100644 index 00000000000..a09ee439245 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn force(f: F) where F: FnOnce() { f(); } +fn main() { + let x: isize; + force(|| { //~ ERROR capture of possibly uninitialized variable: `x` + println!("{}", x); + }); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.stderr new file mode 100644 index 00000000000..53aa8919fd8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-block-unint.stderr @@ -0,0 +1,9 @@ +error[E0381]: capture of possibly uninitialized variable: `x` + --> $DIR/borrowck-block-unint.rs:14:11 + | +LL | force(|| { //~ ERROR capture of possibly uninitialized variable: `x` + | ^^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr new file mode 100644 index 00000000000..08d66eb0344 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr @@ -0,0 +1,127 @@ +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:29:17 + | +LL | let bar1 = &mut foo.bar1; + | ------------- first mutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ second mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:36:17 + | +LL | let bar1 = &mut foo.bar1; + | ------------- mutable borrow occurs here +LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^ immutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:43:17 + | +LL | let bar1 = &foo.bar1; + | --------- immutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:72:11 + | +LL | let bar1 = &mut foo.bar1; + | ------------- mutable borrow occurs here +LL | match *foo { + | ^^^^ immutable borrow occurs here +... +LL | *bar1; + | ----- borrow later used here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:73:21 + | +LL | let bar1 = &mut foo.bar1; + | ------------- first mutable borrow occurs here +LL | match *foo { +LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} + | ^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:82:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &*foo; //~ ERROR cannot borrow +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:83:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow +LL | let _foo2 = &*foo; //~ ERROR cannot borrow + | ^^^^^ immutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:90:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ first mutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ second mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0499]: cannot borrow `*foo` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:97:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ first mutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^^^^^^ second mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:104:17 + | +LL | let bar1 = &foo.bar1.int1; + | -------------- immutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:111:17 + | +LL | let bar1 = &foo.bar1.int1; + | -------------- immutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^^^^^^ mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:132:16 + | +LL | let foo = make_foo(); + | --- help: consider changing this to be mutable: `mut foo` +LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ cannot borrow as mutable + +error: aborting due to 12 previous errors + +Some errors occurred: E0499, E0502, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.rs new file mode 100644 index 00000000000..e5091a92581 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.rs @@ -0,0 +1,144 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#[derive(Copy, Clone)] +struct Foo { + bar1: Bar, + bar2: Bar +} + +#[derive(Copy, Clone)] +struct Bar { + int1: isize, + int2: isize, +} + +fn make_foo() -> Box { panic!() } + +fn borrow_same_field_twice_mut_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_same_field_twice_mut_imm() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_same_field_twice_imm_mut() { + let mut foo = make_foo(); + let bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_same_field_twice_imm_imm() { + let mut foo = make_foo(); + let bar1 = &foo.bar1; + let _bar2 = &foo.bar1; + *bar1; +} + +fn borrow_both_fields_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_both_mut_pattern() { + let mut foo = make_foo(); + match *foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + //~^ ERROR cannot borrow + } +} + +fn borrow_var_and_pattern() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + match *foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR cannot borrow + } + *bar1; +} + +fn borrow_mut_and_base_imm() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR cannot borrow + let _foo2 = &*foo; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_mut_and_base_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_mut_and_base_mut2() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_imm_and_base_mut() { + let mut foo = make_foo(); + let bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_imm_and_base_mut2() { + let mut foo = make_foo(); + let bar1 = &foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_imm_and_base_imm() { + let mut foo = make_foo(); + let bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &*foo; + *bar1; +} + +fn borrow_mut_and_imm() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_mut_from_imm() { + let foo = make_foo(); + let bar1 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_long_path_both_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let foo1 = &mut foo.bar2.int2; //~ ERROR cannot borrow + *bar1; + *foo1; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.stderr new file mode 100644 index 00000000000..9fc030f604c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-owned-ptr.stderr @@ -0,0 +1,168 @@ +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:29:22 + | +LL | let bar1 = &mut foo.bar1; + | -------- first mutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here +LL | *bar1; +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:36:18 + | +LL | let bar1 = &mut foo.bar1; + | -------- mutable borrow occurs here +LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ immutable borrow occurs here +LL | *bar1; +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:43:22 + | +LL | let bar1 = &foo.bar1; + | -------- immutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | *bar1; +LL | } + | - immutable borrow ends here + +error[E0499]: cannot borrow `foo` (via `foo.bar2`) as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:57:22 + | +LL | let bar1 = &mut foo.bar1; + | -------- first mutable borrow occurs here (via `foo.bar1`) +LL | let _bar2 = &mut foo.bar2; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`) +LL | *bar1; +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `foo` (via `foo.bar2`) as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:64:42 + | +LL | Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + | ------------- ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`) + | | + | first mutable borrow occurs here (via `foo.bar1`) +LL | //~^ ERROR cannot borrow +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:73:21 + | +LL | let bar1 = &mut foo.bar1; + | -------- first mutable borrow occurs here +LL | match *foo { +LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} + | ^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:82:18 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `*foo` as immutable because `foo.bar1.int1` is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:83:18 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow +LL | let _foo2 = &*foo; //~ ERROR cannot borrow + | ^^^^ immutable borrow occurs here +LL | *bar1; +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:90:22 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- first mutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here +LL | *bar1; +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `*foo` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:97:22 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- first mutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^ second mutable borrow occurs here +LL | *bar1; +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:104:22 + | +LL | let bar1 = &foo.bar1.int1; + | ------------- immutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | *bar1; +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*foo` as mutable because `foo.bar1.int1` is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:111:22 + | +LL | let bar1 = &foo.bar1.int1; + | ------------- immutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^ mutable borrow occurs here +LL | *bar1; +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `foo` (via `foo.bar2`) as immutable because `foo` is also borrowed as mutable (via `foo.bar1`) + --> $DIR/borrowck-borrow-from-owned-ptr.rs:126:18 + | +LL | let bar1 = &mut foo.bar1; + | -------- mutable borrow occurs here (via `foo.bar1`) +LL | let _foo1 = &foo.bar2; //~ ERROR cannot borrow + | ^^^^^^^^ immutable borrow occurs here (via `foo.bar2`) +LL | *bar1; +LL | } + | - mutable borrow ends here + +error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:132:21 + | +LL | let foo = make_foo(); + | --- consider changing this to `mut foo` +LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0499]: cannot borrow `foo` (via `foo.bar2.int2`) as mutable more than once at a time + --> $DIR/borrowck-borrow-from-owned-ptr.rs:139:21 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- first mutable borrow occurs here (via `foo.bar1.int1`) +LL | let foo1 = &mut foo.bar2.int2; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2.int2`) +... +LL | } + | - first borrow ends here + +error: aborting due to 15 previous errors + +Some errors occurred: E0499, E0502, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.nll.stderr new file mode 100644 index 00000000000..8d1b9ca672a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.nll.stderr @@ -0,0 +1,127 @@ +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:28:17 + | +LL | let bar1 = &mut foo.bar1; + | ------------- first mutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ second mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:35:17 + | +LL | let bar1 = &mut foo.bar1; + | ------------- mutable borrow occurs here +LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^ immutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:42:17 + | +LL | let bar1 = &foo.bar1; + | --------- immutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:70:11 + | +LL | let bar1 = &mut foo.bar1; + | ------------- mutable borrow occurs here +LL | match foo { + | ^^^ immutable borrow occurs here +... +LL | *bar1; + | ----- borrow later used here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:71:21 + | +LL | let bar1 = &mut foo.bar1; + | ------------- first mutable borrow occurs here +LL | match foo { +LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} // + | ^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:80:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &foo; //~ ERROR cannot borrow +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:81:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow +LL | let _foo2 = &foo; //~ ERROR cannot borrow + | ^^^^ immutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:88:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ first mutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ second mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0499]: cannot borrow `foo` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:95:17 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------------ first mutable borrow occurs here +LL | let _foo2 = &mut foo; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:102:17 + | +LL | let bar1 = &foo.bar1.int1; + | -------------- immutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:109:17 + | +LL | let bar1 = &foo.bar1.int1; + | -------------- immutable borrow occurs here +LL | let _foo2 = &mut foo; //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | *bar1; + | ----- borrow later used here + +error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:130:16 + | +LL | let foo = make_foo(); + | --- help: consider changing this to be mutable: `mut foo` +LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ cannot borrow as mutable + +error: aborting due to 12 previous errors + +Some errors occurred: E0499, E0502, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.rs new file mode 100644 index 00000000000..440be93dfdc --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.rs @@ -0,0 +1,141 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Copy, Clone)] +struct Foo { + bar1: Bar, + bar2: Bar +} + +#[derive(Copy, Clone)] +struct Bar { + int1: isize, + int2: isize, +} + +fn make_foo() -> Foo { panic!() } + +fn borrow_same_field_twice_mut_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_same_field_twice_mut_imm() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_same_field_twice_imm_mut() { + let mut foo = make_foo(); + let bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_same_field_twice_imm_imm() { + let mut foo = make_foo(); + let bar1 = &foo.bar1; + let _bar2 = &foo.bar1; + *bar1; +} + +fn borrow_both_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; + *bar1; +} + +fn borrow_both_mut_pattern() { + let mut foo = make_foo(); + match foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + match foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} // + //~^ ERROR cannot borrow + } + *bar1; +} + +fn borrow_mut_and_base_imm() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR cannot borrow + let _foo2 = &foo; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_mut_and_base_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_mut_and_base_mut2() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let _foo2 = &mut foo; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_imm_and_base_mut() { + let mut foo = make_foo(); + let bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_imm_and_base_mut2() { + let mut foo = make_foo(); + let bar1 = &foo.bar1.int1; + let _foo2 = &mut foo; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_imm_and_base_imm() { + let mut foo = make_foo(); + let bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &foo; + *bar1; +} + +fn borrow_mut_and_imm() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; + *bar1; +} + +fn borrow_mut_from_imm() { + let foo = make_foo(); + let bar1 = &mut foo.bar1; //~ ERROR cannot borrow + *bar1; +} + +fn borrow_long_path_both_mut() { + let mut foo = make_foo(); + let bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; + *bar1; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.stderr new file mode 100644 index 00000000000..cd0d6aa4ca3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-stack-variable.stderr @@ -0,0 +1,124 @@ +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:28:22 + | +LL | let bar1 = &mut foo.bar1; + | -------- first mutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here +LL | *bar1; +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:35:18 + | +LL | let bar1 = &mut foo.bar1; + | -------- mutable borrow occurs here +LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ immutable borrow occurs here +LL | *bar1; +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:42:22 + | +LL | let bar1 = &foo.bar1; + | -------- immutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | *bar1; +LL | } + | - immutable borrow ends here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:71:21 + | +LL | let bar1 = &mut foo.bar1; + | -------- first mutable borrow occurs here +LL | match foo { +LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} // + | ^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:80:18 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `foo` as immutable because `foo.bar1.int1` is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:81:18 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow +LL | let _foo2 = &foo; //~ ERROR cannot borrow + | ^^^ immutable borrow occurs here +LL | *bar1; +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:88:22 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- first mutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here +LL | *bar1; +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `foo` as mutable more than once at a time + --> $DIR/borrowck-borrow-from-stack-variable.rs:95:22 + | +LL | let bar1 = &mut foo.bar1.int1; + | ------------- first mutable borrow occurs here +LL | let _foo2 = &mut foo; //~ ERROR cannot borrow + | ^^^ second mutable borrow occurs here +LL | *bar1; +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:102:22 + | +LL | let bar1 = &foo.bar1.int1; + | ------------- immutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | *bar1; +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `foo` as mutable because `foo.bar1.int1` is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:109:22 + | +LL | let bar1 = &foo.bar1.int1; + | ------------- immutable borrow occurs here +LL | let _foo2 = &mut foo; //~ ERROR cannot borrow + | ^^^ mutable borrow occurs here +LL | *bar1; +LL | } + | - immutable borrow ends here + +error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:130:21 + | +LL | let foo = make_foo(); + | --- consider changing this to `mut foo` +LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ cannot mutably borrow field of immutable binding + +error: aborting due to 11 previous errors + +Some errors occurred: E0499, E0502, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.rs new file mode 100644 index 00000000000..f7514df800d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test lifetimes are linked properly when we take reference +// to interior. + +fn id(x: T) -> T { x } + +struct Foo(isize); + +fn foo<'a>() -> &'a isize { + let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough + x +} + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.stderr new file mode 100644 index 00000000000..7dcfb3e3c87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-from-temporary.stderr @@ -0,0 +1,18 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/borrowck-borrow-from-temporary.rs:19:24 + | +LL | let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^^ temporary value does not live long enough +LL | x +LL | } + | - temporary value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 18:8... + --> $DIR/borrowck-borrow-from-temporary.rs:18:8 + | +LL | fn foo<'a>() -> &'a isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr new file mode 100644 index 00000000000..c2b7d790eea --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable + --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:22:5 + | +LL | let a: Box<_> = box A; + | - help: consider changing this to be mutable: `mut a` +LL | a.foo(); + | ^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs new file mode 100644 index 00000000000..3662e23a412 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct A; + +impl A { + fn foo(&mut self) { + } +} + +pub fn main() { + let a: Box<_> = box A; + a.foo(); + //~^ ERROR cannot borrow immutable `Box` content `*a` as mutable +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr new file mode 100644 index 00000000000..d852125a775 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable `Box` content `*a` as mutable + --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:22:5 + | +LL | let a: Box<_> = box A; + | - consider changing this to `mut a` +LL | a.foo(); + | ^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr new file mode 100644 index 00000000000..8c30e6ac002 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr @@ -0,0 +1,31 @@ +error[E0594]: cannot assign to `**t1` which is behind a `&` reference + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:5 + | +LL | let t1 = t0; + | -- help: consider changing this to be a mutable reference: `&mut &mut isize` +LL | let p: &isize = &**t0; +LL | **t1 = 22; //~ ERROR cannot assign + | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written + +error[E0502]: cannot borrow `**t0` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:24:21 + | +LL | let t1 = &mut *t0; + | -------- mutable borrow occurs here +LL | let p: &isize = &**t0; //~ ERROR cannot borrow + | ^^^^^ immutable borrow occurs here +LL | **t1 = 22; + | --------- borrow later used here + +error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:29:26 + | +LL | fn foo4(t0: & &mut isize) { + | ------------ help: consider changing this to be a mutable reference: `&mut &mut isize` +LL | let x: &mut isize = &mut **t0; //~ ERROR cannot borrow + | ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable + +error: aborting due to 3 previous errors + +Some errors occurred: E0502, E0594, E0596. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs new file mode 100644 index 00000000000..d60751eddc7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that attempt to reborrow an `&mut` pointer in an aliasable +// location yields an error. +// +// Example from src/librustc_borrowck/borrowck/README.md + +fn foo(t0: & &mut isize) { + let t1 = t0; + let p: &isize = &**t0; + **t1 = 22; //~ ERROR cannot assign +} + +fn foo3(t0: &mut &mut isize) { + let t1 = &mut *t0; + let p: &isize = &**t0; //~ ERROR cannot borrow + **t1 = 22; +} + +fn foo4(t0: & &mut isize) { + let x: &mut isize = &mut **t0; //~ ERROR cannot borrow + *x += 1; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr new file mode 100644 index 00000000000..f90ffa8c35a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -0,0 +1,29 @@ +error[E0389]: cannot assign to data in a `&` reference + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:5 + | +LL | **t1 = 22; //~ ERROR cannot assign + | ^^^^^^^^^ assignment into an immutable reference + +error[E0502]: cannot borrow `**t0` as immutable because `*t0` is also borrowed as mutable + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:24:22 + | +LL | let t1 = &mut *t0; + | --- mutable borrow occurs here +LL | let p: &isize = &**t0; //~ ERROR cannot borrow + | ^^^^ immutable borrow occurs here +LL | **t1 = 22; +LL | } + | - mutable borrow ends here + +error[E0389]: cannot borrow data mutably in a `&` reference + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:29:31 + | +LL | fn foo4(t0: & &mut isize) { + | ------------ use `&mut &mut isize` here to make mutable +LL | let x: &mut isize = &mut **t0; //~ ERROR cannot borrow + | ^^^^ assignment into an immutable reference + +error: aborting due to 3 previous errors + +Some errors occurred: E0389, E0502. +For more information about an error, try `rustc --explain E0389`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.rs new file mode 100644 index 00000000000..7175194355b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that `&mut` objects cannot be borrowed twice, just like +// other `&mut` pointers. + +trait Foo { + fn f1(&mut self) -> &(); + fn f2(&mut self); +} + +fn test(x: &mut Foo) { + let _y = x.f1(); + x.f2(); //~ ERROR cannot borrow `*x` as mutable +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.stderr new file mode 100644 index 00000000000..1812420e444 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-mut-object-twice.stderr @@ -0,0 +1,13 @@ +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/borrowck-borrow-mut-object-twice.rs:21:5 + | +LL | let _y = x.f1(); + | - first mutable borrow occurs here +LL | x.f2(); //~ ERROR cannot borrow `*x` as mutable + | ^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr new file mode 100644 index 00000000000..522cdfd94d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr @@ -0,0 +1,88 @@ +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:57:19 + | +LL | let __isize = &mut x.y; //~ ERROR cannot borrow + | ^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:61:19 + | +LL | let __isize = &mut x.y; //~ ERROR cannot borrow + | ^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:69:5 + | +LL | &mut x.y //~ ERROR cannot borrow + | ^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:73:5 + | +LL | &mut x.y //~ ERROR cannot borrow + | ^^^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:77:5 + | +LL | x.y = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot assign + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:81:5 + | +LL | x.y = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot assign + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:85:5 + | +LL | x.y = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot assign + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:93:5 + | +LL | x.set(0, 0); //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:97:5 + | +LL | x.set(0, 0); //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:105:5 + | +LL | x.y_mut() //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:109:5 + | +LL | x.y_mut() //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:113:6 + | +LL | *x.y_mut() = 3; //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:117:6 + | +LL | *x.y_mut() = 3; //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:121:6 + | +LL | *x.y_mut() = 3; //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error: aborting due to 14 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.rs new file mode 100644 index 00000000000..693ed29bd05 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.rs @@ -0,0 +1,124 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test how overloaded deref interacts with borrows when only +// Deref and not DerefMut is implemented. + +use std::ops::Deref; + +struct Rc { + value: *const T +} + +impl Deref for Rc { + type Target = T; + + fn deref(&self) -> &T { + unsafe { &*self.value } + } +} + +struct Point { + x: isize, + y: isize +} + +impl Point { + fn get(&self) -> (isize, isize) { + (self.x, self.y) + } + + fn set(&mut self, x: isize, y: isize) { + self.x = x; + self.y = y; + } + + fn x_ref(&self) -> &isize { + &self.x + } + + fn y_mut(&mut self) -> &mut isize { + &mut self.y + } +} + +fn deref_imm_field(x: Rc) { + let __isize = &x.y; +} + +fn deref_mut_field1(x: Rc) { + let __isize = &mut x.y; //~ ERROR cannot borrow +} + +fn deref_mut_field2(mut x: Rc) { + let __isize = &mut x.y; //~ ERROR cannot borrow +} + +fn deref_extend_field(x: &Rc) -> &isize { + &x.y +} + +fn deref_extend_mut_field1(x: &Rc) -> &mut isize { + &mut x.y //~ ERROR cannot borrow +} + +fn deref_extend_mut_field2(x: &mut Rc) -> &mut isize { + &mut x.y //~ ERROR cannot borrow +} + +fn assign_field1<'a>(x: Rc) { + x.y = 3; //~ ERROR cannot assign +} + +fn assign_field2<'a>(x: &'a Rc) { + x.y = 3; //~ ERROR cannot assign +} + +fn assign_field3<'a>(x: &'a mut Rc) { + x.y = 3; //~ ERROR cannot assign +} + +fn deref_imm_method(x: Rc) { + let __isize = x.get(); +} + +fn deref_mut_method1(x: Rc) { + x.set(0, 0); //~ ERROR cannot borrow +} + +fn deref_mut_method2(mut x: Rc) { + x.set(0, 0); //~ ERROR cannot borrow +} + +fn deref_extend_method(x: &Rc) -> &isize { + x.x_ref() +} + +fn deref_extend_mut_method1(x: &Rc) -> &mut isize { + x.y_mut() //~ ERROR cannot borrow +} + +fn deref_extend_mut_method2(x: &mut Rc) -> &mut isize { + x.y_mut() //~ ERROR cannot borrow +} + +fn assign_method1<'a>(x: Rc) { + *x.y_mut() = 3; //~ ERROR cannot borrow +} + +fn assign_method2<'a>(x: &'a Rc) { + *x.y_mut() = 3; //~ ERROR cannot borrow +} + +fn assign_method3<'a>(x: &'a mut Rc) { + *x.y_mut() = 3; //~ ERROR cannot borrow +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.stderr new file mode 100644 index 00000000000..31563fbaa1c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-auto-deref.stderr @@ -0,0 +1,88 @@ +error[E0596]: cannot borrow field of immutable binding as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:57:24 + | +LL | let __isize = &mut x.y; //~ ERROR cannot borrow + | ^^^ cannot mutably borrow field of immutable binding + +error[E0596]: cannot borrow field of immutable binding as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:61:24 + | +LL | let __isize = &mut x.y; //~ ERROR cannot borrow + | ^^^ cannot mutably borrow field of immutable binding + +error[E0596]: cannot borrow field of immutable binding as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:69:10 + | +LL | &mut x.y //~ ERROR cannot borrow + | ^^^ cannot mutably borrow field of immutable binding + +error[E0596]: cannot borrow field of immutable binding as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:73:10 + | +LL | &mut x.y //~ ERROR cannot borrow + | ^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field of immutable binding + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:77:5 + | +LL | x.y = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field of immutable binding + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:81:5 + | +LL | x.y = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field of immutable binding + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:85:5 + | +LL | x.y = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:93:5 + | +LL | x.set(0, 0); //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:97:5 + | +LL | x.set(0, 0); //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:105:5 + | +LL | x.y_mut() //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:109:5 + | +LL | x.y_mut() //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:113:6 + | +LL | *x.y_mut() = 3; //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:117:6 + | +LL | *x.y_mut() = 3; //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:121:6 + | +LL | *x.y_mut() = 3; //~ ERROR cannot borrow + | ^ cannot borrow as mutable + +error: aborting due to 14 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.nll.stderr new file mode 100644 index 00000000000..1e8d81fe76e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.nll.stderr @@ -0,0 +1,46 @@ +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:33:19 + | +LL | let __isize = &mut *x; //~ ERROR cannot borrow + | ^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:37:19 + | +LL | let __isize = &mut *x; //~ ERROR cannot borrow + | ^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:45:5 + | +LL | &mut **x //~ ERROR cannot borrow + | ^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:49:5 + | +LL | &mut **x //~ ERROR cannot borrow + | ^^^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-borrow-overloaded-deref.rs:53:5 + | +LL | *x = 3; //~ ERROR cannot assign + | ^^^^^^ cannot assign + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-borrow-overloaded-deref.rs:57:5 + | +LL | **x = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot assign + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-borrow-overloaded-deref.rs:61:5 + | +LL | **x = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot assign + +error: aborting due to 7 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.rs new file mode 100644 index 00000000000..5b916243b9e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.rs @@ -0,0 +1,64 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test how overloaded deref interacts with borrows when only +// Deref and not DerefMut is implemented. + +use std::ops::Deref; + +struct Rc { + value: *const T +} + +impl Deref for Rc { + type Target = T; + + fn deref<'a>(&'a self) -> &'a T { + unsafe { &*self.value } + } +} + +fn deref_imm(x: Rc) { + let __isize = &*x; +} + +fn deref_mut1(x: Rc) { + let __isize = &mut *x; //~ ERROR cannot borrow +} + +fn deref_mut2(mut x: Rc) { + let __isize = &mut *x; //~ ERROR cannot borrow +} + +fn deref_extend<'a>(x: &'a Rc) -> &'a isize { + &**x +} + +fn deref_extend_mut1<'a>(x: &'a Rc) -> &'a mut isize { + &mut **x //~ ERROR cannot borrow +} + +fn deref_extend_mut2<'a>(x: &'a mut Rc) -> &'a mut isize { + &mut **x //~ ERROR cannot borrow +} + +fn assign1<'a>(x: Rc) { + *x = 3; //~ ERROR cannot assign +} + +fn assign2<'a>(x: &'a Rc) { + **x = 3; //~ ERROR cannot assign +} + +fn assign3<'a>(x: &'a mut Rc) { + **x = 3; //~ ERROR cannot assign +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.stderr new file mode 100644 index 00000000000..641f943b6ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrow-overloaded-deref.stderr @@ -0,0 +1,46 @@ +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:33:24 + | +LL | let __isize = &mut *x; //~ ERROR cannot borrow + | ^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:37:24 + | +LL | let __isize = &mut *x; //~ ERROR cannot borrow + | ^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:45:10 + | +LL | &mut **x //~ ERROR cannot borrow + | ^^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:49:10 + | +LL | &mut **x //~ ERROR cannot borrow + | ^^^ cannot borrow as mutable + +error[E0594]: cannot assign to immutable borrowed content + --> $DIR/borrowck-borrow-overloaded-deref.rs:53:5 + | +LL | *x = 3; //~ ERROR cannot assign + | ^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to immutable borrowed content + --> $DIR/borrowck-borrow-overloaded-deref.rs:57:5 + | +LL | **x = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to immutable borrowed content + --> $DIR/borrowck-borrow-overloaded-deref.rs:61:5 + | +LL | **x = 3; //~ ERROR cannot assign + | ^^^^^^^ cannot borrow as mutable + +error: aborting due to 7 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr new file mode 100644 index 00000000000..8f42fb45627 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr @@ -0,0 +1,15 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:32:20 + | +LL | let x = defer(&vec!["Goodbye", "world!"]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value only lives until here + | | + | temporary value does not live long enough +LL | x.x[0]; + | ------ borrow later used here + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.rs new file mode 100644 index 00000000000..9178aadeeeb --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: borrowed value does not live long enough + +struct defer<'a> { + x: &'a [&'a str], +} + +impl<'a> Drop for defer<'a> { + fn drop(&mut self) { + unsafe { + println!("{:?}", self.x); + } + } +} + +fn defer<'r>(x: &'r [&'r str]) -> defer<'r> { + defer { + x: x + } +} + +fn main() { + let x = defer(&vec!["Goodbye", "world!"]); + x.x[0]; +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr new file mode 100644 index 00000000000..890b2894943 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr @@ -0,0 +1,17 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:32:20 + | +LL | let x = defer(&vec!["Goodbye", "world!"]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +LL | x.x[0]; +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr new file mode 100644 index 00000000000..04f74af4114 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/borrowck-borrowed-uniq-rvalue.rs:20:28 + | +LL | buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^^^ - temporary value only lives until here + | | + | temporary value does not live long enough +... +LL | buggy_map.insert(43, &*tmp); + | --------- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.rs new file mode 100644 index 00000000000..f58eca7c8ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//buggy.rs + +#![feature(box_syntax)] + +use std::collections::HashMap; + +fn main() { + let tmp: Box<_>; + let mut buggy_map: HashMap = HashMap::new(); + buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough + + // but it is ok if we use a temporary + tmp = box 2; + buggy_map.insert(43, &*tmp); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.stderr new file mode 100644 index 00000000000..7defd1ee936 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-borrowed-uniq-rvalue.stderr @@ -0,0 +1,16 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/borrowck-borrowed-uniq-rvalue.rs:20:27 + | +LL | buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough + | ^^^^^^^^^^^^ - borrowed value dropped here while still borrowed + | | + | borrowed value does not live long enough +... +LL | } + | - borrowed value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.nll.stderr new file mode 100644 index 00000000000..8c961838ca4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `x` + --> $DIR/borrowck-break-uninit-2.rs:19:20 + | +LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.rs new file mode 100644 index 00000000000..82a6c92abaf --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() -> isize { + let x: isize; + + while 1 != 2 { + break; + x = 0; + } + + println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + + return 17; +} + +fn main() { println!("{}", foo()); } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.stderr new file mode 100644 index 00000000000..4d7d1a0ed22 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit-2.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-break-uninit-2.rs:19:20 + | +LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.nll.stderr new file mode 100644 index 00000000000..4441c727539 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `x` + --> $DIR/borrowck-break-uninit.rs:19:20 + | +LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.rs new file mode 100644 index 00000000000..8a6a036945b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo() -> isize { + let x: isize; + + loop { + break; + x = 0; + } + + println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + + return 17; +} + +fn main() { println!("{}", foo()); } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.stderr new file mode 100644 index 00000000000..9d5a21319ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-break-uninit.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-break-uninit.rs:19:20 + | +LL | println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr new file mode 100644 index 00000000000..f24d0ed046a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr @@ -0,0 +1,116 @@ +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:31:14 + | +LL | let c1 = || x = 4; + | -- - first borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + | ^^ - second borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | drop(c1); + | -- borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:39:14 + | +LL | let c1 = || set(&mut x); + | -- - first borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` + | ^^ - second borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | drop(c1); + | -- borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:47:14 + | +LL | let c1 = || set(&mut x); + | -- - first borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + | ^^ - second borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | drop(c1); + | -- borrow later used here + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:55:5 + | +LL | let c2 = || x * 5; + | -- - borrow occurs due to use in closure + | | + | borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(c2); + | -- borrow later used here + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:63:5 + | +LL | let c1 = || get(&x); + | -- - borrow occurs due to use in closure + | | + | borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(c1); + | -- borrow later used here + +error[E0506]: cannot assign to `*x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:71:5 + | +LL | let c1 = || get(&*x); + | -- - borrow occurs due to use in closure + | | + | borrow of `*x` occurs here +LL | *x = 5; //[ast]~ ERROR cannot assign to `*x` + | ^^^^^^ assignment to borrowed `*x` occurs here +LL | //[mir]~^ ERROR cannot assign to `*x` because it is borrowed +LL | drop(c1); + | -- borrow later used here + +error[E0506]: cannot assign to `*x.f` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:83:5 + | +LL | let c1 = || get(&*x.f); + | -- - borrow occurs due to use in closure + | | + | borrow of `*x.f` occurs here +LL | *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` + | ^^^^^^^^ assignment to borrowed `*x.f` occurs here +LL | //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed +LL | drop(c1); + | -- borrow later used here + +error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-closures-mut-and-imm.rs:95:14 + | +LL | let c1 = || get(&*x.f); + | -- - first borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable + | ^^ - second borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable +LL | drop(c1); + | -- borrow later used here + +error: aborting due to 8 previous errors + +Some errors occurred: E0502, E0506. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.stderr new file mode 100644 index 00000000000..628fbbd1901 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.ast.stderr @@ -0,0 +1,96 @@ +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:31:14 + | +LL | let c1 = || x = 4; + | -- - previous borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + | ^^ - borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:39:14 + | +LL | let c1 = || set(&mut x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` + | ^^ - borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:47:14 + | +LL | let c1 = || set(&mut x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + | ^^ - borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:55:5 + | +LL | let c2 = || x * 5; + | -- borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:63:5 + | +LL | let c1 = || get(&x); + | -- borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here + +error[E0506]: cannot assign to `*x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:71:5 + | +LL | let c1 = || get(&*x); + | -- borrow of `*x` occurs here +LL | *x = 5; //[ast]~ ERROR cannot assign to `*x` + | ^^^^^^ assignment to borrowed `*x` occurs here + +error[E0506]: cannot assign to `*x.f` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:83:5 + | +LL | let c1 = || get(&*x.f); + | -- borrow of `*x.f` occurs here +LL | *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` + | ^^^^^^^^ assignment to borrowed `*x.f` occurs here + +error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-closures-mut-and-imm.rs:95:14 + | +LL | let c1 = || get(&*x.f); + | -- - previous borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable + | ^^ - borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error: aborting due to 8 previous errors + +Some errors occurred: E0502, E0506. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.mir.stderr new file mode 100644 index 00000000000..f24d0ed046a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.mir.stderr @@ -0,0 +1,116 @@ +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:31:14 + | +LL | let c1 = || x = 4; + | -- - first borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + | ^^ - second borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | drop(c1); + | -- borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:39:14 + | +LL | let c1 = || set(&mut x); + | -- - first borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` + | ^^ - second borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | drop(c1); + | -- borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-mut-and-imm.rs:47:14 + | +LL | let c1 = || set(&mut x); + | -- - first borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + | ^^ - second borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | drop(c1); + | -- borrow later used here + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:55:5 + | +LL | let c2 = || x * 5; + | -- - borrow occurs due to use in closure + | | + | borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(c2); + | -- borrow later used here + +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:63:5 + | +LL | let c1 = || get(&x); + | -- - borrow occurs due to use in closure + | | + | borrow of `x` occurs here +LL | x = 5; //[ast]~ ERROR cannot assign + | ^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(c1); + | -- borrow later used here + +error[E0506]: cannot assign to `*x` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:71:5 + | +LL | let c1 = || get(&*x); + | -- - borrow occurs due to use in closure + | | + | borrow of `*x` occurs here +LL | *x = 5; //[ast]~ ERROR cannot assign to `*x` + | ^^^^^^ assignment to borrowed `*x` occurs here +LL | //[mir]~^ ERROR cannot assign to `*x` because it is borrowed +LL | drop(c1); + | -- borrow later used here + +error[E0506]: cannot assign to `*x.f` because it is borrowed + --> $DIR/borrowck-closures-mut-and-imm.rs:83:5 + | +LL | let c1 = || get(&*x.f); + | -- - borrow occurs due to use in closure + | | + | borrow of `*x.f` occurs here +LL | *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` + | ^^^^^^^^ assignment to borrowed `*x.f` occurs here +LL | //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed +LL | drop(c1); + | -- borrow later used here + +error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-closures-mut-and-imm.rs:95:14 + | +LL | let c1 = || get(&*x.f); + | -- - first borrow occurs due to use of `x` in closure + | | + | immutable borrow occurs here +LL | let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable + | ^^ - second borrow occurs due to use of `x` in closure + | | + | mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable +LL | drop(c1); + | -- borrow later used here + +error: aborting due to 8 previous errors + +Some errors occurred: E0502, E0506. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.rs new file mode 100644 index 00000000000..9057ba07907 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-and-imm.rs @@ -0,0 +1,101 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that two closures cannot simultaneously have mutable +// and immutable access to the variable. Issue #6801. + +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(box_syntax)] + +fn get(x: &isize) -> isize { + *x +} + +fn set(x: &mut isize) { + *x = 4; +} + +fn a() { + let mut x = 3; + let c1 = || x = 4; + let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + drop(c1); +} + +fn b() { + let mut x = 3; + let c1 = || set(&mut x); + let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` + //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + drop(c1); +} + +fn c() { + let mut x = 3; + let c1 = || set(&mut x); + let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` + //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + drop(c1); +} + +fn d() { + let mut x = 3; + let c2 = || x * 5; + x = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed + drop(c2); +} + +fn e() { + let mut x = 3; + let c1 = || get(&x); + x = 5; //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed + drop(c1); +} + +fn f() { + let mut x: Box<_> = box 3; + let c1 = || get(&*x); + *x = 5; //[ast]~ ERROR cannot assign to `*x` + //[mir]~^ ERROR cannot assign to `*x` because it is borrowed + drop(c1); +} + +fn g() { + struct Foo { + f: Box + } + + let mut x: Box<_> = box Foo { f: box 3 }; + let c1 = || get(&*x.f); + *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` + //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed + drop(c1); +} + +fn h() { + struct Foo { + f: Box + } + + let mut x: Box<_> = box Foo { f: box 3 }; + let c1 = || get(&*x.f); + let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable + //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + drop(c1); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.nll.stderr new file mode 100644 index 00000000000..e8fae63a5d6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.nll.stderr @@ -0,0 +1,15 @@ +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-closures-mut-of-imm.rs:23:21 + | +LL | let c1 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-closures-mut-of-imm.rs:25:21 + | +LL | let c2 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.rs new file mode 100644 index 00000000000..dc2f0e8395f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that two closures cannot simultaneously have mutable +// and immutable access to the variable. Issue #6801. + +fn get(x: &isize) -> isize { + *x +} + +fn set(x: &mut isize) { + *x = 4; +} + +fn a(x: &isize) { + let c1 = || set(&mut *x); + //~^ ERROR cannot borrow + let c2 = || set(&mut *x); + //~^ ERROR cannot borrow + //~| ERROR two closures require unique access to `x` at the same time +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.stderr new file mode 100644 index 00000000000..87eb52b6aa6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-mut-of-imm.stderr @@ -0,0 +1,32 @@ +error[E0524]: two closures require unique access to `x` at the same time + --> $DIR/borrowck-closures-mut-of-imm.rs:25:14 + | +LL | let c1 = || set(&mut *x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first closure is constructed here +LL | //~^ ERROR cannot borrow +LL | let c2 = || set(&mut *x); + | ^^ - borrow occurs due to use of `x` in closure + | | + | second closure is constructed here +... +LL | } + | - borrow from first closure ends here + +error[E0596]: cannot borrow immutable borrowed content `***x` as mutable + --> $DIR/borrowck-closures-mut-of-imm.rs:23:26 + | +LL | let c1 = || set(&mut *x); + | ^^ cannot borrow as mutable + +error[E0596]: cannot borrow immutable borrowed content `***x` as mutable + --> $DIR/borrowck-closures-mut-of-imm.rs:25:26 + | +LL | let c2 = || set(&mut *x); + | ^^ cannot borrow as mutable + +error: aborting due to 3 previous errors + +Some errors occurred: E0524, E0596. +For more information about an error, try `rustc --explain E0524`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.rs new file mode 100644 index 00000000000..29546abe0bb --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.rs @@ -0,0 +1,60 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that two closures cannot simultaneously have mutable +// access to the variable, whether that mutable access be used +// for direct assignment or for taking mutable ref. Issue #6801. + +#![feature(box_syntax)] + +fn to_fn_mut(f: F) -> F { f } + +fn a() { + let mut x = 3; + let c1 = to_fn_mut(|| x = 4); + let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once +} + +fn set(x: &mut isize) { + *x = 4; +} + +fn b() { + let mut x = 3; + let c1 = to_fn_mut(|| set(&mut x)); + let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once +} + +fn c() { + let mut x = 3; + let c1 = to_fn_mut(|| x = 5); + let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once +} + +fn d() { + let mut x = 3; + let c1 = to_fn_mut(|| x = 5); + let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) + //~^ ERROR cannot borrow `x` as mutable more than once +} + +fn g() { + struct Foo { + f: Box + } + + let mut x: Box<_> = box Foo { f: box 3 }; + let c1 = to_fn_mut(|| set(&mut *x.f)); + let c2 = to_fn_mut(|| set(&mut *x.f)); + //~^ ERROR cannot borrow `x` as mutable more than once +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.stderr new file mode 100644 index 00000000000..3b4e050ee25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-two-mut.stderr @@ -0,0 +1,75 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:22:24 + | +LL | let c1 = to_fn_mut(|| x = 4); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first mutable borrow occurs here +LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once + | ^^ - borrow occurs due to use of `x` in closure + | | + | second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:32:24 + | +LL | let c1 = to_fn_mut(|| set(&mut x)); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first mutable borrow occurs here +LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once + | ^^ - borrow occurs due to use of `x` in closure + | | + | second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:38:24 + | +LL | let c1 = to_fn_mut(|| x = 5); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first mutable borrow occurs here +LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once + | ^^ - borrow occurs due to use of `x` in closure + | | + | second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:44:24 + | +LL | let c1 = to_fn_mut(|| x = 5); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first mutable borrow occurs here +LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) + | ^^ - borrow occurs due to use of `x` in closure + | | + | second mutable borrow occurs here +LL | //~^ ERROR cannot borrow `x` as mutable more than once +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-closures-two-mut.rs:55:24 + | +LL | let c1 = to_fn_mut(|| set(&mut *x.f)); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first mutable borrow occurs here +LL | let c2 = to_fn_mut(|| set(&mut *x.f)); + | ^^ - borrow occurs due to use of `x` in closure + | | + | second mutable borrow occurs here +LL | //~^ ERROR cannot borrow `x` as mutable more than once +LL | } + | - first borrow ends here + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.rs new file mode 100644 index 00000000000..247a4fe89a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + x: isize, +} + +pub fn main() { + let mut this = &mut Foo { + x: 1, + }; + let mut r = || { + let p = &this.x; + &mut this.x; //~ ERROR cannot borrow + }; + r() +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.stderr new file mode 100644 index 00000000000..31b1a1bb0e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique-imm.stderr @@ -0,0 +1,13 @@ +error[E0502]: cannot borrow `this.x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-closures-unique-imm.rs:21:14 + | +LL | let p = &this.x; + | ------ immutable borrow occurs here +LL | &mut this.x; //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here +LL | }; + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.rs new file mode 100644 index 00000000000..1b22dc4d2c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.rs @@ -0,0 +1,50 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that a closure which requires mutable access to the referent +// of an `&mut` requires a "unique" borrow -- that is, the variable to +// be borrowed (here, `x`) will not be borrowed *mutably*, but +// may be *immutable*, but we cannot allow +// multiple borrows. + +fn get(x: &isize) -> isize { + *x +} + +fn set(x: &mut isize) -> isize { + *x +} + +fn a(x: &mut isize) { + let c1 = || get(x); + let c2 = || get(x); +} + +fn b(x: &mut isize) { + let c1 = || get(x); + let c2 = || set(x); //~ ERROR closure requires unique access to `x` +} + +fn c(x: &mut isize) { + let c1 = || get(x); + let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x` +} + +fn d(x: &mut isize) { + let c1 = || set(x); + let c2 = || set(x); //~ ERROR two closures require unique access to `x` at the same time +} + +fn e(x: &mut isize) { + let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable argument +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.stderr new file mode 100644 index 00000000000..8f213c16cff --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-unique.stderr @@ -0,0 +1,56 @@ +error[E0500]: closure requires unique access to `x` but it is already borrowed + --> $DIR/borrowck-closures-unique.rs:32:14 + | +LL | let c1 = || get(x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | borrow occurs here +LL | let c2 = || set(x); //~ ERROR closure requires unique access to `x` + | ^^ - borrow occurs due to use of `x` in closure + | | + | closure construction occurs here +LL | } + | - borrow ends here + +error[E0500]: closure requires unique access to `x` but it is already borrowed + --> $DIR/borrowck-closures-unique.rs:37:14 + | +LL | let c1 = || get(x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | borrow occurs here +LL | let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x` + | ^^ - borrow occurs due to use of `x` in closure + | | + | closure construction occurs here +LL | } + | - borrow ends here + +error[E0524]: two closures require unique access to `x` at the same time + --> $DIR/borrowck-closures-unique.rs:42:14 + | +LL | let c1 = || set(x); + | -- - previous borrow occurs due to use of `x` in closure + | | + | first closure is constructed here +LL | let c2 = || set(x); //~ ERROR two closures require unique access to `x` at the same time + | ^^ - borrow occurs due to use of `x` in closure + | | + | second closure is constructed here +LL | } + | - borrow from first closure ends here + +error[E0595]: closure cannot assign to immutable argument `x` + --> $DIR/borrowck-closures-unique.rs:46:14 + | +LL | let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable argument + | ^^ cannot borrow mutably +help: consider removing the `&mut`, as it is an immutable binding to a mutable reference + | +LL | x //~ ERROR closure cannot assign to immutable argument + | ^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0500, E0524, E0595. +For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.nll.stderr new file mode 100644 index 00000000000..dc73929989c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.nll.stderr @@ -0,0 +1,17 @@ +error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-use-after-free.rs:32:8 + | +LL | let mut test = |foo: &Foo| { + | ----------- mutable borrow occurs here +LL | ptr = box Foo { x: ptr.x + 1 }; + | --- first borrow occurs due to use of `ptr` in closure +LL | }; +LL | test(&*ptr); //~ ERROR cannot borrow `*ptr` + | -----^^^^^- + | | | + | | immutable borrow occurs here + | borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.rs new file mode 100644 index 00000000000..bb474342a7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that a closure which mutates a local variable +// cannot also be supplied a borrowed version of that +// variable's contents. Issue #11192. + +#![feature(box_syntax)] + +struct Foo { + x: isize +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("drop {}", self.x); + } +} + +fn main() { + let mut ptr: Box<_> = box Foo { x: 0 }; + let mut test = |foo: &Foo| { + ptr = box Foo { x: ptr.x + 1 }; + }; + test(&*ptr); //~ ERROR cannot borrow `*ptr` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.stderr new file mode 100644 index 00000000000..7beb31f3944 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-closures-use-after-free.stderr @@ -0,0 +1,16 @@ +error[E0502]: cannot borrow `*ptr` as immutable because `ptr` is also borrowed as mutable + --> $DIR/borrowck-closures-use-after-free.rs:32:9 + | +LL | let mut test = |foo: &Foo| { + | ----------- mutable borrow occurs here +LL | ptr = box Foo { x: ptr.x + 1 }; + | --- previous borrow occurs due to use of `ptr` in closure +LL | }; +LL | test(&*ptr); //~ ERROR cannot borrow `*ptr` + | ^^^^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.rs new file mode 100644 index 00000000000..32490e0dc7d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we report an error if an upcast box is moved twice. + +fn consume(_: Box<[i32]>) { +} + +fn foo(b: Box<[i32;5]>) { + consume(b); + consume(b); //~ ERROR use of moved value +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.stderr new file mode 100644 index 00000000000..8199ce70e2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-unsize-vec.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `b` + --> $DIR/borrowck-consume-unsize-vec.rs:18:13 + | +LL | consume(b); + | - value moved here +LL | consume(b); //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `b` has type `std::boxed::Box<[i32; 5]>`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.nll.stderr new file mode 100644 index 00000000000..b999e092847 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `b` + --> $DIR/borrowck-consume-upcast-box.rs:20:13 + | +LL | consume(b); + | - value moved here +LL | consume(b); //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.rs new file mode 100644 index 00000000000..5bcafa675c7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we report an error if an upcast box is moved twice. + +trait Foo { fn dummy(&self); } + +fn consume(_: Box) { +} + +fn foo(b: Box) { + consume(b); + consume(b); //~ ERROR use of moved value +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.stderr new file mode 100644 index 00000000000..159933a6155 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-consume-upcast-box.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `b` + --> $DIR/borrowck-consume-upcast-box.rs:20:13 + | +LL | consume(b); + | - value moved here +LL | consume(b); //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `b` has type `std::boxed::Box<(dyn Foo + std::marker::Send + 'static)>`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.nll.stderr new file mode 100644 index 00000000000..34715e307fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.nll.stderr @@ -0,0 +1,543 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-describe-lvalue.rs:295:13 + | +LL | let y = &mut x; + | ------ first mutable borrow occurs here +LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + | ^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time +LL | *y = 1; + | ------ borrow later used here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-describe-lvalue.rs:307:20 + | +LL | let y = &mut x; + | ------ first mutable borrow occurs here +LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + | ^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time +LL | *y = 1; + | ------ borrow later used here + +error: unsatisfied lifetime constraints + --> $DIR/borrowck-describe-lvalue.rs:305:16 + | +LL | || { + | ____________- + | |____________| + | || +LL | || || { //[mir]~ ERROR unsatisfied lifetime constraints + | ||________________^ +LL | ||| let y = &mut x; +LL | ||| &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time +LL | ||| //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time +LL | ||| *y = 1; +LL | ||| drop(y); +LL | ||| } + | |||_________________^ requires that `'1` must outlive `'2` +LL | || }; + | || - + | ||____________| + | |_____________lifetime `'1` represents the closure body + | lifetime `'2` appears in return type + +error[E0503]: cannot use `f.x` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:53:9 + | +LL | let x = f.x(); + | - borrow of `f` occurs here +LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + | ^^^ use of borrowed `f` +LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `g.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:61:9 + | +LL | let x = g.x(); + | - borrow of `g` occurs here +LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + | ^^^ use of borrowed `g` +LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `h.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:69:9 + | +LL | let x = &mut h.0; + | -------- borrow of `h.0` occurs here +LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + | ^^^ use of borrowed `h.0` +LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:77:15 + | +LL | let x = e.x(); + | - borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + | ^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:78:20 + | +LL | let x = e.x(); + | - borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | Baz::X(value) => value + | ^^^^^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:88:9 + | +LL | let x = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `f.x` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:96:9 + | +LL | let x = f.x(); + | - borrow of `*f` occurs here +LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + | ^^^ use of borrowed `*f` +LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `g.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:104:9 + | +LL | let x = g.x(); + | - borrow of `*g` occurs here +LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + | ^^^ use of borrowed `*g` +LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `h.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:112:9 + | +LL | let x = &mut h.0; + | -------- borrow of `h.0` occurs here +LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + | ^^^ use of borrowed `h.0` +LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `*e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:120:15 + | +LL | let x = e.x(); + | - borrow of `*e` occurs here +LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed + | ^^ use of borrowed `*e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:121:20 + | +LL | let x = e.x(); + | - borrow of `*e` occurs here +LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed +LL | Baz::X(value) => value + | ^^^^^ use of borrowed `*e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:131:9 + | +LL | let x = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:139:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:140:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[x, _, .., _, _] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:145:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:146:18 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, x, .., _, _] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:151:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:152:25 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, _, .., x, _] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:157:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:158:28 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, _, .., _, x] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:169:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:170:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[x..] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:175:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:176:18 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, x..] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:181:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:182:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[x.., _] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:187:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:188:18 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, x.., _] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:201:15 + | +LL | let x = &mut e; + | ------ borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + | ^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:202:13 + | +LL | let x = &mut e; + | ------ borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | E::A(ref ax) => + | ^^^^^^^^^^^^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:202:18 + | +LL | let x = &mut e; + | ------ mutable borrow occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | E::A(ref ax) => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:207:23 + | +LL | let x = &mut e; + | ------ mutable borrow occurs here +... +LL | E::B { x: ref bx } => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `s` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:220:15 + | +LL | let x = &mut s; + | ------ borrow of `s` occurs here +LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + | ^ use of borrowed `s` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:221:22 + | +LL | let x = &mut s; + | ------ mutable borrow occurs here +LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed +LL | S { y: (ref y0, _), .. } => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `s` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:227:15 + | +LL | let x = &mut s; + | ------ borrow of `s` occurs here +... +LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + | ^ use of borrowed `s` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:228:28 + | +LL | let x = &mut s; + | ------ mutable borrow occurs here +... +LL | S { x: F { y: ref x0, .. }, .. } => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `*v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:271:9 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | v[0].y; + | ^^^^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..].y` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:271:9 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | v[0].y; + | ^^^^^^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:282:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:283:24 + | +LL | let x = &mut v; + | ------ mutable borrow occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:245:29 + | +LL | let x = &mut block; + | ---------- mutable borrow occurs here +LL | let p: &'a u8 = &*block.current; + | ^^^^^^^^^^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:260:33 + | +LL | let x = &mut block; + | ---------- mutable borrow occurs here +LL | let p : *const u8 = &*(*block).current; + | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-describe-lvalue.rs:318:22 + | +LL | drop(x); + | - value moved here +LL | drop(x); //[ast]~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 46 previous errors + +Some errors occurred: E0382, E0499, E0502, E0503. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.stderr new file mode 100644 index 00000000000..ca9b2dda8bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.ast.stderr @@ -0,0 +1,246 @@ +error[E0503]: cannot use `f.x` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:53:9 + | +LL | let x = f.x(); + | - borrow of `f` occurs here +LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + | ^^^ use of borrowed `f` + +error[E0503]: cannot use `g.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:61:9 + | +LL | let x = g.x(); + | - borrow of `g` occurs here +LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + | ^^^ use of borrowed `g` + +error[E0503]: cannot use `h.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:69:9 + | +LL | let x = &mut h.0; + | --- borrow of `h.0` occurs here +LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + | ^^^ use of borrowed `h.0` + +error[E0503]: cannot use `e.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:78:20 + | +LL | let x = e.x(); + | - borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | Baz::X(value) => value + | ^^^^^ use of borrowed `e` + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:88:9 + | +LL | let x = &mut u.a; + | --- borrow of `u.a` occurs here +LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` + +error[E0503]: cannot use `f.x` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:96:9 + | +LL | let x = f.x(); + | - borrow of `*f` occurs here +LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + | ^^^ use of borrowed `*f` + +error[E0503]: cannot use `g.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:104:9 + | +LL | let x = g.x(); + | - borrow of `*g` occurs here +LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + | ^^^ use of borrowed `*g` + +error[E0503]: cannot use `h.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:112:9 + | +LL | let x = &mut h.0; + | --- borrow of `h.0` occurs here +LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + | ^^^ use of borrowed `h.0` + +error[E0503]: cannot use `e.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:121:20 + | +LL | let x = e.x(); + | - borrow of `*e` occurs here +LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed +LL | Baz::X(value) => value + | ^^^^^ use of borrowed `*e` + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:131:9 + | +LL | let x = &mut u.a; + | --- borrow of `u.a` occurs here +LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:140:15 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[x, _, .., _, _] => println!("{}", x), + | ^ use of borrowed `v` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:146:18 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +... +LL | &[_, x, .., _, _] => println!("{}", x), + | ^ use of borrowed `v` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:152:25 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +... +LL | &[_, _, .., x, _] => println!("{}", x), + | ^ use of borrowed `v` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:158:28 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +... +LL | &[_, _, .., _, x] => println!("{}", x), + | ^ use of borrowed `v` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:170:15 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[x..] => println!("{:?}", x), + | ^ use of borrowed `v` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:176:18 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +... +LL | &[_, x..] => println!("{:?}", x), + | ^ use of borrowed `v` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:182:15 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +... +LL | &[x.., _] => println!("{:?}", x), + | ^ use of borrowed `v` + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:188:18 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +... +LL | &[_, x.., _] => println!("{:?}", x), + | ^ use of borrowed `v` + +error[E0502]: cannot borrow `e.0` as immutable because `e` is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:202:18 + | +LL | let x = &mut e; + | - mutable borrow occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | E::A(ref ax) => + | ^^^^^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `e.x` as immutable because `e` is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:207:23 + | +LL | let x = &mut e; + | - mutable borrow occurs here +... +LL | E::B { x: ref bx } => + | ^^^^^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:221:22 + | +LL | let x = &mut s; + | - mutable borrow occurs here +LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed +LL | S { y: (ref y0, _), .. } => + | ^^^^^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:228:28 + | +LL | let x = &mut s; + | - mutable borrow occurs here +... +LL | S { x: F { y: ref x0, .. }, .. } => + | ^^^^^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0503]: cannot use `v[..].y` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:271:9 + | +LL | let x = &mut v; + | - borrow of `v` occurs here +LL | v[0].y; + | ^^^^^^ use of borrowed `v` + +error[E0499]: cannot borrow `**x` as mutable more than once at a time + --> $DIR/borrowck-describe-lvalue.rs:295:18 + | +LL | let y = &mut x; + | - first mutable borrow occurs here +LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + | ^ second mutable borrow occurs here +... +LL | }; + | - first borrow ends here + +error[E0499]: cannot borrow `**x` as mutable more than once at a time + --> $DIR/borrowck-describe-lvalue.rs:307:25 + | +LL | let y = &mut x; + | - first mutable borrow occurs here +LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + | ^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-describe-lvalue.rs:318:22 + | +LL | drop(x); + | - value moved here +LL | drop(x); //[ast]~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 26 previous errors + +Some errors occurred: E0382, E0499, E0502, E0503. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.mir.stderr new file mode 100644 index 00000000000..34715e307fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.mir.stderr @@ -0,0 +1,543 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-describe-lvalue.rs:295:13 + | +LL | let y = &mut x; + | ------ first mutable borrow occurs here +LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + | ^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time +LL | *y = 1; + | ------ borrow later used here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-describe-lvalue.rs:307:20 + | +LL | let y = &mut x; + | ------ first mutable borrow occurs here +LL | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + | ^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time +LL | *y = 1; + | ------ borrow later used here + +error: unsatisfied lifetime constraints + --> $DIR/borrowck-describe-lvalue.rs:305:16 + | +LL | || { + | ____________- + | |____________| + | || +LL | || || { //[mir]~ ERROR unsatisfied lifetime constraints + | ||________________^ +LL | ||| let y = &mut x; +LL | ||| &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time +LL | ||| //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time +LL | ||| *y = 1; +LL | ||| drop(y); +LL | ||| } + | |||_________________^ requires that `'1` must outlive `'2` +LL | || }; + | || - + | ||____________| + | |_____________lifetime `'1` represents the closure body + | lifetime `'2` appears in return type + +error[E0503]: cannot use `f.x` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:53:9 + | +LL | let x = f.x(); + | - borrow of `f` occurs here +LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + | ^^^ use of borrowed `f` +LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `g.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:61:9 + | +LL | let x = g.x(); + | - borrow of `g` occurs here +LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + | ^^^ use of borrowed `g` +LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `h.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:69:9 + | +LL | let x = &mut h.0; + | -------- borrow of `h.0` occurs here +LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + | ^^^ use of borrowed `h.0` +LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:77:15 + | +LL | let x = e.x(); + | - borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + | ^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:78:20 + | +LL | let x = e.x(); + | - borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | Baz::X(value) => value + | ^^^^^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:88:9 + | +LL | let x = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `f.x` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:96:9 + | +LL | let x = f.x(); + | - borrow of `*f` occurs here +LL | f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + | ^^^ use of borrowed `*f` +LL | //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `g.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:104:9 + | +LL | let x = g.x(); + | - borrow of `*g` occurs here +LL | g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + | ^^^ use of borrowed `*g` +LL | //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `h.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:112:9 + | +LL | let x = &mut h.0; + | -------- borrow of `h.0` occurs here +LL | h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + | ^^^ use of borrowed `h.0` +LL | //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `*e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:120:15 + | +LL | let x = e.x(); + | - borrow of `*e` occurs here +LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed + | ^^ use of borrowed `*e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e.0` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:121:20 + | +LL | let x = e.x(); + | - borrow of `*e` occurs here +LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed +LL | Baz::X(value) => value + | ^^^^^ use of borrowed `*e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:131:9 + | +LL | let x = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:139:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:140:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[x, _, .., _, _] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:145:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:146:18 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, x, .., _, _] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:151:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:152:25 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, _, .., x, _] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:157:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:158:28 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, _, .., _, x] => println!("{}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:169:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:170:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[x..] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:175:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:176:18 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, x..] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:181:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:182:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[x.., _] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:187:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..]` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:188:18 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +... +LL | &[_, x.., _] => println!("{:?}", x), + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:201:15 + | +LL | let x = &mut e; + | ------ borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + | ^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:202:13 + | +LL | let x = &mut e; + | ------ borrow of `e` occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | E::A(ref ax) => + | ^^^^^^^^^^^^ use of borrowed `e` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:202:18 + | +LL | let x = &mut e; + | ------ mutable borrow occurs here +LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | E::A(ref ax) => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:207:23 + | +LL | let x = &mut e; + | ------ mutable borrow occurs here +... +LL | E::B { x: ref bx } => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `s` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:220:15 + | +LL | let x = &mut s; + | ------ borrow of `s` occurs here +LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + | ^ use of borrowed `s` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:221:22 + | +LL | let x = &mut s; + | ------ mutable borrow occurs here +LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed +LL | S { y: (ref y0, _), .. } => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `s` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:227:15 + | +LL | let x = &mut s; + | ------ borrow of `s` occurs here +... +LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + | ^ use of borrowed `s` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:228:28 + | +LL | let x = &mut s; + | ------ mutable borrow occurs here +... +LL | S { x: F { y: ref x0, .. }, .. } => + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `*v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:271:9 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | v[0].y; + | ^^^^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v[..].y` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:271:9 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | v[0].y; + | ^^^^^^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0503]: cannot use `v` because it was mutably borrowed + --> $DIR/borrowck-describe-lvalue.rs:282:15 + | +LL | let x = &mut v; + | ------ borrow of `v` occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + | ^ use of borrowed `v` +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:283:24 + | +LL | let x = &mut v; + | ------ mutable borrow occurs here +LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), + | ^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:245:29 + | +LL | let x = &mut block; + | ---------- mutable borrow occurs here +LL | let p: &'a u8 = &*block.current; + | ^^^^^^^^^^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-describe-lvalue.rs:260:33 + | +LL | let x = &mut block; + | ---------- mutable borrow occurs here +LL | let p : *const u8 = &*(*block).current; + | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here +... +LL | drop(x); + | - borrow later used here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-describe-lvalue.rs:318:22 + | +LL | drop(x); + | - value moved here +LL | drop(x); //[ast]~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 46 previous errors + +Some errors occurred: E0382, E0499, E0502, E0503. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.rs new file mode 100644 index 00000000000..b821c7cfa34 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-describe-lvalue.rs @@ -0,0 +1,324 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(slice_patterns)] + +pub struct Foo { + x: u32 +} + +pub struct Bar(u32); + +pub enum Baz { + X(u32) +} + +union U { + a: u8, + b: u64, +} + +impl Foo { + fn x(&mut self) -> &mut u32 { &mut self.x } +} + +impl Bar { + fn x(&mut self) -> &mut u32 { &mut self.0 } +} + +impl Baz { + fn x(&mut self) -> &mut u32 { + match *self { + Baz::X(ref mut value) => value + } + } +} + +fn main() { + // Local and field from struct + { + let mut f = Foo { x: 22 }; + let x = f.x(); + f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed + drop(x); + } + // Local and field from tuple-struct + { + let mut g = Bar(22); + let x = g.x(); + g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed + drop(x); + } + // Local and field from tuple + { + let mut h = (22, 23); + let x = &mut h.0; + h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed + drop(x); + } + // Local and field from enum + { + let mut e = Baz::X(2); + let x = e.x(); + match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + Baz::X(value) => value + //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed + }; + drop(x); + } + // Local and field from union + unsafe { + let mut u = U { b: 0 }; + let x = &mut u.a; + u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed + drop(x); + } + // Deref and field from struct + { + let mut f = Box::new(Foo { x: 22 }); + let x = f.x(); + f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed + //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed + drop(x); + } + // Deref and field from tuple-struct + { + let mut g = Box::new(Bar(22)); + let x = g.x(); + g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed + //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed + drop(x); + } + // Deref and field from tuple + { + let mut h = Box::new((22, 23)); + let x = &mut h.0; + h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed + //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed + drop(x); + } + // Deref and field from enum + { + let mut e = Box::new(Baz::X(3)); + let x = e.x(); + match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed + Baz::X(value) => value + //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed + }; + drop(x); + } + // Deref and field from union + unsafe { + let mut u = Box::new(U { b: 0 }); + let x = &mut u.a; + u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed + drop(x); + } + // Constant index + { + let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let x = &mut v; + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[x, _, .., _, _] => println!("{}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[_, x, .., _, _] => println!("{}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[_, _, .., x, _] => println!("{}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[_, _, .., _, x] => println!("{}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + drop(x); + } + // Subslices + { + let mut v = &[1, 2, 3, 4, 5]; + let x = &mut v; + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[x..] => println!("{:?}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[_, x..] => println!("{:?}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[x.., _] => println!("{:?}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[_, x.., _] => println!("{:?}", x), + //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + _ => panic!("other case"), + } + drop(x); + } + // Downcasted field + { + enum E { A(X), B { x: X } } + + let mut e = E::A(3); + let x = &mut e; + match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + E::A(ref ax) => + //[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable + //[mir]~| ERROR cannot use `e` because it was mutably borrowed + println!("e.ax: {:?}", ax), + E::B { x: ref bx } => + //[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable + println!("e.bx: {:?}", bx), + } + drop(x); + } + // Field in field + { + struct F { x: u32, y: u32 }; + struct S { x: F, y: (u32, u32), }; + let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) }; + let x = &mut s; + match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + S { y: (ref y0, _), .. } => + //[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable + println!("y0: {:?}", y0), + _ => panic!("other case"), + } + match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + S { x: F { y: ref x0, .. }, .. } => + //[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable + println!("x0: {:?}", x0), + _ => panic!("other case"), + } + drop(x); + } + // Field of ref + { + struct Block<'a> { + current: &'a u8, + unrelated: &'a u8, + }; + + fn bump<'a>(mut block: &mut Block<'a>) { + let x = &mut block; + let p: &'a u8 = &*block.current; + //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable + // No errors in AST because of issue rust#38899 + drop(x); + } + } + // Field of ptr + { + struct Block2 { + current: *const u8, + unrelated: *const u8, + } + + unsafe fn bump2(mut block: *mut Block2) { + let x = &mut block; + let p : *const u8 = &*(*block).current; + //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable + // No errors in AST because of issue rust#38899 + drop(x); + } + } + // Field of index + { + struct F {x: u32, y: u32}; + let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; + let x = &mut v; + v[0].y; + //[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed + //[mir]~^^ ERROR cannot use `v[..].y` because it was mutably borrowed + //[mir]~| ERROR cannot use `*v` because it was mutably borrowed + drop(x); + } + // Field of constant index + { + struct F {x: u32, y: u32}; + let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; + let x = &mut v; + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + &[_, F {x: ref xf, ..}] => println!("{}", xf), + //[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable + // No errors in AST + _ => panic!("other case") + } + drop(x); + } + // Field from upvar + { + let mut x = 0; + || { + let y = &mut x; + &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time + *y = 1; + }; + } + // Field from upvar nested + { + // FIXME(#49824) -- the free region error below should probably not be there + let mut x = 0; + || { + || { //[mir]~ ERROR unsatisfied lifetime constraints + let y = &mut x; + &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time + //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time + *y = 1; + drop(y); + } + }; + } + { + fn foo(x: Vec) { + let c = || { + drop(x); + drop(x); //[ast]~ ERROR use of moved value: `x` + //[mir]~^ ERROR use of moved value: `x` + }; + c(); + } + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.rs new file mode 100644 index 00000000000..496aa84b593 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +//compile-flags: -Z borrowck=mir + +fn foo(_:String) {} + +fn main() +{ + let my_str = "hello".to_owned(); + match Some(42) { + Some(_) if { drop(my_str); false } => {} + Some(_) => {} + None => { foo(my_str); } //~ ERROR [E0382] + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.stderr new file mode 100644 index 00000000000..e28b500ce63 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-drop-from-guard.stderr @@ -0,0 +1,14 @@ +error[E0382]: use of moved value: `my_str` + --> $DIR/borrowck-drop-from-guard.rs:22:23 + | +LL | Some(_) if { drop(my_str); false } => {} + | ------ value moved here +LL | Some(_) => {} +LL | None => { foo(my_str); } //~ ERROR [E0382] + | ^^^^^^ value used here after move + | + = note: move occurs because `my_str` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.nll.stderr new file mode 100644 index 00000000000..fb300d32b05 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.nll.stderr @@ -0,0 +1,110 @@ +error[E0382]: use of moved value: `*x.b` + --> $DIR/borrowck-field-sensitivity.rs:18:10 + | +LL | drop(x.b); + | --- value moved here +LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` + | ^^^^ value used here after move + +error[E0382]: use of moved value: `*x.b` + --> $DIR/borrowck-field-sensitivity.rs:24:10 + | +LL | let y = A { a: 3, .. x }; + | ---------------- value moved here +LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` + | ^^^^ value used here after move + +error[E0382]: borrow of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:30:13 + | +LL | drop(x.b); + | --- value moved here +LL | let p = &x.b; //~ ERROR use of moved value: `x.b` + | ^^^^ value borrowed here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: borrow of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:37:13 + | +LL | let _y = A { a: 3, .. x }; + | ---------------- value moved here +LL | let p = &x.b; //~ ERROR use of moved value: `x.b` + | ^^^^ value borrowed here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0505]: cannot move out of `x.b` because it is borrowed + --> $DIR/borrowck-field-sensitivity.rs:44:10 + | +LL | let p = &x.b; + | ---- borrow of `x.b` occurs here +LL | drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed + | ^^^ move out of `x.b` occurs here +LL | drop(**p); + | --- borrow later used here + +error[E0505]: cannot move out of `x.b` because it is borrowed + --> $DIR/borrowck-field-sensitivity.rs:51:14 + | +LL | let p = &x.b; + | ---- borrow of `x.b` occurs here +LL | let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed + | ^^^^^^^^^^^^^^^^ move out of `x.b` occurs here +LL | drop(**p); + | --- borrow later used here + +error[E0499]: cannot borrow `x.a` as mutable more than once at a time + --> $DIR/borrowck-field-sensitivity.rs:58:13 + | +LL | let p = &mut x.a; + | -------- first mutable borrow occurs here +LL | let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time + | ^^^^^^^^ second mutable borrow occurs here +LL | drop(*p); + | -- borrow later used here + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:66:10 + | +LL | drop(x.b); + | --- value moved here +LL | drop(x.b); //~ ERROR use of moved value: `x.b` + | ^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:72:10 + | +LL | let _y = A { a: 3, .. x }; + | ---------------- value moved here +LL | drop(x.b); //~ ERROR use of moved value: `x.b` + | ^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:78:14 + | +LL | drop(x.b); + | --- value moved here +LL | let _z = A { a: 3, .. x }; //~ ERROR use of moved value: `x.b` + | ^^^^^^^^^^^^^^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:84:14 + | +LL | let _y = A { a: 3, .. x }; + | ---------------- value moved here +LL | let _z = A { a: 4, .. x }; //~ ERROR use of moved value: `x.b` + | ^^^^^^^^^^^^^^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 11 previous errors + +Some errors occurred: E0382, E0499, E0505. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.rs new file mode 100644 index 00000000000..13fd5fce955 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.rs @@ -0,0 +1,126 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct A { a: isize, b: Box } + +fn deref_after_move() { + let x = A { a: 1, b: box 2 }; + drop(x.b); + drop(*x.b); //~ ERROR use of moved value: `*x.b` +} + +fn deref_after_fu_move() { + let x = A { a: 1, b: box 2 }; + let y = A { a: 3, .. x }; + drop(*x.b); //~ ERROR use of moved value: `*x.b` +} + +fn borrow_after_move() { + let x = A { a: 1, b: box 2 }; + drop(x.b); + let p = &x.b; //~ ERROR use of moved value: `x.b` + drop(**p); +} + +fn borrow_after_fu_move() { + let x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + let p = &x.b; //~ ERROR use of moved value: `x.b` + drop(**p); +} + +fn move_after_borrow() { + let x = A { a: 1, b: box 2 }; + let p = &x.b; + drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed + drop(**p); +} + +fn fu_move_after_borrow() { + let x = A { a: 1, b: box 2 }; + let p = &x.b; + let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed + drop(**p); +} + +fn mut_borrow_after_mut_borrow() { + let mut x = A { a: 1, b: box 2 }; + let p = &mut x.a; + let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time + drop(*p); + drop(*q); +} + +fn move_after_move() { + let x = A { a: 1, b: box 2 }; + drop(x.b); + drop(x.b); //~ ERROR use of moved value: `x.b` +} + +fn move_after_fu_move() { + let x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + drop(x.b); //~ ERROR use of moved value: `x.b` +} + +fn fu_move_after_move() { + let x = A { a: 1, b: box 2 }; + drop(x.b); + let _z = A { a: 3, .. x }; //~ ERROR use of moved value: `x.b` +} + +fn fu_move_after_fu_move() { + let x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + let _z = A { a: 4, .. x }; //~ ERROR use of moved value: `x.b` +} + +// The following functions aren't yet accepted, but they should be. + +fn copy_after_field_assign_after_uninit() { + let mut x: A; + x.a = 1; + drop(x.a); //~ ERROR use of possibly uninitialized variable: `x.a` +} + +fn borrow_after_field_assign_after_uninit() { + let mut x: A; + x.a = 1; + let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a` + drop(*p); +} + +fn move_after_field_assign_after_uninit() { + let mut x: A; + x.b = box 1; + drop(x.b); //~ ERROR use of possibly uninitialized variable: `x.b` +} + +fn main() { + deref_after_move(); + deref_after_fu_move(); + + borrow_after_move(); + borrow_after_fu_move(); + move_after_borrow(); + fu_move_after_borrow(); + mut_borrow_after_mut_borrow(); + + move_after_move(); + move_after_fu_move(); + fu_move_after_move(); + fu_move_after_fu_move(); + + copy_after_field_assign_after_uninit(); + borrow_after_field_assign_after_uninit(); + move_after_field_assign_after_uninit(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.stderr new file mode 100644 index 00000000000..e5eba3790a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-field-sensitivity.stderr @@ -0,0 +1,129 @@ +error[E0382]: use of moved value: `*x.b` + --> $DIR/borrowck-field-sensitivity.rs:18:10 + | +LL | drop(x.b); + | --- value moved here +LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` + | ^^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `*x.b` + --> $DIR/borrowck-field-sensitivity.rs:24:10 + | +LL | let y = A { a: 3, .. x }; + | - value moved here +LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` + | ^^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:30:14 + | +LL | drop(x.b); + | --- value moved here +LL | let p = &x.b; //~ ERROR use of moved value: `x.b` + | ^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:37:14 + | +LL | let _y = A { a: 3, .. x }; + | - value moved here +LL | let p = &x.b; //~ ERROR use of moved value: `x.b` + | ^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0505]: cannot move out of `x.b` because it is borrowed + --> $DIR/borrowck-field-sensitivity.rs:44:10 + | +LL | let p = &x.b; + | --- borrow of `x.b` occurs here +LL | drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed + | ^^^ move out of `x.b` occurs here + +error[E0505]: cannot move out of `x.b` because it is borrowed + --> $DIR/borrowck-field-sensitivity.rs:51:27 + | +LL | let p = &x.b; + | --- borrow of `x.b` occurs here +LL | let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed + | ^ move out of `x.b` occurs here + +error[E0499]: cannot borrow `x.a` as mutable more than once at a time + --> $DIR/borrowck-field-sensitivity.rs:58:18 + | +LL | let p = &mut x.a; + | --- first mutable borrow occurs here +LL | let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time + | ^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:66:10 + | +LL | drop(x.b); + | --- value moved here +LL | drop(x.b); //~ ERROR use of moved value: `x.b` + | ^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:72:10 + | +LL | let _y = A { a: 3, .. x }; + | - value moved here +LL | drop(x.b); //~ ERROR use of moved value: `x.b` + | ^^^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:78:27 + | +LL | drop(x.b); + | --- value moved here +LL | let _z = A { a: 3, .. x }; //~ ERROR use of moved value: `x.b` + | ^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:84:27 + | +LL | let _y = A { a: 3, .. x }; + | - value moved here +LL | let _z = A { a: 4, .. x }; //~ ERROR use of moved value: `x.b` + | ^ value used here after move + | + = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0381]: use of possibly uninitialized variable: `x.a` + --> $DIR/borrowck-field-sensitivity.rs:92:10 + | +LL | drop(x.a); //~ ERROR use of possibly uninitialized variable: `x.a` + | ^^^ use of possibly uninitialized `x.a` + +error[E0381]: use of possibly uninitialized variable: `x.a` + --> $DIR/borrowck-field-sensitivity.rs:98:14 + | +LL | let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a` + | ^^^ use of possibly uninitialized `x.a` + +error[E0381]: use of possibly uninitialized variable: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:105:10 + | +LL | drop(x.b); //~ ERROR use of possibly uninitialized variable: `x.b` + | ^^^ use of possibly uninitialized `x.b` + +error: aborting due to 14 previous errors + +Some errors occurred: E0381, E0382, E0499, E0505. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.ast.stderr new file mode 100644 index 00000000000..4d0c762ca77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.ast.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-fn-in-const-a.rs:19:16 + | +LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] + | ^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.mir.stderr new file mode 100644 index 00000000000..4d0c762ca77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.mir.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-fn-in-const-a.rs:19:16 + | +LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] + | ^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.rs new file mode 100644 index 00000000000..33b78cb26d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-a.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Check that we check fns appearing in constant declarations. +// Issue #22382. + +const MOVE: fn(&String) -> String = { + fn broken(x: &String) -> String { + return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] + //[mir]~^ ERROR [E0507] + } + broken +}; + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.nll.stderr new file mode 100644 index 00000000000..827b66cf068 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.nll.stderr @@ -0,0 +1,13 @@ +error[E0597]: `local.inner` does not live long enough + --> $DIR/borrowck-fn-in-const-c.rs:27:16 + | +LL | return &local.inner; //~ ERROR does not live long enough + | ^^^^^^^^^^^^ borrowed value does not live long enough +LL | } + | - `local.inner` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.rs new file mode 100644 index 00000000000..e607397e920 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we check fns appearing in constant declarations. +// Issue #22382. + +// Returning local references? +struct DropString { + inner: String +} +impl Drop for DropString { + fn drop(&mut self) { + self.inner.clear(); + self.inner.push_str("dropped"); + } +} +const LOCAL_REF: fn() -> &'static str = { + fn broken() -> &'static str { + let local = DropString { inner: format!("Some local string") }; + return &local.inner; //~ ERROR does not live long enough + } + broken +}; + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.stderr new file mode 100644 index 00000000000..1dda8d41860 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-fn-in-const-c.stderr @@ -0,0 +1,13 @@ +error[E0597]: `local.inner` does not live long enough + --> $DIR/borrowck-fn-in-const-c.rs:27:17 + | +LL | return &local.inner; //~ ERROR does not live long enough + | ^^^^^^^^^^^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr new file mode 100644 index 00000000000..f9e517def14 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr @@ -0,0 +1,30 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | - ^^^^^^^^ cannot move out of borrowed content + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref a` + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:15 + | +LL | for &a in &f.a { //~ ERROR cannot move out + | - ^^^^ cannot move out of borrowed content + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref a` + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:15 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | - ^^^^^^^^ cannot move out of borrowed content + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref a` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs new file mode 100644 index 00000000000..31ec5aea7f3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #16205. + +#![feature(box_syntax)] + +struct Foo { + a: [Box; 3], +} + +fn main() { + let mut y = 1; + let x = Some(&mut y); + for &a in x.iter() { //~ ERROR cannot move out + } + + let f = Foo { + a: [box 3, box 4, box 5], + }; + for &a in &f.a { //~ ERROR cannot move out + } + + let x: Option> = Some(box 1); + for &a in x.iter() { //~ ERROR cannot move out + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr new file mode 100644 index 00000000000..baa8a668cd9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr @@ -0,0 +1,30 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:9 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | ^- + | || + | |hint: to prevent move, use `ref a` or `ref mut a` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:9 + | +LL | for &a in &f.a { //~ ERROR cannot move out + | ^- + | || + | |hint: to prevent move, use `ref a` or `ref mut a` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:9 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | ^- + | || + | |hint: to prevent move, use `ref a` or `ref mut a` + | cannot move out of borrowed content + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.nll.stderr new file mode 100644 index 00000000000..c3f71d60072 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.nll.stderr @@ -0,0 +1,27 @@ +error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-for-loop-head-linkage.rs:17:9 + | +LL | for &x in &vector { + | ------- + | | + | immutable borrow occurs here + | borrow used here in later iteration of loop +LL | let cap = vector.capacity(); +LL | vector.extend(repeat(0)); //~ ERROR cannot borrow + | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here + +error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-for-loop-head-linkage.rs:18:9 + | +LL | for &x in &vector { + | ------- + | | + | immutable borrow occurs here + | borrow used here in later iteration of loop +... +LL | vector[1] = 5; //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.rs new file mode 100644 index 00000000000..b79fc5b2bf6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::iter::repeat; + +fn main() { + let mut vector = vec![1, 2]; + for &x in &vector { + let cap = vector.capacity(); + vector.extend(repeat(0)); //~ ERROR cannot borrow + vector[1] = 5; //~ ERROR cannot borrow + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.stderr new file mode 100644 index 00000000000..fd00138356d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-for-loop-head-linkage.stderr @@ -0,0 +1,27 @@ +error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-for-loop-head-linkage.rs:17:9 + | +LL | for &x in &vector { + | ------ + | | | + | | immutable borrow ends here + | immutable borrow occurs here +LL | let cap = vector.capacity(); +LL | vector.extend(repeat(0)); //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here + +error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-for-loop-head-linkage.rs:18:9 + | +LL | for &x in &vector { + | ------ + | | | + | | immutable borrow ends here + | immutable borrow occurs here +... +LL | vector[1] = 5; //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.rs new file mode 100644 index 00000000000..74b542800b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: isize) { println!("{}", x); } + +fn main() { + let x: isize; if 1 > 2 { x = 10; } + foo(x); //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.stderr new file mode 100644 index 00000000000..6c4a53a37d9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-no-else.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-if-no-else.rs:15:9 + | +LL | foo(x); //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.rs new file mode 100644 index 00000000000..f3b02d12854 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: isize) { println!("{}", x); } + +fn main() { + let x: isize; + if 1 > 2 { + println!("whoops"); + } else { + x = 10; + } + foo(x); //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.stderr new file mode 100644 index 00000000000..097d11e387e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-if-with-else.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-if-with-else.rs:20:9 + | +LL | foo(x); //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr new file mode 100644 index 00000000000..0a1bc2c1959 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0506]: cannot assign to `_a` because it is borrowed + --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:19:9 + | +LL | let b = &mut _a; + | ------- borrow of `_a` occurs here +... +LL | _a = 4; //[ast]~ ERROR cannot assign to `_a` + | ^^^^^^ assignment to borrowed `_a` occurs here +... +LL | drop(b); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr new file mode 100644 index 00000000000..cb6d9875a92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr @@ -0,0 +1,12 @@ +error[E0506]: cannot assign to `_a` because it is borrowed + --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:19:9 + | +LL | let b = &mut _a; + | -- borrow of `_a` occurs here +... +LL | _a = 4; //[ast]~ ERROR cannot assign to `_a` + | ^^^^^^ assignment to borrowed `_a` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr new file mode 100644 index 00000000000..0a1bc2c1959 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr @@ -0,0 +1,15 @@ +error[E0506]: cannot assign to `_a` because it is borrowed + --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:19:9 + | +LL | let b = &mut _a; + | ------- borrow of `_a` occurs here +... +LL | _a = 4; //[ast]~ ERROR cannot assign to `_a` + | ^^^^^^ assignment to borrowed `_a` occurs here +... +LL | drop(b); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs new file mode 100644 index 00000000000..6f0e0f43f60 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn main() { + let mut _a = 3; + let b = &mut _a; + { + let c = &*b; + _a = 4; //[ast]~ ERROR cannot assign to `_a` + //[mir]~^ ERROR cannot assign to `_a` because it is borrowed + drop(c); + } + drop(b); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.rs new file mode 100644 index 00000000000..5b32fd2d198 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let j = || -> isize { + let i: isize; + i //~ ERROR use of possibly uninitialized variable: `i` + }; + j(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.stderr new file mode 100644 index 00000000000..e55603c451f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-called-fn-expr.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `i` + --> $DIR/borrowck-init-in-called-fn-expr.rs:14:9 + | +LL | i //~ ERROR use of possibly uninitialized variable: `i` + | ^ use of possibly uninitialized `i` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.rs new file mode 100644 index 00000000000..65f1a1fa098 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let f = || -> isize { + let i: isize; + i //~ ERROR use of possibly uninitialized variable: `i` + }; + println!("{}", f()); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.stderr new file mode 100644 index 00000000000..406fb5e6834 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fn-expr.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `i` + --> $DIR/borrowck-init-in-fn-expr.rs:14:9 + | +LL | i //~ ERROR use of possibly uninitialized variable: `i` + | ^ use of possibly uninitialized `i` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.nll.stderr new file mode 100644 index 00000000000..cac9d890dae --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `origin.y` + --> $DIR/borrowck-init-in-fru.rs:22:5 + | +LL | origin = point {x: 10,.. origin}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `origin.y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.stderr new file mode 100644 index 00000000000..a5c1ef7f4f5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.ast.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `origin.y` + --> $DIR/borrowck-init-in-fru.rs:22:30 + | +LL | origin = point {x: 10,.. origin}; + | ^^^^^^ use of possibly uninitialized `origin.y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.mir.stderr new file mode 100644 index 00000000000..cac9d890dae --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.mir.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `origin.y` + --> $DIR/borrowck-init-in-fru.rs:22:5 + | +LL | origin = point {x: 10,.. origin}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `origin.y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.rs new file mode 100644 index 00000000000..1ec0f980774 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-in-fru.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#[derive(Clone)] +struct point { + x: isize, + y: isize, +} + +fn main() { + let mut origin: point; + origin = point {x: 10,.. origin}; + //[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381] + //[mir]~^^ ERROR [E0381] + origin.clone(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.rs new file mode 100644 index 00000000000..e0d93fd1d47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.rs @@ -0,0 +1,19 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn test() { + let v: isize; + v += 1; //~ ERROR use of possibly uninitialized variable: `v` + v.clone(); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.stderr new file mode 100644 index 00000000000..b8e91e356c1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-op-equal.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `v` + --> $DIR/borrowck-init-op-equal.rs:14:5 + | +LL | v += 1; //~ ERROR use of possibly uninitialized variable: `v` + | ^^^^^^ use of possibly uninitialized `v` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.rs new file mode 100644 index 00000000000..a036286f363 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn test() { + let mut v: isize; + v = v + 1; //~ ERROR use of possibly uninitialized variable: `v` + v.clone(); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.stderr new file mode 100644 index 00000000000..f49c06c0c86 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-init-plus-equal.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `v` + --> $DIR/borrowck-init-plus-equal.rs:13:9 + | +LL | v = v + 1; //~ ERROR use of possibly uninitialized variable: `v` + | ^ use of possibly uninitialized `v` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.nll.stderr new file mode 100644 index 00000000000..e403b076ab4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.nll.stderr @@ -0,0 +1,36 @@ +error[E0501]: cannot borrow `*f` as mutable because previous closure requires unique access + --> $DIR/borrowck-insert-during-each.rs:26:3 + | +LL | f.foo( + | ___^ + | |___| + | || +LL | || |a| { //~ ERROR closure requires unique access to `f` + | || --- closure construction occurs here +LL | || f.n.insert(*a); + | || - first borrow occurs due to use of `f` in closure +LL | || }) + | || ^ + | ||__________| + | |___________borrow occurs here + | borrow later used here + +error[E0500]: closure requires unique access to `f` but it is already borrowed + --> $DIR/borrowck-insert-during-each.rs:27:9 + | +LL | f.foo( + | - + | | + | ___borrow occurs here + | | +LL | | |a| { //~ ERROR closure requires unique access to `f` + | | ^^^ closure construction occurs here +LL | | f.n.insert(*a); + | | - second borrow occurs due to use of `f` in closure +LL | | }) + | |__________- borrow later used here + +error: aborting due to 2 previous errors + +Some errors occurred: E0500, E0501. +For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.rs new file mode 100644 index 00000000000..8499ebb8ac3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::collections::HashSet; + +struct Foo { + n: HashSet, +} + +impl Foo { + pub fn foo(&mut self, mut fun: F) where F: FnMut(&isize) { + for f in &self.n { + fun(f); + } + } +} + +fn bar(f: &mut Foo) { + f.foo( + |a| { //~ ERROR closure requires unique access to `f` + f.n.insert(*a); + }) +} + +fn main() { + let mut f = Foo { n: HashSet::new() }; + bar(&mut f); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.stderr new file mode 100644 index 00000000000..30648edffd8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-insert-during-each.stderr @@ -0,0 +1,15 @@ +error[E0500]: closure requires unique access to `f` but `*f` is already borrowed + --> $DIR/borrowck-insert-during-each.rs:27:9 + | +LL | f.foo( + | - borrow occurs here +LL | |a| { //~ ERROR closure requires unique access to `f` + | ^^^ closure construction occurs here +LL | f.n.insert(*a); + | - borrow occurs due to use of `f` in closure +LL | }) + | - borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0500`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.nll.stderr new file mode 100644 index 00000000000..d90eda41164 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.nll.stderr @@ -0,0 +1,108 @@ +error[E0594]: cannot assign to `***p` which is behind a `&` reference + --> $DIR/borrowck-issue-14498.rs:29:5 + | +LL | let p = &y; + | -- help: consider changing this to be a mutable reference: `&mut y` +LL | ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference + | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:39:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:50:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:61:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:72:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:83:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:94:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:105:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:116:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error: aborting due to 9 previous errors + +Some errors occurred: E0506, E0594. +For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.stderr new file mode 100644 index 00000000000..ffb793e48df --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.ast.stderr @@ -0,0 +1,82 @@ +error[E0389]: cannot assign to data in a `&` reference + --> $DIR/borrowck-issue-14498.rs:29:5 + | +LL | ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference + | ^^^^^^^^ assignment into an immutable reference + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:39:5 + | +LL | let p = &y; + | - borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:50:5 + | +LL | let p = &y; + | - borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:61:5 + | +LL | let p = &y; + | - borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:72:5 + | +LL | let p = &y; + | - borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:83:5 + | +LL | let p = &y.a; + | --- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:94:5 + | +LL | let p = &y.a; + | --- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:105:5 + | +LL | let p = &y.a; + | --- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:116:5 + | +LL | let p = &y.a; + | --- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here + +error: aborting due to 9 previous errors + +Some errors occurred: E0389, E0506. +For more information about an error, try `rustc --explain E0389`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.mir.stderr new file mode 100644 index 00000000000..d90eda41164 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.mir.stderr @@ -0,0 +1,108 @@ +error[E0594]: cannot assign to `***p` which is behind a `&` reference + --> $DIR/borrowck-issue-14498.rs:29:5 + | +LL | let p = &y; + | -- help: consider changing this to be a mutable reference: `&mut y` +LL | ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference + | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:39:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:50:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:61:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:72:5 + | +LL | let p = &y; + | -- borrow of `**y` occurs here +LL | let q = &***p; +LL | **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + | ^^^^^^^ assignment to borrowed `**y` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:83:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:94:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:105:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $DIR/borrowck-issue-14498.rs:116:5 + | +LL | let p = &y.a; + | ---- borrow of `**y.a` occurs here +LL | let q = &***p; +LL | **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed +LL | drop(p); + | - borrow later used here + +error: aborting due to 9 previous errors + +Some errors occurred: E0506, E0594. +For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.rs new file mode 100644 index 00000000000..3c5f932af47 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-14498.rs @@ -0,0 +1,132 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This tests that we can't modify Box<&mut T> contents while they +// are borrowed (#14498). +// +// Also includes tests of the errors reported when the Box in question +// is immutable (#14270). + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(box_syntax)] + +struct A { a: isize } +struct B<'a> { a: Box<&'a mut isize> } + +fn indirect_write_to_imm_box() { + let mut x: isize = 1; + let y: Box<_> = box &mut x; + let p = &y; + ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference + //[mir]~^ ERROR cannot assign to `***p` + drop(p); +} + +fn borrow_in_var_from_var() { + let mut x: isize = 1; + let mut y: Box<_> = box &mut x; + let p = &y; + let q = &***p; + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + drop(p); + drop(q); +} + +fn borrow_in_var_from_var_via_imm_box() { + let mut x: isize = 1; + let y: Box<_> = box &mut x; + let p = &y; + let q = &***p; + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + drop(p); + drop(q); +} + +fn borrow_in_var_from_field() { + let mut x = A { a: 1 }; + let mut y: Box<_> = box &mut x.a; + let p = &y; + let q = &***p; + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + drop(p); + drop(q); +} + +fn borrow_in_var_from_field_via_imm_box() { + let mut x = A { a: 1 }; + let y: Box<_> = box &mut x.a; + let p = &y; + let q = &***p; + **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + drop(p); + drop(q); +} + +fn borrow_in_field_from_var() { + let mut x: isize = 1; + let mut y = B { a: box &mut x }; + let p = &y.a; + let q = &***p; + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + drop(p); + drop(q); +} + +fn borrow_in_field_from_var_via_imm_box() { + let mut x: isize = 1; + let y = B { a: box &mut x }; + let p = &y.a; + let q = &***p; + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + drop(p); + drop(q); +} + +fn borrow_in_field_from_field() { + let mut x = A { a: 1 }; + let mut y = B { a: box &mut x.a }; + let p = &y.a; + let q = &***p; + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + drop(p); + drop(q); +} + +fn borrow_in_field_from_field_via_imm_box() { + let mut x = A { a: 1 }; + let y = B { a: box &mut x.a }; + let p = &y.a; + let q = &***p; + **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + drop(p); + drop(q); +} + +fn main() { + indirect_write_to_imm_box(); + borrow_in_var_from_var(); + borrow_in_var_from_var_via_imm_box(); + borrow_in_var_from_field(); + borrow_in_var_from_field_via_imm_box(); + borrow_in_field_from_var(); + borrow_in_field_from_var_via_imm_box(); + borrow_in_field_from_field(); + borrow_in_field_from_field_via_imm_box(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.rs new file mode 100644 index 00000000000..0e1712137d3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn main() { + let x: Option> = Some(box 1); + match x { + Some(ref _y) => { + let _a = x; //~ ERROR cannot move + } + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.stderr new file mode 100644 index 00000000000..3f184f5f964 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-1.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-issue-2657-1.rs:17:13 + | +LL | Some(ref _y) => { + | ------ borrow of `x.0` occurs here +LL | let _a = x; //~ ERROR cannot move + | ^^ move out of `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.nll.stderr new file mode 100644 index 00000000000..55c6a40d281 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.nll.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-issue-2657-2.rs:17:18 + | +LL | let _b = *y; //~ ERROR cannot move out + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing this dereference operator: `y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.rs new file mode 100644 index 00000000000..a389a4a5593 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.rs @@ -0,0 +1,21 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn main() { + let x: Option> = Some(box 1); + match x { + Some(ref y) => { + let _b = *y; //~ ERROR cannot move out + } + _ => {} + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.stderr new file mode 100644 index 00000000000..42baecd7943 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-2657-2.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-issue-2657-2.rs:17:18 + | +LL | let _b = *y; //~ ERROR cannot move out + | ^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&*y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.rs new file mode 100644 index 00000000000..e3bbfd9d5fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.rs @@ -0,0 +1,38 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +struct Node { + elem: i32, + next: Option>, +} + +fn a() { + let mut node = Node { + elem: 5, + next: None, + }; + + let mut src = &mut node; + {src}; + src.next = None; //~ ERROR use of moved value: `src` [E0382] +} + +fn b() { + let mut src = &mut (22, 44); + {src}; + src.0 = 66; //~ ERROR use of moved value: `src` [E0382] +} + +fn main() { + a(); + b(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.stderr new file mode 100644 index 00000000000..4448cedda69 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-issue-48962.stderr @@ -0,0 +1,23 @@ +error[E0382]: use of moved value: `src` + --> $DIR/borrowck-issue-48962.rs:26:5 + | +LL | {src}; + | --- value moved here +LL | src.next = None; //~ ERROR use of moved value: `src` [E0382] + | ^^^^^^^^ value used here after move + | + = note: move occurs because `src` has type `&mut Node`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `src` + --> $DIR/borrowck-issue-48962.rs:32:5 + | +LL | {src}; + | --- value moved here +LL | src.0 = 66; //~ ERROR use of moved value: `src` [E0382] + | ^^^^^^^^^^ value used here after move + | + = note: move occurs because `src` has type `&mut (i32, i32)`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.rs new file mode 100644 index 00000000000..a6ce36a5507 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.rs @@ -0,0 +1,54 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Note: the borrowck analysis is currently flow-insensitive. +// Therefore, some of these errors are marked as spurious and could be +// corrected by a simple change to the analysis. The others are +// either genuine or would require more advanced changes. The latter +// cases are noted. + +#![feature(box_syntax)] + +fn borrow(_v: &isize) {} +fn borrow_mut(_v: &mut isize) {} +fn cond() -> bool { panic!() } +fn for_func(_f: F) where F: FnOnce() -> bool { panic!() } +fn produce() -> T { panic!(); } + +fn inc(v: &mut Box) { + *v = box (**v + 1); +} + +fn pre_freeze_cond() { + // In this instance, the freeze is conditional and starts before + // the mut borrow. + + let mut v: Box<_> = box 3; + let _w; + if cond() { + _w = &v; + } + borrow_mut(&mut *v); //~ ERROR cannot borrow +} + +fn pre_freeze_else() { + // In this instance, the freeze and mut borrow are on separate sides + // of the if. + + let mut v: Box<_> = box 3; + let _w; + if cond() { + _w = &v; + } else { + borrow_mut(&mut *v); + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.stderr new file mode 100644 index 00000000000..91fe19ab769 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-if.stderr @@ -0,0 +1,14 @@ +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-if.rs:38:21 + | +LL | _w = &v; + | - immutable borrow occurs here +LL | } +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.nll.stderr new file mode 100644 index 00000000000..c46e94866ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.nll.stderr @@ -0,0 +1,26 @@ +error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:45:16 + | +LL | let mut x = &mut v; + | ------ mutable borrow occurs here +LL | for _ in 0..3 { +LL | borrow(&*v); //~ ERROR cannot borrow + | ^^^ immutable borrow occurs here +LL | } +LL | *x = box 5; + | -- borrow used here in later iteration of loop + +error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:109:16 + | +LL | **x += 1; + | -------- borrow used here in later iteration of loop +LL | borrow(&*v); //~ ERROR cannot borrow + | ^^^ immutable borrow occurs here +LL | if cond2 { +LL | x = &mut v; //~ ERROR cannot borrow + | ------ mutable borrow occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.rs new file mode 100644 index 00000000000..f09e7ffd7e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.rs @@ -0,0 +1,150 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Note: the borrowck analysis is currently flow-insensitive. +// Therefore, some of these errors are marked as spurious and could be +// corrected by a simple change to the analysis. The others are +// either genuine or would require more advanced changes. The latter +// cases are noted. + +#![feature(box_syntax)] + +fn borrow(_v: &isize) {} +fn borrow_mut(_v: &mut isize) {} +fn cond() -> bool { panic!() } +fn produce() -> T { panic!(); } + +fn inc(v: &mut Box) { + *v = box (**v + 1); +} + +fn loop_overarching_alias_mut() { + // In this instance, the borrow encompasses the entire loop. + + let mut v: Box<_> = box 3; + let mut x = &mut v; + **x += 1; + loop { + borrow(&*v); //~ ERROR cannot borrow + } +} + +fn block_overarching_alias_mut() { + // In this instance, the borrow encompasses the entire closure call. + + let mut v: Box<_> = box 3; + let mut x = &mut v; + for _ in 0..3 { + borrow(&*v); //~ ERROR cannot borrow + } + *x = box 5; +} + +fn loop_aliased_mut() { + // In this instance, the borrow is carried through the loop. + + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; + let mut _x = &w; + loop { + borrow_mut(&mut *v); //~ ERROR cannot borrow + _x = &v; + } +} + +fn while_aliased_mut() { + // In this instance, the borrow is carried through the loop. + + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; + let mut _x = &w; + while cond() { + borrow_mut(&mut *v); //~ ERROR cannot borrow + _x = &v; + } +} + + +fn loop_aliased_mut_break() { + // In this instance, the borrow is carried through the loop. + + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; + let mut _x = &w; + loop { + borrow_mut(&mut *v); + _x = &v; + break; + } + borrow_mut(&mut *v); //~ ERROR cannot borrow +} + +fn while_aliased_mut_break() { + // In this instance, the borrow is carried through the loop. + + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; + let mut _x = &w; + while cond() { + borrow_mut(&mut *v); + _x = &v; + break; + } + borrow_mut(&mut *v); //~ ERROR cannot borrow +} + +fn while_aliased_mut_cond(cond: bool, cond2: bool) { + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; + let mut x = &mut w; + while cond { + **x += 1; + borrow(&*v); //~ ERROR cannot borrow + if cond2 { + x = &mut v; //~ ERROR cannot borrow + } + } +} + +fn loop_break_pops_scopes<'r, F>(_v: &'r mut [usize], mut f: F) where + F: FnMut(&'r mut usize) -> bool, +{ + // Here we check that when you break out of an inner loop, the + // borrows that go out of scope as you exit the inner loop are + // removed from the bitset. + + while cond() { + while cond() { + // this borrow is limited to the scope of `r`... + let r: &'r mut usize = produce(); + if !f(&mut *r) { + break; // ...so it is not live as exit the `while` loop here + } + } + } +} + +fn loop_loop_pops_scopes<'r, F>(_v: &'r mut [usize], mut f: F) + where F: FnMut(&'r mut usize) -> bool +{ + // Similar to `loop_break_pops_scopes` but for the `loop` keyword + + while cond() { + while cond() { + // this borrow is limited to the scope of `r`... + let r: &'r mut usize = produce(); + if !f(&mut *r) { + continue; // ...so it is not live as exit (and re-enter) the `while` loop here + } + } + } +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.stderr new file mode 100644 index 00000000000..534e30b564d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-loop.stderr @@ -0,0 +1,93 @@ +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:35:17 + | +LL | let mut x = &mut v; + | - mutable borrow occurs here +... +LL | borrow(&*v); //~ ERROR cannot borrow + | ^^ immutable borrow occurs here +LL | } +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:45:17 + | +LL | let mut x = &mut v; + | - mutable borrow occurs here +LL | for _ in 0..3 { +LL | borrow(&*v); //~ ERROR cannot borrow + | ^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:57:25 + | +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | _x = &v; + | - immutable borrow occurs here +LL | } +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:69:25 + | +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | _x = &v; + | - immutable borrow occurs here +LL | } +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:86:21 + | +LL | _x = &v; + | - immutable borrow occurs here +... +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow-loop.rs:100:21 + | +LL | _x = &v; + | - immutable borrow occurs here +... +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-lend-flow-loop.rs:109:17 + | +LL | borrow(&*v); //~ ERROR cannot borrow + | ^^ immutable borrow occurs here +LL | if cond2 { +LL | x = &mut v; //~ ERROR cannot borrow + | - mutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/borrowck-lend-flow-loop.rs:111:22 + | +LL | x = &mut v; //~ ERROR cannot borrow + | ^ mutable borrow starts here in previous iteration of loop +... +LL | } + | - mutable borrow ends here + +error: aborting due to 8 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.nll.stderr new file mode 100644 index 00000000000..0b6eabfb7ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-lend-flow-match.rs:28:13 + | +LL | Some(ref r) => { + | ----- borrow of `x` occurs here +LL | x = Some(1); //[ast]~ ERROR cannot assign + | ^^^^^^^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(r); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.stderr new file mode 100644 index 00000000000..0fcc6bbbc83 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.ast.stderr @@ -0,0 +1,11 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-lend-flow-match.rs:28:13 + | +LL | Some(ref r) => { + | ----- borrow of `x` occurs here +LL | x = Some(1); //[ast]~ ERROR cannot assign + | ^^^^^^^^^^^ assignment to borrowed `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.mir.stderr new file mode 100644 index 00000000000..0b6eabfb7ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.mir.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-lend-flow-match.rs:28:13 + | +LL | Some(ref r) => { + | ----- borrow of `x` occurs here +LL | x = Some(1); //[ast]~ ERROR cannot assign + | ^^^^^^^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(r); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.rs new file mode 100644 index 00000000000..f2f3e791422 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow-match.rs @@ -0,0 +1,36 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![allow(unused_variables)] +#![allow(unused_assignments)] + +fn separate_arms() { + // Here both arms perform assignments, but only is illegal. + + let mut x = None; + match x { + None => { + // It is ok to reassign x here, because there is in + // fact no outstanding loan of x! + x = Some(0); + } + Some(ref r) => { + x = Some(1); //[ast]~ ERROR cannot assign + //[mir]~^ ERROR cannot assign to `x` because it is borrowed + drop(r); + } + } + x.clone(); // just to prevent liveness warnings +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.rs new file mode 100644 index 00000000000..1ed779cfaac --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.rs @@ -0,0 +1,45 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Note: the borrowck analysis is currently flow-insensitive. +// Therefore, some of these errors are marked as spurious and could be +// corrected by a simple change to the analysis. The others are +// either genuine or would require more advanced changes. The latter +// cases are noted. + +#![feature(box_syntax)] + +fn borrow(_v: &isize) {} +fn borrow_mut(_v: &mut isize) {} +fn cond() -> bool { panic!() } +fn for_func(_f: F) where F: FnOnce() -> bool { panic!() } +fn produce() -> T { panic!(); } + +fn inc(v: &mut Box) { + *v = box (**v + 1); +} + +fn pre_freeze() { + // In this instance, the freeze starts before the mut borrow. + + let mut v: Box<_> = box 3; + let _w = &v; + borrow_mut(&mut *v); //~ ERROR cannot borrow +} + +fn post_freeze() { + // In this instance, the const alias starts after the borrow. + + let mut v: Box<_> = box 3; + borrow_mut(&mut *v); + let _w = &v; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.stderr new file mode 100644 index 00000000000..1fedf0a0f62 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-lend-flow.stderr @@ -0,0 +1,13 @@ +error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable + --> $DIR/borrowck-lend-flow.rs:34:21 + | +LL | let _w = &v; + | - immutable borrow occurs here +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.rs new file mode 100644 index 00000000000..57b584a8959 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.rs @@ -0,0 +1,38 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +use std::thread; + +fn borrow(v: &isize, f: F) where F: FnOnce(&isize) { + f(v); +} + +fn box_imm() { + let v: Box<_> = box 3; + let _w = &v; + thread::spawn(move|| { + println!("v={}", *v); + //~^ ERROR cannot move `v` into closure + }); +} + +fn box_imm_explicit() { + let v: Box<_> = box 3; + let _w = &v; + thread::spawn(move|| { + println!("v={}", *v); + //~^ ERROR cannot move + }); +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.stderr new file mode 100644 index 00000000000..20ab864a53b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move-cc.stderr @@ -0,0 +1,21 @@ +error[E0504]: cannot move `v` into closure because it is borrowed + --> $DIR/borrowck-loan-blocks-move-cc.rs:23:27 + | +LL | let _w = &v; + | - borrow of `v` occurs here +LL | thread::spawn(move|| { +LL | println!("v={}", *v); + | ^ move into closure occurs here + +error[E0504]: cannot move `v` into closure because it is borrowed + --> $DIR/borrowck-loan-blocks-move-cc.rs:32:27 + | +LL | let _w = &v; + | - borrow of `v` occurs here +LL | thread::spawn(move|| { +LL | println!("v={}", *v); + | ^ move into closure occurs here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0504`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.rs new file mode 100644 index 00000000000..f3f18807314 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn take(_v: Box) { +} + +fn box_imm() { + let v = box 3; + let _w = &v; + take(v); //~ ERROR cannot move out of `v` because it is borrowed +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.stderr new file mode 100644 index 00000000000..6bd6bb268af --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-move.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `v` because it is borrowed + --> $DIR/borrowck-loan-blocks-move.rs:19:10 + | +LL | let _w = &v; + | - borrow of `v` occurs here +LL | take(v); //~ ERROR cannot move out of `v` because it is borrowed + | ^ move out of `v` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr new file mode 100644 index 00000000000..5c3cd46a87d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr @@ -0,0 +1,19 @@ +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-loan-blocks-mut-uniq.rs:20:12 + | +LL | borrow(&*v, + | - --- immutable borrow occurs here + | _____| + | | +LL | | |w| { //~ ERROR cannot borrow `v` as mutable + | | ^^^ mutable borrow occurs here +LL | | v = box 4; + | | - second borrow occurs due to use of `v` in closure +LL | | assert_eq!(*v, 3); +LL | | assert_eq!(*w, 4); +LL | | }) + | |__________- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.rs new file mode 100644 index 00000000000..32d8088549d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.rs @@ -0,0 +1,28 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn borrow(v: &isize, f: F) where F: FnOnce(&isize) { + f(v); +} + +fn box_imm() { + let mut v: Box<_> = box 3; + borrow(&*v, + |w| { //~ ERROR cannot borrow `v` as mutable + v = box 4; + assert_eq!(*v, 3); + assert_eq!(*w, 4); + }) +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.stderr new file mode 100644 index 00000000000..752322dec87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-blocks-mut-uniq.stderr @@ -0,0 +1,16 @@ +error[E0502]: cannot borrow `v` as mutable because `*v` is also borrowed as immutable + --> $DIR/borrowck-loan-blocks-mut-uniq.rs:20:12 + | +LL | borrow(&*v, + | -- immutable borrow occurs here +LL | |w| { //~ ERROR cannot borrow `v` as mutable + | ^^^ mutable borrow occurs here +LL | v = box 4; + | - borrow occurs due to use of `v` in closure +... +LL | }) + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.nll.stderr new file mode 100644 index 00000000000..03ddfb4c903 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/borrowck-loan-in-overloaded-op.rs:31:20 + | +LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur + | - ^ value borrowed here after move + | | + | value moved here + | + = note: move occurs because `x` has type `foo`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.rs new file mode 100644 index 00000000000..a9079cfc27d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_patterns)] +#![feature(box_syntax)] + +use std::ops::Add; + +#[derive(Clone)] +struct foo(Box); + +impl Add for foo { + type Output = foo; + + fn add(self, f: foo) -> foo { + let foo(box i) = self; + let foo(box j) = f; + foo(box (i + j)) + } +} + +fn main() { + let x = foo(box 3); + let _y = {x} + x.clone(); // the `{x}` forces a move to occur + //~^ ERROR use of moved value: `x` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.stderr new file mode 100644 index 00000000000..7cd54e293b0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-in-overloaded-op.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-loan-in-overloaded-op.rs:31:20 + | +LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur + | - ^ value used here after move + | | + | value moved here + | + = note: move occurs because `x` has type `foo`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr new file mode 100644 index 00000000000..eb9e72a6c5c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `*s` because it is borrowed + --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:26:5 + | +LL | let alias: &'static mut String = s; + | - borrow of `*s` occurs here +... +LL | *s = String::new(); //~ ERROR cannot assign + | ^^ assignment to borrowed `*s` occurs here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.rs new file mode 100644 index 00000000000..228e71025fd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; + +fn leak(mut b: Box) -> &'static mut T { + // isn't this supposed to be safe? + let inner = &mut *b as *mut _; + mem::forget(b); + unsafe { &mut *inner } +} + +fn evil(mut s: &'static mut String) +{ + // create alias + let alias: &'static mut String = s; + let inner: &str = &alias; + // free value + *s = String::new(); //~ ERROR cannot assign + let _spray = "0wned".to_owned(); + // ... and then use it + println!("{}", inner); +} + +fn main() { + evil(leak(Box::new("hello".to_owned()))); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.stderr new file mode 100644 index 00000000000..3f5e09b7443 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-of-static-data-issue-27616.stderr @@ -0,0 +1,12 @@ +error[E0506]: cannot assign to `*s` because it is borrowed + --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:26:5 + | +LL | let alias: &'static mut String = s; + | - borrow of `*s` occurs here +... +LL | *s = String::new(); //~ ERROR cannot assign + | ^^^^^^^^^^^^^^^^^^ assignment to borrowed `*s` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr new file mode 100644 index 00000000000..b7c87162587 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr @@ -0,0 +1,28 @@ +error[E0503]: cannot use `p` because it was mutably borrowed + --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:48:5 + | +LL | let q = &mut p; + | ------ borrow of `p` occurs here +LL | +LL | p + 3; //~ ERROR cannot use `p` + | ^ use of borrowed `p` +... +LL | *q + 3; // OK to use the new alias `q` + | -- borrow later used here + +error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:49:5 + | +LL | let q = &mut p; + | ------ mutable borrow occurs here +... +LL | p.times(3); //~ ERROR cannot borrow `p` + | ^ immutable borrow occurs here +LL | +LL | *q + 3; // OK to use the new alias `q` + | -- borrow later used here + +error: aborting due to 2 previous errors + +Some errors occurred: E0502, E0503. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.rs new file mode 100644 index 00000000000..cce55b6c941 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.rs @@ -0,0 +1,56 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Add; + +#[derive(Copy, Clone)] +struct Point { + x: isize, + y: isize, +} + +impl Add for Point { + type Output = isize; + + fn add(self, z: isize) -> isize { + self.x + self.y + z + } +} + +impl Point { + pub fn times(&self, z: isize) -> isize { + self.x * self.y * z + } +} + +fn a() { + let mut p = Point {x: 3, y: 4}; + + // ok (we can loan out rcvr) + p + 3; + p.times(3); +} + +fn b() { + let mut p = Point {x: 3, y: 4}; + + // Here I create an outstanding loan and check that we get conflicts: + + let q = &mut p; + + p + 3; //~ ERROR cannot use `p` + p.times(3); //~ ERROR cannot borrow `p` + + *q + 3; // OK to use the new alias `q` + q.x += 1; // and OK to mutate it +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.stderr new file mode 100644 index 00000000000..4db1d1f298e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr-overloaded-op.stderr @@ -0,0 +1,25 @@ +error[E0503]: cannot use `p` because it was mutably borrowed + --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:48:5 + | +LL | let q = &mut p; + | - borrow of `p` occurs here +LL | +LL | p + 3; //~ ERROR cannot use `p` + | ^ use of borrowed `p` + +error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:49:5 + | +LL | let q = &mut p; + | - mutable borrow occurs here +... +LL | p.times(3); //~ ERROR cannot borrow `p` + | ^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error: aborting due to 2 previous errors + +Some errors occurred: E0502, E0503. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.nll.stderr new file mode 100644 index 00000000000..a5b81027c2f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.nll.stderr @@ -0,0 +1,27 @@ +error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-loan-rcvr.rs:34:14 + | +LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable + | - ^^ mutable borrow occurs here + | | + | _____immutable borrow occurs here + | | +LL | | p.x = 10; + | | - second borrow occurs due to use of `p` in closure +LL | | }) + | |______- borrow later used here + +error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-loan-rcvr.rs:45:5 + | +LL | let l = &mut p; + | ------ mutable borrow occurs here +LL | p.impurem(); //~ ERROR cannot borrow + | ^ immutable borrow occurs here +LL | +LL | l.x += 1; + | -------- borrow later used here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.rs new file mode 100644 index 00000000000..014b27f9659 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.rs @@ -0,0 +1,51 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +struct point { x: isize, y: isize } + +trait methods { + fn impurem(&self); + fn blockm(&self, f: F) where F: FnOnce(); +} + +impl methods for point { + fn impurem(&self) { + } + + fn blockm(&self, f: F) where F: FnOnce() { f() } +} + +fn a() { + let mut p = point {x: 3, y: 4}; + + // Here: it's ok to call even though receiver is mutable, because we + // can loan it out. + p.impurem(); + + // But in this case we do not honor the loan: + p.blockm(|| { //~ ERROR cannot borrow `p` as mutable + p.x = 10; + }) +} + +fn b() { + let mut p = point {x: 3, y: 4}; + + // Here I create an outstanding loan and check that we get conflicts: + + let l = &mut p; + p.impurem(); //~ ERROR cannot borrow + + l.x += 1; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.stderr new file mode 100644 index 00000000000..f5d3cfb3834 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-rcvr.stderr @@ -0,0 +1,26 @@ +error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-loan-rcvr.rs:34:14 + | +LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable + | - ^^ mutable borrow occurs here + | | + | immutable borrow occurs here +LL | p.x = 10; + | - borrow occurs due to use of `p` in closure +LL | }) + | - immutable borrow ends here + +error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-loan-rcvr.rs:45:5 + | +LL | let l = &mut p; + | - mutable borrow occurs here +LL | p.impurem(); //~ ERROR cannot borrow + | ^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.nll.stderr new file mode 100644 index 00000000000..492e90914ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.nll.stderr @@ -0,0 +1,16 @@ +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-loan-vec-content.rs:28:9 + | +LL | / takes_imm_elt( +LL | | &v[0], + | | - immutable borrow occurs here +LL | | || { //~ ERROR cannot borrow `v` as mutable + | | ^^ mutable borrow occurs here +LL | | v[1] = 4; + | | - second borrow occurs due to use of `v` in closure +LL | | }) + | |__________- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.rs new file mode 100644 index 00000000000..c5de95f8fc0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.rs @@ -0,0 +1,34 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Here we check that it is allowed to lend out an element of a +// (locally rooted) mutable, unique vector, and that we then prevent +// modifications to the contents. + +fn takes_imm_elt(_v: &isize, f: F) where F: FnOnce() { + f(); +} + +fn has_mut_vec_and_does_not_try_to_change_it() { + let mut v: Vec = vec![1, 2, 3]; + takes_imm_elt(&v[0], || {}) +} + +fn has_mut_vec_but_tries_to_change_it() { + let mut v: Vec = vec![1, 2, 3]; + takes_imm_elt( + &v[0], + || { //~ ERROR cannot borrow `v` as mutable + v[1] = 4; + }) +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.stderr new file mode 100644 index 00000000000..2fcfd1fb08d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-loan-vec-content.stderr @@ -0,0 +1,15 @@ +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-loan-vec-content.rs:28:9 + | +LL | &v[0], + | - immutable borrow occurs here +LL | || { //~ ERROR cannot borrow `v` as mutable + | ^^ mutable borrow occurs here +LL | v[1] = 4; + | - borrow occurs due to use of `v` in closure +LL | }) + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr new file mode 100644 index 00000000000..97bf509a458 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/borrowck-local-borrow-outlives-fn.rs:15:5 + | +LL | &x + | ^^ borrowed value does not live long enough +... +LL | } + | - `x` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr new file mode 100644 index 00000000000..af1d294c387 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/borrowck-local-borrow-outlives-fn.rs:15:6 + | +LL | &x + | ^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr new file mode 100644 index 00000000000..97bf509a458 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/borrowck-local-borrow-outlives-fn.rs:15:5 + | +LL | &x + | ^^ borrowed value does not live long enough +... +LL | } + | - `x` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.rs new file mode 100644 index 00000000000..0d5feb6b9cc --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-outlives-fn.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn cplusplus_mode(x: isize) -> &'static isize { + &x + //[ast]~^ ERROR `x` does not live long enough [E0597] + //[mir]~^^ ERROR `x` does not live long enough [E0597] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr new file mode 100644 index 00000000000..5e2b469e68f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: `z.1` does not live long enough + --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:16:15 + | +LL | *x = Some(&mut z.1); + | ^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `z.1` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr new file mode 100644 index 00000000000..0c61c13345c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr @@ -0,0 +1,14 @@ +error[E0597]: `z.1` does not live long enough + --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:16:20 + | +LL | *x = Some(&mut z.1); + | ^^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr new file mode 100644 index 00000000000..5e2b469e68f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr @@ -0,0 +1,14 @@ +error[E0597]: `z.1` does not live long enough + --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:16:15 + | +LL | *x = Some(&mut z.1); + | ^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `z.1` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs new file mode 100644 index 00000000000..2c9ace4825d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) { + let mut z = (0, 0); + *x = Some(&mut z.1); + //[ast]~^ ERROR `z.1` does not live long enough [E0597] + //[mir]~^^ ERROR `z.1` does not live long enough [E0597] + panic!("catch me for a dangling pointer!") +} + +fn main() { + cplusplus_mode_exceptionally_unsafe(&mut None); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.nll.stderr new file mode 100644 index 00000000000..8dec40520c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.nll.stderr @@ -0,0 +1,73 @@ +error[E0503]: cannot use `foo` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:22:19 + | +LL | let p = &mut foo; + | -------- borrow of `foo` occurs here +LL | let _ = match foo { //[mir]~ ERROR [E0503] + | ^^^ use of borrowed `foo` +... +LL | drop(p); + | - borrow later used here + +error[E0503]: cannot use `foo` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:23:9 + | +LL | let p = &mut foo; + | -------- borrow of `foo` occurs here +LL | let _ = match foo { //[mir]~ ERROR [E0503] +LL | Foo::B => 1, //[mir]~ ERROR [E0503] + | ^^^^^^ use of borrowed `foo` +... +LL | drop(p); + | - borrow later used here + +error[E0503]: cannot use `foo.0` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:25:16 + | +LL | let p = &mut foo; + | -------- borrow of `foo` occurs here +... +LL | Foo::A(x) => x //[ast]~ ERROR [E0503] + | ^ use of borrowed `foo` +... +LL | drop(p); + | - borrow later used here + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:35:19 + | +LL | let r = &mut x; + | ------ borrow of `x` occurs here +LL | let _ = match x { //[mir]~ ERROR [E0503] + | ^ use of borrowed `x` +... +LL | drop(r); + | - borrow later used here + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:36:9 + | +LL | let r = &mut x; + | ------ borrow of `x` occurs here +LL | let _ = match x { //[mir]~ ERROR [E0503] +LL | x => x + 1, //[ast]~ ERROR [E0503] + | ^ use of borrowed `x` +... +LL | drop(r); + | - borrow later used here + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:38:9 + | +LL | let r = &mut x; + | ------ borrow of `x` occurs here +... +LL | y => y + 2, //[ast]~ ERROR [E0503] + | ^ use of borrowed `x` +... +LL | drop(r); + | - borrow later used here + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.stderr new file mode 100644 index 00000000000..2e49f90a169 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.ast.stderr @@ -0,0 +1,30 @@ +error[E0503]: cannot use `(foo as Foo::A).0` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:25:16 + | +LL | let p = &mut foo; + | --- borrow of `foo` occurs here +... +LL | Foo::A(x) => x //[ast]~ ERROR [E0503] + | ^ use of borrowed `foo` + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:36:9 + | +LL | let r = &mut x; + | - borrow of `x` occurs here +LL | let _ = match x { //[mir]~ ERROR [E0503] +LL | x => x + 1, //[ast]~ ERROR [E0503] + | ^ use of borrowed `x` + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:38:9 + | +LL | let r = &mut x; + | - borrow of `x` occurs here +... +LL | y => y + 2, //[ast]~ ERROR [E0503] + | ^ use of borrowed `x` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.mir.stderr new file mode 100644 index 00000000000..8dec40520c4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.mir.stderr @@ -0,0 +1,73 @@ +error[E0503]: cannot use `foo` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:22:19 + | +LL | let p = &mut foo; + | -------- borrow of `foo` occurs here +LL | let _ = match foo { //[mir]~ ERROR [E0503] + | ^^^ use of borrowed `foo` +... +LL | drop(p); + | - borrow later used here + +error[E0503]: cannot use `foo` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:23:9 + | +LL | let p = &mut foo; + | -------- borrow of `foo` occurs here +LL | let _ = match foo { //[mir]~ ERROR [E0503] +LL | Foo::B => 1, //[mir]~ ERROR [E0503] + | ^^^^^^ use of borrowed `foo` +... +LL | drop(p); + | - borrow later used here + +error[E0503]: cannot use `foo.0` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:25:16 + | +LL | let p = &mut foo; + | -------- borrow of `foo` occurs here +... +LL | Foo::A(x) => x //[ast]~ ERROR [E0503] + | ^ use of borrowed `foo` +... +LL | drop(p); + | - borrow later used here + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:35:19 + | +LL | let r = &mut x; + | ------ borrow of `x` occurs here +LL | let _ = match x { //[mir]~ ERROR [E0503] + | ^ use of borrowed `x` +... +LL | drop(r); + | - borrow later used here + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:36:9 + | +LL | let r = &mut x; + | ------ borrow of `x` occurs here +LL | let _ = match x { //[mir]~ ERROR [E0503] +LL | x => x + 1, //[ast]~ ERROR [E0503] + | ^ use of borrowed `x` +... +LL | drop(r); + | - borrow later used here + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-match-already-borrowed.rs:38:9 + | +LL | let r = &mut x; + | ------ borrow of `x` occurs here +... +LL | y => y + 2, //[ast]~ ERROR [E0503] + | ^ use of borrowed `x` +... +LL | drop(r); + | - borrow later used here + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.rs new file mode 100644 index 00000000000..c2136e62a7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-already-borrowed.rs @@ -0,0 +1,42 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +enum Foo { + A(i32), + B +} + +fn match_enum() { + let mut foo = Foo::B; + let p = &mut foo; + let _ = match foo { //[mir]~ ERROR [E0503] + Foo::B => 1, //[mir]~ ERROR [E0503] + _ => 2, + Foo::A(x) => x //[ast]~ ERROR [E0503] + //[mir]~^ ERROR [E0503] + }; + drop(p); +} + + +fn main() { + let mut x = 1; + let r = &mut x; + let _ = match x { //[mir]~ ERROR [E0503] + x => x + 1, //[ast]~ ERROR [E0503] + //[mir]~^ ERROR [E0503] + y => y + 2, //[ast]~ ERROR [E0503] + //[mir]~^ ERROR [E0503] + }; + drop(r); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr new file mode 100644 index 00000000000..0191e0765b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr @@ -0,0 +1,58 @@ +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:27:13 + | +LL | x => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:34:13 + | +LL | E::Foo(x) => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:41:13 + | +LL | S { bar: x } => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:48:13 + | +LL | (x,) => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:55:13 + | +LL | [x,_,_] => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.stderr new file mode 100644 index 00000000000..0d776f44daa --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.ast.stderr @@ -0,0 +1,43 @@ +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:27:13 + | +LL | x => { + | - first assignment to `x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:34:13 + | +LL | E::Foo(x) => { + | - first assignment to `x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:41:13 + | +LL | S { bar: x } => { + | - first assignment to `x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:48:13 + | +LL | (x,) => { + | - first assignment to `x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:55:13 + | +LL | [x,_,_] => { + | - first assignment to `x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.mir.stderr new file mode 100644 index 00000000000..0191e0765b3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.mir.stderr @@ -0,0 +1,58 @@ +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:27:13 + | +LL | x => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:34:13 + | +LL | E::Foo(x) => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:41:13 + | +LL | S { bar: x } => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:48:13 + | +LL | (x,) => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/borrowck-match-binding-is-assignment.rs:55:13 + | +LL | [x,_,_] => { + | - + | | + | first assignment to `x` + | consider changing this to `mut x` +LL | x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + | ^^^^^^ cannot assign twice to immutable variable + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.rs new file mode 100644 index 00000000000..30047f84041 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-match-binding-is-assignment.rs @@ -0,0 +1,59 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Test that immutable pattern bindings cannot be reassigned. + +enum E { + Foo(isize) +} + +struct S { + bar: isize, +} + +pub fn main() { + match 1 { + x => { + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + //[mir]~^ ERROR [E0384] + } + } + + match E::Foo(1) { + E::Foo(x) => { + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + //[mir]~^ ERROR [E0384] + } + } + + match (S { bar: 1 }) { + S { bar: x } => { + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + //[mir]~^ ERROR [E0384] + } + } + + match (1,) { + (x,) => { + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + //[mir]~^ ERROR [E0384] + } + } + + match [1,2,3] { + [x,_,_] => { + x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` + //[mir]~^ ERROR [E0384] + } + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.nll.stderr new file mode 100644 index 00000000000..f5b7ca22278 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.nll.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of captured variable in an `FnMut` closure + --> $DIR/borrowck-move-by-capture.rs:19:29 + | +LL | let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of captured variable in an `FnMut` closure + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.rs new file mode 100644 index 00000000000..bad52121043 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax,unboxed_closures)] + +fn to_fn_mut>(f: F) -> F { f } +fn to_fn_once>(f: F) -> F { f } + +pub fn main() { + let bar: Box<_> = box 3; + let _g = to_fn_mut(|| { + let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of + }); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.stderr new file mode 100644 index 00000000000..a88af1596ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-by-capture.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of captured outer variable in an `FnMut` closure + --> $DIR/borrowck-move-by-capture.rs:19:29 + | +LL | let bar: Box<_> = box 3; + | --- captured outer variable +LL | let _g = to_fn_mut(|| { +LL | let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of + | ^^^^^^^^^^^^^^^^ cannot move out of captured outer variable in an `FnMut` closure + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs new file mode 100644 index 00000000000..c02c6a71514 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// verify that an error is raised when trying to move out of a +// borrowed path. + +#![feature(box_syntax)] + +fn main() { + let a: Box> = box box 2; + let b = &a; + + let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr new file mode 100644 index 00000000000..1bdc8a85232 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr @@ -0,0 +1,12 @@ +error[E0505]: cannot move out of `*a` because it is borrowed + --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:20:9 + | +LL | let b = &a; + | - borrow of `a` occurs here +LL | +LL | let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed + | ^ move out of `*a` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr new file mode 100644 index 00000000000..4f692bfc55e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-from-unsafe-ptr.rs:13:13 + | +LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer + | ^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.rs new file mode 100644 index 00000000000..9a39ff6206b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +unsafe fn foo(x: *const Box) -> Box { + let y = *x; //~ ERROR cannot move out of dereference of raw pointer + return y; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.stderr new file mode 100644 index 00000000000..cad155103f0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-from-unsafe-ptr.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of dereference of raw pointer + --> $DIR/borrowck-move-from-unsafe-ptr.rs:13:13 + | +LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer + | ^^ + | | + | cannot move out of dereference of raw pointer + | help: consider using a reference instead: `&*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr new file mode 100644 index 00000000000..f670936dbac --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr @@ -0,0 +1,32 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:16:13 + | +LL | fn arg_item(&_x: &String) {} + | ^-- + | || + | |data moved here + | |help: to prevent move, use ref or ref mut: `ref _x` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:21:11 + | +LL | with(|&_x| ()) + | ^-- + | || + | |data moved here + | |help: to prevent move, use ref or ref mut: `ref _x` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:27:15 + | +LL | let &_x = &"hi".to_string(); + | -- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _x` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.stderr new file mode 100644 index 00000000000..fa7fb649c8d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.ast.stderr @@ -0,0 +1,30 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:16:13 + | +LL | fn arg_item(&_x: &String) {} + | ^-- + | || + | |hint: to prevent move, use `ref _x` or `ref mut _x` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:21:11 + | +LL | with(|&_x| ()) + | ^-- + | || + | |hint: to prevent move, use `ref _x` or `ref mut _x` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:27:9 + | +LL | let &_x = &"hi".to_string(); + | ^-- + | || + | |hint: to prevent move, use `ref _x` or `ref mut _x` + | cannot move out of borrowed content + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.mir.stderr new file mode 100644 index 00000000000..f670936dbac --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.mir.stderr @@ -0,0 +1,32 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:16:13 + | +LL | fn arg_item(&_x: &String) {} + | ^-- + | || + | |data moved here + | |help: to prevent move, use ref or ref mut: `ref _x` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:21:11 + | +LL | with(|&_x| ()) + | ^-- + | || + | |data moved here + | |help: to prevent move, use ref or ref mut: `ref _x` + | cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-in-irrefut-pat.rs:27:15 + | +LL | let &_x = &"hi".to_string(); + | -- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _x` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.rs new file mode 100644 index 00000000000..5fdde484f82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-in-irrefut-pat.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn with(f: F) where F: FnOnce(&String) {} + +fn arg_item(&_x: &String) {} + //[ast]~^ ERROR cannot move out of borrowed content [E0507] + //[mir]~^^ ERROR [E0507] + +fn arg_closure() { + with(|&_x| ()) + //[ast]~^ ERROR cannot move out of borrowed content [E0507] + //[mir]~^^ ERROR [E0507] +} + +fn let_pat() { + let &_x = &"hi".to_string(); + //[ast]~^ ERROR cannot move out of borrowed content [E0507] + //[mir]~^^ ERROR [E0507] +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr new file mode 100644 index 00000000000..d896ff491c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr @@ -0,0 +1,17 @@ +error[E0382]: use of moved value: `t` + --> $DIR/borrowck-move-moved-value-into-closure.rs:24:12 + | +LL | call_f(move|| { *t + 1 }); + | ------ - variable moved due to use in closure + | | + | value moved into closure here +LL | call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value + | ^^^^^^ - use occurs due to use in closure + | | + | value used here after move + | + = note: move occurs because `t` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.stderr new file mode 100644 index 00000000000..c7576b1b32d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.ast.stderr @@ -0,0 +1,13 @@ +error[E0382]: capture of moved value: `t` + --> $DIR/borrowck-move-moved-value-into-closure.rs:24:22 + | +LL | call_f(move|| { *t + 1 }); + | ------ value moved (into closure) here +LL | call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value + | ^ value captured here after move + | + = note: move occurs because `t` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.mir.stderr new file mode 100644 index 00000000000..d896ff491c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.mir.stderr @@ -0,0 +1,17 @@ +error[E0382]: use of moved value: `t` + --> $DIR/borrowck-move-moved-value-into-closure.rs:24:12 + | +LL | call_f(move|| { *t + 1 }); + | ------ - variable moved due to use in closure + | | + | value moved into closure here +LL | call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value + | ^^^^^^ - use occurs due to use in closure + | | + | value used here after move + | + = note: move occurs because `t` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.rs new file mode 100644 index 00000000000..2bd6f75df1b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-moved-value-into-closure.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(box_syntax)] + +fn call_f isize>(f: F) -> isize { + f() +} + +fn main() { + let t: Box<_> = box 3; + + call_f(move|| { *t + 1 }); + call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value + //[mir]~^ ERROR use of moved value +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.rs new file mode 100644 index 00000000000..2fb89e6364b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that attempt to move `&mut` pointer while pointee is borrowed +// yields an error. +// +// Example from src/librustc_borrowck/borrowck/README.md + +fn foo(t0: &mut isize) { + let p: &isize = &*t0; // Freezes `*t0` + let t1 = t0; //~ ERROR cannot move out of `t0` + *t1 = 22; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.stderr new file mode 100644 index 00000000000..0cbcda4d2cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-mut-base-ptr.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `t0` because it is borrowed + --> $DIR/borrowck-move-mut-base-ptr.rs:18:9 + | +LL | let p: &isize = &*t0; // Freezes `*t0` + | --- borrow of `*t0` occurs here +LL | let t1 = t0; //~ ERROR cannot move out of `t0` + | ^^ move out of `t0` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.nll.stderr new file mode 100644 index 00000000000..d67b63b5aa7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.nll.stderr @@ -0,0 +1,19 @@ +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array.rs:20:14 + | +LL | let [_, _x] = a; + | -- value moved here +LL | let [.., _y] = a; //[ast]~ ERROR [E0382] + | ^^ value used here after move + +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array.rs:27:10 + | +LL | let [_x, _] = a; + | -- value moved here +LL | let [_y..] = a; //[ast]~ ERROR [E0382] + | ^^ value used here after move + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.stderr new file mode 100644 index 00000000000..d19c23dce5f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.ast.stderr @@ -0,0 +1,23 @@ +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array.rs:20:14 + | +LL | let [_, _x] = a; + | -- value moved here +LL | let [.., _y] = a; //[ast]~ ERROR [E0382] + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array.rs:27:10 + | +LL | let [_x, _] = a; + | -- value moved here +LL | let [_y..] = a; //[ast]~ ERROR [E0382] + | ^^ value used here after move + | + = note: move occurs because `a[..]` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.mir.stderr new file mode 100644 index 00000000000..d67b63b5aa7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.mir.stderr @@ -0,0 +1,19 @@ +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array.rs:20:14 + | +LL | let [_, _x] = a; + | -- value moved here +LL | let [.., _y] = a; //[ast]~ ERROR [E0382] + | ^^ value used here after move + +error[E0382]: use of moved value: `a[..]` + --> $DIR/borrowck-move-out-from-array.rs:27:10 + | +LL | let [_x, _] = a; + | -- value moved here +LL | let [_y..] = a; //[ast]~ ERROR [E0382] + | ^^ value used here after move + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.rs new file mode 100644 index 00000000000..0db31cef0ed --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-from-array.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(box_syntax)] +#![feature(slice_patterns)] + +fn move_out_from_begin_and_end() { + let a = [box 1, box 2]; + let [_, _x] = a; + let [.., _y] = a; //[ast]~ ERROR [E0382] + //[mir]~^ ERROR [E0382] +} + +fn move_out_by_const_index_and_subslice() { + let a = [box 1, box 2]; + let [_x, _] = a; + let [_y..] = a; //[ast]~ ERROR [E0382] + //[mir]~^ ERROR [E0382] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr new file mode 100644 index 00000000000..94f7eba63a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14 + | +LL | let _x = Rc::new(vec![1, 2]).into_iter(); + | ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr new file mode 100644 index 00000000000..94f7eba63a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14 + | +LL | let _x = Rc::new(vec![1, 2]).into_iter(); + | ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs new file mode 100644 index 00000000000..af9202d8d77 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +use std::rc::Rc; + +pub fn main() { + let _x = Rc::new(vec![1, 2]).into_iter(); + //[ast]~^ ERROR cannot move out of borrowed content [E0507] + //[mir]~^^ ERROR [E0507] +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.rs new file mode 100644 index 00000000000..fffcf575ab0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::rc::Rc; + +pub fn main() { + let _x = *Rc::new("hi".to_string()); + //~^ ERROR cannot move out of borrowed content +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.stderr new file mode 100644 index 00000000000..df5d911f6a8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-overloaded-deref.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-move-out-of-overloaded-deref.rs:14:14 + | +LL | let _x = *Rc::new("hi".to_string()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&*Rc::new("hi".to_string())` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.ast.stderr new file mode 100644 index 00000000000..65f70a7984f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.ast.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of static item + --> $DIR/borrowck-move-out-of-static-item.rs:28:10 + | +LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] + | ^^^ cannot move out of static item + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.mir.stderr new file mode 100644 index 00000000000..65f70a7984f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.mir.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of static item + --> $DIR/borrowck-move-out-of-static-item.rs:28:10 + | +LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] + | ^^^ cannot move out of static item + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.rs new file mode 100644 index 00000000000..79eb68c95a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-static-item.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Ensure that moves out of static items is forbidden + +struct Foo { + foo: isize, +} + +static BAR: Foo = Foo { foo: 5 }; + + +fn test(f: Foo) { + let _f = Foo{foo: 4, ..f}; +} + +fn main() { + test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] + //[mir]~^ ERROR [E0507] +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr new file mode 100644 index 00000000000..15c7011d716 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr @@ -0,0 +1,34 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:20:11 + | +LL | match (S {f:"foo".to_string()}) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here +LL | //[mir]~^ ERROR [E0509] +LL | S {f:_s} => {} + | -- + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _s` + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:28:20 + | +LL | let S {f:_s} = S {f:"foo".to_string()}; + | -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _s` + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:33:19 + | +LL | fn move_in_fn_arg(S {f:_s}: S) { + | ^^^^^--^ + | | | + | | data moved here + | | help: to prevent move, use ref or ref mut: `ref _s` + | cannot move out of here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr new file mode 100644 index 00000000000..4384f046d16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr @@ -0,0 +1,30 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:22:9 + | +LL | S {f:_s} => {} + | ^^^^^--^ + | | | + | | hint: to prevent move, use `ref _s` or `ref mut _s` + | cannot move out of here + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:28:9 + | +LL | let S {f:_s} = S {f:"foo".to_string()}; + | ^^^^^--^ + | | | + | | hint: to prevent move, use `ref _s` or `ref mut _s` + | cannot move out of here + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:33:19 + | +LL | fn move_in_fn_arg(S {f:_s}: S) { + | ^^^^^--^ + | | | + | | hint: to prevent move, use `ref _s` or `ref mut _s` + | cannot move out of here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr new file mode 100644 index 00000000000..15c7011d716 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr @@ -0,0 +1,34 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:20:11 + | +LL | match (S {f:"foo".to_string()}) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here +LL | //[mir]~^ ERROR [E0509] +LL | S {f:_s} => {} + | -- + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _s` + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:28:20 + | +LL | let S {f:_s} = S {f:"foo".to_string()}; + | -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _s` + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:33:19 + | +LL | fn move_in_fn_arg(S {f:_s}: S) { + | ^^^^^--^ + | | | + | | data moved here + | | help: to prevent move, use ref or ref mut: `ref _s` + | cannot move out of here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.rs new file mode 100644 index 00000000000..4bb66ace026 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-struct-with-dtor.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct S {f:String} +impl Drop for S { + fn drop(&mut self) { println!("{}", self.f); } +} + +fn move_in_match() { + match (S {f:"foo".to_string()}) { + //[mir]~^ ERROR [E0509] + S {f:_s} => {} + //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] + } +} + +fn move_in_let() { + let S {f:_s} = S {f:"foo".to_string()}; + //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] + //[mir]~^^ ERROR [E0509] +} + +fn move_in_fn_arg(S {f:_s}: S) { + //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] + //[mir]~^^ ERROR [E0509] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr new file mode 100644 index 00000000000..c69ae8755a9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr @@ -0,0 +1,33 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:17:11 + | +LL | match S("foo".to_string()) { + | ^^^^^^^^^^^^^^^^^^^^ cannot move out of here +LL | S(_s) => {} + | -- + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _s` + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:24:17 + | +LL | let S(_s) = S("foo".to_string()); + | -- ^^^^^^^^^^^^^^^^^^^^ cannot move out of here + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref _s` + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:28:19 + | +LL | fn move_in_fn_arg(S(_s): S) { + | ^^--^ + | | | + | | data moved here + | | help: to prevent move, use ref or ref mut: `ref _s` + | cannot move out of here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs new file mode 100644 index 00000000000..f5fedb8d487 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S(String); +impl Drop for S { + fn drop(&mut self) { } +} + +fn move_in_match() { + match S("foo".to_string()) { + S(_s) => {} + //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait + } +} + +fn move_in_let() { + let S(_s) = S("foo".to_string()); + //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait +} + +fn move_in_fn_arg(S(_s): S) { + //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr new file mode 100644 index 00000000000..78a065b60da --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr @@ -0,0 +1,30 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:9 + | +LL | S(_s) => {} + | ^^--^ + | | | + | | hint: to prevent move, use `ref _s` or `ref mut _s` + | cannot move out of here + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:24:9 + | +LL | let S(_s) = S("foo".to_string()); + | ^^--^ + | | | + | | hint: to prevent move, use `ref _s` or `ref mut _s` + | cannot move out of here + +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:28:19 + | +LL | fn move_in_fn_arg(S(_s): S) { + | ^^--^ + | | | + | | hint: to prevent move, use `ref _s` or `ref mut _s` + | cannot move out of here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.nll.stderr new file mode 100644 index 00000000000..cd8d0cdfee2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.nll.stderr @@ -0,0 +1,13 @@ +error[E0505]: cannot move out of `a.x` because it is borrowed + --> $DIR/borrowck-move-subcomponent.rs:25:14 + | +LL | let pb = &a; + | -- borrow of `a` occurs here +LL | let S { x: ax } = a; //~ ERROR cannot move out + | ^^ move out of `a.x` occurs here +LL | f(pb); + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.rs new file mode 100644 index 00000000000..88871dda659 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.rs @@ -0,0 +1,27 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that the borrow checker checks all components of a path when moving +// out. + +#![feature(box_syntax)] + +struct S { + x : Box +} + +fn f(_: T) {} + +fn main() { + let a : S = S { x : box 1 }; + let pb = &a; + let S { x: ax } = a; //~ ERROR cannot move out + f(pb); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.stderr new file mode 100644 index 00000000000..f249f0f22cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-move-subcomponent.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `a.x` because it is borrowed + --> $DIR/borrowck-move-subcomponent.rs:25:14 + | +LL | let pb = &a; + | - borrow of `a` occurs here +LL | let S { x: ax } = a; //~ ERROR cannot move out + | ^^ move out of `a.x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.nll.stderr new file mode 100644 index 00000000000..ce1880c584a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.nll.stderr @@ -0,0 +1,103 @@ +error[E0505]: cannot move out of `x1` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:22:19 + | +LL | let p1 = &x1; + | --- borrow of `x1` occurs here +... +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x1` occurs here +LL | drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed + | -- move occurs due to use in closure +... +LL | borrow(&*p1); + | ---- borrow later used here + +error[E0505]: cannot move out of `x2` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:22:19 + | +LL | let p2 = &x2; + | --- borrow of `x2` occurs here +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x2` occurs here +LL | drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed +LL | drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed + | -- move occurs due to use in closure +... +LL | borrow(&*p2); + | ---- borrow later used here + +error[E0382]: use of moved value: `x1` + --> $DIR/borrowck-multiple-captures.rs:35:19 + | +LL | drop(x1); + | -- value moved here +... +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move +LL | drop(x1); //~ ERROR capture of moved value: `x1` + | -- use occurs due to use in closure + | + = note: move occurs because `x1` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x2` + --> $DIR/borrowck-multiple-captures.rs:35:19 + | +LL | drop(x2); + | -- value moved here +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move +LL | drop(x1); //~ ERROR capture of moved value: `x1` +LL | drop(x2); //~ ERROR capture of moved value: `x2` + | -- use occurs due to use in closure + | + = note: move occurs because `x2` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:46:14 + | +LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed + | - value moved here +LL | drop(x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:44:19 + | +LL | let p = &x; + | -- borrow of `x` occurs here +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x` occurs here +LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed + | - move occurs due to use in closure +... +LL | borrow(&*p); + | --- borrow later used here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:56:14 + | +LL | drop(x); //~ ERROR capture of moved value: `x` + | - value moved here +LL | drop(x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:54:19 + | +LL | drop(x); + | - value moved here +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move +LL | drop(x); //~ ERROR capture of moved value: `x` + | - use occurs due to use in closure + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 8 previous errors + +Some errors occurred: E0382, E0505. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.rs new file mode 100644 index 00000000000..042b914ce41 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.rs @@ -0,0 +1,65 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +use std::thread; + +fn borrow(_: &T) { } + +fn different_vars_after_borrows() { + let x1: Box<_> = box 1; + let p1 = &x1; + let x2: Box<_> = box 2; + let p2 = &x2; + thread::spawn(move|| { + drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed + drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed + }); + borrow(&*p1); + borrow(&*p2); +} + +fn different_vars_after_moves() { + let x1: Box<_> = box 1; + drop(x1); + let x2: Box<_> = box 2; + drop(x2); + thread::spawn(move|| { + drop(x1); //~ ERROR capture of moved value: `x1` + drop(x2); //~ ERROR capture of moved value: `x2` + }); +} + +fn same_var_after_borrow() { + let x: Box<_> = box 1; + let p = &x; + thread::spawn(move|| { + drop(x); //~ ERROR cannot move `x` into closure because it is borrowed + drop(x); //~ ERROR use of moved value: `x` + }); + borrow(&*p); +} + +fn same_var_after_move() { + let x: Box<_> = box 1; + drop(x); + thread::spawn(move|| { + drop(x); //~ ERROR capture of moved value: `x` + drop(x); //~ ERROR use of moved value: `x` + }); +} + +fn main() { + different_vars_after_borrows(); + different_vars_after_moves(); + same_var_after_borrow(); + same_var_after_move(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.stderr new file mode 100644 index 00000000000..3163ca63452 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-multiple-captures.stderr @@ -0,0 +1,84 @@ +error[E0504]: cannot move `x1` into closure because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:23:14 + | +LL | let p1 = &x1; + | -- borrow of `x1` occurs here +... +LL | drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed + | ^^ move into closure occurs here + +error[E0504]: cannot move `x2` into closure because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:24:14 + | +LL | let p2 = &x2; + | -- borrow of `x2` occurs here +... +LL | drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed + | ^^ move into closure occurs here + +error[E0382]: capture of moved value: `x1` + --> $DIR/borrowck-multiple-captures.rs:36:14 + | +LL | drop(x1); + | -- value moved here +... +LL | drop(x1); //~ ERROR capture of moved value: `x1` + | ^^ value captured here after move + | + = note: move occurs because `x1` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: capture of moved value: `x2` + --> $DIR/borrowck-multiple-captures.rs:37:14 + | +LL | drop(x2); + | -- value moved here +... +LL | drop(x2); //~ ERROR capture of moved value: `x2` + | ^^ value captured here after move + | + = note: move occurs because `x2` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0504]: cannot move `x` into closure because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:45:14 + | +LL | let p = &x; + | - borrow of `x` occurs here +LL | thread::spawn(move|| { +LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed + | ^ move into closure occurs here + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:46:14 + | +LL | drop(x); //~ ERROR cannot move `x` into closure because it is borrowed + | - value moved here +LL | drop(x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: capture of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:55:14 + | +LL | drop(x); + | - value moved here +LL | thread::spawn(move|| { +LL | drop(x); //~ ERROR capture of moved value: `x` + | ^ value captured here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:56:14 + | +LL | drop(x); //~ ERROR capture of moved value: `x` + | - value moved here +LL | drop(x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to 8 previous errors + +Some errors occurred: E0382, E0504. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr new file mode 100644 index 00000000000..352ace41d93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/borrowck-mut-addr-of-imm-var.rs:13:25 + | +LL | let x: isize = 3; + | - help: consider changing this to be mutable: `mut x` +LL | let y: &mut isize = &mut x; //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.rs new file mode 100644 index 00000000000..b6626a835e4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x: isize = 3; + let y: &mut isize = &mut x; //~ ERROR cannot borrow + *y = 5; + println!("{}", *y); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.stderr new file mode 100644 index 00000000000..0859a4e0f55 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-addr-of-imm-var.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable local variable `x` as mutable + --> $DIR/borrowck-mut-addr-of-imm-var.rs:13:30 + | +LL | let x: isize = 3; + | - consider changing this to `mut x` +LL | let y: &mut isize = &mut x; //~ ERROR cannot borrow + | ^ cannot borrow mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr new file mode 100644 index 00000000000..b3c86a56091 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr @@ -0,0 +1,32 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:23:30 + | +LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ---- ^^^^^^ second mutable borrow occurs here + | | + | borrow used here in later iteration of loop +... +LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ------ first mutable borrow occurs here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30 + | +LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ---- borrow used here in later iteration of loop +LL | //[mir]~^ ERROR [E0499] +LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR [E0499] +LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ------ first mutable borrow occurs here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:27:30 + | +LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ^^^^^^ mutable borrow starts here in previous iteration of loop + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr new file mode 100644 index 00000000000..7a43cf15422 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr @@ -0,0 +1,36 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:23:35 + | +LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ^ mutable borrow starts here in previous iteration of loop +... +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:35 + | +LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | - first mutable borrow occurs here +LL | //[mir]~^ ERROR [E0499] +LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:27:35 + | +LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | - first mutable borrow occurs here +... +LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr new file mode 100644 index 00000000000..b3c86a56091 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr @@ -0,0 +1,32 @@ +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:23:30 + | +LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ---- ^^^^^^ second mutable borrow occurs here + | | + | borrow used here in later iteration of loop +... +LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ------ first mutable borrow occurs here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30 + | +LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ---- borrow used here in later iteration of loop +LL | //[mir]~^ ERROR [E0499] +LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR [E0499] +LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ------ first mutable borrow occurs here + +error[E0499]: cannot borrow `x` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-linear-errors.rs:27:30 + | +LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + | ^^^^^^ mutable borrow starts here in previous iteration of loop + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.rs new file mode 100644 index 00000000000..7b0a71815a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-linear-errors.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test to ensure we only report an error for the first issued loan that +// conflicts with a new loan, as opposed to every issued loan. This keeps us +// down to O(n) errors (for n problem lines), instead of O(n^2) errors. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn main() { + let mut x = 1; + let mut addr = vec![]; + loop { + match 1 { + 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + //[mir]~^ ERROR [E0499] + 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + //[mir]~^ ERROR [E0499] + _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] + //[mir]~^ ERROR [E0499] + } + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs new file mode 100644 index 00000000000..bdeb7ea69bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.rs @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that attempt to mutably borrow `&mut` pointer while pointee is +// borrowed yields an error. +// +// Example from src/librustc_borrowck/borrowck/README.md + +fn foo<'a>(mut t0: &'a mut isize, + mut t1: &'a mut isize) { + let p: &isize = &*t0; // Freezes `*t0` + let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` + **t2 += 1; // Mutates `*t0` +} + +fn bar<'a>(mut t0: &'a mut isize, + mut t1: &'a mut isize) { + let p: &mut isize = &mut *t0; // Claims `*t0` + let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` + **t2 += 1; // Mutates `*t0` but not through `*p` +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr new file mode 100644 index 00000000000..28b740b23f9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr @@ -0,0 +1,26 @@ +error[E0502]: cannot borrow `t0` as mutable because `*t0` is also borrowed as immutable + --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:23 + | +LL | let p: &isize = &*t0; // Freezes `*t0` + | --- immutable borrow occurs here +LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` + | ^^ mutable borrow occurs here +LL | **t2 += 1; // Mutates `*t0` +LL | } + | - immutable borrow ends here + +error[E0499]: cannot borrow `t0` as mutable more than once at a time + --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:26:23 + | +LL | let p: &mut isize = &mut *t0; // Claims `*t0` + | --- first mutable borrow occurs here +LL | let mut t2 = &mut t0; //~ ERROR cannot borrow `t0` + | ^^ second mutable borrow occurs here +LL | **t2 += 1; // Mutates `*t0` but not through `*p` +LL | } + | - first borrow ends here + +error: aborting due to 2 previous errors + +Some errors occurred: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr new file mode 100644 index 00000000000..7c151da3c36 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable + --> $DIR/borrowck-mut-slice-of-imm-vec.rs:17:11 + | +LL | let v = vec![1, 2, 3]; + | - help: consider changing this to be mutable: `mut v` +LL | write(&mut v); //~ ERROR cannot borrow + | ^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.rs new file mode 100644 index 00000000000..4e0304e20c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.rs @@ -0,0 +1,18 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn write(v: &mut [isize]) { + v[0] += 1; +} + +fn main() { + let v = vec![1, 2, 3]; + write(&mut v); //~ ERROR cannot borrow +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.stderr new file mode 100644 index 00000000000..e2fd9d771f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mut-slice-of-imm-vec.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow immutable local variable `v` as mutable + --> $DIR/borrowck-mut-slice-of-imm-vec.rs:17:16 + | +LL | let v = vec![1, 2, 3]; + | - consider changing this to `mut v` +LL | write(&mut v); //~ ERROR cannot borrow + | ^ cannot borrow mutably + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.rs new file mode 100644 index 00000000000..e35edca639e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Enum<'a> { + A(&'a isize), + B(bool), +} + +fn foo() -> isize { + let mut n = 42; + let mut x = Enum::A(&mut n); + match x { + Enum::A(_) if { x = Enum::B(false); false } => 1, + //~^ ERROR cannot assign in a pattern guard + Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, + //~^ ERROR cannot mutably borrow in a pattern guard + //~^^ ERROR cannot assign in a pattern guard + Enum::A(p) => *p, + Enum::B(_) => 2, + } +} + +fn main() { + foo(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.stderr new file mode 100644 index 00000000000..7a111a1bbcc --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-mutate-in-guard.stderr @@ -0,0 +1,22 @@ +error[E0302]: cannot assign in a pattern guard + --> $DIR/borrowck-mutate-in-guard.rs:20:25 + | +LL | Enum::A(_) if { x = Enum::B(false); false } => 1, + | ^^^^^^^^^^^^^^^^^^ assignment in pattern guard + +error[E0301]: cannot mutably borrow in a pattern guard + --> $DIR/borrowck-mutate-in-guard.rs:22:38 + | +LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, + | ^ borrowed mutably in pattern guard + +error[E0302]: cannot assign in a pattern guard + --> $DIR/borrowck-mutate-in-guard.rs:22:41 + | +LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, + | ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard + +error: aborting due to 3 previous errors + +Some errors occurred: E0301, E0302. +For more information about an error, try `rustc --explain E0301`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr new file mode 100644 index 00000000000..9bb1e825f25 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr @@ -0,0 +1,13 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-no-cycle-in-exchange-heap.rs:26:15 + | +LL | cycle::node(ref mut y) => { + | --------- borrow of `x.0` occurs here +LL | y.a = x; //~ ERROR cannot move out of + | --- ^ move out of `x` occurs here + | | + | borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.rs new file mode 100644 index 00000000000..8cb7423f3cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.rs @@ -0,0 +1,30 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +struct node_ { + a: Box +} + +enum cycle { + node(node_), + empty +} +fn main() { + let mut x: Box<_> = box cycle::node(node_ {a: box cycle::empty}); + // Create a cycle! + match *x { + cycle::node(ref mut y) => { + y.a = x; //~ ERROR cannot move out of + } + cycle::empty => {} + }; +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.stderr new file mode 100644 index 00000000000..693f25e243c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-no-cycle-in-exchange-heap.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-no-cycle-in-exchange-heap.rs:26:15 + | +LL | cycle::node(ref mut y) => { + | --------- borrow of `x.0` occurs here +LL | y.a = x; //~ ERROR cannot move out of + | ^ move out of `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.rs new file mode 100644 index 00000000000..021b3f38e00 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.rs @@ -0,0 +1,39 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that borrows that occur due to calls to object methods +// properly "claim" the object path. + +trait Foo { + fn borrowed(&self) -> &(); + fn mut_borrowed(&mut self) -> &(); +} + +fn borrowed_receiver(x: &Foo) { + let _y = x.borrowed(); + let _z = x.borrowed(); +} + +fn mut_borrowed_receiver(x: &mut Foo) { + let _y = x.borrowed(); + let _z = x.mut_borrowed(); //~ ERROR cannot borrow +} + +fn mut_owned_receiver(mut x: Box) { + let _y = x.borrowed(); + let _z = &mut x; //~ ERROR cannot borrow +} + +fn imm_owned_receiver(mut x: Box) { + let _y = x.borrowed(); + let _z = &x; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.stderr new file mode 100644 index 00000000000..e7ae92d822e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-object-lifetime.stderr @@ -0,0 +1,23 @@ +error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-object-lifetime.rs:26:14 + | +LL | let _y = x.borrowed(); + | - immutable borrow occurs here +LL | let _z = x.mut_borrowed(); //~ ERROR cannot borrow + | ^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `x` as mutable because `*x` is also borrowed as immutable + --> $DIR/borrowck-object-lifetime.rs:31:19 + | +LL | let _y = x.borrowed(); + | - immutable borrow occurs here +LL | let _z = &mut x; //~ ERROR cannot borrow + | ^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.nll.stderr new file mode 100644 index 00000000000..dd8bf879735 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `i` + --> $DIR/borrowck-or-init.rs:15:20 + | +LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + | ^ use of possibly uninitialized `i` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.rs new file mode 100644 index 00000000000..27871a6ab16 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let i: isize; + + println!("{}", false || { i = 5; true }); + println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.stderr new file mode 100644 index 00000000000..bc1c3a51667 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-or-init.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `i` + --> $DIR/borrowck-or-init.rs:15:20 + | +LL | println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + | ^ use of possibly uninitialized `i` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.nll.stderr new file mode 100644 index 00000000000..dc8d731dede --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.nll.stderr @@ -0,0 +1,23 @@ +error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable + --> $DIR/borrowck-overloaded-call.rs:77:5 + | +LL | let s = SFnMut { + | - help: consider changing this to be mutable: `mut s` +... +LL | s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable + | ^ cannot borrow as mutable + +error[E0382]: use of moved value: `s` + --> $DIR/borrowck-overloaded-call.rs:85:5 + | +LL | s(" world".to_string()); + | - value moved here +LL | s(" world".to_string()); //~ ERROR use of moved value: `s` + | ^ value used here after move + | + = note: move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +Some errors occurred: E0382, E0596. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.rs new file mode 100644 index 00000000000..41f3e472cd1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.rs @@ -0,0 +1,88 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(fn_traits, unboxed_closures)] + +use std::ops::{Fn, FnMut, FnOnce}; + +struct SFn { + x: isize, + y: isize, +} + +impl Fn<(isize,)> for SFn { + extern "rust-call" fn call(&self, (z,): (isize,)) -> isize { + self.x * self.y * z + } +} + +impl FnMut<(isize,)> for SFn { + extern "rust-call" fn call_mut(&mut self, args: (isize,)) -> isize { self.call(args) } +} + +impl FnOnce<(isize,)> for SFn { + type Output = isize; + extern "rust-call" fn call_once(self, args: (isize,)) -> isize { self.call(args) } +} + +struct SFnMut { + x: isize, + y: isize, +} + +impl FnMut<(isize,)> for SFnMut { + extern "rust-call" fn call_mut(&mut self, (z,): (isize,)) -> isize { + self.x * self.y * z + } +} + +impl FnOnce<(isize,)> for SFnMut { + type Output = isize; + extern "rust-call" fn call_once(mut self, args: (isize,)) -> isize { self.call_mut(args) } +} + +struct SFnOnce { + x: String, +} + +impl FnOnce<(String,)> for SFnOnce { + type Output = usize; + + extern "rust-call" fn call_once(self, (z,): (String,)) -> usize { + self.x.len() + z.len() + } +} + +fn f() { + let mut s = SFn { + x: 1, + y: 2, + }; + let sp = &mut s; + s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable +} + +fn g() { + let s = SFnMut { + x: 1, + y: 2, + }; + s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable +} + +fn h() { + let s = SFnOnce { + x: "hello".to_string(), + }; + s(" world".to_string()); + s(" world".to_string()); //~ ERROR use of moved value: `s` +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.stderr new file mode 100644 index 00000000000..213d78339e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-call.stderr @@ -0,0 +1,33 @@ +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-call.rs:69:5 + | +LL | let sp = &mut s; + | - mutable borrow occurs here +LL | s(3); //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + | ^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0596]: cannot borrow immutable local variable `s` as mutable + --> $DIR/borrowck-overloaded-call.rs:77:5 + | +LL | let s = SFnMut { + | - consider changing this to `mut s` +... +LL | s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable + | ^ cannot borrow mutably + +error[E0382]: use of moved value: `s` + --> $DIR/borrowck-overloaded-call.rs:85:5 + | +LL | s(" world".to_string()); + | - value moved here +LL | s(" world".to_string()); //~ ERROR use of moved value: `s` + | ^ value used here after move + | + = note: move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +Some errors occurred: E0382, E0502, E0596. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr new file mode 100644 index 00000000000..874e6d74b64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `v` because it is borrowed + --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:44:5 + | +LL | let i = &v[0].f; + | - borrow of `v` occurs here +LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here +... +LL | read(*i); + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr new file mode 100644 index 00000000000..8343b60dfbf --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr @@ -0,0 +1,11 @@ +error[E0506]: cannot assign to `v` because it is borrowed + --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:44:5 + | +LL | let i = &v[0].f; + | - borrow of `v` occurs here +LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr new file mode 100644 index 00000000000..874e6d74b64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `v` because it is borrowed + --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:44:5 + | +LL | let i = &v[0].f; + | - borrow of `v` occurs here +LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here +... +LL | read(*i); + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs new file mode 100644 index 00000000000..931d053ae7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs @@ -0,0 +1,50 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we properly record borrows when we are doing an +// overloaded, autoderef of a value obtained via an overloaded index +// operator. The accounting of the all the implicit things going on +// here is rather subtle. Issue #20232. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +use std::ops::{Deref, Index}; + +struct MyVec { x: T } + +impl Index for MyVec { + type Output = T; + fn index(&self, _: usize) -> &T { + &self.x + } +} + +struct MyPtr { x: T } + +impl Deref for MyPtr { + type Target = T; + fn deref(&self) -> &T { + &self.x + } +} + +struct Foo { f: usize } + +fn main() { + let mut v = MyVec { x: MyPtr { x: Foo { f: 22 } } }; + let i = &v[0].f; + v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; + //[ast]~^ ERROR cannot assign to `v` + //[mir]~^^ ERROR cannot assign to `v` because it is borrowed + read(*i); +} + +fn read(_: usize) { } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.rs new file mode 100644 index 00000000000..b726c46d5d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.rs @@ -0,0 +1,93 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we still see borrowck errors of various kinds when using +// indexing and autoderef in combination. + +use std::ops::{Index, IndexMut}; + +struct Foo { + x: isize, + y: isize, +} + +impl<'a> Index<&'a String> for Foo { + type Output = isize; + + fn index(&self, z: &String) -> &isize { + if *z == "x" { + &self.x + } else { + &self.y + } + } +} + +impl<'a> IndexMut<&'a String> for Foo { + fn index_mut(&mut self, z: &String) -> &mut isize { + if *z == "x" { + &mut self.x + } else { + &mut self.y + } + } +} + +fn test1(mut f: Box, s: String) { + let _p = &mut f[&s]; + let _q = &f[&s]; //~ ERROR cannot borrow +} + +fn test2(mut f: Box, s: String) { + let _p = &mut f[&s]; + let _q = &mut f[&s]; //~ ERROR cannot borrow +} + +struct Bar { + foo: Foo +} + +fn test3(mut f: Box, s: String) { + let _p = &mut f.foo[&s]; + let _q = &mut f.foo[&s]; //~ ERROR cannot borrow +} + +fn test4(mut f: Box, s: String) { + let _p = &f.foo[&s]; + let _q = &f.foo[&s]; +} + +fn test5(mut f: Box, s: String) { + let _p = &f.foo[&s]; + let _q = &mut f.foo[&s]; //~ ERROR cannot borrow +} + +fn test6(mut f: Box, g: Foo, s: String) { + let _p = &f.foo[&s]; + f.foo = g; //~ ERROR cannot assign +} + +fn test7(mut f: Box, g: Bar, s: String) { + let _p = &f.foo[&s]; + *f = g; //~ ERROR cannot assign +} + +fn test8(mut f: Box, g: Foo, s: String) { + let _p = &mut f.foo[&s]; + f.foo = g; //~ ERROR cannot assign +} + +fn test9(mut f: Box, g: Bar, s: String) { + let _p = &mut f.foo[&s]; + *f = g; //~ ERROR cannot assign +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.stderr new file mode 100644 index 00000000000..c17eed1322b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-autoderef.stderr @@ -0,0 +1,76 @@ +error[E0502]: cannot borrow `*f` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-index-autoderef.rs:45:15 + | +LL | let _p = &mut f[&s]; + | - mutable borrow occurs here +LL | let _q = &f[&s]; //~ ERROR cannot borrow + | ^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/borrowck-overloaded-index-autoderef.rs:50:19 + | +LL | let _p = &mut f[&s]; + | - first mutable borrow occurs here +LL | let _q = &mut f[&s]; //~ ERROR cannot borrow + | ^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `f.foo` as mutable more than once at a time + --> $DIR/borrowck-overloaded-index-autoderef.rs:59:19 + | +LL | let _p = &mut f.foo[&s]; + | ----- first mutable borrow occurs here +LL | let _q = &mut f.foo[&s]; //~ ERROR cannot borrow + | ^^^^^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-overloaded-index-autoderef.rs:69:19 + | +LL | let _p = &f.foo[&s]; + | ----- immutable borrow occurs here +LL | let _q = &mut f.foo[&s]; //~ ERROR cannot borrow + | ^^^^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0506]: cannot assign to `f.foo` because it is borrowed + --> $DIR/borrowck-overloaded-index-autoderef.rs:74:5 + | +LL | let _p = &f.foo[&s]; + | ----- borrow of `f.foo` occurs here +LL | f.foo = g; //~ ERROR cannot assign + | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here + +error[E0506]: cannot assign to `*f` because it is borrowed + --> $DIR/borrowck-overloaded-index-autoderef.rs:79:5 + | +LL | let _p = &f.foo[&s]; + | ----- borrow of `*f` occurs here +LL | *f = g; //~ ERROR cannot assign + | ^^^^^^ assignment to borrowed `*f` occurs here + +error[E0506]: cannot assign to `f.foo` because it is borrowed + --> $DIR/borrowck-overloaded-index-autoderef.rs:84:5 + | +LL | let _p = &mut f.foo[&s]; + | ----- borrow of `f.foo` occurs here +LL | f.foo = g; //~ ERROR cannot assign + | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here + +error[E0506]: cannot assign to `*f` because it is borrowed + --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 + | +LL | let _p = &mut f.foo[&s]; + | ----- borrow of `*f` occurs here +LL | *f = g; //~ ERROR cannot assign + | ^^^^^^ assignment to borrowed `*f` occurs here + +error: aborting due to 8 previous errors + +Some errors occurred: E0499, E0502, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr new file mode 100644 index 00000000000..4a72d7f3302 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-overloaded-index-move-from-vec.rs:30:15 + | +LL | let bad = v[0]; + | ^^^^ + | | + | cannot move out of borrowed content + | help: consider using a reference instead: `&v[0]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.rs new file mode 100644 index 00000000000..df72c2b0af7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +use std::ops::Index; + +struct MyVec { + data: Vec, +} + +impl Index for MyVec { + type Output = T; + + fn index(&self, i: usize) -> &T { + &self.data[i] + } +} + +fn main() { + let v = MyVec::> { data: vec![box 1, box 2, box 3] }; + let good = &v[0]; // Shouldn't fail here + let bad = v[0]; + //~^ ERROR cannot move out of indexed content +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.stderr new file mode 100644 index 00000000000..56246cbf770 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-from-vec.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of indexed content + --> $DIR/borrowck-overloaded-index-move-from-vec.rs:30:15 + | +LL | let bad = v[0]; + | ^^^^ + | | + | cannot move out of indexed content + | help: consider using a reference instead: `&v[0]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.nll.stderr new file mode 100644 index 00000000000..824d8298ecb --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.nll.stderr @@ -0,0 +1,14 @@ +error[E0382]: use of moved value: `s` + --> $DIR/borrowck-overloaded-index-move-index.rs:63:7 + | +LL | println!("{}", f[s]); + | - value moved here +... +LL | f[s] = 10; + | ^ value used here after move + | + = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.rs new file mode 100644 index 00000000000..d8615d19053 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.rs @@ -0,0 +1,74 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::{Index, IndexMut}; + +struct Foo { + x: isize, + y: isize, +} + +impl Index for Foo { + type Output = isize; + + fn index(&self, z: String) -> &isize { + if z == "x" { + &self.x + } else { + &self.y + } + } +} + +impl IndexMut for Foo { + fn index_mut(&mut self, z: String) -> &mut isize { + if z == "x" { + &mut self.x + } else { + &mut self.y + } + } +} + +struct Bar { + x: isize, +} + +impl Index for Bar { + type Output = isize; + + fn index<'a>(&'a self, z: isize) -> &'a isize { + &self.x + } +} + +fn main() { + let mut f = Foo { + x: 1, + y: 2, + }; + let mut s = "hello".to_string(); + let rs = &mut s; + + println!("{}", f[s]); + //~^ ERROR cannot move out of `s` because it is borrowed + + f[s] = 10; + //~^ ERROR cannot move out of `s` because it is borrowed + //~| ERROR use of moved value: `s` + + let s = Bar { + x: 1, + }; + let i = 2; + let _j = &i; + println!("{}", s[i]); // no error, i is copy + println!("{}", s[i]); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.stderr new file mode 100644 index 00000000000..cfa5a6e317d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-move-index.stderr @@ -0,0 +1,33 @@ +error[E0505]: cannot move out of `s` because it is borrowed + --> $DIR/borrowck-overloaded-index-move-index.rs:60:22 + | +LL | let rs = &mut s; + | - borrow of `s` occurs here +LL | +LL | println!("{}", f[s]); + | ^ move out of `s` occurs here + +error[E0505]: cannot move out of `s` because it is borrowed + --> $DIR/borrowck-overloaded-index-move-index.rs:63:7 + | +LL | let rs = &mut s; + | - borrow of `s` occurs here +... +LL | f[s] = 10; + | ^ move out of `s` occurs here + +error[E0382]: use of moved value: `s` + --> $DIR/borrowck-overloaded-index-move-index.rs:63:7 + | +LL | println!("{}", f[s]); + | - value moved here +... +LL | f[s] = 10; + | ^ value used here after move + | + = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +Some errors occurred: E0382, E0505. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr new file mode 100644 index 00000000000..3a2bfb18cb9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr @@ -0,0 +1,33 @@ +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-index-ref-index.rs:62:22 + | +LL | let rs = &mut s; + | ------ mutable borrow occurs here +LL | println!("{}", f[&s]); + | ^^ immutable borrow occurs here +... +LL | drop(rs); + | -- borrow later used here + +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-index-ref-index.rs:65:7 + | +LL | let rs = &mut s; + | ------ mutable borrow occurs here +... +LL | f[&s] = 10; + | ^^ immutable borrow occurs here +... +LL | drop(rs); + | -- borrow later used here + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-overloaded-index-ref-index.rs:71:5 + | +LL | s[2] = 20; + | ^^^^^^^^^ cannot assign + +error: aborting due to 3 previous errors + +Some errors occurred: E0502, E0594. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.stderr new file mode 100644 index 00000000000..63024acc7df --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.ast.stderr @@ -0,0 +1,33 @@ +error[E0594]: cannot assign to immutable indexed content + --> $DIR/borrowck-overloaded-index-ref-index.rs:71:5 + | +LL | s[2] = 20; + | ^^^^^^^^^ cannot borrow as mutable + +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-index-ref-index.rs:62:23 + | +LL | let rs = &mut s; + | - mutable borrow occurs here +LL | println!("{}", f[&s]); + | ^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-index-ref-index.rs:65:8 + | +LL | let rs = &mut s; + | - mutable borrow occurs here +... +LL | f[&s] = 10; + | ^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error: aborting due to 3 previous errors + +Some errors occurred: E0502, E0594. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.mir.stderr new file mode 100644 index 00000000000..3a2bfb18cb9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.mir.stderr @@ -0,0 +1,33 @@ +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-index-ref-index.rs:62:22 + | +LL | let rs = &mut s; + | ------ mutable borrow occurs here +LL | println!("{}", f[&s]); + | ^^ immutable borrow occurs here +... +LL | drop(rs); + | -- borrow later used here + +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-overloaded-index-ref-index.rs:65:7 + | +LL | let rs = &mut s; + | ------ mutable borrow occurs here +... +LL | f[&s] = 10; + | ^^ immutable borrow occurs here +... +LL | drop(rs); + | -- borrow later used here + +error[E0594]: cannot assign to data in a `&` reference + --> $DIR/borrowck-overloaded-index-ref-index.rs:71:5 + | +LL | s[2] = 20; + | ^^^^^^^^^ cannot assign + +error: aborting due to 3 previous errors + +Some errors occurred: E0502, E0594. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.rs new file mode 100644 index 00000000000..f4f40e0407f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-overloaded-index-ref-index.rs @@ -0,0 +1,75 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +use std::ops::{Index, IndexMut}; + +struct Foo { + x: isize, + y: isize, +} + +impl<'a> Index<&'a String> for Foo { + type Output = isize; + + fn index(&self, z: &String) -> &isize { + if *z == "x" { + &self.x + } else { + &self.y + } + } +} + +impl<'a> IndexMut<&'a String> for Foo { + fn index_mut(&mut self, z: &String) -> &mut isize { + if *z == "x" { + &mut self.x + } else { + &mut self.y + } + } +} + +struct Bar { + x: isize, +} + +impl Index for Bar { + type Output = isize; + + fn index<'a>(&'a self, z: isize) -> &'a isize { + &self.x + } +} + +fn main() { + let mut f = Foo { + x: 1, + y: 2, + }; + let mut s = "hello".to_string(); + let rs = &mut s; + println!("{}", f[&s]); + //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + f[&s] = 10; + //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + let s = Bar { + x: 1, + }; + s[2] = 20; + //[ast]~^ ERROR cannot assign to immutable indexed content + //[mir]~^^ ERROR cannot assign to data in a `&` reference + drop(rs); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.nll.stderr new file mode 100644 index 00000000000..0444bf97c65 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.nll.stderr @@ -0,0 +1,23 @@ +error[E0382]: assign of moved value: `t` + --> $DIR/borrowck-partial-reinit-1.rs:37:5 + | +LL | drop(t); + | - value moved here +LL | t.b = Some(u); + | ^^^ value assigned here after move + | + = note: move occurs because `t` has type `Test2`, which does not implement the `Copy` trait + +error[E0382]: assign of moved value: `t` + --> $DIR/borrowck-partial-reinit-1.rs:43:5 + | +LL | drop(t); + | - value moved here +LL | t.0 = Some(u); + | ^^^ value assigned here after move + | + = note: move occurs because `t` has type `Test3`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.rs new file mode 100644 index 00000000000..1ee040a0705 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.rs @@ -0,0 +1,49 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Test; + +struct Test2 { + b: Option, +} + +struct Test3(Option); + +impl Drop for Test { + fn drop(&mut self) { + println!("dropping!"); + } +} + +impl Drop for Test2 { + fn drop(&mut self) {} +} + +impl Drop for Test3 { + fn drop(&mut self) {} +} + +fn stuff() { + let mut t = Test2 { b: None }; + let u = Test; + drop(t); + t.b = Some(u); + //~^ ERROR partial reinitialization of uninitialized structure `t` + + let mut t = Test3(None); + let u = Test; + drop(t); + t.0 = Some(u); + //~^ ERROR partial reinitialization of uninitialized structure `t` +} + +fn main() { + stuff() +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.stderr new file mode 100644 index 00000000000..c03921cd3dd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-1.stderr @@ -0,0 +1,15 @@ +error[E0383]: partial reinitialization of uninitialized structure `t` + --> $DIR/borrowck-partial-reinit-1.rs:37:5 + | +LL | t.b = Some(u); + | ^^^^^^^^^^^^^ + +error[E0383]: partial reinitialization of uninitialized structure `t` + --> $DIR/borrowck-partial-reinit-1.rs:43:5 + | +LL | t.0 = Some(u); + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0383`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.nll.stderr new file mode 100644 index 00000000000..14272fa3ed5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: assign of moved value: `t` + --> $DIR/borrowck-partial-reinit-2.rs:25:5 + | +LL | let mut u = Test { a: 2, b: Some(Box::new(t))}; + | - value moved here +LL | t.b = Some(Box::new(u)); + | ^^^ value assigned here after move + | + = note: move occurs because `t` has type `Test`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.rs new file mode 100644 index 00000000000..c9cdeff9c7a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.rs @@ -0,0 +1,33 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Test { + a: isize, + b: Option>, +} + +impl Drop for Test { + fn drop(&mut self) { + println!("Dropping {}", self.a); + } +} + +fn stuff() { + let mut t = Test { a: 1, b: None}; + let mut u = Test { a: 2, b: Some(Box::new(t))}; + t.b = Some(Box::new(u)); + //~^ ERROR partial reinitialization of uninitialized structure `t` + println!("done"); +} + +fn main() { + stuff(); + println!("Hello, world!") +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.stderr new file mode 100644 index 00000000000..4ed87b95292 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-2.stderr @@ -0,0 +1,9 @@ +error[E0383]: partial reinitialization of uninitialized structure `t` + --> $DIR/borrowck-partial-reinit-2.rs:25:5 + | +LL | t.b = Some(Box::new(u)); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0383`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.nll.stderr new file mode 100644 index 00000000000..3979f1e6753 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.nll.stderr @@ -0,0 +1,13 @@ +error[E0382]: assign of moved value: `x.0` + --> $DIR/borrowck-partial-reinit-3.rs:20:5 + | +LL | mem::drop(x.0); + | --- value moved here +LL | x.0.f = 3; + | ^^^^^^^^^ value assigned here after move + | + = note: move occurs because `x.0` has type `Test`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.rs new file mode 100644 index 00000000000..0aa73892b82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +use std::mem; + +struct Test { f: usize } +impl Drop for Test { + fn drop(&mut self) {} +} + +fn main() { + let mut x = (Test { f: 2 }, Test { f: 4 }); + mem::drop(x.0); + x.0.f = 3; + //~^ ERROR partial reinitialization of uninitialized structure `x.0` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.stderr new file mode 100644 index 00000000000..66465c07374 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-3.stderr @@ -0,0 +1,9 @@ +error[E0383]: partial reinitialization of uninitialized structure `x.0` + --> $DIR/borrowck-partial-reinit-3.rs:20:5 + | +LL | x.0.f = 3; + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0383`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.nll.stderr new file mode 100644 index 00000000000..e1ede72a7c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: assign of possibly uninitialized variable: `x.0` + --> $DIR/borrowck-partial-reinit-4.rs:27:5 + | +LL | (x.0).0 = Some(Test); + | ^^^^^^^ use of possibly uninitialized `x.0` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.rs new file mode 100644 index 00000000000..774e04ecb29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Test; + +struct Test2(Option); + +impl Drop for Test { + fn drop(&mut self) { + println!("dropping!"); + } +} + +impl Drop for Test2 { + fn drop(&mut self) {} +} + +fn stuff() { + let mut x : (Test2, Test2); + (x.0).0 = Some(Test); + //~^ ERROR partial reinitialization of uninitialized structure `x.0` +} + +fn main() { + stuff() +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.stderr new file mode 100644 index 00000000000..229a53ad827 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-partial-reinit-4.stderr @@ -0,0 +1,9 @@ +error[E0383]: partial reinitialization of uninitialized structure `x.0` + --> $DIR/borrowck-partial-reinit-4.rs:27:5 + | +LL | (x.0).0 = Some(Test); + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0383`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr new file mode 100644 index 00000000000..cfcf177efa3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-pat-reassign-binding.rs:23:11 + | +LL | Some(ref i) => { + | ----- borrow of `x` occurs here +LL | // But on this branch, `i` is an outstanding borrow +LL | x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` + | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(i); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.stderr new file mode 100644 index 00000000000..fdc04e226a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.ast.stderr @@ -0,0 +1,12 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-pat-reassign-binding.rs:23:11 + | +LL | Some(ref i) => { + | ----- borrow of `x` occurs here +LL | // But on this branch, `i` is an outstanding borrow +LL | x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` + | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.mir.stderr new file mode 100644 index 00000000000..cfcf177efa3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.mir.stderr @@ -0,0 +1,15 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/borrowck-pat-reassign-binding.rs:23:11 + | +LL | Some(ref i) => { + | ----- borrow of `x` occurs here +LL | // But on this branch, `i` is an outstanding borrow +LL | x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` + | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here +LL | //[mir]~^ ERROR cannot assign to `x` because it is borrowed +LL | drop(i); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.rs new file mode 100644 index 00000000000..d917a0abb88 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-pat-reassign-binding.rs @@ -0,0 +1,29 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn main() { + let mut x: Option = None; + match x { + None => { + // Note: on this branch, no borrow has occurred. + x = Some(0); + } + Some(ref i) => { + // But on this branch, `i` is an outstanding borrow + x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` + //[mir]~^ ERROR cannot assign to `x` because it is borrowed + drop(i); + } + } + x.clone(); // just to prevent liveness warnings +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.nll.stderr new file mode 100644 index 00000000000..4c81bb8eb30 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.nll.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-reborrow-from-mut.rs:98:17 + | +LL | fn borrow_mut_from_imm(foo: &Foo) { + | ---- help: consider changing this to be a mutable reference: `&mut Foo` +LL | let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.rs new file mode 100644 index 00000000000..6f5dfa67be5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.rs @@ -0,0 +1,106 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + bar1: Bar, + bar2: Bar +} + +struct Bar { + int1: isize, + int2: isize, +} + +fn borrow_same_field_twice_mut_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow +} + +fn borrow_same_field_twice_mut_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &foo.bar1; //~ ERROR cannot borrow +} + +fn borrow_same_field_twice_imm_mut(foo: &mut Foo) { + let _bar1 = &foo.bar1; + let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow +} + +fn borrow_same_field_twice_imm_imm(foo: &mut Foo) { + let _bar1 = &foo.bar1; + let _bar2 = &foo.bar1; +} + +fn borrow_both_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _bar2 = &mut foo.bar2; +} + +fn borrow_both_mut_pattern(foo: &mut Foo) { + match *foo { + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} + } +} + +fn borrow_var_and_pattern(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + match *foo { + Foo { bar1: ref mut _bar1, bar2: _ } => {} + //~^ ERROR cannot borrow + } +} + +fn borrow_mut_and_base_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &foo.bar1; //~ ERROR cannot borrow + let _foo2 = &*foo; //~ ERROR cannot borrow +} + +fn borrow_mut_and_base_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow +} + +fn borrow_mut_and_base_mut2(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR cannot borrow +} + +fn borrow_imm_and_base_mut(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow +} + +fn borrow_imm_and_base_mut2(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo2 = &mut *foo; //~ ERROR cannot borrow +} + +fn borrow_imm_and_base_imm(foo: &mut Foo) { + let _bar1 = &foo.bar1.int1; + let _foo1 = &foo.bar1; + let _foo2 = &*foo; +} + +fn borrow_mut_and_imm(foo: &mut Foo) { + let _bar1 = &mut foo.bar1; + let _foo1 = &foo.bar2; +} + +fn borrow_mut_from_imm(foo: &Foo) { + let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow +} + +fn borrow_long_path_both_mut(foo: &mut Foo) { + let _bar1 = &mut foo.bar1.int1; + let _foo1 = &mut foo.bar2.int2; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.stderr new file mode 100644 index 00000000000..00660ff8484 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-mut.stderr @@ -0,0 +1,116 @@ +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:23:22 + | +LL | let _bar1 = &mut foo.bar1; + | -------- first mutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:28:18 + | +LL | let _bar1 = &mut foo.bar1; + | -------- mutable borrow occurs here +LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:33:22 + | +LL | let _bar1 = &foo.bar1; + | -------- immutable borrow occurs here +LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:55:21 + | +LL | let _bar1 = &mut foo.bar1; + | -------- first mutable borrow occurs here +LL | match *foo { +LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} + | ^^^^^^^^^^^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:62:18 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------- mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &*foo; //~ ERROR cannot borrow +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `*foo` as immutable because `foo.bar1.int1` is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:63:18 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------- mutable borrow occurs here +LL | let _foo1 = &foo.bar1; //~ ERROR cannot borrow +LL | let _foo2 = &*foo; //~ ERROR cannot borrow + | ^^^^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:68:22 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------- first mutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0499]: cannot borrow `*foo` as mutable more than once at a time + --> $DIR/borrowck-reborrow-from-mut.rs:73:22 + | +LL | let _bar1 = &mut foo.bar1.int1; + | ------------- first mutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^ second mutable borrow occurs here +LL | } + | - first borrow ends here + +error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:78:22 + | +LL | let _bar1 = &foo.bar1.int1; + | ------------- immutable borrow occurs here +LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0502]: cannot borrow `*foo` as mutable because `foo.bar1.int1` is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:83:22 + | +LL | let _bar1 = &foo.bar1.int1; + | ------------- immutable borrow occurs here +LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow + | ^^^^ mutable borrow occurs here +LL | } + | - immutable borrow ends here + +error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:98:22 + | +LL | fn borrow_mut_from_imm(foo: &Foo) { + | ---- use `&mut Foo` here to make mutable +LL | let _bar1 = &mut foo.bar1; //~ ERROR cannot borrow + | ^^^^^^^^ cannot mutably borrow field of immutable binding + +error: aborting due to 11 previous errors + +Some errors occurred: E0499, E0502, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr new file mode 100644 index 00000000000..43c2a84c957 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr @@ -0,0 +1,18 @@ +warning: not reporting region error due to nll + --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:18 + | +LL | S { pointer: &mut *p.pointer } + | ^^^^^^^^^^^^^^^ + +error: unsatisfied lifetime constraints + --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:18 + | +LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | S { pointer: &mut *p.pointer } + | ^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b` + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs new file mode 100644 index 00000000000..af85e68f5de --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that assignments to an `&mut` pointer which is found in a +// borrowed (but otherwise non-aliasable) location is illegal. + +struct S<'a> { + pointer: &'a mut isize +} + +fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { + S { pointer: &mut *p.pointer } + //~^ ERROR lifetime mismatch +} + +fn main() { + let mut x = 1; + + { + let mut y = S { pointer: &mut x }; + let z = copy_borrowed_ptr(&mut y); + *y.pointer += 1; + *z.pointer += 1; + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr new file mode 100644 index 00000000000..52dabfaa1d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-reborrow-from-shorter-lived-andmut.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:5 + | +LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { + | ------------- ----- + | | + | this parameter and the return type are declared with different lifetimes... +LL | S { pointer: &mut *p.pointer } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...but data from `p` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.nll.stderr new file mode 100644 index 00000000000..ccea5d9565b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.nll.stderr @@ -0,0 +1,12 @@ +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/borrowck-ref-mut-of-imm.rs:14:12 + | +LL | fn destructure(x: Option) -> isize { + | - help: consider changing this to be mutable: `mut x` +... +LL | Some(ref mut v) => *v //~ ERROR cannot borrow + | ^^^^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.rs new file mode 100644 index 00000000000..1784b72a699 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.rs @@ -0,0 +1,20 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn destructure(x: Option) -> isize { + match x { + None => 0, + Some(ref mut v) => *v //~ ERROR cannot borrow + } +} + +fn main() { + assert_eq!(destructure(Some(22)), 22); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.stderr new file mode 100644 index 00000000000..2e2a1224306 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-ref-mut-of-imm.stderr @@ -0,0 +1,12 @@ +error[E0596]: cannot borrow field `(x as std::prelude::v1::Some).0` of immutable binding as mutable + --> $DIR/borrowck-ref-mut-of-imm.rs:14:12 + | +LL | fn destructure(x: Option) -> isize { + | - consider changing this to `mut x` +... +LL | Some(ref mut v) => *v //~ ERROR cannot borrow + | ^^^^^^^^^ cannot mutably borrow field of immutable binding + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr new file mode 100644 index 00000000000..93436d0ca97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr @@ -0,0 +1,17 @@ +error[E0597]: `x` does not live long enough + --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:17:5 + | +LL | (&x).clone() //~ ERROR `x` does not live long enough + | ^^^^ borrowed value does not live long enough +LL | } + | - `x` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 16:9... + --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:16:9 + | +LL | fn leak<'a, T>(x: T) -> &'a T { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.rs new file mode 100644 index 00000000000..7529943f0bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that when we clone a `&T` pointer we properly relate the +// lifetime of the pointer which results to the pointer being cloned. +// Bugs in method resolution have sometimes broken this connection. +// Issue #19261. + +fn leak<'a, T>(x: T) -> &'a T { + (&x).clone() //~ ERROR `x` does not live long enough +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.stderr new file mode 100644 index 00000000000..69d5229244b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-return-variable-on-stack-via-clone.stderr @@ -0,0 +1,17 @@ +error[E0597]: `x` does not live long enough + --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:17:7 + | +LL | (&x).clone() //~ ERROR `x` does not live long enough + | ^ borrowed value does not live long enough +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 16:9... + --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:16:9 + | +LL | fn leak<'a, T>(x: T) -> &'a T { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-return.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-return.rs new file mode 100644 index 00000000000..74d435b35e7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-return.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> isize { + let x: isize; + return x; //~ ERROR use of possibly uninitialized variable: `x` +} + +fn main() { f(); } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-return.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-return.stderr new file mode 100644 index 00000000000..7223289b376 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-return.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-return.rs:13:12 + | +LL | return x; //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.rs new file mode 100644 index 00000000000..bc01088696d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.rs @@ -0,0 +1,37 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z borrowck=compare + +fn ok() { + loop { + let _x = 1; + } +} + +fn also_ok() { + loop { + let _x = String::new(); + } +} + +fn fail() { + loop { + let x: i32; + let _ = x + 1; //~ERROR (Ast) [E0381] + //~^ ERROR (Mir) [E0381] + } +} + +fn main() { + ok(); + also_ok(); + fail(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.stderr new file mode 100644 index 00000000000..edb7c13cf8b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-storage-dead.stderr @@ -0,0 +1,15 @@ +error[E0381]: use of possibly uninitialized variable: `x` (Ast) + --> $DIR/borrowck-storage-dead.rs:28:17 + | +LL | let _ = x + 1; //~ERROR (Ast) [E0381] + | ^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` (Mir) + --> $DIR/borrowck-storage-dead.rs:28:17 + | +LL | let _ = x + 1; //~ERROR (Ast) [E0381] + | ^ use of possibly uninitialized `x` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr new file mode 100644 index 00000000000..a811f5d4def --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-struct-update-with-dtor.rs:25:15 + | +LL | let _s2 = S{a: 2, ..s0}; + | ^^^^^^^^^^^^^ cannot move out of here + +error[E0509]: cannot move out of type `T`, which implements the `Drop` trait + --> $DIR/borrowck-struct-update-with-dtor.rs:31:15 + | +LL | let _s2 = T{a: 2, ..s0}; + | ^^^^^^^^^^^^^ cannot move out of here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.stderr new file mode 100644 index 00000000000..aebee2c3321 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.ast.stderr @@ -0,0 +1,15 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-struct-update-with-dtor.rs:25:25 + | +LL | let _s2 = S{a: 2, ..s0}; + | ^^ cannot move out of here + +error[E0509]: cannot move out of type `T`, which implements the `Drop` trait + --> $DIR/borrowck-struct-update-with-dtor.rs:31:25 + | +LL | let _s2 = T{a: 2, ..s0}; + | ^^ cannot move out of here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.mir.stderr new file mode 100644 index 00000000000..a811f5d4def --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.mir.stderr @@ -0,0 +1,15 @@ +error[E0509]: cannot move out of type `S`, which implements the `Drop` trait + --> $DIR/borrowck-struct-update-with-dtor.rs:25:15 + | +LL | let _s2 = S{a: 2, ..s0}; + | ^^^^^^^^^^^^^ cannot move out of here + +error[E0509]: cannot move out of type `T`, which implements the `Drop` trait + --> $DIR/borrowck-struct-update-with-dtor.rs:31:15 + | +LL | let _s2 = T{a: 2, ..s0}; + | ^^^^^^^^^^^^^ cannot move out of here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.rs new file mode 100644 index 00000000000..f90651687a5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-struct-update-with-dtor.rs @@ -0,0 +1,36 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Issue 4691: Ensure that functional-struct-update can only copy, not +// move, when the struct implements Drop. + +struct B; +struct S { a: isize, b: B } +impl Drop for S { fn drop(&mut self) { } } + +struct T { a: isize, mv: Box } +impl Drop for T { fn drop(&mut self) { } } + +fn f(s0:S) { + let _s2 = S{a: 2, ..s0}; + //[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait + //[mir]~^^ ERROR [E0509] +} + +fn g(s0:T) { + let _s2 = T{a: 2, ..s0}; + //[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait + //[mir]~^^ ERROR [E0509] +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.rs new file mode 100644 index 00000000000..552fcec8e28 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that attempt to swap `&mut` pointer while pointee is borrowed +// yields an error. +// +// Example from src/librustc_borrowck/borrowck/README.md + +use std::mem::swap; + +fn foo<'a>(mut t0: &'a mut isize, + mut t1: &'a mut isize) { + let p: &isize = &*t0; // Freezes `*t0` + swap(&mut t0, &mut t1); //~ ERROR cannot borrow `t0` + *t1 = 22; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.stderr new file mode 100644 index 00000000000..1e42f9b63d7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-swap-mut-base-ptr.stderr @@ -0,0 +1,14 @@ +error[E0502]: cannot borrow `t0` as mutable because `*t0` is also borrowed as immutable + --> $DIR/borrowck-swap-mut-base-ptr.rs:21:15 + | +LL | let p: &isize = &*t0; // Freezes `*t0` + | --- immutable borrow occurs here +LL | swap(&mut t0, &mut t1); //~ ERROR cannot borrow `t0` + | ^^ mutable borrow occurs here +LL | *t1 = 22; +LL | } + | - immutable borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr new file mode 100644 index 00000000000..fa448209f2b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: `FOO` does not live long enough + --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:21:20 + | +LL | assert_static(&FOO); //[ast]~ ERROR [E0597] + | ^^^^ borrowed value does not live long enough +LL | //[mir]~^ ERROR [E0597] +LL | } + | - `FOO` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr new file mode 100644 index 00000000000..27e0dba5095 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr @@ -0,0 +1,13 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:21:21 + | +LL | assert_static(&FOO); //[ast]~ ERROR [E0597] + | ^^^ - temporary value only lives until here + | | + | temporary value does not live long enough + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr new file mode 100644 index 00000000000..fa448209f2b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr @@ -0,0 +1,14 @@ +error[E0597]: `FOO` does not live long enough + --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:21:20 + | +LL | assert_static(&FOO); //[ast]~ ERROR [E0597] + | ^^^^ borrowed value does not live long enough +LL | //[mir]~^ ERROR [E0597] +LL | } + | - `FOO` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs new file mode 100644 index 00000000000..7aa02558446 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(thread_local)] + +#[thread_local] +static FOO: u8 = 3; + +fn assert_static(_t: &'static u8) {} +fn main() { + assert_static(&FOO); //[ast]~ ERROR [E0597] + //[mir]~^ ERROR [E0712] +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.nll.stderr new file mode 100644 index 00000000000..caeaa173bb8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.nll.stderr @@ -0,0 +1,14 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-unary-move.rs:17:10 + | +LL | let y = &*x; + | --- borrow of `*x` occurs here +LL | free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here +LL | //[mir]~^ ERROR cannot move out of `x` because it is borrowed +LL | *y + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.stderr new file mode 100644 index 00000000000..968fbb4526d --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.ast.stderr @@ -0,0 +1,11 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-unary-move.rs:17:10 + | +LL | let y = &*x; + | -- borrow of `*x` occurs here +LL | free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.mir.stderr new file mode 100644 index 00000000000..caeaa173bb8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.mir.stderr @@ -0,0 +1,14 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-unary-move.rs:17:10 + | +LL | let y = &*x; + | --- borrow of `*x` occurs here +LL | free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed + | ^ move out of `x` occurs here +LL | //[mir]~^ ERROR cannot move out of `x` because it is borrowed +LL | *y + | -- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.rs new file mode 100644 index 00000000000..8163ce29939 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-unary-move.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn foo(x: Box) -> isize { + let y = &*x; + free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed + //[mir]~^ ERROR cannot move out of `x` because it is borrowed + *y +} + +fn free(_x: Box) { +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.nll.stderr new file mode 100644 index 00000000000..3fbb747db24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.nll.stderr @@ -0,0 +1,22 @@ +error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable + --> $DIR/borrowck-unboxed-closures.rs:17:5 + | +LL | fn b isize>(f: F) { + | - help: consider changing this to be mutable: `mut f` +LL | f(1, 2); //~ ERROR cannot borrow immutable argument + | ^ cannot borrow as mutable + +error[E0382]: use of moved value: `f` + --> $DIR/borrowck-unboxed-closures.rs:22:5 + | +LL | f(1, 2); + | - value moved here +LL | f(1, 2); //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +Some errors occurred: E0382, E0596. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.rs new file mode 100644 index 00000000000..4813b4b6a72 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn a isize>(mut f: F) { + let g = &mut f; + f(1, 2); //~ ERROR cannot borrow `f` as immutable +} + +fn b isize>(f: F) { + f(1, 2); //~ ERROR cannot borrow immutable argument +} + +fn c isize>(f: F) { + f(1, 2); + f(1, 2); //~ ERROR use of moved value +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.stderr new file mode 100644 index 00000000000..03b835d3077 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-unboxed-closures.stderr @@ -0,0 +1,32 @@ +error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-unboxed-closures.rs:13:5 + | +LL | let g = &mut f; + | - mutable borrow occurs here +LL | f(1, 2); //~ ERROR cannot borrow `f` as immutable + | ^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0596]: cannot borrow immutable argument `f` as mutable + --> $DIR/borrowck-unboxed-closures.rs:17:5 + | +LL | fn b isize>(f: F) { + | - consider changing this to `mut f` +LL | f(1, 2); //~ ERROR cannot borrow immutable argument + | ^ cannot borrow mutably + +error[E0382]: use of moved value: `f` + --> $DIR/borrowck-unboxed-closures.rs:22:5 + | +LL | f(1, 2); + | - value moved here +LL | f(1, 2); //~ ERROR use of moved value + | ^ value used here after move + | + = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +Some errors occurred: E0382, E0502, E0596. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.rs new file mode 100644 index 00000000000..acd827d6c62 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.rs @@ -0,0 +1,15 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let bar; + fn baz(_x: isize) { } + baz(bar); //~ ERROR use of possibly uninitialized variable: `bar` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.stderr new file mode 100644 index 00000000000..17f9c0197ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-after-item.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `bar` + --> $DIR/borrowck-uninit-after-item.rs:14:9 + | +LL | baz(bar); //~ ERROR use of possibly uninitialized variable: `bar` + | ^^^ use of possibly uninitialized `bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.nll.stderr new file mode 100644 index 00000000000..9c7dbd7e778 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.nll.stderr @@ -0,0 +1,30 @@ +error[E0381]: use of possibly uninitialized variable: `a.x` + --> $DIR/borrowck-uninit-field-access.rs:34:13 + | +LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` + | ^^^ use of possibly uninitialized `a.x` + +error[E0382]: use of moved value: `line1.origin.x` + --> $DIR/borrowck-uninit-field-access.rs:39:13 + | +LL | let _moved = line1.origin; + | ------------ value moved here +LL | let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` + | ^^^^^^^^^^^^^^ value used here after move + | + = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `line2` + --> $DIR/borrowck-uninit-field-access.rs:44:5 + | +LL | let _moved = (line2.origin, line2.middle); + | ------------ value moved here +LL | line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] + | ^^^^^ value used here after move + | + = note: move occurs because `line2.middle` has type `Point`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +Some errors occurred: E0381, E0382. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.stderr new file mode 100644 index 00000000000..8536bf22de9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.ast.stderr @@ -0,0 +1,30 @@ +error[E0381]: use of possibly uninitialized variable: `a.x` + --> $DIR/borrowck-uninit-field-access.rs:34:13 + | +LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` + | ^^^ use of possibly uninitialized `a.x` + +error[E0382]: use of moved value: `line1.origin.x` + --> $DIR/borrowck-uninit-field-access.rs:39:13 + | +LL | let _moved = line1.origin; + | ------ value moved here +LL | let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` + | ^^^^^^^^^^^^^^ value used here after move + | + = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait + +error[E0382]: use of partially moved value: `line2` + --> $DIR/borrowck-uninit-field-access.rs:44:5 + | +LL | let _moved = (line2.origin, line2.middle); + | ------------ value moved here +LL | line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] + | ^^^^^ value used here after move + | + = note: move occurs because `line2.origin` has type `Point`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +Some errors occurred: E0381, E0382. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.mir.stderr new file mode 100644 index 00000000000..9c7dbd7e778 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.mir.stderr @@ -0,0 +1,30 @@ +error[E0381]: use of possibly uninitialized variable: `a.x` + --> $DIR/borrowck-uninit-field-access.rs:34:13 + | +LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` + | ^^^ use of possibly uninitialized `a.x` + +error[E0382]: use of moved value: `line1.origin.x` + --> $DIR/borrowck-uninit-field-access.rs:39:13 + | +LL | let _moved = line1.origin; + | ------------ value moved here +LL | let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` + | ^^^^^^^^^^^^^^ value used here after move + | + = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `line2` + --> $DIR/borrowck-uninit-field-access.rs:44:5 + | +LL | let _moved = (line2.origin, line2.middle); + | ------------ value moved here +LL | line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] + | ^^^^^ value used here after move + | + = note: move occurs because `line2.middle` has type `Point`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +Some errors occurred: E0381, E0382. +For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.rs new file mode 100644 index 00000000000..eec7df84c82 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-field-access.rs @@ -0,0 +1,46 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Check that do not allow access to fields of uninitialized or moved +// structs. + +#[derive(Default)] +struct Point { + x: isize, + y: isize, +} + +#[derive(Default)] +struct Line { + origin: Point, + middle: Point, + target: Point, +} + +impl Line { fn consume(self) { } } + +fn main() { + let mut a: Point; + let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` + //[mir]~^ ERROR [E0381] + + let mut line1 = Line::default(); + let _moved = line1.origin; + let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` + //[mir]~^ [E0382] + + let mut line2 = Line::default(); + let _moved = (line2.origin, line2.middle); + line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] + //[mir]~^ [E0382] +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.rs new file mode 100644 index 00000000000..e253ecc74b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.rs @@ -0,0 +1,44 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that the use of uninitialized variable in assignment operator +// expression is detected. + +pub fn main() { + let x: isize; + x += 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x -= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x *= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x /= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x %= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x ^= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x &= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x |= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x <<= 1; //~ ERROR use of possibly uninitialized variable: `x` + + let x: isize; + x >>= 1; //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.stderr new file mode 100644 index 00000000000..7d905f64761 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-in-assignop.stderr @@ -0,0 +1,63 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:16:5 + | +LL | x += 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:19:5 + | +LL | x -= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:22:5 + | +LL | x *= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:25:5 + | +LL | x /= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:28:5 + | +LL | x %= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:31:5 + | +LL | x ^= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:34:5 + | +LL | x &= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:37:5 + | +LL | x |= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:40:5 + | +LL | x <<= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^^ use of possibly uninitialized `x` + +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit-in-assignop.rs:43:5 + | +LL | x >>= 1; //~ ERROR use of possibly uninitialized variable: `x` + | ^^^^^^^ use of possibly uninitialized `x` + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr new file mode 100644 index 00000000000..bd9836e3174 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr @@ -0,0 +1,33 @@ +error[E0381]: borrow of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:21:14 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^^ use of possibly uninitialized `**x` + +error[E0381]: borrow of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:25:14 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^^ use of possibly uninitialized `**x` + +error[E0381]: borrow of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:29:14 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^^ use of possibly uninitialized `**x` + +error[E0381]: borrow of possibly uninitialized variable: `a.y` + --> $DIR/borrowck-uninit-ref-chain.rs:46:14 + | +LL | let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] + | ^^^^ use of possibly uninitialized `a.y` + +error[E0381]: borrow of possibly uninitialized variable: `**a.y` + --> $DIR/borrowck-uninit-ref-chain.rs:51:14 + | +LL | let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] + | ^^^^^^ use of possibly uninitialized `**a.y` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.stderr new file mode 100644 index 00000000000..6b51414e5a2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.ast.stderr @@ -0,0 +1,45 @@ +error[E0381]: use of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:21:15 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^ use of possibly uninitialized `**x` + +error[E0381]: use of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:25:15 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^ use of possibly uninitialized `**x` + +error[E0381]: use of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:29:15 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^ use of possibly uninitialized `**x` + +error[E0381]: use of possibly uninitialized variable: `a.x` + --> $DIR/borrowck-uninit-ref-chain.rs:35:15 + | +LL | let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] + | ^^^ use of possibly uninitialized `a.x` + +error[E0381]: use of possibly uninitialized variable: `**a.x` + --> $DIR/borrowck-uninit-ref-chain.rs:40:15 + | +LL | let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] + | ^^^^^ use of possibly uninitialized `**a.x` + +error[E0381]: use of possibly uninitialized variable: `a.y` + --> $DIR/borrowck-uninit-ref-chain.rs:46:15 + | +LL | let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] + | ^^^ use of possibly uninitialized `a.y` + +error[E0381]: use of possibly uninitialized variable: `**a.y` + --> $DIR/borrowck-uninit-ref-chain.rs:51:15 + | +LL | let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] + | ^^^^^ use of possibly uninitialized `**a.y` + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.mir.stderr new file mode 100644 index 00000000000..bd9836e3174 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.mir.stderr @@ -0,0 +1,33 @@ +error[E0381]: borrow of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:21:14 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^^ use of possibly uninitialized `**x` + +error[E0381]: borrow of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:25:14 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^^ use of possibly uninitialized `**x` + +error[E0381]: borrow of possibly uninitialized variable: `**x` + --> $DIR/borrowck-uninit-ref-chain.rs:29:14 + | +LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + | ^^^^ use of possibly uninitialized `**x` + +error[E0381]: borrow of possibly uninitialized variable: `a.y` + --> $DIR/borrowck-uninit-ref-chain.rs:46:14 + | +LL | let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] + | ^^^^ use of possibly uninitialized `a.y` + +error[E0381]: borrow of possibly uninitialized variable: `**a.y` + --> $DIR/borrowck-uninit-ref-chain.rs:51:14 + | +LL | let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] + | ^^^^^^ use of possibly uninitialized `**a.y` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.rs new file mode 100644 index 00000000000..c52b1f0bf64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit-ref-chain.rs @@ -0,0 +1,53 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +struct S { + x: X, + y: Y, +} + +fn main() { + let x: &&Box; + let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + //[mir]~^ [E0381] + + let x: &&S; + let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + //[mir]~^ [E0381] + + let x: &&i32; + let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] + //[mir]~^ [E0381] + + + let mut a: S; + a.x = 0; + let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] + // (deliberately *not* an error under MIR-borrowck) + + let mut a: S<&&i32, &&i32>; + a.x = &&0; + let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] + // (deliberately *not* an error under MIR-borrowck) + + + let mut a: S; + a.x = 0; + let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] + //[mir]~^ ERROR [E0381] + + let mut a: S<&&i32, &&i32>; + a.x = &&0; + let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] + //[mir]~^ ERROR [E0381] +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.rs new file mode 100644 index 00000000000..f4b73bc889f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(x: isize) { println!("{}", x); } + +fn main() { + let x: isize; + foo(x); //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.stderr new file mode 100644 index 00000000000..ce78001dc64 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uninit.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-uninit.rs:15:9 + | +LL | foo(x); //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.rs new file mode 100644 index 00000000000..6298c87453c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.rs @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Clone, Copy)] +struct S { + a: u8, + b: u16, +} + +#[derive(Clone, Copy)] +union U { + s: S, + c: u32, +} + +fn main() { + unsafe { + { + let mut u = U { s: S { a: 0, b: 1 } }; + let ra = &mut u.s.a; + let b = u.s.b; // OK + } + { + let mut u = U { s: S { a: 0, b: 1 } }; + let ra = &mut u.s.a; + let b = u.c; //~ ERROR cannot use `u.c` because it was mutably borrowed + } + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.stderr new file mode 100644 index 00000000000..4f25a0f742a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow-nested.stderr @@ -0,0 +1,11 @@ +error[E0503]: cannot use `u.c` because it was mutably borrowed + --> $DIR/borrowck-union-borrow-nested.rs:33:17 + | +LL | let ra = &mut u.s.a; + | ----- borrow of `u.s.a` occurs here +LL | let b = u.c; //~ ERROR cannot use `u.c` because it was mutably borrowed + | ^ use of borrowed `u.s.a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.nll.stderr new file mode 100644 index 00000000000..2f14826fa12 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.nll.stderr @@ -0,0 +1,136 @@ +error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-union-borrow.rs:37:23 + | +LL | let ra = &u.a; + | ---- immutable borrow occurs here +LL | let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable + | ^^^^^^^^ mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable +LL | drop(ra); + | -- borrow later used here + +error[E0506]: cannot assign to `u.a` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:43:13 + | +LL | let ra = &u.a; + | ---- borrow of `u.a` occurs here +LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed +LL | drop(ra); + | -- borrow later used here + +error[E0502]: cannot borrow `u.b` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-union-borrow.rs:60:23 + | +LL | let ra = &u.a; + | ---- immutable borrow occurs here +LL | let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + | ^^^^^^^^ mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable +LL | drop(ra); + | -- borrow later used here + +error[E0506]: cannot assign to `u.b` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:66:13 + | +LL | let ra = &u.a; + | ---- borrow of `u.b` occurs here +LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed +LL | drop(ra); + | -- borrow later used here + +error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-union-borrow.rs:73:22 + | +LL | let rma = &mut u.a; + | -------- mutable borrow occurs here +LL | let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable + | ^^^^ immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable +LL | drop(rma); + | --- borrow later used here + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-union-borrow.rs:79:21 + | +LL | let ra = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed +LL | drop(ra); + | -- borrow later used here + +error[E0499]: cannot borrow `u.a` as mutable more than once at a time + --> $DIR/borrowck-union-borrow.rs:85:24 + | +LL | let rma = &mut u.a; + | -------- first mutable borrow occurs here +LL | let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time + | ^^^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time +LL | drop(rma); + | --- borrow later used here + +error[E0506]: cannot assign to `u.a` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:91:13 + | +LL | let rma = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed +LL | drop(rma); + | --- borrow later used here + +error[E0502]: cannot borrow `u.b` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-union-borrow.rs:98:22 + | +LL | let rma = &mut u.a; + | -------- mutable borrow occurs here +LL | let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + | ^^^^ immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable +LL | drop(rma); + | --- borrow later used here + +error[E0503]: cannot use `u.b` because it was mutably borrowed + --> $DIR/borrowck-union-borrow.rs:104:21 + | +LL | let ra = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +... +LL | drop(ra); + | -- borrow later used here + +error[E0499]: cannot borrow `u.b` as mutable more than once at a time + --> $DIR/borrowck-union-borrow.rs:111:24 + | +LL | let rma = &mut u.a; + | -------- first mutable borrow occurs here +LL | let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time + | ^^^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time +LL | drop(rma); + | --- borrow later used here + +error[E0506]: cannot assign to `u.b` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:117:13 + | +LL | let rma = &mut u.a; + | -------- borrow of `u.b` occurs here +LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed +LL | drop(rma); + | --- borrow later used here + +error: aborting due to 12 previous errors + +Some errors occurred: E0499, E0502, E0503, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.stderr new file mode 100644 index 00000000000..9a020705792 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.ast.stderr @@ -0,0 +1,118 @@ +error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-union-borrow.rs:37:28 + | +LL | let ra = &u.a; + | --- immutable borrow occurs here +LL | let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable + | ^^^ mutable borrow occurs here +... +LL | } + | - immutable borrow ends here + +error[E0506]: cannot assign to `u.a` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:43:13 + | +LL | let ra = &u.a; + | --- borrow of `u.a` occurs here +LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.a` occurs here + +error[E0502]: cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + --> $DIR/borrowck-union-borrow.rs:60:28 + | +LL | let ra = &u.a; + | --- immutable borrow occurs here (via `u.a`) +LL | let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + | ^^^ mutable borrow occurs here (via `u.b`) +... +LL | } + | - immutable borrow ends here + +error[E0506]: cannot assign to `u.b` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:66:13 + | +LL | let ra = &u.a; + | --- borrow of `u.b` occurs here +LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.b` occurs here + +error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-union-borrow.rs:73:23 + | +LL | let rma = &mut u.a; + | --- mutable borrow occurs here +LL | let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable + | ^^^ immutable borrow occurs here +... +LL | } + | - mutable borrow ends here + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-union-borrow.rs:79:17 + | +LL | let ra = &mut u.a; + | --- borrow of `u.a` occurs here +LL | let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^ use of borrowed `u.a` + +error[E0499]: cannot borrow `u.a` as mutable more than once at a time + --> $DIR/borrowck-union-borrow.rs:85:29 + | +LL | let rma = &mut u.a; + | --- first mutable borrow occurs here +LL | let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time + | ^^^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0506]: cannot assign to `u.a` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:91:13 + | +LL | let rma = &mut u.a; + | --- borrow of `u.a` occurs here +LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.a` occurs here + +error[E0502]: cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + --> $DIR/borrowck-union-borrow.rs:98:23 + | +LL | let rma = &mut u.a; + | --- mutable borrow occurs here (via `u.a`) +LL | let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + | ^^^ immutable borrow occurs here (via `u.b`) +... +LL | } + | - mutable borrow ends here + +error[E0503]: cannot use `u.b` because it was mutably borrowed + --> $DIR/borrowck-union-borrow.rs:104:17 + | +LL | let ra = &mut u.a; + | --- borrow of `u.a` occurs here +LL | let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed + | ^ use of borrowed `u.a` + +error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time + --> $DIR/borrowck-union-borrow.rs:111:29 + | +LL | let rma = &mut u.a; + | --- first mutable borrow occurs here (via `u.a`) +LL | let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time + | ^^^ second mutable borrow occurs here (via `u.b`) +... +LL | } + | - first borrow ends here + +error[E0506]: cannot assign to `u.b` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:117:13 + | +LL | let rma = &mut u.a; + | --- borrow of `u.b` occurs here +LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.b` occurs here + +error: aborting due to 12 previous errors + +Some errors occurred: E0499, E0502, E0503, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.mir.stderr new file mode 100644 index 00000000000..2f14826fa12 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.mir.stderr @@ -0,0 +1,136 @@ +error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-union-borrow.rs:37:23 + | +LL | let ra = &u.a; + | ---- immutable borrow occurs here +LL | let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable + | ^^^^^^^^ mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable +LL | drop(ra); + | -- borrow later used here + +error[E0506]: cannot assign to `u.a` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:43:13 + | +LL | let ra = &u.a; + | ---- borrow of `u.a` occurs here +LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed +LL | drop(ra); + | -- borrow later used here + +error[E0502]: cannot borrow `u.b` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-union-borrow.rs:60:23 + | +LL | let ra = &u.a; + | ---- immutable borrow occurs here +LL | let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + | ^^^^^^^^ mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable +LL | drop(ra); + | -- borrow later used here + +error[E0506]: cannot assign to `u.b` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:66:13 + | +LL | let ra = &u.a; + | ---- borrow of `u.b` occurs here +LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed +LL | drop(ra); + | -- borrow later used here + +error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-union-borrow.rs:73:22 + | +LL | let rma = &mut u.a; + | -------- mutable borrow occurs here +LL | let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable + | ^^^^ immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable +LL | drop(rma); + | --- borrow later used here + +error[E0503]: cannot use `u.a` because it was mutably borrowed + --> $DIR/borrowck-union-borrow.rs:79:21 + | +LL | let ra = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +LL | //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed +LL | drop(ra); + | -- borrow later used here + +error[E0499]: cannot borrow `u.a` as mutable more than once at a time + --> $DIR/borrowck-union-borrow.rs:85:24 + | +LL | let rma = &mut u.a; + | -------- first mutable borrow occurs here +LL | let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time + | ^^^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time +LL | drop(rma); + | --- borrow later used here + +error[E0506]: cannot assign to `u.a` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:91:13 + | +LL | let rma = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed +LL | drop(rma); + | --- borrow later used here + +error[E0502]: cannot borrow `u.b` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-union-borrow.rs:98:22 + | +LL | let rma = &mut u.a; + | -------- mutable borrow occurs here +LL | let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + | ^^^^ immutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable +LL | drop(rma); + | --- borrow later used here + +error[E0503]: cannot use `u.b` because it was mutably borrowed + --> $DIR/borrowck-union-borrow.rs:104:21 + | +LL | let ra = &mut u.a; + | -------- borrow of `u.a` occurs here +LL | let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed + | ^^^ use of borrowed `u.a` +... +LL | drop(ra); + | -- borrow later used here + +error[E0499]: cannot borrow `u.b` as mutable more than once at a time + --> $DIR/borrowck-union-borrow.rs:111:24 + | +LL | let rma = &mut u.a; + | -------- first mutable borrow occurs here +LL | let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time + | ^^^^^^^^ second mutable borrow occurs here +LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time +LL | drop(rma); + | --- borrow later used here + +error[E0506]: cannot assign to `u.b` because it is borrowed + --> $DIR/borrowck-union-borrow.rs:117:13 + | +LL | let rma = &mut u.a; + | -------- borrow of `u.b` occurs here +LL | u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed +LL | drop(rma); + | --- borrow later used here + +error: aborting due to 12 previous errors + +Some errors occurred: E0499, E0502, E0503, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.rs new file mode 100644 index 00000000000..97193bd0191 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-borrow.rs @@ -0,0 +1,122 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#[derive(Clone, Copy)] +union U { + a: u8, + b: u64, +} + +fn main() { + unsafe { + let mut u = U { b: 0 }; + // Imm borrow, same field + { + let ra = &u.a; + let ra2 = &u.a; // OK + drop(ra); + } + { + let ra = &u.a; + let a = u.a; // OK + drop(ra); + } + { + let ra = &u.a; + let rma = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable + //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable + drop(ra); + } + { + let ra = &u.a; + u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed + drop(ra); + } + // Imm borrow, other field + { + let ra = &u.a; + let rb = &u.b; // OK + drop(ra); + } + { + let ra = &u.a; + let b = u.b; // OK + drop(ra); + } + { + let ra = &u.a; + let rmb = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable + drop(ra); + } + { + let ra = &u.a; + u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed + drop(ra); + } + // Mut borrow, same field + { + let rma = &mut u.a; + let ra = &u.a; //[ast]~ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable + //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable + drop(rma); + } + { + let ra = &mut u.a; + let a = u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed + //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed + drop(ra); + } + { + let rma = &mut u.a; + let rma2 = &mut u.a; //[ast]~ ERROR cannot borrow `u.a` as mutable more than once at a time + //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time + drop(rma); + } + { + let rma = &mut u.a; + u.a = 1; //[ast]~ ERROR cannot assign to `u.a` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.a` because it is borrowed + drop(rma); + } + // Mut borrow, other field + { + let rma = &mut u.a; + let rb = &u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable + drop(rma); + } + { + let ra = &mut u.a; + let b = u.b; //[ast]~ ERROR cannot use `u.b` because it was mutably borrowed + //[mir]~^ ERROR cannot use `u.b` because it was mutably borrowed + + drop(ra); + } + { + let rma = &mut u.a; + let rmb2 = &mut u.b; //[ast]~ ERROR cannot borrow `u` (via `u.b`) as mutable more than once at a time + //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time + drop(rma); + } + { + let rma = &mut u.a; + u.b = 1; //[ast]~ ERROR cannot assign to `u.b` because it is borrowed + //[mir]~^ ERROR cannot assign to `u.b` because it is borrowed + drop(rma); + } + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.nll.stderr new file mode 100644 index 00000000000..2a877050e4c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.nll.stderr @@ -0,0 +1,35 @@ +error[E0382]: use of moved value: `u.a` + --> $DIR/borrowck-union-move-assign.rs:27:21 + | +LL | let a = u.a; + | --- value moved here +LL | let a = u.a; //~ ERROR use of moved value: `u.a` + | ^^^ value used here after move + | + = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.a` + --> $DIR/borrowck-union-move-assign.rs:33:21 + | +LL | let a = u.a; + | --- value moved here +LL | u.a = A; +LL | let a = u.a; // OK + | ^^^ value used here after move + | + = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.a` + --> $DIR/borrowck-union-move-assign.rs:39:21 + | +LL | let a = u.a; + | --- value moved here +LL | u.b = B; +LL | let a = u.a; // OK + | ^^^ value used here after move + | + = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.rs new file mode 100644 index 00000000000..d4d7bc6b0f7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.rs @@ -0,0 +1,42 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] + +// Non-copy +struct A; +struct B; + +union U { + a: A, + b: B, +} + +fn main() { + unsafe { + { + let mut u = U { a: A }; + let a = u.a; + let a = u.a; //~ ERROR use of moved value: `u.a` + } + { + let mut u = U { a: A }; + let a = u.a; + u.a = A; + let a = u.a; // OK + } + { + let mut u = U { a: A }; + let a = u.a; + u.b = B; + let a = u.a; // OK + } + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.stderr new file mode 100644 index 00000000000..b0924d28c9c --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move-assign.stderr @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `u.a` + --> $DIR/borrowck-union-move-assign.rs:27:17 + | +LL | let a = u.a; + | - value moved here +LL | let a = u.a; //~ ERROR use of moved value: `u.a` + | ^ value used here after move + | + = note: move occurs because `u.a` has type `A`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.nll.stderr new file mode 100644 index 00000000000..6fd6a1c82a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.nll.stderr @@ -0,0 +1,63 @@ +error[E0382]: use of moved value: `u.n1` + --> $DIR/borrowck-union-move.rs:36:21 + | +LL | let a = u.n1; + | ---- value moved here +LL | let a = u.n1; //~ ERROR use of moved value: `u.n1` + | ^^^^ value used here after move + | + = note: move occurs because `u` has type `Unn`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:41:21 + | +LL | let a = u.n1; + | ---- value moved here +LL | let a = u; //~ ERROR use of partially moved value: `u` + | ^ value used here after move + | + = note: move occurs because `u` has type `Unn`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.n2` + --> $DIR/borrowck-union-move.rs:46:21 + | +LL | let a = u.n1; + | ---- value moved here +LL | let a = u.n2; //~ ERROR use of moved value: `u.n2` + | ^^^^ value used here after move + | + = note: move occurs because `u` has type `Unn`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.n` + --> $DIR/borrowck-union-move.rs:73:21 + | +LL | let a = u.n; + | --- value moved here +LL | let a = u.n; //~ ERROR use of moved value: `u.n` + | ^^^ value used here after move + | + = note: move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.c` + --> $DIR/borrowck-union-move.rs:78:21 + | +LL | let a = u.n; + | --- value moved here +LL | let a = u.c; //~ ERROR use of moved value: `u.c` + | ^^^ value used here after move + | + = note: move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:93:21 + | +LL | let a = u.n; + | --- value moved here +LL | let a = u; //~ ERROR use of partially moved value: `u` + | ^ value used here after move + | + = note: move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.rs new file mode 100644 index 00000000000..5320244cf43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.rs @@ -0,0 +1,96 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(untagged_unions)] + +#[derive(Clone, Copy)] +struct Copy; +struct NonCopy; + +union Unn { + n1: NonCopy, + n2: NonCopy, +} +union Ucc { + c1: Copy, + c2: Copy, +} +union Ucn { + c: Copy, + n: NonCopy, +} + +fn main() { + unsafe { + // 2 NonCopy + { + let mut u = Unn { n1: NonCopy }; + let a = u.n1; + let a = u.n1; //~ ERROR use of moved value: `u.n1` + } + { + let mut u = Unn { n1: NonCopy }; + let a = u.n1; + let a = u; //~ ERROR use of partially moved value: `u` + } + { + let mut u = Unn { n1: NonCopy }; + let a = u.n1; + let a = u.n2; //~ ERROR use of moved value: `u.n2` + } + // 2 Copy + { + let mut u = Ucc { c1: Copy }; + let a = u.c1; + let a = u.c1; // OK + } + { + let mut u = Ucc { c1: Copy }; + let a = u.c1; + let a = u; // OK + } + { + let mut u = Ucc { c1: Copy }; + let a = u.c1; + let a = u.c2; // OK + } + // 1 Copy, 1 NonCopy + { + let mut u = Ucn { c: Copy }; + let a = u.c; + let a = u.c; // OK + } + { + let mut u = Ucn { c: Copy }; + let a = u.n; + let a = u.n; //~ ERROR use of moved value: `u.n` + } + { + let mut u = Ucn { c: Copy }; + let a = u.n; + let a = u.c; //~ ERROR use of moved value: `u.c` + } + { + let mut u = Ucn { c: Copy }; + let a = u.c; + let a = u.n; // OK + } + { + let mut u = Ucn { c: Copy }; + let a = u.c; + let a = u; // OK + } + { + let mut u = Ucn { c: Copy }; + let a = u.n; + let a = u; //~ ERROR use of partially moved value: `u` + } + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.stderr new file mode 100644 index 00000000000..d3e441bbbf4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-move.stderr @@ -0,0 +1,63 @@ +error[E0382]: use of moved value: `u.n1` + --> $DIR/borrowck-union-move.rs:36:17 + | +LL | let a = u.n1; + | - value moved here +LL | let a = u.n1; //~ ERROR use of moved value: `u.n1` + | ^ value used here after move + | + = note: move occurs because `u.n1` has type `NonCopy`, which does not implement the `Copy` trait + +error[E0382]: use of partially moved value: `u` + --> $DIR/borrowck-union-move.rs:41:17 + | +LL | let a = u.n1; + | - value moved here +LL | let a = u; //~ ERROR use of partially moved value: `u` + | ^ value used here after move + | + = note: move occurs because `u.n2` has type `[type error]`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.n2` + --> $DIR/borrowck-union-move.rs:46:17 + | +LL | let a = u.n1; + | - value moved here +LL | let a = u.n2; //~ ERROR use of moved value: `u.n2` + | ^ value used here after move + | + = note: move occurs because `u.n2` has type `[type error]`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.n` + --> $DIR/borrowck-union-move.rs:73:17 + | +LL | let a = u.n; + | - value moved here +LL | let a = u.n; //~ ERROR use of moved value: `u.n` + | ^ value used here after move + | + = note: move occurs because `u.n` has type `NonCopy`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.c` + --> $DIR/borrowck-union-move.rs:78:17 + | +LL | let a = u.n; + | - value moved here +LL | let a = u.c; //~ ERROR use of moved value: `u.c` + | ^ value used here after move + | + = note: move occurs because `u.c` has type `[type error]`, which does not implement the `Copy` trait + +error[E0382]: use of partially moved value: `u` + --> $DIR/borrowck-union-move.rs:93:17 + | +LL | let a = u.n; + | - value moved here +LL | let a = u; //~ ERROR use of partially moved value: `u` + | ^ value used here after move + | + = note: move occurs because `u.c` has type `[type error]`, which does not implement the `Copy` trait + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.nll.stderr new file mode 100644 index 00000000000..49bc6d32636 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `u.a` + --> $DIR/borrowck-union-uninitialized.rs:26:18 + | +LL | let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` + | ^^^ use of possibly uninitialized `u.a` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.rs new file mode 100644 index 00000000000..81376a1a169 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S { + a: u8, +} + +union U { + a: u8, +} + +fn main() { + unsafe { + let mut s: S; + let mut u: U; + s.a = 0; + u.a = 0; + let sa = s.a; //~ ERROR use of possibly uninitialized variable: `s.a` + let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` + } +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.stderr new file mode 100644 index 00000000000..901d1ecc506 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-union-uninitialized.stderr @@ -0,0 +1,15 @@ +error[E0381]: use of possibly uninitialized variable: `s.a` + --> $DIR/borrowck-union-uninitialized.rs:25:13 + | +LL | let sa = s.a; //~ ERROR use of possibly uninitialized variable: `s.a` + | ^^ use of possibly uninitialized `s.a` + +error[E0381]: use of possibly uninitialized variable: `u.a` + --> $DIR/borrowck-union-uninitialized.rs:26:13 + | +LL | let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` + | ^^ use of possibly uninitialized `u.a` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.rs new file mode 100644 index 00000000000..f36dc0ca43f --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.rs @@ -0,0 +1,62 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +fn borrow(_v: &isize) {} + +fn local() { + let mut v: Box<_> = box 3; + borrow(&*v); +} + +fn local_rec() { + struct F { f: Box } + let mut v = F {f: box 3}; + borrow(&*v.f); +} + +fn local_recs() { + struct F { f: G } + struct G { g: H } + struct H { h: Box } + let mut v = F {f: G {g: H {h: box 3}}}; + borrow(&*v.f.g.h); +} + +fn aliased_imm() { + let mut v: Box<_> = box 3; + let _w = &v; + borrow(&*v); +} + +fn aliased_mut() { + let mut v: Box<_> = box 3; + let _w = &mut v; + borrow(&*v); //~ ERROR cannot borrow `*v` +} + +fn aliased_other() { + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; + let _x = &mut w; + borrow(&*v); +} + +fn aliased_other_reassign() { + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; + let mut _x = &mut w; + _x = &mut v; + borrow(&*v); //~ ERROR cannot borrow `*v` +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.stderr new file mode 100644 index 00000000000..9131cad1275 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-uniq-via-lend.stderr @@ -0,0 +1,23 @@ +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-uniq-via-lend.rs:43:13 + | +LL | let _w = &mut v; + | - mutable borrow occurs here +LL | borrow(&*v); //~ ERROR cannot borrow `*v` + | ^^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable + --> $DIR/borrowck-uniq-via-lend.rs:58:13 + | +LL | _x = &mut v; + | - mutable borrow occurs here +LL | borrow(&*v); //~ ERROR cannot borrow `*v` + | ^^ immutable borrow occurs here +LL | } + | - mutable borrow ends here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr new file mode 100644 index 00000000000..d69693eb035 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0381]: use of possibly uninitialized variable: `*w` + --> $DIR/borrowck-use-in-index-lvalue.rs:16:5 + | +LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + | ^^^^ use of possibly uninitialized `*w` + +error[E0381]: use of possibly uninitialized variable: `*w` + --> $DIR/borrowck-use-in-index-lvalue.rs:20:5 + | +LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + | ^^^^ use of possibly uninitialized `*w` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.stderr new file mode 100644 index 00000000000..3a33081dfcd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.ast.stderr @@ -0,0 +1,15 @@ +error[E0381]: use of possibly uninitialized variable: `*w` + --> $DIR/borrowck-use-in-index-lvalue.rs:16:5 + | +LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + | ^^^^^^^^ use of possibly uninitialized `*w` + +error[E0381]: use of possibly uninitialized variable: `*w` + --> $DIR/borrowck-use-in-index-lvalue.rs:20:5 + | +LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + | ^^^^^^^^ use of possibly uninitialized `*w` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.mir.stderr new file mode 100644 index 00000000000..d69693eb035 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.mir.stderr @@ -0,0 +1,15 @@ +error[E0381]: use of possibly uninitialized variable: `*w` + --> $DIR/borrowck-use-in-index-lvalue.rs:16:5 + | +LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + | ^^^^ use of possibly uninitialized `*w` + +error[E0381]: use of possibly uninitialized variable: `*w` + --> $DIR/borrowck-use-in-index-lvalue.rs:20:5 + | +LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + | ^^^^ use of possibly uninitialized `*w` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.rs new file mode 100644 index 00000000000..eb99f78f461 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-in-index-lvalue.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn test() { + let w: &mut [isize]; + w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + //[mir]~^ ERROR [E0381] + + let mut w: &mut [isize]; + w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] + //[mir]~^ ERROR [E0381] +} + +fn main() { test(); } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.nll.stderr new file mode 100644 index 00000000000..2289dd688cf --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.nll.stderr @@ -0,0 +1,95 @@ +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:21:10 + | +LL | let p = &mut x; + | ------ borrow of `x` occurs here +LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed + | ^ use of borrowed `x` +LL | *p = 2; + | ------ borrow later used here + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:28:10 + | +LL | let p = &mut x.a; + | -------- borrow of `x.a` occurs here +LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed + | ^ use of borrowed `x.a` +LL | *p = 3; + | ------ borrow later used here + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:35:10 + | +LL | let p = &mut x; + | ------ borrow of `x` occurs here +LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^^^ use of borrowed `x` +LL | p.a = 3; + | ------- borrow later used here + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:42:10 + | +LL | let p = &mut x.a; + | -------- borrow of `x.a` occurs here +LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^^^ use of borrowed `x.a` +LL | *p = 3; + | ------ borrow later used here + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:49:13 + | +LL | let p = &mut x; + | ------ borrow of `x` occurs here +LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^^^^^^^^^^^^^^^^ use of borrowed `x` +LL | drop(y); +LL | p.a = 4; + | ------- borrow later used here + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:57:13 + | +LL | let p = &mut x.a; + | -------- borrow of `x.a` occurs here +LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^^^^^^^^^^^^^^^^ use of borrowed `x.a` +LL | drop(y); +LL | *p = 4; + | ------ borrow later used here + +error[E0503]: cannot use `*x` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:65:10 + | +LL | let p = &mut x; + | ------ borrow of `x` occurs here +LL | drop(*x); //~ ERROR cannot use `*x` because it was mutably borrowed + | ^^ use of borrowed `x` +LL | **p = 2; + | ------- borrow later used here + +error[E0503]: cannot use `*x.b` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:72:10 + | +LL | let p = &mut x; + | ------ borrow of `x` occurs here +LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed + | ^^^^ use of borrowed `x` +LL | p.a = 3; + | ------- borrow later used here + +error[E0503]: cannot use `*x.b` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:79:10 + | +LL | let p = &mut x.b; + | -------- borrow of `x.b` occurs here +LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed + | ^^^^ use of borrowed `x.b` +LL | **p = 3; + | ------- borrow later used here + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.rs new file mode 100644 index 00000000000..c11e58651aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.rs @@ -0,0 +1,96 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +#[derive(Copy, Clone)] +struct A { a: isize, b: isize } + +struct B { a: isize, b: Box } + +fn var_copy_after_var_borrow() { + let mut x: isize = 1; + let p = &mut x; + drop(x); //~ ERROR cannot use `x` because it was mutably borrowed + *p = 2; +} + +fn var_copy_after_field_borrow() { + let mut x = A { a: 1, b: 2 }; + let p = &mut x.a; + drop(x); //~ ERROR cannot use `x` because it was mutably borrowed + *p = 3; +} + +fn field_copy_after_var_borrow() { + let mut x = A { a: 1, b: 2 }; + let p = &mut x; + drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed + p.a = 3; +} + +fn field_copy_after_field_borrow() { + let mut x = A { a: 1, b: 2 }; + let p = &mut x.a; + drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed + *p = 3; +} + +fn fu_field_copy_after_var_borrow() { + let mut x = A { a: 1, b: 2 }; + let p = &mut x; + let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed + drop(y); + p.a = 4; +} + +fn fu_field_copy_after_field_borrow() { + let mut x = A { a: 1, b: 2 }; + let p = &mut x.a; + let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed + drop(y); + *p = 4; +} + +fn var_deref_after_var_borrow() { + let mut x: Box = box 1; + let p = &mut x; + drop(*x); //~ ERROR cannot use `*x` because it was mutably borrowed + **p = 2; +} + +fn field_deref_after_var_borrow() { + let mut x = B { a: 1, b: box 2 }; + let p = &mut x; + drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed + p.a = 3; +} + +fn field_deref_after_field_borrow() { + let mut x = B { a: 1, b: box 2 }; + let p = &mut x.b; + drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed + **p = 3; +} + +fn main() { + var_copy_after_var_borrow(); + var_copy_after_field_borrow(); + + field_copy_after_var_borrow(); + field_copy_after_field_borrow(); + + fu_field_copy_after_var_borrow(); + fu_field_copy_after_field_borrow(); + + var_deref_after_var_borrow(); + field_deref_after_var_borrow(); + field_deref_after_field_borrow(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.stderr new file mode 100644 index 00000000000..c5bfd813a79 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-mut-borrow.stderr @@ -0,0 +1,75 @@ +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:21:10 + | +LL | let p = &mut x; + | - borrow of `x` occurs here +LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed + | ^ use of borrowed `x` + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:28:10 + | +LL | let p = &mut x.a; + | --- borrow of `x.a` occurs here +LL | drop(x); //~ ERROR cannot use `x` because it was mutably borrowed + | ^ use of borrowed `x.a` + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:35:10 + | +LL | let p = &mut x; + | - borrow of `x` occurs here +LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^^^ use of borrowed `x` + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:42:10 + | +LL | let p = &mut x.a; + | --- borrow of `x.a` occurs here +LL | drop(x.a); //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^^^ use of borrowed `x.a` + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:49:26 + | +LL | let p = &mut x; + | - borrow of `x` occurs here +LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^ use of borrowed `x` + +error[E0503]: cannot use `x.a` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:57:26 + | +LL | let p = &mut x.a; + | --- borrow of `x.a` occurs here +LL | let y = A { b: 3, .. x }; //~ ERROR cannot use `x.a` because it was mutably borrowed + | ^ use of borrowed `x.a` + +error[E0503]: cannot use `*x` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:65:10 + | +LL | let p = &mut x; + | - borrow of `x` occurs here +LL | drop(*x); //~ ERROR cannot use `*x` because it was mutably borrowed + | ^^ use of borrowed `x` + +error[E0503]: cannot use `*x.b` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:72:10 + | +LL | let p = &mut x; + | - borrow of `x` occurs here +LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed + | ^^^^ use of borrowed `x` + +error[E0503]: cannot use `*x.b` because it was mutably borrowed + --> $DIR/borrowck-use-mut-borrow.rs:79:10 + | +LL | let p = &mut x.b; + | --- borrow of `x.b` occurs here +LL | drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed + | ^^^^ use of borrowed `x.b` + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr new file mode 100644 index 00000000000..b96379db650 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `*x` + --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:22:13 + | +LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` + | ^ use of possibly uninitialized `*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr new file mode 100644 index 00000000000..47ea9f33b1e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `*x` + --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:22:13 + | +LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` + | ^ use of possibly uninitialized `*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr new file mode 100644 index 00000000000..b96379db650 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `*x` + --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:22:13 + | +LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` + | ^ use of possibly uninitialized `*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.rs new file mode 100644 index 00000000000..57c2d508356 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast-trait.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Variation on `borrowck-use-uninitialized-in-cast` in which we do a +// trait cast from an uninitialized source. Issue #20791. + +trait Foo { fn dummy(&self) { } } +impl Foo for i32 { } + +fn main() { + let x: &i32; + let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` + //[mir]~^ ERROR [E0381] +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr new file mode 100644 index 00000000000..6eddbd934d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `*x` + --> $DIR/borrowck-use-uninitialized-in-cast.rs:20:13 + | +LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] + | ^ use of possibly uninitialized `*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr new file mode 100644 index 00000000000..75109abad51 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `*x` + --> $DIR/borrowck-use-uninitialized-in-cast.rs:20:13 + | +LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] + | ^ use of possibly uninitialized `*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr new file mode 100644 index 00000000000..6eddbd934d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `*x` + --> $DIR/borrowck-use-uninitialized-in-cast.rs:20:13 + | +LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] + | ^ use of possibly uninitialized `*x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.rs new file mode 100644 index 00000000000..dbc20d02057 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-use-uninitialized-in-cast.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Check that we detect unused values that are cast to other things. +// The problem was specified to casting to `*`, as creating unsafe +// pointers was not being fully checked. Issue #20791. + +fn main() { + let x: &i32; + let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] + //[mir]~^ ERROR [E0381] +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.nll.stderr new file mode 100644 index 00000000000..374256c6bd6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.nll.stderr @@ -0,0 +1,48 @@ +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-element-loan.rs:15:25 + | +LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough + | ^^^^ borrowed value does not live long enough +... +LL | } + | - `vec` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... + --> $DIR/borrowck-vec-pattern-element-loan.rs:13:6 + | +LL | fn a<'a>() -> &'a [isize] { + | ^^ + +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-element-loan.rs:25:25 + | +LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough + | ^^^^ borrowed value does not live long enough +... +LL | } + | - `vec` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:6... + --> $DIR/borrowck-vec-pattern-element-loan.rs:23:6 + | +LL | fn b<'a>() -> &'a [isize] { + | ^^ + +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-element-loan.rs:35:25 + | +LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough + | ^^^^ borrowed value does not live long enough +... +LL | } + | - `vec` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 33:6... + --> $DIR/borrowck-vec-pattern-element-loan.rs:33:6 + | +LL | fn c<'a>() -> &'a [isize] { + | ^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.rs new file mode 100644 index 00000000000..0fd6923326a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.rs @@ -0,0 +1,43 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] + +fn a<'a>() -> &'a [isize] { + let vec = vec![1, 2, 3, 4]; + let vec: &[isize] = &vec; //~ ERROR does not live long enough + let tail = match vec { + &[_, ref tail..] => tail, + _ => panic!("a") + }; + tail +} + +fn b<'a>() -> &'a [isize] { + let vec = vec![1, 2, 3, 4]; + let vec: &[isize] = &vec; //~ ERROR does not live long enough + let init = match vec { + &[ref init.., _] => init, + _ => panic!("b") + }; + init +} + +fn c<'a>() -> &'a [isize] { + let vec = vec![1, 2, 3, 4]; + let vec: &[isize] = &vec; //~ ERROR does not live long enough + let slice = match vec { + &[_, ref slice.., _] => slice, + _ => panic!("c") + }; + slice +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.stderr new file mode 100644 index 00000000000..656a25d14fc --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-element-loan.stderr @@ -0,0 +1,48 @@ +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-element-loan.rs:15:26 + | +LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... + --> $DIR/borrowck-vec-pattern-element-loan.rs:13:6 + | +LL | fn a<'a>() -> &'a [isize] { + | ^^ + +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-element-loan.rs:25:26 + | +LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:6... + --> $DIR/borrowck-vec-pattern-element-loan.rs:23:6 + | +LL | fn b<'a>() -> &'a [isize] { + | ^^ + +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-element-loan.rs:35:26 + | +LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 33:6... + --> $DIR/borrowck-vec-pattern-element-loan.rs:33:6 + | +LL | fn c<'a>() -> &'a [isize] { + | ^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr new file mode 100644 index 00000000000..9b73991ce30 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr @@ -0,0 +1,14 @@ +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/borrowck-vec-pattern-loan-from-mut.rs:18:13 + | +LL | let vb: &mut [isize] = &mut v; + | ------ first mutable borrow occurs here +... +LL | v.push(tail[0] + tail[1]); //~ ERROR cannot borrow + | ^ ------- borrow later used here + | | + | second mutable borrow occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.rs new file mode 100644 index 00000000000..505c8c6d535 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] + +fn a() { + let mut v = vec![1, 2, 3]; + let vb: &mut [isize] = &mut v; + match vb { + &mut [_a, ref tail..] => { + v.push(tail[0] + tail[1]); //~ ERROR cannot borrow + } + _ => {} + }; +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.stderr new file mode 100644 index 00000000000..7015923af0a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-loan-from-mut.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/borrowck-vec-pattern-loan-from-mut.rs:18:13 + | +LL | let vb: &mut [isize] = &mut v; + | - first mutable borrow occurs here +... +LL | v.push(tail[0] + tail[1]); //~ ERROR cannot borrow + | ^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr new file mode 100644 index 00000000000..f99e2cec330 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr @@ -0,0 +1,15 @@ +error[E0506]: cannot assign to `a[..]` because it is borrowed + --> $DIR/borrowck-vec-pattern-move-tail.rs:24:5 + | +LL | [1, 2, ref tail..] => tail, + | -------- borrow of `a[..]` occurs here +... +LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed + | ^^^^^^^^ assignment to borrowed `a[..]` occurs here +... +LL | println!("t[0]: {}", t[0]); + | ---- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.stderr new file mode 100644 index 00000000000..2b32de6944a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.ast.stderr @@ -0,0 +1,12 @@ +error[E0506]: cannot assign to `a[..]` because it is borrowed + --> $DIR/borrowck-vec-pattern-move-tail.rs:24:5 + | +LL | [1, 2, ref tail..] => tail, + | -------- borrow of `a[..]` occurs here +... +LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed + | ^^^^^^^^ assignment to borrowed `a[..]` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr new file mode 100644 index 00000000000..a6aa9cd6d2a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr @@ -0,0 +1,24 @@ +error[E0506]: cannot assign to `a[..]` because it is borrowed (Ast) + --> $DIR/borrowck-vec-pattern-move-tail.rs:24:5 + | +LL | [1, 2, ref tail..] => tail, + | -------- borrow of `a[..]` occurs here +... +LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed + | ^^^^^^^^ assignment to borrowed `a[..]` occurs here + +error[E0506]: cannot assign to `a[..]` because it is borrowed (Mir) + --> $DIR/borrowck-vec-pattern-move-tail.rs:24:5 + | +LL | [1, 2, ref tail..] => tail, + | -------- borrow of `a[..]` occurs here +... +LL | a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed + | ^^^^^^^^ assignment to borrowed `a[..]` occurs here +... +LL | println!("t[0]: {}", t[0]); + | ---- borrow later used here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.rs new file mode 100644 index 00000000000..94877b27d58 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-move-tail.rs @@ -0,0 +1,29 @@ + +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast cmp +//[cmp]compile-flags: -Z borrowck=compare + +#![feature(slice_patterns)] + +fn main() { + let mut a = [1, 2, 3, 4]; + let t = match a { + [1, 2, ref tail..] => tail, + _ => unreachable!() + }; + println!("t[0]: {}", t[0]); + a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed + //[cmp]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast) + //[cmp]~| ERROR cannot assign to `a[..]` because it is borrowed (Mir) + println!("t[0]: {}", t[0]); + t[0]; +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr new file mode 100644 index 00000000000..6d45f1541a0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr @@ -0,0 +1,18 @@ +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:15:25 + | +LL | let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough + | ^^^^ borrowed value does not live long enough +... +LL | } + | - `vec` dropped here while still borrowed + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... + --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:13:6 + | +LL | fn a<'a>() -> &'a isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.rs new file mode 100644 index 00000000000..cd8f3ebefe6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(slice_patterns)] + +fn a<'a>() -> &'a isize { + let vec = vec![1, 2, 3, 4]; + let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough + let tail = match vec { + &[_a, ref tail..] => &tail[0], + _ => panic!("foo") + }; + tail +} + +fn main() { + let fifth = a(); + println!("{}", *fifth); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.stderr new file mode 100644 index 00000000000..36343c1bde6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-vec-pattern-tail-element-loan.stderr @@ -0,0 +1,18 @@ +error[E0597]: `vec` does not live long enough + --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:15:26 + | +LL | let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough + | ^^^ borrowed value does not live long enough +... +LL | } + | - borrowed value only lives until here + | +note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... + --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:13:6 + | +LL | fn a<'a>() -> &'a isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.nll.stderr new file mode 100644 index 00000000000..de2ba578962 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.nll.stderr @@ -0,0 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `v` + --> $DIR/borrowck-while-break.rs:17:20 + | +LL | println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` + | ^ use of possibly uninitialized `v` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.rs new file mode 100644 index 00000000000..8cdf1da5c93 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn test(cond: bool) { + let v; + while cond { + v = 3; + break; + } + println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` +} + +fn main() { + test(true); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.stderr new file mode 100644 index 00000000000..eaaecdb5bbb --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-break.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `v` + --> $DIR/borrowck-while-break.rs:17:20 + | +LL | println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` + | ^ use of possibly uninitialized `v` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.rs new file mode 100644 index 00000000000..27d42d666ea --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.rs @@ -0,0 +1,14 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x: bool; + while x { } //~ ERROR use of possibly uninitialized variable: `x` +} diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.stderr new file mode 100644 index 00000000000..41ef9e800bd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-while-cond.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-while-cond.rs:13:11 + | +LL | while x { } //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-while.rs b/src/test/ui/compile-fail-migration/borrowck/borrowck-while.rs new file mode 100644 index 00000000000..e3566e9bb92 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-while.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f() -> isize { + let mut x: isize; + while 1 == 1 { x = 10; } + return x; //~ ERROR use of possibly uninitialized variable: `x` +} + +fn main() { f(); } diff --git a/src/test/ui/compile-fail-migration/borrowck/borrowck-while.stderr b/src/test/ui/compile-fail-migration/borrowck/borrowck-while.stderr new file mode 100644 index 00000000000..9fb2dcaa436 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/borrowck-while.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `x` + --> $DIR/borrowck-while.rs:14:12 + | +LL | return x; //~ ERROR use of possibly uninitialized variable: `x` + | ^ use of possibly uninitialized `x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.ast.stderr new file mode 100644 index 00000000000..4c399ab6014 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.ast.stderr @@ -0,0 +1,15 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/move-in-static-initializer-issue-38520.rs:27:23 + | +LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/move-in-static-initializer-issue-38520.rs:29:22 + | +LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ cannot move out of borrowed content + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.mir.stderr b/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.mir.stderr new file mode 100644 index 00000000000..4c399ab6014 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.mir.stderr @@ -0,0 +1,15 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/move-in-static-initializer-issue-38520.rs:27:23 + | +LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ cannot move out of borrowed content + +error[E0507]: cannot move out of borrowed content + --> $DIR/move-in-static-initializer-issue-38520.rs:29:22 + | +LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ cannot move out of borrowed content + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.rs b/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.rs new file mode 100644 index 00000000000..508e09318ae --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/move-in-static-initializer-issue-38520.rs @@ -0,0 +1,33 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Regression test for #38520. Check that moves of `Foo` are not +// permitted as `Foo` is not copy (even in a static/const +// initializer). + +#![feature(const_fn)] + +struct Foo(usize); + +const fn get(x: Foo) -> usize { + x.0 +} + +const X: Foo = Foo(22); +static Y: usize = get(*&X); //[ast]~ ERROR E0507 + //[mir]~^ ERROR [E0507] +const Z: usize = get(*&X); //[ast]~ ERROR E0507 + //[mir]~^ ERROR [E0507] + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.rs new file mode 100644 index 00000000000..e03a0355b48 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.rs @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a borrow which starts as a 2-phase borrow and gets +// carried around a loop winds up conflicting with itself. + +#![feature(nll)] + +struct Foo { x: String } + +impl Foo { + fn get_string(&mut self) -> &str { + &self.x + } +} + +fn main() { + let mut foo = Foo { x: format!("Hello, world") }; + let mut strings = vec![]; + + loop { + strings.push(foo.get_string()); //~ ERROR cannot borrow `foo` as mutable + if strings.len() > 2 { break; } + } + + println!("{:?}", strings); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.stderr new file mode 100644 index 00000000000..65c3d27923e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-across-loop.stderr @@ -0,0 +1,9 @@ +error[E0499]: cannot borrow `foo` as mutable more than once at a time + --> $DIR/two-phase-across-loop.rs:29:22 + | +LL | strings.push(foo.get_string()); //~ ERROR cannot borrow `foo` as mutable + | ^^^ mutable borrow starts here in previous iteration of loop + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.nll_target.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.nll_target.stderr new file mode 100644 index 00000000000..5a7f33e5b56 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.nll_target.stderr @@ -0,0 +1,47 @@ +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-activation-sharing-interference.rs:42:15 + | +LL | let y = &mut x; + | ------ mutable borrow occurs here +LL | { let z = &x; read(z); } + | ^^ immutable borrow occurs here +LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | *y += 1; + | ------- borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-activation-sharing-interference.rs:50:13 + | +LL | let y = &mut x; + | ------ mutable borrow occurs here +LL | let z = &x; + | ^^ immutable borrow occurs here +LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | *y += 1; + | ------- borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-activation-sharing-interference.rs:61:13 + | +LL | let y = &mut x; + | ------ mutable borrow occurs here +LL | let z = &x; + | ^^ immutable borrow occurs here +... +LL | *y += 1; + | ------- borrow later used here + +error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-activation-sharing-interference.rs:72:14 + | +LL | let y = &mut x; + | ------ mutable borrow occurs here +LL | let _z = &x; + | ^^ immutable borrow occurs here +LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable +LL | *y += 1; + | ------- borrow later used here + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.rs new file mode 100644 index 00000000000..77b237e34f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-activation-sharing-interference.rs @@ -0,0 +1,79 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +// revisions: nll_target + +// The following revisions are disabled due to missing support from two-phase beyond autorefs +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref + +//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows + +// This is an important corner case pointed out by Niko: one is +// allowed to initiate a shared borrow during a reservation, but it +// *must end* before the activation occurs. +// +// FIXME: for clarity, diagnostics for these cases might be better off +// if they specifically said "cannot activate mutable borrow of `x`" +// +// The convention for the listed revisions: "lxl" means lexical +// lifetimes (which can be easier to reason about). "nll" means +// non-lexical lifetimes. "nll_target" means the initial conservative +// two-phase borrows that only applies to autoref-introduced borrows. +// "nll_beyond" means the generalization of two-phase borrows to all +// `&mut`-borrows (doing so makes it easier to write code for specific +// corner cases). + +#![allow(dead_code)] + +fn read(_: &i32) { } + +fn ok() { + let mut x = 3; + let y = &mut x; + { let z = &x; read(z); } + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + *y += 1; +} + +fn not_ok() { + let mut x = 3; + let y = &mut x; + let z = &x; + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + *y += 1; + //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + //[nll_beyond]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + read(z); +} + +fn should_be_ok_with_nll() { + let mut x = 3; + let y = &mut x; + let z = &x; + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + read(z); + *y += 1; + //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + // (okay with (generalized) nll today) +} + +fn should_also_eventually_be_ok_with_nll() { + let mut x = 3; + let y = &mut x; + let _z = &x; + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + *y += 1; + //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + // (okay with (generalized) nll today) +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr new file mode 100644 index 00000000000..45cfc836017 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.nll_target.stderr @@ -0,0 +1,27 @@ +error[E0503]: cannot use `i` because it was mutably borrowed + --> $DIR/two-phase-allow-access-during-reservation.rs:40:19 + | +LL | /*1*/ let p = &mut i; // (reservation of `i` starts here) + | ------ borrow of `i` occurs here +LL | +LL | /*2*/ let j = i; // OK: `i` is only reserved here + | ^ use of borrowed `i` +... +LL | /*3*/ *p += 1; // (mutable borrow of `i` starts here, since `p` is used) + | ------- borrow later used here + +error[E0503]: cannot use `i` because it was mutably borrowed + --> $DIR/two-phase-allow-access-during-reservation.rs:45:19 + | +LL | /*1*/ let p = &mut i; // (reservation of `i` starts here) + | ------ borrow of `i` occurs here +... +LL | /*4*/ let k = i; //[nll_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503] + | ^ use of borrowed `i` +... +LL | /*5*/ *p += 1; + | ------- borrow later used here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.rs new file mode 100644 index 00000000000..5deabf93764 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-allow-access-during-reservation.rs @@ -0,0 +1,51 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +// revisions: nll_target + +// The following revisions are disabled due to missing support for two_phase_beyond_autoref +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref + +//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows + +// This is the second counter-example from Niko's blog post +// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ +// +// It is "artificial". It is meant to illustrate directly that we +// should allow an aliasing access during reservation, but *not* while +// the mutable borrow is active. +// +// The convention for the listed revisions: "lxl" means lexical +// lifetimes (which can be easier to reason about). "nll" means +// non-lexical lifetimes. "nll_target" means the initial conservative +// two-phase borrows that only applies to autoref-introduced borrows. +// "nll_beyond" means the generalization of two-phase borrows to all +// `&mut`-borrows (doing so makes it easier to write code for specific +// corner cases). + +fn main() { + /*0*/ let mut i = 0; + + /*1*/ let p = &mut i; // (reservation of `i` starts here) + + /*2*/ let j = i; // OK: `i` is only reserved here + //[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] + + /*3*/ *p += 1; // (mutable borrow of `i` starts here, since `p` is used) + + /*4*/ let k = i; //[nll_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503] + //[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] + + /*5*/ *p += 1; + + let _ = (j, k, p); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.rs new file mode 100644 index 00000000000..15700a1d61a --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.rs @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z borrowck=mir -Z two-phase-borrows + +// This is the third counter-example from Niko's blog post +// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ +// +// It shows that not all nested method calls on `self` are magically +// allowed by this change. In particular, a nested `&mut` borrow is +// still disallowed. + +fn main() { + + + let mut vec = vec![0, 1]; + vec.get({ + + vec.push(2); + //~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + + 0 + }); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.stderr new file mode 100644 index 00000000000..942a38febdd --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-cannot-nest-mut-self-calls.stderr @@ -0,0 +1,20 @@ +error[E0502]: cannot borrow `vec` as mutable because it is also borrowed as immutable + --> $DIR/two-phase-cannot-nest-mut-self-calls.rs:26:9 + | +LL | vec.get({ + | --- + | | + | _____immutable borrow occurs here + | | +LL | | +LL | | vec.push(2); + | | ^^^^^^^^^^^ mutable borrow occurs here +LL | | //~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable +LL | | +LL | | 0 +LL | | }); + | |______- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr new file mode 100644 index 00000000000..a8651c0e741 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr @@ -0,0 +1,82 @@ +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:70:11 + | +LL | f(f(10)); + | --^----- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + | borrow later used here + +error[E0382]: use of moved value: `*f` + --> $DIR/two-phase-nonrecv-autoref.rs:79:11 + | +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:86:11 + | +LL | f(f(10)); + | --^----- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + | borrow later used here + +error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined + --> $DIR/two-phase-nonrecv-autoref.rs:95:9 + | +LL | f(f(10)); + | ^ + +error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined + --> $DIR/two-phase-nonrecv-autoref.rs:95:11 + | +LL | f(f(10)); + | ^ + +error[E0382]: use of moved value: `*f` + --> $DIR/two-phase-nonrecv-autoref.rs:95:11 + | +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:139:27 + | +LL | double_access(&mut a, &a); + | ----------------------^^- + | | | | + | | | immutable borrow occurs here + | | mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:167:7 + | +LL | i[i[3]] = 4; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:173:7 + | +LL | i[i[3]] = i[4]; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | borrow later used here + +error: aborting due to 9 previous errors + +Some errors occurred: E0161, E0382, E0499, E0502. +For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.stderr new file mode 100644 index 00000000000..b64323a5cc4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.ast.stderr @@ -0,0 +1,113 @@ +error[E0503]: cannot use `*x` because it was mutably borrowed + --> $DIR/two-phase-nonrecv-autoref.rs:41:12 + | +LL | foo(x, *x); + | - ^^ use of borrowed `*x` + | | + | borrow of `*x` occurs here + +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:70:11 + | +LL | f(f(10)); + | - ^ - first borrow ends here + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + +error[E0382]: use of moved value: `*f` + --> $DIR/two-phase-nonrecv-autoref.rs:79:11 + | +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + | + = note: move occurs because `*f` has type `F`, which does not implement the `Copy` trait + +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:86:11 + | +LL | f(f(10)); + | - ^ - first borrow ends here + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + +error[E0382]: use of moved value: `*f` + --> $DIR/two-phase-nonrecv-autoref.rs:95:11 + | +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + | + = note: move occurs because `*f` has type `(dyn std::ops::FnOnce(i32) -> i32 + 'static)`, which does not implement the `Copy` trait + +error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:139:28 + | +LL | double_access(&mut a, &a); + | - ^- mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:145:9 + | +LL | a.m(a.i(10)); + | - ^ - mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:167:7 + | +LL | i[i[3]] = 4; + | - ^ - mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:173:7 + | +LL | i[i[3]] = i[4]; + | - ^ - mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:182:12 + | +LL | v.push(v.len()); + | - ^ - mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:193:9 + | +LL | s.m(s.i(10)); + | - ^ - mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error[E0502]: cannot borrow `t` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:198:9 + | +LL | t.m(t.i(10)); + | - ^ - mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error: aborting due to 12 previous errors + +Some errors occurred: E0382, E0499, E0502, E0503. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.nll.stderr new file mode 100644 index 00000000000..a8651c0e741 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -0,0 +1,82 @@ +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:70:11 + | +LL | f(f(10)); + | --^----- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + | borrow later used here + +error[E0382]: use of moved value: `*f` + --> $DIR/two-phase-nonrecv-autoref.rs:79:11 + | +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0499]: cannot borrow `*f` as mutable more than once at a time + --> $DIR/two-phase-nonrecv-autoref.rs:86:11 + | +LL | f(f(10)); + | --^----- + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + | borrow later used here + +error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined + --> $DIR/two-phase-nonrecv-autoref.rs:95:9 + | +LL | f(f(10)); + | ^ + +error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined + --> $DIR/two-phase-nonrecv-autoref.rs:95:11 + | +LL | f(f(10)); + | ^ + +error[E0382]: use of moved value: `*f` + --> $DIR/two-phase-nonrecv-autoref.rs:95:11 + | +LL | f(f(10)); + | - ^ value used here after move + | | + | value moved here + +error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:139:27 + | +LL | double_access(&mut a, &a); + | ----------------------^^- + | | | | + | | | immutable borrow occurs here + | | mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:167:7 + | +LL | i[i[3]] = 4; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable + --> $DIR/two-phase-nonrecv-autoref.rs:173:7 + | +LL | i[i[3]] = i[4]; + | --^---- + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | borrow later used here + +error: aborting due to 9 previous errors + +Some errors occurred: E0161, E0382, E0499, E0502. +For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.rs new file mode 100644 index 00000000000..30752e8ddb1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-nonrecv-autoref.rs @@ -0,0 +1,204 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast nll +//[ast]compile-flags: +//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows + +//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +// the above revision is disabled until two-phase-beyond-autoref support is better + +// This is a test checking that when we limit two-phase borrows to +// method receivers, we do not let other kinds of auto-ref to leak +// through. +// +// The g2p revision illustrates the "undesirable" behavior you would +// otherwise observe without limiting the phasing to autoref on method +// receivers (namely, in many cases demonstrated below, the error +// would not arise). + +// (If we revise the compiler or this test so that the g2p revision +// passes, turn the `rustc_attrs` feature back on and tag the `fn +// main` with `#[rustc_error]` so that this remains a valid +// compile-fail test.) +// +// #![feature(rustc_attrs)] + +use std::ops::{Index, IndexMut}; + +fn foo(x: &mut u32, y: u32) { + *x += y; +} + +fn deref_coercion(x: &mut u32) { + foo(x, *x); + //[ast]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503] + // Above error is a known limitation of AST borrowck +} + +// While adding a flag to adjustments (indicating whether they +// should support two-phase borrows, here are the cases I +// encountered: +// +// - [x] Resolving overloaded_call_traits (call, call_mut, call_once) +// - [x] deref_coercion (shown above) +// - [x] coerce_unsized e.g. `&[T; n]`, `&mut [T; n] -> &[T]`, +// `&mut [T; n] -> &mut [T]`, `&Concrete -> &Trait` +// - [x] Method Call Receivers (the case we want to support!) +// - [x] ExprKind::Index and ExprKind::Unary Deref; only need to handle coerce_index_op +// - [x] overloaded_binops + +fn overloaded_call_traits() { + // Regarding overloaded call traits, note that there is no + // scenario where adding two-phase borrows should "fix" these + // cases, because either we will resolve both invocations to + // `call_mut` (in which case the inner call requires a mutable + // borrow which will conflict with the outer reservation), or we + // will resolve both to `call` (which will just work, regardless + // of two-phase borrow support), or we will resolve both to + // `call_once` (in which case the inner call requires moving the + // receiver, invalidating the outer call). + + fn twice_ten_sm i32>(f: &mut F) { + f(f(10)); + //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time + //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time + //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time + } + fn twice_ten_si i32>(f: &mut F) { + f(f(10)); + } + fn twice_ten_so i32>(f: Box) { + f(f(10)); + //[nll]~^ ERROR use of moved value: `*f` + //[g2p]~^^ ERROR use of moved value: `*f` + //[ast]~^^^ ERROR use of moved value: `*f` + } + + fn twice_ten_om(f: &mut FnMut(i32) -> i32) { + f(f(10)); + //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time + //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time + //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time + } + fn twice_ten_oi(f: &mut Fn(i32) -> i32) { + f(f(10)); + } + fn twice_ten_oo(f: Box i32>) { + f(f(10)); + //[nll]~^ ERROR cannot move a value of type + //[nll]~^^ ERROR cannot move a value of type + //[nll]~^^^ ERROR use of moved value: `*f` + //[g2p]~^^^^ ERROR cannot move a value of type + //[g2p]~^^^^^ ERROR cannot move a value of type + //[g2p]~^^^^^^ ERROR use of moved value: `*f` + //[ast]~^^^^^^^ ERROR use of moved value: `*f` + } + + twice_ten_sm(&mut |x| x + 1); + twice_ten_si(&mut |x| x + 1); + twice_ten_so(Box::new(|x| x + 1)); + twice_ten_om(&mut |x| x + 1); + twice_ten_oi(&mut |x| x + 1); + twice_ten_oo(Box::new(|x| x + 1)); +} + +trait TwoMethods { + fn m(&mut self, x: i32) -> i32 { x + 1 } + fn i(&self, x: i32) -> i32 { x + 1 } +} + +struct T; + +impl TwoMethods for T { } + +struct S; + +impl S { + fn m(&mut self, x: i32) -> i32 { x + 1 } + fn i(&self, x: i32) -> i32 { x + 1 } +} + +impl TwoMethods for [i32; 3] { } + +fn double_access(m: &mut [X], s: &[X]) { + m[0] = s[1]; +} + +fn coerce_unsized() { + let mut a = [1, 2, 3]; + + // This is not okay. + double_access(&mut a, &a); + //[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + //[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + //[ast]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + + // But this is okay. + a.m(a.i(10)); + //[ast]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + // Above error is an expected limitation of AST borrowck +} + +struct I(i32); + +impl Index for I { + type Output = i32; + fn index(&self, _: i32) -> &i32 { + &self.0 + } +} + +impl IndexMut for I { + fn index_mut(&mut self, _: i32) -> &mut i32 { + &mut self.0 + } +} + +fn coerce_index_op() { + let mut i = I(10); + i[i[3]] = 4; + //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + + i[3] = i[4]; + + i[i[3]] = i[4]; + //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] +} + +fn main() { + + // As a reminder, this is the basic case we want to ensure we handle. + let mut v = vec![1, 2, 3]; + v.push(v.len()); + //[ast]~^ ERROR cannot borrow `v` as immutable because it is also borrowed as mutable [E0502] + // Error above is an expected limitation of AST borrowck + + // (as a rule, pnkfelix does not like to write tests with dead code.) + + deref_coercion(&mut 5); + overloaded_call_traits(); + + + let mut s = S; + s.m(s.i(10)); + //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable [E0502] + // Error above is an expected limitation of AST borrowck + + let mut t = T; + t.m(t.i(10)); + //[ast]~^ ERROR cannot borrow `t` as immutable because it is also borrowed as mutable [E0502] + // Error above is an expected limitation of AST borrowck + + coerce_unsized(); + coerce_index_op(); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.rs new file mode 100644 index 00000000000..f9326d944b8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.rs @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z borrowck=mir -Z two-phase-borrows + +// This is similar to two-phase-reservation-sharing-interference.rs +// in that it shows a reservation that overlaps with a shared borrow. +// +// Currently, this test fails with lexical lifetimes, but succeeds +// with non-lexical lifetimes. (The reason is because the activation +// of the mutable borrow ends up overlapping with a lexically-scoped +// shared borrow; but a non-lexical shared borrow can end before the +// activation occurs.) +// +// So this test is just making a note of the current behavior. + +#![feature(rustc_attrs)] + +#[rustc_error] +fn main() { //~ ERROR compilation successful + let mut v = vec![0, 1, 2]; + let shared = &v; + + v.push(shared.len()); + + assert_eq!(v, [0, 1, 2, 3]); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.stderr new file mode 100644 index 00000000000..2ac10a82f7b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference-2.stderr @@ -0,0 +1,14 @@ +error: compilation successful + --> $DIR/two-phase-reservation-sharing-interference-2.rs:27:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | let mut v = vec![0, 1, 2]; +LL | | let shared = &v; +LL | | +... | +LL | | assert_eq!(v, [0, 1, 2, 3]); +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr new file mode 100644 index 00000000000..62a548af62b --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr @@ -0,0 +1,15 @@ +error[E0502]: cannot borrow `vec` as mutable because it is also borrowed as immutable + --> $DIR/two-phase-reservation-sharing-interference.rs:46:17 + | +LL | let shared = &vec; + | ---- immutable borrow occurs here +... +LL | delay = &mut vec; + | ^^^^^^^^ mutable borrow occurs here +... +LL | shared[0]; + | ------ borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.rs new file mode 100644 index 00000000000..1e86603c19e --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-reservation-sharing-interference.rs @@ -0,0 +1,60 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +// revisions: nll_target + +// The following revisions are disabled due to missing support from two-phase beyond autorefs +//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[nll_beyond] should-fail + +//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows + +// This is a corner case that the current implementation is (probably) +// treating more conservatively than is necessary. But it also does +// not seem like a terribly important use case to cover. +// +// So this test is just making a note of the current behavior, with +// the caveat that in the future, the rules may be loosened, at which +// point this test might be thrown out. +// +// The convention for the listed revisions: "lxl" means lexical +// lifetimes (which can be easier to reason about). "nll" means +// non-lexical lifetimes. "nll_target" means the initial conservative +// two-phase borrows that only applies to autoref-introduced borrows. +// "nll_beyond" means the generalization of two-phase borrows to all +// `&mut`-borrows (doing so makes it easier to write code for specific +// corner cases). + +fn main() { + let mut vec = vec![0, 1]; + let delay: &mut Vec<_>; + { + let shared = &vec; + + // we reserve here, which could (on its own) be compatible + // with the shared borrow. But in the current implementation, + // its an error. + delay = &mut vec; + //[nll_beyond]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + //[nll_target]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + + shared[0]; + } + + // the &mut-borrow only becomes active way down here. + // + // (At least in theory; part of the reason this test fails is that + // the constructed MIR throws in extra &mut reborrows which + // flummoxes our attmpt to delay the activation point here.) + delay.push(2); +} + diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.nll.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.nll.stderr new file mode 100644 index 00000000000..26a6271bbde --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.nll.stderr @@ -0,0 +1,20 @@ +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/two-phase-sneaky.rs:22:9 + | +LL | v[0].push_str({ + | - + | | + | _____first mutable borrow occurs here + | | +LL | | +LL | | v.push(format!("foo")); + | | ^ second mutable borrow occurs here +LL | | //~^ ERROR cannot borrow `v` as mutable more than once at a time [E0499] +LL | | +LL | | "World!" +LL | | }); + | |______- borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.rs b/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.rs new file mode 100644 index 00000000000..eec4b470d75 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// cmpile-flags: -Z borrowck=mir -Z two-phase-borrows + +// This is the first counter-example from Niko's blog post +// smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ +// of a danger for code to crash if we just turned off the check for whether +// a mutable-borrow aliases another borrow. + +fn main() { + let mut v: Vec = vec![format!("Hello, ")]; + v[0].push_str({ + + v.push(format!("foo")); + //~^ ERROR cannot borrow `v` as mutable more than once at a time [E0499] + + "World!" + }); +} diff --git a/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.stderr b/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.stderr new file mode 100644 index 00000000000..1ab9c188482 --- /dev/null +++ b/src/test/ui/compile-fail-migration/borrowck/two-phase-sneaky.stderr @@ -0,0 +1,15 @@ +error[E0499]: cannot borrow `v` as mutable more than once at a time + --> $DIR/two-phase-sneaky.rs:22:9 + | +LL | v[0].push_str({ + | - first mutable borrow occurs here +LL | +LL | v.push(format!("foo")); + | ^ second mutable borrow occurs here +... +LL | }); + | - first borrow ends here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/bounds-lifetime.rs b/src/test/ui/compile-fail-migration/bounds-lifetime.rs new file mode 100644 index 00000000000..5bfaa6c54fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/bounds-lifetime.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +type A = for<'b, 'a: 'b> fn(); //~ ERROR lifetime bounds cannot be used in this context +type B = for<'b, 'a: 'b,> fn(); //~ ERROR lifetime bounds cannot be used in this context +type C = for<'b, 'a: 'b +> fn(); //~ ERROR lifetime bounds cannot be used in this context +type D = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context +type E = for Fn(); //~ ERROR only lifetime parameters can be used in this context + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/bounds-lifetime.stderr b/src/test/ui/compile-fail-migration/bounds-lifetime.stderr new file mode 100644 index 00000000000..cbd140c13be --- /dev/null +++ b/src/test/ui/compile-fail-migration/bounds-lifetime.stderr @@ -0,0 +1,32 @@ +error: lifetime bounds cannot be used in this context + --> $DIR/bounds-lifetime.rs:11:22 + | +LL | type A = for<'b, 'a: 'b> fn(); //~ ERROR lifetime bounds cannot be used in this context + | ^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/bounds-lifetime.rs:12:22 + | +LL | type B = for<'b, 'a: 'b,> fn(); //~ ERROR lifetime bounds cannot be used in this context + | ^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/bounds-lifetime.rs:13:22 + | +LL | type C = for<'b, 'a: 'b +> fn(); //~ ERROR lifetime bounds cannot be used in this context + | ^^ + +error: only lifetime parameters can be used in this context + --> $DIR/bounds-lifetime.rs:14:18 + | +LL | type D = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context + | ^ + +error: only lifetime parameters can be used in this context + --> $DIR/bounds-lifetime.rs:15:14 + | +LL | type E = for Fn(); //~ ERROR only lifetime parameters can be used in this context + | ^ + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/compile-fail-migration/break-outside-loop.rs b/src/test/ui/compile-fail-migration/break-outside-loop.rs new file mode 100644 index 00000000000..1f257b8a5cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/break-outside-loop.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + t: String +} + +fn cond() -> bool { true } + +fn foo(_: F) where F: FnOnce() {} + +fn main() { + let pth = break; //~ ERROR: `break` outside of loop + if cond() { continue } //~ ERROR: `continue` outside of loop + + while cond() { + if cond() { break } + if cond() { continue } + foo(|| { + if cond() { break } //~ ERROR: `break` inside of a closure + if cond() { continue } //~ ERROR: `continue` inside of a closure + }) + } + + let rs: Foo = Foo{t: pth}; + + let unconstrained = break; //~ ERROR: `break` outside of loop +} diff --git a/src/test/ui/compile-fail-migration/break-outside-loop.stderr b/src/test/ui/compile-fail-migration/break-outside-loop.stderr new file mode 100644 index 00000000000..820272d7e80 --- /dev/null +++ b/src/test/ui/compile-fail-migration/break-outside-loop.stderr @@ -0,0 +1,34 @@ +error[E0268]: `break` outside of loop + --> $DIR/break-outside-loop.rs:20:15 + | +LL | let pth = break; //~ ERROR: `break` outside of loop + | ^^^^^ cannot break outside of a loop + +error[E0268]: `continue` outside of loop + --> $DIR/break-outside-loop.rs:21:17 + | +LL | if cond() { continue } //~ ERROR: `continue` outside of loop + | ^^^^^^^^ cannot break outside of a loop + +error[E0267]: `break` inside of a closure + --> $DIR/break-outside-loop.rs:27:25 + | +LL | if cond() { break } //~ ERROR: `break` inside of a closure + | ^^^^^ cannot break inside of a closure + +error[E0267]: `continue` inside of a closure + --> $DIR/break-outside-loop.rs:28:25 + | +LL | if cond() { continue } //~ ERROR: `continue` inside of a closure + | ^^^^^^^^ cannot break inside of a closure + +error[E0268]: `break` outside of loop + --> $DIR/break-outside-loop.rs:34:25 + | +LL | let unconstrained = break; //~ ERROR: `break` outside of loop + | ^^^^^ cannot break outside of a loop + +error: aborting due to 5 previous errors + +Some errors occurred: E0267, E0268. +For more information about an error, try `rustc --explain E0267`. diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.rs b/src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.rs new file mode 100644 index 00000000000..3f7f2adabdf --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.rs @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for traits that inherit from multiple builtin kinds at once, +// testing that all such kinds must be present on implementing types. + +trait Foo : Send+Sync { } + +impl Foo for (T,) { } +//~^ ERROR `T` cannot be sent between threads safely [E0277] + +impl Foo for (T,T) { } +//~^ ERROR `T` cannot be shared between threads safely [E0277] + +impl Foo for (T,T,T) { } // (ok) + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.stderr b/src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.stderr new file mode 100644 index 00000000000..a462fcf4de4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-double-superkind.stderr @@ -0,0 +1,23 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/builtin-superkinds-double-superkind.rs:16:24 + | +LL | impl Foo for (T,) { } + | ^^^ `T` cannot be sent between threads safely + | + = help: within `(T,)`, the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + = note: required because it appears within the type `(T,)` + +error[E0277]: `T` cannot be shared between threads safely + --> $DIR/builtin-superkinds-double-superkind.rs:19:16 + | +LL | impl Foo for (T,T) { } + | ^^^ `T` cannot be shared between threads safely + | + = help: within `(T, T)`, the trait `std::marker::Sync` is not implemented for `T` + = help: consider adding a `where T: std::marker::Sync` bound + = note: required because it appears within the type `(T, T)` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.rs b/src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.rs new file mode 100644 index 00000000000..88b5a3fbb55 --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.rs @@ -0,0 +1,27 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// aux-build:trait_superkinds_in_metadata.rs + +// Test for traits inheriting from the builtin kinds cross-crate. +// Mostly tests correctness of metadata. + +extern crate trait_superkinds_in_metadata; +use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; + +struct X(T); + +impl RequiresShare for X { } + +impl RequiresRequiresShareAndSend for X { } +//~^ ERROR `T` cannot be sent between threads safely [E0277] + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.stderr b/src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.stderr new file mode 100644 index 00000000000..dcc7e3cd350 --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-in-metadata.stderr @@ -0,0 +1,13 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/builtin-superkinds-in-metadata.rs:24:23 + | +LL | impl RequiresRequiresShareAndSend for X { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely + | + = help: within `X`, the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + = note: required because it appears within the type `X` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-self-type.rs b/src/test/ui/compile-fail-migration/builtin-superkinds-self-type.rs new file mode 100644 index 00000000000..3065ecfaa30 --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-self-type.rs @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests (negatively) the ability for the Self type in default methods +// to use capabilities granted by builtin kinds as supertraits. + +use std::sync::mpsc::{channel, Sender}; + +trait Foo : Sized+Sync+'static { + fn foo(self, mut chan: Sender) { } +} + +impl Foo for T { } +//~^ ERROR the parameter type `T` may not live long enough + +fn main() { + let (tx, rx) = channel(); + 1193182.foo(tx); + assert_eq!(rx.recv(), 1193182); +} diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-self-type.stderr b/src/test/ui/compile-fail-migration/builtin-superkinds-self-type.stderr new file mode 100644 index 00000000000..f96393d4b85 --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-self-type.stderr @@ -0,0 +1,17 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/builtin-superkinds-self-type.rs:20:16 + | +LL | impl Foo for T { } + | -- ^^^ + | | + | help: consider adding an explicit lifetime bound `T: 'static`... + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/builtin-superkinds-self-type.rs:20:16 + | +LL | impl Foo for T { } + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-simple.rs b/src/test/ui/compile-fail-migration/builtin-superkinds-simple.rs new file mode 100644 index 00000000000..22dc9598d29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-simple.rs @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Basic test for traits inheriting from the builtin kinds, checking +// the type contents of the implementing type (that's not a typaram). + +trait Foo : Send { } + +impl Foo for std::rc::Rc { } +//~^ ERROR `std::rc::Rc` cannot be sent between threads safely + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-simple.stderr b/src/test/ui/compile-fail-migration/builtin-superkinds-simple.stderr new file mode 100644 index 00000000000..043953e7a2b --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-simple.stderr @@ -0,0 +1,11 @@ +error[E0277]: `std::rc::Rc` cannot be sent between threads safely + --> $DIR/builtin-superkinds-simple.rs:16:6 + | +LL | impl Foo for std::rc::Rc { } + | ^^^ `std::rc::Rc` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `std::rc::Rc` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.rs b/src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.rs new file mode 100644 index 00000000000..e0b2043c110 --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.rs @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Basic test for traits inheriting from the builtin kinds. + +trait Foo : Send { } + +impl Foo for T { } +//~^ ERROR `T` cannot be sent between threads safely + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.stderr b/src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.stderr new file mode 100644 index 00000000000..00bad2e80ef --- /dev/null +++ b/src/test/ui/compile-fail-migration/builtin-superkinds-typaram-not-send.stderr @@ -0,0 +1,12 @@ +error[E0277]: `T` cannot be sent between threads safely + --> $DIR/builtin-superkinds-typaram-not-send.rs:15:24 + | +LL | impl Foo for T { } + | ^^^ `T` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `T` + = help: consider adding a `where T: std::marker::Send` bound + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/by-move-pattern-binding.nll.stderr b/src/test/ui/compile-fail-migration/by-move-pattern-binding.nll.stderr new file mode 100644 index 00000000000..4ba9b3aeb5d --- /dev/null +++ b/src/test/ui/compile-fail-migration/by-move-pattern-binding.nll.stderr @@ -0,0 +1,15 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/by-move-pattern-binding.rs:24:11 + | +LL | match &s.x { + | ^^^^ cannot move out of borrowed content +LL | &E::Foo => {} +LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move + | ---------- + | | + | data moved here + | help: to prevent move, use ref or ref mut: `ref identifier` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/by-move-pattern-binding.rs b/src/test/ui/compile-fail-migration/by-move-pattern-binding.rs new file mode 100644 index 00000000000..a49256d1bfc --- /dev/null +++ b/src/test/ui/compile-fail-migration/by-move-pattern-binding.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum E { + Foo, + Bar(String) +} + +struct S { + x: E +} + +fn f(x: String) {} + +fn main() { + let s = S { x: E::Bar("hello".to_string()) }; + match &s.x { + &E::Foo => {} + &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move + }; + match &s.x { + &E::Foo => {} + &E::Bar(ref identifier) => println!("{}", *identifier) + }; +} diff --git a/src/test/ui/compile-fail-migration/by-move-pattern-binding.stderr b/src/test/ui/compile-fail-migration/by-move-pattern-binding.stderr new file mode 100644 index 00000000000..a20de4ba42a --- /dev/null +++ b/src/test/ui/compile-fail-migration/by-move-pattern-binding.stderr @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/by-move-pattern-binding.rs:26:9 + | +LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move + | ^^^^^^^^----------^ + | | | + | | hint: to prevent move, use `ref identifier` or `ref mut identifier` + | cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.rs b/src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.rs new file mode 100644 index 00000000000..583befed1e8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we can't pass other types for ! + +#![feature(never_type)] + +fn foo(x: !) -> ! { + x +} + +fn main() { + foo("wow"); //~ ERROR mismatched types +} + diff --git a/src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.stderr b/src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.stderr new file mode 100644 index 00000000000..84ed8d15a42 --- /dev/null +++ b/src/test/ui/compile-fail-migration/call-fn-never-arg-wrong-type.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/call-fn-never-arg-wrong-type.rs:20:9 + | +LL | foo("wow"); //~ ERROR mismatched types + | ^^^^^ expected !, found reference + | + = note: expected type `!` + found type `&'static str` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/can-begin-expr-check.rs b/src/test/ui/compile-fail-migration/can-begin-expr-check.rs new file mode 100644 index 00000000000..68f219c6ed9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/can-begin-expr-check.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + + return; + return (); + return as (); + return return as (); + return return return; + + return if true { + () + } else { + () + }; + + loop { + return break as (); + } + + return enum; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `enum` +} diff --git a/src/test/ui/compile-fail-migration/can-begin-expr-check.stderr b/src/test/ui/compile-fail-migration/can-begin-expr-check.stderr new file mode 100644 index 00000000000..ddcb69c5ee3 --- /dev/null +++ b/src/test/ui/compile-fail-migration/can-begin-expr-check.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `enum` + --> $DIR/can-begin-expr-check.rs:29:12 + | +LL | return enum; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `enum` + | ^^^^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.nll.stderr b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.nll.stderr new file mode 100644 index 00000000000..a7ffc06872c --- /dev/null +++ b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.nll.stderr @@ -0,0 +1,20 @@ +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/cannot-mutate-captured-non-mut-var.rs:23:25 + | +LL | let x = 1; + | - help: consider changing this to be mutable: `mut x` +LL | to_fn_once(move|| { x = 2; }); + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable + --> $DIR/cannot-mutate-captured-non-mut-var.rs:28:25 + | +LL | let s = std::io::stdin(); + | - help: consider changing this to be mutable: `mut s` +LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); + | ^ cannot borrow as mutable + +error: aborting due to 2 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.stderr b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.stderr new file mode 100644 index 00000000000..02d57ca48f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.ast.stderr @@ -0,0 +1,16 @@ +error[E0594]: cannot assign to immutable captured outer variable in an `FnOnce` closure `x` + --> $DIR/cannot-mutate-captured-non-mut-var.rs:23:25 + | +LL | to_fn_once(move|| { x = 2; }); + | ^^^^^ + +error[E0596]: cannot borrow immutable captured outer variable in an `FnOnce` closure `s` as mutable + --> $DIR/cannot-mutate-captured-non-mut-var.rs:28:25 + | +LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); + | ^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.mir.stderr b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.mir.stderr new file mode 100644 index 00000000000..a7ffc06872c --- /dev/null +++ b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.mir.stderr @@ -0,0 +1,20 @@ +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/cannot-mutate-captured-non-mut-var.rs:23:25 + | +LL | let x = 1; + | - help: consider changing this to be mutable: `mut x` +LL | to_fn_once(move|| { x = 2; }); + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable + --> $DIR/cannot-mutate-captured-non-mut-var.rs:28:25 + | +LL | let s = std::io::stdin(); + | - help: consider changing this to be mutable: `mut s` +LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); + | ^ cannot borrow as mutable + +error: aborting due to 2 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff --git a/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.rs b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.rs new file mode 100644 index 00000000000..6bd52f00788 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cannot-mutate-captured-non-mut-var.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +#![feature(unboxed_closures)] + +use std::io::Read; + +fn to_fn_once>(f: F) -> F { f } + +fn main() { + let x = 1; + to_fn_once(move|| { x = 2; }); + //[ast]~^ ERROR: cannot assign to immutable captured outer variable + //[mir]~^^ ERROR: cannot assign to `x`, as it is not declared as mutable + + let s = std::io::stdin(); + to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); + //[ast]~^ ERROR: cannot borrow immutable captured outer variable + //[mir]~^^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable +} diff --git a/src/test/ui/compile-fail-migration/capture1.rs b/src/test/ui/compile-fail-migration/capture1.rs new file mode 100644 index 00000000000..984385f4cc0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/capture1.rs @@ -0,0 +1,17 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// error-pattern: can't capture dynamic environment in a fn item + +fn main() { + let bar: isize = 5; + fn foo() -> isize { return bar; } +} diff --git a/src/test/ui/compile-fail-migration/capture1.stderr b/src/test/ui/compile-fail-migration/capture1.stderr new file mode 100644 index 00000000000..82eb1b64cfc --- /dev/null +++ b/src/test/ui/compile-fail-migration/capture1.stderr @@ -0,0 +1,11 @@ +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/capture1.rs:16:32 + | +LL | fn foo() -> isize { return bar; } + | ^^^ + | + = help: use the `|| { ... }` closure form instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0434`. diff --git a/src/test/ui/compile-fail-migration/cast-from-nil.rs b/src/test/ui/compile-fail-migration/cast-from-nil.rs new file mode 100644 index 00000000000..ab22d352480 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-from-nil.rs @@ -0,0 +1,12 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: non-primitive cast: `()` as `u32` +fn main() { let u = (assert!(true) as u32); } diff --git a/src/test/ui/compile-fail-migration/cast-from-nil.stderr b/src/test/ui/compile-fail-migration/cast-from-nil.stderr new file mode 100644 index 00000000000..4400007f93d --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-from-nil.stderr @@ -0,0 +1,11 @@ +error[E0605]: non-primitive cast: `()` as `u32` + --> $DIR/cast-from-nil.rs:12:21 + | +LL | fn main() { let u = (assert!(true) as u32); } + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/cast-ptr-to-int-const.rs b/src/test/ui/compile-fail-migration/cast-ptr-to-int-const.rs new file mode 100644 index 00000000000..8764cb72b8c --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-ptr-to-int-const.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// gate-test-const_raw_ptr_to_usize_cast + +fn main() { + const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable + const Y: u32 = 0; + const Z: u32 = &Y as *const u32 as u32; //~ ERROR is unstable +} diff --git a/src/test/ui/compile-fail-migration/cast-ptr-to-int-const.stderr b/src/test/ui/compile-fail-migration/cast-ptr-to-int-const.stderr new file mode 100644 index 00000000000..7c3b4e42138 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-ptr-to-int-const.stderr @@ -0,0 +1,19 @@ +error[E0658]: casting pointers to integers in constants is unstable (see issue #51910) + --> $DIR/cast-ptr-to-int-const.rs:14:20 + | +LL | const X: u32 = main as u32; //~ ERROR casting pointers to integers in constants is unstable + | ^^^^^^^^^^^ + | + = help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable + +error[E0658]: casting pointers to integers in constants is unstable (see issue #51910) + --> $DIR/cast-ptr-to-int-const.rs:16:20 + | +LL | const Z: u32 = &Y as *const u32 as u32; //~ ERROR is unstable + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/cast-to-bare-fn.rs b/src/test/ui/compile-fail-migration/cast-to-bare-fn.rs new file mode 100644 index 00000000000..d5a998c6e4b --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-to-bare-fn.rs @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(_x: isize) { } + +fn main() { + let v: u64 = 5; + let x = foo as extern "C" fn() -> isize; + //~^ ERROR non-primitive cast + let y = v as extern "Rust" fn(isize) -> (isize, isize); + //~^ ERROR non-primitive cast + y(x()); +} diff --git a/src/test/ui/compile-fail-migration/cast-to-bare-fn.stderr b/src/test/ui/compile-fail-migration/cast-to-bare-fn.stderr new file mode 100644 index 00000000000..ed07f37f4f1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-to-bare-fn.stderr @@ -0,0 +1,19 @@ +error[E0605]: non-primitive cast: `fn(isize) {foo}` as `extern "C" fn() -> isize` + --> $DIR/cast-to-bare-fn.rs:15:13 + | +LL | let x = foo as extern "C" fn() -> isize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error[E0605]: non-primitive cast: `u64` as `fn(isize) -> (isize, isize)` + --> $DIR/cast-to-bare-fn.rs:17:13 + | +LL | let y = v as extern "Rust" fn(isize) -> (isize, isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/cast-to-nil.rs b/src/test/ui/compile-fail-migration/cast-to-nil.rs new file mode 100644 index 00000000000..27d9e8a42b1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-to-nil.rs @@ -0,0 +1,12 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: non-primitive cast: `u32` as `()` +fn main() { let u = 0u32 as (); } diff --git a/src/test/ui/compile-fail-migration/cast-to-nil.stderr b/src/test/ui/compile-fail-migration/cast-to-nil.stderr new file mode 100644 index 00000000000..f7ee68e3d2b --- /dev/null +++ b/src/test/ui/compile-fail-migration/cast-to-nil.stderr @@ -0,0 +1,11 @@ +error[E0605]: non-primitive cast: `u32` as `()` + --> $DIR/cast-to-nil.rs:12:21 + | +LL | fn main() { let u = 0u32 as (); } + | ^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/catch-bad-lifetime.nll.stderr b/src/test/ui/compile-fail-migration/catch-bad-lifetime.nll.stderr new file mode 100644 index 00000000000..dd1595f9315 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-bad-lifetime.nll.stderr @@ -0,0 +1,39 @@ +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/catch-bad-lifetime.rs:33:13 + | +LL | let k = &mut i; + | ------ borrow of `i` occurs here +... +LL | i = 10; //~ ERROR cannot assign to `i` because it is borrowed + | ^^^^^^ assignment to borrowed `i` occurs here +LL | }; +LL | ::std::mem::drop(k); //~ ERROR use of moved value: `k` + | - borrow later used here + +error[E0382]: use of moved value: `k` + --> $DIR/catch-bad-lifetime.rs:35:26 + | +LL | Err(k) ?; + | - value moved here +... +LL | ::std::mem::drop(k); //~ ERROR use of moved value: `k` + | ^ value used here after move + | + = note: move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait + +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/catch-bad-lifetime.rs:36:9 + | +LL | let k = &mut i; + | ------ borrow of `i` occurs here +... +LL | i = 40; //~ ERROR cannot assign to `i` because it is borrowed + | ^^^^^^ assignment to borrowed `i` occurs here +LL | +LL | let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") }; + | - borrow later used here + +error: aborting due to 3 previous errors + +Some errors occurred: E0382, E0506. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/catch-bad-lifetime.rs b/src/test/ui/compile-fail-migration/catch-bad-lifetime.rs new file mode 100644 index 00000000000..f332ffd4494 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-bad-lifetime.rs @@ -0,0 +1,42 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(catch_expr)] + +// This test checks that borrows made and returned inside catch blocks are properly constrained +pub fn main() { + { + // Test that borrows returned from a catch block must be valid for the lifetime of the + // result variable + let _result: Result<(), &str> = do catch { + let my_string = String::from(""); + let my_str: & str = & my_string; + //~^ ERROR `my_string` does not live long enough + Err(my_str) ?; + Err("") ?; + }; + } + + { + // Test that borrows returned from catch blocks freeze their referent + let mut i = 5; + let k = &mut i; + let mut j: Result<(), &mut i32> = do catch { + Err(k) ?; + i = 10; //~ ERROR cannot assign to `i` because it is borrowed + }; + ::std::mem::drop(k); //~ ERROR use of moved value: `k` + i = 40; //~ ERROR cannot assign to `i` because it is borrowed + + let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") }; + *i_ptr = 50; + } +} + diff --git a/src/test/ui/compile-fail-migration/catch-bad-lifetime.stderr b/src/test/ui/compile-fail-migration/catch-bad-lifetime.stderr new file mode 100644 index 00000000000..2ea54d1fb24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-bad-lifetime.stderr @@ -0,0 +1,44 @@ +error[E0597]: `my_string` does not live long enough + --> $DIR/catch-bad-lifetime.rs:20:35 + | +LL | let my_str: & str = & my_string; + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | }; + | - `my_string` dropped here while still borrowed +LL | } + | - borrowed value needs to live until here + +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/catch-bad-lifetime.rs:33:13 + | +LL | let k = &mut i; + | - borrow of `i` occurs here +... +LL | i = 10; //~ ERROR cannot assign to `i` because it is borrowed + | ^^^^^^ assignment to borrowed `i` occurs here + +error[E0382]: use of moved value: `k` + --> $DIR/catch-bad-lifetime.rs:35:26 + | +LL | Err(k) ?; + | - value moved here +... +LL | ::std::mem::drop(k); //~ ERROR use of moved value: `k` + | ^ value used here after move + | + = note: move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait + +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/catch-bad-lifetime.rs:36:9 + | +LL | let k = &mut i; + | - borrow of `i` occurs here +... +LL | i = 40; //~ ERROR cannot assign to `i` because it is borrowed + | ^^^^^^ assignment to borrowed `i` occurs here + +error: aborting due to 4 previous errors + +Some errors occurred: E0382, E0506, E0597. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/catch-bad-type.rs b/src/test/ui/compile-fail-migration/catch-bad-type.rs new file mode 100644 index 00000000000..b369847699b --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-bad-type.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(catch_expr)] + +pub fn main() { + let res: Result = do catch { + Err("")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied + 5 + }; + + let res: Result = do catch { + "" //~ ERROR type mismatch + }; + + let res: Result = do catch { }; //~ ERROR type mismatch + + let res: () = do catch { }; //~ the trait bound `(): std::ops::Try` is not satisfied + + let res: i32 = do catch { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied +} diff --git a/src/test/ui/compile-fail-migration/catch-bad-type.stderr b/src/test/ui/compile-fail-migration/catch-bad-type.stderr new file mode 100644 index 00000000000..f7405e5e5c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-bad-type.stderr @@ -0,0 +1,52 @@ +error[E0277]: the trait bound `i32: std::convert::From<&str>` is not satisfied + --> $DIR/catch-bad-type.rs:15:9 + | +LL | Err("")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied + | ^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `i32` + | + = help: the following implementations were found: + > + > + > + > + > + = note: required by `std::convert::From::from` + +error[E0271]: type mismatch resolving ` as std::ops::Try>::Ok == &str` + --> $DIR/catch-bad-type.rs:20:9 + | +LL | "" //~ ERROR type mismatch + | ^^ expected i32, found &str + | + = note: expected type `i32` + found type `&str` + +error[E0271]: type mismatch resolving ` as std::ops::Try>::Ok == ()` + --> $DIR/catch-bad-type.rs:23:44 + | +LL | let res: Result = do catch { }; //~ ERROR type mismatch + | ^ expected i32, found () + | + = note: expected type `i32` + found type `()` + +error[E0277]: the trait bound `(): std::ops::Try` is not satisfied + --> $DIR/catch-bad-type.rs:25:28 + | +LL | let res: () = do catch { }; //~ the trait bound `(): std::ops::Try` is not satisfied + | ^^^ the trait `std::ops::Try` is not implemented for `()` + | + = note: required by `std::ops::Try::from_ok` + +error[E0277]: the trait bound `i32: std::ops::Try` is not satisfied + --> $DIR/catch-bad-type.rs:27:29 + | +LL | let res: i32 = do catch { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied + | ^^^^^ the trait `std::ops::Try` is not implemented for `i32` + | + = note: required by `std::ops::Try::from_ok` + +error: aborting due to 5 previous errors + +Some errors occurred: E0271, E0277. +For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/compile-fail-migration/catch-in-match.rs b/src/test/ui/compile-fail-migration/catch-in-match.rs new file mode 100644 index 00000000000..9f9968e8124 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-in-match.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(catch_expr)] + +fn main() { + match do catch { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `do` +} diff --git a/src/test/ui/compile-fail-migration/catch-in-match.stderr b/src/test/ui/compile-fail-migration/catch-in-match.stderr new file mode 100644 index 00000000000..1542989cc35 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-in-match.stderr @@ -0,0 +1,8 @@ +error: expected expression, found reserved keyword `do` + --> $DIR/catch-in-match.rs:14:11 + | +LL | match do catch { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `do` + | ^^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/catch-in-while.rs b/src/test/ui/compile-fail-migration/catch-in-while.rs new file mode 100644 index 00000000000..cb8613ee60b --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-in-while.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(catch_expr)] + +fn main() { + while do catch { false } {} //~ ERROR expected expression, found reserved keyword `do` +} diff --git a/src/test/ui/compile-fail-migration/catch-in-while.stderr b/src/test/ui/compile-fail-migration/catch-in-while.stderr new file mode 100644 index 00000000000..9316bbcd4bc --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-in-while.stderr @@ -0,0 +1,8 @@ +error: expected expression, found reserved keyword `do` + --> $DIR/catch-in-while.rs:14:11 + | +LL | while do catch { false } {} //~ ERROR expected expression, found reserved keyword `do` + | ^^ expected expression + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.nll.stderr b/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.nll.stderr new file mode 100644 index 00000000000..157793160ce --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.nll.stderr @@ -0,0 +1,14 @@ +error[E0382]: borrow of moved value: `x` + --> $DIR/catch-maybe-bad-lifetime.rs:33:24 + | +LL | ::std::mem::drop(x); + | - value moved here +LL | }; +LL | println!("{}", x); //~ ERROR use of moved value: `x` + | ^ value borrowed here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.rs b/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.rs new file mode 100644 index 00000000000..faefb5ef18a --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.rs @@ -0,0 +1,49 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(catch_expr)] + +// This test checks that borrows made and returned inside catch blocks are properly constrained +pub fn main() { + { + // Test that a borrow which *might* be returned still freezes its referent + let mut i = 222; + let x: Result<&i32, ()> = do catch { + Err(())?; + &i + }; + x.ok().cloned(); + i = 0; //~ ERROR cannot assign to `i` because it is borrowed + let _ = i; + } + + { + let x = String::new(); + let _y: Result<(), ()> = do catch { + Err(())?; + ::std::mem::drop(x); + }; + println!("{}", x); //~ ERROR use of moved value: `x` + } + + { + // Test that a borrow which *might* be assigned to an outer variable still freezes + // its referent + let mut i = 222; + let j; + let x: Result<(), ()> = do catch { + Err(())?; + j = &i; + }; + i = 0; //~ ERROR cannot assign to `i` because it is borrowed + let _ = i; + } +} + diff --git a/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.stderr b/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.stderr new file mode 100644 index 00000000000..21fe1049f43 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-maybe-bad-lifetime.stderr @@ -0,0 +1,33 @@ +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/catch-maybe-bad-lifetime.rs:23:9 + | +LL | &i + | - borrow of `i` occurs here +... +LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed + | ^^^^^ assignment to borrowed `i` occurs here + +error[E0382]: use of moved value: `x` + --> $DIR/catch-maybe-bad-lifetime.rs:33:24 + | +LL | ::std::mem::drop(x); + | - value moved here +LL | }; +LL | println!("{}", x); //~ ERROR use of moved value: `x` + | ^ value used here after move + | + = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + +error[E0506]: cannot assign to `i` because it is borrowed + --> $DIR/catch-maybe-bad-lifetime.rs:45:9 + | +LL | j = &i; + | - borrow of `i` occurs here +LL | }; +LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed + | ^^^^^ assignment to borrowed `i` occurs here + +error: aborting due to 3 previous errors + +Some errors occurred: E0382, E0506. +For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/compile-fail-migration/catch-opt-init.nll.stderr b/src/test/ui/compile-fail-migration/catch-opt-init.nll.stderr new file mode 100644 index 00000000000..ea8c8ebdcb7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-opt-init.nll.stderr @@ -0,0 +1,11 @@ +error[E0381]: borrow of possibly uninitialized variable: `cfg_res` + --> $DIR/catch-opt-init.rs:23:5 + | +LL | assert_eq!(cfg_res, 5); //~ ERROR use of possibly uninitialized variable + | ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `cfg_res` + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/catch-opt-init.rs b/src/test/ui/compile-fail-migration/catch-opt-init.rs new file mode 100644 index 00000000000..0c41102e3be --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-opt-init.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(catch_expr)] + +fn use_val(_x: T) {} + +pub fn main() { + let cfg_res; + let _: Result<(), ()> = do catch { + Err(())?; + cfg_res = 5; + Ok::<(), ()>(())?; + use_val(cfg_res); + }; + assert_eq!(cfg_res, 5); //~ ERROR use of possibly uninitialized variable +} + diff --git a/src/test/ui/compile-fail-migration/catch-opt-init.stderr b/src/test/ui/compile-fail-migration/catch-opt-init.stderr new file mode 100644 index 00000000000..6a14ba17f9e --- /dev/null +++ b/src/test/ui/compile-fail-migration/catch-opt-init.stderr @@ -0,0 +1,9 @@ +error[E0381]: use of possibly uninitialized variable: `cfg_res` + --> $DIR/catch-opt-init.rs:23:16 + | +LL | assert_eq!(cfg_res, 5); //~ ERROR use of possibly uninitialized variable + | ^^^^^^^ use of possibly uninitialized `cfg_res` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.rs b/src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.rs new file mode 100644 index 00000000000..0a06e01cab0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: crate `cdylib_dep` required to be available in rlib format, but was not found +// aux-build:cdylib-dep.rs +// ignore-musl +// ignore-cloudabi +// ignore-emscripten + +#![crate_type = "cdylib"] + +extern crate cdylib_dep; diff --git a/src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.stderr b/src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.stderr new file mode 100644 index 00000000000..a1dc8e985da --- /dev/null +++ b/src/test/ui/compile-fail-migration/cdylib-deps-must-be-static.stderr @@ -0,0 +1,4 @@ +error: crate `cdylib_dep` required to be available in rlib format, but was not found in this form + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/cfg-arg-invalid.rs b/src/test/ui/compile-fail-migration/cfg-arg-invalid.rs new file mode 100644 index 00000000000..404630399c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-arg-invalid.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --cfg a{b} +// error-pattern: invalid --cfg argument: a{b} +fn main() {} diff --git a/src/test/ui/compile-fail-migration/cfg-attr-cfg-2.rs b/src/test/ui/compile-fail-migration/cfg-attr-cfg-2.rs new file mode 100644 index 00000000000..58a62d45ea5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-cfg-2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// error-pattern: `main` function not found +// compile-flags: --cfg foo + +// main is conditionally compiled, but the conditional compilation +// is conditional too! + +#[cfg_attr(foo, cfg(bar))] +fn main() { } diff --git a/src/test/ui/compile-fail-migration/cfg-attr-cfg-2.stderr b/src/test/ui/compile-fail-migration/cfg-attr-cfg-2.stderr new file mode 100644 index 00000000000..db3c7acff15 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-cfg-2.stderr @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `cfg_attr_cfg_2` + | + = note: consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/cfg-attr-crate-2.rs b/src/test/ui/compile-fail-migration/cfg-attr-crate-2.rs new file mode 100644 index 00000000000..a79c7663861 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-crate-2.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// compile-flags: --cfg broken + +// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 + +#![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/cfg-attr-crate-2.stderr b/src/test/ui/compile-fail-migration/cfg-attr-crate-2.stderr new file mode 100644 index 00000000000..7b66c8f5e40 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-crate-2.stderr @@ -0,0 +1,11 @@ +error[E0658]: no_core is experimental (see issue #29639) + --> $DIR/cfg-attr-crate-2.rs:15:21 + | +LL | #![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental + | ^^^^^^^^ + | + = help: add #![feature(no_core)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.rs b/src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.rs new file mode 100644 index 00000000000..09fe6cec49c --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(foo(bar))] //~ ERROR invalid predicate `foo` +fn main() {} diff --git a/src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.stderr b/src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.stderr new file mode 100644 index 00000000000..5a89f9766d1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-invalid-predicate.stderr @@ -0,0 +1,9 @@ +error[E0537]: invalid predicate `foo` + --> $DIR/cfg-attr-invalid-predicate.rs:11:7 + | +LL | #[cfg(foo(bar))] //~ ERROR invalid predicate `foo` + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0537`. diff --git a/src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.rs b/src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.rs new file mode 100644 index 00000000000..afcb896b43c --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + () => { + #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown + fn foo() {} + } +} + +foo!(); + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.stderr b/src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.stderr new file mode 100644 index 00000000000..33fe52366db --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-attr-unknown-attribute-macro-expansion.stderr @@ -0,0 +1,14 @@ +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:13:27 + | +LL | #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown + | ^^^^^^^^ +... +LL | foo!(); + | ------- in this macro invocation + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/compile-fail-migration/cfg-empty-codemap.rs b/src/test/ui/compile-fail-migration/cfg-empty-codemap.rs new file mode 100644 index 00000000000..8868a5a9549 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-empty-codemap.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that empty codemaps don't ICE (#23301) + +// compile-flags: --cfg "" + +// error-pattern: expected identifier, found + +pub fn main() { +} diff --git a/src/test/ui/compile-fail-migration/cfg-in-crate-1.rs b/src/test/ui/compile-fail-migration/cfg-in-crate-1.rs new file mode 100644 index 00000000000..bbccf2bcd0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-in-crate-1.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: `main` function not found + +#![cfg(bar)] diff --git a/src/test/ui/compile-fail-migration/cfg-in-crate-1.stderr b/src/test/ui/compile-fail-migration/cfg-in-crate-1.stderr new file mode 100644 index 00000000000..c6d42c732c9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-in-crate-1.stderr @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `cfg_in_crate_1` + | + = note: consider adding a `main` function to `$DIR/cfg-in-crate-1.rs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/compile-fail-migration/cfg-non-opt-expr.rs b/src/test/ui/compile-fail-migration/cfg-non-opt-expr.rs new file mode 100644 index 00000000000..a4b24fa8b4b --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-non-opt-expr.rs @@ -0,0 +1,22 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(stmt_expr_attributes)] + +fn main() { + let _ = #[cfg(unset)] (); + //~^ ERROR removing an expression is not supported in this position + let _ = 1 + 2 + #[cfg(unset)] 3; + //~^ ERROR removing an expression is not supported in this position + let _ = [1, 2, 3][#[cfg(unset)] 1]; + //~^ ERROR removing an expression is not supported in this position + let _ = #[test] (); + //~^ ERROR removing an expression is not supported in this position +} diff --git a/src/test/ui/compile-fail-migration/cfg-non-opt-expr.stderr b/src/test/ui/compile-fail-migration/cfg-non-opt-expr.stderr new file mode 100644 index 00000000000..0511c575546 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg-non-opt-expr.stderr @@ -0,0 +1,26 @@ +error: removing an expression is not supported in this position + --> $DIR/cfg-non-opt-expr.rs:14:13 + | +LL | let _ = #[cfg(unset)] (); + | ^^^^^^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/cfg-non-opt-expr.rs:16:21 + | +LL | let _ = 1 + 2 + #[cfg(unset)] 3; + | ^^^^^^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/cfg-non-opt-expr.rs:18:23 + | +LL | let _ = [1, 2, 3][#[cfg(unset)] 1]; + | ^^^^^^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/cfg-non-opt-expr.rs:20:13 + | +LL | let _ = #[test] (); + | ^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/compile-fail-migration/cfg_attr_path.rs b/src/test/ui/compile-fail-migration/cfg_attr_path.rs new file mode 100644 index 00000000000..7d799850a65 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg_attr_path.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![deny(unused_attributes)] // c.f #35584 + +mod auxiliary { + #[cfg_attr(any(), path = "nonexistent_file.rs")] pub mod namespaced_enums; + #[cfg_attr(all(), path = "namespaced_enums.rs")] pub mod nonexistent_file; +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful + let _ = auxiliary::namespaced_enums::Foo::A; + let _ = auxiliary::nonexistent_file::Foo::A; +} diff --git a/src/test/ui/compile-fail-migration/cfg_attr_path.stderr b/src/test/ui/compile-fail-migration/cfg_attr_path.stderr new file mode 100644 index 00000000000..67e59d054d5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cfg_attr_path.stderr @@ -0,0 +1,11 @@ +error: compilation successful + --> $DIR/cfg_attr_path.rs:21:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | let _ = auxiliary::namespaced_enums::Foo::A; +LL | | let _ = auxiliary::nonexistent_file::Foo::A; +LL | | } + | |_^ + +error: aborting due to previous error + diff --git a/src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.rs b/src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.rs new file mode 100644 index 00000000000..1804b9e04c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks that immutable static items can't have mutable slices + +static TEST: &'static mut [isize] = &mut []; +//~^ ERROR references in statics may only refer to immutable values + +pub fn main() { } diff --git a/src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.stderr b/src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.stderr new file mode 100644 index 00000000000..b0a7cd1221b --- /dev/null +++ b/src/test/ui/compile-fail-migration/check-static-immutable-mut-slices.stderr @@ -0,0 +1,9 @@ +error[E0017]: references in statics may only refer to immutable values + --> $DIR/check-static-immutable-mut-slices.rs:13:37 + | +LL | static TEST: &'static mut [isize] = &mut []; + | ^^^^^^^ statics require immutable values + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0017`. diff --git a/src/test/ui/compile-fail-migration/check-static-values-constraints.nll.stderr b/src/test/ui/compile-fail-migration/check-static-values-constraints.nll.stderr new file mode 100644 index 00000000000..b265ec8bdda --- /dev/null +++ b/src/test/ui/compile-fail-migration/check-static-values-constraints.nll.stderr @@ -0,0 +1,70 @@ +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/check-static-values-constraints.rs:75:43 + | +LL | ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), + | ___________________________________________^ +LL | | //~^ ERROR destructors cannot be evaluated at compile-time +LL | | field2: SafeEnum::Variant1}}; + | |________________________________________________________________________________^ statics cannot evaluate destructors + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:89:33 + | +LL | static STATIC11: Box = box MyOwned; + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants + --> $DIR/check-static-values-constraints.rs:99:32 + | +LL | field2: SafeEnum::Variant4("str".to_string()) + | ^^^^^^^^^^^^^^^^^ + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:104:5 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:105:5 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:109:6 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:110:6 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:116:5 + | +LL | box 3; + | ^^^^^ allocation not allowed in statics + +error[E0507]: cannot move out of static item + --> $DIR/check-static-values-constraints.rs:120:45 + | +LL | let y = { static x: Box = box 3; x }; + | ^ + | | + | cannot move out of static item + | help: consider using a reference instead: `&x` + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:120:38 + | +LL | let y = { static x: Box = box 3; x }; + | ^^^^^ allocation not allowed in statics + +error: aborting due to 10 previous errors + +Some errors occurred: E0010, E0015, E0493, E0507. +For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/compile-fail-migration/check-static-values-constraints.rs b/src/test/ui/compile-fail-migration/check-static-values-constraints.rs new file mode 100644 index 00000000000..37f665960c8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/check-static-values-constraints.rs @@ -0,0 +1,123 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Verifies all possible restrictions for statics values. + +#![allow(warnings)] +#![feature(box_syntax)] + +use std::marker; + +struct WithDtor; + +impl Drop for WithDtor { + fn drop(&mut self) {} +} + +// This enum will be used to test the following rules: +// 1. Variants are safe for static +// 2. Expr calls are allowed as long as they arguments are safe +// 3. Expr calls with unsafe arguments for statics are rejected +enum SafeEnum { + Variant1, + Variant2(isize), + Variant3(WithDtor), + Variant4(String) +} + +// These should be ok +static STATIC1: SafeEnum = SafeEnum::Variant1; +static STATIC2: SafeEnum = SafeEnum::Variant2(0); +static STATIC3: SafeEnum = SafeEnum::Variant3(WithDtor); + +enum UnsafeEnum { + Variant5, + Variant6(isize) +} + +impl Drop for UnsafeEnum { + fn drop(&mut self) {} +} + + +static STATIC4: UnsafeEnum = UnsafeEnum::Variant5; +static STATIC5: UnsafeEnum = UnsafeEnum::Variant6(0); + + +struct SafeStruct { + field1: SafeEnum, + field2: SafeEnum, +} + + +// Struct fields are safe, hence this static should be safe +static STATIC6: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, field2: SafeEnum::Variant2(0)}; + +static STATIC7: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, + field2: SafeEnum::Variant3(WithDtor)}; + +// Test variadic constructor for structs. The base struct should be examined +// as well as every field present in the constructor. +// This example shouldn't fail because all the fields are safe. +static STATIC8: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, + ..SafeStruct{field1: SafeEnum::Variant1, + field2: SafeEnum::Variant1}}; + +// This example should fail because field1 in the base struct is not safe +static STATIC9: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, + ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), +//~^ ERROR destructors cannot be evaluated at compile-time + field2: SafeEnum::Variant1}}; + +struct UnsafeStruct; + +impl Drop for UnsafeStruct { + fn drop(&mut self) {} +} + +static STATIC10: UnsafeStruct = UnsafeStruct; + +struct MyOwned; + +static STATIC11: Box = box MyOwned; +//~^ ERROR allocations are not allowed in statics + +static mut STATIC12: UnsafeStruct = UnsafeStruct; + +static mut STATIC13: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, + field2: SafeEnum::Variant3(WithDtor)}; + +static mut STATIC14: SafeStruct = SafeStruct { + field1: SafeEnum::Variant1, + field2: SafeEnum::Variant4("str".to_string()) +//~^ ERROR calls in statics are limited to constant functions +}; + +static STATIC15: &'static [Box] = &[ + box MyOwned, //~ ERROR allocations are not allowed in statics + box MyOwned, //~ ERROR allocations are not allowed in statics +]; + +static STATIC16: (&'static Box, &'static Box) = ( + &box MyOwned, //~ ERROR allocations are not allowed in statics + &box MyOwned, //~ ERROR allocations are not allowed in statics +); + +static mut STATIC17: SafeEnum = SafeEnum::Variant1; + +static STATIC19: Box = + box 3; +//~^ ERROR allocations are not allowed in statics + +pub fn main() { + let y = { static x: Box = box 3; x }; + //~^ ERROR allocations are not allowed in statics + //~^^ ERROR cannot move out of static item +} diff --git a/src/test/ui/compile-fail-migration/check-static-values-constraints.stderr b/src/test/ui/compile-fail-migration/check-static-values-constraints.stderr new file mode 100644 index 00000000000..ac979a3fa7c --- /dev/null +++ b/src/test/ui/compile-fail-migration/check-static-values-constraints.stderr @@ -0,0 +1,67 @@ +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/check-static-values-constraints.rs:75:43 + | +LL | ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), + | ___________________________________________^ +LL | | //~^ ERROR destructors cannot be evaluated at compile-time +LL | | field2: SafeEnum::Variant1}}; + | |________________________________________________________________________________^ statics cannot evaluate destructors + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:89:33 + | +LL | static STATIC11: Box = box MyOwned; + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants + --> $DIR/check-static-values-constraints.rs:99:32 + | +LL | field2: SafeEnum::Variant4("str".to_string()) + | ^^^^^^^^^^^^^^^^^ + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:104:5 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:105:5 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:109:6 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:110:6 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^^^^^ allocation not allowed in statics + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:116:5 + | +LL | box 3; + | ^^^^^ allocation not allowed in statics + +error[E0507]: cannot move out of static item + --> $DIR/check-static-values-constraints.rs:120:45 + | +LL | let y = { static x: Box = box 3; x }; + | ^ cannot move out of static item + +error[E0010]: allocations are not allowed in statics + --> $DIR/check-static-values-constraints.rs:120:38 + | +LL | let y = { static x: Box = box 3; x }; + | ^^^^^ allocation not allowed in statics + +error: aborting due to 10 previous errors + +Some errors occurred: E0010, E0015, E0493, E0507. +For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/compile-fail-migration/class-cast-to-trait.rs b/src/test/ui/compile-fail-migration/class-cast-to-trait.rs new file mode 100644 index 00000000000..af83b0ecbf2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/class-cast-to-trait.rs @@ -0,0 +1,64 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +trait noisy { + fn speak(&self); +} + +struct cat { + meows : usize, + + how_hungry : isize, + name : String, +} + +impl cat { + pub fn eat(&self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } + else { + println!("Not hungry!"); + return false; + } + } +} + +impl noisy for cat { + fn speak(&self) { self.meow(); } + +} + +impl cat { + fn meow(&self) { + println!("Meow"); + self.meows += 1; + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } +} + +fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } +} + +fn main() { + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + nyan.eat(); //~ ERROR no method named `eat` found +} diff --git a/src/test/ui/compile-fail-migration/class-cast-to-trait.stderr b/src/test/ui/compile-fail-migration/class-cast-to-trait.stderr new file mode 100644 index 00000000000..c1e08807f97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/class-cast-to-trait.stderr @@ -0,0 +1,9 @@ +error[E0599]: no method named `eat` found for type `std::boxed::Box` in the current scope + --> $DIR/class-cast-to-trait.rs:63:8 + | +LL | nyan.eat(); //~ ERROR no method named `eat` found + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/compile-fail-migration/class-method-missing.rs b/src/test/ui/compile-fail-migration/class-method-missing.rs new file mode 100644 index 00000000000..46b100a4d39 --- /dev/null +++ b/src/test/ui/compile-fail-migration/class-method-missing.rs @@ -0,0 +1,31 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait animal { + fn eat(&self); +} + +struct cat { + meows: usize, +} + +impl animal for cat { + //~^ ERROR not all trait items implemented, missing: `eat` +} + +fn cat(in_x : usize) -> cat { + cat { + meows: in_x + } +} + +fn main() { + let nyan = cat(0); +} diff --git a/src/test/ui/compile-fail-migration/class-method-missing.stderr b/src/test/ui/compile-fail-migration/class-method-missing.stderr new file mode 100644 index 00000000000..c1da06e3a3a --- /dev/null +++ b/src/test/ui/compile-fail-migration/class-method-missing.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `eat` + --> $DIR/class-method-missing.rs:19:1 + | +LL | fn eat(&self); + | -------------- `eat` from trait +... +LL | impl animal for cat { + | ^^^^^^^^^^^^^^^^^^^ missing `eat` in implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/compile-fail-migration/class-missing-self.rs b/src/test/ui/compile-fail-migration/class-missing-self.rs new file mode 100644 index 00000000000..372bf4cac87 --- /dev/null +++ b/src/test/ui/compile-fail-migration/class-missing-self.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct cat { + meows : usize, +} + +impl cat { + fn sleep(&self) { loop{} } + fn meow(&self) { + println!("Meow"); + meows += 1; //~ ERROR cannot find value `meows` in this scope + sleep(); //~ ERROR cannot find function `sleep` in this scope + } + +} + + + fn main() { } diff --git a/src/test/ui/compile-fail-migration/class-missing-self.stderr b/src/test/ui/compile-fail-migration/class-missing-self.stderr new file mode 100644 index 00000000000..33bf62e7087 --- /dev/null +++ b/src/test/ui/compile-fail-migration/class-missing-self.stderr @@ -0,0 +1,19 @@ +error[E0425]: cannot find value `meows` in this scope + --> $DIR/class-missing-self.rs:19:7 + | +LL | meows += 1; //~ ERROR cannot find value `meows` in this scope + | ^^^^^ help: try: `self.meows` + +error[E0425]: cannot find function `sleep` in this scope + --> $DIR/class-missing-self.rs:20:7 + | +LL | sleep(); //~ ERROR cannot find function `sleep` in this scope + | ^^^^^ not found in this scope +help: possible candidate is found in another module, you can import it into scope + | +LL | use std::thread::sleep; + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.rs b/src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.rs new file mode 100644 index 00000000000..dcbb25ba5a9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.rs @@ -0,0 +1,43 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the borrow checker prevents pointers to temporaries +// with statement lifetimes from escaping. + +use std::ops::Drop; + +static mut FLAGS: u64 = 0; + +struct Box { f: T } +struct AddFlags { bits: u64 } + +fn AddFlags(bits: u64) -> AddFlags { + AddFlags { bits: bits } +} + +fn arg(x: &AddFlags) -> &AddFlags { + x +} + +impl AddFlags { + fn get(&self) -> &AddFlags { + self + } +} + +pub fn main() { + let _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough + let _x = AddFlags(1).get(); //~ ERROR value does not live long enough + let _x = &*arg(&AddFlags(1)); //~ ERROR value does not live long enough + let ref _x = *arg(&AddFlags(1)); //~ ERROR value does not live long enough + let &ref _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough + let _x = AddFlags(1).get(); //~ ERROR value does not live long enough + let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough +} diff --git a/src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.stderr b/src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.stderr new file mode 100644 index 00000000000..f30271db289 --- /dev/null +++ b/src/test/ui/compile-fail-migration/cleanup-rvalue-scopes-cf.stderr @@ -0,0 +1,93 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/cleanup-rvalue-scopes-cf.rs:36:19 + | +LL | let _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough + | ^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +... +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/cleanup-rvalue-scopes-cf.rs:37:14 + | +LL | let _x = AddFlags(1).get(); //~ ERROR value does not live long enough + | ^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +... +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/cleanup-rvalue-scopes-cf.rs:38:21 + | +LL | let _x = &*arg(&AddFlags(1)); //~ ERROR value does not live long enough + | ^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +... +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/cleanup-rvalue-scopes-cf.rs:39:24 + | +LL | let ref _x = *arg(&AddFlags(1)); //~ ERROR value does not live long enough + | ^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +... +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/cleanup-rvalue-scopes-cf.rs:40:24 + | +LL | let &ref _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough + | ^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +... +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/cleanup-rvalue-scopes-cf.rs:41:14 + | +LL | let _x = AddFlags(1).get(); //~ ERROR value does not live long enough + | ^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +LL | let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error[E0597]: borrowed value does not live long enough + --> $DIR/cleanup-rvalue-scopes-cf.rs:42:34 + | +LL | let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough + | ^^^^^^^^^^^ - temporary value dropped here while still borrowed + | | + | temporary value does not live long enough +LL | } + | - temporary value needs to live until here + | + = note: consider using a `let` binding to increase its lifetime + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.rs new file mode 100644 index 00000000000..12e9fb30902 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.rs @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct X where F: FnOnce() + 'static + Send { + field: F, +} + +fn foo(blk: F) -> X where F: FnOnce() + 'static { + //~^ ERROR `F` cannot be sent between threads safely + return X { field: blk }; +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.stderr b/src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.stderr new file mode 100644 index 00000000000..e1b18b1d49e --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-bounds-cant-promote-superkind-in-struct.stderr @@ -0,0 +1,20 @@ +error[E0277]: `F` cannot be sent between threads safely + --> $DIR/closure-bounds-cant-promote-superkind-in-struct.rs:15:1 + | +LL | / fn foo(blk: F) -> X where F: FnOnce() + 'static { +LL | | //~^ ERROR `F` cannot be sent between threads safely +LL | | return X { field: blk }; +LL | | } + | |_^ `F` cannot be sent between threads safely + | + = help: the trait `std::marker::Send` is not implemented for `F` + = help: consider adding a `where F: std::marker::Send` bound +note: required by `X` + --> $DIR/closure-bounds-cant-promote-superkind-in-struct.rs:11:1 + | +LL | struct X where F: FnOnce() + 'static + Send { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.nll.stderr b/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.nll.stderr new file mode 100644 index 00000000000..ca82020a2cc --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.nll.stderr @@ -0,0 +1,39 @@ +warning: not reporting region error due to nll + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:9 + | +LL | bar(|| { + | _________^ +LL | | //~^ ERROR explicit lifetime required in the type of `x` [E0621] +LL | | let _ = x; +LL | | }) + | |_____^ + +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:5 + | +LL | fn foo(x: &()) { + | --- help: add explicit lifetime `'static` to the type of `x`: `&'static ()` +LL | / bar(|| { +LL | | //~^ ERROR explicit lifetime required in the type of `x` [E0621] +LL | | let _ = x; +LL | | }) + | |______^ lifetime `'static` required + +error[E0597]: `x` does not live long enough + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:17:17 + | +LL | bar(|| { + | -- value captured here +LL | //~^ ERROR explicit lifetime required in the type of `x` [E0621] +LL | let _ = x; + | ^ borrowed value does not live long enough +LL | }) +LL | } + | - `x` dropped here while still borrowed + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 2 previous errors + +Some errors occurred: E0597, E0621. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.rs b/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.rs new file mode 100644 index 00000000000..1ffba68263a --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.rs @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn bar(blk: F) where F: FnOnce() + 'static { +} + +fn foo(x: &()) { + bar(|| { + //~^ ERROR explicit lifetime required in the type of `x` [E0621] + let _ = x; + }) +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.stderr b/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.stderr new file mode 100644 index 00000000000..825f469c330 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-bounds-static-cant-capture-borrowed.stderr @@ -0,0 +1,11 @@ +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:5 + | +LL | fn foo(x: &()) { + | --- help: add explicit lifetime `'static` to the type of `x`: `&'static ()` +LL | bar(|| { + | ^^^ lifetime `'static` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff --git a/src/test/ui/compile-fail-migration/closure-bounds-subtype.rs b/src/test/ui/compile-fail-migration/closure-bounds-subtype.rs new file mode 100644 index 00000000000..db26535b004 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-bounds-subtype.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +fn take_any(_: F) where F: FnOnce() { +} + +fn take_const_owned(_: F) where F: FnOnce() + Sync + Send { +} + +fn give_any(f: F) where F: FnOnce() { + take_any(f); +} + +fn give_owned(f: F) where F: FnOnce() + Send { + take_any(f); + take_const_owned(f); //~ ERROR `F` cannot be shared between threads safely [E0277] +} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/closure-bounds-subtype.stderr b/src/test/ui/compile-fail-migration/closure-bounds-subtype.stderr new file mode 100644 index 00000000000..ffe486d4468 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-bounds-subtype.stderr @@ -0,0 +1,17 @@ +error[E0277]: `F` cannot be shared between threads safely + --> $DIR/closure-bounds-subtype.rs:24:5 + | +LL | take_const_owned(f); //~ ERROR `F` cannot be shared between threads safely [E0277] + | ^^^^^^^^^^^^^^^^ `F` cannot be shared between threads safely + | + = help: the trait `std::marker::Sync` is not implemented for `F` + = help: consider adding a `where F: std::marker::Sync` bound +note: required by `take_const_owned` + --> $DIR/closure-bounds-subtype.rs:15:1 + | +LL | fn take_const_owned(_: F) where F: FnOnce() + Sync + Send { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/README.md b/src/test/ui/compile-fail-migration/closure-expected-type/README.md new file mode 100644 index 00000000000..9995b00a9a7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/README.md @@ -0,0 +1 @@ +See `src/test/run-pass/closure-expected-type`. diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn-multiple.rs b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn-multiple.rs new file mode 100644 index 00000000000..32efb01c0fe --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn-multiple.rs @@ -0,0 +1,48 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![allow(warnings)] + +type Different<'a, 'b> = &'a mut (&'a (), &'b ()); +type Same<'a> = Different<'a, 'a>; + +fn with_closure_expecting_different(_: F) + where F: for<'a, 'b> FnOnce(Different<'a, 'b>) +{ +} + +fn with_closure_expecting_different_anon(_: F) + where F: FnOnce(Different<'_, '_>) +{ +} + +fn supplying_nothing_expecting_anon() { + with_closure_expecting_different_anon(|x: Different| { + }) +} + +fn supplying_nothing_expecting_named() { + with_closure_expecting_different(|x: Different| { + }) +} + +fn supplying_underscore_expecting_anon() { + with_closure_expecting_different_anon(|x: Different<'_, '_>| { + }) +} + +fn supplying_underscore_expecting_named() { + with_closure_expecting_different(|x: Different<'_, '_>| { + }) +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.nll.stderr b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.nll.stderr new file mode 100644 index 00000000000..fe857001bfa --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.nll.stderr @@ -0,0 +1,60 @@ +warning: not reporting region error due to nll + --> $DIR/expect-fn-supply-fn.rs:24:52 + | +LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^ + +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:40:5 + | +LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` + | | + | expected signature of `for<'a, 'r> fn(fn(&'a u32), &'r i32) -> _` + | +note: required by `with_closure_expecting_fn_with_free_region` + --> $DIR/expect-fn-supply-fn.rs:11:1 + | +LL | / fn with_closure_expecting_fn_with_free_region(_: F) +LL | | where F: for<'a> FnOnce(fn(&'a u32), &i32) +LL | | { +LL | | } + | |_^ + +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:47:5 + | +LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` + | | + | expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _` + | +note: required by `with_closure_expecting_fn_with_bound_region` + --> $DIR/expect-fn-supply-fn.rs:16:1 + | +LL | / fn with_closure_expecting_fn_with_bound_region(_: F) +LL | | where F: FnOnce(fn(&u32), &i32) +LL | | { +LL | | } + | |_^ + +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:56:5 + | +LL | with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` + | | + | expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _` + | +note: required by `with_closure_expecting_fn_with_bound_region` + --> $DIR/expect-fn-supply-fn.rs:16:1 + | +LL | / fn with_closure_expecting_fn_with_bound_region(_: F) +LL | | where F: FnOnce(fn(&u32), &i32) +LL | | { +LL | | } + | |_^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.rs b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.rs new file mode 100644 index 00000000000..63284c98020 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.rs @@ -0,0 +1,68 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn with_closure_expecting_fn_with_free_region(_: F) + where F: for<'a> FnOnce(fn(&'a u32), &i32) +{ +} + +fn with_closure_expecting_fn_with_bound_region(_: F) + where F: FnOnce(fn(&u32), &i32) +{ +} + +fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { + // Here, the type given for `'x` "obscures" a region from the + // expected signature that is bound at closure level. + with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); + //~^ ERROR mismatched types + //~| ERROR mismatched types +} + +fn expect_free_supply_free_from_closure() { + // A variant on the previous test. Here, the region `'a` will be + // bound at the closure level, just as is expected, so no error + // results. + type Foo<'a> = fn(&'a u32); + with_closure_expecting_fn_with_free_region(|_x: Foo<'_>, y| {}); +} + +fn expect_free_supply_bound() { + // Here, we are given a function whose region is bound at closure level, + // but we expect one bound in the argument. Error results. + with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); + //~^ ERROR type mismatch in closure arguments +} + +fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) { + // Here, we are given a `fn(&u32)` but we expect a `fn(&'x + // u32)`. In principle, this could be ok, but we demand equality. + with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); + //~^ ERROR type mismatch in closure arguments +} + +fn expect_bound_supply_free_from_closure() { + // A variant on the previous test. Here, the region `'a` will be + // bound at the closure level, but we expect something bound at + // the argument level. + type Foo<'a> = fn(&'a u32); + with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {}); + //~^ ERROR type mismatch in closure arguments +} + +fn expect_bound_supply_bound<'x>(x: &'x u32) { + // No error in this case. The supplied type supplies the bound + // regions, and hence we are able to figure out the type of `y` + // from the expected type + with_closure_expecting_fn_with_bound_region(|x: for<'z> fn(&'z u32), y| { + }); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.stderr new file mode 100644 index 00000000000..4dca5922910 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-fn-supply-fn.stderr @@ -0,0 +1,93 @@ +error[E0308]: mismatched types + --> $DIR/expect-fn-supply-fn.rs:24:52 + | +LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `fn(&u32)` + found type `fn(&'x u32)` +note: the anonymous lifetime #2 defined on the body at 24:48... + --> $DIR/expect-fn-supply-fn.rs:24:48 + | +LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^ +note: ...does not necessarily outlive the lifetime 'x as defined on the function body at 21:36 + --> $DIR/expect-fn-supply-fn.rs:21:36 + | +LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { + | ^^ + +error[E0308]: mismatched types + --> $DIR/expect-fn-supply-fn.rs:24:52 + | +LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `fn(&u32)` + found type `fn(&'x u32)` +note: the lifetime 'x as defined on the function body at 21:36... + --> $DIR/expect-fn-supply-fn.rs:21:36 + | +LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) { + | ^^ +note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 24:48 + --> $DIR/expect-fn-supply-fn.rs:24:48 + | +LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:40:5 + | +LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` + | | + | expected signature of `for<'a, 'r> fn(fn(&'a u32), &'r i32) -> _` + | +note: required by `with_closure_expecting_fn_with_free_region` + --> $DIR/expect-fn-supply-fn.rs:11:1 + | +LL | / fn with_closure_expecting_fn_with_free_region(_: F) +LL | | where F: for<'a> FnOnce(fn(&'a u32), &i32) +LL | | { +LL | | } + | |_^ + +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:47:5 + | +LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` + | | + | expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _` + | +note: required by `with_closure_expecting_fn_with_bound_region` + --> $DIR/expect-fn-supply-fn.rs:16:1 + | +LL | / fn with_closure_expecting_fn_with_bound_region(_: F) +LL | | where F: FnOnce(fn(&u32), &i32) +LL | | { +LL | | } + | |_^ + +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:56:5 + | +LL | with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` + | | + | expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _` + | +note: required by `with_closure_expecting_fn_with_bound_region` + --> $DIR/expect-fn-supply-fn.rs:16:1 + | +LL | / fn with_closure_expecting_fn_with_bound_region(_: F) +LL | | where F: FnOnce(fn(&u32), &i32) +LL | | { +LL | | } + | |_^ + +error: aborting due to 5 previous errors + +Some errors occurred: E0308, E0631. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.rs b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.rs new file mode 100644 index 00000000000..bef69a4b0b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.rs @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn with_closure(_: F) + where F: FnOnce(A, A) +{ +} + +fn a() { + with_closure(|x: u32, y| { + // We deduce type of `y` from `x`. + }); +} + +fn b() { + // Here we take the supplied types, resulting in an error later on. + with_closure(|x: u32, y: i32| { + //~^ ERROR type mismatch in closure arguments + }); +} + +fn c() { + with_closure(|x, y: i32| { + // We deduce type of `x` from `y`. + }); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.stderr b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.stderr new file mode 100644 index 00000000000..51dcf5eb3da --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-appearing-twice.stderr @@ -0,0 +1,20 @@ +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-infer-var-appearing-twice.rs:24:5 + | +LL | with_closure(|x: u32, y: i32| { + | ^^^^^^^^^^^^ ---------------- found signature of `fn(u32, i32) -> _` + | | + | expected signature of `fn(_, _) -> _` + | +note: required by `with_closure` + --> $DIR/expect-infer-var-appearing-twice.rs:11:1 + | +LL | / fn with_closure(_: F) +LL | | where F: FnOnce(A, A) +LL | | { +LL | | } + | |_^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0631`. diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs new file mode 100644 index 00000000000..6767aa62f78 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-bound-region.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +fn with_closure(_: F) + where F: FnOnce(A, &u32) +{ +} + +fn foo() { + // This version works; we infer `A` to be `u32`, and take the type + // of `y` to be `&u32`. + with_closure(|x: u32, y| {}); +} + +fn bar() { + // This version also works. + with_closure(|x: &u32, y| {}); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs new file mode 100644 index 00000000000..aea5cb21e63 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-infer-var-supply-ty-with-free-region.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +fn with_closure(_: F) + where F: FnOnce(A, &u32) +{ +} + +fn foo() { + // This version works; we infer `A` to be `u32`, and take the type + // of `y` to be `&u32`. + with_closure(|x: u32, y| {}); +} + +fn bar<'x>(x: &'x u32) { + // Same. + with_closure(|x: &'x u32, y| {}); +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs b/src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs new file mode 100644 index 00000000000..377eaadbd6a --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn with_closure(_: F) + where F: FnOnce(A, B) +{ +} + +fn a() { + // Type of `y` is unconstrained. + with_closure(|x: u32, y| {}); //~ ERROR E0282 +} + +fn b() { + with_closure(|x: u32, y: u32| {}); // OK +} + +fn c() { + with_closure(|x: u32, y: u32| {}); // OK +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr b/src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr new file mode 100644 index 00000000000..273fb2a2dd2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:18:27 + | +LL | with_closure(|x: u32, y| {}); //~ ERROR E0282 + | ^ consider giving this closure parameter a type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/compile-fail-migration/closure-no-fn-1.rs b/src/test/ui/compile-fail-migration/closure-no-fn-1.rs new file mode 100644 index 00000000000..10c99703a97 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-no-fn-1.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that capturing closures are never coerced to fns +// Especially interesting as non-capturing closures can be. + +fn main() { + let mut a = 0u8; + let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/closure-no-fn-1.stderr b/src/test/ui/compile-fail-migration/closure-no-fn-1.stderr new file mode 100644 index 00000000000..4786a6836cd --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-no-fn-1.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/closure-no-fn-1.rs:16:29 + | +LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a }; + | ^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure + | + = note: expected type `fn(u8) -> u8` + found type `[closure@$DIR/closure-no-fn-1.rs:16:29: 16:50 a:_]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/closure-no-fn-2.rs b/src/test/ui/compile-fail-migration/closure-no-fn-2.rs new file mode 100644 index 00000000000..a6438bb5f24 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-no-fn-2.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that capturing closures are never coerced to fns +// Especially interesting as non-capturing closures can be. + +fn main() { + let b = 0u8; + let bar: fn() -> u8 = || { b }; + //~^ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/closure-no-fn-2.stderr b/src/test/ui/compile-fail-migration/closure-no-fn-2.stderr new file mode 100644 index 00000000000..1aad49777dc --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-no-fn-2.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/closure-no-fn-2.rs:16:27 + | +LL | let bar: fn() -> u8 = || { b }; + | ^^^^^^^^ expected fn pointer, found closure + | + = note: expected type `fn() -> u8` + found type `[closure@$DIR/closure-no-fn-2.rs:16:27: 16:35 b:_]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/closure-no-fn-3.rs b/src/test/ui/compile-fail-migration/closure-no-fn-3.rs new file mode 100644 index 00000000000..6584c16c9de --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-no-fn-3.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Ensure that capturing closures are never coerced to fns +// Especially interesting as non-capturing closures can be. + +fn main() { + let b = 0u8; + let baz: fn() -> u8 = (|| { b }) as fn() -> u8; + //~^ ERROR non-primitive cast +} diff --git a/src/test/ui/compile-fail-migration/closure-no-fn-3.stderr b/src/test/ui/compile-fail-migration/closure-no-fn-3.stderr new file mode 100644 index 00000000000..bd28045c1b9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-no-fn-3.stderr @@ -0,0 +1,11 @@ +error[E0605]: non-primitive cast: `[closure@$DIR/closure-no-fn-3.rs:16:27: 16:37 b:_]` as `fn() -> u8` + --> $DIR/closure-no-fn-3.rs:16:27 + | +LL | let baz: fn() -> u8 = (|| { b }) as fn() -> u8; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.rs b/src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.rs new file mode 100644 index 00000000000..9357d0e7615 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.rs @@ -0,0 +1,28 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #25954: detect and reject a closure type that +// references itself. + +use std::cell::{Cell, RefCell}; + +struct A { + x: RefCell>, + b: Cell, +} + +fn main() { + let mut p = A{x: RefCell::new(None), b: Cell::new(4i32)}; + + // This is an error about types of infinite size: + let q = || p.b.set(5i32); //~ ERROR mismatched types + + *(p.x.borrow_mut()) = Some(q); +} diff --git a/src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.stderr b/src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.stderr new file mode 100644 index 00000000000..fa00d9fd9a4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-referencing-itself-issue-25954.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/closure-referencing-itself-issue-25954.rs:25:13 + | +LL | let q = || p.b.set(5i32); //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^ cyclic type of infinite size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/closure-reform-bad.rs b/src/test/ui/compile-fail-migration/closure-reform-bad.rs new file mode 100644 index 00000000000..490734d463d --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-reform-bad.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +fn call_bare(f: fn(&str)) { + f("Hello "); +} + +fn main() { + let string = "world!"; + let f = |s: &str| println!("{}{}", s, string); + call_bare(f) //~ ERROR mismatched types +} diff --git a/src/test/ui/compile-fail-migration/closure-reform-bad.stderr b/src/test/ui/compile-fail-migration/closure-reform-bad.stderr new file mode 100644 index 00000000000..a4e18175369 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-reform-bad.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/closure-reform-bad.rs:21:15 + | +LL | call_bare(f) //~ ERROR mismatched types + | ^ expected fn pointer, found closure + | + = note: expected type `for<'r> fn(&'r str)` + found type `[closure@$DIR/closure-reform-bad.rs:20:13: 20:50 string:_]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/closure-wrong-kind.rs b/src/test/ui/compile-fail-migration/closure-wrong-kind.rs new file mode 100644 index 00000000000..a387e4c5ece --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-wrong-kind.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +struct X; +fn foo(_: T) {} +fn bar(_: T) {} + +fn main() { + let x = X; + let closure = |_| foo(x); //~ ERROR E0525 + bar(closure); +} diff --git a/src/test/ui/compile-fail-migration/closure-wrong-kind.stderr b/src/test/ui/compile-fail-migration/closure-wrong-kind.stderr new file mode 100644 index 00000000000..636f30770a9 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure-wrong-kind.stderr @@ -0,0 +1,14 @@ +error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` + --> $DIR/closure-wrong-kind.rs:20:19 + | +LL | let closure = |_| foo(x); //~ ERROR E0525 + | ^^^^^^^^-^ + | | | + | | closure is `FnOnce` because it moves the variable `x` out of its environment + | this closure implements `FnOnce`, not `Fn` +LL | bar(closure); + | --- the requirement to implement `Fn` derives from here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0525`. diff --git a/src/test/ui/compile-fail-migration/closure_promotion.rs b/src/test/ui/compile-fail-migration/closure_promotion.rs new file mode 100644 index 00000000000..ddc995a1a41 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure_promotion.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(const_err)] + +// nll successfully compiles this. It is a bug. +// See https://github.com/rust-lang/rust/issues/52384 +fn main() { + let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough +} diff --git a/src/test/ui/compile-fail-migration/closure_promotion.stderr b/src/test/ui/compile-fail-migration/closure_promotion.stderr new file mode 100644 index 00000000000..cfb5d141a29 --- /dev/null +++ b/src/test/ui/compile-fail-migration/closure_promotion.stderr @@ -0,0 +1,13 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/closure_promotion.rs:16:26 + | +LL | let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough + | ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.rs b/src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.rs new file mode 100644 index 00000000000..ef65927fc5d --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// A version of coerce-expect-unsized that uses type ascription. +// Doesn't work so far, but supposed to work eventually + +#![feature(box_syntax, type_ascription)] + +use std::fmt::Debug; + +pub fn main() { + let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types + let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types + let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; + //~^ ERROR mismatched types + let _ = box { |x| (x as u8) }: Box _>; //~ ERROR mismatched types + let _ = box if true { false } else { true }: Box; //~ ERROR mismatched types + let _ = box match true { true => 'a', false => 'b' }: Box; //~ ERROR mismatched types + + let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types + let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types + let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; + //~^ ERROR mismatched types + let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types + let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types + let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types + + let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types + let _ = Box::new(|x| (x as u8)): Box _>; //~ ERROR mismatched types + + let _ = vec![ + Box::new(|x| (x as u8)), + box |x| (x as i16 as u8), + ]: Vec _>>; +} diff --git a/src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.stderr b/src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.stderr new file mode 100644 index 00000000000..894fbbf202a --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-expect-unsized-ascribed.stderr @@ -0,0 +1,129 @@ +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:19:13 + | +LL | let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements + | + = note: expected type `std::boxed::Box<[i32]>` + found type `std::boxed::Box<[i32; 3]>` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:20:13 + | +LL | let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements + | + = note: expected type `std::boxed::Box<[i32]>` + found type `std::boxed::Box<[i32; 3]>` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:21:13 + | +LL | let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements + | + = note: expected type `std::boxed::Box<[i32]>` + found type `std::boxed::Box<[i32; 3]>` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:23:13 + | +LL | let _ = box { |x| (x as u8) }: Box _>; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure + | + = note: expected type `std::boxed::Box u8>` + found type `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:23:19: 23:32]>` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:24:13 + | +LL | let _ = box if true { false } else { true }: Box; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool + | + = note: expected type `std::boxed::Box` + found type `std::boxed::Box` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:25:13 + | +LL | let _ = box match true { true => 'a', false => 'b' }: Box; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char + | + = note: expected type `std::boxed::Box` + found type `std::boxed::Box` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:27:13 + | +LL | let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^ expected slice, found array of 3 elements + | + = note: expected type `&[i32]` + found type `&[i32; 3]` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:28:13 + | +LL | let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements + | + = note: expected type `&[i32]` + found type `&[i32; 3]` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:29:13 + | +LL | let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements + | + = note: expected type `&[i32]` + found type `&[i32; 3]` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:31:13 + | +LL | let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure + | + = note: expected type `&dyn std::ops::Fn(i32) -> u8` + found type `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:31:16: 31:29]` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:32:13 + | +LL | let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool + | + = note: expected type `&dyn std::fmt::Debug` + found type `&bool` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:33:13 + | +LL | let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char + | + = note: expected type `&dyn std::fmt::Debug` + found type `&char` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:35:13 + | +LL | let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements + | + = note: expected type `std::boxed::Box<[i32]>` + found type `std::boxed::Box<[i32; 3]>` + +error[E0308]: mismatched types + --> $DIR/coerce-expect-unsized-ascribed.rs:36:13 + | +LL | let _ = Box::new(|x| (x as u8)): Box _>; //~ ERROR mismatched types + | ^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure + | + = note: expected type `std::boxed::Box _>` + found type `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:36:22: 36:35]>` + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/coerce-mut.rs b/src/test/ui/compile-fail-migration/coerce-mut.rs new file mode 100644 index 00000000000..bc3d58ef33d --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-mut.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn f(x: &mut i32) {} + +fn main() { + let x = 0; + f(&x); + //~^ ERROR mismatched types + //~| expected type `&mut i32` + //~| found type `&{integer}` + //~| types differ in mutability +} diff --git a/src/test/ui/compile-fail-migration/coerce-mut.stderr b/src/test/ui/compile-fail-migration/coerce-mut.stderr new file mode 100644 index 00000000000..5e460b199a1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-mut.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/coerce-mut.rs:15:7 + | +LL | f(&x); + | ^^ types differ in mutability + | + = note: expected type `&mut i32` + found type `&{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.nll.stderr b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.nll.stderr new file mode 100644 index 00000000000..29b6f057562 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.nll.stderr @@ -0,0 +1,47 @@ +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:22:24 + | +LL | let y = borrow_mut(x); + | - first mutable borrow occurs here +LL | let z = borrow_mut(x); + | ^ second mutable borrow occurs here +... +LL | drop((y, z)); + | - borrow later used here + +error[E0506]: cannot assign to `**x` because it is borrowed + --> $DIR/coerce-overloaded-autoderef.rs:31:5 + | +LL | let y = borrow(x); + | - borrow of `**x` occurs here +LL | let z = borrow(x); +LL | **x += 1; + | ^^^^^^^^ assignment to borrowed `**x` occurs here +... +LL | drop((y, z)); + | - borrow later used here + +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:38:20 + | +LL | borrow_mut2(x, x); + | ---------------^- + | | | | + | | | second mutable borrow occurs here + | | first mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable + --> $DIR/coerce-overloaded-autoderef.rs:44:5 + | +LL | borrow2(x, x); + | ^^^^^^^^^^^-^ + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | borrow later used here + +error: aborting due to 4 previous errors + +Some errors occurred: E0499, E0502, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.stderr b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.stderr new file mode 100644 index 00000000000..3bb5ec72002 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.ast.stderr @@ -0,0 +1,42 @@ +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:22:24 + | +LL | let y = borrow_mut(x); + | - first mutable borrow occurs here +LL | let z = borrow_mut(x); + | ^ second mutable borrow occurs here +... +LL | } + | - first borrow ends here + +error[E0506]: cannot assign to `**x` because it is borrowed + --> $DIR/coerce-overloaded-autoderef.rs:31:5 + | +LL | let y = borrow(x); + | - borrow of `**x` occurs here +LL | let z = borrow(x); +LL | **x += 1; + | ^^^^^^^^ assignment to borrowed `**x` occurs here + +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:38:20 + | +LL | borrow_mut2(x, x); + | - ^- first borrow ends here + | | | + | | second mutable borrow occurs here + | first mutable borrow occurs here + +error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable + --> $DIR/coerce-overloaded-autoderef.rs:44:16 + | +LL | borrow2(x, x); + | - ^- mutable borrow ends here + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + +error: aborting due to 4 previous errors + +Some errors occurred: E0499, E0502, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.nll.stderr b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.nll.stderr new file mode 100644 index 00000000000..29b6f057562 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.nll.stderr @@ -0,0 +1,47 @@ +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:22:24 + | +LL | let y = borrow_mut(x); + | - first mutable borrow occurs here +LL | let z = borrow_mut(x); + | ^ second mutable borrow occurs here +... +LL | drop((y, z)); + | - borrow later used here + +error[E0506]: cannot assign to `**x` because it is borrowed + --> $DIR/coerce-overloaded-autoderef.rs:31:5 + | +LL | let y = borrow(x); + | - borrow of `**x` occurs here +LL | let z = borrow(x); +LL | **x += 1; + | ^^^^^^^^ assignment to borrowed `**x` occurs here +... +LL | drop((y, z)); + | - borrow later used here + +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:38:20 + | +LL | borrow_mut2(x, x); + | ---------------^- + | | | | + | | | second mutable borrow occurs here + | | first mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable + --> $DIR/coerce-overloaded-autoderef.rs:44:5 + | +LL | borrow2(x, x); + | ^^^^^^^^^^^-^ + | | | + | | immutable borrow occurs here + | mutable borrow occurs here + | borrow later used here + +error: aborting due to 4 previous errors + +Some errors occurred: E0499, E0502, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.stderr b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.stderr new file mode 100644 index 00000000000..fbc49a7e91f --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.mir.stderr @@ -0,0 +1,47 @@ +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:22:24 + | +LL | let y = borrow_mut(x); + | - first mutable borrow occurs here +LL | let z = borrow_mut(x); + | ^ second mutable borrow occurs here +... +LL | drop((y, z)); + | - borrow later used here + +error[E0506]: cannot assign to `**x` because it is borrowed + --> $DIR/coerce-overloaded-autoderef.rs:31:5 + | +LL | let y = borrow(x); + | - borrow of `**x` occurs here +LL | let z = borrow(x); +LL | **x += 1; + | ^^^^^^^^ assignment to borrowed `**x` occurs here +... +LL | drop((y, z)); + | - borrow later used here + +error[E0499]: cannot borrow `*x` as mutable more than once at a time + --> $DIR/coerce-overloaded-autoderef.rs:38:20 + | +LL | borrow_mut2(x, x); + | ---------------^- + | | | | + | | | second mutable borrow occurs here + | | first mutable borrow occurs here + | borrow later used here + +error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable + --> $DIR/coerce-overloaded-autoderef.rs:44:16 + | +LL | borrow2(x, x); + | -----------^- + | | | | + | | | immutable borrow occurs here + | | mutable borrow occurs here + | borrow later used here + +error: aborting due to 4 previous errors + +Some errors occurred: E0499, E0502, E0506. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.rs b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.rs new file mode 100644 index 00000000000..5a05f59c6f4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-overloaded-autoderef.rs @@ -0,0 +1,49 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +fn borrow_mut(x: &mut T) -> &mut T { x } +fn borrow(x: &T) -> &T { x } + +fn borrow_mut2(_: &mut T, _: &mut T) {} +fn borrow2(_: &mut T, _: &T) {} + +fn double_mut_borrow(x: &mut Box) { + let y = borrow_mut(x); + let z = borrow_mut(x); + //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time + //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time + drop((y, z)); +} + +fn double_imm_borrow(x: &mut Box) { + let y = borrow(x); + let z = borrow(x); + **x += 1; + //[ast]~^ ERROR cannot assign to `**x` because it is borrowed + //[mir]~^^ ERROR cannot assign to `**x` because it is borrowed + drop((y, z)); +} + +fn double_mut_borrow2(x: &mut Box) { + borrow_mut2(x, x); + //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time + //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time +} + +fn double_borrow2(x: &mut Box) { + borrow2(x, x); + //[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable + //[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable +} + +pub fn main() {} diff --git a/src/test/ui/compile-fail-migration/coerce-to-bang-cast.rs b/src/test/ui/compile-fail-migration/coerce-to-bang-cast.rs new file mode 100644 index 00000000000..14a06b306d8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-to-bang-cast.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] + +fn foo(x: usize, y: !, z: usize) { } + +fn cast_a() { + let y = {return; 22} as !; + //~^ ERROR non-primitive cast +} + +fn cast_b() { + let y = 22 as !; //~ ERROR non-primitive cast +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coerce-to-bang-cast.stderr b/src/test/ui/compile-fail-migration/coerce-to-bang-cast.stderr new file mode 100644 index 00000000000..fde94144512 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-to-bang-cast.stderr @@ -0,0 +1,19 @@ +error[E0605]: non-primitive cast: `i32` as `!` + --> $DIR/coerce-to-bang-cast.rs:16:13 + | +LL | let y = {return; 22} as !; + | ^^^^^^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error[E0605]: non-primitive cast: `i32` as `!` + --> $DIR/coerce-to-bang-cast.rs:21:13 + | +LL | let y = 22 as !; //~ ERROR non-primitive cast + | ^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0605`. diff --git a/src/test/ui/compile-fail-migration/coerce-to-bang.rs b/src/test/ui/compile-fail-migration/coerce-to-bang.rs new file mode 100644 index 00000000000..8b4e2c3c051 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-to-bang.rs @@ -0,0 +1,89 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(never_type)] + +fn foo(x: usize, y: !, z: usize) { } + +fn call_foo_a() { + foo(return, 22, 44); + //~^ ERROR mismatched types +} + +fn call_foo_b() { + // Divergence happens in the argument itself, definitely ok. + foo(22, return, 44); +} + +fn call_foo_c() { + // This test fails because the divergence happens **after** the + // coercion to `!`: + foo(22, 44, return); //~ ERROR mismatched types +} + +fn call_foo_d() { + // This test passes because `a` has type `!`: + let a: ! = return; + let b = 22; + let c = 44; + foo(a, b, c); // ... and hence a reference to `a` is expected to diverge. + //~^ ERROR mismatched types +} + +fn call_foo_e() { + // This test probably could pass but we don't *know* that `a` + // has type `!` so we don't let it work. + let a = return; + let b = 22; + let c = 44; + foo(a, b, c); //~ ERROR mismatched types +} + +fn call_foo_f() { + // This fn fails because `a` has type `usize`, and hence a + // reference to is it **not** considered to diverge. + let a: usize = return; + let b = 22; + let c = 44; + foo(a, b, c); //~ ERROR mismatched types +} + +fn array_a() { + // Return is coerced to `!` just fine, but `22` cannot be. + let x: [!; 2] = [return, 22]; //~ ERROR mismatched types +} + +fn array_b() { + // Error: divergence has not yet occurred. + let x: [!; 2] = [22, return]; //~ ERROR mismatched types +} + +fn tuple_a() { + // No divergence at all. + let x: (usize, !, usize) = (22, 44, 66); //~ ERROR mismatched types +} + +fn tuple_b() { + // Divergence happens before coercion: OK + let x: (usize, !, usize) = (return, 44, 66); + //~^ ERROR mismatched types +} + +fn tuple_c() { + // Divergence happens before coercion: OK + let x: (usize, !, usize) = (22, return, 66); +} + +fn tuple_d() { + // Error: divergence happens too late + let x: (usize, !, usize) = (22, 44, return); //~ ERROR mismatched types +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coerce-to-bang.stderr b/src/test/ui/compile-fail-migration/coerce-to-bang.stderr new file mode 100644 index 00000000000..bf490cd20aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-to-bang.stderr @@ -0,0 +1,93 @@ +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:16:17 + | +LL | foo(return, 22, 44); + | ^^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:28:13 + | +LL | foo(22, 44, return); //~ ERROR mismatched types + | ^^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:36:12 + | +LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge. + | ^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:46:12 + | +LL | foo(a, b, c); //~ ERROR mismatched types + | ^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:55:12 + | +LL | foo(a, b, c); //~ ERROR mismatched types + | ^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:60:21 + | +LL | let x: [!; 2] = [return, 22]; //~ ERROR mismatched types + | ^^^^^^^^^^^^ expected !, found integral variable + | + = note: expected type `[!; 2]` + found type `[{integer}; 2]` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:65:22 + | +LL | let x: [!; 2] = [22, return]; //~ ERROR mismatched types + | ^^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:70:37 + | +LL | let x: (usize, !, usize) = (22, 44, 66); //~ ERROR mismatched types + | ^^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:75:41 + | +LL | let x: (usize, !, usize) = (return, 44, 66); + | ^^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/coerce-to-bang.rs:86:37 + | +LL | let x: (usize, !, usize) = (22, 44, return); //~ ERROR mismatched types + | ^^ expected !, found integral variable + | + = note: expected type `!` + found type `{integer}` + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.rs b/src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.rs new file mode 100644 index 00000000000..90cbbf242aa --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); + //~^ ERROR E0277 +} diff --git a/src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.stderr b/src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.stderr new file mode 100644 index 00000000000..ca402b25585 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coerce-unsafe-to-closure.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}: std::ops::FnOnce<(&str,)>` is not satisfied + --> $DIR/coerce-unsafe-to-closure.rs:12:40 + | +LL | let x: Option<&[u8]> = Some("foo").map(std::mem::transmute); + | ^^^ the trait `std::ops::FnOnce<(&str,)>` is not implemented for `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/compile-fail-migration/coercion-slice.rs b/src/test/ui/compile-fail-migration/coercion-slice.rs new file mode 100644 index 00000000000..7c5a4e0c3c6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coercion-slice.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that we forbid coercion from `[T; n]` to `&[T]` + +fn main() { + let _: &[i32] = [0]; + //~^ ERROR mismatched types + //~| expected type `&[i32]` + //~| expected &[i32], found array of 1 elements +} diff --git a/src/test/ui/compile-fail-migration/coercion-slice.stderr b/src/test/ui/compile-fail-migration/coercion-slice.stderr new file mode 100644 index 00000000000..47a77d42773 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coercion-slice.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/coercion-slice.rs:14:21 + | +LL | let _: &[i32] = [0]; + | ^^^ + | | + | expected &[i32], found array of 1 elements + | help: consider borrowing here: `&[0]` + | + = note: expected type `&[i32]` + found type `[{integer}; 1]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/compile-fail-migration/coherence-all-remote.rs b/src/test/ui/compile-fail-migration/coherence-all-remote.rs new file mode 100644 index 00000000000..7a5340041c2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-all-remote.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote1; + +impl Remote1 for isize { } +//~^ ERROR E0210 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-all-remote.stderr b/src/test/ui/compile-fail-migration/coherence-all-remote.stderr new file mode 100644 index 00000000000..1f71969989b --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-all-remote.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-all-remote.rs:16:1 + | +LL | impl Remote1 for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-bigint-param.rs b/src/test/ui/compile-fail-migration/coherence-bigint-param.rs new file mode 100644 index 00000000000..32c5b669381 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-bigint-param.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub struct BigInt; + +impl Remote1 for T { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-bigint-param.stderr b/src/test/ui/compile-fail-migration/coherence-bigint-param.stderr new file mode 100644 index 00000000000..7d2796ee690 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-bigint-param.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-bigint-param.rs:18:1 + | +LL | impl Remote1 for T { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.rs new file mode 100644 index 00000000000..434d77828b4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; +use std::default::Default; + +// Test that two blanket impls conflict (at least without negative +// bounds). After all, some other crate could implement Even or Odd +// for the same type (though this crate doesn't). + +trait MyTrait { + fn get(&self) -> usize; +} + +trait Even { } + +trait Odd { } + +impl Even for isize { } + +impl Odd for usize { } + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for T { //~ ERROR E0119 + fn get(&self) -> usize { 0 } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.stderr b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.stderr new file mode 100644 index 00000000000..7dbcda06511 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-implemented.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:34:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.rs new file mode 100644 index 00000000000..7ad5cd71ca8 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; +use std::default::Default; + +// Test that two blanket impls conflict (at least without negative +// bounds). After all, some other crate could implement Even or Odd +// for the same type (though this crate doesn't implement them at all). + +trait MyTrait { + fn get(&self) -> usize; +} + +trait Even {} + +trait Odd {} + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for T { //~ ERROR E0119 + fn get(&self) -> usize { 0 } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.stderr b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.stderr new file mode 100644 index 00000000000..faabfb6c7c0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-blanket-unimplemented.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:30:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.rs b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.rs new file mode 100644 index 00000000000..b3ef79c6cc0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:go_trait.rs + +extern crate go_trait; + +use go_trait::{Go,GoMut}; +use std::fmt::Debug; +use std::default::Default; + +struct MyThingy; + +impl Go for MyThingy { + fn go(&self, arg: isize) { } +} + +impl GoMut for MyThingy { //~ ERROR conflicting implementations + fn go_mut(&mut self, arg: isize) { } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.stderr b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.stderr new file mode 100644 index 00000000000..38aff37bfcc --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-cross-crate.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`: + --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:25:1 + | +LL | impl GoMut for MyThingy { //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `go_trait`: + - impl go_trait::GoMut for G + where G: go_trait::Go; + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.rs b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.rs new file mode 100644 index 00000000000..1defe6c8b20 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; +use std::default::Default; + +// Test that a blank impl for all T conflicts with an impl for some +// specific T, even when there are multiple type parameters involved. + +trait MyTrait { + fn get(&self) -> T; +} + +impl MyTrait for T { + fn get(&self) -> T { + panic!() + } +} + +#[derive(Clone)] +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { //~ ERROR E0119 + fn get(&self) -> usize { (*self).clone() } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.stderr b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.stderr new file mode 100644 index 00000000000..a5992406262 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-multidispatch.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:32:1 + | +LL | impl MyTrait for T { + | ------------------------ first implementation here +... +LL | impl MyTrait for MyType { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.rs b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.rs new file mode 100644 index 00000000000..5c5c4d32d67 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a blank impl for all T:PartialEq conflicts with an impl for some +// specific T when T:PartialEq. + +trait OtherTrait { + fn noop(&self); +} + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { //~ ERROR E0119 + fn get(&self) -> usize { self.dummy } +} + +impl OtherTrait for MyType { + fn noop(&self) { } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.stderr b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.stderr new file mode 100644 index 00000000000..9a6e0071eb7 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific-trait.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:30:1 + | +LL | impl MyTrait for T { + | -------------------------------- first implementation here +... +LL | impl MyTrait for MyType { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.rs b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.rs new file mode 100644 index 00000000000..57d71b44b0f --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Debug; +use std::default::Default; + +// Test that a blank impl for all T conflicts with an impl for some +// specific T. + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { //~ ERROR E0119 + fn get(&self) -> usize { self.dummy } +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.stderr b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.stderr new file mode 100644 index 00000000000..955cd3b125f --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-blanket-conflicts-with-specific.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific.rs:29:1 + | +LL | impl MyTrait for T { + | --------------------- first implementation here +... +LL | impl MyTrait for MyType { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.rs b/src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.rs new file mode 100644 index 00000000000..8e9d1eff345 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(overlapping_marker_traits)] + +trait MyTrait {} + +struct TestType(::std::marker::PhantomData); + +unsafe impl Send for TestType {} + +impl !Send for TestType {} +//~^ ERROR conflicting implementations of trait `std::marker::Send` + +unsafe impl Send for TestType {} + +impl !Send for TestType {} +//~^ ERROR conflicting implementations of trait `std::marker::Send` + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.stderr b/src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.stderr new file mode 100644 index 00000000000..a2a869daff0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-conflicting-negative-trait-impl.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:20:1 + | +LL | unsafe impl Send for TestType {} + | ---------------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` + +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:25:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-cow.a.stderr b/src/test/ui/compile-fail-migration/coherence-cow.a.stderr new file mode 100644 index 00000000000..f05333348ec --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-cow.a.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-cow.rs:26:1 + | +LL | impl Remote for Pair> { } //[a]~ ERROR E0210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-cow.b.stderr b/src/test/ui/compile-fail-migration/coherence-cow.b.stderr new file mode 100644 index 00000000000..269bcd576af --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-cow.b.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-cow.rs:29:1 + | +LL | impl Remote for Pair,T> { } //[b]~ ERROR E0210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-cow.c.stderr b/src/test/ui/compile-fail-migration/coherence-cow.c.stderr new file mode 100644 index 00000000000..e89308db054 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-cow.c.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-cow.rs:32:1 + | +LL | impl Remote for Pair,U> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-cow.rs b/src/test/ui/compile-fail-migration/coherence-cow.rs new file mode 100644 index 00000000000..86ae5b44d9d --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-cow.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: a b c + +// aux-build:coherence_lib.rs + +// Test that the `Pair` type reports an error if it contains type +// parameters, even when they are covered by local types. This test +// was originally intended to test the opposite, but the rules changed +// with RFC 1023 and this became illegal. + +extern crate coherence_lib as lib; +use lib::{Remote,Pair}; + +pub struct Cover(T); + +#[cfg(a)] +impl Remote for Pair> { } //[a]~ ERROR E0210 + +#[cfg(b)] +impl Remote for Pair,T> { } //[b]~ ERROR E0210 + +#[cfg(c)] +impl Remote for Pair,U> { } +//[c]~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.rs b/src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.rs new file mode 100644 index 00000000000..aac870293fd --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The error here is strictly due to orphan rules; the impl here +// generalizes the one upstream + +// aux-build:trait_impl_conflict.rs +extern crate trait_impl_conflict; +use trait_impl_conflict::Foo; + +impl Foo for A { + //~^ ERROR type parameter `A` must be used as the type parameter for some local type + //~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` +} + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.stderr b/src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.stderr new file mode 100644 index 00000000000..ee11967cc0d --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-cross-crate-conflict.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`: + --> $DIR/coherence-cross-crate-conflict.rs:18:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `trait_impl_conflict`: + - impl trait_impl_conflict::Foo for isize; + +error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-cross-crate-conflict.rs:18:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to 2 previous errors + +Some errors occurred: E0119, E0210. +For more information about an error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-default-trait-impl.rs b/src/test/ui/compile-fail-migration/coherence-default-trait-impl.rs new file mode 100644 index 00000000000..751d0a14c57 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-default-trait-impl.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +auto trait MySafeTrait {} + +struct Foo; + +unsafe impl MySafeTrait for Foo {} +//~^ ERROR implementing the trait `MySafeTrait` is not unsafe + +unsafe auto trait MyUnsafeTrait {} + +impl MyUnsafeTrait for Foo {} +//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-default-trait-impl.stderr b/src/test/ui/compile-fail-migration/coherence-default-trait-impl.stderr new file mode 100644 index 00000000000..b7d9364f237 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-default-trait-impl.stderr @@ -0,0 +1,16 @@ +error[E0199]: implementing the trait `MySafeTrait` is not unsafe + --> $DIR/coherence-default-trait-impl.rs:17:1 + | +LL | unsafe impl MySafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration + --> $DIR/coherence-default-trait-impl.rs:22:1 + | +LL | impl MyUnsafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0199, E0200. +For more information about an error, try `rustc --explain E0199`. diff --git a/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.rs b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.rs new file mode 100644 index 00000000000..8bb9556fcc0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we give suitable error messages when the user attempts to +// impl a trait `Trait` for its own object type. + +// If the trait is not object-safe, we give a more tailored message +// because we're such schnuckels: +trait NotObjectSafe { fn eq(&self, other: Self); } +impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.stderr b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.stderr new file mode 100644 index 00000000000..5d62a86b96f --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait-object-safe.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `NotObjectSafe` cannot be made into an object + --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:17:6 + | +LL | impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 + | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object + | + = note: method `eq` references the `Self` type in its arguments or return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.rs b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.rs new file mode 100644 index 00000000000..cd75b0e34f2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we give suitable error messages when the user attempts to +// impl a trait `Trait` for its own object type. + +trait Foo { fn dummy(&self) { } } +trait Bar: Foo { } +trait Baz: Bar { } + +// Supertraits of Baz are not legal: +impl Foo for Baz { } //~ ERROR E0371 +impl Bar for Baz { } //~ ERROR E0371 +impl Baz for Baz { } //~ ERROR E0371 + +// But other random traits are: +trait Other { } +impl Other for Baz { } // OK, Other not a supertrait of Baz + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.stderr b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.stderr new file mode 100644 index 00000000000..26e702d1fde --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impl-trait-for-trait.stderr @@ -0,0 +1,21 @@ +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` + --> $DIR/coherence-impl-trait-for-trait.rs:19:1 + | +LL | impl Foo for Baz { } //~ ERROR E0371 + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` + --> $DIR/coherence-impl-trait-for-trait.rs:20:1 + | +LL | impl Bar for Baz { } //~ ERROR E0371 + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` + --> $DIR/coherence-impl-trait-for-trait.rs:21:1 + | +LL | impl Baz for Baz { } //~ ERROR E0371 + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0371`. diff --git a/src/test/ui/compile-fail-migration/coherence-impls-send.rs b/src/test/ui/compile-fail-migration/coherence-impls-send.rs new file mode 100644 index 00000000000..9caaee41aeb --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impls-send.rs @@ -0,0 +1,40 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(overlapping_marker_traits)] + +use std::marker::Copy; + +enum TestE { + A +} + +struct MyType; + +struct NotSync; +impl !Sync for NotSync {} + +unsafe impl Send for TestE {} +unsafe impl Send for MyType {} +unsafe impl Send for (MyType, MyType) {} +//~^ ERROR E0117 + +unsafe impl Send for &'static NotSync {} +//~^ ERROR E0321 + +unsafe impl Send for [MyType] {} +//~^ ERROR E0117 + +unsafe impl Send for &'static [NotSync] {} +//~^ ERROR E0117 + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/coherence-impls-send.stderr b/src/test/ui/compile-fail-migration/coherence-impls-send.stderr new file mode 100644 index 00000000000..4e7e228b23f --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impls-send.stderr @@ -0,0 +1,37 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:27:1 + | +LL | unsafe impl Send for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` + --> $DIR/coherence-impls-send.rs:30:1 + | +LL | unsafe impl Send for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:33:1 + | +LL | unsafe impl Send for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:36:1 + | +LL | unsafe impl Send for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 4 previous errors + +Some errors occurred: E0117, E0321. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/coherence-impls-sized.rs b/src/test/ui/compile-fail-migration/coherence-impls-sized.rs new file mode 100644 index 00000000000..60b5d14d158 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impls-sized.rs @@ -0,0 +1,46 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +use std::marker::Copy; + +enum TestE { + A +} + +struct MyType; + +struct NotSync; +impl !Sync for NotSync {} + +impl Sized for TestE {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed + +impl Sized for MyType {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed + +impl Sized for (MyType, MyType) {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed +//~| ERROR E0117 + +impl Sized for &'static NotSync {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed + +impl Sized for [MyType] {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed +//~| ERROR E0117 + +impl Sized for &'static [NotSync] {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed +//~| ERROR E0117 + +fn main() { +} diff --git a/src/test/ui/compile-fail-migration/coherence-impls-sized.stderr b/src/test/ui/compile-fail-migration/coherence-impls-sized.stderr new file mode 100644 index 00000000000..683fb0aaa68 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-impls-sized.stderr @@ -0,0 +1,67 @@ +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:24:1 + | +LL | impl Sized for TestE {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:27:1 + | +LL | impl Sized for MyType {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:30:1 + | +LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:34:1 + | +LL | impl Sized for &'static NotSync {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:37:1 + | +LL | impl Sized for [MyType] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:41:1 + | +LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:30:1 + | +LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:37:1 + | +LL | impl Sized for [MyType] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:41:1 + | +LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 9 previous errors + +Some errors occurred: E0117, E0322. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.rs b/src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.rs new file mode 100644 index 00000000000..5db901b5ba1 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.rs @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Formerly this ICEd with the following message: +// Tried to project an inherited associated type during coherence checking, +// which is currently not supported. +// +// No we expect to run into a more user-friendly cycle error instead. + +#![feature(specialization)] + +trait Trait { type Assoc; } +//~^ cycle detected + +impl Trait for Vec { + type Assoc = (); +} + +impl Trait for Vec {} + +impl Trait for String { + type Assoc = (); +} + +impl Trait< as Trait>::Assoc> for String {} + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.stderr b/src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.stderr new file mode 100644 index 00000000000..5dba448a963 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-inherited-assoc-ty-cycle-err.stderr @@ -0,0 +1,16 @@ +error[E0391]: cycle detected when processing `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:19:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + | + = note: ...which again requires processing `Trait`, completing the cycle +note: cycle used when coherence checking all impls of trait `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:19:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/compile-fail-migration/coherence-lone-type-parameter.rs b/src/test/ui/compile-fail-migration/coherence-lone-type-parameter.rs new file mode 100644 index 00000000000..e78f392b386 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-lone-type-parameter.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +impl Remote for T { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-lone-type-parameter.stderr b/src/test/ui/compile-fail-migration/coherence-lone-type-parameter.stderr new file mode 100644 index 00000000000..6389bc0e7ab --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-lone-type-parameter.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-lone-type-parameter.rs:16:1 + | +LL | impl Remote for T { } + | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-negative-impls-safe.rs b/src/test/ui/compile-fail-migration/coherence-negative-impls-safe.rs new file mode 100644 index 00000000000..1ae07b64685 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-negative-impls-safe.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] + +use std::marker::Send; + +struct TestType; + +unsafe impl !Send for TestType {} +//~^ ERROR negative impls cannot be unsafe + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-negative-impls-safe.stderr b/src/test/ui/compile-fail-migration/coherence-negative-impls-safe.stderr new file mode 100644 index 00000000000..7373f79942f --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-negative-impls-safe.stderr @@ -0,0 +1,9 @@ +error[E0198]: negative impls cannot be unsafe + --> $DIR/coherence-negative-impls-safe.rs:17:1 + | +LL | unsafe impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0198`. diff --git a/src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.rs b/src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.rs new file mode 100644 index 00000000000..47026cd32d4 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that you cannot *directly* dispatch on lifetime requirements + +trait MyTrait { fn foo() {} } + +impl MyTrait for T {} +impl MyTrait for T {} //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.stderr b/src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.stderr new file mode 100644 index 00000000000..669c5e3a4a6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-no-direct-lifetime-dispatch.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-no-direct-lifetime-dispatch.rs:16:1 + | +LL | impl MyTrait for T {} + | --------------------- first implementation here +LL | impl MyTrait for T {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-orphan.rs b/src/test/ui/compile-fail-migration/coherence-orphan.rs new file mode 100644 index 00000000000..80efc7b75e2 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-orphan.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_orphan_lib.rs + +#![feature(optin_builtin_traits)] + +extern crate coherence_orphan_lib as lib; + +use lib::TheTrait; + +struct TheType; + +impl TheTrait for isize { } +//~^ ERROR E0117 + +impl TheTrait for isize { } + +impl TheTrait for TheType { } + +impl !Send for Vec { } +//~^ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-orphan.stderr b/src/test/ui/compile-fail-migration/coherence-orphan.stderr new file mode 100644 index 00000000000..ee863533237 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-orphan.stderr @@ -0,0 +1,21 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:21:1 + | +LL | impl TheTrait for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:28:1 + | +LL | impl !Send for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.rs b/src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.rs new file mode 100644 index 00000000000..1fad608db6c --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that we detect an overlap here in the case where: +// +// for some type X: +// T = (X,) +// T11 = X, U11 = X +// +// Seems pretty basic, but then there was issue #24241. :) + +trait From { + fn foo() {} +} + +impl From for T { +} + +impl From<(U11,)> for (T11,) { //~ ERROR E0119 +} + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.stderr b/src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.stderr new file mode 100644 index 00000000000..993de789ef5 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-overlap-all-t-and-tuple.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`: + --> $DIR/coherence-overlap-all-t-and-tuple.rs:26:1 + | +LL | impl From for T { + | ---------------------- first implementation here +... +LL | impl From<(U11,)> for (T11,) { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-overlap-messages.rs b/src/test/ui/compile-fail-migration/coherence-overlap-messages.rs new file mode 100644 index 00000000000..a10deeafbe6 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-overlap-messages.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { fn foo() {} } + +impl Foo for T {} +impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: + +trait Bar { fn bar() {} } + +impl Bar for (T, u8) {} +impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: + +trait Baz { fn baz() {} } + +impl Baz for T {} +impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: + +trait Quux { fn quux() {} } + +impl Quux for T {} +impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: + +fn main() {} diff --git a/src/test/ui/compile-fail-migration/coherence-overlap-messages.stderr b/src/test/ui/compile-fail-migration/coherence-overlap-messages.stderr new file mode 100644 index 00000000000..60023c6c249 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-overlap-messages.stderr @@ -0,0 +1,44 @@ +error[E0119]: conflicting implementations of trait `Foo`: + --> $DIR/coherence-overlap-messages.rs:14:1 + | +LL | impl Foo for T {} + | ----------------- first implementation here +LL | impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: + | ^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: + --> $DIR/coherence-overlap-messages.rs:19:1 + | +LL | impl Bar for (T, u8) {} + | ----------------------- first implementation here +LL | impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` + +error[E0119]: conflicting implementations of trait `Baz` for type `u8`: + --> $DIR/coherence-overlap-messages.rs:24:1 + | +LL | impl Baz for T {} + | --------------------- first implementation here +LL | impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:29:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:30:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/compile-fail-migration/coherence-overlapping-pairs.rs b/src/test/ui/compile-fail-migration/coherence-overlapping-pairs.rs new file mode 100644 index 00000000000..ba9dc53e868 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-overlapping-pairs.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Foo; + +impl Remote for lib::Pair { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-overlapping-pairs.stderr b/src/test/ui/compile-fail-migration/coherence-overlapping-pairs.stderr new file mode 100644 index 00000000000..41d47888554 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-overlapping-pairs.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-overlapping-pairs.rs:18:1 + | +LL | impl Remote for lib::Pair { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.rs b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.rs new file mode 100644 index 00000000000..f55efef14fa --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the same coverage rules apply even if the local type appears in the +// list of type parameters, not the self type. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::{Remote1, Pair}; + +pub struct Local(T); + +impl Remote1>> for i32 { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.stderr b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.stderr new file mode 100644 index 00000000000..3545593fb6d --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered-1.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-pair-covered-uncovered-1.rs:21:1 + | +LL | impl Remote1>> for i32 { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.rs b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.rs new file mode 100644 index 00000000000..0642dff4b28 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::{Remote, Pair}; + +struct Local(T); + +impl Remote for Pair> { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.stderr b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.stderr new file mode 100644 index 00000000000..f58cb4648cb --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-pair-covered-uncovered.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-pair-covered-uncovered.rs:18:1 + | +LL | impl Remote for Pair> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.rs b/src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.rs new file mode 100644 index 00000000000..784ff0cd5e0 --- /dev/null +++ b/src/test/ui/compile-fail-migration/coherence-projection-conflict-orphan.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +// Here we expect a coherence conflict because, even though `i32` does +// not implement `Iterator`, we cannot rely on that negative reasoning +// due to the orphan rules. Therefore, `A::Item` may yet turn out to +// be `i32`. + +pub trait Foo