From e69748ba4f48efdc9a1dfcf8c16bc9aba39a86e3 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Thu, 16 Apr 2020 15:50:32 +0900 Subject: Move tests from `test/run-fail` to UI --- src/test/run-fail/args-panic.rs | 11 --- src/test/run-fail/assert-as-macro.rs | 5 -- src/test/run-fail/assert-eq-macro-panic.rs | 7 -- src/test/run-fail/assert-macro-explicit.rs | 5 -- src/test/run-fail/assert-macro-fmt.rs | 5 -- src/test/run-fail/assert-macro-owned.rs | 5 -- src/test/run-fail/assert-macro-static.rs | 5 -- src/test/run-fail/assert-ne-macro-panic.rs | 7 -- src/test/run-fail/binop-fail-3.rs | 9 --- src/test/run-fail/binop-panic.rs | 8 -- src/test/run-fail/borrowck-local-borrow.rs | 10 --- src/test/run-fail/bounds-check-no-overflow.rs | 9 --- .../run-fail/bug-2470-bounds-check-overflow.rs | 25 ------ src/test/run-fail/bug-811.rs | 24 ------ src/test/run-fail/die-macro-expr.rs | 5 -- src/test/run-fail/die-macro-pure.rs | 9 --- src/test/run-fail/die-macro.rs | 5 -- src/test/run-fail/diverging-closure.rs | 8 -- src/test/run-fail/divide-by-zero.rs | 6 -- src/test/run-fail/doublepanic.rs | 7 -- src/test/run-fail/dst-raw-slice.rs | 9 --- src/test/run-fail/explicit-panic-msg.rs | 11 --- src/test/run-fail/explicit-panic.rs | 4 - src/test/run-fail/expr-fn-panic.rs | 9 --- src/test/run-fail/expr-if-panic-fn.rs | 18 ----- src/test/run-fail/expr-if-panic.rs | 11 --- src/test/run-fail/expr-match-panic-fn.rs | 17 ---- src/test/run-fail/expr-match-panic.rs | 8 -- src/test/run-fail/fmt-panic.rs | 6 -- src/test/run-fail/for-each-loop-panic.rs | 7 -- src/test/run-fail/generator-resume-after-panic.rs | 22 ----- src/test/run-fail/glob-use-std.rs | 9 --- src/test/run-fail/hashmap-capacity-overflow.rs | 11 --- src/test/run-fail/if-check-panic.rs | 22 ----- src/test/run-fail/if-cond-bot.rs | 9 --- src/test/run-fail/issue-12920.rs | 6 -- src/test/run-fail/issue-13202.rs | 5 -- src/test/run-fail/issue-18576.rs | 13 --- src/test/run-fail/issue-20971.rs | 21 ----- src/test/run-fail/issue-23354-2.rs | 7 -- src/test/run-fail/issue-23354.rs | 6 -- src/test/run-fail/issue-2444.rs | 15 ---- src/test/run-fail/issue-2761.rs | 5 -- src/test/run-fail/issue-28934.rs | 23 ------ src/test/run-fail/issue-29798.rs | 9 --- src/test/run-fail/issue-3029.rs | 12 --- src/test/run-fail/issue-30380.rs | 34 -------- src/test/run-fail/issue-44216-add-instant.rs | 8 -- src/test/run-fail/issue-44216-add-system-time.rs | 8 -- src/test/run-fail/issue-44216-sub-instant.rs | 8 -- src/test/run-fail/issue-44216-sub-system-time.rs | 8 -- src/test/run-fail/issue-51345.rs | 6 -- src/test/run-fail/issue-6458-1.rs | 6 -- src/test/run-fail/issue-948.rs | 13 --- src/test/run-fail/main-panic.rs | 5 -- src/test/run-fail/match-bot-panic.rs | 14 ---- src/test/run-fail/match-disc-bot.rs | 13 --- src/test/run-fail/match-wildcards.rs | 18 ----- src/test/run-fail/meta-revision-bad.rs | 20 ----- src/test/run-fail/meta-revision-ok.rs | 19 ----- .../run-fail/mir_codegen_calls_converging_drops.rs | 24 ------ .../mir_codegen_calls_converging_drops_2.rs | 28 ------- src/test/run-fail/mir_codegen_calls_diverging.rs | 13 --- .../run-fail/mir_codegen_calls_diverging_drops.rs | 22 ----- src/test/run-fail/mir_drop_panics.rs | 22 ----- src/test/run-fail/mir_dynamic_drops_1.rs | 30 ------- src/test/run-fail/mir_dynamic_drops_2.rs | 28 ------- src/test/run-fail/mir_dynamic_drops_3.rs | 33 -------- src/test/run-fail/mir_indexing_oob_1.rs | 12 --- src/test/run-fail/mir_indexing_oob_2.rs | 12 --- src/test/run-fail/mir_indexing_oob_3.rs | 12 --- src/test/run-fail/mod-zero.rs | 6 -- src/test/run-fail/overflowing-add.rs | 8 -- src/test/run-fail/overflowing-lsh-1.rs | 9 --- src/test/run-fail/overflowing-lsh-2.rs | 9 --- src/test/run-fail/overflowing-lsh-3.rs | 9 --- src/test/run-fail/overflowing-lsh-4.rs | 24 ------ src/test/run-fail/overflowing-mul.rs | 8 -- src/test/run-fail/overflowing-neg.rs | 8 -- src/test/run-fail/overflowing-pow-signed.rs | 6 -- src/test/run-fail/overflowing-pow-unsigned.rs | 6 -- src/test/run-fail/overflowing-rsh-1.rs | 9 --- src/test/run-fail/overflowing-rsh-2.rs | 9 --- src/test/run-fail/overflowing-rsh-3.rs | 9 --- src/test/run-fail/overflowing-rsh-4.rs | 24 ------ src/test/run-fail/overflowing-rsh-5.rs | 9 --- src/test/run-fail/overflowing-rsh-6.rs | 10 --- src/test/run-fail/overflowing-sub.rs | 8 -- src/test/run-fail/panic-arg.rs | 8 -- src/test/run-fail/panic-macro-any-wrapped.rs | 5 -- src/test/run-fail/panic-macro-any.rs | 7 -- src/test/run-fail/panic-macro-explicit.rs | 5 -- src/test/run-fail/panic-macro-fmt.rs | 5 -- src/test/run-fail/panic-macro-owned.rs | 5 -- src/test/run-fail/panic-macro-static.rs | 5 -- src/test/run-fail/panic-main.rs | 4 - src/test/run-fail/panic-parens.rs | 17 ---- src/test/run-fail/panic-set-handler.rs | 10 --- src/test/run-fail/panic-set-unset-handler.rs | 11 --- src/test/run-fail/panic-take-handler-nop.rs | 8 -- src/test/run-fail/panic-task-name-none.rs | 12 --- src/test/run-fail/panic-task-name-owned.rs | 17 ---- src/test/run-fail/panic.rs | 4 - src/test/run-fail/promoted_div_by_zero.rs | 7 -- src/test/run-fail/promoted_overflow.rs | 8 -- src/test/run-fail/result-get-panic.rs | 7 -- src/test/run-fail/return-never-coerce.rs | 16 ---- .../termination-trait-for-box-dyn-error.rs | 9 --- .../termination-trait-for-never.rs | 5 -- .../termination-trait-for-result-box-error_err.rs | 8 -- .../termination-trait-for-str.rs | 6 -- src/test/run-fail/rhs-type.rs | 15 ---- src/test/run-fail/run-unexported-tests.rs | 12 --- src/test/run-fail/str-overrun.rs | 7 -- src/test/run-fail/task-spawn-barefn.rs | 17 ---- src/test/run-fail/test-panic.rs | 9 --- src/test/run-fail/test-should-fail-bad-message.rs | 10 --- src/test/run-fail/test-should-panic-bad-message.rs | 9 --- src/test/run-fail/test-should-panic-no-message.rs | 9 --- src/test/run-fail/test-tasks-invalid-value.rs | 10 --- src/test/run-fail/tls-exit-status.rs | 10 --- src/test/run-fail/unimplemented-macro-panic.rs | 4 - src/test/run-fail/unique-panic.rs | 5 -- src/test/run-fail/unreachable-fmt-msg.rs | 4 - src/test/run-fail/unreachable-macro-panic.rs | 4 - src/test/run-fail/unreachable-static-msg.rs | 4 - src/test/run-fail/unreachable.rs | 4 - src/test/run-fail/unwind-interleaved.rs | 14 ---- src/test/run-fail/unwind-rec.rs | 14 ---- src/test/run-fail/unwind-rec2.rs | 22 ----- src/test/run-fail/unwind-unique.rs | 10 --- src/test/run-fail/vec-overrun.rs | 11 --- src/test/run-fail/while-body-panics.rs | 11 --- src/test/run-fail/while-panic.rs | 11 --- .../ui/array-slice-vec/bounds-check-no-overflow.rs | 10 +++ src/test/ui/array-slice-vec/dst-raw-slice.rs | 11 +++ src/test/ui/binop/binop-fail-3.rs | 10 +++ src/test/ui/binop/binop-panic.rs | 11 +++ src/test/ui/borrowck/borrowck-local-borrow.rs | 11 +++ src/test/ui/closures/diverging-closure.rs | 9 +++ src/test/ui/consts/promoted_div_by_zero.rs | 8 ++ src/test/ui/fn/expr-fn-panic.rs | 10 +++ .../ui/generator/generator-resume-after-panic.rs | 23 ++++++ src/test/ui/hashmap-iter-value-lifetime.nll.stderr | 15 ---- src/test/ui/hashmap-iter-value-lifetime.rs | 10 --- src/test/ui/hashmap-iter-value-lifetime.stderr | 15 ---- src/test/ui/hashmap-lifetimes.nll.stderr | 13 --- src/test/ui/hashmap-lifetimes.rs | 8 -- src/test/ui/hashmap-lifetimes.stderr | 13 --- src/test/ui/hashmap-memory.rs | 94 ---------------------- src/test/ui/hashmap/hashmap-capacity-overflow.rs | 12 +++ .../hashmap/hashmap-iter-value-lifetime.nll.stderr | 15 ++++ src/test/ui/hashmap/hashmap-iter-value-lifetime.rs | 10 +++ .../ui/hashmap/hashmap-iter-value-lifetime.stderr | 15 ++++ src/test/ui/hashmap/hashmap-lifetimes.nll.stderr | 13 +++ src/test/ui/hashmap/hashmap-lifetimes.rs | 8 ++ src/test/ui/hashmap/hashmap-lifetimes.stderr | 13 +++ src/test/ui/hashmap/hashmap-memory.rs | 94 ++++++++++++++++++++++ src/test/ui/if/expr-if-panic-fn.rs | 19 +++++ src/test/ui/if/expr-if-panic.rs | 12 +++ src/test/ui/if/if-check-panic.rs | 24 ++++++ src/test/ui/if/if-cond-bot.rs | 12 +++ src/test/ui/imports/glob-use-std.rs | 10 +++ src/test/ui/issues/issue-12920.rs | 7 ++ src/test/ui/issues/issue-13202.rs | 6 ++ src/test/ui/issues/issue-18576.rs | 15 ++++ src/test/ui/issues/issue-20971.rs | 22 +++++ src/test/ui/issues/issue-23354-2.rs | 8 ++ src/test/ui/issues/issue-23354.rs | 7 ++ src/test/ui/issues/issue-2444.rs | 16 ++++ .../ui/issues/issue-2470-bounds-check-overflow.rs | 26 ++++++ src/test/ui/issues/issue-2761.rs | 6 ++ src/test/ui/issues/issue-28934.rs | 24 ++++++ src/test/ui/issues/issue-29798.rs | 10 +++ src/test/ui/issues/issue-3029.rs | 13 +++ src/test/ui/issues/issue-30380.rs | 35 ++++++++ src/test/ui/issues/issue-44216-add-instant.rs | 9 +++ src/test/ui/issues/issue-44216-add-system-time.rs | 9 +++ src/test/ui/issues/issue-44216-sub-instant.rs | 9 +++ src/test/ui/issues/issue-44216-sub-system-time.rs | 9 +++ src/test/ui/issues/issue-51345-2.rs | 7 ++ src/test/ui/issues/issue-6458-1.rs | 7 ++ src/test/ui/issues/issue-811.rs | 25 ++++++ src/test/ui/issues/issue-948.rs | 14 ++++ src/test/ui/loops/for-each-loop-panic.rs | 8 ++ src/test/ui/macros/assert-as-macro.rs | 6 ++ src/test/ui/macros/assert-eq-macro-panic.rs | 8 ++ src/test/ui/macros/assert-macro-explicit.rs | 6 ++ src/test/ui/macros/assert-macro-fmt.rs | 6 ++ src/test/ui/macros/assert-macro-owned.rs | 6 ++ src/test/ui/macros/assert-macro-static.rs | 6 ++ src/test/ui/macros/assert-ne-macro-panic.rs | 8 ++ src/test/ui/macros/die-macro-2.rs | 6 ++ src/test/ui/macros/die-macro-expr.rs | 6 ++ src/test/ui/macros/die-macro-pure.rs | 10 +++ src/test/ui/macros/unimplemented-macro-panic.rs | 6 ++ src/test/ui/macros/unreachable-fmt-msg.rs | 6 ++ src/test/ui/macros/unreachable-macro-panic.rs | 6 ++ src/test/ui/macros/unreachable-static-msg.rs | 6 ++ src/test/ui/macros/unreachable.rs | 6 ++ src/test/ui/match/expr-match-panic-fn.rs | 18 +++++ src/test/ui/match/expr-match-panic.rs | 9 +++ src/test/ui/match/match-bot-panic.rs | 15 ++++ src/test/ui/match/match-disc-bot.rs | 15 ++++ src/test/ui/match/match-wildcards.rs | 20 +++++ src/test/ui/meta-revision-bad.rs | 21 +++++ src/test/ui/meta-revision-ok.rs | 20 +++++ .../ui/mir/mir_codegen_calls_converging_drops.rs | 25 ++++++ .../ui/mir/mir_codegen_calls_converging_drops_2.rs | 29 +++++++ src/test/ui/mir/mir_codegen_calls_diverging.rs | 14 ++++ .../ui/mir/mir_codegen_calls_diverging_drops.rs | 23 ++++++ src/test/ui/mir/mir_drop_panics.rs | 23 ++++++ src/test/ui/mir/mir_dynamic_drops_1.rs | 31 +++++++ src/test/ui/mir/mir_dynamic_drops_2.rs | 29 +++++++ src/test/ui/mir/mir_dynamic_drops_3.rs | 34 ++++++++ src/test/ui/mir/mir_indexing_oob_1.rs | 13 +++ src/test/ui/mir/mir_indexing_oob_2.rs | 13 +++ src/test/ui/mir/mir_indexing_oob_3.rs | 13 +++ src/test/ui/never_type/return-never-coerce.rs | 17 ++++ src/test/ui/numbers-arithmetic/divide-by-zero.rs | 7 ++ src/test/ui/numbers-arithmetic/mod-zero.rs | 7 ++ src/test/ui/numbers-arithmetic/overflowing-add.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-lsh-1.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-lsh-1.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-lsh-2.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-lsh-2.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-lsh-3.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-lsh-3.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-lsh-4.rs | 24 ++++++ .../ui/numbers-arithmetic/overflowing-lsh-4.stderr | 14 ++++ src/test/ui/numbers-arithmetic/overflowing-mul.rs | 9 +++ src/test/ui/numbers-arithmetic/overflowing-neg.rs | 9 +++ .../numbers-arithmetic/overflowing-pow-signed.rs | 7 ++ .../numbers-arithmetic/overflowing-pow-unsigned.rs | 7 ++ .../ui/numbers-arithmetic/overflowing-rsh-1.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-rsh-1.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-rsh-2.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-rsh-2.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-rsh-3.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-rsh-3.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-rsh-4.rs | 24 ++++++ .../ui/numbers-arithmetic/overflowing-rsh-4.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-rsh-5.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-rsh-5.stderr | 14 ++++ .../ui/numbers-arithmetic/overflowing-rsh-6.rs | 9 +++ .../ui/numbers-arithmetic/overflowing-rsh-6.stderr | 14 ++++ src/test/ui/numbers-arithmetic/overflowing-sub.rs | 9 +++ .../ui/numbers-arithmetic/promoted_overflow.rs | 9 +++ src/test/ui/panic-runtime/unwind-interleaved.rs | 15 ++++ src/test/ui/panic-runtime/unwind-rec.rs | 14 ++++ src/test/ui/panic-runtime/unwind-rec2.rs | 22 +++++ src/test/ui/panic-runtime/unwind-unique.rs | 11 +++ src/test/ui/panics/args-panic.rs | 12 +++ src/test/ui/panics/doublepanic.rs | 9 +++ src/test/ui/panics/explicit-panic-msg.rs | 13 +++ src/test/ui/panics/explicit-panic.rs | 6 ++ src/test/ui/panics/fmt-panic.rs | 7 ++ src/test/ui/panics/main-panic.rs | 6 ++ src/test/ui/panics/panic-arg.rs | 10 +++ src/test/ui/panics/panic-macro-any-wrapped.rs | 6 ++ src/test/ui/panics/panic-macro-any.rs | 8 ++ src/test/ui/panics/panic-macro-explicit.rs | 6 ++ src/test/ui/panics/panic-macro-fmt.rs | 6 ++ src/test/ui/panics/panic-macro-owned.rs | 6 ++ src/test/ui/panics/panic-macro-static.rs | 6 ++ src/test/ui/panics/panic-main.rs | 6 ++ src/test/ui/panics/panic-parens.rs | 18 +++++ src/test/ui/panics/panic-set-handler.rs | 11 +++ src/test/ui/panics/panic-set-unset-handler.rs | 12 +++ src/test/ui/panics/panic-take-handler-nop.rs | 9 +++ src/test/ui/panics/panic-task-name-none.rs | 13 +++ src/test/ui/panics/panic-task-name-owned.rs | 18 +++++ src/test/ui/panics/panic.rs | 6 ++ src/test/ui/panics/result-get-panic.rs | 8 ++ src/test/ui/panics/test-panic.rs | 9 +++ src/test/ui/panics/test-should-fail-bad-message.rs | 10 +++ .../ui/panics/test-should-panic-bad-message.rs | 9 +++ src/test/ui/panics/test-should-panic-no-message.rs | 9 +++ src/test/ui/panics/unique-panic.rs | 6 ++ src/test/ui/panics/while-body-panics.rs | 13 +++ src/test/ui/panics/while-panic.rs | 13 +++ src/test/ui/process/tls-exit-status.rs | 11 +++ .../termination-trait-for-box-dyn-error.rs | 10 +++ .../termination-trait-for-never.rs | 6 ++ .../termination-trait-for-result-box-error_err.rs | 9 +++ .../termination-trait-for-str.rs | 7 ++ src/test/ui/str/str-overrun.rs | 9 +++ src/test/ui/structs/rhs-type.rs | 17 ++++ src/test/ui/test-attrs/run-unexported-tests.rs | 12 +++ src/test/ui/threads-sendsync/task-spawn-barefn.rs | 18 +++++ .../threads-sendsync/test-tasks-invalid-value.rs | 11 +++ src/test/ui/vec/vec-overrun.rs | 11 +++ 292 files changed, 1919 insertions(+), 1640 deletions(-) delete mode 100644 src/test/run-fail/args-panic.rs delete mode 100644 src/test/run-fail/assert-as-macro.rs delete mode 100644 src/test/run-fail/assert-eq-macro-panic.rs delete mode 100644 src/test/run-fail/assert-macro-explicit.rs delete mode 100644 src/test/run-fail/assert-macro-fmt.rs delete mode 100644 src/test/run-fail/assert-macro-owned.rs delete mode 100644 src/test/run-fail/assert-macro-static.rs delete mode 100644 src/test/run-fail/assert-ne-macro-panic.rs delete mode 100644 src/test/run-fail/binop-fail-3.rs delete mode 100644 src/test/run-fail/binop-panic.rs delete mode 100644 src/test/run-fail/borrowck-local-borrow.rs delete mode 100644 src/test/run-fail/bounds-check-no-overflow.rs delete mode 100644 src/test/run-fail/bug-2470-bounds-check-overflow.rs delete mode 100644 src/test/run-fail/bug-811.rs delete mode 100644 src/test/run-fail/die-macro-expr.rs delete mode 100644 src/test/run-fail/die-macro-pure.rs delete mode 100644 src/test/run-fail/die-macro.rs delete mode 100644 src/test/run-fail/diverging-closure.rs delete mode 100644 src/test/run-fail/divide-by-zero.rs delete mode 100644 src/test/run-fail/doublepanic.rs delete mode 100644 src/test/run-fail/dst-raw-slice.rs delete mode 100644 src/test/run-fail/explicit-panic-msg.rs delete mode 100644 src/test/run-fail/explicit-panic.rs delete mode 100644 src/test/run-fail/expr-fn-panic.rs delete mode 100644 src/test/run-fail/expr-if-panic-fn.rs delete mode 100644 src/test/run-fail/expr-if-panic.rs delete mode 100644 src/test/run-fail/expr-match-panic-fn.rs delete mode 100644 src/test/run-fail/expr-match-panic.rs delete mode 100644 src/test/run-fail/fmt-panic.rs delete mode 100644 src/test/run-fail/for-each-loop-panic.rs delete mode 100644 src/test/run-fail/generator-resume-after-panic.rs delete mode 100644 src/test/run-fail/glob-use-std.rs delete mode 100644 src/test/run-fail/hashmap-capacity-overflow.rs delete mode 100644 src/test/run-fail/if-check-panic.rs delete mode 100644 src/test/run-fail/if-cond-bot.rs delete mode 100644 src/test/run-fail/issue-12920.rs delete mode 100644 src/test/run-fail/issue-13202.rs delete mode 100644 src/test/run-fail/issue-18576.rs delete mode 100644 src/test/run-fail/issue-20971.rs delete mode 100644 src/test/run-fail/issue-23354-2.rs delete mode 100644 src/test/run-fail/issue-23354.rs delete mode 100644 src/test/run-fail/issue-2444.rs delete mode 100644 src/test/run-fail/issue-2761.rs delete mode 100644 src/test/run-fail/issue-28934.rs delete mode 100644 src/test/run-fail/issue-29798.rs delete mode 100644 src/test/run-fail/issue-3029.rs delete mode 100644 src/test/run-fail/issue-30380.rs delete mode 100644 src/test/run-fail/issue-44216-add-instant.rs delete mode 100644 src/test/run-fail/issue-44216-add-system-time.rs delete mode 100644 src/test/run-fail/issue-44216-sub-instant.rs delete mode 100644 src/test/run-fail/issue-44216-sub-system-time.rs delete mode 100644 src/test/run-fail/issue-51345.rs delete mode 100644 src/test/run-fail/issue-6458-1.rs delete mode 100644 src/test/run-fail/issue-948.rs delete mode 100644 src/test/run-fail/main-panic.rs delete mode 100644 src/test/run-fail/match-bot-panic.rs delete mode 100644 src/test/run-fail/match-disc-bot.rs delete mode 100644 src/test/run-fail/match-wildcards.rs delete mode 100644 src/test/run-fail/meta-revision-bad.rs delete mode 100644 src/test/run-fail/meta-revision-ok.rs delete mode 100644 src/test/run-fail/mir_codegen_calls_converging_drops.rs delete mode 100644 src/test/run-fail/mir_codegen_calls_converging_drops_2.rs delete mode 100644 src/test/run-fail/mir_codegen_calls_diverging.rs delete mode 100644 src/test/run-fail/mir_codegen_calls_diverging_drops.rs delete mode 100644 src/test/run-fail/mir_drop_panics.rs delete mode 100644 src/test/run-fail/mir_dynamic_drops_1.rs delete mode 100644 src/test/run-fail/mir_dynamic_drops_2.rs delete mode 100644 src/test/run-fail/mir_dynamic_drops_3.rs delete mode 100644 src/test/run-fail/mir_indexing_oob_1.rs delete mode 100644 src/test/run-fail/mir_indexing_oob_2.rs delete mode 100644 src/test/run-fail/mir_indexing_oob_3.rs delete mode 100644 src/test/run-fail/mod-zero.rs delete mode 100644 src/test/run-fail/overflowing-add.rs delete mode 100644 src/test/run-fail/overflowing-lsh-1.rs delete mode 100644 src/test/run-fail/overflowing-lsh-2.rs delete mode 100644 src/test/run-fail/overflowing-lsh-3.rs delete mode 100644 src/test/run-fail/overflowing-lsh-4.rs delete mode 100644 src/test/run-fail/overflowing-mul.rs delete mode 100644 src/test/run-fail/overflowing-neg.rs delete mode 100644 src/test/run-fail/overflowing-pow-signed.rs delete mode 100644 src/test/run-fail/overflowing-pow-unsigned.rs delete mode 100644 src/test/run-fail/overflowing-rsh-1.rs delete mode 100644 src/test/run-fail/overflowing-rsh-2.rs delete mode 100644 src/test/run-fail/overflowing-rsh-3.rs delete mode 100644 src/test/run-fail/overflowing-rsh-4.rs delete mode 100644 src/test/run-fail/overflowing-rsh-5.rs delete mode 100644 src/test/run-fail/overflowing-rsh-6.rs delete mode 100644 src/test/run-fail/overflowing-sub.rs delete mode 100644 src/test/run-fail/panic-arg.rs delete mode 100644 src/test/run-fail/panic-macro-any-wrapped.rs delete mode 100644 src/test/run-fail/panic-macro-any.rs delete mode 100644 src/test/run-fail/panic-macro-explicit.rs delete mode 100644 src/test/run-fail/panic-macro-fmt.rs delete mode 100644 src/test/run-fail/panic-macro-owned.rs delete mode 100644 src/test/run-fail/panic-macro-static.rs delete mode 100644 src/test/run-fail/panic-main.rs delete mode 100644 src/test/run-fail/panic-parens.rs delete mode 100644 src/test/run-fail/panic-set-handler.rs delete mode 100644 src/test/run-fail/panic-set-unset-handler.rs delete mode 100644 src/test/run-fail/panic-take-handler-nop.rs delete mode 100644 src/test/run-fail/panic-task-name-none.rs delete mode 100644 src/test/run-fail/panic-task-name-owned.rs delete mode 100644 src/test/run-fail/panic.rs delete mode 100644 src/test/run-fail/promoted_div_by_zero.rs delete mode 100644 src/test/run-fail/promoted_overflow.rs delete mode 100644 src/test/run-fail/result-get-panic.rs delete mode 100644 src/test/run-fail/return-never-coerce.rs delete mode 100644 src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs delete mode 100644 src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-never.rs delete mode 100644 src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs delete mode 100644 src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-str.rs delete mode 100644 src/test/run-fail/rhs-type.rs delete mode 100644 src/test/run-fail/run-unexported-tests.rs delete mode 100644 src/test/run-fail/str-overrun.rs delete mode 100644 src/test/run-fail/task-spawn-barefn.rs delete mode 100644 src/test/run-fail/test-panic.rs delete mode 100644 src/test/run-fail/test-should-fail-bad-message.rs delete mode 100644 src/test/run-fail/test-should-panic-bad-message.rs delete mode 100644 src/test/run-fail/test-should-panic-no-message.rs delete mode 100644 src/test/run-fail/test-tasks-invalid-value.rs delete mode 100644 src/test/run-fail/tls-exit-status.rs delete mode 100644 src/test/run-fail/unimplemented-macro-panic.rs delete mode 100644 src/test/run-fail/unique-panic.rs delete mode 100644 src/test/run-fail/unreachable-fmt-msg.rs delete mode 100644 src/test/run-fail/unreachable-macro-panic.rs delete mode 100644 src/test/run-fail/unreachable-static-msg.rs delete mode 100644 src/test/run-fail/unreachable.rs delete mode 100644 src/test/run-fail/unwind-interleaved.rs delete mode 100644 src/test/run-fail/unwind-rec.rs delete mode 100644 src/test/run-fail/unwind-rec2.rs delete mode 100644 src/test/run-fail/unwind-unique.rs delete mode 100644 src/test/run-fail/vec-overrun.rs delete mode 100644 src/test/run-fail/while-body-panics.rs delete mode 100644 src/test/run-fail/while-panic.rs create mode 100644 src/test/ui/array-slice-vec/bounds-check-no-overflow.rs create mode 100644 src/test/ui/array-slice-vec/dst-raw-slice.rs create mode 100644 src/test/ui/binop/binop-fail-3.rs create mode 100644 src/test/ui/binop/binop-panic.rs create mode 100644 src/test/ui/borrowck/borrowck-local-borrow.rs create mode 100644 src/test/ui/closures/diverging-closure.rs create mode 100644 src/test/ui/consts/promoted_div_by_zero.rs create mode 100644 src/test/ui/fn/expr-fn-panic.rs create mode 100644 src/test/ui/generator/generator-resume-after-panic.rs delete mode 100644 src/test/ui/hashmap-iter-value-lifetime.nll.stderr delete mode 100644 src/test/ui/hashmap-iter-value-lifetime.rs delete mode 100644 src/test/ui/hashmap-iter-value-lifetime.stderr delete mode 100644 src/test/ui/hashmap-lifetimes.nll.stderr delete mode 100644 src/test/ui/hashmap-lifetimes.rs delete mode 100644 src/test/ui/hashmap-lifetimes.stderr delete mode 100644 src/test/ui/hashmap-memory.rs create mode 100644 src/test/ui/hashmap/hashmap-capacity-overflow.rs create mode 100644 src/test/ui/hashmap/hashmap-iter-value-lifetime.nll.stderr create mode 100644 src/test/ui/hashmap/hashmap-iter-value-lifetime.rs create mode 100644 src/test/ui/hashmap/hashmap-iter-value-lifetime.stderr create mode 100644 src/test/ui/hashmap/hashmap-lifetimes.nll.stderr create mode 100644 src/test/ui/hashmap/hashmap-lifetimes.rs create mode 100644 src/test/ui/hashmap/hashmap-lifetimes.stderr create mode 100644 src/test/ui/hashmap/hashmap-memory.rs create mode 100644 src/test/ui/if/expr-if-panic-fn.rs create mode 100644 src/test/ui/if/expr-if-panic.rs create mode 100644 src/test/ui/if/if-check-panic.rs create mode 100644 src/test/ui/if/if-cond-bot.rs create mode 100644 src/test/ui/imports/glob-use-std.rs create mode 100644 src/test/ui/issues/issue-12920.rs create mode 100644 src/test/ui/issues/issue-13202.rs create mode 100644 src/test/ui/issues/issue-18576.rs create mode 100644 src/test/ui/issues/issue-20971.rs create mode 100644 src/test/ui/issues/issue-23354-2.rs create mode 100644 src/test/ui/issues/issue-23354.rs create mode 100644 src/test/ui/issues/issue-2444.rs create mode 100644 src/test/ui/issues/issue-2470-bounds-check-overflow.rs create mode 100644 src/test/ui/issues/issue-2761.rs create mode 100644 src/test/ui/issues/issue-28934.rs create mode 100644 src/test/ui/issues/issue-29798.rs create mode 100644 src/test/ui/issues/issue-3029.rs create mode 100644 src/test/ui/issues/issue-30380.rs create mode 100644 src/test/ui/issues/issue-44216-add-instant.rs create mode 100644 src/test/ui/issues/issue-44216-add-system-time.rs create mode 100644 src/test/ui/issues/issue-44216-sub-instant.rs create mode 100644 src/test/ui/issues/issue-44216-sub-system-time.rs create mode 100644 src/test/ui/issues/issue-51345-2.rs create mode 100644 src/test/ui/issues/issue-6458-1.rs create mode 100644 src/test/ui/issues/issue-811.rs create mode 100644 src/test/ui/issues/issue-948.rs create mode 100644 src/test/ui/loops/for-each-loop-panic.rs create mode 100644 src/test/ui/macros/assert-as-macro.rs create mode 100644 src/test/ui/macros/assert-eq-macro-panic.rs create mode 100644 src/test/ui/macros/assert-macro-explicit.rs create mode 100644 src/test/ui/macros/assert-macro-fmt.rs create mode 100644 src/test/ui/macros/assert-macro-owned.rs create mode 100644 src/test/ui/macros/assert-macro-static.rs create mode 100644 src/test/ui/macros/assert-ne-macro-panic.rs create mode 100644 src/test/ui/macros/die-macro-2.rs create mode 100644 src/test/ui/macros/die-macro-expr.rs create mode 100644 src/test/ui/macros/die-macro-pure.rs create mode 100644 src/test/ui/macros/unimplemented-macro-panic.rs create mode 100644 src/test/ui/macros/unreachable-fmt-msg.rs create mode 100644 src/test/ui/macros/unreachable-macro-panic.rs create mode 100644 src/test/ui/macros/unreachable-static-msg.rs create mode 100644 src/test/ui/macros/unreachable.rs create mode 100644 src/test/ui/match/expr-match-panic-fn.rs create mode 100644 src/test/ui/match/expr-match-panic.rs create mode 100644 src/test/ui/match/match-bot-panic.rs create mode 100644 src/test/ui/match/match-disc-bot.rs create mode 100644 src/test/ui/match/match-wildcards.rs create mode 100644 src/test/ui/meta-revision-bad.rs create mode 100644 src/test/ui/meta-revision-ok.rs create mode 100644 src/test/ui/mir/mir_codegen_calls_converging_drops.rs create mode 100644 src/test/ui/mir/mir_codegen_calls_converging_drops_2.rs create mode 100644 src/test/ui/mir/mir_codegen_calls_diverging.rs create mode 100644 src/test/ui/mir/mir_codegen_calls_diverging_drops.rs create mode 100644 src/test/ui/mir/mir_drop_panics.rs create mode 100644 src/test/ui/mir/mir_dynamic_drops_1.rs create mode 100644 src/test/ui/mir/mir_dynamic_drops_2.rs create mode 100644 src/test/ui/mir/mir_dynamic_drops_3.rs create mode 100644 src/test/ui/mir/mir_indexing_oob_1.rs create mode 100644 src/test/ui/mir/mir_indexing_oob_2.rs create mode 100644 src/test/ui/mir/mir_indexing_oob_3.rs create mode 100644 src/test/ui/never_type/return-never-coerce.rs create mode 100644 src/test/ui/numbers-arithmetic/divide-by-zero.rs create mode 100644 src/test/ui/numbers-arithmetic/mod-zero.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-add.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-1.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-1.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-2.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-2.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-3.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-3.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-4.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-lsh-4.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-mul.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-neg.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-pow-signed.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-pow-unsigned.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-1.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-1.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-2.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-2.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-3.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-3.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-4.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-4.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-5.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-5.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-6.rs create mode 100644 src/test/ui/numbers-arithmetic/overflowing-rsh-6.stderr create mode 100644 src/test/ui/numbers-arithmetic/overflowing-sub.rs create mode 100644 src/test/ui/numbers-arithmetic/promoted_overflow.rs create mode 100644 src/test/ui/panic-runtime/unwind-interleaved.rs create mode 100644 src/test/ui/panic-runtime/unwind-rec.rs create mode 100644 src/test/ui/panic-runtime/unwind-rec2.rs create mode 100644 src/test/ui/panic-runtime/unwind-unique.rs create mode 100644 src/test/ui/panics/args-panic.rs create mode 100644 src/test/ui/panics/doublepanic.rs create mode 100644 src/test/ui/panics/explicit-panic-msg.rs create mode 100644 src/test/ui/panics/explicit-panic.rs create mode 100644 src/test/ui/panics/fmt-panic.rs create mode 100644 src/test/ui/panics/main-panic.rs create mode 100644 src/test/ui/panics/panic-arg.rs create mode 100644 src/test/ui/panics/panic-macro-any-wrapped.rs create mode 100644 src/test/ui/panics/panic-macro-any.rs create mode 100644 src/test/ui/panics/panic-macro-explicit.rs create mode 100644 src/test/ui/panics/panic-macro-fmt.rs create mode 100644 src/test/ui/panics/panic-macro-owned.rs create mode 100644 src/test/ui/panics/panic-macro-static.rs create mode 100644 src/test/ui/panics/panic-main.rs create mode 100644 src/test/ui/panics/panic-parens.rs create mode 100644 src/test/ui/panics/panic-set-handler.rs create mode 100644 src/test/ui/panics/panic-set-unset-handler.rs create mode 100644 src/test/ui/panics/panic-take-handler-nop.rs create mode 100644 src/test/ui/panics/panic-task-name-none.rs create mode 100644 src/test/ui/panics/panic-task-name-owned.rs create mode 100644 src/test/ui/panics/panic.rs create mode 100644 src/test/ui/panics/result-get-panic.rs create mode 100644 src/test/ui/panics/test-panic.rs create mode 100644 src/test/ui/panics/test-should-fail-bad-message.rs create mode 100644 src/test/ui/panics/test-should-panic-bad-message.rs create mode 100644 src/test/ui/panics/test-should-panic-no-message.rs create mode 100644 src/test/ui/panics/unique-panic.rs create mode 100644 src/test/ui/panics/while-body-panics.rs create mode 100644 src/test/ui/panics/while-panic.rs create mode 100644 src/test/ui/process/tls-exit-status.rs create mode 100644 src/test/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs create mode 100644 src/test/ui/rfc-1937-termination-trait/termination-trait-for-never.rs create mode 100644 src/test/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs create mode 100644 src/test/ui/rfc-1937-termination-trait/termination-trait-for-str.rs create mode 100644 src/test/ui/str/str-overrun.rs create mode 100644 src/test/ui/structs/rhs-type.rs create mode 100644 src/test/ui/test-attrs/run-unexported-tests.rs create mode 100644 src/test/ui/threads-sendsync/task-spawn-barefn.rs create mode 100644 src/test/ui/threads-sendsync/test-tasks-invalid-value.rs create mode 100644 src/test/ui/vec/vec-overrun.rs (limited to 'src') diff --git a/src/test/run-fail/args-panic.rs b/src/test/run-fail/args-panic.rs deleted file mode 100644 index 9a62652dde1..00000000000 --- a/src/test/run-fail/args-panic.rs +++ /dev/null @@ -1,11 +0,0 @@ -// error-pattern:meep - -#![feature(box_syntax)] - -fn f(_a: isize, _b: isize, _c: Box) { - panic!("moop"); -} - -fn main() { - f(1, panic!("meep"), box 42); -} diff --git a/src/test/run-fail/assert-as-macro.rs b/src/test/run-fail/assert-as-macro.rs deleted file mode 100644 index f715e21f781..00000000000 --- a/src/test/run-fail/assert-as-macro.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:assertion failed: 1 == 2 - -fn main() { - assert!(1 == 2); -} diff --git a/src/test/run-fail/assert-eq-macro-panic.rs b/src/test/run-fail/assert-eq-macro-panic.rs deleted file mode 100644 index 863fec12d74..00000000000 --- a/src/test/run-fail/assert-eq-macro-panic.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:assertion failed: `(left == right)` -// error-pattern: left: `14` -// error-pattern:right: `15` - -fn main() { - assert_eq!(14, 15); -} diff --git a/src/test/run-fail/assert-macro-explicit.rs b/src/test/run-fail/assert-macro-explicit.rs deleted file mode 100644 index 3689323c999..00000000000 --- a/src/test/run-fail/assert-macro-explicit.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'assertion failed: false' - -fn main() { - assert!(false); -} diff --git a/src/test/run-fail/assert-macro-fmt.rs b/src/test/run-fail/assert-macro-fmt.rs deleted file mode 100644 index 9fbfb085c2f..00000000000 --- a/src/test/run-fail/assert-macro-fmt.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'test-assert-fmt 42 rust' - -fn main() { - assert!(false, "test-assert-fmt {} {}", 42, "rust"); -} diff --git a/src/test/run-fail/assert-macro-owned.rs b/src/test/run-fail/assert-macro-owned.rs deleted file mode 100644 index bd58d35eb71..00000000000 --- a/src/test/run-fail/assert-macro-owned.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'test-assert-owned' - -fn main() { - assert!(false, "test-assert-owned".to_string()); -} diff --git a/src/test/run-fail/assert-macro-static.rs b/src/test/run-fail/assert-macro-static.rs deleted file mode 100644 index 650aaeab4f6..00000000000 --- a/src/test/run-fail/assert-macro-static.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'test-assert-static' - -fn main() { - assert!(false, "test-assert-static"); -} diff --git a/src/test/run-fail/assert-ne-macro-panic.rs b/src/test/run-fail/assert-ne-macro-panic.rs deleted file mode 100644 index f55ef2b3ff5..00000000000 --- a/src/test/run-fail/assert-ne-macro-panic.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:assertion failed: `(left != right)` -// error-pattern: left: `14` -// error-pattern:right: `14` - -fn main() { - assert_ne!(14, 14); -} diff --git a/src/test/run-fail/binop-fail-3.rs b/src/test/run-fail/binop-fail-3.rs deleted file mode 100644 index a7696fffda0..00000000000 --- a/src/test/run-fail/binop-fail-3.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:quux -fn foo() -> ! { - panic!("quux"); -} - -#[allow(resolve_trait_on_defaulted_unit)] -fn main() { - foo() == foo(); // these types wind up being defaulted to () -} diff --git a/src/test/run-fail/binop-panic.rs b/src/test/run-fail/binop-panic.rs deleted file mode 100644 index dba5cecc67e..00000000000 --- a/src/test/run-fail/binop-panic.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:quux -fn my_err(s: String) -> ! { - println!("{}", s); - panic!("quux"); -} -fn main() { - 3_usize == my_err("bye".to_string()); -} diff --git a/src/test/run-fail/borrowck-local-borrow.rs b/src/test/run-fail/borrowck-local-borrow.rs deleted file mode 100644 index d07f76b6252..00000000000 --- a/src/test/run-fail/borrowck-local-borrow.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern:panic 1 - -// revisions: migrate mir -//[mir]compile-flags: -Z borrowck=mir - -fn main() { - let x = 2; - let y = &x; - panic!("panic 1"); -} diff --git a/src/test/run-fail/bounds-check-no-overflow.rs b/src/test/run-fail/bounds-check-no-overflow.rs deleted file mode 100644 index 3943f87f7fe..00000000000 --- a/src/test/run-fail/bounds-check-no-overflow.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:index out of bounds - -use std::usize; -use std::mem::size_of; - -fn main() { - let xs = [1, 2, 3]; - xs[usize::MAX / size_of::() + 1]; -} diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow.rs b/src/test/run-fail/bug-2470-bounds-check-overflow.rs deleted file mode 100644 index b4e3f246991..00000000000 --- a/src/test/run-fail/bug-2470-bounds-check-overflow.rs +++ /dev/null @@ -1,25 +0,0 @@ -// error-pattern:index out of bounds - -use std::mem; - -fn main() { - - // This should cause a bounds-check panic, but may not if we do our - // bounds checking by comparing the scaled index to the vector's - // address-bounds, since we've scaled the index to wrap around to the - // address of the 0th cell in the array (even though the index is - // huge). - - let x = vec![1_usize, 2_usize, 3_usize]; - - let base = x.as_ptr() as usize; - let idx = base / mem::size_of::(); - println!("ov1 base = 0x{:x}", base); - println!("ov1 idx = 0x{:x}", idx); - println!("ov1 sizeof::() = 0x{:x}", mem::size_of::()); - println!("ov1 idx * sizeof::() = 0x{:x}", - idx * mem::size_of::()); - - // This should panic. - println!("ov1 0x{:x}", x[idx]); -} diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs deleted file mode 100644 index e36ec0f5901..00000000000 --- a/src/test/run-fail/bug-811.rs +++ /dev/null @@ -1,24 +0,0 @@ -// error-pattern:quux - -use std::marker::PhantomData; - -fn test00_start(ch: chan_t, message: isize) { - send(ch, message); -} - -type task_id = isize; -type port_id = isize; - -struct chan_t { - task: task_id, - port: port_id, - marker: PhantomData<*mut T>, -} - -fn send(_ch: chan_t, _data: T) { - panic!(); -} - -fn main() { - panic!("quux"); -} diff --git a/src/test/run-fail/die-macro-expr.rs b/src/test/run-fail/die-macro-expr.rs deleted file mode 100644 index 70413f97896..00000000000 --- a/src/test/run-fail/die-macro-expr.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:test - -fn main() { - let __isize: isize = panic!("test"); -} diff --git a/src/test/run-fail/die-macro-pure.rs b/src/test/run-fail/die-macro-pure.rs deleted file mode 100644 index cec0742d503..00000000000 --- a/src/test/run-fail/die-macro-pure.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:test - -fn f() { - panic!("test"); -} - -fn main() { - f(); -} diff --git a/src/test/run-fail/die-macro.rs b/src/test/run-fail/die-macro.rs deleted file mode 100644 index 846b9ea24d3..00000000000 --- a/src/test/run-fail/die-macro.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:test - -fn main() { - panic!("test"); -} diff --git a/src/test/run-fail/diverging-closure.rs b/src/test/run-fail/diverging-closure.rs deleted file mode 100644 index a92e07a21fe..00000000000 --- a/src/test/run-fail/diverging-closure.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:oops - -fn main() { - let func = || -> ! { - panic!("oops"); - }; - func(); -} diff --git a/src/test/run-fail/divide-by-zero.rs b/src/test/run-fail/divide-by-zero.rs deleted file mode 100644 index ba93563154a..00000000000 --- a/src/test/run-fail/divide-by-zero.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:attempt to divide by zero -#[allow(unconditional_panic)] -fn main() { - let y = 0; - let _z = 1 / y; -} diff --git a/src/test/run-fail/doublepanic.rs b/src/test/run-fail/doublepanic.rs deleted file mode 100644 index 10d303e491e..00000000000 --- a/src/test/run-fail/doublepanic.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(unreachable_code)] - -// error-pattern:One -fn main() { - panic!("One"); - panic!("Two"); -} diff --git a/src/test/run-fail/dst-raw-slice.rs b/src/test/run-fail/dst-raw-slice.rs deleted file mode 100644 index 2575de7cc58..00000000000 --- a/src/test/run-fail/dst-raw-slice.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Test bounds checking for DST raw slices -// error-pattern:index out of bounds -#[allow(unconditional_panic)] -fn main() { - let a: *const [_] = &[1, 2, 3]; - unsafe { - let _b = (*a)[3]; - } -} diff --git a/src/test/run-fail/explicit-panic-msg.rs b/src/test/run-fail/explicit-panic-msg.rs deleted file mode 100644 index 35e0518b9be..00000000000 --- a/src/test/run-fail/explicit-panic-msg.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![allow(unused_assignments)] -#![allow(unused_variables)] - -// error-pattern:wooooo -fn main() { - let mut a = 1; - if 1 == 1 { - a = 2; - } - panic!(format!("woooo{}", "o")); -} diff --git a/src/test/run-fail/explicit-panic.rs b/src/test/run-fail/explicit-panic.rs deleted file mode 100644 index 11ea6b41221..00000000000 --- a/src/test/run-fail/explicit-panic.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:explicit -fn main() { - panic!(); -} diff --git a/src/test/run-fail/expr-fn-panic.rs b/src/test/run-fail/expr-fn-panic.rs deleted file mode 100644 index 0532c32ec70..00000000000 --- a/src/test/run-fail/expr-fn-panic.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:explicit panic - -fn f() -> ! { - panic!() -} - -fn main() { - f(); -} diff --git a/src/test/run-fail/expr-if-panic-fn.rs b/src/test/run-fail/expr-if-panic-fn.rs deleted file mode 100644 index 660b1396e38..00000000000 --- a/src/test/run-fail/expr-if-panic-fn.rs +++ /dev/null @@ -1,18 +0,0 @@ -// error-pattern:explicit panic - -fn f() -> ! { - panic!() -} - -fn g() -> isize { - let x = if true { - f() - } else { - 10 - }; - return x; -} - -fn main() { - g(); -} diff --git a/src/test/run-fail/expr-if-panic.rs b/src/test/run-fail/expr-if-panic.rs deleted file mode 100644 index 36aaf459a56..00000000000 --- a/src/test/run-fail/expr-if-panic.rs +++ /dev/null @@ -1,11 +0,0 @@ -// error-pattern:explicit panic - -fn main() { - let _x = if false { - 0 - } else if true { - panic!() - } else { - 10 - }; -} diff --git a/src/test/run-fail/expr-match-panic-fn.rs b/src/test/run-fail/expr-match-panic-fn.rs deleted file mode 100644 index 120df61b4bf..00000000000 --- a/src/test/run-fail/expr-match-panic-fn.rs +++ /dev/null @@ -1,17 +0,0 @@ -// error-pattern:explicit panic - -fn f() -> ! { - panic!() -} - -fn g() -> isize { - let x = match true { - true => f(), - false => 10, - }; - return x; -} - -fn main() { - g(); -} diff --git a/src/test/run-fail/expr-match-panic.rs b/src/test/run-fail/expr-match-panic.rs deleted file mode 100644 index b2f0179a083..00000000000 --- a/src/test/run-fail/expr-match-panic.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:explicit panic - -fn main() { - let _x = match true { - false => 0, - true => panic!(), - }; -} diff --git a/src/test/run-fail/fmt-panic.rs b/src/test/run-fail/fmt-panic.rs deleted file mode 100644 index 5749991914c..00000000000 --- a/src/test/run-fail/fmt-panic.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:meh - -fn main() { - let str_var: String = "meh".to_string(); - panic!("{}", str_var); -} diff --git a/src/test/run-fail/for-each-loop-panic.rs b/src/test/run-fail/for-each-loop-panic.rs deleted file mode 100644 index d24e81e152c..00000000000 --- a/src/test/run-fail/for-each-loop-panic.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:moop - -fn main() { - for _ in 0_usize..10_usize { - panic!("moop"); - } -} diff --git a/src/test/run-fail/generator-resume-after-panic.rs b/src/test/run-fail/generator-resume-after-panic.rs deleted file mode 100644 index 1a7c2e80629..00000000000 --- a/src/test/run-fail/generator-resume-after-panic.rs +++ /dev/null @@ -1,22 +0,0 @@ -// error-pattern:generator resumed after panicking - -// Test that we get the correct message for resuming a panicked generator. - -#![feature(generators, generator_trait)] - -use std::{ - ops::Generator, - pin::Pin, - panic, -}; - -fn main() { - let mut g = || { - panic!(); - yield; - }; - panic::catch_unwind(panic::AssertUnwindSafe(|| { - let x = Pin::new(&mut g).resume(()); - })); - Pin::new(&mut g).resume(()); -} diff --git a/src/test/run-fail/glob-use-std.rs b/src/test/run-fail/glob-use-std.rs deleted file mode 100644 index d19a782986b..00000000000 --- a/src/test/run-fail/glob-use-std.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Issue #7580 - -// error-pattern:panic works - -use std::*; - -fn main() { - panic!("panic works") -} diff --git a/src/test/run-fail/hashmap-capacity-overflow.rs b/src/test/run-fail/hashmap-capacity-overflow.rs deleted file mode 100644 index 038f2756ff3..00000000000 --- a/src/test/run-fail/hashmap-capacity-overflow.rs +++ /dev/null @@ -1,11 +0,0 @@ -// error-pattern:capacity overflow - -use std::collections::hash_map::HashMap; -use std::usize; -use std::mem::size_of; - -fn main() { - let threshold = usize::MAX / size_of::<(u64, u64, u64)>(); - let mut h = HashMap::::with_capacity(threshold + 100); - h.insert(0, 0); -} diff --git a/src/test/run-fail/if-check-panic.rs b/src/test/run-fail/if-check-panic.rs deleted file mode 100644 index f9a4b8fcb38..00000000000 --- a/src/test/run-fail/if-check-panic.rs +++ /dev/null @@ -1,22 +0,0 @@ -// error-pattern:Number is odd -fn even(x: usize) -> bool { - if x < 2 { - return false; - } else if x == 2 { - return true; - } else { - return even(x - 2); - } -} - -fn foo(x: usize) { - if even(x) { - println!("{}", x); - } else { - panic!("Number is odd"); - } -} - -fn main() { - foo(3); -} diff --git a/src/test/run-fail/if-cond-bot.rs b/src/test/run-fail/if-cond-bot.rs deleted file mode 100644 index c680cad258f..00000000000 --- a/src/test/run-fail/if-cond-bot.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:quux -fn my_err(s: String) -> ! { - println!("{}", s); - panic!("quux"); -} -fn main() { - if my_err("bye".to_string()) { - } -} diff --git a/src/test/run-fail/issue-12920.rs b/src/test/run-fail/issue-12920.rs deleted file mode 100644 index 0819e992d13..00000000000 --- a/src/test/run-fail/issue-12920.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:explicit panic - -pub fn main() { - panic!(); - println!("{}", 1); -} diff --git a/src/test/run-fail/issue-13202.rs b/src/test/run-fail/issue-13202.rs deleted file mode 100644 index cf3a6b3d986..00000000000 --- a/src/test/run-fail/issue-13202.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:bad input - -fn main() { - Some("foo").unwrap_or(panic!("bad input")).to_string(); -} diff --git a/src/test/run-fail/issue-18576.rs b/src/test/run-fail/issue-18576.rs deleted file mode 100644 index ca9d1e5f5e7..00000000000 --- a/src/test/run-fail/issue-18576.rs +++ /dev/null @@ -1,13 +0,0 @@ -// error-pattern:stop - -// #18576 -// Make sure that calling an extern function pointer in an unreachable -// context doesn't cause an LLVM assertion - -#[allow(unreachable_code)] -fn main() { - panic!("stop"); - let pointer = other; - pointer(); -} -extern "C" fn other() {} diff --git a/src/test/run-fail/issue-20971.rs b/src/test/run-fail/issue-20971.rs deleted file mode 100644 index 6c2de783c01..00000000000 --- a/src/test/run-fail/issue-20971.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Regression test for Issue #20971. - -// error-pattern:Hello, world! - -pub trait Parser { - type Input; - fn parse(&mut self, input: ::Input); -} - -impl Parser for () { - type Input = (); - fn parse(&mut self, input: ()) {} -} - -pub fn many() -> Box::Input> + 'static> { - panic!("Hello, world!") -} - -fn main() { - many().parse(()); -} diff --git a/src/test/run-fail/issue-23354-2.rs b/src/test/run-fail/issue-23354-2.rs deleted file mode 100644 index 8f7baff56dc..00000000000 --- a/src/test/run-fail/issue-23354-2.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:panic evaluated - -#[allow(unused_variables)] -fn main() { - // This used to trigger an LLVM assertion during compilation - let x = [panic!("panic evaluated"); 2]; -} diff --git a/src/test/run-fail/issue-23354.rs b/src/test/run-fail/issue-23354.rs deleted file mode 100644 index 4c2fb022a6b..00000000000 --- a/src/test/run-fail/issue-23354.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:panic evaluated - -#[allow(unused_variables)] -fn main() { - let x = [panic!("panic evaluated"); 0]; -} diff --git a/src/test/run-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs deleted file mode 100644 index 17f89e4d20d..00000000000 --- a/src/test/run-fail/issue-2444.rs +++ /dev/null @@ -1,15 +0,0 @@ -// error-pattern:explicit panic - -use std::sync::Arc; - -enum e { - ee(Arc), -} - -fn foo() -> e { - panic!(); -} - -fn main() { - let _f = foo(); -} diff --git a/src/test/run-fail/issue-2761.rs b/src/test/run-fail/issue-2761.rs deleted file mode 100644 index 84d90930d2d..00000000000 --- a/src/test/run-fail/issue-2761.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:custom message - -fn main() { - assert!(false, "custom message"); -} diff --git a/src/test/run-fail/issue-28934.rs b/src/test/run-fail/issue-28934.rs deleted file mode 100644 index 5915372b692..00000000000 --- a/src/test/run-fail/issue-28934.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Regression test: issue had to do with "givens" in region inference, -// which were not being considered during the contraction phase. - -// error-pattern:explicit panic - -struct Parser<'i: 't, 't>(&'i u8, &'t u8); - -impl<'i, 't> Parser<'i, 't> { - fn parse_nested_block(&mut self, parse: F) -> Result - where for<'tt> F: FnOnce(&mut Parser<'i, 'tt>) -> T - { - panic!() - } - - fn expect_exhausted(&mut self) -> Result<(), ()> { - Ok(()) - } -} - -fn main() { - let x = 0u8; - Parser(&x, &x).parse_nested_block(|input| input.expect_exhausted()).unwrap(); -} diff --git a/src/test/run-fail/issue-29798.rs b/src/test/run-fail/issue-29798.rs deleted file mode 100644 index b06aa5fc728..00000000000 --- a/src/test/run-fail/issue-29798.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:index out of bounds: the len is 5 but the index is 5 - -const fn test(x: usize) -> i32 { - [42;5][x] -} - -fn main () { - let _ = test(5); -} diff --git a/src/test/run-fail/issue-3029.rs b/src/test/run-fail/issue-3029.rs deleted file mode 100644 index face808b68f..00000000000 --- a/src/test/run-fail/issue-3029.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![allow(unused_allocation)] -#![allow(unreachable_code)] -#![allow(unused_variables)] - - -// error-pattern:so long -fn main() { - let mut x = Vec::new(); - let y = vec![3]; - panic!("so long"); - x.extend(y.into_iter()); -} diff --git a/src/test/run-fail/issue-30380.rs b/src/test/run-fail/issue-30380.rs deleted file mode 100644 index 036071a89c7..00000000000 --- a/src/test/run-fail/issue-30380.rs +++ /dev/null @@ -1,34 +0,0 @@ -// check that panics in destructors during assignment do not leave -// destroyed values lying around for other destructors to observe. - -// error-pattern:panicking destructors ftw! - -struct Observer<'a>(&'a mut FilledOnDrop); - -struct FilledOnDrop(u32); -impl Drop for FilledOnDrop { - fn drop(&mut self) { - if self.0 == 0 { - // this is only set during the destructor - safe - // code should not be able to observe this. - self.0 = 0x1c1c1c1c; - panic!("panicking destructors ftw!"); - } - } -} - -impl<'a> Drop for Observer<'a> { - fn drop(&mut self) { - assert_eq!(self.0 .0, 1); - } -} - -fn foo(b: &mut Observer) { - *b.0 = FilledOnDrop(1); -} - -fn main() { - let mut bomb = FilledOnDrop(0); - let mut observer = Observer(&mut bomb); - foo(&mut observer); -} diff --git a/src/test/run-fail/issue-44216-add-instant.rs b/src/test/run-fail/issue-44216-add-instant.rs deleted file mode 100644 index 76ad0a3d41b..00000000000 --- a/src/test/run-fail/issue-44216-add-instant.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:overflow - -use std::time::{Instant, Duration}; - -fn main() { - let now = Instant::now(); - let _ = now + Duration::from_secs(u64::max_value()); -} diff --git a/src/test/run-fail/issue-44216-add-system-time.rs b/src/test/run-fail/issue-44216-add-system-time.rs deleted file mode 100644 index aa861f7d599..00000000000 --- a/src/test/run-fail/issue-44216-add-system-time.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:overflow - -use std::time::{Duration, SystemTime}; - -fn main() { - let now = SystemTime::now(); - let _ = now + Duration::from_secs(u64::max_value()); -} diff --git a/src/test/run-fail/issue-44216-sub-instant.rs b/src/test/run-fail/issue-44216-sub-instant.rs deleted file mode 100644 index 8bc1f47ae2d..00000000000 --- a/src/test/run-fail/issue-44216-sub-instant.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:overflow - -use std::time::{Instant, Duration}; - -fn main() { - let now = Instant::now(); - let _ = now - Duration::from_secs(u64::max_value()); -} diff --git a/src/test/run-fail/issue-44216-sub-system-time.rs b/src/test/run-fail/issue-44216-sub-system-time.rs deleted file mode 100644 index 37ab0e7c3f9..00000000000 --- a/src/test/run-fail/issue-44216-sub-system-time.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:overflow - -use std::time::{Duration, SystemTime}; - -fn main() { - let now = SystemTime::now(); - let _ = now - Duration::from_secs(u64::max_value()); -} diff --git a/src/test/run-fail/issue-51345.rs b/src/test/run-fail/issue-51345.rs deleted file mode 100644 index c62f98ea78d..00000000000 --- a/src/test/run-fail/issue-51345.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern: thread 'main' panicked at 'explicit panic' - -fn main() { - let mut vec = vec![]; - vec.push((vec.len(), panic!())); -} diff --git a/src/test/run-fail/issue-6458-1.rs b/src/test/run-fail/issue-6458-1.rs deleted file mode 100644 index 550bb2b832f..00000000000 --- a/src/test/run-fail/issue-6458-1.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:explicit panic - -fn foo(t: T) {} -fn main() { - foo(panic!()) -} diff --git a/src/test/run-fail/issue-948.rs b/src/test/run-fail/issue-948.rs deleted file mode 100644 index 8f1c6587f03..00000000000 --- a/src/test/run-fail/issue-948.rs +++ /dev/null @@ -1,13 +0,0 @@ -// error-pattern:beep boop - -#![allow(unused_variables)] - -struct Point { - x: isize, - y: isize, -} - -fn main() { - let origin = Point { x: 0, y: 0 }; - let f: Point = Point { x: (panic!("beep boop")), ..origin }; -} diff --git a/src/test/run-fail/main-panic.rs b/src/test/run-fail/main-panic.rs deleted file mode 100644 index 3a9409562db..00000000000 --- a/src/test/run-fail/main-panic.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:thread 'main' panicked at - -fn main() { - panic!() -} diff --git a/src/test/run-fail/match-bot-panic.rs b/src/test/run-fail/match-bot-panic.rs deleted file mode 100644 index f4da8c4e43f..00000000000 --- a/src/test/run-fail/match-bot-panic.rs +++ /dev/null @@ -1,14 +0,0 @@ -// error-pattern:explicit panic - -#![allow(unreachable_code)] -#![allow(unused_variables)] - -fn foo(s: String) {} - -fn main() { - let i = match Some::(3) { - None:: => panic!(), - Some::(_) => panic!(), - }; - foo(i); -} diff --git a/src/test/run-fail/match-disc-bot.rs b/src/test/run-fail/match-disc-bot.rs deleted file mode 100644 index a9312fbb1fb..00000000000 --- a/src/test/run-fail/match-disc-bot.rs +++ /dev/null @@ -1,13 +0,0 @@ -// error-pattern:quux -fn f() -> ! { - panic!("quux") -} -fn g() -> isize { - match f() { - true => 1, - false => 0, - } -} -fn main() { - g(); -} diff --git a/src/test/run-fail/match-wildcards.rs b/src/test/run-fail/match-wildcards.rs deleted file mode 100644 index 7a65ad52558..00000000000 --- a/src/test/run-fail/match-wildcards.rs +++ /dev/null @@ -1,18 +0,0 @@ -// error-pattern:squirrelcupcake -fn cmp() -> isize { - match (Some('a'), None::) { - (Some(_), _) => { - panic!("squirrelcupcake"); - } - (_, Some(_)) => { - panic!(); - } - _ => { - panic!("wat"); - } - } -} - -fn main() { - println!("{}", cmp()); -} diff --git a/src/test/run-fail/meta-revision-bad.rs b/src/test/run-fail/meta-revision-bad.rs deleted file mode 100644 index 17f6398b735..00000000000 --- a/src/test/run-fail/meta-revision-bad.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Meta test for compiletest: check that when we give the wrong error -// patterns, the test fails. - -// revisions: foo bar -// should-fail -//[foo] error-pattern:bar -//[bar] error-pattern:foo - -#[cfg(foo)] -fn die() { - panic!("foo"); -} -#[cfg(bar)] -fn die() { - panic!("bar"); -} - -fn main() { - die(); -} diff --git a/src/test/run-fail/meta-revision-ok.rs b/src/test/run-fail/meta-revision-ok.rs deleted file mode 100644 index 8693ee5f4ef..00000000000 --- a/src/test/run-fail/meta-revision-ok.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Meta test for compiletest: check that when we give the right error -// patterns, the test passes. See all `meta-revision-bad.rs`. - -// revisions: foo bar -//[foo] error-pattern:foo -//[bar] error-pattern:bar - -#[cfg(foo)] -fn die() { - panic!("foo"); -} -#[cfg(bar)] -fn die() { - panic!("bar"); -} - -fn main() { - die(); -} diff --git a/src/test/run-fail/mir_codegen_calls_converging_drops.rs b/src/test/run-fail/mir_codegen_calls_converging_drops.rs deleted file mode 100644 index ee0dc98ce68..00000000000 --- a/src/test/run-fail/mir_codegen_calls_converging_drops.rs +++ /dev/null @@ -1,24 +0,0 @@ -// error-pattern:converging_fn called -// error-pattern:0 dropped -// error-pattern:exit - -struct Droppable(u8); -impl Drop for Droppable { - fn drop(&mut self) { - eprintln!("{} dropped", self.0); - } -} - -fn converging_fn() { - eprintln!("converging_fn called"); -} - -fn mir(d: Droppable) { - converging_fn(); -} - -fn main() { - let d = Droppable(0); - mir(d); - panic!("exit"); -} diff --git a/src/test/run-fail/mir_codegen_calls_converging_drops_2.rs b/src/test/run-fail/mir_codegen_calls_converging_drops_2.rs deleted file mode 100644 index ee2c25ce856..00000000000 --- a/src/test/run-fail/mir_codegen_calls_converging_drops_2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// error-pattern:complex called -// error-pattern:dropped -// error-pattern:exit - -struct Droppable; -impl Drop for Droppable { - fn drop(&mut self) { - eprintln!("dropped"); - } -} - -// return value of this function is copied into the return slot -fn complex() -> u64 { - eprintln!("complex called"); - 42 -} - - -fn mir() -> u64 { - let x = Droppable; - return complex(); - drop(x); -} - -pub fn main() { - assert_eq!(mir(), 42); - panic!("exit"); -} diff --git a/src/test/run-fail/mir_codegen_calls_diverging.rs b/src/test/run-fail/mir_codegen_calls_diverging.rs deleted file mode 100644 index dceae0a4e4a..00000000000 --- a/src/test/run-fail/mir_codegen_calls_diverging.rs +++ /dev/null @@ -1,13 +0,0 @@ -// error-pattern:diverging_fn called - -fn diverging_fn() -> ! { - panic!("diverging_fn called") -} - -fn mir() { - diverging_fn(); -} - -fn main() { - mir(); -} diff --git a/src/test/run-fail/mir_codegen_calls_diverging_drops.rs b/src/test/run-fail/mir_codegen_calls_diverging_drops.rs deleted file mode 100644 index 187e526f7c0..00000000000 --- a/src/test/run-fail/mir_codegen_calls_diverging_drops.rs +++ /dev/null @@ -1,22 +0,0 @@ -// error-pattern:diverging_fn called -// error-pattern:0 dropped - -struct Droppable(u8); -impl Drop for Droppable { - fn drop(&mut self) { - eprintln!("{} dropped", self.0); - } -} - -fn diverging_fn() -> ! { - panic!("diverging_fn called") -} - -fn mir(d: Droppable) { - diverging_fn(); -} - -fn main() { - let d = Droppable(0); - mir(d); -} diff --git a/src/test/run-fail/mir_drop_panics.rs b/src/test/run-fail/mir_drop_panics.rs deleted file mode 100644 index bda555b9262..00000000000 --- a/src/test/run-fail/mir_drop_panics.rs +++ /dev/null @@ -1,22 +0,0 @@ -// error-pattern:panic 1 -// error-pattern:drop 2 - -struct Droppable(u32); -impl Drop for Droppable { - fn drop(&mut self) { - if self.0 == 1 { - panic!("panic 1"); - } else { - eprintln!("drop {}", self.0); - } - } -} - -fn mir() { - let x = Droppable(2); - let y = Droppable(1); -} - -fn main() { - mir(); -} diff --git a/src/test/run-fail/mir_dynamic_drops_1.rs b/src/test/run-fail/mir_dynamic_drops_1.rs deleted file mode 100644 index db8d0af29db..00000000000 --- a/src/test/run-fail/mir_dynamic_drops_1.rs +++ /dev/null @@ -1,30 +0,0 @@ -// error-pattern:drop 1 -// error-pattern:drop 2 -// ignore-cloudabi no std::process - -/// Structure which will not allow to be dropped twice. -struct Droppable<'a>(&'a mut bool, u32); -impl<'a> Drop for Droppable<'a> { - fn drop(&mut self) { - if *self.0 { - eprintln!("{} dropped twice", self.1); - ::std::process::exit(1); - } - eprintln!("drop {}", self.1); - *self.0 = true; - } -} - -fn mir() { - let (mut xv, mut yv) = (false, false); - let x = Droppable(&mut xv, 1); - let y = Droppable(&mut yv, 2); - let mut z = x; - let k = y; - z = k; -} - -fn main() { - mir(); - panic!(); -} diff --git a/src/test/run-fail/mir_dynamic_drops_2.rs b/src/test/run-fail/mir_dynamic_drops_2.rs deleted file mode 100644 index 21d3a042b1e..00000000000 --- a/src/test/run-fail/mir_dynamic_drops_2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// error-pattern:drop 1 -// ignore-cloudabi no std::process - -/// Structure which will not allow to be dropped twice. -struct Droppable<'a>(&'a mut bool, u32); -impl<'a> Drop for Droppable<'a> { - fn drop(&mut self) { - if *self.0 { - eprintln!("{} dropped twice", self.1); - ::std::process::exit(1); - } - eprintln!("drop {}", self.1); - *self.0 = true; - } -} - -fn mir<'a>(d: Droppable<'a>) { - loop { - let x = d; - break; - } -} - -fn main() { - let mut xv = false; - mir(Droppable(&mut xv, 1)); - panic!(); -} diff --git a/src/test/run-fail/mir_dynamic_drops_3.rs b/src/test/run-fail/mir_dynamic_drops_3.rs deleted file mode 100644 index b9049968682..00000000000 --- a/src/test/run-fail/mir_dynamic_drops_3.rs +++ /dev/null @@ -1,33 +0,0 @@ -// error-pattern:unwind happens -// error-pattern:drop 3 -// error-pattern:drop 2 -// error-pattern:drop 1 -// ignore-cloudabi no std::process - -/// Structure which will not allow to be dropped twice. -struct Droppable<'a>(&'a mut bool, u32); -impl<'a> Drop for Droppable<'a> { - fn drop(&mut self) { - if *self.0 { - eprintln!("{} dropped twice", self.1); - ::std::process::exit(1); - } - eprintln!("drop {}", self.1); - *self.0 = true; - } -} - -fn may_panic<'a>() -> Droppable<'a> { - panic!("unwind happens"); -} - -fn mir<'a>(d: Droppable<'a>) { - let (mut a, mut b) = (false, false); - let y = Droppable(&mut a, 2); - let x = [Droppable(&mut b, 1), y, d, may_panic()]; -} - -fn main() { - let mut c = false; - mir(Droppable(&mut c, 3)); -} diff --git a/src/test/run-fail/mir_indexing_oob_1.rs b/src/test/run-fail/mir_indexing_oob_1.rs deleted file mode 100644 index 1cd53e309eb..00000000000 --- a/src/test/run-fail/mir_indexing_oob_1.rs +++ /dev/null @@ -1,12 +0,0 @@ -// error-pattern:index out of bounds: the len is 5 but the index is 10 - -const C: [u32; 5] = [0; 5]; - -#[allow(unconditional_panic)] -fn test() -> u32 { - C[10] -} - -fn main() { - test(); -} diff --git a/src/test/run-fail/mir_indexing_oob_2.rs b/src/test/run-fail/mir_indexing_oob_2.rs deleted file mode 100644 index 64b260993c9..00000000000 --- a/src/test/run-fail/mir_indexing_oob_2.rs +++ /dev/null @@ -1,12 +0,0 @@ -// error-pattern:index out of bounds: the len is 5 but the index is 10 - -const C: &'static [u8; 5] = b"hello"; - -#[allow(unconditional_panic)] -fn test() -> u8 { - C[10] -} - -fn main() { - test(); -} diff --git a/src/test/run-fail/mir_indexing_oob_3.rs b/src/test/run-fail/mir_indexing_oob_3.rs deleted file mode 100644 index 3688088439b..00000000000 --- a/src/test/run-fail/mir_indexing_oob_3.rs +++ /dev/null @@ -1,12 +0,0 @@ -// error-pattern:index out of bounds: the len is 5 but the index is 10 - -const C: &'static [u8; 5] = b"hello"; - -#[allow(unconditional_panic)] -fn mir() -> u8 { - C[10] -} - -fn main() { - mir(); -} diff --git a/src/test/run-fail/mod-zero.rs b/src/test/run-fail/mod-zero.rs deleted file mode 100644 index f70b3ac920c..00000000000 --- a/src/test/run-fail/mod-zero.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:attempt to calculate the remainder with a divisor of zero -#[allow(unconditional_panic)] -fn main() { - let y = 0; - let _z = 1 % y; -} diff --git a/src/test/run-fail/overflowing-add.rs b/src/test/run-fail/overflowing-add.rs deleted file mode 100644 index 5ca91314d95..00000000000 --- a/src/test/run-fail/overflowing-add.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to add with overflow' -// compile-flags: -C debug-assertions - -#![allow(arithmetic_overflow)] - -fn main() { - let _x = 200u8 + 200u8 + 200u8; -} diff --git a/src/test/run-fail/overflowing-lsh-1.rs b/src/test/run-fail/overflowing-lsh-1.rs deleted file mode 100644 index 977cfea0fe0..00000000000 --- a/src/test/run-fail/overflowing-lsh-1.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - let _x = 1_i32 << 32; -} diff --git a/src/test/run-fail/overflowing-lsh-2.rs b/src/test/run-fail/overflowing-lsh-2.rs deleted file mode 100644 index 3517dacde3a..00000000000 --- a/src/test/run-fail/overflowing-lsh-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - let _x = 1 << -1; -} diff --git a/src/test/run-fail/overflowing-lsh-3.rs b/src/test/run-fail/overflowing-lsh-3.rs deleted file mode 100644 index 4a575c3fa7f..00000000000 --- a/src/test/run-fail/overflowing-lsh-3.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - let _x = 1_u64 << 64; -} diff --git a/src/test/run-fail/overflowing-lsh-4.rs b/src/test/run-fail/overflowing-lsh-4.rs deleted file mode 100644 index 0d3912ce13f..00000000000 --- a/src/test/run-fail/overflowing-lsh-4.rs +++ /dev/null @@ -1,24 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow' -// compile-flags: -C debug-assertions - -// This function is checking that our automatic truncation does not -// sidestep the overflow checking. - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - // this signals overflow when checking is on - let x = 1_i8 << 17; - - // ... but when checking is off, the fallback will truncate the - // input to its lower three bits (= 1). Note that this is *not* - // the behavior of the x86 processor for 8- and 16-bit types, - // but it is necessary to avoid undefined behavior from LLVM. - // - // We check that here, by ensuring the result has only been - // shifted by one place; if overflow checking is turned off, then - // this assertion will pass (and the compiletest driver will - // report that the test did not produce the error expected above). - assert_eq!(x, 2_i8); -} diff --git a/src/test/run-fail/overflowing-mul.rs b/src/test/run-fail/overflowing-mul.rs deleted file mode 100644 index 2dfc9bb5ae4..00000000000 --- a/src/test/run-fail/overflowing-mul.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' -// compile-flags: -C debug-assertions - -#![allow(arithmetic_overflow)] - -fn main() { - let x = 200u8 * 4; -} diff --git a/src/test/run-fail/overflowing-neg.rs b/src/test/run-fail/overflowing-neg.rs deleted file mode 100644 index f512aa35bed..00000000000 --- a/src/test/run-fail/overflowing-neg.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to negate with overflow' -// compile-flags: -C debug-assertions - -#![allow(arithmetic_overflow)] - -fn main() { - let _x = -std::i8::MIN; -} diff --git a/src/test/run-fail/overflowing-pow-signed.rs b/src/test/run-fail/overflowing-pow-signed.rs deleted file mode 100644 index c539c685faf..00000000000 --- a/src/test/run-fail/overflowing-pow-signed.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' -// compile-flags: -C debug-assertions - -fn main() { - let _x = 2i32.pow(1024); -} diff --git a/src/test/run-fail/overflowing-pow-unsigned.rs b/src/test/run-fail/overflowing-pow-unsigned.rs deleted file mode 100644 index 1d4fa3b5c7e..00000000000 --- a/src/test/run-fail/overflowing-pow-unsigned.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' -// compile-flags: -C debug-assertions - -fn main() { - let _x = 2u32.pow(1024); -} diff --git a/src/test/run-fail/overflowing-rsh-1.rs b/src/test/run-fail/overflowing-rsh-1.rs deleted file mode 100644 index 4592b2b6260..00000000000 --- a/src/test/run-fail/overflowing-rsh-1.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - let _x = -1_i32 >> 32; -} diff --git a/src/test/run-fail/overflowing-rsh-2.rs b/src/test/run-fail/overflowing-rsh-2.rs deleted file mode 100644 index 066267b770d..00000000000 --- a/src/test/run-fail/overflowing-rsh-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - let _x = -1_i32 >> -1; -} diff --git a/src/test/run-fail/overflowing-rsh-3.rs b/src/test/run-fail/overflowing-rsh-3.rs deleted file mode 100644 index 67e78482866..00000000000 --- a/src/test/run-fail/overflowing-rsh-3.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - let _x = -1_i64 >> 64; -} diff --git a/src/test/run-fail/overflowing-rsh-4.rs b/src/test/run-fail/overflowing-rsh-4.rs deleted file mode 100644 index 1877d5c9685..00000000000 --- a/src/test/run-fail/overflowing-rsh-4.rs +++ /dev/null @@ -1,24 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow' -// compile-flags: -C debug-assertions - -// This function is checking that our (type-based) automatic -// truncation does not sidestep the overflow checking. - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - // this signals overflow when checking is on - let x = 2_i8 >> 17; - - // ... but when checking is off, the fallback will truncate the - // input to its lower three bits (= 1). Note that this is *not* - // the behavior of the x86 processor for 8- and 16-bit types, - // but it is necessary to avoid undefined behavior from LLVM. - // - // We check that here, by ensuring the result is not zero; if - // overflow checking is turned off, then this assertion will pass - // (and the compiletest driver will report that the test did not - // produce the error expected above). - assert_eq!(x, 1_i8); -} diff --git a/src/test/run-fail/overflowing-rsh-5.rs b/src/test/run-fail/overflowing-rsh-5.rs deleted file mode 100644 index 20ef324a82a..00000000000 --- a/src/test/run-fail/overflowing-rsh-5.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] - -fn main() { - let _n = 1i64 >> [64][0]; -} diff --git a/src/test/run-fail/overflowing-rsh-6.rs b/src/test/run-fail/overflowing-rsh-6.rs deleted file mode 100644 index 589a98bab04..00000000000 --- a/src/test/run-fail/overflowing-rsh-6.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow' -// compile-flags: -C debug-assertions - -#![warn(arithmetic_overflow)] -#![warn(const_err)] -#![feature(const_indexing)] - -fn main() { - let _n = 1i64 >> [64][0]; -} diff --git a/src/test/run-fail/overflowing-sub.rs b/src/test/run-fail/overflowing-sub.rs deleted file mode 100644 index fb096c31957..00000000000 --- a/src/test/run-fail/overflowing-sub.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:thread 'main' panicked at 'attempt to subtract with overflow' -// compile-flags: -C debug-assertions - -#![allow(arithmetic_overflow)] - -fn main() { - let _x = 42u8 - (42u8 + 1); -} diff --git a/src/test/run-fail/panic-arg.rs b/src/test/run-fail/panic-arg.rs deleted file mode 100644 index c164ff94630..00000000000 --- a/src/test/run-fail/panic-arg.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:woe -fn f(a: isize) { - println!("{}", a); -} - -fn main() { - f(panic!("woe")); -} diff --git a/src/test/run-fail/panic-macro-any-wrapped.rs b/src/test/run-fail/panic-macro-any-wrapped.rs deleted file mode 100644 index 83eb39a538f..00000000000 --- a/src/test/run-fail/panic-macro-any-wrapped.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'Box' - -fn main() { - panic!(Box::new(612_i64)); -} diff --git a/src/test/run-fail/panic-macro-any.rs b/src/test/run-fail/panic-macro-any.rs deleted file mode 100644 index 72d42e5b799..00000000000 --- a/src/test/run-fail/panic-macro-any.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:panicked at 'Box' - -#![feature(box_syntax)] - -fn main() { - panic!(box 413 as Box<::std::any::Any + Send>); -} diff --git a/src/test/run-fail/panic-macro-explicit.rs b/src/test/run-fail/panic-macro-explicit.rs deleted file mode 100644 index f632034807c..00000000000 --- a/src/test/run-fail/panic-macro-explicit.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'explicit panic' - -fn main() { - panic!(); -} diff --git a/src/test/run-fail/panic-macro-fmt.rs b/src/test/run-fail/panic-macro-fmt.rs deleted file mode 100644 index 658ae56e7e4..00000000000 --- a/src/test/run-fail/panic-macro-fmt.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'test-fail-fmt 42 rust' - -fn main() { - panic!("test-fail-fmt {} {}", 42, "rust"); -} diff --git a/src/test/run-fail/panic-macro-owned.rs b/src/test/run-fail/panic-macro-owned.rs deleted file mode 100644 index 9b935717638..00000000000 --- a/src/test/run-fail/panic-macro-owned.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'test-fail-owned' - -fn main() { - panic!("test-fail-owned"); -} diff --git a/src/test/run-fail/panic-macro-static.rs b/src/test/run-fail/panic-macro-static.rs deleted file mode 100644 index 31ac488beb2..00000000000 --- a/src/test/run-fail/panic-macro-static.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:panicked at 'test-fail-static' - -fn main() { - panic!("test-fail-static"); -} diff --git a/src/test/run-fail/panic-main.rs b/src/test/run-fail/panic-main.rs deleted file mode 100644 index 881eb7b5823..00000000000 --- a/src/test/run-fail/panic-main.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:moop -fn main() { - panic!("moop"); -} diff --git a/src/test/run-fail/panic-parens.rs b/src/test/run-fail/panic-parens.rs deleted file mode 100644 index e7f98e58c4f..00000000000 --- a/src/test/run-fail/panic-parens.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Fail macros without arguments need to be disambiguated in -// certain positions -// error-pattern:oops - -fn bigpanic() { - while (panic!("oops")) { - if (panic!()) { - match (panic!()) { - () => {} - } - } - } -} - -fn main() { - bigpanic(); -} diff --git a/src/test/run-fail/panic-set-handler.rs b/src/test/run-fail/panic-set-handler.rs deleted file mode 100644 index ea2b152c6c4..00000000000 --- a/src/test/run-fail/panic-set-handler.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern:greetings from the panic handler - -use std::panic; - -fn main() { - panic::set_hook(Box::new(|i| { - eprintln!("greetings from the panic handler"); - })); - panic!("foobar"); -} diff --git a/src/test/run-fail/panic-set-unset-handler.rs b/src/test/run-fail/panic-set-unset-handler.rs deleted file mode 100644 index f8809c2f388..00000000000 --- a/src/test/run-fail/panic-set-unset-handler.rs +++ /dev/null @@ -1,11 +0,0 @@ -// error-pattern:thread 'main' panicked at 'foobar' - -use std::panic; - -fn main() { - panic::set_hook(Box::new(|i| { - eprint!("greetings from the panic handler"); - })); - panic::take_hook(); - panic!("foobar"); -} diff --git a/src/test/run-fail/panic-take-handler-nop.rs b/src/test/run-fail/panic-take-handler-nop.rs deleted file mode 100644 index bb191a38f84..00000000000 --- a/src/test/run-fail/panic-take-handler-nop.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:thread 'main' panicked at 'foobar' - -use std::panic; - -fn main() { - panic::take_hook(); - panic!("foobar"); -} diff --git a/src/test/run-fail/panic-task-name-none.rs b/src/test/run-fail/panic-task-name-none.rs deleted file mode 100644 index c7f504046ba..00000000000 --- a/src/test/run-fail/panic-task-name-none.rs +++ /dev/null @@ -1,12 +0,0 @@ -// error-pattern:thread '' panicked at 'test' -// ignore-emscripten Needs threads - -use std::thread; - -fn main() { - let r: Result<(), _> = thread::spawn(move || { - panic!("test"); - }) - .join(); - assert!(r.is_ok()); -} diff --git a/src/test/run-fail/panic-task-name-owned.rs b/src/test/run-fail/panic-task-name-owned.rs deleted file mode 100644 index 58f76ff787f..00000000000 --- a/src/test/run-fail/panic-task-name-owned.rs +++ /dev/null @@ -1,17 +0,0 @@ -// error-pattern:thread 'owned name' panicked at 'test' -// ignore-emscripten Needs threads. - -use std::thread::Builder; - -fn main() { - let r: () = Builder::new() - .name("owned name".to_string()) - .spawn(move || { - panic!("test"); - () - }) - .unwrap() - .join() - .unwrap(); - panic!(); -} diff --git a/src/test/run-fail/panic.rs b/src/test/run-fail/panic.rs deleted file mode 100644 index 95f20dedad2..00000000000 --- a/src/test/run-fail/panic.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:1 == 2 -fn main() { - assert!(1 == 2); -} diff --git a/src/test/run-fail/promoted_div_by_zero.rs b/src/test/run-fail/promoted_div_by_zero.rs deleted file mode 100644 index dc6719ce025..00000000000 --- a/src/test/run-fail/promoted_div_by_zero.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(unconditional_panic, const_err)] - -// error-pattern: attempt to divide by zero - -fn main() { - let x = &(1 / (1 - 1)); -} diff --git a/src/test/run-fail/promoted_overflow.rs b/src/test/run-fail/promoted_overflow.rs deleted file mode 100644 index 3c42da4b1d8..00000000000 --- a/src/test/run-fail/promoted_overflow.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![allow(arithmetic_overflow)] - -// error-pattern: overflow -// compile-flags: -C overflow-checks=yes - -fn main() { - let x: &'static u32 = &(0u32 - 1); -} diff --git a/src/test/run-fail/result-get-panic.rs b/src/test/run-fail/result-get-panic.rs deleted file mode 100644 index cddf20ee49d..00000000000 --- a/src/test/run-fail/result-get-panic.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:called `Result::unwrap()` on an `Err` value - -use std::result::Result::Err; - -fn main() { - println!("{}", Err::("kitty".to_string()).unwrap()); -} diff --git a/src/test/run-fail/return-never-coerce.rs b/src/test/run-fail/return-never-coerce.rs deleted file mode 100644 index 18182ff0f9d..00000000000 --- a/src/test/run-fail/return-never-coerce.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Test that ! coerces to other types. - -// error-pattern:aah! - -fn call_another_fn T>(f: F) -> T { - f() -} - -fn wub() -> ! { - panic!("aah!"); -} - -fn main() { - let x: i32 = call_another_fn(wub); - let y: u32 = wub(); -} diff --git a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs b/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs deleted file mode 100644 index 796729ac4cc..00000000000 --- a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs +++ /dev/null @@ -1,9 +0,0 @@ -// error-pattern:returned Box from main() -// failure-status: 1 - -use std::error::Error; -use std::io; - -fn main() -> Result<(), Box> { - Err(Box::new(io::Error::new(io::ErrorKind::Other, "returned Box from main()"))) -} diff --git a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-never.rs b/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-never.rs deleted file mode 100644 index cb37b8e0670..00000000000 --- a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-never.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern:oh, dear - -fn main() -> ! { - panic!("oh, dear"); -} diff --git a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs b/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs deleted file mode 100644 index 2f3a73a30ad..00000000000 --- a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs +++ /dev/null @@ -1,8 +0,0 @@ -// error-pattern:returned Box from main() -// failure-status: 1 - -use std::io::{Error, ErrorKind}; - -fn main() -> Result<(), Box> { - Err(Box::new(Error::new(ErrorKind::Other, "returned Box from main()"))) -} diff --git a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-str.rs b/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-str.rs deleted file mode 100644 index bd6fa8af935..00000000000 --- a/src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-str.rs +++ /dev/null @@ -1,6 +0,0 @@ -// error-pattern: An error message for you -// failure-status: 1 - -fn main() -> Result<(), &'static str> { - Err("An error message for you") -} diff --git a/src/test/run-fail/rhs-type.rs b/src/test/run-fail/rhs-type.rs deleted file mode 100644 index 6efbeadd704..00000000000 --- a/src/test/run-fail/rhs-type.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Tests that codegen treats the rhs of pth's decl -// as a _|_-typed thing, not a str-typed thing -// error-pattern:bye - -#![allow(unreachable_code)] -#![allow(unused_variables)] - -struct T { - t: String, -} - -fn main() { - let pth = panic!("bye"); - let _rs: T = T { t: pth }; -} diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs deleted file mode 100644 index 11e100e716e..00000000000 --- a/src/test/run-fail/run-unexported-tests.rs +++ /dev/null @@ -1,12 +0,0 @@ -// error-pattern:ran an unexported test -// compile-flags:--test -// check-stdout - -mod m { - pub fn exported() {} - - #[test] - fn unexported() { - panic!("ran an unexported test"); - } -} diff --git a/src/test/run-fail/str-overrun.rs b/src/test/run-fail/str-overrun.rs deleted file mode 100644 index e566308a087..00000000000 --- a/src/test/run-fail/str-overrun.rs +++ /dev/null @@ -1,7 +0,0 @@ -// error-pattern:index out of bounds: the len is 5 but the index is 5 -fn main() { - let s: String = "hello".to_string(); - - // Bounds-check panic. - assert_eq!(s.as_bytes()[5], 0x0 as u8); -} diff --git a/src/test/run-fail/task-spawn-barefn.rs b/src/test/run-fail/task-spawn-barefn.rs deleted file mode 100644 index 497c5ea7180..00000000000 --- a/src/test/run-fail/task-spawn-barefn.rs +++ /dev/null @@ -1,17 +0,0 @@ -// error-pattern:Ensure that the child thread runs by panicking -// ignore-emscripten Needs threads. - -use std::thread; - -fn main() { - // the purpose of this test is to make sure that thread::spawn() - // works when provided with a bare function: - let r = thread::spawn(startfn).join(); - if r.is_err() { - panic!() - } -} - -fn startfn() { - assert!("Ensure that the child thread runs by panicking".is_empty()); -} diff --git a/src/test/run-fail/test-panic.rs b/src/test/run-fail/test-panic.rs deleted file mode 100644 index 92f5146b710..00000000000 --- a/src/test/run-fail/test-panic.rs +++ /dev/null @@ -1,9 +0,0 @@ -// check-stdout -// error-pattern:thread 'test_foo' panicked at -// compile-flags: --test -// ignore-emscripten - -#[test] -fn test_foo() { - panic!() -} diff --git a/src/test/run-fail/test-should-fail-bad-message.rs b/src/test/run-fail/test-should-fail-bad-message.rs deleted file mode 100644 index 3c69bb07d3b..00000000000 --- a/src/test/run-fail/test-should-fail-bad-message.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-stdout -// error-pattern:thread 'test_foo' panicked at -// compile-flags: --test -// ignore-emscripten - -#[test] -#[should_panic(expected = "foobar")] -fn test_foo() { - panic!("blah") -} diff --git a/src/test/run-fail/test-should-panic-bad-message.rs b/src/test/run-fail/test-should-panic-bad-message.rs deleted file mode 100644 index b73d4d7377a..00000000000 --- a/src/test/run-fail/test-should-panic-bad-message.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags: --test - -// error-pattern:panicked at 'bar' -// check-stdout -#[test] -#[should_panic(expected = "foo")] -pub fn test_bar() { - panic!("bar") -} diff --git a/src/test/run-fail/test-should-panic-no-message.rs b/src/test/run-fail/test-should-panic-no-message.rs deleted file mode 100644 index b18389ec744..00000000000 --- a/src/test/run-fail/test-should-panic-no-message.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags: --test - -// error-pattern:panicked at 'explicit panic' -// check-stdout -#[test] -#[should_panic(expected = "foo")] -pub fn test_explicit() { - panic!() -} diff --git a/src/test/run-fail/test-tasks-invalid-value.rs b/src/test/run-fail/test-tasks-invalid-value.rs deleted file mode 100644 index 2dae1b4592c..00000000000 --- a/src/test/run-fail/test-tasks-invalid-value.rs +++ /dev/null @@ -1,10 +0,0 @@ -// This checks that RUST_TEST_THREADS not being 1, 2, ... is detected -// properly. - -// error-pattern:should be a positive integer -// compile-flags: --test -// exec-env:RUST_TEST_THREADS=foo -// ignore-emscripten - -#[test] -fn do_nothing() {} diff --git a/src/test/run-fail/tls-exit-status.rs b/src/test/run-fail/tls-exit-status.rs deleted file mode 100644 index f15fd4f6894..00000000000 --- a/src/test/run-fail/tls-exit-status.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern:nonzero -// exec-env:RUST_NEWRT=1 -// ignore-cloudabi no std::env - -use std::env; - -fn main() { - env::args(); - panic!("please have a nonzero exit status"); -} diff --git a/src/test/run-fail/unimplemented-macro-panic.rs b/src/test/run-fail/unimplemented-macro-panic.rs deleted file mode 100644 index 4d9cb740fc6..00000000000 --- a/src/test/run-fail/unimplemented-macro-panic.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:not implemented -fn main() { - unimplemented!() -} diff --git a/src/test/run-fail/unique-panic.rs b/src/test/run-fail/unique-panic.rs deleted file mode 100644 index adefd796af4..00000000000 --- a/src/test/run-fail/unique-panic.rs +++ /dev/null @@ -1,5 +0,0 @@ -// error-pattern: panic - -fn main() { - Box::new(panic!()); -} diff --git a/src/test/run-fail/unreachable-fmt-msg.rs b/src/test/run-fail/unreachable-fmt-msg.rs deleted file mode 100644 index ac2a52163b4..00000000000 --- a/src/test/run-fail/unreachable-fmt-msg.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:internal error: entered unreachable code: 6 is not prime -fn main() { - unreachable!("{} is not {}", 6u32, "prime"); -} diff --git a/src/test/run-fail/unreachable-macro-panic.rs b/src/test/run-fail/unreachable-macro-panic.rs deleted file mode 100644 index 597a0144722..00000000000 --- a/src/test/run-fail/unreachable-macro-panic.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:internal error: entered unreachable code -fn main() { - unreachable!() -} diff --git a/src/test/run-fail/unreachable-static-msg.rs b/src/test/run-fail/unreachable-static-msg.rs deleted file mode 100644 index 40a2881cc57..00000000000 --- a/src/test/run-fail/unreachable-static-msg.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:internal error: entered unreachable code: uhoh -fn main() { - unreachable!("uhoh") -} diff --git a/src/test/run-fail/unreachable.rs b/src/test/run-fail/unreachable.rs deleted file mode 100644 index 597a0144722..00000000000 --- a/src/test/run-fail/unreachable.rs +++ /dev/null @@ -1,4 +0,0 @@ -// error-pattern:internal error: entered unreachable code -fn main() { - unreachable!() -} diff --git a/src/test/run-fail/unwind-interleaved.rs b/src/test/run-fail/unwind-interleaved.rs deleted file mode 100644 index c163678ae98..00000000000 --- a/src/test/run-fail/unwind-interleaved.rs +++ /dev/null @@ -1,14 +0,0 @@ -// error-pattern:fail - -fn a() {} - -fn b() { - panic!(); -} - -fn main() { - let _x = vec![0]; - a(); - let _y = vec![0]; - b(); -} diff --git a/src/test/run-fail/unwind-rec.rs b/src/test/run-fail/unwind-rec.rs deleted file mode 100644 index 83ac19ff4a5..00000000000 --- a/src/test/run-fail/unwind-rec.rs +++ /dev/null @@ -1,14 +0,0 @@ -// error-pattern:fail - - -fn build() -> Vec { - panic!(); -} - -struct Blk { - node: Vec, -} - -fn main() { - let _blk = Blk { node: build() }; -} diff --git a/src/test/run-fail/unwind-rec2.rs b/src/test/run-fail/unwind-rec2.rs deleted file mode 100644 index 4dfc282b6c0..00000000000 --- a/src/test/run-fail/unwind-rec2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// error-pattern:fail - - -fn build1() -> Vec { - vec![0, 0, 0, 0, 0, 0, 0] -} - -fn build2() -> Vec { - panic!(); -} - -struct Blk { - node: Vec, - span: Vec, -} - -fn main() { - let _blk = Blk { - node: build1(), - span: build2(), - }; -} diff --git a/src/test/run-fail/unwind-unique.rs b/src/test/run-fail/unwind-unique.rs deleted file mode 100644 index 7b761faad95..00000000000 --- a/src/test/run-fail/unwind-unique.rs +++ /dev/null @@ -1,10 +0,0 @@ -// error-pattern:fail - -fn failfn() { - panic!(); -} - -fn main() { - Box::new(0); - failfn(); -} diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs deleted file mode 100644 index 2be945f736c..00000000000 --- a/src/test/run-fail/vec-overrun.rs +++ /dev/null @@ -1,11 +0,0 @@ -// error-pattern:index out of bounds: the len is 1 but the index is 2 - - -fn main() { - let v: Vec = vec![10]; - let x: usize = 0; - assert_eq!(v[x], 10); - // Bounds-check panic. - - assert_eq!(v[x + 2], 20); -} diff --git a/src/test/run-fail/while-body-panics.rs b/src/test/run-fail/while-body-panics.rs deleted file mode 100644 index 76acb4ba42d..00000000000 --- a/src/test/run-fail/while-body-panics.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![allow(while_true)] - -// error-pattern:quux -fn main() { - let _x: isize = { - while true { - panic!("quux"); - } - 8 - }; -} diff --git a/src/test/run-fail/while-panic.rs b/src/test/run-fail/while-panic.rs deleted file mode 100644 index a0827591729..00000000000 --- a/src/test/run-fail/while-panic.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![allow(while_true)] - -// error-pattern:giraffe -fn main() { - panic!({ - while true { - panic!("giraffe") - } - "clandestine" - }); -} diff --git a/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs b/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs new file mode 100644 index 00000000000..70cbb067254 --- /dev/null +++ b/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:index out of bounds + +use std::usize; +use std::mem::size_of; + +fn main() { + let xs = [1, 2, 3]; + xs[usize::MAX / size_of::() + 1]; +} diff --git a/src/test/ui/array-slice-vec/dst-raw-slice.rs b/src/test/ui/array-slice-vec/dst-raw-slice.rs new file mode 100644 index 00000000000..33db126944d --- /dev/null +++ b/src/test/ui/array-slice-vec/dst-raw-slice.rs @@ -0,0 +1,11 @@ +// Test bounds checking for DST raw slices + +// run-fail +// error-pattern:index out of bounds +#[allow(unconditional_panic)] +fn main() { + let a: *const [_] = &[1, 2, 3]; + unsafe { + let _b = (*a)[3]; + } +} diff --git a/src/test/ui/binop/binop-fail-3.rs b/src/test/ui/binop/binop-fail-3.rs new file mode 100644 index 00000000000..7120a5c1f19 --- /dev/null +++ b/src/test/ui/binop/binop-fail-3.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:quux + +fn foo() -> ! { + panic!("quux"); +} + +fn main() { + foo() == foo(); // these types wind up being defaulted to () +} diff --git a/src/test/ui/binop/binop-panic.rs b/src/test/ui/binop/binop-panic.rs new file mode 100644 index 00000000000..6927b96c1b3 --- /dev/null +++ b/src/test/ui/binop/binop-panic.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:quux + +fn my_err(s: String) -> ! { + println!("{}", s); + panic!("quux"); +} + +fn main() { + 3_usize == my_err("bye".to_string()); +} diff --git a/src/test/ui/borrowck/borrowck-local-borrow.rs b/src/test/ui/borrowck/borrowck-local-borrow.rs new file mode 100644 index 00000000000..c2b59ecce86 --- /dev/null +++ b/src/test/ui/borrowck/borrowck-local-borrow.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:panic 1 + +// revisions: migrate mir +//[mir]compile-flags: -Z borrowck=mir + +fn main() { + let x = 2; + let y = &x; + panic!("panic 1"); +} diff --git a/src/test/ui/closures/diverging-closure.rs b/src/test/ui/closures/diverging-closure.rs new file mode 100644 index 00000000000..de7b68ef684 --- /dev/null +++ b/src/test/ui/closures/diverging-closure.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:oops + +fn main() { + let func = || -> ! { + panic!("oops"); + }; + func(); +} diff --git a/src/test/ui/consts/promoted_div_by_zero.rs b/src/test/ui/consts/promoted_div_by_zero.rs new file mode 100644 index 00000000000..582c186b4e4 --- /dev/null +++ b/src/test/ui/consts/promoted_div_by_zero.rs @@ -0,0 +1,8 @@ +#![allow(unconditional_panic, const_err)] + +// run-fail +// error-pattern: attempt to divide by zero + +fn main() { + let x = &(1 / (1 - 1)); +} diff --git a/src/test/ui/fn/expr-fn-panic.rs b/src/test/ui/fn/expr-fn-panic.rs new file mode 100644 index 00000000000..e93439a1d17 --- /dev/null +++ b/src/test/ui/fn/expr-fn-panic.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:explicit panic + +fn f() -> ! { + panic!() +} + +fn main() { + f(); +} diff --git a/src/test/ui/generator/generator-resume-after-panic.rs b/src/test/ui/generator/generator-resume-after-panic.rs new file mode 100644 index 00000000000..1e9a7ed1e94 --- /dev/null +++ b/src/test/ui/generator/generator-resume-after-panic.rs @@ -0,0 +1,23 @@ +// run-fail +// error-pattern:generator resumed after panicking + +// Test that we get the correct message for resuming a panicked generator. + +#![feature(generators, generator_trait)] + +use std::{ + ops::Generator, + pin::Pin, + panic, +}; + +fn main() { + let mut g = || { + panic!(); + yield; + }; + panic::catch_unwind(panic::AssertUnwindSafe(|| { + let x = Pin::new(&mut g).resume(()); + })); + Pin::new(&mut g).resume(()); +} diff --git a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr b/src/test/ui/hashmap-iter-value-lifetime.nll.stderr deleted file mode 100644 index 312a91adca6..00000000000 --- a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-iter-value-lifetime.rs:7:5 - | -LL | let (_, thing) = my_stuff.iter().next().unwrap(); - | -------- immutable borrow occurs here -LL | -LL | my_stuff.clear(); - | ^^^^^^^^ mutable borrow occurs here -LL | -LL | println!("{}", *thing); - | ------ immutable 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/hashmap-iter-value-lifetime.rs b/src/test/ui/hashmap-iter-value-lifetime.rs deleted file mode 100644 index 260ea8c7ae1..00000000000 --- a/src/test/ui/hashmap-iter-value-lifetime.rs +++ /dev/null @@ -1,10 +0,0 @@ -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/hashmap-iter-value-lifetime.stderr b/src/test/ui/hashmap-iter-value-lifetime.stderr deleted file mode 100644 index f7626b13bad..00000000000 --- a/src/test/ui/hashmap-iter-value-lifetime.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-iter-value-lifetime.rs:7:5 - | -LL | let (_, thing) = my_stuff.iter().next().unwrap(); - | -------- immutable borrow occurs here -LL | -LL | my_stuff.clear(); - | ^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | -LL | println!("{}", *thing); - | ------ immutable 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/hashmap-lifetimes.nll.stderr b/src/test/ui/hashmap-lifetimes.nll.stderr deleted file mode 100644 index aa8e890c168..00000000000 --- a/src/test/ui/hashmap-lifetimes.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-lifetimes.rs:6:5 - | -LL | let mut it = my_stuff.iter(); - | -------- immutable borrow occurs here -LL | my_stuff.insert(1, 43); - | ^^^^^^^^ mutable borrow occurs here -LL | it; - | -- immutable 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/hashmap-lifetimes.rs b/src/test/ui/hashmap-lifetimes.rs deleted file mode 100644 index 295bf3b0e66..00000000000 --- a/src/test/ui/hashmap-lifetimes.rs +++ /dev/null @@ -1,8 +0,0 @@ -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 - it; -} diff --git a/src/test/ui/hashmap-lifetimes.stderr b/src/test/ui/hashmap-lifetimes.stderr deleted file mode 100644 index 497c7d1216c..00000000000 --- a/src/test/ui/hashmap-lifetimes.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-lifetimes.rs:6:5 - | -LL | let mut it = my_stuff.iter(); - | -------- immutable borrow occurs here -LL | my_stuff.insert(1, 43); - | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | it; - | -- immutable 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/hashmap-memory.rs b/src/test/ui/hashmap-memory.rs deleted file mode 100644 index 3129eb0da82..00000000000 --- a/src/test/ui/hashmap-memory.rs +++ /dev/null @@ -1,94 +0,0 @@ -// run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] -#![allow(unused_mut)] -// ignore-emscripten No support for threads - -/** - A somewhat reduced test case to expose some Valgrind issues. - - This originally came from the word-count benchmark. -*/ - -pub fn map(filename: String, mut emit: map_reduce::putter) { - emit(filename, "1".to_string()); -} - -mod map_reduce { - use std::collections::HashMap; - use std::sync::mpsc::{channel, Sender}; - use std::str; - use std::thread; - - pub type putter<'a> = Box; - - pub type mapper = extern fn(String, putter); - - enum ctrl_proto { find_reducer(Vec, Sender), mapper_done, } - - fn start_mappers(ctrl: Sender, inputs: Vec) { - for i in &inputs { - let ctrl = ctrl.clone(); - let i = i.clone(); - thread::spawn(move|| map_task(ctrl.clone(), i.clone()) ); - } - } - - fn map_task(ctrl: Sender, input: String) { - let mut intermediates = HashMap::new(); - - fn emit(im: &mut HashMap, - ctrl: Sender, key: String, - _val: String) { - if im.contains_key(&key) { - return; - } - let (tx, rx) = channel(); - println!("sending find_reducer"); - ctrl.send(ctrl_proto::find_reducer(key.as_bytes().to_vec(), tx)).unwrap(); - println!("receiving"); - let c = rx.recv().unwrap(); - println!("{}", c); - im.insert(key, c); - } - - let ctrl_clone = ctrl.clone(); - ::map(input, Box::new(|a,b| emit(&mut intermediates, ctrl.clone(), a, b))); - ctrl_clone.send(ctrl_proto::mapper_done).unwrap(); - } - - pub fn map_reduce(inputs: Vec) { - let (tx, rx) = channel(); - - // This thread becomes the master control thread. It spawns others - // to do the rest. - - let mut reducers: HashMap; - - reducers = HashMap::new(); - - start_mappers(tx, inputs.clone()); - - let mut num_mappers = inputs.len() as isize; - - while num_mappers > 0 { - match rx.recv().unwrap() { - ctrl_proto::mapper_done => { num_mappers -= 1; } - ctrl_proto::find_reducer(k, cc) => { - let mut c; - match reducers.get(&str::from_utf8(&k).unwrap().to_string()) { - Some(&_c) => { c = _c; } - None => { c = 0; } - } - cc.send(c).unwrap(); - } - } - } - } -} - -pub fn main() { - map_reduce::map_reduce( - vec!["../src/test/run-pass/hashmap-memory.rs".to_string()]); -} diff --git a/src/test/ui/hashmap/hashmap-capacity-overflow.rs b/src/test/ui/hashmap/hashmap-capacity-overflow.rs new file mode 100644 index 00000000000..0e904b7b6a4 --- /dev/null +++ b/src/test/ui/hashmap/hashmap-capacity-overflow.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:capacity overflow + +use std::collections::hash_map::HashMap; +use std::usize; +use std::mem::size_of; + +fn main() { + let threshold = usize::MAX / size_of::<(u64, u64, u64)>(); + let mut h = HashMap::::with_capacity(threshold + 100); + h.insert(0, 0); +} diff --git a/src/test/ui/hashmap/hashmap-iter-value-lifetime.nll.stderr b/src/test/ui/hashmap/hashmap-iter-value-lifetime.nll.stderr new file mode 100644 index 00000000000..312a91adca6 --- /dev/null +++ b/src/test/ui/hashmap/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:7:5 + | +LL | let (_, thing) = my_stuff.iter().next().unwrap(); + | -------- immutable borrow occurs here +LL | +LL | my_stuff.clear(); + | ^^^^^^^^ mutable borrow occurs here +LL | +LL | println!("{}", *thing); + | ------ immutable 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/hashmap/hashmap-iter-value-lifetime.rs b/src/test/ui/hashmap/hashmap-iter-value-lifetime.rs new file mode 100644 index 00000000000..260ea8c7ae1 --- /dev/null +++ b/src/test/ui/hashmap/hashmap-iter-value-lifetime.rs @@ -0,0 +1,10 @@ +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/hashmap/hashmap-iter-value-lifetime.stderr b/src/test/ui/hashmap/hashmap-iter-value-lifetime.stderr new file mode 100644 index 00000000000..f7626b13bad --- /dev/null +++ b/src/test/ui/hashmap/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:7:5 + | +LL | let (_, thing) = my_stuff.iter().next().unwrap(); + | -------- immutable borrow occurs here +LL | +LL | my_stuff.clear(); + | ^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | println!("{}", *thing); + | ------ immutable 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/hashmap/hashmap-lifetimes.nll.stderr b/src/test/ui/hashmap/hashmap-lifetimes.nll.stderr new file mode 100644 index 00000000000..aa8e890c168 --- /dev/null +++ b/src/test/ui/hashmap/hashmap-lifetimes.nll.stderr @@ -0,0 +1,13 @@ +error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable + --> $DIR/hashmap-lifetimes.rs:6:5 + | +LL | let mut it = my_stuff.iter(); + | -------- immutable borrow occurs here +LL | my_stuff.insert(1, 43); + | ^^^^^^^^ mutable borrow occurs here +LL | it; + | -- immutable 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/hashmap/hashmap-lifetimes.rs b/src/test/ui/hashmap/hashmap-lifetimes.rs new file mode 100644 index 00000000000..295bf3b0e66 --- /dev/null +++ b/src/test/ui/hashmap/hashmap-lifetimes.rs @@ -0,0 +1,8 @@ +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 + it; +} diff --git a/src/test/ui/hashmap/hashmap-lifetimes.stderr b/src/test/ui/hashmap/hashmap-lifetimes.stderr new file mode 100644 index 00000000000..497c7d1216c --- /dev/null +++ b/src/test/ui/hashmap/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:6:5 + | +LL | let mut it = my_stuff.iter(); + | -------- immutable borrow occurs here +LL | my_stuff.insert(1, 43); + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | it; + | -- immutable 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/hashmap/hashmap-memory.rs b/src/test/ui/hashmap/hashmap-memory.rs new file mode 100644 index 00000000000..3129eb0da82 --- /dev/null +++ b/src/test/ui/hashmap/hashmap-memory.rs @@ -0,0 +1,94 @@ +// run-pass + +#![allow(non_camel_case_types)] +#![allow(dead_code)] +#![allow(unused_mut)] +// ignore-emscripten No support for threads + +/** + A somewhat reduced test case to expose some Valgrind issues. + + This originally came from the word-count benchmark. +*/ + +pub fn map(filename: String, mut emit: map_reduce::putter) { + emit(filename, "1".to_string()); +} + +mod map_reduce { + use std::collections::HashMap; + use std::sync::mpsc::{channel, Sender}; + use std::str; + use std::thread; + + pub type putter<'a> = Box; + + pub type mapper = extern fn(String, putter); + + enum ctrl_proto { find_reducer(Vec, Sender), mapper_done, } + + fn start_mappers(ctrl: Sender, inputs: Vec) { + for i in &inputs { + let ctrl = ctrl.clone(); + let i = i.clone(); + thread::spawn(move|| map_task(ctrl.clone(), i.clone()) ); + } + } + + fn map_task(ctrl: Sender, input: String) { + let mut intermediates = HashMap::new(); + + fn emit(im: &mut HashMap, + ctrl: Sender, key: String, + _val: String) { + if im.contains_key(&key) { + return; + } + let (tx, rx) = channel(); + println!("sending find_reducer"); + ctrl.send(ctrl_proto::find_reducer(key.as_bytes().to_vec(), tx)).unwrap(); + println!("receiving"); + let c = rx.recv().unwrap(); + println!("{}", c); + im.insert(key, c); + } + + let ctrl_clone = ctrl.clone(); + ::map(input, Box::new(|a,b| emit(&mut intermediates, ctrl.clone(), a, b))); + ctrl_clone.send(ctrl_proto::mapper_done).unwrap(); + } + + pub fn map_reduce(inputs: Vec) { + let (tx, rx) = channel(); + + // This thread becomes the master control thread. It spawns others + // to do the rest. + + let mut reducers: HashMap; + + reducers = HashMap::new(); + + start_mappers(tx, inputs.clone()); + + let mut num_mappers = inputs.len() as isize; + + while num_mappers > 0 { + match rx.recv().unwrap() { + ctrl_proto::mapper_done => { num_mappers -= 1; } + ctrl_proto::find_reducer(k, cc) => { + let mut c; + match reducers.get(&str::from_utf8(&k).unwrap().to_string()) { + Some(&_c) => { c = _c; } + None => { c = 0; } + } + cc.send(c).unwrap(); + } + } + } + } +} + +pub fn main() { + map_reduce::map_reduce( + vec!["../src/test/run-pass/hashmap-memory.rs".to_string()]); +} diff --git a/src/test/ui/if/expr-if-panic-fn.rs b/src/test/ui/if/expr-if-panic-fn.rs new file mode 100644 index 00000000000..7ddd4bc5e0f --- /dev/null +++ b/src/test/ui/if/expr-if-panic-fn.rs @@ -0,0 +1,19 @@ +// run-fail +// error-pattern:explicit panic + +fn f() -> ! { + panic!() +} + +fn g() -> isize { + let x = if true { + f() + } else { + 10 + }; + return x; +} + +fn main() { + g(); +} diff --git a/src/test/ui/if/expr-if-panic.rs b/src/test/ui/if/expr-if-panic.rs new file mode 100644 index 00000000000..4ab73dc736a --- /dev/null +++ b/src/test/ui/if/expr-if-panic.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:explicit panic + +fn main() { + let _x = if false { + 0 + } else if true { + panic!() + } else { + 10 + }; +} diff --git a/src/test/ui/if/if-check-panic.rs b/src/test/ui/if/if-check-panic.rs new file mode 100644 index 00000000000..d768cf10c8b --- /dev/null +++ b/src/test/ui/if/if-check-panic.rs @@ -0,0 +1,24 @@ +// run-fail +// error-pattern:Number is odd + +fn even(x: usize) -> bool { + if x < 2 { + return false; + } else if x == 2 { + return true; + } else { + return even(x - 2); + } +} + +fn foo(x: usize) { + if even(x) { + println!("{}", x); + } else { + panic!("Number is odd"); + } +} + +fn main() { + foo(3); +} diff --git a/src/test/ui/if/if-cond-bot.rs b/src/test/ui/if/if-cond-bot.rs new file mode 100644 index 00000000000..3bbea458446 --- /dev/null +++ b/src/test/ui/if/if-cond-bot.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:quux + +fn my_err(s: String) -> ! { + println!("{}", s); + panic!("quux"); +} + +fn main() { + if my_err("bye".to_string()) { + } +} diff --git a/src/test/ui/imports/glob-use-std.rs b/src/test/ui/imports/glob-use-std.rs new file mode 100644 index 00000000000..3cd6a380ed2 --- /dev/null +++ b/src/test/ui/imports/glob-use-std.rs @@ -0,0 +1,10 @@ +// Issue #7580 + +// run-fail +// error-pattern:panic works + +use std::*; + +fn main() { + panic!("panic works") +} diff --git a/src/test/ui/issues/issue-12920.rs b/src/test/ui/issues/issue-12920.rs new file mode 100644 index 00000000000..85d199f6d82 --- /dev/null +++ b/src/test/ui/issues/issue-12920.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:explicit panic + +pub fn main() { + panic!(); + println!("{}", 1); +} diff --git a/src/test/ui/issues/issue-13202.rs b/src/test/ui/issues/issue-13202.rs new file mode 100644 index 00000000000..511273bae9d --- /dev/null +++ b/src/test/ui/issues/issue-13202.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:bad input + +fn main() { + Some("foo").unwrap_or(panic!("bad input")).to_string(); +} diff --git a/src/test/ui/issues/issue-18576.rs b/src/test/ui/issues/issue-18576.rs new file mode 100644 index 00000000000..946d2d47369 --- /dev/null +++ b/src/test/ui/issues/issue-18576.rs @@ -0,0 +1,15 @@ +// run-fail +// error-pattern:stop + +// #18576 +// Make sure that calling an extern function pointer in an unreachable +// context doesn't cause an LLVM assertion + +#[allow(unreachable_code)] +fn main() { + panic!("stop"); + let pointer = other; + pointer(); +} + +extern "C" fn other() {} diff --git a/src/test/ui/issues/issue-20971.rs b/src/test/ui/issues/issue-20971.rs new file mode 100644 index 00000000000..4fb901e2272 --- /dev/null +++ b/src/test/ui/issues/issue-20971.rs @@ -0,0 +1,22 @@ +// Regression test for Issue #20971. + +// run-fail +// error-pattern:Hello, world! + +pub trait Parser { + type Input; + fn parse(&mut self, input: ::Input); +} + +impl Parser for () { + type Input = (); + fn parse(&mut self, input: ()) {} +} + +pub fn many() -> Box::Input> + 'static> { + panic!("Hello, world!") +} + +fn main() { + many().parse(()); +} diff --git a/src/test/ui/issues/issue-23354-2.rs b/src/test/ui/issues/issue-23354-2.rs new file mode 100644 index 00000000000..1a3ed103060 --- /dev/null +++ b/src/test/ui/issues/issue-23354-2.rs @@ -0,0 +1,8 @@ +// run-fail +// error-pattern:panic evaluated + +#[allow(unused_variables)] +fn main() { + // This used to trigger an LLVM assertion during compilation + let x = [panic!("panic evaluated"); 2]; +} diff --git a/src/test/ui/issues/issue-23354.rs b/src/test/ui/issues/issue-23354.rs new file mode 100644 index 00000000000..77b7dbf99da --- /dev/null +++ b/src/test/ui/issues/issue-23354.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:panic evaluated + +#[allow(unused_variables)] +fn main() { + let x = [panic!("panic evaluated"); 0]; +} diff --git a/src/test/ui/issues/issue-2444.rs b/src/test/ui/issues/issue-2444.rs new file mode 100644 index 00000000000..35d8eabcd60 --- /dev/null +++ b/src/test/ui/issues/issue-2444.rs @@ -0,0 +1,16 @@ +// run-fail +// error-pattern:explicit panic + +use std::sync::Arc; + +enum Err { + Errr(Arc), +} + +fn foo() -> Err { + panic!(); +} + +fn main() { + let _f = foo(); +} diff --git a/src/test/ui/issues/issue-2470-bounds-check-overflow.rs b/src/test/ui/issues/issue-2470-bounds-check-overflow.rs new file mode 100644 index 00000000000..86558c228c5 --- /dev/null +++ b/src/test/ui/issues/issue-2470-bounds-check-overflow.rs @@ -0,0 +1,26 @@ +// run-fail +// error-pattern:index out of bounds + +use std::mem; + +fn main() { + + // This should cause a bounds-check panic, but may not if we do our + // bounds checking by comparing the scaled index to the vector's + // address-bounds, since we've scaled the index to wrap around to the + // address of the 0th cell in the array (even though the index is + // huge). + + let x = vec![1_usize, 2_usize, 3_usize]; + + let base = x.as_ptr() as usize; + let idx = base / mem::size_of::(); + println!("ov1 base = 0x{:x}", base); + println!("ov1 idx = 0x{:x}", idx); + println!("ov1 sizeof::() = 0x{:x}", mem::size_of::()); + println!("ov1 idx * sizeof::() = 0x{:x}", + idx * mem::size_of::()); + + // This should panic. + println!("ov1 0x{:x}", x[idx]); +} diff --git a/src/test/ui/issues/issue-2761.rs b/src/test/ui/issues/issue-2761.rs new file mode 100644 index 00000000000..43756645925 --- /dev/null +++ b/src/test/ui/issues/issue-2761.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:custom message + +fn main() { + assert!(false, "custom message"); +} diff --git a/src/test/ui/issues/issue-28934.rs b/src/test/ui/issues/issue-28934.rs new file mode 100644 index 00000000000..fcf91d74fbe --- /dev/null +++ b/src/test/ui/issues/issue-28934.rs @@ -0,0 +1,24 @@ +// Regression test: issue had to do with "givens" in region inference, +// which were not being considered during the contraction phase. + +// run-fail +// error-pattern:explicit panic + +struct Parser<'i: 't, 't>(&'i u8, &'t u8); + +impl<'i, 't> Parser<'i, 't> { + fn parse_nested_block(&mut self, parse: F) -> Result + where for<'tt> F: FnOnce(&mut Parser<'i, 'tt>) -> T + { + panic!() + } + + fn expect_exhausted(&mut self) -> Result<(), ()> { + Ok(()) + } +} + +fn main() { + let x = 0u8; + Parser(&x, &x).parse_nested_block(|input| input.expect_exhausted()).unwrap(); +} diff --git a/src/test/ui/issues/issue-29798.rs b/src/test/ui/issues/issue-29798.rs new file mode 100644 index 00000000000..31b08f2164a --- /dev/null +++ b/src/test/ui/issues/issue-29798.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:index out of bounds: the len is 5 but the index is 5 + +const fn test(x: usize) -> i32 { + [42;5][x] +} + +fn main () { + let _ = test(5); +} diff --git a/src/test/ui/issues/issue-3029.rs b/src/test/ui/issues/issue-3029.rs new file mode 100644 index 00000000000..aea2368a211 --- /dev/null +++ b/src/test/ui/issues/issue-3029.rs @@ -0,0 +1,13 @@ +// run-fail +// error-pattern:so long + +#![allow(unused_allocation)] +#![allow(unreachable_code)] +#![allow(unused_variables)] + +fn main() { + let mut x = Vec::new(); + let y = vec![3]; + panic!("so long"); + x.extend(y.into_iter()); +} diff --git a/src/test/ui/issues/issue-30380.rs b/src/test/ui/issues/issue-30380.rs new file mode 100644 index 00000000000..34bd6c1b0e5 --- /dev/null +++ b/src/test/ui/issues/issue-30380.rs @@ -0,0 +1,35 @@ +// check that panics in destructors during assignment do not leave +// destroyed values lying around for other destructors to observe. + +// run-fail +// error-pattern:panicking destructors ftw! + +struct Observer<'a>(&'a mut FilledOnDrop); + +struct FilledOnDrop(u32); +impl Drop for FilledOnDrop { + fn drop(&mut self) { + if self.0 == 0 { + // this is only set during the destructor - safe + // code should not be able to observe this. + self.0 = 0x1c1c1c1c; + panic!("panicking destructors ftw!"); + } + } +} + +impl<'a> Drop for Observer<'a> { + fn drop(&mut self) { + assert_eq!(self.0 .0, 1); + } +} + +fn foo(b: &mut Observer) { + *b.0 = FilledOnDrop(1); +} + +fn main() { + let mut bomb = FilledOnDrop(0); + let mut observer = Observer(&mut bomb); + foo(&mut observer); +} diff --git a/src/test/ui/issues/issue-44216-add-instant.rs b/src/test/ui/issues/issue-44216-add-instant.rs new file mode 100644 index 00000000000..b5f48e8cedc --- /dev/null +++ b/src/test/ui/issues/issue-44216-add-instant.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:overflow + +use std::time::{Instant, Duration}; + +fn main() { + let now = Instant::now(); + let _ = now + Duration::from_secs(u64::max_value()); +} diff --git a/src/test/ui/issues/issue-44216-add-system-time.rs b/src/test/ui/issues/issue-44216-add-system-time.rs new file mode 100644 index 00000000000..da28433dde9 --- /dev/null +++ b/src/test/ui/issues/issue-44216-add-system-time.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:overflow + +use std::time::{Duration, SystemTime}; + +fn main() { + let now = SystemTime::now(); + let _ = now + Duration::from_secs(u64::max_value()); +} diff --git a/src/test/ui/issues/issue-44216-sub-instant.rs b/src/test/ui/issues/issue-44216-sub-instant.rs new file mode 100644 index 00000000000..954cf45591f --- /dev/null +++ b/src/test/ui/issues/issue-44216-sub-instant.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:overflow + +use std::time::{Instant, Duration}; + +fn main() { + let now = Instant::now(); + let _ = now - Duration::from_secs(u64::max_value()); +} diff --git a/src/test/ui/issues/issue-44216-sub-system-time.rs b/src/test/ui/issues/issue-44216-sub-system-time.rs new file mode 100644 index 00000000000..e024e231565 --- /dev/null +++ b/src/test/ui/issues/issue-44216-sub-system-time.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:overflow + +use std::time::{Duration, SystemTime}; + +fn main() { + let now = SystemTime::now(); + let _ = now - Duration::from_secs(u64::max_value()); +} diff --git a/src/test/ui/issues/issue-51345-2.rs b/src/test/ui/issues/issue-51345-2.rs new file mode 100644 index 00000000000..4abdba6176a --- /dev/null +++ b/src/test/ui/issues/issue-51345-2.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern: thread 'main' panicked at 'explicit panic' + +fn main() { + let mut vec = vec![]; + vec.push((vec.len(), panic!())); +} diff --git a/src/test/ui/issues/issue-6458-1.rs b/src/test/ui/issues/issue-6458-1.rs new file mode 100644 index 00000000000..16c479a6a5c --- /dev/null +++ b/src/test/ui/issues/issue-6458-1.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:explicit panic + +fn foo(t: T) {} +fn main() { + foo(panic!()) +} diff --git a/src/test/ui/issues/issue-811.rs b/src/test/ui/issues/issue-811.rs new file mode 100644 index 00000000000..d16467e4b51 --- /dev/null +++ b/src/test/ui/issues/issue-811.rs @@ -0,0 +1,25 @@ +// run-fail +// error-pattern:quux + +use std::marker::PhantomData; + +fn test00_start(ch: Chan, message: isize) { + send(ch, message); +} + +type TaskId = isize; +type PortId = isize; + +struct Chan { + task: TaskId, + port: PortId, + marker: PhantomData<*mut T>, +} + +fn send(_ch: Chan, _data: T) { + panic!(); +} + +fn main() { + panic!("quux"); +} diff --git a/src/test/ui/issues/issue-948.rs b/src/test/ui/issues/issue-948.rs new file mode 100644 index 00000000000..ab0cee71929 --- /dev/null +++ b/src/test/ui/issues/issue-948.rs @@ -0,0 +1,14 @@ +// run-fail +// error-pattern:beep boop + +#![allow(unused_variables)] + +struct Point { + x: isize, + y: isize, +} + +fn main() { + let origin = Point { x: 0, y: 0 }; + let f: Point = Point { x: (panic!("beep boop")), ..origin }; +} diff --git a/src/test/ui/loops/for-each-loop-panic.rs b/src/test/ui/loops/for-each-loop-panic.rs new file mode 100644 index 00000000000..1d0dbe176ae --- /dev/null +++ b/src/test/ui/loops/for-each-loop-panic.rs @@ -0,0 +1,8 @@ +// run-fail +// error-pattern:moop + +fn main() { + for _ in 0_usize..10_usize { + panic!("moop"); + } +} diff --git a/src/test/ui/macros/assert-as-macro.rs b/src/test/ui/macros/assert-as-macro.rs new file mode 100644 index 00000000000..bc51b673606 --- /dev/null +++ b/src/test/ui/macros/assert-as-macro.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:assertion failed: 1 == 2 + +fn main() { + assert!(1 == 2); +} diff --git a/src/test/ui/macros/assert-eq-macro-panic.rs b/src/test/ui/macros/assert-eq-macro-panic.rs new file mode 100644 index 00000000000..bd4eb78de9f --- /dev/null +++ b/src/test/ui/macros/assert-eq-macro-panic.rs @@ -0,0 +1,8 @@ +// run-fail +// error-pattern:assertion failed: `(left == right)` +// error-pattern: left: `14` +// error-pattern:right: `15` + +fn main() { + assert_eq!(14, 15); +} diff --git a/src/test/ui/macros/assert-macro-explicit.rs b/src/test/ui/macros/assert-macro-explicit.rs new file mode 100644 index 00000000000..da13c06d575 --- /dev/null +++ b/src/test/ui/macros/assert-macro-explicit.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'assertion failed: false' + +fn main() { + assert!(false); +} diff --git a/src/test/ui/macros/assert-macro-fmt.rs b/src/test/ui/macros/assert-macro-fmt.rs new file mode 100644 index 00000000000..3b173156d7a --- /dev/null +++ b/src/test/ui/macros/assert-macro-fmt.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'test-assert-fmt 42 rust' + +fn main() { + assert!(false, "test-assert-fmt {} {}", 42, "rust"); +} diff --git a/src/test/ui/macros/assert-macro-owned.rs b/src/test/ui/macros/assert-macro-owned.rs new file mode 100644 index 00000000000..c231ceb46e9 --- /dev/null +++ b/src/test/ui/macros/assert-macro-owned.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'test-assert-owned' + +fn main() { + assert!(false, "test-assert-owned".to_string()); +} diff --git a/src/test/ui/macros/assert-macro-static.rs b/src/test/ui/macros/assert-macro-static.rs new file mode 100644 index 00000000000..3c988ba4469 --- /dev/null +++ b/src/test/ui/macros/assert-macro-static.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'test-assert-static' + +fn main() { + assert!(false, "test-assert-static"); +} diff --git a/src/test/ui/macros/assert-ne-macro-panic.rs b/src/test/ui/macros/assert-ne-macro-panic.rs new file mode 100644 index 00000000000..0e505e58e2b --- /dev/null +++ b/src/test/ui/macros/assert-ne-macro-panic.rs @@ -0,0 +1,8 @@ +// run-fail +// error-pattern:assertion failed: `(left != right)` +// error-pattern: left: `14` +// error-pattern:right: `14` + +fn main() { + assert_ne!(14, 14); +} diff --git a/src/test/ui/macros/die-macro-2.rs b/src/test/ui/macros/die-macro-2.rs new file mode 100644 index 00000000000..11a3222440d --- /dev/null +++ b/src/test/ui/macros/die-macro-2.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:test + +fn main() { + panic!("test"); +} diff --git a/src/test/ui/macros/die-macro-expr.rs b/src/test/ui/macros/die-macro-expr.rs new file mode 100644 index 00000000000..05f821acdf5 --- /dev/null +++ b/src/test/ui/macros/die-macro-expr.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:test + +fn main() { + let __isize: isize = panic!("test"); +} diff --git a/src/test/ui/macros/die-macro-pure.rs b/src/test/ui/macros/die-macro-pure.rs new file mode 100644 index 00000000000..1a86a7c22cc --- /dev/null +++ b/src/test/ui/macros/die-macro-pure.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:test + +fn f() { + panic!("test"); +} + +fn main() { + f(); +} diff --git a/src/test/ui/macros/unimplemented-macro-panic.rs b/src/test/ui/macros/unimplemented-macro-panic.rs new file mode 100644 index 00000000000..37932ca7670 --- /dev/null +++ b/src/test/ui/macros/unimplemented-macro-panic.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:not implemented + +fn main() { + unimplemented!() +} diff --git a/src/test/ui/macros/unreachable-fmt-msg.rs b/src/test/ui/macros/unreachable-fmt-msg.rs new file mode 100644 index 00000000000..b2df8f82500 --- /dev/null +++ b/src/test/ui/macros/unreachable-fmt-msg.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:internal error: entered unreachable code: 6 is not prime + +fn main() { + unreachable!("{} is not {}", 6u32, "prime"); +} diff --git a/src/test/ui/macros/unreachable-macro-panic.rs b/src/test/ui/macros/unreachable-macro-panic.rs new file mode 100644 index 00000000000..ad0d82feeaf --- /dev/null +++ b/src/test/ui/macros/unreachable-macro-panic.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:internal error: entered unreachable code + +fn main() { + unreachable!() +} diff --git a/src/test/ui/macros/unreachable-static-msg.rs b/src/test/ui/macros/unreachable-static-msg.rs new file mode 100644 index 00000000000..b59d1960511 --- /dev/null +++ b/src/test/ui/macros/unreachable-static-msg.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:internal error: entered unreachable code: uhoh + +fn main() { + unreachable!("uhoh") +} diff --git a/src/test/ui/macros/unreachable.rs b/src/test/ui/macros/unreachable.rs new file mode 100644 index 00000000000..ad0d82feeaf --- /dev/null +++ b/src/test/ui/macros/unreachable.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:internal error: entered unreachable code + +fn main() { + unreachable!() +} diff --git a/src/test/ui/match/expr-match-panic-fn.rs b/src/test/ui/match/expr-match-panic-fn.rs new file mode 100644 index 00000000000..c5bd7382f9f --- /dev/null +++ b/src/test/ui/match/expr-match-panic-fn.rs @@ -0,0 +1,18 @@ +// run-fail +// error-pattern:explicit panic + +fn f() -> ! { + panic!() +} + +fn g() -> isize { + let x = match true { + true => f(), + false => 10, + }; + return x; +} + +fn main() { + g(); +} diff --git a/src/test/ui/match/expr-match-panic.rs b/src/test/ui/match/expr-match-panic.rs new file mode 100644 index 00000000000..76144314fad --- /dev/null +++ b/src/test/ui/match/expr-match-panic.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:explicit panic + +fn main() { + let _x = match true { + false => 0, + true => panic!(), + }; +} diff --git a/src/test/ui/match/match-bot-panic.rs b/src/test/ui/match/match-bot-panic.rs new file mode 100644 index 00000000000..8b147cb5ab6 --- /dev/null +++ b/src/test/ui/match/match-bot-panic.rs @@ -0,0 +1,15 @@ +// run-fail +// error-pattern:explicit panic + +#![allow(unreachable_code)] +#![allow(unused_variables)] + +fn foo(s: String) {} + +fn main() { + let i = match Some::(3) { + None:: => panic!(), + Some::(_) => panic!(), + }; + foo(i); +} diff --git a/src/test/ui/match/match-disc-bot.rs b/src/test/ui/match/match-disc-bot.rs new file mode 100644 index 00000000000..785237b34af --- /dev/null +++ b/src/test/ui/match/match-disc-bot.rs @@ -0,0 +1,15 @@ +// run-fail +// error-pattern:quux + +fn f() -> ! { + panic!("quux") +} +fn g() -> isize { + match f() { + true => 1, + false => 0, + } +} +fn main() { + g(); +} diff --git a/src/test/ui/match/match-wildcards.rs b/src/test/ui/match/match-wildcards.rs new file mode 100644 index 00000000000..b79fd03c133 --- /dev/null +++ b/src/test/ui/match/match-wildcards.rs @@ -0,0 +1,20 @@ +// run-fail +// error-pattern:squirrelcupcake + +fn cmp() -> isize { + match (Some('a'), None::) { + (Some(_), _) => { + panic!("squirrelcupcake"); + } + (_, Some(_)) => { + panic!(); + } + _ => { + panic!("wat"); + } + } +} + +fn main() { + println!("{}", cmp()); +} diff --git a/src/test/ui/meta-revision-bad.rs b/src/test/ui/meta-revision-bad.rs new file mode 100644 index 00000000000..01f1518c1c6 --- /dev/null +++ b/src/test/ui/meta-revision-bad.rs @@ -0,0 +1,21 @@ +// Meta test for compiletest: check that when we give the wrong error +// patterns, the test fails. + +// run-fail +// revisions: foo bar +// should-fail +//[foo] error-pattern:bar +//[bar] error-pattern:foo + +#[cfg(foo)] +fn die() { + panic!("foo"); +} +#[cfg(bar)] +fn die() { + panic!("bar"); +} + +fn main() { + die(); +} diff --git a/src/test/ui/meta-revision-ok.rs b/src/test/ui/meta-revision-ok.rs new file mode 100644 index 00000000000..c77ce084a5c --- /dev/null +++ b/src/test/ui/meta-revision-ok.rs @@ -0,0 +1,20 @@ +// Meta test for compiletest: check that when we give the right error +// patterns, the test passes. See all `meta-revision-bad.rs`. + +// run-fail +// revisions: foo bar +//[foo] error-pattern:foo +//[bar] error-pattern:bar + +#[cfg(foo)] +fn die() { + panic!("foo"); +} +#[cfg(bar)] +fn die() { + panic!("bar"); +} + +fn main() { + die(); +} diff --git a/src/test/ui/mir/mir_codegen_calls_converging_drops.rs b/src/test/ui/mir/mir_codegen_calls_converging_drops.rs new file mode 100644 index 00000000000..7b31c1aa12e --- /dev/null +++ b/src/test/ui/mir/mir_codegen_calls_converging_drops.rs @@ -0,0 +1,25 @@ +// run-fail +// error-pattern:converging_fn called +// error-pattern:0 dropped +// error-pattern:exit + +struct Droppable(u8); +impl Drop for Droppable { + fn drop(&mut self) { + eprintln!("{} dropped", self.0); + } +} + +fn converging_fn() { + eprintln!("converging_fn called"); +} + +fn mir(d: Droppable) { + converging_fn(); +} + +fn main() { + let d = Droppable(0); + mir(d); + panic!("exit"); +} diff --git a/src/test/ui/mir/mir_codegen_calls_converging_drops_2.rs b/src/test/ui/mir/mir_codegen_calls_converging_drops_2.rs new file mode 100644 index 00000000000..f8117887c90 --- /dev/null +++ b/src/test/ui/mir/mir_codegen_calls_converging_drops_2.rs @@ -0,0 +1,29 @@ +// run-fail +// error-pattern:complex called +// error-pattern:dropped +// error-pattern:exit + +struct Droppable; +impl Drop for Droppable { + fn drop(&mut self) { + eprintln!("dropped"); + } +} + +// return value of this function is copied into the return slot +fn complex() -> u64 { + eprintln!("complex called"); + 42 +} + + +fn mir() -> u64 { + let x = Droppable; + return complex(); + drop(x); +} + +pub fn main() { + assert_eq!(mir(), 42); + panic!("exit"); +} diff --git a/src/test/ui/mir/mir_codegen_calls_diverging.rs b/src/test/ui/mir/mir_codegen_calls_diverging.rs new file mode 100644 index 00000000000..96630da4d49 --- /dev/null +++ b/src/test/ui/mir/mir_codegen_calls_diverging.rs @@ -0,0 +1,14 @@ +// run-fail +// error-pattern:diverging_fn called + +fn diverging_fn() -> ! { + panic!("diverging_fn called") +} + +fn mir() { + diverging_fn(); +} + +fn main() { + mir(); +} diff --git a/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs b/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs new file mode 100644 index 00000000000..96a03a0d6a7 --- /dev/null +++ b/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs @@ -0,0 +1,23 @@ +// run-fail +// error-pattern:diverging_fn called +// error-pattern:0 dropped + +struct Droppable(u8); +impl Drop for Droppable { + fn drop(&mut self) { + eprintln!("{} dropped", self.0); + } +} + +fn diverging_fn() -> ! { + panic!("diverging_fn called") +} + +fn mir(d: Droppable) { + diverging_fn(); +} + +fn main() { + let d = Droppable(0); + mir(d); +} diff --git a/src/test/ui/mir/mir_drop_panics.rs b/src/test/ui/mir/mir_drop_panics.rs new file mode 100644 index 00000000000..da6d0b6a346 --- /dev/null +++ b/src/test/ui/mir/mir_drop_panics.rs @@ -0,0 +1,23 @@ +// run-fail +// error-pattern:panic 1 +// error-pattern:drop 2 + +struct Droppable(u32); +impl Drop for Droppable { + fn drop(&mut self) { + if self.0 == 1 { + panic!("panic 1"); + } else { + eprintln!("drop {}", self.0); + } + } +} + +fn mir() { + let x = Droppable(2); + let y = Droppable(1); +} + +fn main() { + mir(); +} diff --git a/src/test/ui/mir/mir_dynamic_drops_1.rs b/src/test/ui/mir/mir_dynamic_drops_1.rs new file mode 100644 index 00000000000..524f13d754d --- /dev/null +++ b/src/test/ui/mir/mir_dynamic_drops_1.rs @@ -0,0 +1,31 @@ +// run-fail +// error-pattern:drop 1 +// error-pattern:drop 2 +// ignore-cloudabi no std::process + +/// Structure which will not allow to be dropped twice. +struct Droppable<'a>(&'a mut bool, u32); +impl<'a> Drop for Droppable<'a> { + fn drop(&mut self) { + if *self.0 { + eprintln!("{} dropped twice", self.1); + ::std::process::exit(1); + } + eprintln!("drop {}", self.1); + *self.0 = true; + } +} + +fn mir() { + let (mut xv, mut yv) = (false, false); + let x = Droppable(&mut xv, 1); + let y = Droppable(&mut yv, 2); + let mut z = x; + let k = y; + z = k; +} + +fn main() { + mir(); + panic!(); +} diff --git a/src/test/ui/mir/mir_dynamic_drops_2.rs b/src/test/ui/mir/mir_dynamic_drops_2.rs new file mode 100644 index 00000000000..8415b99bcf9 --- /dev/null +++ b/src/test/ui/mir/mir_dynamic_drops_2.rs @@ -0,0 +1,29 @@ +// run-fail +// error-pattern:drop 1 +// ignore-cloudabi no std::process + +/// Structure which will not allow to be dropped twice. +struct Droppable<'a>(&'a mut bool, u32); +impl<'a> Drop for Droppable<'a> { + fn drop(&mut self) { + if *self.0 { + eprintln!("{} dropped twice", self.1); + ::std::process::exit(1); + } + eprintln!("drop {}", self.1); + *self.0 = true; + } +} + +fn mir<'a>(d: Droppable<'a>) { + loop { + let x = d; + break; + } +} + +fn main() { + let mut xv = false; + mir(Droppable(&mut xv, 1)); + panic!(); +} diff --git a/src/test/ui/mir/mir_dynamic_drops_3.rs b/src/test/ui/mir/mir_dynamic_drops_3.rs new file mode 100644 index 00000000000..18914fdb03d --- /dev/null +++ b/src/test/ui/mir/mir_dynamic_drops_3.rs @@ -0,0 +1,34 @@ +// run-fail +// error-pattern:unwind happens +// error-pattern:drop 3 +// error-pattern:drop 2 +// error-pattern:drop 1 +// ignore-cloudabi no std::process + +/// Structure which will not allow to be dropped twice. +struct Droppable<'a>(&'a mut bool, u32); +impl<'a> Drop for Droppable<'a> { + fn drop(&mut self) { + if *self.0 { + eprintln!("{} dropped twice", self.1); + ::std::process::exit(1); + } + eprintln!("drop {}", self.1); + *self.0 = true; + } +} + +fn may_panic<'a>() -> Droppable<'a> { + panic!("unwind happens"); +} + +fn mir<'a>(d: Droppable<'a>) { + let (mut a, mut b) = (false, false); + let y = Droppable(&mut a, 2); + let x = [Droppable(&mut b, 1), y, d, may_panic()]; +} + +fn main() { + let mut c = false; + mir(Droppable(&mut c, 3)); +} diff --git a/src/test/ui/mir/mir_indexing_oob_1.rs b/src/test/ui/mir/mir_indexing_oob_1.rs new file mode 100644 index 00000000000..d46d3704779 --- /dev/null +++ b/src/test/ui/mir/mir_indexing_oob_1.rs @@ -0,0 +1,13 @@ +// run-fail +// error-pattern:index out of bounds: the len is 5 but the index is 10 + +const C: [u32; 5] = [0; 5]; + +#[allow(unconditional_panic)] +fn test() -> u32 { + C[10] +} + +fn main() { + test(); +} diff --git a/src/test/ui/mir/mir_indexing_oob_2.rs b/src/test/ui/mir/mir_indexing_oob_2.rs new file mode 100644 index 00000000000..03b3ea01d6b --- /dev/null +++ b/src/test/ui/mir/mir_indexing_oob_2.rs @@ -0,0 +1,13 @@ +// run-fail +// error-pattern:index out of bounds: the len is 5 but the index is 10 + +const C: &'static [u8; 5] = b"hello"; + +#[allow(unconditional_panic)] +fn test() -> u8 { + C[10] +} + +fn main() { + test(); +} diff --git a/src/test/ui/mir/mir_indexing_oob_3.rs b/src/test/ui/mir/mir_indexing_oob_3.rs new file mode 100644 index 00000000000..023d65c4bd0 --- /dev/null +++ b/src/test/ui/mir/mir_indexing_oob_3.rs @@ -0,0 +1,13 @@ +// run-fail +// error-pattern:index out of bounds: the len is 5 but the index is 10 + +const C: &'static [u8; 5] = b"hello"; + +#[allow(unconditional_panic)] +fn mir() -> u8 { + C[10] +} + +fn main() { + mir(); +} diff --git a/src/test/ui/never_type/return-never-coerce.rs b/src/test/ui/never_type/return-never-coerce.rs new file mode 100644 index 00000000000..fa0c78c2cf3 --- /dev/null +++ b/src/test/ui/never_type/return-never-coerce.rs @@ -0,0 +1,17 @@ +// Test that ! coerces to other types. + +// run-fail +// error-pattern:aah! + +fn call_another_fn T>(f: F) -> T { + f() +} + +fn wub() -> ! { + panic!("aah!"); +} + +fn main() { + let x: i32 = call_another_fn(wub); + let y: u32 = wub(); +} diff --git a/src/test/ui/numbers-arithmetic/divide-by-zero.rs b/src/test/ui/numbers-arithmetic/divide-by-zero.rs new file mode 100644 index 00000000000..fcbc23b8367 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/divide-by-zero.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:attempt to divide by zero +#[allow(unconditional_panic)] +fn main() { + let y = 0; + let _z = 1 / y; +} diff --git a/src/test/ui/numbers-arithmetic/mod-zero.rs b/src/test/ui/numbers-arithmetic/mod-zero.rs new file mode 100644 index 00000000000..a2798175d68 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/mod-zero.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:attempt to calculate the remainder with a divisor of zero +#[allow(unconditional_panic)] +fn main() { + let y = 0; + let _z = 1 % y; +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-add.rs b/src/test/ui/numbers-arithmetic/overflowing-add.rs new file mode 100644 index 00000000000..7d63fe3d20b --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-add.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'attempt to add with overflow' +// compile-flags: -C debug-assertions + +#![allow(arithmetic_overflow)] + +fn main() { + let _x = 200u8 + 200u8 + 200u8; +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-1.rs b/src/test/ui/numbers-arithmetic/overflowing-lsh-1.rs new file mode 100644 index 00000000000..e5ce8033639 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-1.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _x = 1_i32 << 32; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-1.stderr b/src/test/ui/numbers-arithmetic/overflowing-lsh-1.stderr new file mode 100644 index 00000000000..54008d33968 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-1.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-lsh-1.rs:7:14 + | +LL | let _x = 1_i32 << 32; + | ^^^^^^^^^^^ attempt to shift left with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-lsh-1.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-2.rs b/src/test/ui/numbers-arithmetic/overflowing-lsh-2.rs new file mode 100644 index 00000000000..7fd3407a056 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-2.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _x = 1 << -1; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-2.stderr b/src/test/ui/numbers-arithmetic/overflowing-lsh-2.stderr new file mode 100644 index 00000000000..872e71bb737 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-2.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-lsh-2.rs:7:14 + | +LL | let _x = 1 << -1; + | ^^^^^^^ attempt to shift left with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-lsh-2.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-3.rs b/src/test/ui/numbers-arithmetic/overflowing-lsh-3.rs new file mode 100644 index 00000000000..e007eb4a2e2 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-3.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _x = 1_u64 << 64; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-3.stderr b/src/test/ui/numbers-arithmetic/overflowing-lsh-3.stderr new file mode 100644 index 00000000000..d55ed4a046c --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-3.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-lsh-3.rs:7:14 + | +LL | let _x = 1_u64 << 64; + | ^^^^^^^^^^^ attempt to shift left with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-lsh-3.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-4.rs b/src/test/ui/numbers-arithmetic/overflowing-lsh-4.rs new file mode 100644 index 00000000000..738d0133915 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-4.rs @@ -0,0 +1,24 @@ +// build-fail +// compile-flags: -C debug-assertions + +// This function is checking that our automatic truncation does not +// sidestep the overflow checking. + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + // this signals overflow when checking is on + let x = 1_i8 << 17; + //~^ ERROR: this arithmetic operation will overflow + + // ... but when checking is off, the fallback will truncate the + // input to its lower three bits (= 1). Note that this is *not* + // the behavior of the x86 processor for 8- and 16-bit types, + // but it is necessary to avoid undefined behavior from LLVM. + // + // We check that here, by ensuring the result has only been + // shifted by one place; if overflow checking is turned off, then + // this assertion will pass (and the compiletest driver will + // report that the test did not produce the error expected above). + assert_eq!(x, 2_i8); +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-lsh-4.stderr b/src/test/ui/numbers-arithmetic/overflowing-lsh-4.stderr new file mode 100644 index 00000000000..1ef8dd3466c --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-lsh-4.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-lsh-4.rs:11:13 + | +LL | let x = 1_i8 << 17; + | ^^^^^^^^^^ attempt to shift left with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-lsh-4.rs:7:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-mul.rs b/src/test/ui/numbers-arithmetic/overflowing-mul.rs new file mode 100644 index 00000000000..6e17aeb6761 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-mul.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' +// compile-flags: -C debug-assertions + +#![allow(arithmetic_overflow)] + +fn main() { + let x = 200u8 * 4; +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-neg.rs b/src/test/ui/numbers-arithmetic/overflowing-neg.rs new file mode 100644 index 00000000000..f77bc132e76 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-neg.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'attempt to negate with overflow' +// compile-flags: -C debug-assertions + +#![allow(arithmetic_overflow)] + +fn main() { + let _x = -std::i8::MIN; +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-pow-signed.rs b/src/test/ui/numbers-arithmetic/overflowing-pow-signed.rs new file mode 100644 index 00000000000..a855ef0ec06 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-pow-signed.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' +// compile-flags: -C debug-assertions + +fn main() { + let _x = 2i32.pow(1024); +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-pow-unsigned.rs b/src/test/ui/numbers-arithmetic/overflowing-pow-unsigned.rs new file mode 100644 index 00000000000..26a2b2c4b8a --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-pow-unsigned.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow' +// compile-flags: -C debug-assertions + +fn main() { + let _x = 2u32.pow(1024); +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-1.rs b/src/test/ui/numbers-arithmetic/overflowing-rsh-1.rs new file mode 100644 index 00000000000..f1488cf8559 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-1.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _x = -1_i32 >> 32; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-1.stderr b/src/test/ui/numbers-arithmetic/overflowing-rsh-1.stderr new file mode 100644 index 00000000000..236303e2e9a --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-1.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-rsh-1.rs:7:14 + | +LL | let _x = -1_i32 >> 32; + | ^^^^^^^^^^^^ attempt to shift right with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-rsh-1.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-2.rs b/src/test/ui/numbers-arithmetic/overflowing-rsh-2.rs new file mode 100644 index 00000000000..39127b9703b --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-2.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _x = -1_i32 >> -1; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-2.stderr b/src/test/ui/numbers-arithmetic/overflowing-rsh-2.stderr new file mode 100644 index 00000000000..981c8986f76 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-2.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-rsh-2.rs:7:14 + | +LL | let _x = -1_i32 >> -1; + | ^^^^^^^^^^^^ attempt to shift right with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-rsh-2.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-3.rs b/src/test/ui/numbers-arithmetic/overflowing-rsh-3.rs new file mode 100644 index 00000000000..8ee6dde93ea --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-3.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _x = -1_i64 >> 64; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-3.stderr b/src/test/ui/numbers-arithmetic/overflowing-rsh-3.stderr new file mode 100644 index 00000000000..c2994503f0e --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-3.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-rsh-3.rs:7:14 + | +LL | let _x = -1_i64 >> 64; + | ^^^^^^^^^^^^ attempt to shift right with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-rsh-3.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-4.rs b/src/test/ui/numbers-arithmetic/overflowing-rsh-4.rs new file mode 100644 index 00000000000..ce7f818e330 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-4.rs @@ -0,0 +1,24 @@ +// build-fail +// compile-flags: -C debug-assertions + +// This function is checking that our (type-based) automatic +// truncation does not sidestep the overflow checking. + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + // this signals overflow when checking is on + let x = 2_i8 >> 17; + //~^ ERROR: this arithmetic operation will overflow + + // ... but when checking is off, the fallback will truncate the + // input to its lower three bits (= 1). Note that this is *not* + // the behavior of the x86 processor for 8- and 16-bit types, + // but it is necessary to avoid undefined behavior from LLVM. + // + // We check that here, by ensuring the result is not zero; if + // overflow checking is turned off, then this assertion will pass + // (and the compiletest driver will report that the test did not + // produce the error expected above). + assert_eq!(x, 1_i8); +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-4.stderr b/src/test/ui/numbers-arithmetic/overflowing-rsh-4.stderr new file mode 100644 index 00000000000..3db1da06dbe --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-4.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-rsh-4.rs:11:13 + | +LL | let x = 2_i8 >> 17; + | ^^^^^^^^^^ attempt to shift right with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-rsh-4.rs:7:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-5.rs b/src/test/ui/numbers-arithmetic/overflowing-rsh-5.rs new file mode 100644 index 00000000000..88928c99596 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-5.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _n = 1i64 >> [64][0]; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-5.stderr b/src/test/ui/numbers-arithmetic/overflowing-rsh-5.stderr new file mode 100644 index 00000000000..bd3eae82977 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-5.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-rsh-5.rs:7:14 + | +LL | let _n = 1i64 >> [64][0]; + | ^^^^^^^^^^^^^^^ attempt to shift right with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-rsh-5.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-6.rs b/src/test/ui/numbers-arithmetic/overflowing-rsh-6.rs new file mode 100644 index 00000000000..88928c99596 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-6.rs @@ -0,0 +1,9 @@ +// build-fail +// compile-flags: -C debug-assertions + +#![deny(arithmetic_overflow, const_err)] + +fn main() { + let _n = 1i64 >> [64][0]; + //~^ ERROR: this arithmetic operation will overflow +} diff --git a/src/test/ui/numbers-arithmetic/overflowing-rsh-6.stderr b/src/test/ui/numbers-arithmetic/overflowing-rsh-6.stderr new file mode 100644 index 00000000000..5d76639fb50 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-rsh-6.stderr @@ -0,0 +1,14 @@ +error: this arithmetic operation will overflow + --> $DIR/overflowing-rsh-6.rs:7:14 + | +LL | let _n = 1i64 >> [64][0]; + | ^^^^^^^^^^^^^^^ attempt to shift right with overflow + | +note: the lint level is defined here + --> $DIR/overflowing-rsh-6.rs:4:9 + | +LL | #![deny(arithmetic_overflow, const_err)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/numbers-arithmetic/overflowing-sub.rs b/src/test/ui/numbers-arithmetic/overflowing-sub.rs new file mode 100644 index 00000000000..2e2ee521247 --- /dev/null +++ b/src/test/ui/numbers-arithmetic/overflowing-sub.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'attempt to subtract with overflow' +// compile-flags: -C debug-assertions + +#![allow(arithmetic_overflow)] + +fn main() { + let _x = 42u8 - (42u8 + 1); +} diff --git a/src/test/ui/numbers-arithmetic/promoted_overflow.rs b/src/test/ui/numbers-arithmetic/promoted_overflow.rs new file mode 100644 index 00000000000..da59e81ed6b --- /dev/null +++ b/src/test/ui/numbers-arithmetic/promoted_overflow.rs @@ -0,0 +1,9 @@ +#![allow(arithmetic_overflow)] + +// run-fail +// error-pattern: overflow +// compile-flags: -C overflow-checks=yes + +fn main() { + let x: &'static u32 = &(0u32 - 1); +} diff --git a/src/test/ui/panic-runtime/unwind-interleaved.rs b/src/test/ui/panic-runtime/unwind-interleaved.rs new file mode 100644 index 00000000000..3d2b8a69480 --- /dev/null +++ b/src/test/ui/panic-runtime/unwind-interleaved.rs @@ -0,0 +1,15 @@ +// run-fail +// error-pattern:explicit panic + +fn a() {} + +fn b() { + panic!(); +} + +fn main() { + let _x = vec![0]; + a(); + let _y = vec![0]; + b(); +} diff --git a/src/test/ui/panic-runtime/unwind-rec.rs b/src/test/ui/panic-runtime/unwind-rec.rs new file mode 100644 index 00000000000..88aa6a577e6 --- /dev/null +++ b/src/test/ui/panic-runtime/unwind-rec.rs @@ -0,0 +1,14 @@ +// run-fail +// error-pattern:explicit panic + +fn build() -> Vec { + panic!(); +} + +struct Blk { + node: Vec, +} + +fn main() { + let _blk = Blk { node: build() }; +} diff --git a/src/test/ui/panic-runtime/unwind-rec2.rs b/src/test/ui/panic-runtime/unwind-rec2.rs new file mode 100644 index 00000000000..b3cac5141bb --- /dev/null +++ b/src/test/ui/panic-runtime/unwind-rec2.rs @@ -0,0 +1,22 @@ +// run-fail +// error-pattern:explicit panic + +fn build1() -> Vec { + vec![0, 0, 0, 0, 0, 0, 0] +} + +fn build2() -> Vec { + panic!(); +} + +struct Blk { + node: Vec, + span: Vec, +} + +fn main() { + let _blk = Blk { + node: build1(), + span: build2(), + }; +} diff --git a/src/test/ui/panic-runtime/unwind-unique.rs b/src/test/ui/panic-runtime/unwind-unique.rs new file mode 100644 index 00000000000..fabd28ac4f9 --- /dev/null +++ b/src/test/ui/panic-runtime/unwind-unique.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:explicit panic + +fn failfn() { + panic!(); +} + +fn main() { + Box::new(0); + failfn(); +} diff --git a/src/test/ui/panics/args-panic.rs b/src/test/ui/panics/args-panic.rs new file mode 100644 index 00000000000..cdf1ef44752 --- /dev/null +++ b/src/test/ui/panics/args-panic.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:meep + +#![feature(box_syntax)] + +fn f(_a: isize, _b: isize, _c: Box) { + panic!("moop"); +} + +fn main() { + f(1, panic!("meep"), box 42); +} diff --git a/src/test/ui/panics/doublepanic.rs b/src/test/ui/panics/doublepanic.rs new file mode 100644 index 00000000000..0b6ac6fe410 --- /dev/null +++ b/src/test/ui/panics/doublepanic.rs @@ -0,0 +1,9 @@ +#![allow(unreachable_code)] + +// run-fail +// error-pattern:One + +fn main() { + panic!("One"); + panic!("Two"); +} diff --git a/src/test/ui/panics/explicit-panic-msg.rs b/src/test/ui/panics/explicit-panic-msg.rs new file mode 100644 index 00000000000..d27fc3e06f1 --- /dev/null +++ b/src/test/ui/panics/explicit-panic-msg.rs @@ -0,0 +1,13 @@ +#![allow(unused_assignments)] +#![allow(unused_variables)] + +// run-fail +// error-pattern:wooooo + +fn main() { + let mut a = 1; + if 1 == 1 { + a = 2; + } + panic!(format!("woooo{}", "o")); +} diff --git a/src/test/ui/panics/explicit-panic.rs b/src/test/ui/panics/explicit-panic.rs new file mode 100644 index 00000000000..ddd5f00be6e --- /dev/null +++ b/src/test/ui/panics/explicit-panic.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:explicit + +fn main() { + panic!(); +} diff --git a/src/test/ui/panics/fmt-panic.rs b/src/test/ui/panics/fmt-panic.rs new file mode 100644 index 00000000000..8024f7b6166 --- /dev/null +++ b/src/test/ui/panics/fmt-panic.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern:meh + +fn main() { + let str_var: String = "meh".to_string(); + panic!("{}", str_var); +} diff --git a/src/test/ui/panics/main-panic.rs b/src/test/ui/panics/main-panic.rs new file mode 100644 index 00000000000..34bd9f8e0c6 --- /dev/null +++ b/src/test/ui/panics/main-panic.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:thread 'main' panicked at + +fn main() { + panic!() +} diff --git a/src/test/ui/panics/panic-arg.rs b/src/test/ui/panics/panic-arg.rs new file mode 100644 index 00000000000..b73487d083c --- /dev/null +++ b/src/test/ui/panics/panic-arg.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:woe + +fn f(a: isize) { + println!("{}", a); +} + +fn main() { + f(panic!("woe")); +} diff --git a/src/test/ui/panics/panic-macro-any-wrapped.rs b/src/test/ui/panics/panic-macro-any-wrapped.rs new file mode 100644 index 00000000000..85737e947a1 --- /dev/null +++ b/src/test/ui/panics/panic-macro-any-wrapped.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'Box' + +fn main() { + panic!(Box::new(612_i64)); +} diff --git a/src/test/ui/panics/panic-macro-any.rs b/src/test/ui/panics/panic-macro-any.rs new file mode 100644 index 00000000000..0d9eec17eb7 --- /dev/null +++ b/src/test/ui/panics/panic-macro-any.rs @@ -0,0 +1,8 @@ +// run-fail +// error-pattern:panicked at 'Box' + +#![feature(box_syntax)] + +fn main() { + panic!(box 413 as Box); +} diff --git a/src/test/ui/panics/panic-macro-explicit.rs b/src/test/ui/panics/panic-macro-explicit.rs new file mode 100644 index 00000000000..f27bdda3f32 --- /dev/null +++ b/src/test/ui/panics/panic-macro-explicit.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'explicit panic' + +fn main() { + panic!(); +} diff --git a/src/test/ui/panics/panic-macro-fmt.rs b/src/test/ui/panics/panic-macro-fmt.rs new file mode 100644 index 00000000000..c18d7830d06 --- /dev/null +++ b/src/test/ui/panics/panic-macro-fmt.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'test-fail-fmt 42 rust' + +fn main() { + panic!("test-fail-fmt {} {}", 42, "rust"); +} diff --git a/src/test/ui/panics/panic-macro-owned.rs b/src/test/ui/panics/panic-macro-owned.rs new file mode 100644 index 00000000000..fd56cfa3bb8 --- /dev/null +++ b/src/test/ui/panics/panic-macro-owned.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'test-fail-owned' + +fn main() { + panic!("test-fail-owned"); +} diff --git a/src/test/ui/panics/panic-macro-static.rs b/src/test/ui/panics/panic-macro-static.rs new file mode 100644 index 00000000000..a78732ed398 --- /dev/null +++ b/src/test/ui/panics/panic-macro-static.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:panicked at 'test-fail-static' + +fn main() { + panic!("test-fail-static"); +} diff --git a/src/test/ui/panics/panic-main.rs b/src/test/ui/panics/panic-main.rs new file mode 100644 index 00000000000..17ad25e3686 --- /dev/null +++ b/src/test/ui/panics/panic-main.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:moop + +fn main() { + panic!("moop"); +} diff --git a/src/test/ui/panics/panic-parens.rs b/src/test/ui/panics/panic-parens.rs new file mode 100644 index 00000000000..8052c78cc63 --- /dev/null +++ b/src/test/ui/panics/panic-parens.rs @@ -0,0 +1,18 @@ +// Fail macros without arguments need to be disambiguated in +// certain positions +// run-fail +// error-pattern:oops + +fn bigpanic() { + while (panic!("oops")) { + if (panic!()) { + match (panic!()) { + () => {} + } + } + } +} + +fn main() { + bigpanic(); +} diff --git a/src/test/ui/panics/panic-set-handler.rs b/src/test/ui/panics/panic-set-handler.rs new file mode 100644 index 00000000000..55542e58433 --- /dev/null +++ b/src/test/ui/panics/panic-set-handler.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:greetings from the panic handler + +use std::panic; + +fn main() { + panic::set_hook(Box::new(|i| { + eprintln!("greetings from the panic handler"); + })); + panic!("foobar"); +} diff --git a/src/test/ui/panics/panic-set-unset-handler.rs b/src/test/ui/panics/panic-set-unset-handler.rs new file mode 100644 index 00000000000..6b4c047eaf2 --- /dev/null +++ b/src/test/ui/panics/panic-set-unset-handler.rs @@ -0,0 +1,12 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'foobar' + +use std::panic; + +fn main() { + panic::set_hook(Box::new(|i| { + eprint!("greetings from the panic handler"); + })); + panic::take_hook(); + panic!("foobar"); +} diff --git a/src/test/ui/panics/panic-take-handler-nop.rs b/src/test/ui/panics/panic-take-handler-nop.rs new file mode 100644 index 00000000000..e519209a5a6 --- /dev/null +++ b/src/test/ui/panics/panic-take-handler-nop.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:thread 'main' panicked at 'foobar' + +use std::panic; + +fn main() { + panic::take_hook(); + panic!("foobar"); +} diff --git a/src/test/ui/panics/panic-task-name-none.rs b/src/test/ui/panics/panic-task-name-none.rs new file mode 100644 index 00000000000..4e95fb5bdb8 --- /dev/null +++ b/src/test/ui/panics/panic-task-name-none.rs @@ -0,0 +1,13 @@ +// run-fail +// error-pattern:thread '' panicked at 'test' +// ignore-emscripten Needs threads + +use std::thread; + +fn main() { + let r: Result<(), _> = thread::spawn(move || { + panic!("test"); + }) + .join(); + assert!(r.is_ok()); +} diff --git a/src/test/ui/panics/panic-task-name-owned.rs b/src/test/ui/panics/panic-task-name-owned.rs new file mode 100644 index 00000000000..f85be7bb8e2 --- /dev/null +++ b/src/test/ui/panics/panic-task-name-owned.rs @@ -0,0 +1,18 @@ +// run-fail +// error-pattern:thread 'owned name' panicked at 'test' +// ignore-emscripten Needs threads. + +use std::thread::Builder; + +fn main() { + let r: () = Builder::new() + .name("owned name".to_string()) + .spawn(move || { + panic!("test"); + () + }) + .unwrap() + .join() + .unwrap(); + panic!(); +} diff --git a/src/test/ui/panics/panic.rs b/src/test/ui/panics/panic.rs new file mode 100644 index 00000000000..7e8ea8b8175 --- /dev/null +++ b/src/test/ui/panics/panic.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:1 == 2 + +fn main() { + assert!(1 == 2); +} diff --git a/src/test/ui/panics/result-get-panic.rs b/src/test/ui/panics/result-get-panic.rs new file mode 100644 index 00000000000..41bc13bf085 --- /dev/null +++ b/src/test/ui/panics/result-get-panic.rs @@ -0,0 +1,8 @@ +// run-fail +// error-pattern:called `Result::unwrap()` on an `Err` value + +use std::result::Result::Err; + +fn main() { + println!("{}", Err::("kitty".to_string()).unwrap()); +} diff --git a/src/test/ui/panics/test-panic.rs b/src/test/ui/panics/test-panic.rs new file mode 100644 index 00000000000..85c9279cdf2 --- /dev/null +++ b/src/test/ui/panics/test-panic.rs @@ -0,0 +1,9 @@ +// run-fail +// check-stdout +// compile-flags: --test +// ignore-emscripten + +#[test] +fn test_foo() { + panic!() +} diff --git a/src/test/ui/panics/test-should-fail-bad-message.rs b/src/test/ui/panics/test-should-fail-bad-message.rs new file mode 100644 index 00000000000..701f2677648 --- /dev/null +++ b/src/test/ui/panics/test-should-fail-bad-message.rs @@ -0,0 +1,10 @@ +// run-fail +// check-stdout +// compile-flags: --test +// ignore-emscripten + +#[test] +#[should_panic(expected = "foobar")] +fn test_foo() { + panic!("blah") +} diff --git a/src/test/ui/panics/test-should-panic-bad-message.rs b/src/test/ui/panics/test-should-panic-bad-message.rs new file mode 100644 index 00000000000..a90d67a7d6b --- /dev/null +++ b/src/test/ui/panics/test-should-panic-bad-message.rs @@ -0,0 +1,9 @@ +// run-fail +// compile-flags: --test +// check-stdout + +#[test] +#[should_panic(expected = "foo")] +pub fn test_bar() { + panic!("bar") +} diff --git a/src/test/ui/panics/test-should-panic-no-message.rs b/src/test/ui/panics/test-should-panic-no-message.rs new file mode 100644 index 00000000000..217267d2d75 --- /dev/null +++ b/src/test/ui/panics/test-should-panic-no-message.rs @@ -0,0 +1,9 @@ +// run-fail +// compile-flags: --test +// check-stdout + +#[test] +#[should_panic(expected = "foo")] +pub fn test_explicit() { + panic!() +} diff --git a/src/test/ui/panics/unique-panic.rs b/src/test/ui/panics/unique-panic.rs new file mode 100644 index 00000000000..22e0d63d594 --- /dev/null +++ b/src/test/ui/panics/unique-panic.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern: panic + +fn main() { + Box::new(panic!()); +} diff --git a/src/test/ui/panics/while-body-panics.rs b/src/test/ui/panics/while-body-panics.rs new file mode 100644 index 00000000000..b335c90a073 --- /dev/null +++ b/src/test/ui/panics/while-body-panics.rs @@ -0,0 +1,13 @@ +#![allow(while_true)] + +// run-fail +// error-pattern:quux + +fn main() { + let _x: isize = { + while true { + panic!("quux"); + } + 8 + }; +} diff --git a/src/test/ui/panics/while-panic.rs b/src/test/ui/panics/while-panic.rs new file mode 100644 index 00000000000..45be38418e0 --- /dev/null +++ b/src/test/ui/panics/while-panic.rs @@ -0,0 +1,13 @@ +#![allow(while_true)] + +// run-fail +// error-pattern:giraffe + +fn main() { + panic!({ + while true { + panic!("giraffe") + } + "clandestine" + }); +} diff --git a/src/test/ui/process/tls-exit-status.rs b/src/test/ui/process/tls-exit-status.rs new file mode 100644 index 00000000000..973bb9c4f0c --- /dev/null +++ b/src/test/ui/process/tls-exit-status.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:nonzero +// exec-env:RUST_NEWRT=1 +// ignore-cloudabi no std::env + +use std::env; + +fn main() { + env::args(); + panic!("please have a nonzero exit status"); +} diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs new file mode 100644 index 00000000000..724ce509041 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:returned Box from main() +// failure-status: 1 + +use std::error::Error; +use std::io; + +fn main() -> Result<(), Box> { + Err(Box::new(io::Error::new(io::ErrorKind::Other, "returned Box from main()"))) +} diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-for-never.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-never.rs new file mode 100644 index 00000000000..d5b6b5016d4 --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-never.rs @@ -0,0 +1,6 @@ +// run-fail +// error-pattern:oh, dear + +fn main() -> ! { + panic!("oh, dear"); +} diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs new file mode 100644 index 00000000000..a99480e57ab --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:returned Box from main() +// failure-status: 1 + +use std::io::{Error, ErrorKind}; + +fn main() -> Result<(), Box> { + Err(Box::new(Error::new(ErrorKind::Other, "returned Box from main()"))) +} diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-for-str.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-str.rs new file mode 100644 index 00000000000..c78477e4eee --- /dev/null +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-for-str.rs @@ -0,0 +1,7 @@ +// run-fail +// error-pattern: An error message for you +// failure-status: 1 + +fn main() -> Result<(), &'static str> { + Err("An error message for you") +} diff --git a/src/test/ui/str/str-overrun.rs b/src/test/ui/str/str-overrun.rs new file mode 100644 index 00000000000..78bbf0cfdb9 --- /dev/null +++ b/src/test/ui/str/str-overrun.rs @@ -0,0 +1,9 @@ +// run-fail +// error-pattern:index out of bounds: the len is 5 but the index is 5 + +fn main() { + let s: String = "hello".to_string(); + + // Bounds-check panic. + assert_eq!(s.as_bytes()[5], 0x0 as u8); +} diff --git a/src/test/ui/structs/rhs-type.rs b/src/test/ui/structs/rhs-type.rs new file mode 100644 index 00000000000..dd227a7f0a0 --- /dev/null +++ b/src/test/ui/structs/rhs-type.rs @@ -0,0 +1,17 @@ +// Tests that codegen treats the rhs of pth's decl +// as a _|_-typed thing, not a str-typed thing + +// run-fail +// error-pattern:bye + +#![allow(unreachable_code)] +#![allow(unused_variables)] + +struct T { + t: String, +} + +fn main() { + let pth = panic!("bye"); + let _rs: T = T { t: pth }; +} diff --git a/src/test/ui/test-attrs/run-unexported-tests.rs b/src/test/ui/test-attrs/run-unexported-tests.rs new file mode 100644 index 00000000000..f533a3ef885 --- /dev/null +++ b/src/test/ui/test-attrs/run-unexported-tests.rs @@ -0,0 +1,12 @@ +// run-fail +// compile-flags:--test +// check-stdout + +mod m { + pub fn exported() {} + + #[test] + fn unexported() { + panic!("ran an unexported test"); + } +} diff --git a/src/test/ui/threads-sendsync/task-spawn-barefn.rs b/src/test/ui/threads-sendsync/task-spawn-barefn.rs new file mode 100644 index 00000000000..e5b899e0af9 --- /dev/null +++ b/src/test/ui/threads-sendsync/task-spawn-barefn.rs @@ -0,0 +1,18 @@ +// run-fail +// error-pattern:Ensure that the child thread runs by panicking +// ignore-emscripten Needs threads. + +use std::thread; + +fn main() { + // the purpose of this test is to make sure that thread::spawn() + // works when provided with a bare function: + let r = thread::spawn(startfn).join(); + if r.is_err() { + panic!() + } +} + +fn startfn() { + assert!("Ensure that the child thread runs by panicking".is_empty()); +} diff --git a/src/test/ui/threads-sendsync/test-tasks-invalid-value.rs b/src/test/ui/threads-sendsync/test-tasks-invalid-value.rs new file mode 100644 index 00000000000..6411421429c --- /dev/null +++ b/src/test/ui/threads-sendsync/test-tasks-invalid-value.rs @@ -0,0 +1,11 @@ +// This checks that RUST_TEST_THREADS not being 1, 2, ... is detected +// properly. + +// run-fail +// error-pattern:should be a positive integer +// compile-flags: --test +// exec-env:RUST_TEST_THREADS=foo +// ignore-emscripten + +#[test] +fn do_nothing() {} diff --git a/src/test/ui/vec/vec-overrun.rs b/src/test/ui/vec/vec-overrun.rs new file mode 100644 index 00000000000..4f6aec7773f --- /dev/null +++ b/src/test/ui/vec/vec-overrun.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:index out of bounds: the len is 1 but the index is 2 + +fn main() { + let v: Vec = vec![10]; + let x: usize = 0; + assert_eq!(v[x], 10); + // Bounds-check panic. + + assert_eq!(v[x + 2], 20); +} -- cgit 1.4.1-3-g733a5