From 7828c3dd2858d8f3a0448484d8093e22719dbda0 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 9 Oct 2014 15:17:22 -0400 Subject: [PATCH 1/2] Rename fail! to panic! https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change] --- src/compiletest/compiletest.rs | 12 +-- src/compiletest/header.rs | 4 +- src/compiletest/runtest.rs | 8 +- src/compiletest/util.rs | 2 +- src/doc/complement-design-faq.md | 4 +- src/doc/complement-lang-faq.md | 5 +- src/doc/guide-ffi.md | 2 +- src/doc/guide-macros.md | 6 +- src/doc/guide-tasks.md | 30 +++--- src/doc/guide-testing.md | 4 +- src/doc/guide-unsafe.md | 4 +- src/doc/guide.md | 16 ++-- src/doc/reference.md | 44 ++++----- src/doc/rustdoc.md | 4 +- src/grammar/verify.rs | 4 +- src/liballoc/arc.rs | 6 +- src/liballoc/boxed.rs | 4 +- src/libarena/lib.rs | 9 +- src/libcollections/btree/node.rs | 2 +- src/libcollections/dlist.rs | 4 +- src/libcollections/lib.rs | 4 +- src/libcollections/ringbuf.rs | 4 +- src/libcollections/slice.rs | 14 +-- src/libcollections/smallintmap.rs | 2 +- src/libcollections/str.rs | 6 +- src/libcollections/string.rs | 14 +-- src/libcollections/treemap.rs | 8 +- src/libcollections/trie.rs | 6 +- src/libcollections/vec.rs | 42 ++++----- src/libcore/atomic.rs | 10 +- src/libcore/cell.rs | 8 +- src/libcore/char.rs | 4 +- src/libcore/finally.rs | 4 +- src/libcore/fmt/float.rs | 6 +- src/libcore/fmt/num.rs | 4 +- src/libcore/lib.rs | 8 +- src/libcore/macros.rs | 20 ++-- src/libcore/num/mod.rs | 2 +- src/libcore/option.rs | 14 +-- src/libcore/{failure.rs => panicking.rs} | 40 ++++---- src/libcore/ptr.rs | 2 +- src/libcore/result.rs | 46 +++++----- src/libcore/str.rs | 8 +- src/libcoretest/any.rs | 16 ++-- src/libcoretest/finally.rs | 2 +- src/libcoretest/iter.rs | 12 +-- src/libcoretest/option.rs | 6 +- src/libcoretest/result.rs | 8 +- src/libgetopts/lib.rs | 92 ++++++++++--------- src/libgreen/basic.rs | 4 +- src/libgreen/context.rs | 4 +- src/libgreen/lib.rs | 4 +- src/libgreen/sched.rs | 10 +- src/libgreen/simple.rs | 14 +-- src/libgreen/stack.rs | 8 +- src/libgreen/task.rs | 12 +-- src/liblog/lib.rs | 6 +- src/libnative/io/file_unix.rs | 4 +- src/libnative/io/pipe_windows.rs | 2 +- src/libnative/io/process.rs | 12 +-- src/libnative/io/timer_unix.rs | 4 +- src/libnative/lib.rs | 2 +- src/libnative/task.rs | 10 +- src/librand/distributions/mod.rs | 2 +- src/librand/lib.rs | 8 +- src/librbml/lib.rs | 2 +- src/libregex/compile.rs | 8 +- src/libregex/lib.rs | 2 +- src/libregex/parse.rs | 14 +-- src/libregex/re.rs | 2 +- src/libregex/test/bench.rs | 4 +- src/libregex/test/mod.rs | 2 +- src/libregex/test/tests.rs | 4 +- src/librustc/back/write.rs | 12 +-- src/librustc/driver/config.rs | 4 +- src/librustc/driver/mod.rs | 14 +-- src/librustc/driver/pretty.rs | 2 +- src/librustc/lint/builtin.rs | 14 +-- src/librustc/lint/context.rs | 4 +- src/librustc/metadata/creader.rs | 2 +- src/librustc/metadata/decoder.rs | 26 +++--- src/librustc/metadata/filesearch.rs | 4 +- src/librustc/metadata/tydecode.rs | 28 +++--- src/librustc/middle/astencode.rs | 16 ++-- .../borrowck/gather_loans/move_error.rs | 4 +- src/librustc/middle/borrowck/mod.rs | 4 +- src/librustc/middle/dataflow.rs | 2 +- src/librustc/middle/def.rs | 2 +- src/librustc/middle/lang_items.rs | 12 +-- src/librustc/middle/liveness.rs | 4 +- src/librustc/middle/region.rs | 4 +- src/librustc/middle/resolve.rs | 20 ++-- src/librustc/middle/subst.rs | 6 +- src/librustc/middle/trans/_match.rs | 4 +- src/librustc/middle/trans/adt.rs | 2 +- src/librustc/middle/trans/base.rs | 10 +- src/librustc/middle/trans/build.rs | 4 +- src/librustc/middle/trans/cabi_arm.rs | 4 +- src/librustc/middle/trans/cabi_mips.rs | 4 +- src/librustc/middle/trans/cabi_x86_64.rs | 8 +- src/librustc/middle/trans/callee.rs | 10 +- src/librustc/middle/trans/cleanup.rs | 8 +- src/librustc/middle/trans/common.rs | 4 +- src/librustc/middle/trans/context.rs | 4 +- src/librustc/middle/trans/doc.rs | 16 ++-- src/librustc/middle/trans/expr.rs | 4 +- src/librustc/middle/trans/foreign.rs | 4 +- src/librustc/middle/trans/glue.rs | 2 +- src/librustc/middle/trans/intrinsic.rs | 2 +- src/librustc/middle/trans/meth.rs | 2 +- src/librustc/middle/trans/tvec.rs | 2 +- src/librustc/middle/trans/type_.rs | 2 +- src/librustc/middle/trans/type_of.rs | 4 +- src/librustc/middle/ty.rs | 26 +++--- src/librustc/middle/typeck/astconv.rs | 2 +- src/librustc/middle/typeck/check/_match.rs | 2 +- src/librustc/middle/typeck/check/method.rs | 6 +- src/librustc/middle/typeck/check/vtable.rs | 2 +- src/librustc/middle/typeck/coherence/mod.rs | 6 +- src/librustc/middle/typeck/collect.rs | 2 +- src/librustc/middle/typeck/infer/glb.rs | 2 +- src/librustc/middle/typeck/infer/mod.rs | 2 +- .../typeck/infer/region_inference/mod.rs | 4 +- src/librustc/middle/typeck/infer/test.rs | 20 ++-- .../middle/typeck/infer/type_variable.rs | 4 +- src/librustc/middle/typeck/infer/unify.rs | 2 +- src/librustc/middle/typeck/variance.rs | 6 +- src/librustc/middle/weak_lang_items.rs | 2 +- src/librustc/plugin/registry.rs | 2 +- src/librustc/util/snapshot_vec.rs | 2 +- src/librustc_back/archive.rs | 2 +- src/librustc_back/rpath.rs | 8 +- src/librustc_back/sha2.rs | 6 +- src/librustc_back/svh.rs | 2 +- src/librustdoc/clean/inline.rs | 6 +- src/librustdoc/clean/mod.rs | 14 +-- src/librustdoc/flock.rs | 6 +- src/librustdoc/html/format.rs | 2 +- src/librustdoc/html/render.rs | 2 +- src/librustdoc/lib.rs | 6 +- src/librustdoc/test.rs | 6 +- src/librustdoc/visit_ast.rs | 4 +- src/librustrt/args.rs | 6 +- src/librustrt/c_str.rs | 4 +- src/librustrt/lib.rs | 2 +- src/librustrt/local_data.rs | 20 ++-- src/librustrt/mutex.rs | 2 +- src/librustrt/stack_overflow.rs | 8 +- src/librustrt/task.rs | 36 ++++---- src/librustrt/thread.rs | 26 +++--- src/librustrt/unwind.rs | 32 +++---- src/libserialize/base64.rs | 2 +- src/libserialize/json.rs | 20 ++-- src/libstd/ascii.rs | 10 +- src/libstd/c_vec.rs | 6 +- src/libstd/collections/hashmap/map.rs | 21 ++--- src/libstd/collections/hashmap/table.rs | 2 +- src/libstd/dynamic_lib.rs | 10 +- src/libstd/failure.rs | 14 +-- src/libstd/io/buffered.rs | 11 +-- src/libstd/io/comm_adapters.rs | 12 +-- src/libstd/io/extensions.rs | 8 +- src/libstd/io/fs.rs | 30 +++--- src/libstd/io/mem.rs | 4 +- src/libstd/io/mod.rs | 2 +- src/libstd/io/net/pipe.rs | 28 +++--- src/libstd/io/net/tcp.rs | 26 +++--- src/libstd/io/net/udp.rs | 32 +++---- src/libstd/io/process.rs | 18 ++-- src/libstd/io/result.rs | 6 +- src/libstd/io/stdio.rs | 8 +- src/libstd/io/test.rs | 6 +- src/libstd/io/timer.rs | 6 +- src/libstd/lib.rs | 4 +- src/libstd/macros.rs | 50 +++++----- src/libstd/num/strconv.rs | 14 +-- src/libstd/os.rs | 24 ++--- src/libstd/path/windows.rs | 2 +- src/libstd/rand/mod.rs | 12 +-- src/libstd/rand/os.rs | 6 +- src/libstd/rand/reader.rs | 6 +- src/libstd/rt/backtrace.rs | 6 +- src/libstd/rt/mod.rs | 2 +- src/libstd/rt/util.rs | 2 +- src/libstd/sync/future.rs | 18 ++-- src/libstd/sync/task_pool.rs | 6 +- src/libstd/task.rs | 64 ++++++------- src/libstd/time/duration.rs | 2 +- src/libsync/comm/mod.rs | 82 +++++++++-------- src/libsync/comm/oneshot.rs | 4 +- src/libsync/comm/select.rs | 26 +++--- src/libsync/comm/shared.rs | 4 +- src/libsync/comm/sync.rs | 4 +- src/libsync/deque.rs | 16 ++-- src/libsync/lock.rs | 32 +++---- src/libsync/mpsc_queue.rs | 2 +- src/libsync/raw.rs | 35 +++---- src/libsync/spsc_queue.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/ast_map/blocks.rs | 10 +- src/libsyntax/ast_map/mod.rs | 36 ++++---- src/libsyntax/ast_util.rs | 10 +- src/libsyntax/codemap.rs | 8 +- src/libsyntax/diagnostic.rs | 14 +-- src/libsyntax/ext/expand.rs | 6 +- src/libsyntax/ext/mtwt.rs | 8 +- src/libsyntax/ext/quote.rs | 8 +- src/libsyntax/ext/tt/macro_parser.rs | 4 +- src/libsyntax/ext/tt/macro_rules.rs | 2 +- src/libsyntax/fold.rs | 4 +- src/libsyntax/parse/lexer/comments.rs | 4 +- src/libsyntax/parse/lexer/mod.rs | 10 +- src/libsyntax/parse/mod.rs | 32 +++---- src/libsyntax/parse/parser.rs | 4 +- src/libsyntax/print/pp.rs | 2 +- src/libsyntax/print/pprust.rs | 6 +- src/libsyntax/util/small_vector.rs | 6 +- src/libsyntax/visit.rs | 2 +- src/libterm/terminfo/parm.rs | 2 +- src/libtest/lib.rs | 30 +++--- src/libtime/lib.rs | 4 +- src/test/auxiliary/cci_nested_lib.rs | 2 +- src/test/auxiliary/issue_2723_a.rs | 2 +- src/test/auxiliary/logging_right_crate.rs | 2 +- ...-method-type-parameters-cross-crate-lib.rs | 6 +- src/test/auxiliary/static-methods-crate.rs | 2 +- src/test/auxiliary/weak-lang-items.rs | 2 +- src/test/bench/core-std.rs | 4 +- src/test/bench/shootout-chameneos-redux.rs | 2 +- src/test/bench/shootout-k-nucleotide.rs | 2 +- src/test/bench/shootout-meteor.rs | 2 +- src/test/bench/shootout-pfib.rs | 2 +- src/test/bench/sudoku.rs | 4 +- src/test/bench/task-perf-alloc-unwind.rs | 8 +- .../bench/task-perf-jargon-metal-smoke.rs | 2 +- src/test/compile-fail/bad-bang-ann.rs | 2 +- ...her-can-live-while-the-other-survives-2.rs | 2 +- ...her-can-live-while-the-other-survives-3.rs | 2 +- ...her-can-live-while-the-other-survives-4.rs | 2 +- .../compile-fail/bind-by-move-no-guards.rs | 4 +- .../borrowck-anon-fields-variant.rs | 8 +- .../compile-fail/borrowck-autoref-3261.rs | 2 +- .../borrowck-borrow-from-owned-ptr.rs | 2 +- .../borrowck-borrow-from-stack-variable.rs | 2 +- .../compile-fail/borrowck-closures-unique.rs | 2 +- .../compile-fail/borrowck-lend-flow-if.rs | 6 +- .../compile-fail/borrowck-lend-flow-loop.rs | 4 +- src/test/compile-fail/borrowck-lend-flow.rs | 6 +- ...borrowck-loan-local-as-both-mut-and-imm.rs | 2 +- .../compile-fail/borrowck-ref-into-rvalue.rs | 2 +- .../borrowck-vec-pattern-element-loan.rs | 6 +- .../borrowck-vec-pattern-tail-element-loan.rs | 2 +- src/test/compile-fail/closure-that-fails.rs | 4 +- ...t-conflicts-with-specific-multidispatch.rs | 2 +- .../compile-fail/dead-code-closure-bang.rs | 2 +- src/test/compile-fail/deref-non-pointer.rs | 2 +- .../compile-fail/fail-no-dead-code-core.rs | 6 +- src/test/compile-fail/fail-no-dead-code.rs | 6 +- src/test/compile-fail/fail-simple.rs | 2 +- .../generic-lifetime-trait-impl.rs | 2 +- src/test/compile-fail/issue-10392-2.rs | 2 +- src/test/compile-fail/issue-10392.rs | 2 +- src/test/compile-fail/issue-11844.rs | 2 +- src/test/compile-fail/issue-12116.rs | 2 +- src/test/compile-fail/issue-12187-1.rs | 2 +- src/test/compile-fail/issue-12187-2.rs | 2 +- src/test/compile-fail/issue-13466.rs | 2 +- src/test/compile-fail/issue-2149.rs | 2 +- src/test/compile-fail/issue-2150.rs | 2 +- src/test/compile-fail/issue-2151.rs | 2 +- src/test/compile-fail/issue-2330.rs | 2 +- src/test/compile-fail/issue-2354.rs | 4 +- src/test/compile-fail/issue-2611-4.rs | 2 +- src/test/compile-fail/issue-2611-5.rs | 2 +- src/test/compile-fail/issue-3021.rs | 2 +- src/test/compile-fail/issue-3601.rs | 2 +- src/test/compile-fail/issue-3668.rs | 2 +- src/test/compile-fail/issue-5500-1.rs | 2 +- src/test/compile-fail/issue-6458-1.rs | 2 +- src/test/compile-fail/issue-897-2.rs | 2 +- src/test/compile-fail/issue-897.rs | 4 +- ...-return-type-requires-explicit-lifetime.rs | 6 +- src/test/compile-fail/lint-unused-unsafe.rs | 4 +- .../lint-visible-private-types.rs | 54 +++++------ .../compile-fail/liveness-use-after-send.rs | 4 +- src/test/compile-fail/match-join.rs | 4 +- .../compile-fail/moves-based-on-type-exprs.rs | 2 +- .../moves-based-on-type-match-bindings.rs | 2 +- ...ased-on-type-no-recursive-stack-closure.rs | 2 +- .../non-exhaustive-match-nested.rs | 4 +- src/test/compile-fail/not-enough-arguments.rs | 2 +- src/test/compile-fail/pattern-tyvar-2.rs | 2 +- src/test/compile-fail/pattern-tyvar.rs | 2 +- src/test/compile-fail/qquote-1.rs | 2 +- src/test/compile-fail/qquote-2.rs | 2 +- src/test/compile-fail/regions-fn-bound.rs | 4 +- .../regions-fn-subtyping-return-static.rs | 6 +- src/test/compile-fail/regions-fn-subtyping.rs | 4 +- .../regions-free-region-ordering-callee.rs | 2 +- .../tag-that-dare-not-speak-its-name.rs | 2 +- src/test/compile-fail/tag-type-args.rs | 2 +- ...rait-bounds-on-structs-and-enums-locals.rs | 2 +- src/test/compile-fail/unused-result.rs | 2 +- src/test/debuginfo/basic-types-metadata.rs | 2 +- src/test/pretty/issue-929.rs | 2 +- src/test/run-fail/args-fail.rs | 4 +- src/test/run-fail/binop-fail.rs | 2 +- .../bug-2470-bounds-check-overflow-2.rs | 4 +- .../bug-2470-bounds-check-overflow-3.rs | 6 +- .../bug-2470-bounds-check-overflow.rs | 4 +- src/test/run-fail/bug-811.rs | 4 +- .../run-fail/by-value-self-objects-fail.rs | 2 +- src/test/run-fail/die-macro-expr.rs | 2 +- src/test/run-fail/die-macro-pure.rs | 2 +- src/test/run-fail/die-macro.rs | 2 +- src/test/run-fail/doublefail.rs | 4 +- src/test/run-fail/explicit-fail-msg.rs | 2 +- src/test/run-fail/explicit-fail.rs | 2 +- src/test/run-fail/expr-fn-fail.rs | 2 +- src/test/run-fail/expr-if-fail-fn.rs | 2 +- src/test/run-fail/expr-if-fail.rs | 2 +- src/test/run-fail/expr-match-fail-fn.rs | 2 +- src/test/run-fail/expr-match-fail.rs | 2 +- src/test/run-fail/extern-fail.rs | 2 +- src/test/run-fail/fail-arg.rs | 2 +- src/test/run-fail/fail-macro-any-wrapped.rs | 2 +- src/test/run-fail/fail-macro-any.rs | 2 +- src/test/run-fail/fail-macro-explicit.rs | 2 +- src/test/run-fail/fail-macro-fmt.rs | 2 +- src/test/run-fail/fail-macro-owned.rs | 2 +- src/test/run-fail/fail-macro-static.rs | 2 +- src/test/run-fail/fail-main.rs | 2 +- src/test/run-fail/fail-non-utf8.rs | 2 +- src/test/run-fail/fail-parens.rs | 8 +- src/test/run-fail/fail-task-name-none.rs | 2 +- src/test/run-fail/fail-task-name-owned.rs | 2 +- src/test/run-fail/fail-task-name-send-str.rs | 2 +- src/test/run-fail/fail-task-name-static.rs | 2 +- src/test/run-fail/fmt-fail.rs | 2 +- src/test/run-fail/for-each-loop-fail.rs | 2 +- src/test/run-fail/glob-use-std.rs | 2 +- src/test/run-fail/if-check-fail.rs | 2 +- src/test/run-fail/if-cond-bot.rs | 2 +- src/test/run-fail/issue-12920.rs | 2 +- src/test/run-fail/issue-13202.rs | 2 +- src/test/run-fail/issue-2444.rs | 2 +- src/test/run-fail/issue-3029.rs | 2 +- src/test/run-fail/issue-948.rs | 2 +- src/test/run-fail/main-fail.rs | 2 +- src/test/run-fail/match-bot-fail.rs | 2 +- src/test/run-fail/match-disc-bot.rs | 2 +- src/test/run-fail/match-wildcards.rs | 6 +- src/test/run-fail/native-failure.rs | 2 +- src/test/run-fail/rhs-type.rs | 2 +- src/test/run-fail/rt-set-exit-status-fail.rs | 4 +- src/test/run-fail/rt-set-exit-status-fail2.rs | 4 +- src/test/run-fail/rt-set-exit-status.rs | 2 +- src/test/run-fail/run-unexported-tests.rs | 2 +- src/test/run-fail/str-overrun.rs | 2 +- src/test/run-fail/task-spawn-barefn.rs | 6 +- src/test/run-fail/test-fail.rs | 2 +- src/test/run-fail/tls-exit-status.rs | 2 +- .../run-fail/too-much-recursion-unwinding.rs | 2 +- src/test/run-fail/unique-fail.rs | 2 +- src/test/run-fail/unwind-interleaved.rs | 2 +- src/test/run-fail/unwind-rec.rs | 2 +- src/test/run-fail/unwind-rec2.rs | 2 +- src/test/run-fail/unwind-unique.rs | 2 +- src/test/run-fail/vec-overrun.rs | 2 +- src/test/run-fail/while-body-fails.rs | 2 +- src/test/run-fail/while-fail.rs | 2 +- src/test/run-make/static-unwinding/main.rs | 2 +- src/test/run-pass/attr-main-2.rs | 2 +- src/test/run-pass/backtrace.rs | 6 +- .../run-pass/binary-minus-without-space.rs | 2 +- src/test/run-pass/bind-by-move.rs | 2 +- .../borrowck-macro-interaction-issue-6304.rs | 4 +- src/test/run-pass/byte-literals.rs | 6 +- src/test/run-pass/cell-does-not-clone.rs | 2 +- .../class-impl-very-parameterized-trait.rs | 8 +- ...nup-rvalue-temp-during-incomplete-alloc.rs | 4 +- src/test/run-pass/closure-return-bang.rs | 2 +- src/test/run-pass/conditional-compile.rs | 4 +- .../run-pass/conditional-debug-macro-off.rs | 4 +- .../run-pass/conditional-debug-macro-on.rs | 4 +- src/test/run-pass/const-big-enum.rs | 6 +- src/test/run-pass/const-enum-byref-self.rs | 2 +- src/test/run-pass/const-enum-byref.rs | 2 +- src/test/run-pass/const-enum-ptr.rs | 2 +- src/test/run-pass/const-enum-structlike.rs | 2 +- src/test/run-pass/const-enum-vec-index.rs | 8 +- src/test/run-pass/const-enum-vec-ptr.rs | 4 +- src/test/run-pass/const-enum-vector.rs | 4 +- src/test/run-pass/const-nullary-enum.rs | 4 +- src/test/run-pass/core-run-destroy.rs | 6 +- .../run-pass/deriving-cmp-shortcircuit.rs | 8 +- src/test/run-pass/die-macro.rs | 6 +- src/test/run-pass/drop-trait-enum.rs | 2 +- src/test/run-pass/dst-deref-mut.rs | 2 +- src/test/run-pass/enum-alignment.rs | 2 +- .../enum-nullable-simplifycfg-misopt.rs | 2 +- src/test/run-pass/expr-if-fail-all.rs | 6 +- src/test/run-pass/expr-if-fail.rs | 14 +-- src/test/run-pass/expr-match-fail-all.rs | 6 +- src/test/run-pass/expr-match-fail.rs | 4 +- .../run-pass/expr-match-generic-unique1.rs | 2 +- .../run-pass/expr-match-generic-unique2.rs | 2 +- src/test/run-pass/expr-match-generic.rs | 2 +- src/test/run-pass/expr-match-struct.rs | 2 +- src/test/run-pass/expr-match-unique.rs | 2 +- src/test/run-pass/fail-during-tld-destroy.rs | 2 +- .../run-pass/fail-in-dtor-drops-fields.rs | 2 +- src/test/run-pass/for-loop-fail.rs | 2 +- src/test/run-pass/getopts_ref.rs | 2 +- src/test/run-pass/hygienic-labels.rs | 8 +- src/test/run-pass/if-bot.rs | 2 +- src/test/run-pass/if-check.rs | 2 +- src/test/run-pass/if-let.rs | 16 ++-- .../run-pass/inherent-trait-method-order.rs | 2 +- src/test/run-pass/issue-10392.rs | 4 +- src/test/run-pass/issue-10734.rs | 2 +- src/test/run-pass/issue-11552.rs | 2 +- src/test/run-pass/issue-11709.rs | 8 +- .../run-pass/issue-13259-windows-tcb-trash.rs | 2 +- src/test/run-pass/issue-14865.rs | 4 +- src/test/run-pass/issue-1516.rs | 2 +- src/test/run-pass/issue-2311-2.rs | 2 +- src/test/run-pass/issue-2312.rs | 2 +- src/test/run-pass/issue-2611-3.rs | 2 +- src/test/run-pass/issue-2718.rs | 20 ++-- src/test/run-pass/issue-2904.rs | 2 +- src/test/run-pass/issue-3895.rs | 2 +- src/test/run-pass/issue-4016.rs | 2 +- src/test/run-pass/issue-4241.rs | 14 +-- src/test/run-pass/issue-5521.rs | 2 +- src/test/run-pass/issue-6128.rs | 2 +- src/test/run-pass/issue-6449.rs | 24 ++--- src/test/run-pass/issue-8351-1.rs | 4 +- src/test/run-pass/issue-8351-2.rs | 4 +- src/test/run-pass/last-use-in-block.rs | 2 +- src/test/run-pass/logging-enabled-debug.rs | 2 +- src/test/run-pass/logging-enabled.rs | 4 +- src/test/run-pass/logging-right-crate.rs | 4 +- .../loop-no-reinit-needed-post-bot.rs | 4 +- src/test/run-pass/macro-interpolation.rs | 2 +- src/test/run-pass/match-bot-2.rs | 2 +- src/test/run-pass/match-bot.rs | 2 +- src/test/run-pass/match-enum-struct-0.rs | 2 +- src/test/run-pass/match-enum-struct-1.rs | 4 +- src/test/run-pass/match-pattern-lit.rs | 2 +- src/test/run-pass/match-pipe-binding.rs | 10 +- src/test/run-pass/match-range.rs | 16 ++-- .../match-ref-binding-in-guard-3256.rs | 2 +- src/test/run-pass/match-str.rs | 12 +-- src/test/run-pass/match-struct-0.rs | 6 +- src/test/run-pass/negative.rs | 2 +- src/test/run-pass/nested-block-comment.rs | 2 +- src/test/run-pass/nested-class.rs | 2 +- src/test/run-pass/nested-matchs.rs | 2 +- src/test/run-pass/nested-pattern.rs | 2 +- src/test/run-pass/no-landing-pads.rs | 2 +- .../nullable-pointer-iotareduction.rs | 4 +- src/test/run-pass/option-unwrap.rs | 2 +- src/test/run-pass/overload-index-operator.rs | 2 +- src/test/run-pass/overloaded-autoderef.rs | 2 +- src/test/run-pass/overloaded-deref.rs | 2 +- src/test/run-pass/parse-fail.rs | 2 +- src/test/run-pass/process-detach.rs | 2 +- src/test/run-pass/regions-bot.rs | 2 +- .../run-pass/regions-dependent-addr-of.rs | 6 +- .../regions-early-bound-trait-param.rs | 4 +- .../regions-return-interior-of-option.rs | 2 +- src/test/run-pass/ret-bang.rs | 2 +- src/test/run-pass/return-from-closure.rs | 4 +- src/test/run-pass/running-with-no-runtime.rs | 4 +- src/test/run-pass/sepcomp-unwind.rs | 2 +- src/test/run-pass/signal-exit-status.rs | 2 +- src/test/run-pass/size-and-align.rs | 2 +- src/test/run-pass/slice-fail-2.rs | 2 +- src/test/run-pass/syntax-extension-cfg.rs | 26 +++--- src/test/run-pass/task-stderr.rs | 2 +- src/test/run-pass/tcp-accept-stress.rs | 4 +- src/test/run-pass/tcp-connect-timeouts.rs | 4 +- src/test/run-pass/tcp-stress.rs | 2 +- src/test/run-pass/tempfile.rs | 16 ++-- src/test/run-pass/terminate-in-initializer.rs | 12 +-- src/test/run-pass/test-runner-hides-main.rs | 2 +- src/test/run-pass/trans-tag-static-padding.rs | 4 +- .../typeck-macro-interaction-issue-8852.rs | 2 +- src/test/run-pass/unique-containing-tag.rs | 4 +- src/test/run-pass/unique-decl.rs | 2 +- src/test/run-pass/unique-pat.rs | 2 +- .../run-pass/unit-like-struct-drop-run.rs | 4 +- src/test/run-pass/unix-process-spawn-errno.rs | 2 +- src/test/run-pass/unreachable-code-1.rs | 2 +- src/test/run-pass/unreachable-code.rs | 2 +- src/test/run-pass/unwind-resource.rs | 2 +- src/test/run-pass/unwind-unique.rs | 2 +- src/test/run-pass/use-uninit-match2.rs | 2 +- src/test/run-pass/vec-matching-autoslice.rs | 8 +- src/test/run-pass/vec-matching.rs | 2 +- src/test/run-pass/vector-sort-failure-safe.rs | 12 +-- src/test/run-pass/weird-exprs.rs | 2 +- src/test/run-pass/while-label.rs | 2 +- src/test/run-pass/writealias.rs | 2 +- 505 files changed, 1623 insertions(+), 1618 deletions(-) rename src/libcore/{failure.rs => panicking.rs} (54%) diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 018d77b67cdd6..caf1c8c314dbb 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -41,7 +41,7 @@ pub fn main() { let config = parse_config(args); if config.valgrind_path.is_none() && config.force_valgrind { - fail!("Can't find Valgrind to run Valgrind tests"); + panic!("Can't find Valgrind to run Valgrind tests"); } log_config(&config); @@ -94,20 +94,20 @@ pub fn parse_config(args: Vec ) -> Config { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); println!("{}", getopts::usage(message.as_slice(), groups.as_slice())); println!(""); - fail!() + panic!() } let matches = &match getopts::getopts(args_.as_slice(), groups.as_slice()) { Ok(m) => m, - Err(f) => fail!("{}", f) + Err(f) => panic!("{}", f) }; if matches.opt_present("h") || matches.opt_present("help") { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); println!("{}", getopts::usage(message.as_slice(), groups.as_slice())); println!(""); - fail!() + panic!() } fn opt_path(m: &getopts::Matches, nm: &str) -> Path { @@ -120,7 +120,7 @@ pub fn parse_config(args: Vec ) -> Config { Ok(re) => Some(re), Err(e) => { println!("failed to parse filter /{}/: {}", s, e); - fail!() + panic!() } } } else { @@ -263,7 +263,7 @@ pub fn run_tests(config: &Config) { let res = test::run_tests_console(&opts, tests.into_iter().collect()); match res { Ok(true) => {} - Ok(false) => fail!("Some tests failed"), + Ok(false) => panic!("Some tests failed"), Err(e) => { println!("I/O failure during tests: {}", e); } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index a9c984d8061df..b7b94ca6d0df5 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -305,7 +305,7 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> { let end = strs.pop().unwrap(); (strs.pop().unwrap(), end) } - n => fail!("Expected 1 or 2 strings, not {}", n) + n => panic!("Expected 1 or 2 strings, not {}", n) } }) } @@ -350,7 +350,7 @@ pub fn gdb_version_to_int(version_string: &str) -> int { let components: Vec<&str> = version_string.trim().split('.').collect(); if components.len() != 2 { - fail!("{}", error_string); + panic!("{}", error_string); } let major: int = FromStr::from_str(components[0]).expect(error_string); diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 34129dedbd827..a9edad3add61e 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -39,7 +39,7 @@ pub fn run(config: Config, testfile: String) { "arm-linux-androideabi" => { if !config.adb_device_status { - fail!("android device not available"); + panic!("android device not available"); } } @@ -316,7 +316,7 @@ actual:\n\ ------------------------------------------\n\ \n", expected, actual); - fail!(); + panic!(); } } @@ -1453,7 +1453,7 @@ fn maybe_dump_to_stdout(config: &Config, out: &str, err: &str) { fn error(err: &str) { println!("\nerror: {}", err); } -fn fatal(err: &str) -> ! { error(err); fail!(); } +fn fatal(err: &str) -> ! { error(err); panic!(); } fn fatal_proc_rec(err: &str, proc_res: &ProcRes) -> ! { print!("\n\ @@ -1471,7 +1471,7 @@ stderr:\n\ \n", err, proc_res.status, proc_res.cmdline, proc_res.stdout, proc_res.stderr); - fail!(); + panic!(); } fn _arm_exec_compiled_test(config: &Config, diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index 22b5600d5bfcc..a116cc33690db 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -31,7 +31,7 @@ pub fn get_os(triple: &str) -> &'static str { return os } } - fail!("Cannot determine OS from triple"); + panic!("Cannot determine OS from triple"); } #[cfg(target_os = "windows")] diff --git a/src/doc/complement-design-faq.md b/src/doc/complement-design-faq.md index 6cdaf96d3f50e..9a2531f094c17 100644 --- a/src/doc/complement-design-faq.md +++ b/src/doc/complement-design-faq.md @@ -94,9 +94,9 @@ code should need to run is a stack. `match` being exhaustive has some useful properties. First, if every possibility is covered by the `match`, adding further variants to the `enum` -in the future will prompt a compilation failure, rather than runtime failure. +in the future will prompt a compilation failure, rather than runtime panic. Second, it makes cost explicit. In general, only safe way to have a -non-exhaustive match would be to fail the task if nothing is matched, though +non-exhaustive match would be to panic the task if nothing is matched, though it could fall through if the type of the `match` expression is `()`. This sort of hidden cost and special casing is against the language's philosophy. It's easy to ignore certain cases by using the `_` wildcard: diff --git a/src/doc/complement-lang-faq.md b/src/doc/complement-lang-faq.md index 8db7ba9424fc1..0a8f9b2ffaa65 100644 --- a/src/doc/complement-lang-faq.md +++ b/src/doc/complement-lang-faq.md @@ -65,14 +65,15 @@ Data values in the language can only be constructed through a fixed set of initi * There is no global inter-crate namespace; all name management occurs within a crate. * Using another crate binds the root of _its_ namespace into the user's namespace. -## Why is failure unwinding non-recoverable within a task? Why not try to "catch exceptions"? +## Why is panic unwinding non-recoverable within a task? Why not try to "catch exceptions"? In short, because too few guarantees could be made about the dynamic environment of the catch block, as well as invariants holding in the unwound heap, to be able to safely resume; we believe that other methods of signalling and logging errors are more appropriate, with tasks playing the role of a "hard" isolation boundary between separate heaps. Rust provides, instead, three predictable and well-defined options for handling any combination of the three main categories of "catch" logic: * Failure _logging_ is done by the integrated logging subsystem. -* _Recovery_ after a failure is done by trapping a task failure from _outside_ the task, where other tasks are known to be unaffected. +* _Recovery_ after a panic is done by trapping a task panic from _outside_ + the task, where other tasks are known to be unaffected. * _Cleanup_ of resources is done by RAII-style objects with destructors. Cleanup through RAII-style destructors is more likely to work than in catch blocks anyways, since it will be better tested (part of the non-error control paths, so executed all the time). diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md index 0b0a6b7b69717..3a87271ede7d8 100644 --- a/src/doc/guide-ffi.md +++ b/src/doc/guide-ffi.md @@ -191,7 +191,7 @@ the stack of the task which is spawned. Foreign libraries often hand off ownership of resources to the calling code. When this occurs, we must use Rust's destructors to provide safety and guarantee -the release of these resources (especially in the case of failure). +the release of these resources (especially in the case of panic). # Callbacks from C code to Rust functions diff --git a/src/doc/guide-macros.md b/src/doc/guide-macros.md index ed4e924ce8a8a..ae020037bc594 100644 --- a/src/doc/guide-macros.md +++ b/src/doc/guide-macros.md @@ -240,7 +240,7 @@ match x { // complicated stuff goes here return result + val; }, - _ => fail!("Didn't get good_2") + _ => panic!("Didn't get good_2") } } _ => return 0 // default value @@ -284,7 +284,7 @@ macro_rules! biased_match ( biased_match!((x) ~ (Good1(g1, val)) else { return 0 }; binds g1, val ) biased_match!((g1.body) ~ (Good2(result) ) - else { fail!("Didn't get good_2") }; + else { panic!("Didn't get good_2") }; binds result ) // complicated stuff goes here return result + val; @@ -397,7 +397,7 @@ macro_rules! biased_match ( # fn f(x: T1) -> uint { biased_match!( (x) ~ (Good1(g1, val)) else { return 0 }; - (g1.body) ~ (Good2(result) ) else { fail!("Didn't get Good2") }; + (g1.body) ~ (Good2(result) ) else { panic!("Didn't get Good2") }; binds val, result ) // complicated stuff goes here return result + val; diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index 1d1e9171b8f50..4eaca64560ca2 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -8,10 +8,10 @@ relates to the Rust type system, and introduce the fundamental library abstractions for constructing concurrent programs. Tasks provide failure isolation and recovery. When a fatal error occurs in Rust -code as a result of an explicit call to `fail!()`, an assertion failure, or +code as a result of an explicit call to `panic!()`, an assertion failure, or another invalid operation, the runtime system destroys the entire task. Unlike in languages such as Java and C++, there is no way to `catch` an exception. -Instead, tasks may monitor each other for failure. +Instead, tasks may monitor each other to see if they panic. Tasks use Rust's type system to provide strong memory safety guarantees. In particular, the type system guarantees that tasks cannot induce a data race @@ -317,19 +317,19 @@ spawn(proc() { # } ``` -# Handling task failure +# Handling task panics -Rust has a built-in mechanism for raising exceptions. The `fail!()` macro -(which can also be written with an error string as an argument: `fail!( -~reason)`) and the `assert!` construct (which effectively calls `fail!()` if a +Rust has a built-in mechanism for raising exceptions. The `panic!()` macro +(which can also be written with an error string as an argument: `panic!( +~reason)`) and the `assert!` construct (which effectively calls `panic!()` if a boolean expression is false) are both ways to raise exceptions. When a task raises an exception, the task unwinds its stack—running destructors and freeing memory along the way—and then exits. Unlike exceptions in C++, -exceptions in Rust are unrecoverable within a single task: once a task fails, +exceptions in Rust are unrecoverable within a single task: once a task panics, there is no way to "catch" the exception. -While it isn't possible for a task to recover from failure, tasks may notify -each other of failure. The simplest way of handling task failure is with the +While it isn't possible for a task to recover from panicking, tasks may notify +each other if they panic. The simplest way of handling a panic is with the `try` function, which is similar to `spawn`, but immediately blocks and waits for the child task to finish. `try` returns a value of type `Result>`. `Result` is an `enum` type with two variants: @@ -346,7 +346,7 @@ let result: Result> = task::try(proc() { if some_condition() { calculate_result() } else { - fail!("oops!"); + panic!("oops!"); } }); assert!(result.is_err()); @@ -355,18 +355,18 @@ assert!(result.is_err()); Unlike `spawn`, the function spawned using `try` may return a value, which `try` will dutifully propagate back to the caller in a [`Result`] enum. If the child task terminates successfully, `try` will return an `Ok` result; if the -child task fails, `try` will return an `Error` result. +child task panics, `try` will return an `Error` result. [`Result`]: std/result/index.html -> *Note:* A failed task does not currently produce a useful error +> *Note:* A panicked task does not currently produce a useful error > value (`try` always returns `Err(())`). In the > future, it may be possible for tasks to intercept the value passed to -> `fail!()`. +> `panic!()`. -But not all failures are created equal. In some cases you might need to abort +But not all panics are created equal. In some cases you might need to abort the entire program (perhaps you're writing an assert which, if it trips, indicates an unrecoverable logic error); in other cases you might want to -contain the failure at a certain boundary (perhaps a small piece of input from +contain the panic at a certain boundary (perhaps a small piece of input from the outside world, which you happen to be processing in parallel, is malformed such that the processing task cannot proceed). diff --git a/src/doc/guide-testing.md b/src/doc/guide-testing.md index 07813855d9b9b..9d15f55f33f69 100644 --- a/src/doc/guide-testing.md +++ b/src/doc/guide-testing.md @@ -49,7 +49,7 @@ value. To run the tests in a crate, it must be compiled with the `--test` flag: `rustc myprogram.rs --test -o myprogram-tests`. Running the resulting executable will run all the tests in the crate. A test is considered successful if its function returns; if the task running -the test fails, through a call to `fail!`, a failed `assert`, or some +the test fails, through a call to `panic!`, a failed `assert`, or some other (`assert_eq`, ...) means, then the test fails. When compiling a crate with the `--test` flag `--cfg test` is also @@ -77,7 +77,7 @@ test on windows you can write `#[cfg_attr(windows, ignore)]`. Tests that are intended to fail can be annotated with the `should_fail` attribute. The test will be run, and if it causes its -task to fail then the test will be counted as successful; otherwise it +task to panic then the test will be counted as successful; otherwise it will be counted as a failure. For example: ~~~test_harness diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index 7756abc802014..cade043a7931f 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -182,7 +182,7 @@ code: - implement the `Drop` for resource clean-up via a destructor, and use RAII (Resource Acquisition Is Initialization). This reduces the need for any manual memory management by users, and automatically ensures - that clean-up is always run, even when the task fails. + that clean-up is always run, even when the task panics. - ensure that any data stored behind a raw pointer is destroyed at the appropriate time. @@ -504,7 +504,7 @@ The second of these three functions, `eh_personality`, is used by the failure mechanisms of the compiler. This is often mapped to GCC's personality function (see the [libstd implementation](std/rt/unwind/index.html) for more -information), but crates which do not trigger failure can be assured +information), but crates which do not trigger a panic can be assured that this function is never called. The final function, `fail_fmt`, is also used by the failure mechanisms of the compiler. diff --git a/src/doc/guide.md b/src/doc/guide.md index 87a010c799e1c..53ed2af9cd9aa 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -5213,17 +5213,17 @@ immediately. ## Success and failure -Tasks don't always succeed, they can also fail. A task that wishes to fail -can call the `fail!` macro, passing a message: +Tasks don't always succeed, they can also panic. A task that wishes to panic +can call the `panic!` macro, passing a message: ```{rust} spawn(proc() { - fail!("Nope."); + panic!("Nope."); }); ``` -If a task fails, it is not possible for it to recover. However, it can -notify other tasks that it has failed. We can do this with `task::try`: +If a task panics, it is not possible for it to recover. However, it can +notify other tasks that it has panicked. We can do this with `task::try`: ```{rust} use std::task; @@ -5233,14 +5233,14 @@ let result = task::try(proc() { if rand::random() { println!("OK"); } else { - fail!("oops!"); + panic!("oops!"); } }); ``` -This task will randomly fail or succeed. `task::try` returns a `Result` +This task will randomly panic or succeed. `task::try` returns a `Result` type, so we can handle the response like any other computation that may -fail. +panic. # Macros diff --git a/src/doc/reference.md b/src/doc/reference.md index 11bf895341b90..d83d3cbb1ebca 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -817,15 +817,15 @@ mod math { type Complex = (f64, f64); fn sin(f: f64) -> f64 { /* ... */ -# fail!(); +# panic!(); } fn cos(f: f64) -> f64 { /* ... */ -# fail!(); +# panic!(); } fn tan(f: f64) -> f64 { /* ... */ -# fail!(); +# panic!(); } } ``` @@ -1194,12 +1194,12 @@ output slot type would normally be. For example: ``` fn my_err(s: &str) -> ! { println!("{}", s); - fail!(); + panic!(); } ``` We call such functions "diverging" because they never return a value to the -caller. Every control path in a diverging function must end with a `fail!()` or +caller. Every control path in a diverging function must end with a `panic!()` or a call to another diverging function on every control path. The `!` annotation does *not* denote a type. Rather, the result type of a diverging function is a special type called $\bot$ ("bottom") that unifies with any type. Rust has no @@ -1212,7 +1212,7 @@ were declared without the `!` annotation, the following code would not typecheck: ``` -# fn my_err(s: &str) -> ! { fail!() } +# fn my_err(s: &str) -> ! { panic!() } fn f(i: int) -> int { if i == 42 { @@ -2259,7 +2259,7 @@ These types help drive the compiler's analysis : Allocate memory on the exchange heap. * `closure_exchange_malloc` : ___Needs filling in___ -* `fail_` +* `panic` : Abort the program with an error. * `fail_bounds_check` : Abort the program with a bounds check error. @@ -2866,11 +2866,11 @@ be assigned to. Indices are zero-based, and may be of any integral type. Vector access is bounds-checked at run-time. When the check fails, it will put the task in a -_failing state_. +_panicked state_. ```{should-fail} ([1, 2, 3, 4])[0]; -(["a", "b"])[10]; // fails +(["a", "b"])[10]; // panics ``` ### Unary operator expressions @@ -3300,9 +3300,9 @@ enum List { Nil, Cons(X, Box>) } let x: List = Cons(10, box Cons(11, box Nil)); match x { - Cons(_, box Nil) => fail!("singleton list"), + Cons(_, box Nil) => panic!("singleton list"), Cons(..) => return, - Nil => fail!("empty list") + Nil => panic!("empty list") } ``` @@ -3373,7 +3373,7 @@ match x { return; } _ => { - fail!(); + panic!(); } } ``` @@ -3395,7 +3395,7 @@ fn is_sorted(list: &List) -> bool { Cons(x, ref r @ box Cons(_, _)) => { match *r { box Cons(y, _) => (x <= y) && is_sorted(&**r), - _ => fail!() + _ => panic!() } } } @@ -3459,7 +3459,7 @@ may refer to the variables bound within the pattern they follow. let message = match maybe_digit { Some(x) if x < 10 => process_digit(x), Some(x) => process_other(x), - None => fail!() + None => panic!() }; ``` @@ -4091,7 +4091,7 @@ cause transitions between the states. The lifecycle states of a task are: * running * blocked -* failing +* panicked * dead A task begins its lifecycle — once it has been spawned — in the @@ -4103,21 +4103,21 @@ it makes a blocking communication call. When the call can be completed — when a message arrives at a sender, or a buffer opens to receive a message — then the blocked task will unblock and transition back to *running*. -A task may transition to the *failing* state at any time, due being killed by -some external event or internally, from the evaluation of a `fail!()` macro. -Once *failing*, a task unwinds its stack and transitions to the *dead* state. +A task may transition to the *panicked* state at any time, due being killed by +some external event or internally, from the evaluation of a `panic!()` macro. +Once *panicking*, a task unwinds its stack and transitions to the *dead* state. Unwinding the stack of a task is done by the task itself, on its own control stack. If a value with a destructor is freed during unwinding, the code for the destructor is run, also on the task's control stack. Running the destructor code causes a temporary transition to a *running* state, and allows the destructor code to cause any subsequent state transitions. The original task -of unwinding and failing thereby may suspend temporarily, and may involve +of unwinding and panicking thereby may suspend temporarily, and may involve (recursive) unwinding of the stack of a failed destructor. Nonetheless, the outermost unwinding activity will continue until the stack is unwound and the task transitions to the *dead* state. There is no way to "recover" from task -failure. Once a task has temporarily suspended its unwinding in the *failing* -state, failure occurring from within this destructor results in *hard* failure. -A hard failure currently results in the process aborting. +panics. Once a task has temporarily suspended its unwinding in the *panicking* +state, a panic occurring from within this destructor results in *hard* panic. +A hard panic currently results in the process aborting. A task in the *dead* state cannot transition to other states; it exists only to have its termination status inspected by other tasks, and/or to await diff --git a/src/doc/rustdoc.md b/src/doc/rustdoc.md index f5fbad960a3f5..4b995631467b5 100644 --- a/src/doc/rustdoc.md +++ b/src/doc/rustdoc.md @@ -169,7 +169,7 @@ directive. ~~~md ```should_fail -// This code block is expected to generate a failure when run +// This code block is expected to generate a panic when run ``` ~~~ @@ -189,7 +189,7 @@ were passed to the compiler using the `test_harness` directive. ```test_harness #[test] fn foo() { - fail!("oops! (will run & register as failure)") + panic!("oops! (will run & register as a failed test)") } ``` ~~~ diff --git a/src/grammar/verify.rs b/src/grammar/verify.rs index fef7d3510e7a3..a4345e061640d 100644 --- a/src/grammar/verify.rs +++ b/src/grammar/verify.rs @@ -131,7 +131,7 @@ fn str_to_binop(s: &str) -> BinOpToken { "|" => token::Or, "<<" => token::Shl, ">>" => token::Shr, - _ => fail!("Bad binop str `{}`", s), + _ => panic!("Bad binop str `{}`", s), } } @@ -276,7 +276,7 @@ fn main() { warn!("Different names for {} and {}", rustc_tok, antlr_tok); } } - _ => fail!("{} is not {}", antlr_tok, rustc_tok) + _ => panic!("{} is not {}", antlr_tok, rustc_tok) },)* ref c => assert!(c == &antlr_tok.tok, "{} is not {}", rustc_tok, antlr_tok) } diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index cc6f2d76eaf2f..f543826fe0187 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -227,9 +227,9 @@ impl Drop for Arc { impl Weak { /// Attempts to upgrade this weak reference to a strong reference. /// - /// This method will fail to upgrade this reference if the strong reference - /// count has already reached 0, but if there are still other active strong - /// references this function will return a new strong reference to the data. + /// This method will not upgrade this reference if the strong reference count has already + /// reached 0, but if there are still other active strong references this function will return + /// a new strong reference to the data. pub fn upgrade(&self) -> Option> { // We use a CAS loop to increment the strong count instead of a // fetch_add because once the count hits 0 is must never be above 0. diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 168d0daeb3845..09404af702733 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -148,11 +148,11 @@ mod test { match a.downcast::() { Ok(a) => { assert!(a == box 8u); } - Err(..) => fail!() + Err(..) => panic!() } match b.downcast::() { Ok(a) => { assert!(a == box Test); } - Err(..) => fail!() + Err(..) => panic!() } let a = box 8u as Box; diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 1cd6f7f66851f..924dd5ffed62c 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -69,7 +69,7 @@ impl Chunk { /// element). When the arena is destroyed, it iterates through all of its /// chunks, and uses the tydesc information to trace through the objects, /// calling the destructors on them. One subtle point that needs to be -/// addressed is how to handle failures while running the user provided +/// addressed is how to handle panics while running the user provided /// initializer function. It is important to not run the destructor on /// uninitialized objects, but how to detect them is somewhat subtle. Since /// `alloc()` can be invoked recursively, it is not sufficient to simply exclude @@ -162,7 +162,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) { // We encode whether the object a tydesc describes has been // initialized in the arena in the low bit of the tydesc pointer. This -// is necessary in order to properly do cleanup if a failure occurs +// is necessary in order to properly do cleanup if a panic occurs // during an initializer. #[inline] fn bitpack_tydesc_ptr(p: *const TyDesc, is_done: bool) -> uint { @@ -337,10 +337,9 @@ fn test_arena_destructors_fail() { // things interesting. arena.alloc(|| { [0u8, 1u8, 2u8] }); } - // Now, fail while allocating + // Now, panic while allocating arena.alloc::>(|| { - // Now fail. - fail!(); + panic!(); }); } diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index 4da362952b67c..6b491096e7da4 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -68,7 +68,7 @@ pub struct Node { impl Node { /// Searches for the given key in the node. If it finds an exact match, - /// `Found` will be yielded with the matching index. If it fails to find an exact match, + /// `Found` will be yielded with the matching index. If it doesn't find an exact match, /// `GoDown` will be yielded with the index of the subtree the key must lie in. pub fn search(&self, key: &K) -> SearchResult { // FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V). diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index e751084addd77..22d487bd3a0db 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -760,11 +760,11 @@ mod tests { loop { match (last_ptr, node_ptr.prev.resolve_immut()) { (None , None ) => {} - (None , _ ) => fail!("prev link for list_head"), + (None , _ ) => panic!("prev link for list_head"), (Some(p), Some(pptr)) => { assert_eq!(p as *const Node, pptr as *const Node); } - _ => fail!("prev link is none, not good"), + _ => panic!("prev link is none, not good"), } match node_ptr.next { Some(ref next) => { diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index e1806dae31dbe..20ad5b6334f32 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -527,8 +527,8 @@ pub fn fixme_14344_be_sure_to_link_to_collections() {} #[cfg(not(test))] mod std { - pub use core::fmt; // necessary for fail!() - pub use core::option; // necessary for fail!() + pub use core::fmt; // necessary for panic!() + pub use core::option; // necessary for panic!() pub use core::clone; // deriving(Clone) pub use core::cmp; // deriving(Eq, Ord, etc.) pub use hash; // deriving(Hash) diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index e32e8145d172e..5f05ab7a90693 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -152,7 +152,7 @@ impl RingBuf { pub fn get_mut<'a>(&'a mut self, i: uint) -> &'a mut T { let idx = self.raw_index(i); match *self.elts.get_mut(idx) { - None => fail!(), + None => panic!(), Some(ref mut v) => v } } @@ -460,7 +460,7 @@ impl Index for RingBuf { fn index<'a>(&'a self, i: &uint) -> &'a A { let idx = self.raw_index(*i); match self.elts[idx] { - None => fail!(), + None => panic!(), Some(ref v) => v, } } diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index a3fcd890eb2a6..3f60a6d633097 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1181,7 +1181,7 @@ mod tests { 3 => assert!(v == [2, 3, 1]), 4 => assert!(v == [2, 1, 3]), 5 => assert!(v == [1, 2, 3]), - _ => fail!(), + _ => panic!(), } } } @@ -1391,7 +1391,7 @@ mod tests { } } - // shouldn't fail/crash + // shouldn't panic let mut v: [uint, .. 0] = []; v.sort(); @@ -1545,7 +1545,7 @@ mod tests { #[should_fail] fn test_from_fn_fail() { Vec::from_fn(100, |v| { - if v == 50 { fail!() } + if v == 50 { panic!() } box 0i }); } @@ -1562,7 +1562,7 @@ mod tests { impl Clone for S { fn clone(&self) -> S { self.f.set(self.f.get() + 1); - if self.f.get() == 10 { fail!() } + if self.f.get() == 10 { panic!() } S { f: self.f, boxes: self.boxes.clone() } } } @@ -1577,7 +1577,7 @@ mod tests { let mut v = vec![]; v.grow_fn(100, |i| { if i == 50 { - fail!() + panic!() } (box 0i, Rc::new(0i)) }) @@ -1591,7 +1591,7 @@ mod tests { let mut i = 0u; for _ in v.permutations() { if i == 2 { - fail!() + panic!() } i += 1; } @@ -2189,7 +2189,7 @@ mod bench { sum += *x; } // sum == 11806, to stop dead code elimination. - if sum == 0 {fail!()} + if sum == 0 {panic!()} }) } diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 498f86a8bf1e4..3b509f37c4705 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -511,7 +511,7 @@ mod test_map { assert!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { - None => fail!(), Some(x) => *x = new + None => panic!(), Some(x) => *x = new } assert_eq!(m.find(&5), Some(&new)); } diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 9cd8bde4a95b3..5dd3be4ec8fd4 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1367,7 +1367,7 @@ mod tests { // original problem code path anymore.) let s = String::from_str(""); let _bytes = s.as_bytes(); - fail!(); + panic!(); } #[test] @@ -1586,7 +1586,7 @@ mod tests { let len = c.encode_utf8(bytes).unwrap_or(0); let s = ::core::str::from_utf8(bytes[..len]).unwrap(); if Some(c) != s.chars().next() { - fail!("character {:x}={} does not decode correctly", c as u32, c); + panic!("character {:x}={} does not decode correctly", c as u32, c); } } } @@ -1598,7 +1598,7 @@ mod tests { let len = c.encode_utf8(bytes).unwrap_or(0); let s = ::core::str::from_utf8(bytes[..len]).unwrap(); if Some(c) != s.chars().rev().next() { - fail!("character {:x}={} does not decode correctly", c as u32, c); + panic!("character {:x}={} does not decode correctly", c as u32, c); } } } diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index c44a03b05cd35..b61f26688a2ee 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -504,7 +504,7 @@ impl String { /// assert_eq!(s.as_slice(), "he"); /// ``` #[inline] - #[unstable = "the failure conventions for strings are under development"] + #[unstable = "the panic conventions for strings are under development"] pub fn truncate(&mut self, new_len: uint) { assert!(self.as_slice().is_char_boundary(new_len)); self.vec.truncate(new_len) @@ -545,10 +545,10 @@ impl String { /// This is a O(n) operation as it requires copying every element in the /// buffer. /// - /// # Failure + /// # Panics /// /// If `idx` does not lie on a character boundary, then this function will - /// fail. + /// panic. /// /// # Example /// @@ -559,7 +559,7 @@ impl String { /// assert_eq!(s.remove(0), Some('o')); /// assert_eq!(s.remove(0), None); /// ``` - #[unstable = "the failure semantics of this function and return type \ + #[unstable = "the panic semantics of this function and return type \ may change"] pub fn remove(&mut self, idx: uint) -> Option { let len = self.len(); @@ -582,11 +582,11 @@ impl String { /// This is a O(n) operation as it requires copying every element in the /// buffer. /// - /// # Failure + /// # Panics /// /// If `idx` does not lie on a character boundary or is out of bounds, then - /// this function will fail. - #[unstable = "the failure semantics of this function are uncertain"] + /// this function will panic. + #[unstable = "the panic semantics of this function are uncertain"] pub fn insert(&mut self, idx: uint, ch: char) { let len = self.len(); assert!(idx <= len); diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index ee01cd343c3ae..feb4c11a061a5 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -490,7 +490,7 @@ impl TreeMap { /// let new_ua = "Safari/156.0"; /// match t.find_with_mut(|k| "User-Agent".cmp(k)) { /// Some(x) => *x = new_ua, - /// None => fail!(), + /// None => panic!(), /// } /// /// assert_eq!(t.find(&"User-Agent"), Some(&new_ua)); @@ -1616,7 +1616,7 @@ fn remove(node: &mut Option>>, } } return match node.take() { - Some(box TreeNode{value, ..}) => Some(value), None => fail!() + Some(box TreeNode{value, ..}) => Some(value), None => panic!() }; } @@ -1726,7 +1726,7 @@ mod test_treemap { assert!(m.insert(5, 14)); let new = 100; match m.find_mut(&5) { - None => fail!(), Some(x) => *x = new + None => panic!(), Some(x) => *x = new } assert_eq!(m.find(&5), Some(&new)); } @@ -1739,7 +1739,7 @@ mod test_treemap { assert!(m.insert("t5", 14)); let new = 100; match m.find_with_mut(|k| "t5".cmp(k)) { - None => fail!(), Some(x) => *x = new + None => panic!(), Some(x) => *x = new } assert_eq!(m.find_with(|k| "t5".cmp(k)), Some(&new)); } diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 1b5c5dbc0a20b..d02190e08247e 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -834,7 +834,7 @@ fn insert(count: &mut uint, child: &mut Child, key: uint, value: T, *child = Internal(new); return ret; } - _ => fail!("unreachable code"), + _ => panic!("unreachable code"), } } @@ -844,7 +844,7 @@ fn remove(count: &mut uint, child: &mut Child, key: uint, External(stored, _) if stored == key => { match mem::replace(child, Nothing) { External(_, value) => (Some(value), true), - _ => fail!() + _ => panic!() } } External(..) => (None, false), @@ -1057,7 +1057,7 @@ mod test_map { assert!(m.insert(5u, 14i)); let new = 100; match m.find_mut(&5) { - None => fail!(), Some(x) => *x = new + None => panic!(), Some(x) => *x = new } assert_eq!(m.find(&5), Some(&new)); } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index dd9883ecaae84..759f9ec7d3f03 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -583,7 +583,7 @@ impl Vec { pub fn reserve_additional(&mut self, extra: uint) { if self.cap - self.len < extra { match self.len.checked_add(&extra) { - None => fail!("Vec::reserve_additional: `uint` overflow"), + None => panic!("Vec::reserve_additional: `uint` overflow"), Some(new_cap) => self.reserve(new_cap) } } @@ -699,12 +699,12 @@ impl Vec { /// vec.truncate(2); /// assert_eq!(vec, vec![1, 2]); /// ``` - #[unstable = "waiting on failure semantics"] + #[unstable = "waiting on panic semantics"] pub fn truncate(&mut self, len: uint) { unsafe { // drop any extra elements while len < self.len { - // decrement len before the read(), so a failure on Drop doesn't + // decrement len before the read(), so a panic on Drop doesn't // re-drop the just-failed value. self.len -= 1; ptr::read(self.as_slice().unsafe_get(self.len)); @@ -960,9 +960,9 @@ impl Vec { /// Inserts an element at position `index` within the vector, shifting all /// elements after position `i` one position to the right. /// - /// # Failure + /// # Panics /// - /// Fails if `index` is not between `0` and the vector's length (both + /// Panics if `index` is not between `0` and the vector's length (both /// bounds inclusive). /// /// # Example @@ -974,7 +974,7 @@ impl Vec { /// vec.insert(4, 5); /// assert_eq!(vec, vec![1, 4, 2, 3, 5]); /// ``` - #[unstable = "failure semantics need settling"] + #[unstable = "panic semantics need settling"] pub fn insert(&mut self, index: uint, element: T) { let len = self.len(); assert!(index <= len); @@ -1011,7 +1011,7 @@ impl Vec { /// // v is unchanged: /// assert_eq!(v, vec![1, 3]); /// ``` - #[unstable = "failure semantics need settling"] + #[unstable = "panic semantics need settling"] pub fn remove(&mut self, index: uint) -> Option { let len = self.len(); if index < len { @@ -1353,7 +1353,7 @@ impl Vec { pub fn dedup(&mut self) { unsafe { // Although we have a mutable reference to `self`, we cannot make - // *arbitrary* changes. The `PartialEq` comparisons could fail, so we + // *arbitrary* changes. The `PartialEq` comparisons could panic, so we // must ensure that the vector is in a valid state at all time. // // The way that we handle this is by using swaps; we iterate @@ -1520,7 +1520,7 @@ impl MutableSeq for Vec { if self.len == self.cap { let old_size = self.cap * mem::size_of::(); let size = max(old_size, 2 * mem::size_of::()) * 2; - if old_size > size { fail!("capacity overflow") } + if old_size > size { panic!("capacity overflow") } unsafe { self.ptr = alloc_or_realloc(self.ptr, old_size, size); } @@ -1877,7 +1877,7 @@ impl Vec { // +-+-+-+-+-+-+-+-+-+ // | | // end_u end_t - // We must not fail here, one cell is marked as `T` + // We must not panic here, one cell is marked as `T` // although it is not `T`. pv.start_t = pv.start_t.offset(1); @@ -1888,9 +1888,9 @@ impl Vec { // +-+-+-+-+-+-+-+-+-+ // | | // end_u end_t - // We may fail again. + // We may panic again. - // The function given by the user might fail. + // The function given by the user might panic. let u = f(t); ptr::write(pv.end_u, u); @@ -1901,7 +1901,7 @@ impl Vec { // +-+-+-+-+-+-+-+-+-+ // | | // end_u end_t - // We should not fail here, because that would leak the `U` + // We should not panic here, because that would leak the `U` // pointed to by `end_u`. pv.end_u = pv.end_u.offset(1); @@ -1912,7 +1912,7 @@ impl Vec { // +-+-+-+-+-+-+-+-+-+ // | | // end_u end_t - // We may fail again. + // We may panic again. } } @@ -1926,10 +1926,10 @@ impl Vec { // end_u // Extract `vec` and prevent the destructor of // `PartialVecNonZeroSized` from running. Note that none of the - // function calls can fail, thus no resources can be leaked (as the + // function calls can panic, thus no resources can be leaked (as the // `vec` member of `PartialVec` is the only one which holds // allocations -- and it is returned from this function. None of - // this can fail. + // this can panic. unsafe { let vec_len = pv.vec.len(); let vec_cap = pv.vec.capacity(); @@ -1953,24 +1953,24 @@ impl Vec { while pv.num_t != 0 { unsafe { // Create a `T` out of thin air and decrement `num_t`. This - // must not fail between these steps, as otherwise a + // must not panic between these steps, as otherwise a // destructor of `T` which doesn't exist runs. let t = mem::uninitialized(); pv.num_t -= 1; - // The function given by the user might fail. + // The function given by the user might panic. let u = f(t); // Forget the `U` and increment `num_u`. This increment // cannot overflow the `uint` as we only do this for a // number of times that fits into a `uint` (and start with - // `0`). Again, we should not fail between these steps. + // `0`). Again, we should not panic between these steps. mem::forget(u); pv.num_u += 1; } } // Create a `Vec` from our `PartialVecZeroSized` and make sure the - // destructor of the latter will not run. None of this can fail. + // destructor of the latter will not run. None of this can panic. let mut result = Vec::new(); unsafe { result.set_len(pv.num_u); } result @@ -2292,7 +2292,7 @@ mod tests { fn drop(&mut self) { let BadElem(ref mut x) = *self; if *x == 0xbadbeef { - fail!("BadElem failure: 0xbadbeef") + panic!("BadElem panic: 0xbadbeef") } } } diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs index cc6fe06665bc8..f272465e79626 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -599,8 +599,8 @@ unsafe fn atomic_store(dst: *mut T, val: T, order:Ordering) { Release => intrinsics::atomic_store_rel(dst, val), Relaxed => intrinsics::atomic_store_relaxed(dst, val), SeqCst => intrinsics::atomic_store(dst, val), - Acquire => fail!("there is no such thing as an acquire store"), - AcqRel => fail!("there is no such thing as an acquire/release store"), + Acquire => panic!("there is no such thing as an acquire store"), + AcqRel => panic!("there is no such thing as an acquire/release store"), } } @@ -610,8 +610,8 @@ unsafe fn atomic_load(dst: *const T, order:Ordering) -> T { Acquire => intrinsics::atomic_load_acq(dst), Relaxed => intrinsics::atomic_load_relaxed(dst), SeqCst => intrinsics::atomic_load(dst), - Release => fail!("there is no such thing as a release load"), - AcqRel => fail!("there is no such thing as an acquire/release load"), + Release => panic!("there is no such thing as a release load"), + AcqRel => panic!("there is no such thing as an acquire/release load"), } } @@ -737,7 +737,7 @@ pub fn fence(order: Ordering) { Release => intrinsics::atomic_fence_rel(), AcqRel => intrinsics::atomic_fence_acqrel(), SeqCst => intrinsics::atomic_fence(), - Relaxed => fail!("there is no such thing as a relaxed fence") + Relaxed => panic!("there is no such thing as a relaxed fence") } } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 8a4b9f6e51b60..9d3fa9deed773 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -31,7 +31,7 @@ //! tracked statically, at compile time. Because `RefCell` borrows are //! dynamic it is possible to attempt to borrow a value that is //! already mutably borrowed; when this happens it results in task -//! failure. +//! panic. //! //! # When to choose interior mutability //! @@ -109,7 +109,7 @@ //! // Recursive call to return the just-cached value. //! // Note that if we had not let the previous borrow //! // of the cache fall out of scope then the subsequent -//! // recursive borrow would cause a dynamic task failure. +//! // recursive borrow would cause a dynamic task panic. //! // This is the major hazard of using `RefCell`. //! self.minimum_spanning_tree() //! } @@ -281,7 +281,7 @@ impl RefCell { pub fn borrow<'a>(&'a self) -> Ref<'a, T> { match self.try_borrow() { Some(ptr) => ptr, - None => fail!("RefCell already mutably borrowed") + None => panic!("RefCell already mutably borrowed") } } @@ -314,7 +314,7 @@ impl RefCell { pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> { match self.try_borrow_mut() { Some(ptr) => ptr, - None => fail!("RefCell already borrowed") + None => panic!("RefCell already borrowed") } } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index f507556909c8f..5d9553cbbbd57 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -120,7 +120,7 @@ pub fn is_digit_radix(c: char, radix: uint) -> bool { #[inline] pub fn to_digit(c: char, radix: uint) -> Option { if radix > 36 { - fail!("to_digit: radix is too high (maximum 36)"); + panic!("to_digit: radix is too high (maximum 36)"); } let val = match c { '0' ... '9' => c as uint - ('0' as uint), @@ -147,7 +147,7 @@ pub fn to_digit(c: char, radix: uint) -> Option { #[inline] pub fn from_digit(num: uint, radix: uint) -> Option { if radix > 36 { - fail!("from_digit: radix is too high (maximum 36)"); + panic!("from_digit: radix is to high (maximum 36)"); } if num < radix { unsafe { diff --git a/src/libcore/finally.rs b/src/libcore/finally.rs index 9b59b410e7cc4..a17169f62c8be 100644 --- a/src/libcore/finally.rs +++ b/src/libcore/finally.rs @@ -60,7 +60,7 @@ impl Finally for fn() -> T { /** * The most general form of the `finally` functions. The function - * `try_fn` will be invoked first; whether or not it fails, the + * `try_fn` will be invoked first; whether or not it panics, the * function `finally_fn` will be invoked next. The two parameters * `mutate` and `drop` are used to thread state through the two * closures. `mutate` is used for any shared, mutable state that both @@ -69,7 +69,7 @@ impl Finally for fn() -> T { * * **WARNING:** While shared, mutable state between the try and finally * function is often necessary, one must be very careful; the `try` - * function could have failed at any point, so the values of the shared + * function could have panicked at any point, so the values of the shared * state may be inconsistent. * * # Example diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 343ab7cfd28b9..79191c5a2b426 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -94,7 +94,7 @@ pub fn float_to_str_bytes_common( assert!(2 <= radix && radix <= 36); match exp_format { ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e' - => fail!("float_to_str_bytes_common: radix {} incompatible with \ + => panic!("float_to_str_bytes_common: radix {} incompatible with \ use of 'e' as decimal exponent", radix), _ => () } @@ -127,7 +127,7 @@ pub fn float_to_str_bytes_common( ExpDec => { let (exp, exp_base) = match exp_format { ExpDec => (num.abs().log10().floor(), cast::(10.0f64).unwrap()), - ExpNone => fail!("unreachable"), + ExpNone => panic!("unreachable"), }; (num / exp_base.powf(exp), cast::(exp).unwrap()) @@ -299,7 +299,7 @@ pub fn float_to_str_bytes_common( buf[end] = match exp_format { ExpDec if exp_upper => 'E', ExpDec if !exp_upper => 'e', - _ => fail!("unreachable"), + _ => panic!("unreachable"), } as u8; end += 1; diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index e57c499948362..22d8ba63b20ec 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -92,7 +92,7 @@ macro_rules! radix { fn digit(&self, x: u8) -> u8 { match x { $($x => $conv,)+ - x => fail!("number not in the range 0..{}: {}", self.base() - 1, x), + x => panic!("number not in the range 0..{}: {}", self.base() - 1, x), } } } @@ -126,7 +126,7 @@ impl GenericRadix for Radix { match x { x @ 0 ... 9 => b'0' + x, x if x < self.base() => b'a' + (x - 10), - x => fail!("number not in the range 0..{}: {}", self.base() - 1, x), + x => panic!("number not in the range 0..{}: {}", self.base() - 1, x), } } } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 62a4fbd2e08cd..6370e55332efb 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -40,8 +40,8 @@ //! //! * `rust_begin_unwind` - This function takes three arguments, a //! `&fmt::Arguments`, a `&str`, and a `uint`. These three arguments dictate -//! the failure message, the file at which failure was invoked, and the line. -//! It is up to consumers of this core library to define this failure +//! the panic message, the file at which panic was invoked, and the line. +//! It is up to consumers of this core library to define this panic //! function; it is only required to never return. // Since libcore defines many fundamental lang items, all tests live in a @@ -111,7 +111,7 @@ pub mod atomic; pub mod bool; pub mod cell; pub mod char; -pub mod failure; +pub mod panicking; pub mod finally; pub mod iter; pub mod option; @@ -129,7 +129,7 @@ pub mod fmt; #[doc(hidden)] mod core { - pub use failure; + pub use panicking; } #[doc(hidden)] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 17fcf0254575d..9ba67bb2e47dc 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -10,15 +10,15 @@ #![macro_escape] -/// Entry point of failure, for details, see std::macros +/// Entry point of task panic, for details, see std::macros #[macro_export] -macro_rules! fail( +macro_rules! panic( () => ( - fail!("{}", "explicit failure") + panic!("{}", "explicit panic") ); ($msg:expr) => ({ static _MSG_FILE_LINE: (&'static str, &'static str, uint) = ($msg, file!(), line!()); - ::core::failure::fail(&_MSG_FILE_LINE) + ::core::panicking::panic(&_MSG_FILE_LINE) }); ($fmt:expr, $($arg:tt)*) => ({ // a closure can't have return type !, so we need a full @@ -31,7 +31,7 @@ macro_rules! fail( // as returning !. We really do want this to be inlined, however, // because it's just a tiny wrapper. Small wins (156K to 149K in size) // were seen when forcing this to be inlined, and that number just goes - // up with the number of calls to fail!() + // up with the number of calls to panic!() // // The leading _'s are to avoid dead code warnings if this is // used inside a dead function. Just `#[allow(dead_code)]` is @@ -40,7 +40,7 @@ macro_rules! fail( #[inline(always)] fn _run_fmt(fmt: &::std::fmt::Arguments) -> ! { static _FILE_LINE: (&'static str, uint) = (file!(), line!()); - ::core::failure::fail_fmt(fmt, &_FILE_LINE) + ::core::panicking::panic_fmt(fmt, &_FILE_LINE) } format_args!(_run_fmt, $fmt, $($arg)*) }); @@ -51,12 +51,12 @@ macro_rules! fail( macro_rules! assert( ($cond:expr) => ( if !$cond { - fail!(concat!("assertion failed: ", stringify!($cond))) + panic!(concat!("assertion failed: ", stringify!($cond))) } ); ($cond:expr, $($arg:tt)*) => ( if !$cond { - fail!($($arg)*) + panic!($($arg)*) } ); ) @@ -78,7 +78,7 @@ macro_rules! assert_eq( let c1 = $cond1; let c2 = $cond2; if c1 != c2 || c2 != c1 { - fail!("expressions not equal, left: {}, right: {}", c1, c2); + panic!("expressions not equal, left: {}, right: {}", c1, c2); } }) ) @@ -130,4 +130,4 @@ macro_rules! write( ) #[macro_export] -macro_rules! unreachable( () => (fail!("unreachable code")) ) +macro_rules! unreachable( () => (panic!("unreachable code")) ) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 3dceb42e20653..525d588d70f1d 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1349,7 +1349,7 @@ checked_impl!(CheckedMul, checked_mul, i16, intrinsics::i16_mul_with_overflow) checked_impl!(CheckedMul, checked_mul, i32, intrinsics::i32_mul_with_overflow) checked_impl!(CheckedMul, checked_mul, i64, intrinsics::i64_mul_with_overflow) -/// Performs division that returns `None` instead of failing on division by zero and instead of +/// Performs division that returns `None` instead of panicking on division by zero and instead of /// wrapping around on underflow and overflow. pub trait CheckedDiv: Div { /// Divides two numbers, checking for underflow, overflow and division by zero. If any of that diff --git a/src/libcore/option.rs b/src/libcore/option.rs index dd55c92097e94..522eb8336376e 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -291,9 +291,9 @@ impl Option { /// Unwraps an option, yielding the content of a `Some` /// - /// # Failure + /// # Panics /// - /// Fails if the value is a `None` with a custom failure message provided by + /// Fails if the value is a `None` with a custom panic message provided by /// `msg`. /// /// # Example @@ -312,19 +312,19 @@ impl Option { pub fn expect(self, msg: &str) -> T { match self { Some(val) => val, - None => fail!("{}", msg), + None => panic!("{}", msg), } } /// Returns the inner `T` of a `Some(T)`. /// - /// # Failure + /// # Panics /// - /// Fails if the self value equals `None`. + /// Panics if the self value equals `None`. /// /// # Safety note /// - /// In general, because this function may fail, its use is discouraged. + /// In general, because this function may panic, its use is discouraged. /// Instead, prefer to use pattern matching and handle the `None` /// case explicitly. /// @@ -344,7 +344,7 @@ impl Option { pub fn unwrap(self) -> T { match self { Some(val) => val, - None => fail!("called `Option::unwrap()` on a `None` value"), + None => panic!("called `Option::unwrap()` on a `None` value"), } } diff --git a/src/libcore/failure.rs b/src/libcore/panicking.rs similarity index 54% rename from src/libcore/failure.rs rename to src/libcore/panicking.rs index 9b63d325bc89a..cda21b6ecfa7d 100644 --- a/src/libcore/failure.rs +++ b/src/libcore/panicking.rs @@ -8,23 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Failure support for libcore +//! Panic support for libcore //! -//! The core library cannot define failure, but it does *declare* failure. This -//! means that the functions inside of libcore are allowed to fail, but to be -//! useful an upstream crate must define failure for libcore to use. The current -//! interface for failure is: +//! The core library cannot define panicking, but it does *declare* panicking. This +//! means that the functions inside of libcore are allowed to panic, but to be +//! useful an upstream crate must define panicking for libcore to use. The current +//! interface for panicking is: //! //! ```ignore -//! fn fail_impl(fmt: &fmt::Arguments, &(&'static str, uint)) -> !; +//! fn panic_impl(fmt: &fmt::Arguments, &(&'static str, uint)) -> !; //! ``` //! -//! This definition allows for failing with any general message, but it does not -//! allow for failing with a `~Any` value. The reason for this is that libcore +//! This definition allows for panicking with any general message, but it does not +//! allow for failing with a `Box` value. The reason for this is that libcore //! is not allowed to allocate. //! -//! This module contains a few other failure functions, but these are just the -//! necessary lang items for the compiler. All failure is funneled through this +//! This module contains a few other panicking functions, but these are just the +//! necessary lang items for the compiler. All panics are funneled through this //! one function. Currently, the actual symbol is declared in the standard //! library, but the location of this may change over time. @@ -34,36 +34,36 @@ use fmt; use intrinsics; #[cold] #[inline(never)] // this is the slow path, always -#[lang="fail"] -pub fn fail(expr_file_line: &(&'static str, &'static str, uint)) -> ! { +#[lang="panic"] +pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { let (expr, file, line) = *expr_file_line; let ref file_line = (file, line); format_args!(|args| -> () { - fail_fmt(args, file_line); + panic_fmt(args, file_line); }, "{}", expr); unsafe { intrinsics::abort() } } #[cold] #[inline(never)] -#[lang="fail_bounds_check"] -fn fail_bounds_check(file_line: &(&'static str, uint), +#[lang="panic_bounds_check"] +fn panic_bounds_check(file_line: &(&'static str, uint), index: uint, len: uint) -> ! { format_args!(|args| -> () { - fail_fmt(args, file_line); + panic_fmt(args, file_line); }, "index out of bounds: the len is {} but the index is {}", len, index); unsafe { intrinsics::abort() } } #[cold] #[inline(never)] -pub fn fail_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { +pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { #[allow(ctypes)] extern { - #[lang = "fail_fmt"] - fn fail_impl(fmt: &fmt::Arguments, file: &'static str, + #[lang = "panic_fmt"] + fn panic_impl(fmt: &fmt::Arguments, file: &'static str, line: uint) -> !; } let (file, line) = *file_line; - unsafe { fail_impl(fmt, file, line) } + unsafe { panic_impl(fmt, file, line) } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index f0cd8402b1424..5e2f5529e8d49 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -76,7 +76,7 @@ //! unsafe { //! let my_num: *mut int = libc::malloc(mem::size_of::() as libc::size_t) as *mut int; //! if my_num.is_null() { -//! fail!("failed to allocate memory"); +//! panic!("failed to allocate memory"); //! } //! libc::free(my_num as *mut libc::c_void); //! } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 27bb649d1d99b..82da972f68a35 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -123,8 +123,8 @@ //! warning (by default, controlled by the `unused_must_use` lint). //! //! You might instead, if you don't want to handle the error, simply -//! fail, by converting to an `Option` with `ok`, then asserting -//! success with `expect`. This will fail if the write fails, proving +//! panic, by converting to an `Option` with `ok`, then asserting +//! success with `expect`. This will panic if the write fails, proving //! a marginally useful message indicating why: //! //! ```{.no_run} @@ -250,29 +250,29 @@ //! let mut t = Timer::new().ok().expect("failed to create timer!"); //! ``` //! -//! # `Result` vs. `fail!` +//! # `Result` vs. `panic!` //! -//! `Result` is for recoverable errors; `fail!` is for unrecoverable -//! errors. Callers should always be able to avoid failure if they +//! `Result` is for recoverable errors; `panic!` is for unrecoverable +//! errors. Callers should always be able to avoid panics if they //! take the proper precautions, for example, calling `is_some()` //! on an `Option` type before calling `unwrap`. //! -//! The suitability of `fail!` as an error handling mechanism is +//! The suitability of `panic!` as an error handling mechanism is //! limited by Rust's lack of any way to "catch" and resume execution -//! from a thrown exception. Therefore using failure for error -//! handling requires encapsulating fallible code in a task. Calling -//! the `fail!` macro, or invoking `fail!` indirectly should be -//! avoided as an error reporting strategy. Failure is only for -//! unrecoverable errors and a failing task is typically the sign of +//! from a thrown exception. Therefore using panics for error +//! handling requires encapsulating code that may panic in a task. +//! Calling the `panic!` macro, or invoking `panic!` indirectly should be +//! avoided as an error reporting strategy. Panics is only for +//! unrecoverable errors and a panicking task is typically the sign of //! a bug. //! //! A module that instead returns `Results` is alerting the caller -//! that failure is possible, and providing precise control over how +//! that panics are possible, and providing precise control over how //! it is handled. //! -//! Furthermore, failure may not be recoverable at all, depending on -//! the context. The caller of `fail!` should assume that execution -//! will not resume after failure, that failure is catastrophic. +//! Furthermore, panics may not be recoverable at all, depending on +//! the context. The caller of `panic!` should assume that execution +//! will not resume after the panic, that a panic is catastrophic. #![stable] @@ -764,9 +764,9 @@ impl Result { impl Result { /// Unwraps a result, yielding the content of an `Ok`. /// - /// # Failure + /// # Panics /// - /// Fails if the value is an `Err`, with a custom failure message provided + /// Panics if the value is an `Err`, with a custom panic message provided /// by the `Err`'s value. /// /// # Example @@ -778,7 +778,7 @@ impl Result { /// /// ```{.should_fail} /// let x: Result = Err("emergency failure"); - /// x.unwrap(); // fails with `emergency failure` + /// x.unwrap(); // panics with `emergency failure` /// ``` #[inline] #[unstable = "waiting for conventions"] @@ -786,7 +786,7 @@ impl Result { match self { Ok(t) => t, Err(e) => - fail!("called `Result::unwrap()` on an `Err` value: {}", e) + panic!("called `Result::unwrap()` on an `Err` value: {}", e) } } } @@ -794,16 +794,16 @@ impl Result { impl Result { /// Unwraps a result, yielding the content of an `Err`. /// - /// # Failure + /// # Panics /// - /// Fails if the value is an `Ok`, with a custom failure message provided + /// Panics if the value is an `Ok`, with a custom panic message provided /// by the `Ok`'s value. /// /// # Example /// /// ```{.should_fail} /// let x: Result = Ok(2u); - /// x.unwrap_err(); // fails with `2` + /// x.unwrap_err(); // panics with `2` /// ``` /// /// ``` @@ -815,7 +815,7 @@ impl Result { pub fn unwrap_err(self) -> E { match self { Ok(t) => - fail!("called `Result::unwrap_err()` on an `Ok` value: {}", t), + panic!("called `Result::unwrap_err()` on an `Ok` value: {}", t), Err(e) => e } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 0c2415753faf0..ff1db992844d6 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1460,7 +1460,7 @@ pub trait StrSlice for Sized? { /// /// assert_eq!(s.slice(1, 9), "öwe 老"); /// - /// // these will fail: + /// // these will panic: /// // byte 2 lies within `ö`: /// // s.slice(2, 3); /// @@ -1832,7 +1832,7 @@ pub trait StrSlice for Sized? { #[inline(never)] fn slice_error_fail(s: &str, begin: uint, end: uint) -> ! { assert!(begin <= end); - fail!("index {} and/or {} in `{}` do not lie on character boundary", + panic!("index {} and/or {} in `{}` do not lie on character boundary", begin, end, s); } @@ -1986,8 +1986,8 @@ impl StrSlice for str { if end_byte.is_none() && count == end { end_byte = Some(self.len()) } match (begin_byte, end_byte) { - (None, _) => fail!("slice_chars: `begin` is beyond end of string"), - (_, None) => fail!("slice_chars: `end` is beyond end of string"), + (None, _) => panic!("slice_chars: `begin` is beyond end of string"), + (_, None) => panic!("slice_chars: `end` is beyond end of string"), (Some(a), Some(b)) => unsafe { raw::slice_bytes(self, a, b) } } } diff --git a/src/libcoretest/any.rs b/src/libcoretest/any.rs index 9656a6caba08c..7c832e90ed96b 100644 --- a/src/libcoretest/any.rs +++ b/src/libcoretest/any.rs @@ -56,12 +56,12 @@ fn any_downcast_ref() { match a.downcast_ref::() { Some(&5) => {} - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } match a.downcast_ref::() { None => {} - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } } @@ -79,7 +79,7 @@ fn any_downcast_mut() { assert_eq!(*x, 5u); *x = 612; } - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } match b_r.downcast_mut::() { @@ -87,27 +87,27 @@ fn any_downcast_mut() { assert_eq!(*x, 7u); *x = 413; } - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } match a_r.downcast_mut::() { None => (), - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } match b_r.downcast_mut::() { None => (), - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } match a_r.downcast_mut::() { Some(&612) => {} - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } match b_r.downcast_mut::() { Some(&413) => {} - x => fail!("Unexpected value {}", x) + x => panic!("Unexpected value {}", x) } } diff --git a/src/libcoretest/finally.rs b/src/libcoretest/finally.rs index 5da004086d27f..032f5f7194117 100644 --- a/src/libcoretest/finally.rs +++ b/src/libcoretest/finally.rs @@ -35,7 +35,7 @@ fn test_fail() { &mut i, (), |i, ()| { *i = 10; - fail!(); + panic!(); }, |i| { assert!(failing()); diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index 476a2b50fcc81..98db377b0d576 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -373,7 +373,7 @@ fn test_all() { assert!(v.iter().all(|&x| x < 10)); assert!(!v.iter().all(|&x| x % 2 == 0)); assert!(!v.iter().all(|&x| x > 100)); - assert!(v.slice_or_fail(&0, &0).iter().all(|_| fail!())); + assert!(v.slice_or_fail(&0, &0).iter().all(|_| panic!())); } #[test] @@ -382,7 +382,7 @@ fn test_any() { assert!(v.iter().any(|&x| x < 10)); assert!(v.iter().any(|&x| x % 2 == 0)); assert!(!v.iter().any(|&x| x > 100)); - assert!(!v.slice_or_fail(&0, &0).iter().any(|_| fail!())); + assert!(!v.slice_or_fail(&0, &0).iter().any(|_| panic!())); } #[test] @@ -528,13 +528,13 @@ fn test_rposition() { #[test] #[should_fail] -fn test_rposition_fail() { +fn test_rposition_panic() { let v = [(box 0i, box 0i), (box 0i, box 0i), (box 0i, box 0i), (box 0i, box 0i)]; let mut i = 0i; v.iter().rposition(|_elt| { if i == 2 { - fail!() + panic!() } i += 1; false @@ -678,12 +678,12 @@ fn test_random_access_cycle() { fn test_double_ended_range() { assert!(range(11i, 14).rev().collect::>() == vec![13i, 12, 11]); for _ in range(10i, 0).rev() { - fail!("unreachable"); + panic!("unreachable"); } assert!(range(11u, 14).rev().collect::>() == vec![13u, 12, 11]); for _ in range(10u, 0).rev() { - fail!("unreachable"); + panic!("unreachable"); } } diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs index 71e9270fe4b0c..18444fc424082 100644 --- a/src/libcoretest/option.rs +++ b/src/libcoretest/option.rs @@ -139,14 +139,14 @@ fn test_unwrap() { #[test] #[should_fail] -fn test_unwrap_fail1() { +fn test_unwrap_panic1() { let x: Option = None; x.unwrap(); } #[test] #[should_fail] -fn test_unwrap_fail2() { +fn test_unwrap_panic2() { let x: Option = None; x.unwrap(); } @@ -233,7 +233,7 @@ fn test_collect() { assert!(v == None); // test that it does not take more elements than it needs - let mut functions = [|| Some(()), || None, || fail!()]; + let mut functions = [|| Some(()), || None, || panic!()]; let v: Option> = functions.iter_mut().map(|f| (*f)()).collect(); diff --git a/src/libcoretest/result.rs b/src/libcoretest/result.rs index 1cb72bd9eac78..92124e2f299cd 100644 --- a/src/libcoretest/result.rs +++ b/src/libcoretest/result.rs @@ -81,7 +81,7 @@ fn test_collect() { assert!(v == Err(2)); // test that it does not take more elements than it needs - let mut functions = [|| Ok(()), || Err(1i), || fail!()]; + let mut functions = [|| Ok(()), || Err(1i), || panic!()]; let v: Result, int> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == Err(1)); @@ -113,7 +113,7 @@ pub fn test_unwrap_or_else() { if msg == "I got this." { 50i } else { - fail!("BadBad") + panic!("BadBad") } } @@ -126,12 +126,12 @@ pub fn test_unwrap_or_else() { #[test] #[should_fail] -pub fn test_unwrap_or_else_failure() { +pub fn test_unwrap_or_else_panic() { fn handler(msg: &'static str) -> int { if msg == "I got this." { 50i } else { - fail!("BadBad") + panic!("BadBad") } } diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index a73f7ddf7f7ed..24b7802097409 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -61,7 +61,7 @@ //! ]; //! let matches = match getopts(args.tail(), opts) { //! Ok(m) => { m } -//! Err(f) => { fail!(f.to_string()) } +//! Err(f) => { panic!(f.to_string()) } //! }; //! if matches.opt_present("h") { //! print_usage(program.as_slice(), opts); @@ -243,7 +243,7 @@ impl OptGroup { } = (*self).clone(); match (short_name.len(), long_name.len()) { - (0,0) => fail!("this long-format option was given no name"), + (0,0) => panic!("this long-format option was given no name"), (0,_) => Opt { name: Long((long_name)), hasarg: hasarg, @@ -269,7 +269,7 @@ impl OptGroup { } ) }, - (_,_) => fail!("something is wrong with the long-form opt") + (_,_) => panic!("something is wrong with the long-form opt") } } } @@ -278,7 +278,7 @@ impl Matches { fn opt_vals(&self, nm: &str) -> Vec { match find_opt(self.opts.as_slice(), Name::from_str(nm)) { Some(id) => self.vals[id].clone(), - None => fail!("No option '{}' defined", nm) + None => panic!("No option '{}' defined", nm) } } @@ -530,8 +530,10 @@ impl fmt::Show for Fail_ { /// Parse command line arguments according to the provided options. /// /// On success returns `Ok(Matches)`. Use methods such as `opt_present` -/// `opt_str`, etc. to interrogate results. Returns `Err(Fail_)` on -/// failure: use the `Show` implementation of `Fail_` to display +/// `opt_str`, etc. to interrogate results. +/// # Failure +/// +/// Returns `Err(Fail_)` on failure: use the `Show` implementation of `Fail_` to display /// information about it. pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result { let opts: Vec = optgrps.iter().map(|x| x.long_to_short()).collect(); @@ -688,7 +690,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String { row.push_str(short_name.as_slice()); row.push(' '); } - _ => fail!("the short name should only be 1 ascii char long"), + _ => panic!("the short name should only be 1 ascii char long"), } // long option @@ -852,7 +854,7 @@ fn each_split_within<'a>(ss: &'a str, lim: uint, it: |&'a str| -> bool) (B, Cr, UnderLim) => { B } (B, Cr, OverLim) if (i - last_start + 1) > lim - => fail!("word starting with {} longer than limit!", + => panic!("word starting with {} longer than limit!", ss.slice(last_start, i + 1)), (B, Cr, OverLim) => { *cont = it(ss.slice(slice_start, last_end)); @@ -951,7 +953,7 @@ mod tests { assert!(m.opt_present("t")); assert_eq!(m.opt_str("t").unwrap(), "20".to_string()); } - _ => { fail!("test_reqopt failed (long arg)"); } + _ => { panic!("test_reqopt failed (long arg)"); } } let short_args = vec!("-t".to_string(), "20".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { @@ -961,7 +963,7 @@ mod tests { assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), "20".to_string()); } - _ => { fail!("test_reqopt failed (short arg)"); } + _ => { panic!("test_reqopt failed (short arg)"); } } } @@ -972,7 +974,7 @@ mod tests { let rs = getopts(args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, OptionMissing_), - _ => fail!() + _ => panic!() } } @@ -983,12 +985,12 @@ mod tests { let rs = getopts(long_args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() + _ => panic!() } let short_args = vec!("-t".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() + _ => panic!() } } @@ -999,7 +1001,7 @@ mod tests { let rs = getopts(args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, OptionDuplicated_), - _ => fail!() + _ => panic!() } } @@ -1016,7 +1018,7 @@ mod tests { assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), "20".to_string()); } - _ => fail!() + _ => panic!() } let short_args = vec!("-t".to_string(), "20".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { @@ -1026,7 +1028,7 @@ mod tests { assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), "20".to_string()); } - _ => fail!() + _ => panic!() } } @@ -1040,7 +1042,7 @@ mod tests { assert!(!m.opt_present("test")); assert!(!m.opt_present("t")); } - _ => fail!() + _ => panic!() } } @@ -1051,12 +1053,12 @@ mod tests { let rs = getopts(long_args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() + _ => panic!() } let short_args = vec!("-t".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() + _ => panic!() } } @@ -1067,7 +1069,7 @@ mod tests { let rs = getopts(args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, OptionDuplicated_), - _ => fail!() + _ => panic!() } } @@ -1082,7 +1084,7 @@ mod tests { assert!(m.opt_present("test")); assert!(m.opt_present("t")); } - _ => fail!() + _ => panic!() } let short_args = vec!("-t".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { @@ -1090,7 +1092,7 @@ mod tests { assert!(m.opt_present("test")); assert!(m.opt_present("t")); } - _ => fail!() + _ => panic!() } } @@ -1104,7 +1106,7 @@ mod tests { assert!(!m.opt_present("test")); assert!(!m.opt_present("t")); } - _ => fail!() + _ => panic!() } } @@ -1117,7 +1119,7 @@ mod tests { Err(f) => { check_fail_type(f, UnexpectedArgument_); } - _ => fail!() + _ => panic!() } } @@ -1128,7 +1130,7 @@ mod tests { let rs = getopts(args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, OptionDuplicated_), - _ => fail!() + _ => panic!() } } @@ -1143,7 +1145,7 @@ mod tests { assert!(m.free[0] == "20".to_string()); } - _ => fail!() + _ => panic!() } } @@ -1157,7 +1159,7 @@ mod tests { Ok(ref m) => { assert_eq!(m.opt_count("v"), 1); } - _ => fail!() + _ => panic!() } } @@ -1170,7 +1172,7 @@ mod tests { Ok(ref m) => { assert_eq!(m.opt_count("v"), 2); } - _ => fail!() + _ => panic!() } } @@ -1183,7 +1185,7 @@ mod tests { Ok(ref m) => { assert_eq!(m.opt_count("v"), 2); } - _ => fail!() + _ => panic!() } } @@ -1196,7 +1198,7 @@ mod tests { Ok(ref m) => { assert_eq!(m.opt_count("verbose"), 1); } - _ => fail!() + _ => panic!() } } @@ -1209,7 +1211,7 @@ mod tests { Ok(ref m) => { assert_eq!(m.opt_count("verbose"), 2); } - _ => fail!() + _ => panic!() } } @@ -1224,7 +1226,7 @@ mod tests { assert_eq!(m.opt_count("verbose"), 4); assert_eq!(m.opt_count("v"), 4); } - _ => fail!() + _ => panic!() } } @@ -1241,7 +1243,7 @@ mod tests { assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), "20".to_string()); } - _ => fail!() + _ => panic!() } let short_args = vec!("-t".to_string(), "20".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { @@ -1251,7 +1253,7 @@ mod tests { assert!((m.opt_present("t"))); assert_eq!(m.opt_str("t").unwrap(), "20".to_string()); } - _ => fail!() + _ => panic!() } } @@ -1265,7 +1267,7 @@ mod tests { assert!(!m.opt_present("test")); assert!(!m.opt_present("t")); } - _ => fail!() + _ => panic!() } } @@ -1276,12 +1278,12 @@ mod tests { let rs = getopts(long_args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() + _ => panic!() } let short_args = vec!("-t".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { Err(f) => check_fail_type(f, ArgumentMissing_), - _ => fail!() + _ => panic!() } } @@ -1300,7 +1302,7 @@ mod tests { assert!(pair[0] == "20".to_string()); assert!(pair[1] == "30".to_string()); } - _ => fail!() + _ => panic!() } } @@ -1311,12 +1313,12 @@ mod tests { let rs = getopts(long_args.as_slice(), opts.as_slice()); match rs { Err(f) => check_fail_type(f, UnrecognizedOption_), - _ => fail!() + _ => panic!() } let short_args = vec!("-u".to_string()); match getopts(short_args.as_slice(), opts.as_slice()) { Err(f) => check_fail_type(f, UnrecognizedOption_), - _ => fail!() + _ => panic!() } } @@ -1365,7 +1367,7 @@ mod tests { assert!(pair[1] == "-60 70".to_string()); assert!((!m.opt_present("notpresent"))); } - _ => fail!() + _ => panic!() } } @@ -1379,7 +1381,7 @@ mod tests { let matches_single = &match getopts(args_single.as_slice(), opts.as_slice()) { result::Ok(m) => m, - result::Err(_) => fail!() + result::Err(_) => panic!() }; assert!(matches_single.opts_present(["e".to_string()])); assert!(matches_single.opts_present(["encrypt".to_string(), "e".to_string()])); @@ -1399,7 +1401,7 @@ mod tests { let matches_both = &match getopts(args_both.as_slice(), opts.as_slice()) { result::Ok(m) => m, - result::Err(_) => fail!() + result::Err(_) => panic!() }; assert!(matches_both.opts_present(["e".to_string()])); assert!(matches_both.opts_present(["encrypt".to_string()])); @@ -1424,7 +1426,7 @@ mod tests { optmulti("M", "", "something", "MMMM")); let matches = &match getopts(args.as_slice(), opts.as_slice()) { result::Ok(m) => m, - result::Err(_) => fail!() + result::Err(_) => panic!() }; assert!(matches.opts_present(["L".to_string()])); assert_eq!(matches.opts_str(["L".to_string()]).unwrap(), "foo".to_string()); @@ -1440,7 +1442,7 @@ mod tests { optflagmulti("v", "verbose", "Verbose")); let matches = &match getopts(args.as_slice(), opts.as_slice()) { result::Ok(m) => m, - result::Err(e) => fail!( "{}", e ) + result::Err(e) => panic!( "{}", e ) }; assert!(matches.opts_present(["L".to_string()])); assert_eq!(matches.opts_str(["L".to_string()]).unwrap(), "verbose".to_string()); diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs index b592ba477c2a1..b476f46833bdb 100644 --- a/src/libgreen/basic.rs +++ b/src/libgreen/basic.rs @@ -73,13 +73,13 @@ impl BasicLoop { RunRemote(i) => { match self.remotes.iter_mut().find(|& &(id, _)| id == i) { Some(&(_, ref mut f)) => f.call(), - None => fail!("bad remote: {}", i), + None => panic!("bad remote: {}", i), } } RemoveRemote(i) => { match self.remotes.iter().position(|&(id, _)| id == i) { Some(i) => { self.remotes.remove(i).unwrap(); } - None => fail!("bad remote: {}", i), + None => panic!("bad remote: {}", i), } } } diff --git a/src/libgreen/context.rs b/src/libgreen/context.rs index a665d41aadf96..2d3e85cc833f3 100644 --- a/src/libgreen/context.rs +++ b/src/libgreen/context.rs @@ -102,14 +102,14 @@ impl Context { // Right before we switch to the new context, set the new context's // stack limit in the OS-specified TLS slot. This also means that // we cannot call any more rust functions after record_stack_bounds - // returns because they would all likely fail due to the limit being + // returns because they would all likely panic due to the limit being // invalid for the current task. Lucky for us `rust_swap_registers` // is a C function so we don't have to worry about that! match in_context.stack_bounds { Some((lo, hi)) => stack::record_rust_managed_stack_bounds(lo, hi), // If we're going back to one of the original contexts or // something that's possibly not a "normal task", then reset - // the stack limit to 0 to make morestack never fail + // the stack limit to 0 to make morestack never panic None => stack::record_rust_managed_stack_bounds(0, uint::MAX), } rust_swap_registers(out_regs, in_regs); diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 5435a6f74d38b..fcebfeac29298 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -168,7 +168,7 @@ //! drop(handle); //! //! // Required to shut down this scheduler pool. -//! // The task will fail if `shutdown` is not called. +//! // The task will panic if `shutdown` is not called. //! pool.shutdown(); //! # } //! ``` @@ -511,7 +511,7 @@ impl TaskState { impl Drop for SchedPool { fn drop(&mut self) { if self.threads.len() > 0 { - fail!("dropping a M:N scheduler pool that wasn't shut down"); + panic!("dropping a M:N scheduler pool that wasn't shut down"); } } } diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index c465aad3e3b5b..b1c2695ac7d27 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -761,7 +761,7 @@ impl Scheduler { // task-local lock around this block. The resumption of the task in // context switching will bounce on the lock, thereby waiting for this // block to finish, eliminating the race mentioned above. - // fail!("should never return!"); + // panic!("should never return!"); // // To actually maintain a handle to the lock, we use an unsafe pointer // to it, but we're guaranteed that the task won't exit until we've @@ -806,7 +806,7 @@ impl Scheduler { coroutine.recycle(&mut sched.stack_pool); sched.task_state.decrement(); }); - fail!("should never return!"); + panic!("should never return!"); } pub fn run_task(self: Box, @@ -1054,7 +1054,7 @@ mod test { task.put_runtime(green); return ret; } - None => fail!() + None => panic!() } } @@ -1202,8 +1202,8 @@ mod test { }))) => { *id == sched_id } - TypeGreen(None) => { fail!("task without home"); } - TypeSched => { fail!("expected green task"); } + TypeGreen(None) => { panic!("task without home"); } + TypeSched => { panic!("expected green task"); } }; task.put(); ret diff --git a/src/libgreen/simple.rs b/src/libgreen/simple.rs index 686a039d6d600..6c33e7cc619fd 100644 --- a/src/libgreen/simple.rs +++ b/src/libgreen/simple.rs @@ -67,23 +67,23 @@ impl Runtime for SimpleTask { } } - // These functions are all unimplemented and fail as a result. This is on + // These functions are all unimplemented and panic as a result. This is on // purpose. A "simple task" is just that, a very simple task that can't // really do a whole lot. The only purpose of the task is to get us off our // feet and running. - fn yield_now(self: Box, _cur_task: Box) { fail!() } - fn maybe_yield(self: Box, _cur_task: Box) { fail!() } + fn yield_now(self: Box, _cur_task: Box) { panic!() } + fn maybe_yield(self: Box, _cur_task: Box) { panic!() } fn spawn_sibling(self: Box, _cur_task: Box, _opts: TaskOpts, _f: proc():Send) { - fail!() + panic!() } fn local_io<'a>(&'a mut self) -> Option> { None } - fn stack_bounds(&self) -> (uint, uint) { fail!() } - fn stack_guard(&self) -> Option { fail!() } + fn stack_bounds(&self) -> (uint, uint) { panic!() } + fn stack_guard(&self) -> Option { panic!() } fn can_block(&self) -> bool { true } - fn wrap(self: Box) -> Box { fail!() } + fn wrap(self: Box) -> Box { panic!() } } pub fn task() -> Box { diff --git a/src/libgreen/stack.rs b/src/libgreen/stack.rs index cccf0ec698779..7d6c82cb0c325 100644 --- a/src/libgreen/stack.rs +++ b/src/libgreen/stack.rs @@ -24,7 +24,7 @@ pub struct Stack { // Try to use MAP_STACK on platforms that support it (it's what we're doing // anyway), but some platforms don't support it at all. For example, it appears // that there's a bug in freebsd that MAP_STACK implies MAP_FIXED (so it always -// fails): http://lists.freebsd.org/pipermail/freebsd-bugs/2011-July/044840.html +// panics): http://lists.freebsd.org/pipermail/freebsd-bugs/2011-July/044840.html // // DragonFly BSD also seems to suffer from the same problem. When MAP_STACK is // used, it returns the same `ptr` multiple times. @@ -37,7 +37,7 @@ static STACK_FLAGS: libc::c_int = libc::MAP_PRIVATE | libc::MAP_ANON; static STACK_FLAGS: libc::c_int = 0; impl Stack { - /// Allocate a new stack of `size`. If size = 0, this will fail. Use + /// Allocate a new stack of `size`. If size = 0, this will panic. Use /// `dummy_stack` if you want a zero-sized stack. pub fn new(size: uint) -> Stack { // Map in a stack. Eventually we might be able to handle stack @@ -47,7 +47,7 @@ impl Stack { let stack = match MemoryMap::new(size, [MapReadable, MapWritable, MapNonStandardFlags(STACK_FLAGS)]) { Ok(map) => map, - Err(e) => fail!("mmap for stack of size {} failed: {}", size, e) + Err(e) => panic!("mmap for stack of size {} failed: {}", size, e) }; // Change the last page to be inaccessible. This is to provide safety; @@ -55,7 +55,7 @@ impl Stack { // page. It isn't guaranteed, but that's why FFI is unsafe. buf.data is // guaranteed to be aligned properly. if !protect_last_page(&stack) { - fail!("Could not memory-protect guard page. stack={}, errno={}", + panic!("Could not memory-protect guard page. stack={}, errno={}", stack.data(), errno()); } diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index f151e00f56d56..0c549fa66c103 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -443,7 +443,7 @@ impl Runtime for GreenTask { self.put_task(cur_task); // First, set up a bomb which when it goes off will restore the local - // task unless its disarmed. This will allow us to gracefully fail from + // task unless its disarmed. This will allow us to gracefully panic from // inside of `configure` which allocates a new task. struct Bomb { inner: Option> } impl Drop for Bomb { @@ -529,11 +529,11 @@ mod tests { } #[test] - fn smoke_fail() { + fn smoke_panic() { let (tx, rx) = channel::(); spawn_opts(TaskOpts::new(), proc() { let _tx = tx; - fail!() + panic!() }); assert_eq!(rx.recv_opt(), Err(())); } @@ -550,11 +550,11 @@ mod tests { } #[test] - fn smoke_opts_fail() { + fn smoke_opts_panic() { let mut opts = TaskOpts::new(); let (tx, rx) = channel(); opts.on_exit = Some(proc(r) tx.send(r)); - spawn_opts(opts, proc() { fail!() }); + spawn_opts(opts, proc() { panic!() }); assert!(rx.recv().is_err()); } @@ -597,7 +597,7 @@ mod tests { Some(ops) => { task.put_runtime(ops); } - None => fail!(), + None => panic!(), } Local::put(task); tx.send(()); diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 9d5080522c26e..832f61d8d663d 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -255,7 +255,7 @@ impl Logger for DefaultLogger { record.level, record.module_path, record.args) { - Err(e) => fail!("failed to log: {}", e), + Err(e) => panic!("failed to log: {}", e), Ok(()) => {} } } @@ -263,9 +263,9 @@ impl Logger for DefaultLogger { impl Drop for DefaultLogger { fn drop(&mut self) { - // FIXME(#12628): is failure the right thing to do? + // FIXME(#12628): is panicking the right thing to do? match self.handle.flush() { - Err(e) => fail!("failed to flush a logger: {}", e), + Err(e) => panic!("failed to flush a logger: {}", e), Ok(()) => {} } } diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index 88f5061bbef17..f616295c73d1b 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -523,7 +523,7 @@ mod tests { assert_eq!(buf[2], 's' as u8); assert_eq!(buf[3], 't' as u8); } - r => fail!("invalid read: {}", r) + r => panic!("invalid read: {}", r), } assert!(writer.inner_read(buf).is_err()); @@ -547,7 +547,7 @@ mod tests { assert_eq!(buf[2], 's' as u8); assert_eq!(buf[3], 't' as u8); } - r => fail!("invalid read: {}", r) + r => panic!("invalid read: {}", r) } } } diff --git a/src/libnative/io/pipe_windows.rs b/src/libnative/io/pipe_windows.rs index bc08ede39f769..f764470f37d89 100644 --- a/src/libnative/io/pipe_windows.rs +++ b/src/libnative/io/pipe_windows.rs @@ -710,7 +710,7 @@ impl UnixAcceptor { if new_handle == libc::INVALID_HANDLE_VALUE { let ret = Err(super::last_error()); // If our disconnection fails, then there's not really a whole lot - // that we can do, so fail the task. + // that we can do, so panic let err = unsafe { libc::DisconnectNamedPipe(handle) }; assert!(err != 0); return ret; diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index d69042175f7cc..fed4a46b9df7f 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -600,7 +600,7 @@ fn spawn_process_os(cfg: ProcessConfig, handle: ptr::null_mut() }) } - Ok(..) => fail!("short read on the cloexec pipe"), + Ok(..) => panic!("short read on the cloexec pipe"), }; } // And at this point we've reached a special time in the life of the @@ -944,7 +944,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult { let mut status = 0 as c_int; if deadline == 0 { return match retry(|| unsafe { c::waitpid(pid, &mut status, 0) }) { - -1 => fail!("unknown waitpid error: {}", super::last_error().code), + -1 => panic!("unknown waitpid error: {}", super::last_error().code), _ => Ok(translate_status(status)), } } @@ -1069,7 +1069,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult { continue } - n => fail!("error in select {} ({})", os::errno(), n), + n => panic!("error in select {} ({})", os::errno(), n), } // Process any pending messages @@ -1149,7 +1149,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult { n if n > 0 => { ret = true; } 0 => return true, -1 if util::wouldblock() => return ret, - n => fail!("bad read {} ({})", os::last_os_error(), n), + n => panic!("bad read {} ({})", os::last_os_error(), n), } } } @@ -1172,7 +1172,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult { } { 1 => {} -1 if util::wouldblock() => {} // see above comments - n => fail!("bad error on write fd: {} {}", n, os::errno()), + n => panic!("bad error on write fd: {} {}", n, os::errno()), } } } @@ -1192,7 +1192,7 @@ fn waitpid_nowait(pid: pid_t) -> Option { }) { n if n == pid => Some(translate_status(status)), 0 => None, - n => fail!("unknown waitpid error `{}`: {}", n, + n => panic!("unknown waitpid error `{}`: {}", n, super::last_error().code), } } diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs index 6f57a5e88ba14..38895f2a8f96a 100644 --- a/src/libnative/io/timer_unix.rs +++ b/src/libnative/io/timer_unix.rs @@ -194,7 +194,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { } -1 if os::errno() == libc::EINTR as int => {} - n => fail!("helper thread failed in select() with error: {} ({})", + n => panic!("helper thread panicked in select() with error: {} ({})", n, os::last_os_error()) } } @@ -227,7 +227,7 @@ impl Timer { }; while unsafe { libc::nanosleep(&to_sleep, &mut to_sleep) } != 0 { if os::errno() as int != libc::EINTR as int { - fail!("failed to sleep, but not because of EINTR?"); + panic!("failed to sleep, but not because of EINTR?"); } } } diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index c99143f0a5d7b..4da088cccb334 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -142,7 +142,7 @@ pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int { exit_code = Some(run(main.take().unwrap())); }).destroy()); unsafe { rt::cleanup(); } - // If the exit code wasn't set, then the task block must have failed. + // If the exit code wasn't set, then the task block must have panicked. return exit_code.unwrap_or(rt::DEFAULT_ERROR_CODE); } diff --git a/src/libnative/task.rs b/src/libnative/task.rs index 455656c09d493..e702c12bdffe3 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -297,11 +297,11 @@ mod tests { } #[test] - fn smoke_fail() { + fn smoke_panic() { let (tx, rx) = channel::<()>(); spawn(proc() { let _tx = tx; - fail!() + panic!() }); assert_eq!(rx.recv_opt(), Err(())); } @@ -318,11 +318,11 @@ mod tests { } #[test] - fn smoke_opts_fail() { + fn smoke_opts_panic() { let mut opts = TaskOpts::new(); let (tx, rx) = channel(); opts.on_exit = Some(proc(r) tx.send(r)); - NativeSpawner.spawn(opts, proc() { fail!() }); + NativeSpawner.spawn(opts, proc() { panic!() }); assert!(rx.recv().is_err()); } @@ -365,7 +365,7 @@ mod tests { Some(ops) => { task.put_runtime(ops); } - None => fail!(), + None => panic!(), } Local::put(task); tx.send(()); diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index 89c8e90f2c38b..06bd04814c00b 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -129,7 +129,7 @@ impl<'a, T: Clone> WeightedChoice<'a, T> { for item in items.iter_mut() { running_total = match running_total.checked_add(&item.weight) { Some(n) => n, - None => fail!("WeightedChoice::new called with a total weight \ + None => panic!("WeightedChoice::new called with a total weight \ larger than a uint can contain") }; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index ebaa0349f5b72..405b70492a3aa 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -92,7 +92,7 @@ pub trait Rng { /// not be relied upon. /// /// This method should guarantee that `dest` is entirely filled - /// with new data, and may fail if this is impossible + /// with new data, and may panic if this is impossible /// (e.g. reading past the end of a file that is being used as the /// source of randomness). /// @@ -375,7 +375,7 @@ impl Rng for XorShiftRng { } impl SeedableRng<[u32, .. 4]> for XorShiftRng { - /// Reseed an XorShiftRng. This will fail if `seed` is entirely 0. + /// Reseed an XorShiftRng. This will panic if `seed` is entirely 0. fn reseed(&mut self, seed: [u32, .. 4]) { assert!(!seed.iter().all(|&x| x == 0), "XorShiftRng.reseed called with an all zero seed."); @@ -386,7 +386,7 @@ impl SeedableRng<[u32, .. 4]> for XorShiftRng { self.w = seed[3]; } - /// Create a new XorShiftRng. This will fail if `seed` is entirely 0. + /// Create a new XorShiftRng. This will panic if `seed` is entirely 0. fn from_seed(seed: [u32, .. 4]) -> XorShiftRng { assert!(!seed.iter().all(|&x| x == 0), "XorShiftRng::from_seed called with an all zero seed."); @@ -446,7 +446,7 @@ pub struct Closed01(pub F); #[cfg(not(test))] mod std { - pub use core::{option, fmt}; // fail!() + pub use core::{option, fmt}; // panic!() } #[cfg(test)] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 07474a9f10587..3410a8745b1f4 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -244,7 +244,7 @@ pub mod reader { Some(d) => d, None => { error!("failed to find block with tag {}", tg); - fail!(); + panic!(); } } } diff --git a/src/libregex/compile.rs b/src/libregex/compile.rs index a32dfcf5d2a2b..53d2ea62a2ad0 100644 --- a/src/libregex/compile.rs +++ b/src/libregex/compile.rs @@ -240,13 +240,13 @@ impl<'r> Compiler<'r> { /// Sets the left and right locations of a `Split` instruction at index /// `i` to `pc1` and `pc2`, respectively. /// If the instruction at index `i` isn't a `Split` instruction, then - /// `fail!` is called. + /// `panic!` is called. #[inline] fn set_split(&mut self, i: InstIdx, pc1: InstIdx, pc2: InstIdx) { let split = self.insts.get_mut(i); match *split { Split(_, _) => *split = Split(pc1, pc2), - _ => fail!("BUG: Invalid split index."), + _ => panic!("BUG: Invalid split index."), } } @@ -260,13 +260,13 @@ impl<'r> Compiler<'r> { /// Sets the location of a `Jump` instruction at index `i` to `pc`. /// If the instruction at index `i` isn't a `Jump` instruction, then - /// `fail!` is called. + /// `panic!` is called. #[inline] fn set_jump(&mut self, i: InstIdx, pc: InstIdx) { let jmp = self.insts.get_mut(i); match *jmp { Jump(_) => *jmp = Jump(pc), - _ => fail!("BUG: Invalid jump index."), + _ => panic!("BUG: Invalid jump index."), } } } diff --git a/src/libregex/lib.rs b/src/libregex/lib.rs index bb6df26dab4f5..691dd2a3a6ced 100644 --- a/src/libregex/lib.rs +++ b/src/libregex/lib.rs @@ -31,7 +31,7 @@ //! use regex::Regex; //! let re = match Regex::new(r"^\d{4}-\d{2}-\d{2}$") { //! Ok(re) => re, -//! Err(err) => fail!("{}", err), +//! Err(err) => panic!("{}", err), //! }; //! assert_eq!(re.is_match("2014-01-01"), true); //! ``` diff --git a/src/libregex/parse.rs b/src/libregex/parse.rs index 1d1d1a0e9c5ca..e62fc3602c216 100644 --- a/src/libregex/parse.rs +++ b/src/libregex/parse.rs @@ -117,7 +117,7 @@ impl BuildAst { fn flags(&self) -> Flags { match *self { Paren(flags, _, _) => flags, - _ => fail!("Cannot get flags from {}", self), + _ => panic!("Cannot get flags from {}", self), } } @@ -125,7 +125,7 @@ impl BuildAst { match *self { Paren(_, 0, _) => None, Paren(_, c, _) => Some(c), - _ => fail!("Cannot get capture group from {}", self), + _ => panic!("Cannot get capture group from {}", self), } } @@ -139,7 +139,7 @@ impl BuildAst { Some(name.clone()) } } - _ => fail!("Cannot get capture name from {}", self), + _ => panic!("Cannot get capture name from {}", self), } } @@ -153,7 +153,7 @@ impl BuildAst { fn unwrap(self) -> Result { match self { Expr(x) => Ok(x), - _ => fail!("Tried to unwrap non-AST item: {}", self), + _ => panic!("Tried to unwrap non-AST item: {}", self), } } } @@ -321,7 +321,7 @@ impl<'a> Parser<'a> { } let rep: Repeater = match c { '?' => ZeroOne, '*' => ZeroMore, '+' => OneMore, - _ => fail!("Not a valid repeater operator."), + _ => panic!("Not a valid repeater operator."), }; match self.peek(1) { @@ -393,7 +393,7 @@ impl<'a> Parser<'a> { continue } Some(ast) => - fail!("Expected Class AST but got '{}'", ast), + panic!("Expected Class AST but got '{}'", ast), // Just drop down and try to add as a regular character. None => {}, }, @@ -408,7 +408,7 @@ impl<'a> Parser<'a> { return self.err( "\\A, \\z, \\b and \\B are not valid escape \ sequences inside a character class."), - ast => fail!("Unexpected AST item '{}'", ast), + ast => panic!("Unexpected AST item '{}'", ast), } } _ => {}, diff --git a/src/libregex/re.rs b/src/libregex/re.rs index eebe9b85e3b9d..d352739f853e9 100644 --- a/src/libregex/re.rs +++ b/src/libregex/re.rs @@ -76,7 +76,7 @@ pub fn is_match(regex: &str, text: &str) -> Result { /// # use regex::Regex; /// let re = match Regex::new("[0-9]{3}-[0-9]{3}-[0-9]{4}") { /// Ok(re) => re, -/// Err(err) => fail!("{}", err), +/// Err(err) => panic!("{}", err), /// }; /// assert_eq!(re.find("phone: 111-222-3333"), Some((7, 19))); /// ``` diff --git a/src/libregex/test/bench.rs b/src/libregex/test/bench.rs index be8e12b09f020..e1c24a902fa10 100644 --- a/src/libregex/test/bench.rs +++ b/src/libregex/test/bench.rs @@ -15,7 +15,7 @@ use stdtest::Bencher; use regex::{Regex, NoExpand}; fn bench_assert_match(b: &mut Bencher, re: Regex, text: &str) { - b.iter(|| if !re.is_match(text) { fail!("no match") }); + b.iter(|| if !re.is_match(text) { panic!("no match") }); } #[bench] @@ -143,7 +143,7 @@ macro_rules! throughput( fn $name(b: &mut Bencher) { let text = gen_text($size); b.bytes = $size; - b.iter(|| if $regex.is_match(text.as_slice()) { fail!("match") }); + b.iter(|| if $regex.is_match(text.as_slice()) { panic!("match") }); } ); ) diff --git a/src/libregex/test/mod.rs b/src/libregex/test/mod.rs index 96c600b0fda3a..7f014b4eb68a6 100644 --- a/src/libregex/test/mod.rs +++ b/src/libregex/test/mod.rs @@ -30,7 +30,7 @@ macro_rules! regex( ($re:expr) => ( match ::regex::Regex::new($re) { Ok(re) => re, - Err(err) => fail!("{}", err), + Err(err) => panic!("{}", err), } ); ) diff --git a/src/libregex/test/tests.rs b/src/libregex/test/tests.rs index 088425c088855..f93a3d51251f9 100644 --- a/src/libregex/test/tests.rs +++ b/src/libregex/test/tests.rs @@ -75,7 +75,7 @@ macro_rules! noparse( let re = $re; match Regex::new(re) { Err(_) => {}, - Ok(_) => fail!("Regex '{}' should cause a parse error.", re), + Ok(_) => panic!("Regex '{}' should cause a parse error.", re), } } ); @@ -133,7 +133,7 @@ macro_rules! mat( sgot = sgot[0..sexpect.len()] } if sexpect != sgot { - fail!("For RE '{}' against '{}', expected '{}' but got '{}'", + panic!("For RE '{}' against '{}', expected '{}' but got '{}'", $re, text, sexpect, sgot); } } diff --git a/src/librustc/back/write.rs b/src/librustc/back/write.rs index 474e8e45d94c2..1a53db89196b8 100644 --- a/src/librustc/back/write.rs +++ b/src/librustc/back/write.rs @@ -85,7 +85,7 @@ struct Diagnostic { // We use an Arc instead of just returning a list of diagnostics from the // child task because we need to make sure that the messages are seen even -// if the child task fails (for example, when `fatal` is called). +// if the child task panics (for example, when `fatal` is called). #[deriving(Clone)] struct SharedEmitter { buffer: Arc>>, @@ -133,7 +133,7 @@ impl Emitter for SharedEmitter { fn custom_emit(&mut self, _cm: &codemap::CodeMap, _sp: diagnostic::RenderSpan, _msg: &str, _lvl: Level) { - fail!("SharedEmitter doesn't support custom_emit"); + panic!("SharedEmitter doesn't support custom_emit"); } } @@ -897,19 +897,19 @@ fn run_work_multithreaded(sess: &Session, futures.push(future); } - let mut failed = false; + let mut panicked = false; for future in futures.into_iter() { match future.unwrap() { Ok(()) => {}, Err(_) => { - failed = true; + panicked = true; }, } // Display any new diagnostics. diag_emitter.dump(sess.diagnostic().handler()); } - if failed { - sess.fatal("aborting due to worker thread failure"); + if panicked { + sess.fatal("aborting due to worker thread panic"); } } diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs index 1f44808275f6c..43687a31453d0 100644 --- a/src/librustc/driver/config.rs +++ b/src/librustc/driver/config.rs @@ -898,7 +898,7 @@ mod test { let matches = &match getopts(["--test".to_string()], optgroups().as_slice()) { Ok(m) => m, - Err(f) => fail!("test_switch_implies_cfg_test: {}", f) + Err(f) => panic!("test_switch_implies_cfg_test: {}", f) }; let registry = diagnostics::registry::Registry::new([]); let sessopts = build_session_options(matches); @@ -916,7 +916,7 @@ mod test { optgroups().as_slice()) { Ok(m) => m, Err(f) => { - fail!("test_switch_implies_cfg_test_unless_cfg_test: {}", f) + panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f) } }; let registry = diagnostics::registry::Registry::new([]); diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs index 4a2e209f56282..fbdc0db166524 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc/driver/mod.rs @@ -269,7 +269,7 @@ Available lint options: println!("Compiler plugins can provide additional lints and lint groups. To see a \ listing of these, re-run `rustc -W help` with a crate filename."); } - (false, _, _) => fail!("didn't load lint plugins but got them anyway!"), + (false, _, _) => panic!("didn't load lint plugins but got them anyway!"), (true, 0, 0) => println!("This crate does not load any lint plugins or lint groups."), (true, l, g) => { if l > 0 { @@ -424,7 +424,7 @@ fn parse_crate_attrs(sess: &Session, input: &Input) -> pub fn early_error(msg: &str) -> ! { let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None); emitter.emit(None, msg, None, diagnostic::Fatal); - fail!(diagnostic::FatalError); + panic!(diagnostic::FatalError); } pub fn early_warn(msg: &str) { @@ -466,7 +466,7 @@ pub fn monitor(f: proc():Send) { match task.try(f) { Ok(()) => { /* fallthrough */ } Err(value) => { - // Task failed without emitting a fatal diagnostic + // Task panicked without emitting a fatal diagnostic if !value.is::() { let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None); @@ -475,13 +475,13 @@ pub fn monitor(f: proc():Send) { if !value.is::() { emitter.emit( None, - "unexpected failure", + "unexpected panic", None, diagnostic::Bug); } let xs = [ - "the compiler hit an unexpected failure path. this is a bug.".to_string(), + "the compiler unexpectedly panicked. this is a bug.".to_string(), format!("we would appreciate a bug report: {}", BUG_REPORT_URL), "run with `RUST_BACKTRACE=1` for a backtrace".to_string(), @@ -503,11 +503,11 @@ pub fn monitor(f: proc():Send) { } } - // Fail so the process returns a failure code, but don't pollute the + // Panic so the process returns a failure code, but don't pollute the // output with some unnecessary failure messages, we've already // printed everything that we needed to. io::stdio::set_stderr(box io::util::NullWriter); - fail!(); + panic!(); } } } diff --git a/src/librustc/driver/pretty.rs b/src/librustc/driver/pretty.rs index 19cd03f10a781..0a7cfdeeadc2a 100644 --- a/src/librustc/driver/pretty.rs +++ b/src/librustc/driver/pretty.rs @@ -444,7 +444,7 @@ pub fn pretty_print_input(sess: Session, let r = io::File::create(&p); match r { Ok(w) => box w as Box, - Err(e) => fail!("print-print failed to open {} due to {}", + Err(e) => panic!("print-print failed to open {} due to {}", p.display(), e), } } diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 99ca5770a8a2f..35754fc584ffd 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -190,7 +190,7 @@ impl LintPass for TypeLimits { return; } } - _ => fail!() + _ => panic!() }; }, ty::ty_uint(t) => { @@ -201,7 +201,7 @@ impl LintPass for TypeLimits { let lit_val: u64 = match lit.node { ast::LitByte(_v) => return, // _v is u8, within range by definition ast::LitInt(v, _) => v, - _ => fail!() + _ => panic!() }; if lit_val < min || lit_val > max { cx.span_lint(OVERFLOWING_LITERALS, e.span, @@ -216,7 +216,7 @@ impl LintPass for TypeLimits { Some(f) => f, None => return }, - _ => fail!() + _ => panic!() }; if lit_val < min || lit_val > max { cx.span_lint(OVERFLOWING_LITERALS, e.span, @@ -237,7 +237,7 @@ impl LintPass for TypeLimits { ast::BiGt => v >= min && v < max, ast::BiGe => v > min && v <= max, ast::BiEq | ast::BiNe => v >= min && v <= max, - _ => fail!() + _ => panic!() } } @@ -301,7 +301,7 @@ impl LintPass for TypeLimits { ast::LitInt(v, ast::UnsuffixedIntLit(ast::Minus)) => -(v as i64), _ => return true }, - _ => fail!() + _ => panic!() }; is_valid(norm_binop, lit_val, min, max) } @@ -312,7 +312,7 @@ impl LintPass for TypeLimits { ast::LitInt(v, _) => v, _ => return true }, - _ => fail!() + _ => panic!() }; is_valid(norm_binop, lit_val, min, max) } @@ -353,7 +353,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { def::DefTy(..) => { let tty = match self.cx.tcx.ast_ty_to_ty_cache.borrow().find(&ty_id) { Some(&ty::atttce_resolved(t)) => t, - _ => fail!("ast_ty_to_ty_cache was incomplete after typeck!") + _ => panic!("ast_ty_to_ty_cache was incomplete after typeck!") }; if !ty::is_ffi_safe(self.cx.tcx, tty) { diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 4cdca9e536595..8e4095df45a8f 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -166,7 +166,7 @@ impl LintStore { fn register_renamed(&mut self, old_name: &str, new_name: &str) { let target = match self.by_name.find_equiv(&new_name) { Some(&Id(lint_id)) => lint_id.clone(), - _ => fail!("invalid lint renaming of {} to {}", old_name, new_name) + _ => panic!("invalid lint renaming of {} to {}", old_name, new_name) }; self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target)); } @@ -388,7 +388,7 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint, format!("{} [-{} {}]", msg, match level { Warn => 'W', Deny => 'D', Forbid => 'F', - Allow => fail!() + Allow => panic!() }, name.replace("_", "-")) }, Node(src) => { diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index e2d997a93fe04..43d0156d72770 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -174,7 +174,7 @@ fn extract_crate_info(e: &Env, i: &ast::ViewItem) -> Option { pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option) { let err = |s: &str| { match (sp, sess) { - (_, None) => fail!("{}", s), + (_, None) => panic!("{}", s), (Some(sp), Some(sess)) => sess.span_err(sp, s), (None, Some(sess)) => sess.err(s), } diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index fd71e4f7b1fba..e9e7d1de59db3 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -94,7 +94,7 @@ pub fn maybe_find_item<'a>(item_id: ast::NodeId, fn find_item<'a>(item_id: ast::NodeId, items: rbml::Doc<'a>) -> rbml::Doc<'a> { match maybe_find_item(item_id, items) { - None => fail!("lookup_item: id not found: {}", item_id), + None => panic!("lookup_item: id not found: {}", item_id), Some(d) => d } } @@ -153,7 +153,7 @@ fn item_family(item: rbml::Doc) -> Family { 'S' => Struct, 'g' => PublicField, 'N' => InheritedField, - c => fail!("unexpected family char: {}", c) + c => panic!("unexpected family char: {}", c) } } @@ -164,7 +164,7 @@ fn item_visibility(item: rbml::Doc) -> ast::Visibility { match reader::doc_as_u8(visibility_doc) as char { 'y' => ast::Public, 'i' => ast::Inherited, - _ => fail!("unknown visibility character") + _ => panic!("unknown visibility character") } } } @@ -707,7 +707,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory { match ch as char { 'i' => ast::MutImmutable, 'm' => ast::MutMutable, - _ => fail!("unknown mutability character: `{}`", ch as char), + _ => panic!("unknown mutability character: `{}`", ch as char), } } @@ -725,7 +725,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory { ty::ReEmpty, get_mutability(string.as_bytes()[1])) } - _ => fail!("unknown self type code: `{}`", explicit_self_kind as char) + _ => panic!("unknown self type code: `{}`", explicit_self_kind as char) } } @@ -739,7 +739,7 @@ pub fn get_impl_items(cdata: Cmd, impl_id: ast::NodeId) match item_sort(doc) { 'r' | 'p' => impl_items.push(ty::MethodTraitItemId(def_id)), 't' => impl_items.push(ty::TypeTraitItemId(def_id)), - _ => fail!("unknown impl item sort"), + _ => panic!("unknown impl item sort"), } true }); @@ -760,7 +760,7 @@ pub fn get_trait_item_name_and_kind(intr: Rc, } 't' => (name, TypeTraitItemKind), c => { - fail!("get_trait_item_name_and_kind(): unknown trait item kind \ + panic!("get_trait_item_name_and_kind(): unknown trait item kind \ in metadata: `{}`", c) } } @@ -811,7 +811,7 @@ pub fn get_impl_or_trait_item(intr: Rc, container: container, })) } - _ => fail!("unknown impl/trait item sort"), + _ => panic!("unknown impl/trait item sort"), } } @@ -825,7 +825,7 @@ pub fn get_trait_item_def_ids(cdata: Cmd, id: ast::NodeId) match item_sort(mth) { 'r' | 'p' => result.push(ty::MethodTraitItemId(def_id)), 't' => result.push(ty::TypeTraitItemId(def_id)), - _ => fail!("unknown trait item sort"), + _ => panic!("unknown trait item sort"), } true }); @@ -937,7 +937,7 @@ pub fn get_static_methods_if_impl(intr: Rc, match item_family(impl_method_doc) { StaticMethod => fn_style = ast::NormalFn, UnsafeStaticMethod => fn_style = ast::UnsafeFn, - _ => fail!() + _ => panic!() } static_impl_methods.push(StaticMethodInfo { @@ -998,7 +998,7 @@ fn struct_field_family_to_visibility(family: Family) -> ast::Visibility { match family { PublicField => ast::Public, InheritedField => ast::Inherited, - _ => fail!() + _ => panic!() } } @@ -1207,7 +1207,7 @@ pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId { node: did.node, } } - None => fail!("didn't find a crate in the cnum_map") + None => panic!("didn't find a crate in the cnum_map") } } @@ -1314,7 +1314,7 @@ pub fn get_dylib_dependency_formats(cdata: Cmd) let cnum = from_str(cnum).unwrap(); let cnum = match cdata.cnum_map.find(&cnum) { Some(&n) => n, - None => fail!("didn't find a crate in the cnum_map") + None => panic!("didn't find a crate in the cnum_map") }; result.push((cnum, if link == "d" { cstore::RequireDynamic diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 34aa9310ef236..98ce6942d4818 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -187,13 +187,13 @@ pub fn get_or_default_sysroot() -> Path { path.and_then(|path| match myfs::realpath(&path) { Ok(canon) => Some(canon), - Err(e) => fail!("failed to get realpath: {}", e), + Err(e) => panic!("failed to get realpath: {}", e), }) } match canonicalize(os::self_exe_name()) { Some(mut p) => { p.pop(); p.pop(); p } - None => fail!("can't determine value for sysroot") + None => panic!("can't determine value for sysroot") } } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 60fb490e270b3..a52d02ccca773 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -260,7 +260,7 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> subst::RegionSubsts { parse_vec_per_param_space( st, |st| parse_region(st, |x,y| conv(x,y)))) } - _ => fail!("parse_bound_region: bad input") + _ => panic!("parse_bound_region: bad input") } } @@ -282,7 +282,7 @@ fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion { ty::BrFresh(id) } 'e' => ty::BrEnv, - _ => fail!("parse_bound_region: bad input") + _ => panic!("parse_bound_region: bad input") } } @@ -327,7 +327,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region { 'e' => { ty::ReStatic } - _ => fail!("parse_region: bad input") + _ => panic!("parse_region: bad input") } } @@ -335,7 +335,7 @@ fn parse_opt(st: &mut PState, f: |&mut PState| -> T) -> Option { match next(st) { 'n' => None, 's' => Some(f(st)), - _ => fail!("parse_opt: bad input") + _ => panic!("parse_opt: bad input") } } @@ -374,7 +374,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { 'D' => return ty::mk_mach_int(ast::TyI64), 'f' => return ty::mk_mach_float(ast::TyF32), 'F' => return ty::mk_mach_float(ast::TyF64), - _ => fail!("parse_ty: bad numeric type") + _ => panic!("parse_ty: bad numeric type") } } 'c' => return ty::mk_char(), @@ -474,7 +474,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { 'e' => { return ty::mk_err(); } - c => { fail!("unexpected char in type string: {}", c);} + c => { panic!("unexpected char in type string: {}", c);} } } @@ -527,7 +527,7 @@ fn parse_fn_style(c: char) -> FnStyle { match c { 'u' => UnsafeFn, 'n' => NormalFn, - _ => fail!("parse_fn_style: bad fn_style {}", c) + _ => panic!("parse_fn_style: bad fn_style {}", c) } } @@ -543,7 +543,7 @@ fn parse_onceness(c: char) -> ast::Onceness { match c { 'o' => ast::Once, 'm' => ast::Many, - _ => fail!("parse_onceness: bad onceness") + _ => panic!("parse_onceness: bad onceness") } } @@ -587,7 +587,7 @@ fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig { let variadic = match next(st) { 'V' => true, 'N' => false, - r => fail!(format!("bad variadic: {}", r)), + r => panic!(format!("bad variadic: {}", r)), }; let output = match peek(st) { 'z' => { @@ -609,7 +609,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId { while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } if colon_idx == len { error!("didn't find ':' when parsing def id"); - fail!(); + panic!(); } let crate_part = buf[0u..colon_idx]; @@ -617,12 +617,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId { let crate_num = match uint::parse_bytes(crate_part, 10u) { Some(cn) => cn as ast::CrateNum, - None => fail!("internal error: parse_def_id: crate number expected, found {}", + None => panic!("internal error: parse_def_id: crate number expected, found {}", crate_part) }; let def_num = match uint::parse_bytes(def_part, 10u) { Some(dn) => dn as ast::NodeId, - None => fail!("internal error: parse_def_id: id expected, found {}", + None => panic!("internal error: parse_def_id: id expected, found {}", def_part) }; ast::DefId { krate: crate_num, node: def_num } @@ -688,7 +688,7 @@ fn parse_builtin_bounds(st: &mut PState, _conv: conv_did) -> ty::BuiltinBounds { return builtin_bounds; } c => { - fail!("parse_bounds: bad builtin bounds ('{}')", c) + panic!("parse_bounds: bad builtin bounds ('{}')", c) } } } @@ -714,7 +714,7 @@ fn parse_bounds(st: &mut PState, conv: conv_did) -> ty::ParamBounds { return param_bounds; } c => { - fail!("parse_bounds: bad bounds ('{}')", c) + panic!("parse_bounds: bad bounds ('{}')", c) } } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index aa88de7565523..f6d85a8eb018f 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -341,7 +341,7 @@ impl Folder for NestedItemsDropper { ast::DeclItem(_) => false, } } - ast::StmtMac(..) => fail!("unexpanded macro in astencode") + ast::StmtMac(..) => panic!("unexpanded macro in astencode") }; if use_stmt { Some(stmt) @@ -795,7 +795,7 @@ impl<'a> vtable_decoder_helpers for reader::Decoder<'a> { 3 => { typeck::vtable_error } - _ => fail!("bad enum variant") + _ => panic!("bad enum variant") }) }) }).unwrap() @@ -1488,7 +1488,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { }).unwrap() } - _ => fail!("..") + _ => panic!("..") }) }) }).unwrap() @@ -1618,7 +1618,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { ty::AdjustDerefRef(auto_deref_ref) } - _ => fail!("bad enum variant for ty::AutoAdjustment") + _ => panic!("bad enum variant for ty::AutoAdjustment") }) }) }).unwrap() @@ -1695,7 +1695,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { ty::AutoUnsafe(m, a) } - _ => fail!("bad enum variant for ty::AutoRef") + _ => panic!("bad enum variant for ty::AutoRef") }) }) }).unwrap() @@ -1736,7 +1736,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { substs: substs }; ty::UnsizeVtable(ty_trait, self_ty) } - _ => fail!("bad enum variant for ty::UnsizeKind") + _ => panic!("bad enum variant for ty::UnsizeKind") }) }) }).unwrap() @@ -1762,7 +1762,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { 0 => ty::FnUnboxedClosureKind, 1 => ty::FnMutUnboxedClosureKind, 2 => ty::FnOnceUnboxedClosureKind, - _ => fail!("bad enum variant for ty::UnboxedClosureKind"), + _ => panic!("bad enum variant for ty::UnboxedClosureKind"), }) }).unwrap(); ty::UnboxedClosure { @@ -2032,6 +2032,6 @@ fn test_simplification() { assert!(pprust::item_to_string(&*item_out) == pprust::item_to_string(&*item_exp)); } - _ => fail!() + _ => panic!() } } diff --git a/src/librustc/middle/borrowck/gather_loans/move_error.rs b/src/librustc/middle/borrowck/gather_loans/move_error.rs index 887c6bc3e3fdf..9d4d9fcf9a9d7 100644 --- a/src/librustc/middle/borrowck/gather_loans/move_error.rs +++ b/src/librustc/middle/borrowck/gather_loans/move_error.rs @@ -133,10 +133,10 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) { which defines the `Drop` trait", b.ty.user_string(bccx.tcx)).as_slice()); }, - _ => fail!("this path should not cause illegal move") + _ => panic!("this path should not cause illegal move") } } - _ => fail!("this path should not cause illegal move") + _ => panic!("this path should not cause illegal move") } } diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index b09e9105f3f6b..ae8e975e843b0 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -284,9 +284,9 @@ pub fn closure_to_block(closure_id: ast::NodeId, ast::ExprProc(_, ref block) | ast::ExprFnBlock(_, _, ref block) | ast::ExprUnboxedFn(_, _, _, ref block) => { block.id } - _ => fail!("encountered non-closure id: {}", closure_id) + _ => panic!("encountered non-closure id: {}", closure_id) }, - _ => fail!("encountered non-expr id: {}", closure_id) + _ => panic!("encountered non-expr id: {}", closure_id) } } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index d5557dfeeff1a..612c9a00bbef4 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -88,7 +88,7 @@ struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O: 'a> { fn to_cfgidx_or_die(id: ast::NodeId, index: &NodeMap) -> CFGIndex { let opt_cfgindex = index.find(&id).map(|&i|i); opt_cfgindex.unwrap_or_else(|| { - fail!("nodeid_to_index does not have entry for NodeId {}", id); + panic!("nodeid_to_index does not have entry for NodeId {}", id); }) } diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index 3facf0b0c0a49..f88269ccac947 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/middle/def.rs @@ -74,7 +74,7 @@ impl Def { local_def(id) } - DefPrimTy(_) => fail!() + DefPrimTy(_) => panic!() } } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index f2d1a5e1d9272..08202897558fb 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -264,18 +264,18 @@ lets_do_this! { StrEqFnLangItem, "str_eq", str_eq_fn; - // A number of failure-related lang items. The `fail` item corresponds to - // divide-by-zero and various failure cases with `match`. The - // `fail_bounds_check` item is for indexing arrays. + // A number of panic-related lang items. The `panic` item corresponds to + // divide-by-zero and various panic cases with `match`. The + // `panic_bounds_check` item is for indexing arrays. // // The `begin_unwind` lang item has a predefined symbol name and is sort of // a "weak lang item" in the sense that a crate is not required to have it // defined to use it, but a final product is required to define it // somewhere. Additionally, there are restrictions on crates that use a weak // lang item, but do not have it defined. - FailFnLangItem, "fail", fail_fn; - FailBoundsCheckFnLangItem, "fail_bounds_check", fail_bounds_check_fn; - FailFmtLangItem, "fail_fmt", fail_fmt; + PanicFnLangItem, "panic", panic_fn; + PanicBoundsCheckFnLangItem, "panic_bounds_check", panic_bounds_check_fn; + PanicFmtLangItem, "panic_fmt", panic_fmt; ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn; ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn; diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 4e2ee03877c1e..f9810120d211b 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -93,7 +93,7 @@ * These are described in the `specials` struct: * * - `exit_ln`: a live node that is generated to represent every 'exit' from - * the function, whether it be by explicit return, fail, or other means. + * the function, whether it be by explicit return, panic, or other means. * * - `fallthrough_ln`: a live node that represents a fallthrough * @@ -400,7 +400,7 @@ fn visit_fn(ir: &mut IrMaps, visit::walk_fn(&mut fn_maps, fk, decl, body, sp); // Special nodes and variables: - // - exit_ln represents the end of the fn, either by return or fail + // - exit_ln represents the end of the fn, either by return or panic // - implicit_ret_var is a pseudo-variable that represents // an implicit return let specials = Specials { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index ad297309c0880..32e373f5851c0 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -157,7 +157,7 @@ impl RegionMaps { //! Returns the narrowest scope that encloses `id`, if any. match self.scope_map.borrow().find(&id) { Some(&r) => r, - None => { fail!("no enclosing scope for id {}", id); } + None => { panic!("no enclosing scope for id {}", id); } } } @@ -167,7 +167,7 @@ impl RegionMaps { */ match self.var_map.borrow().find(&var_id) { Some(&r) => r, - None => { fail!("no enclosing scope for id {}", var_id); } + None => { panic!("no enclosing scope for id {}", var_id); } } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index fad4ef4f15f6b..7af4739d40915 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -728,7 +728,7 @@ impl NameBindings { fn get_module(&self) -> Rc { match self.get_module_if_available() { None => { - fail!("get_module called on a node with no module \ + panic!("get_module called on a node with no module \ definition!") } Some(module_def) => module_def @@ -1910,7 +1910,7 @@ impl<'a> Resolver<'a> { DefLocal(..) | DefPrimTy(..) | DefTyParam(..) | DefUse(..) | DefUpvar(..) | DefRegion(..) | DefTyParamBinder(..) | DefLabel(..) | DefSelfTy(..) => { - fail!("didn't expect `{}`", def); + panic!("didn't expect `{}`", def); } } } @@ -2618,7 +2618,7 @@ impl<'a> Resolver<'a> { } UnboundResult => { /* Continue. */ } UnknownResult => { - fail!("value result should be known at this point"); + panic!("value result should be known at this point"); } } match type_result { @@ -2641,7 +2641,7 @@ impl<'a> Resolver<'a> { } UnboundResult => { /* Continue. */ } UnknownResult => { - fail!("type result should be known at this point"); + panic!("type result should be known at this point"); } } @@ -5161,7 +5161,7 @@ impl<'a> Resolver<'a> { target.bindings.value_def.borrow()); match *target.bindings.value_def.borrow() { None => { - fail!("resolved name in the value namespace to a \ + panic!("resolved name in the value namespace to a \ set of name bindings with no def?!"); } Some(def) => { @@ -5191,7 +5191,7 @@ impl<'a> Resolver<'a> { } Indeterminate => { - fail!("unexpected indeterminate result"); + panic!("unexpected indeterminate result"); } Failed(err) => { match err { @@ -5389,7 +5389,7 @@ impl<'a> Resolver<'a> { msg.as_slice())); return None; } - Indeterminate => fail!("indeterminate unexpected"), + Indeterminate => panic!("indeterminate unexpected"), Success((resulting_module, resulting_last_private)) => { containing_module = resulting_module; last_private = resulting_last_private; @@ -5451,7 +5451,7 @@ impl<'a> Resolver<'a> { } Indeterminate => { - fail!("indeterminate unexpected"); + panic!("indeterminate unexpected"); } Success((resulting_module, resulting_last_private)) => { @@ -5537,7 +5537,7 @@ impl<'a> Resolver<'a> { } } Indeterminate => { - fail!("unexpected indeterminate result"); + panic!("unexpected indeterminate result"); } Failed(err) => { match err { @@ -6155,7 +6155,7 @@ impl<'a> Resolver<'a> { type_used: _ }) => (v, t), Some(_) => { - fail!("we should only have LastImport for `use` directives") + panic!("we should only have LastImport for `use` directives") } _ => return, }; diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 237f4e950ceee..b986d4dd591f3 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -177,7 +177,7 @@ impl Substs { */ match self.regions { - ErasedRegions => fail!("Erased regions only expected in trans"), + ErasedRegions => panic!("Erased regions only expected in trans"), NonerasedRegions(ref r) => r } } @@ -190,7 +190,7 @@ impl Substs { */ match self.regions { - ErasedRegions => fail!("Erased regions only expected in trans"), + ErasedRegions => panic!("Erased regions only expected in trans"), NonerasedRegions(ref mut r) => r } } @@ -249,7 +249,7 @@ impl ParamSpace { 0 => TypeSpace, 1 => SelfSpace, 2 => FnSpace, - _ => fail!("Invalid ParamSpace: {}", u) + _ => panic!("Invalid ParamSpace: {}", u) } } } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 2379a5e7f53a2..f53b5331eddeb 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -235,7 +235,7 @@ impl<'a> ConstantExpr<'a> { let ConstantExpr(other_expr) = other; match const_eval::compare_lit_exprs(tcx, expr, other_expr) { Some(val1) => val1 == 0, - None => fail!("compare_list_exprs: type mismatch"), + None => panic!("compare_list_exprs: type mismatch"), } } } @@ -734,7 +734,7 @@ impl FailureHandler { fn handle_fail(&self, bcx: Block) { match *self { Infallible => - fail!("attempted to fail in an infallible failure handler!"), + panic!("attempted to panic in a non-panicking panic handler!"), JumpToBasicBlock(basic_block) => Br(bcx, basic_block), Unreachable => diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 2525da8863f55..1f737cae86f92 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -586,7 +586,7 @@ fn generic_type_of(cx: &CrateContext, Type::array(&Type::i64(cx), align_units), a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4), align_units), - _ => fail!("unsupported enum alignment: {}", align) + _ => panic!("unsupported enum alignment: {}", align) }; assert_eq!(machine::llalign_of_min(cx, pad_ty), align); assert_eq!(align_s % discr_size, 0); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 16ff2f901f6d5..ae8f944cab100 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -291,7 +291,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef { RustCall, Some(llenvironment_type)) } - _ => fail!("expected closure or fn") + _ => panic!("expected closure or fn") }; let llfty = type_of_rust_fn(ccx, env, inputs.as_slice(), output, abi); @@ -2349,7 +2349,7 @@ fn register_fn(ccx: &CrateContext, ty::ty_bare_fn(ref f) => { assert!(f.abi == Rust || f.abi == RustCall); } - _ => fail!("expected bare rust fn") + _ => panic!("expected bare rust fn") }; let llfn = decl_rust_fn(ccx, node_type, sym.as_slice()); @@ -2744,7 +2744,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { llfn } - _ => fail!("get_item_val: weird result in table") + _ => panic!("get_item_val: weird result in table") }; match attr::first_attr_value_str_by_name(i.attrs.as_slice(), @@ -2811,7 +2811,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { let args = match v.node.kind { ast::TupleVariantKind(ref args) => args, ast::StructVariantKind(_) => { - fail!("struct variant kind unexpected in get_item_val") + panic!("struct variant kind unexpected in get_item_val") } }; assert!(args.len() != 0u); @@ -2827,7 +2827,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { ast::ItemEnum(_, _) => { register_fn(ccx, (*v).span, sym, id, ty) } - _ => fail!("NodeVariant, shouldn't happen") + _ => panic!("NodeVariant, shouldn't happen") }; set_inline_hint(llfn); llfn diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 025b5f368ecae..895f03ec2c79d 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -30,7 +30,7 @@ pub fn terminate(cx: Block, _: &str) { pub fn check_not_terminated(cx: Block) { if cx.terminated.get() { - fail!("already terminated!"); + panic!("already terminated!"); } } @@ -45,7 +45,7 @@ pub fn B<'blk, 'tcx>(cx: Block<'blk, 'tcx>) -> Builder<'blk, 'tcx> { // terminated, we're saying that trying to add any further statements in the // block is an error. On the other hand, if something is unreachable, that // means that the block was terminated in some way that we don't want to check -// for (fail/break/return statements, call to diverging functions, etc), and +// for (panic/break/return statements, call to diverging functions, etc), and // further instructions to the block should simply be ignored. pub fn RetVoid(cx: Block) { diff --git a/src/librustc/middle/trans/cabi_arm.rs b/src/librustc/middle/trans/cabi_arm.rs index ccfc79ac0c500..d8cf8dbb7959f 100644 --- a/src/librustc/middle/trans/cabi_arm.rs +++ b/src/librustc/middle/trans/cabi_arm.rs @@ -50,7 +50,7 @@ fn ty_align(ty: Type) -> uint { let elt = ty.element_type(); ty_align(elt) } - _ => fail!("ty_align: unhandled type") + _ => panic!("ty_align: unhandled type") } } @@ -80,7 +80,7 @@ fn ty_size(ty: Type) -> uint { let eltsz = ty_size(elt); len * eltsz } - _ => fail!("ty_size: unhandled type") + _ => panic!("ty_size: unhandled type") } } diff --git a/src/librustc/middle/trans/cabi_mips.rs b/src/librustc/middle/trans/cabi_mips.rs index 90bd1521705f0..9f51e153a0fc9 100644 --- a/src/librustc/middle/trans/cabi_mips.rs +++ b/src/librustc/middle/trans/cabi_mips.rs @@ -50,7 +50,7 @@ fn ty_align(ty: Type) -> uint { let elt = ty.element_type(); ty_align(elt) } - _ => fail!("ty_size: unhandled type") + _ => panic!("ty_size: unhandled type") } } @@ -80,7 +80,7 @@ fn ty_size(ty: Type) -> uint { let eltsz = ty_size(elt); len * eltsz } - _ => fail!("ty_size: unhandled type") + _ => panic!("ty_size: unhandled type") } } diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 1b8a354259ad7..54fd20ff995b5 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -111,7 +111,7 @@ fn classify_ty(ty: Type) -> Vec { let elt = ty.element_type(); ty_align(elt) } - _ => fail!("ty_size: unhandled type") + _ => panic!("ty_size: unhandled type") } } @@ -140,7 +140,7 @@ fn classify_ty(ty: Type) -> Vec { let eltsz = ty_size(elt); len * eltsz } - _ => fail!("ty_size: unhandled type") + _ => panic!("ty_size: unhandled type") } } @@ -235,7 +235,7 @@ fn classify_ty(ty: Type) -> Vec { i += 1u; } } - _ => fail!("classify: unhandled type") + _ => panic!("classify: unhandled type") } } @@ -328,7 +328,7 @@ fn llreg_ty(ccx: &CrateContext, cls: &[RegClass]) -> Type { SSEDs => { tys.push(Type::f64(ccx)); } - _ => fail!("llregtype: unhandled class") + _ => panic!("llregtype: unhandled class") } i += 1u; } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 54f41b79b0130..1f4a0dadc0209 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -689,9 +689,9 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Introduce a temporary cleanup scope that will contain cleanups // for the arguments while they are being evaluated. The purpose - // this cleanup is to ensure that, should a failure occur while + // this cleanup is to ensure that, should a panic occur while // evaluating argument N, the values for arguments 0...N-1 are all - // cleaned up. If no failure occurs, the values are handed off to + // cleaned up. If no panic occurs, the values are handed off to // the callee, and hence none of the cleanups in this temporary // scope will ever execute. let fcx = bcx.fcx; @@ -704,7 +704,7 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let (abi, ret_ty) = match ty::get(callee_ty).sty { ty::ty_bare_fn(ref f) => (f.abi, f.sig.output), ty::ty_closure(ref f) => (f.abi, f.sig.output), - _ => fail!("expected bare rust fn or closure in trans_call_inner") + _ => panic!("expected bare rust fn or closure in trans_call_inner") }; let (llfn, llenv, llself) = match callee.data { @@ -847,7 +847,7 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let mut llargs = Vec::new(); let arg_tys = match args { ArgExprs(a) => a.iter().map(|x| expr_ty(bcx, &**x)).collect(), - _ => fail!("expected arg exprs.") + _ => panic!("expected arg exprs.") }; bcx = trans_args(bcx, args, @@ -1141,7 +1141,7 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx, arg_datum.to_appropriate_datum(bcx)); // Technically, ownership of val passes to the callee. - // However, we must cleanup should we fail before the + // However, we must cleanup should we panic before the // callee is actually invoked. val = arg_datum.add_clean(bcx.fcx, arg_cleanup_scope); } diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 827df48071af9..e5825d7a38f15 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -477,7 +477,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { fn needs_invoke(&self) -> bool { /*! * Returns true if there are pending cleanups that should - * execute on failure. + * execute on panic. */ self.scopes.borrow().iter().rev().any(|s| s.needs_invoke()) @@ -485,8 +485,8 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { fn get_landing_pad(&'blk self) -> BasicBlockRef { /*! - * Returns a basic block to branch to in the event of a failure. - * This block will run the failure cleanups and eventually + * Returns a basic block to branch to in the event of a panic. + * This block will run the panic cleanups and eventually * invoke the LLVM `Resume` instruction. */ @@ -497,7 +497,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { let orig_scopes_len = self.scopes_len(); assert!(orig_scopes_len > 0); - // Remove any scopes that do not have cleanups on failure: + // Remove any scopes that do not have cleanups on panic: let mut popped_scopes = vec!(); while !self.top_scope(|s| s.needs_invoke()) { debug!("top scope does not need invoke"); diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 5d386b0a706b5..60b107c049f41 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -603,7 +603,7 @@ pub fn C_int(ccx: &CrateContext, i: I) -> ValueRef { match machine::llbitsize_of_real(ccx, ccx.int_type()) { 32 => assert!(v < (1<<31) && v >= -(1<<31)), 64 => {}, - n => fail!("unsupported target size: {}", n) + n => panic!("unsupported target size: {}", n) } C_integral(ccx.int_type(), v as u64, true) @@ -615,7 +615,7 @@ pub fn C_uint(ccx: &CrateContext, i: I) -> ValueRef { match machine::llbitsize_of_real(ccx, ccx.int_type()) { 32 => assert!(v < (1<<32)), 64 => {}, - n => fail!("unsupported target size: {}", n) + n => panic!("unsupported target size: {}", n) } C_integral(ccx.int_type(), v, false) diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 64ad88630f460..955fcbfab842f 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -453,7 +453,7 @@ impl LocalCrateContext { /// Create a dummy `CrateContext` from `self` and the provided /// `SharedCrateContext`. This is somewhat dangerous because `self` may /// not actually be an element of `shared.local_ccxs`, which can cause some - /// operations to `fail` unexpectedly. + /// operations to panic unexpectedly. /// /// This is used in the `LocalCrateContext` constructor to allow calling /// functions that expect a complete `CrateContext`, even before the local @@ -527,7 +527,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { } match declare_intrinsic(self, key) { Some(v) => return v, - None => fail!() + None => panic!() } } diff --git a/src/librustc/middle/trans/doc.rs b/src/librustc/middle/trans/doc.rs index d6df0d88a769f..013483d0003c3 100644 --- a/src/librustc/middle/trans/doc.rs +++ b/src/librustc/middle/trans/doc.rs @@ -132,7 +132,7 @@ cleanup arranged, and the slot from `rvalue_scratch_datum` does not. ## The Cleanup module The cleanup module tracks what values need to be cleaned up as scopes -are exited, either via failure or just normal control flow. The basic +are exited, either via panic or just normal control flow. The basic idea is that the function context maintains a stack of cleanup scopes that are pushed/popped as we traverse the AST tree. There is typically at least one cleanup scope per AST node; some AST nodes may introduce @@ -142,9 +142,9 @@ Cleanup items can be scheduled into any of the scopes on the stack. Typically, when a scope is popped, we will also generate the code for each of its cleanups at that time. This corresponds to a normal exit from a block (for example, an expression completing evaluation -successfully without failure). However, it is also possible to pop a +successfully without panic). However, it is also possible to pop a block *without* executing its cleanups; this is typically used to -guard intermediate values that must be cleaned up on failure, but not +guard intermediate values that must be cleaned up on panic, but not if everything goes right. See the section on custom scopes below for more details. @@ -170,7 +170,7 @@ drop uninitialized memory. If the initialization itself produces byproducts that need to be freed, then you should use temporary custom scopes to ensure that those byproducts will get freed on unwind. For example, an expression like `box foo()` will first allocate a box in the -heap and then call `foo()` -- if `foo()` should fail, this box needs +heap and then call `foo()` -- if `foo()` should panic, this box needs to be *shallowly* freed. ### Long-distance jumps @@ -178,13 +178,13 @@ to be *shallowly* freed. In addition to popping a scope, which corresponds to normal control flow exiting the scope, we may also *jump out* of a scope into some earlier scope on the stack. This can occur in response to a `return`, -`break`, or `continue` statement, but also in response to failure. In +`break`, or `continue` statement, but also in response to panic. In any of these cases, we will generate a series of cleanup blocks for each of the scopes that is exited. So, if the stack contains scopes A ... Z, and we break out of a loop whose corresponding cleanup scope is X, we would generate cleanup blocks for the cleanups in X, Y, and Z. After cleanup is done we would branch to the exit point for scope X. -But if failure should occur, we would generate cleanups for all the +But if panic should occur, we would generate cleanups for all the scopes from A to Z and then resume the unwind process afterwards. To avoid generating tons of code, we cache the cleanup blocks that we @@ -211,7 +211,7 @@ the basic blocks where control should flow after a "continue" or Custom cleanup scopes are used for a variety of purposes. The most common though is to handle temporary byproducts, where cleanup only -needs to occur on failure. The general strategy is to push a custom +needs to occur on panic. The general strategy is to push a custom cleanup scope, schedule *shallow* cleanups into the custom scope, and then pop the custom scope (without transing the cleanups) when execution succeeds normally. This way the cleanups are only trans'd on @@ -229,7 +229,7 @@ We would basically: 5. Pop the scope C. 6. Return the box as an rvalue. -This way, if a failure occurs while transing `expr`, the custom +This way, if a panic occurs while transing `expr`, the custom cleanup scope C is pushed and hence the box will be freed. The trans code for `expr` itself is responsible for freeing any other byproducts that may be in play. diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 7d64c42a00030..4d004c85f6e5f 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -1263,7 +1263,7 @@ pub fn with_field_tys(tcx: &ty::ctxt, * Helper for enumerating the field types of structs, enums, or records. * The optional node ID here is the node ID of the path identifying the enum * variant in use. If none, this cannot possibly an enum variant (so, if it - * is and `node_id_opt` is none, this function fails). + * is and `node_id_opt` is none, this function panics). */ match ty::get(ty).sty { @@ -1421,7 +1421,7 @@ pub fn trans_adt<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, }; // This scope holds intermediates that must be cleaned should - // failure occur before the ADT as a whole is ready. + // panic occur before the ADT as a whole is ready. let custom_cleanup_scope = fcx.push_custom_cleanup_scope(); // First we trans the base, if we have one, to the dest diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index aa195837b67d4..d979024c16076 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -551,7 +551,7 @@ pub fn decl_rust_fn_with_foreign_abi(ccx: &CrateContext, let c = llvm_calling_convention(ccx, fn_ty.abi); c.unwrap_or(llvm::CCallConv) } - _ => fail!("expected bare fn in decl_rust_fn_with_foreign_abi") + _ => panic!("expected bare fn in decl_rust_fn_with_foreign_abi") }; let llfn = base::decl_fn(ccx, name, cconv, llfn_ty, ty::FnConverging(ty::mk_nil())); add_argument_attributes(&tys, llfn); @@ -575,7 +575,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext, let c = llvm_calling_convention(ccx, fn_ty.abi); c.unwrap_or(llvm::CCallConv) } - _ => fail!("expected bare fn in register_rust_fn_with_foreign_abi") + _ => panic!("expected bare fn in register_rust_fn_with_foreign_abi") }; let llfn = base::register_fn_llvmty(ccx, sp, sym, node_id, cconv, llfn_ty); add_argument_attributes(&tys, llfn); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index e914dbcc082a6..fb85e61986667 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -244,7 +244,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, adt::fold_variants(bcx, &*repr, struct_data, |variant_cx, st, value| { // Be sure to put all of the fields into a scope so we can use an invoke // instruction to call the user destructor but still call the field - // destructors if the user destructor fails. + // destructors if the user destructor panics. let field_scope = variant_cx.fcx.push_custom_cleanup_scope(); // Class dtors have no explicit args, so the params should diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index 0ddd4894cfa28..2455970b6a64d 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -147,7 +147,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N let ret_ty = match ty::get(callee_ty).sty { ty::ty_bare_fn(ref f) => f.sig.output, - _ => fail!("expected bare_fn in trans_intrinsic_call") + _ => panic!("expected bare_fn in trans_intrinsic_call") }; let foreign_item = tcx.map.expect_foreign_item(node); let name = token::get_ident(foreign_item.ident); diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index bab11c30204cc..db433167298ce 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -193,7 +193,7 @@ pub fn trans_static_method_callee(bcx: Block, }; ident.name } - _ => fail!("callee is not a trait method") + _ => panic!("callee is not a trait method") } } else { csearch::get_item_path(bcx.tcx(), method_id).last().unwrap().name() diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 0dcc69a668656..5c8287c0030d4 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -315,7 +315,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, return bcx; } - // Some cleanup would be required in the case in which failure happens + // Some cleanup would be required in the case in which panic happens // during a copy. But given that copy constructors are not overridable, // this can only happen as a result of OOM. So we just skip out on the // cleanup since things would *probably* be broken at that point anyways. diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index 6acbde3b2adc9..f08fd20314a66 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -308,7 +308,7 @@ impl Type { Double => 64, X86_FP80 => 80, FP128 | PPC_FP128 => 128, - _ => fail!("llvm_float_width called on a non-float type") + _ => panic!("llvm_float_width called on a non-float type") } } } diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 64ab86721bcc7..649dbbacc6984 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -237,7 +237,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type { cx.sess().bug(format!("fictitious type {} in sizing_type_of()", ppaux::ty_to_string(cx.tcx(), t)).as_slice()) } - ty::ty_vec(_, None) | ty::ty_trait(..) | ty::ty_str => fail!("unreachable") + ty::ty_vec(_, None) | ty::ty_trait(..) | ty::ty_str => panic!("unreachable") }; cx.llsizingtypes().borrow_mut().insert(t, llsizingty); @@ -266,7 +266,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { match ty::get(ty::unsized_part_of_type(cx.tcx(), t)).sty { ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyU), ty::ty_trait(_) => Type::vtable_ptr(cx), - _ => fail!("Unexpected type returned from unsized_part_of_type : {}", + _ => panic!("Unexpected type returned from unsized_part_of_type : {}", t.repr(cx.tcx())) } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 6666b85879a89..edb67f7fddf8b 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2083,7 +2083,7 @@ pub fn simd_type(cx: &ctxt, ty: t) -> t { let fields = lookup_struct_fields(cx, did); lookup_field_type(cx, did, fields[0].id, substs) } - _ => fail!("simd_type called on invalid type") + _ => panic!("simd_type called on invalid type") } } @@ -2093,7 +2093,7 @@ pub fn simd_size(cx: &ctxt, ty: t) -> uint { let fields = lookup_struct_fields(cx, did); fields.len() } - _ => fail!("simd_size called on invalid type") + _ => panic!("simd_size called on invalid type") } } @@ -2564,7 +2564,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { // the current crate; therefore, the only type parameters that // could be in scope are those defined in the current crate. // If this assertion fails, it is likely because of a - // failure in the cross-crate inlining code to translate a + // failure of the cross-crate inlining code to translate a // def-id. assert_eq!(p.def_id.krate, ast::LOCAL_CRATE); @@ -3097,7 +3097,7 @@ pub fn unsized_part_of_type(cx: &ctxt, ty: t) -> t { _ => { assert!(type_is_sized(cx, ty), "unsized_part_of_type failed even though ty is unsized"); - fail!("called unsized_part_of_type with sized ty"); + panic!("called unsized_part_of_type with sized ty"); } } } @@ -3229,7 +3229,7 @@ pub fn fn_is_variadic(fty: t) -> bool { ty_bare_fn(ref f) => f.sig.variadic, ty_closure(ref f) => f.sig.variadic, ref s => { - fail!("fn_is_variadic() called on non-fn type: {}", s) + panic!("fn_is_variadic() called on non-fn type: {}", s) } } } @@ -3239,7 +3239,7 @@ pub fn ty_fn_sig(fty: t) -> FnSig { ty_bare_fn(ref f) => f.sig.clone(), ty_closure(ref f) => f.sig.clone(), ref s => { - fail!("ty_fn_sig() called on non-fn type: {}", s) + panic!("ty_fn_sig() called on non-fn type: {}", s) } } } @@ -3249,7 +3249,7 @@ pub fn ty_fn_abi(fty: t) -> abi::Abi { match get(fty).sty { ty_bare_fn(ref f) => f.abi, ty_closure(ref f) => f.abi, - _ => fail!("ty_fn_abi() called on non-fn type"), + _ => panic!("ty_fn_abi() called on non-fn type"), } } @@ -3259,7 +3259,7 @@ pub fn ty_fn_args(fty: t) -> Vec { ty_bare_fn(ref f) => f.sig.inputs.clone(), ty_closure(ref f) => f.sig.inputs.clone(), ref s => { - fail!("ty_fn_args() called on non-fn type: {}", s) + panic!("ty_fn_args() called on non-fn type: {}", s) } } } @@ -3273,7 +3273,7 @@ pub fn ty_closure_store(fty: t) -> TraitStore { UniqTraitStore } ref s => { - fail!("ty_closure_store() called on non-closure type: {}", s) + panic!("ty_closure_store() called on non-closure type: {}", s) } } } @@ -3283,7 +3283,7 @@ pub fn ty_fn_ret(fty: t) -> FnOutput { ty_bare_fn(ref f) => f.sig.output, ty_closure(ref f) => f.sig.output, ref s => { - fail!("ty_fn_ret() called on non-fn type: {}", s) + panic!("ty_fn_ret() called on non-fn type: {}", s) } } } @@ -3735,7 +3735,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind { // Special case `Box` for now: let definition = match tcx.def_map.borrow().find(&place.id) { Some(&def) => def, - None => fail!("no def for place"), + None => panic!("no def for place"), }; let def_id = definition.def_id(); if tcx.lang_items.exchange_heap() == Some(def_id) { @@ -3760,7 +3760,7 @@ pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId { ast::StmtDecl(_, id) | StmtExpr(_, id) | StmtSemi(_, id) => { return id; } - ast::StmtMac(..) => fail!("unexpanded macro in trans") + ast::StmtMac(..) => panic!("unexpanded macro in trans") } } @@ -4068,7 +4068,7 @@ fn lookup_locally_or_in_crate_store( } if def_id.krate == ast::LOCAL_CRATE { - fail!("No def'n found for {} in tcx.{}", def_id, descr); + panic!("No def'n found for {} in tcx.{}", def_id, descr); } let v = load_external(); map.insert(def_id, v.clone()); diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 42990ac79c005..da1e7e24571a6 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -937,7 +937,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( tcx.map.node_to_string(id.node)).as_slice()); } def::DefPrimTy(_) => { - fail!("DefPrimTy arm missed in previous ast_ty_to_prim_ty call"); + panic!("DefPrimTy arm missed in previous ast_ty_to_prim_ty call"); } def::DefAssociatedTy(trait_type_id) => { let path_str = tcx.map.path_to_string( diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index d9f8625504daf..97c6cf24f0e19 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -259,7 +259,7 @@ pub fn check_match(fcx: &FnCtxt, // bottom the type lattice, and we'll be moving up the lattice as // we process each arm. (Note that any match with 0 arms is matching // on any empty type and is therefore unreachable; should the flow - // of execution reach it, we will fail, so bottom is an appropriate + // of execution reach it, we will panic, so bottom is an appropriate // type in that case) let result_ty = arms.iter().fold(fcx.infcx().next_diverging_ty_var(), |result_ty, arm| { check_expr(fcx, &*arm.body); diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 6ace73931bfe8..7527160c825ae 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -916,7 +916,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { // FIXME(#6129). Default methods can't deal with autoref. // // I am a horrible monster and I pray for death. Currently - // the default method code fails when you try to reborrow + // the default method code panics when you try to reborrow // because it is not handling types correctly. In lieu of // fixing that, I am introducing this horrible hack. - ndm self_mt.mutbl == MutImmutable && ty::type_is_self(self_mt.ty) @@ -1034,7 +1034,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { ty::mk_rptr(tcx, r, ty::mt{ ty: tr, mutbl: m }) }) } - _ => fail!("Expected ty_trait in auto_slice_trait") + _ => panic!("Expected ty_trait in auto_slice_trait") } } @@ -1767,7 +1767,7 @@ impl Candidate { ImplSource(def_id) } MethodStaticUnboxedClosure(..) => { - fail!("MethodStaticUnboxedClosure only used in trans") + panic!("MethodStaticUnboxedClosure only used in trans") } MethodTypeParam(ref param) => { TraitSource(param.trait_ref.def_id) diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 08a1e95fd90a1..a5624dcc2fcd3 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -100,7 +100,7 @@ pub fn check_object_cast(fcx: &FnCtxt, fn object_trait<'a>(t: &'a ty::t) -> &'a ty::TyTrait { match ty::get(*t).sty { ty::ty_trait(ref ty_trait) => &**ty_trait, - _ => fail!("expected ty_trait") + _ => panic!("expected ty_trait") } } diff --git a/src/librustc/middle/typeck/coherence/mod.rs b/src/librustc/middle/typeck/coherence/mod.rs index 92fc61cf4c034..a569053507cf8 100644 --- a/src/librustc/middle/typeck/coherence/mod.rs +++ b/src/librustc/middle/typeck/coherence/mod.rs @@ -90,7 +90,7 @@ fn get_base_type(inference_context: &InferCtxt, get(original_type).sty); None } - ty_trait(..) => fail!("should have been caught") + ty_trait(..) => panic!("should have been caught") } } @@ -116,7 +116,7 @@ fn get_base_type_def_id(inference_context: &InferCtxt, Some(def_id) } _ => { - fail!("get_base_type() returned a type that wasn't an \ + panic!("get_base_type() returned a type that wasn't an \ enum, struct, or trait"); } } @@ -125,7 +125,7 @@ fn get_base_type_def_id(inference_context: &InferCtxt, Some(def_id) } _ => { - fail!("get_base_type() returned a type that wasn't an \ + panic!("get_base_type() returned a type that wasn't an \ enum, struct, or trait"); } } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 4c85418669fbb..847d8e88bde88 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -1593,7 +1593,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::Item) return pty; } ast::ItemImpl(..) | ast::ItemMod(_) | - ast::ItemForeignMod(_) | ast::ItemMac(_) => fail!(), + ast::ItemForeignMod(_) | ast::ItemMac(_) => panic!(), } } diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 83ca67f33bc31..fbf2918c2921a 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -210,7 +210,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> { // NB---I do not believe this algorithm computes // (necessarily) the GLB. As written it can - // spuriously fail. In particular, if there is a case + // spuriously fail. In particular, if there is a case // like: |fn(&a)| and fn(fn(&b)), where a and b are // free, it will return fn(&c) where c = GLB(a,b). If // however this GLB is not defined, then the result is diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index fc508db3b2ebd..d2a77f906b535 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -603,7 +603,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { self.commit_unconditionally(|| self.try(|| f())) } - /// Execute `f`, unroll bindings on failure + /// Execute `f`, unroll bindings on panic pub fn try(&self, f: || -> Result) -> Result { debug!("try()"); let snapshot = self.start_snapshot(); diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index b4704b2a27c97..80213d43ec437 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -273,7 +273,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { while undo_log.len() > snapshot.length + 1 { match undo_log.pop().unwrap() { OpenSnapshot => { - fail!("Failure to observe stack discipline"); + panic!("Failure to observe stack discipline"); } Mark | CommitedSnapshot => { } AddVar(vid) => { @@ -916,7 +916,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // We want to generate the intersection of two // scopes or two free regions. So, if one of // these scopes is a subscope of the other, return - // it. Otherwise fail. + // it. Otherwise fail. debug!("intersect_scopes(scope_a={}, scope_b={}, region_a={}, region_b={})", scope_a, scope_b, region_a, region_b); match self.tcx.region_maps.nearest_common_ancestor(scope_a, scope_b) { diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index cad648a8ddbb9..5b1ee7c64b4a3 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -67,7 +67,7 @@ fn remove_message(e: &mut ExpectErrorEmitter, msg: &str, lvl: Level) { e.messages.remove(i); } None => { - fail!("Unexpected error: {} Expected: {}", + panic!("Unexpected error: {} Expected: {}", msg, e.messages); } } @@ -169,7 +169,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { return match search_mod(self, &self.infcx.tcx.map.krate().module, 0, names) { Some(id) => id, None => { - fail!("no item found: `{}`", names.connect("::")); + panic!("no item found: `{}`", names.connect("::")); } }; @@ -218,7 +218,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn make_subtype(&self, a: ty::t, b: ty::t) -> bool { match infer::mk_subty(self.infcx, true, infer::Misc(DUMMY_SP), a, b) { Ok(_) => true, - Err(ref e) => fail!("Encountered error: {}", + Err(ref e) => panic!("Encountered error: {}", ty::type_err_to_str(self.infcx.tcx, e)) } } @@ -232,7 +232,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn assert_subtype(&self, a: ty::t, b: ty::t) { if !self.is_subtype(a, b) { - fail!("{} is not a subtype of {}, but it should be", + panic!("{} is not a subtype of {}, but it should be", self.ty_to_string(a), self.ty_to_string(b)); } @@ -240,7 +240,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn assert_not_subtype(&self, a: ty::t, b: ty::t) { if self.is_subtype(a, b) { - fail!("{} is a subtype of {}, but it shouldn't be", + panic!("{} is a subtype of {}, but it shouldn't be", self.ty_to_string(a), self.ty_to_string(b)); } @@ -315,7 +315,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn make_lub_ty(&self, t1: ty::t, t2: ty::t) -> ty::t { match self.lub().tys(t1, t2) { Ok(t) => t, - Err(ref e) => fail!("unexpected error computing LUB: {}", + Err(ref e) => panic!("unexpected error computing LUB: {}", ty::type_err_to_str(self.infcx.tcx, e)) } } @@ -327,7 +327,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { self.assert_eq(t, t_lub); } Err(ref e) => { - fail!("unexpected error in LUB: {}", + panic!("unexpected error in LUB: {}", ty::type_err_to_str(self.infcx.tcx, e)) } } @@ -341,7 +341,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { self.ty_to_string(t_glb)); match self.glb().tys(t1, t2) { Err(e) => { - fail!("unexpected error computing LUB: {}", e) + panic!("unexpected error computing LUB: {}", e) } Ok(t) => { self.assert_eq(t, t_glb); @@ -358,7 +358,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { match self.lub().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail!("unexpected success computing LUB: {}", self.ty_to_string(t)) + panic!("unexpected success computing LUB: {}", self.ty_to_string(t)) } } } @@ -368,7 +368,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { match self.glb().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail!("unexpected success computing GLB: {}", self.ty_to_string(t)) + panic!("unexpected success computing GLB: {}", self.ty_to_string(t)) } } } diff --git a/src/librustc/middle/typeck/infer/type_variable.rs b/src/librustc/middle/typeck/infer/type_variable.rs index deeb90503df21..63094ceaabdf9 100644 --- a/src/librustc/middle/typeck/infer/type_variable.rs +++ b/src/librustc/middle/typeck/infer/type_variable.rs @@ -102,7 +102,7 @@ impl TypeVariableTable { let relations = match old_value { Bounded(b) => b, - Known(_) => fail!("Asked to instantiate variable that is \ + Known(_) => panic!("Asked to instantiate variable that is \ already instantiated") }; @@ -172,7 +172,7 @@ impl sv::SnapshotVecDelegate for Delegate { fn relations<'a>(v: &'a mut TypeVariableData) -> &'a mut Vec { match v.value { - Known(_) => fail!("var_sub_var: variable is known"), + Known(_) => panic!("var_sub_var: variable is known"), Bounded(ref mut relations) => relations } } diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 301582d55d6eb..d93e985190cff 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -245,7 +245,7 @@ impl> UnificationTable { impl sv::SnapshotVecDelegate,()> for Delegate { fn reverse(&mut self, _: &mut Vec>, _: ()) { - fail!("Nothing to reverse"); + panic!("Nothing to reverse"); } } diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index 8e4aea4463ee3..c8214a743de73 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -572,7 +572,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { match tcx.named_region_map.find(¶m_id) { Some(&rl::DefEarlyBoundRegion(_, _, lifetime_decl_id)) => lifetime_decl_id, - Some(_) => fail!("should not encounter non early-bound cases"), + Some(_) => panic!("should not encounter non early-bound cases"), // The lookup should only fail when `param_id` is // itself a lifetime binding: use it as the decl_id. @@ -597,11 +597,11 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { assert!(is_lifetime(&tcx.map, param_id)); let parent_id = tcx.map.get_parent(decl_id); let parent = tcx.map.find(parent_id).unwrap_or_else( - || fail!("tcx.map missing entry for id: {}", parent_id)); + || panic!("tcx.map missing entry for id: {}", parent_id)); let is_inferred; macro_rules! cannot_happen { () => { { - fail!("invalid parent: {:s} for {:s}", + panic!("invalid parent: {:s} for {:s}", tcx.map.node_to_string(parent_id), tcx.map.node_to_string(param_id)); } } } diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 79faf3aa147ed..e107ac73d7995 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -118,7 +118,7 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { ) ) weak_lang_items!( - fail_fmt, FailFmtLangItem, rust_begin_unwind; + panic_fmt, PanicFmtLangItem, rust_begin_unwind; stack_exhausted, StackExhaustedLangItem, rust_stack_exhausted; eh_personality, EhPersonalityLangItem, rust_eh_personality; ) diff --git a/src/librustc/plugin/registry.rs b/src/librustc/plugin/registry.rs index 88e6f0ad186c6..99e870a901e08 100644 --- a/src/librustc/plugin/registry.rs +++ b/src/librustc/plugin/registry.rs @@ -64,7 +64,7 @@ impl Registry { Decorator(ext) => Decorator(ext), Modifier(ext) => Modifier(ext), // there's probably a nicer way to signal this: - LetSyntaxTT(_, _) => fail!("can't register a new LetSyntax!"), + LetSyntaxTT(_, _) => panic!("can't register a new LetSyntax!"), })); } diff --git a/src/librustc/util/snapshot_vec.rs b/src/librustc/util/snapshot_vec.rs index 7a7c8f8d94f72..8885d86d4da36 100644 --- a/src/librustc/util/snapshot_vec.rs +++ b/src/librustc/util/snapshot_vec.rs @@ -148,7 +148,7 @@ impl> SnapshotVec { match self.undo_log.pop().unwrap() { OpenSnapshot => { // This indicates a failure to obey the stack discipline. - fail!("Cannot rollback an uncommitted snapshot"); + panic!("Cannot rollback an uncommitted snapshot"); } CommittedSnapshot => { diff --git a/src/librustc_back/archive.rs b/src/librustc_back/archive.rs index 060dda5934f8e..2e58a8dab3b39 100644 --- a/src/librustc_back/archive.rs +++ b/src/librustc_back/archive.rs @@ -91,7 +91,7 @@ fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option, handler.err(format!("could not exec `{}`: {}", ar.as_slice(), e).as_slice()); handler.abort_if_errors(); - fail!("rustc::back::archive::run_ar() should not reach this point"); + panic!("rustc::back::archive::run_ar() should not reach this point"); } } } diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs index a7a234dc18ac5..4c62ba54ac427 100644 --- a/src/librustc_back/rpath.rs +++ b/src/librustc_back/rpath.rs @@ -206,7 +206,7 @@ mod test { os: abi::OsLinux, used_crates: Vec::new(), out_filename: Path::new("bin/rustc"), - get_install_prefix_lib_path: || fail!(), + get_install_prefix_lib_path: || panic!(), realpath: |p| Ok(p.clone()) }; let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so")); @@ -220,7 +220,7 @@ mod test { os: abi::OsFreebsd, used_crates: Vec::new(), out_filename: Path::new("bin/rustc"), - get_install_prefix_lib_path: || fail!(), + get_install_prefix_lib_path: || panic!(), realpath: |p| Ok(p.clone()) }; let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so")); @@ -234,7 +234,7 @@ mod test { os: abi::OsDragonfly, used_crates: Vec::new(), out_filename: Path::new("bin/rustc"), - get_install_prefix_lib_path: || fail!(), + get_install_prefix_lib_path: || panic!(), realpath: |p| Ok(p.clone()) }; let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so")); @@ -248,7 +248,7 @@ mod test { os: abi::OsMacos, used_crates: Vec::new(), out_filename: Path::new("bin/rustc"), - get_install_prefix_lib_path: || fail!(), + get_install_prefix_lib_path: || panic!(), realpath: |p| Ok(p.clone()) }; let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so")); diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index bf8d993964ff9..96a15213c5ed6 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -59,18 +59,18 @@ impl ToBits for u64 { } } -/// Adds the specified number of bytes to the bit count. fail!() if this would cause numeric +/// Adds the specified number of bytes to the bit count. panic!() if this would cause numeric /// overflow. fn add_bytes_to_bits(bits: T, bytes: T) -> T { let (new_high_bits, new_low_bits) = bytes.to_bits(); if new_high_bits > Zero::zero() { - fail!("numeric overflow occurred.") + panic!("numeric overflow occurred.") } match bits.checked_add(&new_low_bits) { Some(x) => return x, - None => fail!("numeric overflow occurred.") + None => panic!("numeric overflow occurred.") } } diff --git a/src/librustc_back/svh.rs b/src/librustc_back/svh.rs index 3c28cac6c6f7c..01a5767aeb256 100644 --- a/src/librustc_back/svh.rs +++ b/src/librustc_back/svh.rs @@ -347,7 +347,7 @@ mod svh_visitor { } else { // It is not possible to observe any kind of macro // invocation at this stage except `macro_rules!`. - fail!("reached macro somehow: {}", + panic!("reached macro somehow: {}", pprust::to_string(|pp_state| pp_state.print_mac(macro))); } diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 4ef72361701f2..967e1fbb70021 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -174,7 +174,7 @@ fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, clean::Function { decl: match ty::get(t.ty).sty { ty::ty_bare_fn(ref f) => (did, &f.sig).clean(cx), - _ => fail!("bad function"), + _ => panic!("bad function"), }, generics: (&t.generics, subst::FnSpace).clean(cx), fn_style: style, @@ -308,7 +308,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt, generics: generics, }) } - _ => fail!("not a tymethod"), + _ => panic!("not a tymethod"), }; Some(item) } @@ -382,7 +382,7 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt, decoder::DlDef(..) => {} // All impls were inlined above decoder::DlImpl(..) => {} - decoder::DlField => fail!("unimplemented field"), + decoder::DlField => panic!("unimplemented field"), } }); } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c4d7e85904cb3..7c8f4ba8f65c7 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1259,7 +1259,7 @@ impl Clean for ast::Ty { TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), TyParen(ref ty) => ty.clean(cx), TyBot => Bottom, - ref x => fail!("Unimplemented type {}", x), + ref x => panic!("Unimplemented type {}", x), } } } @@ -1354,9 +1354,9 @@ impl Clean for ty::t { ty::ty_unboxed_closure(..) => Primitive(Unit), // FIXME(pcwalton) - ty::ty_infer(..) => fail!("ty_infer"), - ty::ty_open(..) => fail!("ty_open"), - ty::ty_err => fail!("ty_err"), + ty::ty_infer(..) => panic!("ty_infer"), + ty::ty_open(..) => panic!("ty_open"), + ty::ty_err => panic!("ty_err"), } } } @@ -2068,9 +2068,9 @@ fn name_from_pat(p: &ast::Pat) -> String { which is silly in function arguments"); "()".to_string() }, - PatRange(..) => fail!("tried to get argument name from PatRange, \ + PatRange(..) => panic!("tried to get argument name from PatRange, \ which is not allowed in function arguments"), - PatVec(..) => fail!("tried to get argument name from pat_vec, \ + PatVec(..) => panic!("tried to get argument name from pat_vec, \ which is not allowed in function arguments"), PatMac(..) => { warn!("can't document the name of a function argument \ @@ -2092,7 +2092,7 @@ fn resolve_type(cx: &DocContext, path: Path, debug!("searching for {} in defmap", id); let def = match tcx.def_map.borrow().find(&id) { Some(&k) => k, - None => fail!("unresolved id not in defmap") + None => panic!("unresolved id not in defmap") }; match def { diff --git a/src/librustdoc/flock.rs b/src/librustdoc/flock.rs index ef921a84cfb8e..a89b20c949b40 100644 --- a/src/librustdoc/flock.rs +++ b/src/librustdoc/flock.rs @@ -128,7 +128,7 @@ mod imp { }; if ret == -1 { unsafe { libc::close(fd); } - fail!("could not lock `{}`", p.display()) + panic!("could not lock `{}`", p.display()) } Lock { fd: fd } } @@ -197,7 +197,7 @@ mod imp { ptr::null_mut()) }; if handle == libc::INVALID_HANDLE_VALUE { - fail!("create file error: {}", os::last_os_error()); + panic!("create file error: {}", os::last_os_error()); } let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() }; let ret = unsafe { @@ -206,7 +206,7 @@ mod imp { }; if ret == 0 { unsafe { libc::CloseHandle(handle); } - fail!("could not lock `{}`: {}", p.display(), + panic!("could not lock `{}`: {}", p.display(), os::last_os_error()) } Lock { handle: handle } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ca8a6cd0c4010..f9177c8d61578 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -499,7 +499,7 @@ impl fmt::Show for clean::Type { } } clean::Unique(..) => { - fail!("should have been cleaned") + panic!("should have been cleaned") } } } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 6e515f611986e..b7dfd811574a3 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1042,7 +1042,7 @@ impl Context { /// sure it always points to the top (relatively) fn recurse(&mut self, s: String, f: |&mut Context| -> T) -> T { if s.len() == 0 { - fail!("Unexpected empty destination: {}", self.current); + panic!("Unexpected empty destination: {}", self.current); } let prev = self.dst.clone(); self.dst.push(s.as_slice()); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index ad79faebd45c5..5f404238beb30 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -243,13 +243,13 @@ pub fn main_args(args: &[String]) -> int { Some("html") | None => { match html::render::run(krate, &external_html, output.unwrap_or(Path::new("doc"))) { Ok(()) => {} - Err(e) => fail!("failed to generate documentation: {}", e), + Err(e) => panic!("failed to generate documentation: {}", e), } } Some("json") => { match json_output(krate, res, output.unwrap_or(Path::new("doc.json"))) { Ok(()) => {} - Err(e) => fail!("failed to write json: {}", e), + Err(e) => panic!("failed to write json: {}", e), } } Some(s) => { @@ -480,7 +480,7 @@ fn json_output(krate: clean::Crate, res: Vec , }; let crate_json = match json::from_str(crate_json_str.as_slice()) { Ok(j) => j, - Err(e) => fail!("Rust generated JSON is invalid: {}", e) + Err(e) => panic!("Rust generated JSON is invalid: {}", e) }; json.insert("crate".to_string(), crate_json); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 685d76bb5200b..642abf924ae71 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -192,15 +192,15 @@ fn runtest(test: &str, cratename: &str, libs: Vec, externs: core::Externs, cmd.env(DynamicLibrary::envvar(), newpath.as_slice()); match cmd.output() { - Err(e) => fail!("couldn't run the test: {}{}", e, + Err(e) => panic!("couldn't run the test: {}{}", e, if e.kind == io::PermissionDenied { " - maybe your tempdir is mounted with noexec?" } else { "" }), Ok(out) => { if should_fail && out.status.success() { - fail!("test executable succeeded when it should have failed"); + panic!("test executable succeeded when it should have failed"); } else if !should_fail && !out.status.success() { - fail!("test executable failed:\n{}", + panic!("test executable failed:\n{}", str::from_utf8(out.error.as_slice())); } } diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 8e377037a9713..1cafc38f826c9 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -249,7 +249,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { self.visit_item(&**i, None, om); } } - _ => { fail!("glob not mapped to a module"); } + _ => { panic!("glob not mapped to a module"); } } } else { self.visit_item(it, renamed, om); @@ -353,7 +353,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { om.foreigns.push(fm.clone()); } ast::ItemMac(_) => { - fail!("rustdoc: macros should be gone, after expansion"); + panic!("rustdoc: macros should be gone, after expansion"); } } } diff --git a/src/librustrt/args.rs b/src/librustrt/args.rs index 3138c9be99247..20a63f655b8ff 100644 --- a/src/librustrt/args.rs +++ b/src/librustrt/args.rs @@ -160,14 +160,14 @@ mod imp { } pub fn take() -> Option>> { - fail!() + panic!() } pub fn put(_args: Vec>) { - fail!() + panic!() } pub fn clone() -> Option>> { - fail!() + panic!() } } diff --git a/src/librustrt/c_str.rs b/src/librustrt/c_str.rs index 6a33777a413c5..ddb4df4fdc538 100644 --- a/src/librustrt/c_str.rs +++ b/src/librustrt/c_str.rs @@ -101,7 +101,7 @@ impl Clone for CString { fn clone(&self) -> CString { let len = self.len() + 1; let buf = unsafe { libc::malloc(len as libc::size_t) } as *mut libc::c_char; - if buf.is_null() { fail!("out of memory") } + if buf.is_null() { panic!("out of memory") } unsafe { ptr::copy_nonoverlapping_memory(buf, self.buf, len); } CString { buf: buf as *const libc::c_char, owns_buffer_: true } } @@ -394,7 +394,7 @@ impl<'a> ToCStr for &'a [u8] { unsafe fn to_c_str_unchecked(&self) -> CString { let self_len = self.len(); let buf = libc::malloc(self_len as libc::size_t + 1) as *mut u8; - if buf.is_null() { fail!("out of memory") } + if buf.is_null() { panic!("out of memory") } ptr::copy_memory(buf, self.as_ptr(), self_len); *buf.offset(self_len as int) = 0; diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index 972497f981883..9a8bd3cdfc81c 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -101,7 +101,7 @@ pub trait Runtime { fn wrap(self: Box) -> Box; } -/// The default error code of the rust runtime if the main task fails instead +/// The default error code of the rust runtime if the main task panics instead /// of exiting cleanly. pub const DEFAULT_ERROR_CODE: int = 101; diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index 8d5c49d767f15..5d9e20b07de9a 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -134,7 +134,7 @@ unsafe fn get_local_map<'a>() -> Option<&'a mut Map> { *slot = Some(TreeMap::new()); match *slot { Some(ref mut map_ptr) => { return Some(map_ptr) } - None => fail!("unreachable code"), + None => panic!("unreachable code"), } } } @@ -161,12 +161,12 @@ impl KeyValue { /// If this key is already present in TLD, then the previous value is /// replaced with the provided data, and then returned. /// - /// # Failure + /// # Panics /// - /// This function will fail if the key is present in TLD and currently on + /// This function will panic if the key is present in TLD and currently on /// loan with the `get` method. /// - /// It will also fail if there is no local task (because the current thread + /// It will also panic if there is no local task (because the current thread /// is not owned by the runtime). /// /// # Example @@ -181,7 +181,7 @@ impl KeyValue { pub fn replace(&'static self, data: Option) -> Option { let map = match unsafe { get_local_map() } { Some(map) => map, - None => fail!("must have a local task to insert into TLD"), + None => panic!("must have a local task to insert into TLD"), }; let keyval = key_to_key_value(self); @@ -233,7 +233,7 @@ impl KeyValue { } _ => { // Refcount is 2+, which means we have a live borrow. - fail!("TLD value cannot be replaced because it is already borrowed"); + panic!("TLD value cannot be replaced because it is already borrowed"); } } } @@ -369,7 +369,7 @@ impl TLDValue { unsafe fn d(p: *mut ()) { let value_box = p as *mut TLDValueBox; debug_assert!(*(*value_box).refcount.get() < 2, "TLDValue destructed while borrowed"); - // use a RAII type here to ensure we always deallocate even if we fail while + // use a RAII type here to ensure we always deallocate even if we panic while // running the destructor for the value. struct Guard { p: *mut TLDValueBox @@ -495,7 +495,7 @@ mod tests { #[test] #[should_fail] - fn test_tls_cleanup_on_failure() { + fn test_tls_cleanup_on_panic() { static STR_KEY: Key = &KeyValueKey; static BOX_KEY: Key> = &KeyValueKey; static INT_KEY: Key = &KeyValueKey; @@ -505,11 +505,11 @@ mod tests { STR_KEY.replace(Some("string data".to_string())); BOX_KEY.replace(Some(box 2)); INT_KEY.replace(Some(42)); - fail!(); + panic!(); }); // Not quite nondeterministic. INT_KEY.replace(Some(31337)); - fail!(); + panic!(); } #[test] diff --git a/src/librustrt/mutex.rs b/src/librustrt/mutex.rs index 838dfd6b7abe6..6a6e2e40ec888 100644 --- a/src/librustrt/mutex.rs +++ b/src/librustrt/mutex.rs @@ -81,7 +81,7 @@ pub struct NativeMutex { /// destruction. /// /// Using this makes lock-based code resilient to unwinding/task -/// failure, because the lock will be automatically unlocked even +/// panic, because the lock will be automatically unlocked even /// then. #[must_use] pub struct LockGuard<'a> { diff --git a/src/librustrt/stack_overflow.rs b/src/librustrt/stack_overflow.rs index aaaeb8846ccaf..d01b4a3a4b34c 100644 --- a/src/librustrt/stack_overflow.rs +++ b/src/librustrt/stack_overflow.rs @@ -116,7 +116,7 @@ mod imp { PAGE_SIZE = info.dwPageSize as uint; if AddVectoredExceptionHandler(0, vectored_handler) == ptr::null_mut() { - fail!("failed to install exception handler"); + panic!("failed to install exception handler"); } mem::forget(make_handler()); @@ -127,7 +127,7 @@ mod imp { pub unsafe fn make_handler() -> Handler { if SetThreadStackGuarantee(&mut 0x5000) == 0 { - fail!("failed to reserve stack space for exception handling"); + panic!("failed to reserve stack space for exception handling"); } super::Handler { _data: 0i as *mut libc::c_void } @@ -232,7 +232,7 @@ mod imp { pub unsafe fn init() { let psize = libc::sysconf(libc::consts::os::sysconf::_SC_PAGESIZE); if psize == -1 { - fail!("failed to get page size"); + panic!("failed to get page size"); } PAGE_SIZE = psize as uint; @@ -260,7 +260,7 @@ mod imp { -1, 0); if alt_stack == MAP_FAILED { - fail!("failed to allocate an alternative stack"); + panic!("failed to allocate an alternative stack"); } let mut stack: sigaltstack = mem::zeroed(); diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index 5eb28412abdab..ad3b1dc7e1695 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -53,7 +53,7 @@ use collections::str::SendStr; /// /// * `run` - This function will execute a closure inside the context of a task. /// Failure is caught and handled via the task's on_exit callback. If -/// this fails, the task is still returned, but it can no longer be +/// this panics, the task is still returned, but it can no longer be /// used, it is poisoned. /// /// * `destroy` - This is a required function to call to destroy a task. If a @@ -74,18 +74,18 @@ use collections::str::SendStr; /// // Create a task using a native runtime /// let task = native::task::new((0, uint::MAX), 0); /// -/// // Run some code, catching any possible failures +/// // Run some code, catching any possible panic /// let task = task.run(|| { /// // Run some code inside this task /// println!("Hello with a native runtime!"); /// }); /// -/// // Run some code again, catching the failure +/// // Run some code again, catching the panic /// let task = task.run(|| { -/// fail!("oh no, what to do!"); +/// panic!("oh no, what to do!"); /// }); /// -/// // Now that the task is failed, it can never be used again +/// // Now that the task has panicked, it can never be used again /// assert!(task.is_destroyed()); /// /// // Deallocate the resources associated with this task @@ -114,7 +114,7 @@ enum TaskState { pub struct TaskOpts { /// Invoke this procedure with the result of the task when it finishes. pub on_exit: Option, - /// A name for the task-to-be, for identification in failure messages + /// A name for the task-to-be, for identification in panic messages pub name: Option, /// The size of the stack for the spawned task pub stack_size: Option, @@ -122,7 +122,7 @@ pub struct TaskOpts { /// Indicates the manner in which a task exited. /// -/// A task that completes without failing is considered to exit successfully. +/// A task that completes without panicking is considered to exit successfully. /// /// If you wish for this result's delivery to block until all /// children tasks complete, recommend using a result future. @@ -138,7 +138,7 @@ pub enum BlockedTask { Shared(Arc), } -/// Per-task state related to task death, killing, failure, etc. +/// Per-task state related to task death, killing, panic, etc. pub struct Death { pub on_exit: Option, marker: marker::NoCopy, @@ -175,15 +175,15 @@ impl Task { /// try/catch). Invoking this function is quite cheap. /// /// If the closure `f` succeeds, then the returned task can be used again - /// for another invocation of `run`. If the closure `f` fails then `self` + /// for another invocation of `run`. If the closure `f` panics then `self` /// will be internally destroyed along with all of the other associated /// resources of this task. The `on_exit` callback is invoked with the - /// cause of failure (not returned here). This can be discovered by querying + /// cause of panic (not returned here). This can be discovered by querying /// `is_destroyed()`. /// /// Note that it is possible to view partial execution of the closure `f` /// because it is not guaranteed to run to completion, but this function is - /// guaranteed to return if it fails. Care should be taken to ensure that + /// guaranteed to return if it panicks. Care should be taken to ensure that /// stack references made by `f` are handled appropriately. /// /// It is invalid to call this function with a task that has been previously @@ -212,7 +212,7 @@ impl Task { // recursive invocations of run(). If there's no one else, then // relinquish ownership of ourselves back into TLS. if Local::exists(None::) { - fail!("cannot run a task recursively inside another"); + panic!("cannot run a task recursively inside another"); } self.state = Armed; Local::put(self); @@ -226,7 +226,7 @@ impl Task { let result = unsafe { unwind::try(f) }; // After running the closure given return the task back out if it ran - // successfully, or clean up the task if it failed. + // successfully, or clean up the task if it panicked. let task: Box = Local::take(); match result { Ok(()) => task, @@ -275,7 +275,7 @@ impl Task { // There is a test for this at fail-during-tld-destroy.rs. // // 2. One failure in destruction is tolerable, so long as the task - // didn't originally fail while it was running. + // didn't originally panic while it was running. // // And with all that in mind, we attempt to clean things up! let mut task = self.run(|| { @@ -290,7 +290,7 @@ impl Task { drop(tld); }); - // If the above `run` block failed, then it must be the case that the + // If the above `run` block panicked, then it must be the case that the // task had previously succeeded. This also means that the code below // was recursively run via the `run` method invoking this method. In // this case, we just make sure the world is as we thought, and return. @@ -306,7 +306,7 @@ impl Task { // FIXME: this is running in a seriously constrained context. If this // allocates TLD then it will likely abort the runtime. Similarly, - // if this fails, this will also likely abort the runtime. + // if this panics, this will also likely abort the runtime. // // This closure is currently limited to a channel send via the // standard library's task interface, but this needs @@ -490,7 +490,7 @@ impl BlockedTask { } // This assertion has two flavours because the wake involves an atomic op. - // In the faster version, destructors will fail dramatically instead. + // In the faster version, destructors will panic dramatically instead. #[cfg(not(test))] pub fn trash(self) { } #[cfg(test)] pub fn trash(self) { assert!(self.wake().is_none()); } @@ -570,7 +570,7 @@ mod test { let result = task::try(proc()()); rtdebug!("trying first assert"); assert!(result.is_ok()); - let result = task::try::<()>(proc() fail!()); + let result = task::try::<()>(proc() panic!()); rtdebug!("trying second assert"); assert!(result.is_err()); } diff --git a/src/librustrt/thread.rs b/src/librustrt/thread.rs index 50b570091ada1..9f3f45ba0981c 100644 --- a/src/librustrt/thread.rs +++ b/src/librustrt/thread.rs @@ -235,7 +235,7 @@ mod imp { if ret as uint == 0 { // be sure to not leak the closure let _p: Box = mem::transmute(arg); - fail!("failed to spawn native thread: {}", ret); + panic!("failed to spawn native thread: {}", ret); } return ret; } @@ -327,15 +327,15 @@ mod imp { unsafe fn get_stack_start() -> *mut libc::c_void { let mut attr: libc::pthread_attr_t = mem::zeroed(); if pthread_getattr_np(pthread_self(), &mut attr) != 0 { - fail!("failed to get thread attributes"); + panic!("failed to get thread attributes"); } let mut stackaddr = ptr::null_mut(); let mut stacksize = 0; if pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize) != 0 { - fail!("failed to get stack information"); + panic!("failed to get stack information"); } if pthread_attr_destroy(&mut attr) != 0 { - fail!("failed to destroy thread attributes"); + panic!("failed to destroy thread attributes"); } stackaddr } @@ -343,7 +343,7 @@ mod imp { pub unsafe fn init() { let psize = libc::sysconf(libc::consts::os::sysconf::_SC_PAGESIZE); if psize == -1 { - fail!("failed to get page size"); + panic!("failed to get page size"); } PAGE_SIZE = psize as uint; @@ -361,7 +361,7 @@ mod imp { 0); if result != stackaddr || result == MAP_FAILED { - fail!("failed to allocate a guard page"); + panic!("failed to allocate a guard page"); } let offset = if cfg!(target_os = "linux") { @@ -387,22 +387,22 @@ mod imp { pub unsafe fn current() -> uint { let mut attr: libc::pthread_attr_t = mem::zeroed(); if pthread_getattr_np(pthread_self(), &mut attr) != 0 { - fail!("failed to get thread attributes"); + panic!("failed to get thread attributes"); } let mut guardsize = 0; if pthread_attr_getguardsize(&attr, &mut guardsize) != 0 { - fail!("failed to get stack guard page"); + panic!("failed to get stack guard page"); } if guardsize == 0 { - fail!("there is no guard page"); + panic!("there is no guard page"); } let mut stackaddr = ptr::null_mut(); let mut stacksize = 0; if pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize) != 0 { - fail!("failed to get stack information"); + panic!("failed to get stack information"); } if pthread_attr_destroy(&mut attr) != 0 { - fail!("failed to destroy thread attributes"); + panic!("failed to destroy thread attributes"); } stackaddr as uint + guardsize as uint @@ -433,7 +433,7 @@ mod imp { }, errno => { // This cannot really happen. - fail!("pthread_attr_setstacksize() error: {}", errno); + panic!("pthread_attr_setstacksize() error: {}", errno); }, }; @@ -444,7 +444,7 @@ mod imp { if ret != 0 { // be sure to not leak the closure let _p: Box = mem::transmute(arg); - fail!("failed to spawn native thread: {}", ret); + panic!("failed to spawn native thread: {}", ret); } native } diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs index 9483beca1c39d..96a584492aeda 100644 --- a/src/librustrt/unwind.rs +++ b/src/librustrt/unwind.rs @@ -115,11 +115,11 @@ impl Unwinder { } } -/// Invoke a closure, capturing the cause of failure if one occurs. +/// Invoke a closure, capturing the cause of panic if one occurs. /// -/// This function will return `None` if the closure did not fail, and will -/// return `Some(cause)` if the closure fails. The `cause` returned is the -/// object with which failure was originally invoked. +/// This function will return `None` if the closure did not panic, and will +/// return `Some(cause)` if the closure panics. The `cause` returned is the +/// object with which panic was originally invoked. /// /// This function also is unsafe for a variety of reasons: /// @@ -489,9 +489,9 @@ pub mod eabi { } } -// Entry point of failure from the libcore crate +// Entry point of panic from the libcore crate #[cfg(not(test))] -#[lang = "fail_fmt"] +#[lang = "panic_fmt"] pub extern fn rust_begin_unwind(msg: &fmt::Arguments, file: &'static str, line: uint) -> ! { begin_unwind_fmt(msg, &(file, line)) @@ -500,7 +500,7 @@ pub extern fn rust_begin_unwind(msg: &fmt::Arguments, /// The entry point for unwinding with a formatted message. /// /// This is designed to reduce the amount of code required at the call -/// site as much as possible (so that `fail!()` has as low an impact +/// site as much as possible (so that `panic!()` has as low an impact /// on (e.g.) the inlining of other functions as possible), by moving /// the actual formatting into this shared place. #[inline(never)] #[cold] @@ -509,7 +509,7 @@ pub fn begin_unwind_fmt(msg: &fmt::Arguments, file_line: &(&'static str, uint)) // We do two allocations here, unfortunately. But (a) they're // required with the current scheme, and (b) we don't handle - // failure + OOM properly anyway (see comment in begin_unwind + // panic + OOM properly anyway (see comment in begin_unwind // below). struct VecWriter<'a> { v: &'a mut Vec } @@ -528,15 +528,15 @@ pub fn begin_unwind_fmt(msg: &fmt::Arguments, file_line: &(&'static str, uint)) begin_unwind_inner(msg, file_line) } -/// This is the entry point of unwinding for fail!() and assert!(). +/// This is the entry point of unwinding for panic!() and assert!(). #[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible pub fn begin_unwind(msg: M, file_line: &(&'static str, uint)) -> ! { // Note that this should be the only allocation performed in this code path. - // Currently this means that fail!() on OOM will invoke this code path, - // but then again we're not really ready for failing on OOM anyway. If + // Currently this means that panic!() on OOM will invoke this code path, + // but then again we're not really ready for panic on OOM anyway. If // we do start doing this, then we should propagate this allocation to // be performed in the parent of this task instead of the task that's - // failing. + // panicking. // see below for why we do the `Any` coercion here. begin_unwind_inner(box msg, file_line) @@ -549,11 +549,11 @@ pub fn begin_unwind(msg: M, file_line: &(&'static str, uint)) -> /// we need the `Any` object anyway, we're not just creating it to /// avoid being generic.) /// -/// Do this split took the LLVM IR line counts of `fn main() { fail!() +/// Do this split took the LLVM IR line counts of `fn main() { panic!() /// }` from ~1900/3700 (-O/no opts) to 180/590. #[inline(never)] #[cold] // this is the slow path, please never inline this fn begin_unwind_inner(msg: Box, file_line: &(&'static str, uint)) -> ! { - // First, invoke call the user-defined callbacks triggered on task failure. + // First, invoke call the user-defined callbacks triggered on task panic. // // By the time that we see a callback has been registered (by reading // MAX_CALLBACKS), the actual callback itself may have not been stored yet, @@ -584,7 +584,7 @@ fn begin_unwind_inner(msg: Box, file_line: &(&'static str, uint)) -> }; if task.unwinder.unwinding { - // If a task fails while it's already unwinding then we + // If a task panics while it's already unwinding then we // have limited options. Currently our preference is to // just abort. In the future we may consider resuming // unwinding or otherwise exiting the task cleanly. @@ -603,7 +603,7 @@ fn begin_unwind_inner(msg: Box, file_line: &(&'static str, uint)) -> /// Register a callback to be invoked when a task unwinds. /// /// This is an unsafe and experimental API which allows for an arbitrary -/// callback to be invoked when a task fails. This callback is invoked on both +/// callback to be invoked when a task panics. This callback is invoked on both /// the initial unwinding and a double unwinding if one occurs. Additionally, /// the local `Task` will be in place for the duration of the callback, and /// the callback must ensure that it remains in place once the callback returns. diff --git a/src/libserialize/base64.rs b/src/libserialize/base64.rs index 19dcc3c132cd7..c999157b89a8f 100644 --- a/src/libserialize/base64.rs +++ b/src/libserialize/base64.rs @@ -144,7 +144,7 @@ impl<'a> ToBase64 for &'a [u8] { v.push(b'='); } } - _ => fail!("Algebra is broken, please alert the math police") + _ => panic!("Algebra is broken, please alert the math police") } unsafe { diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 73b4773fb3ff9..99c60dde0ac59 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1229,7 +1229,7 @@ impl Stack { let len = self.stack.len(); let idx = match *self.stack.last().unwrap() { InternalIndex(i) => { i + 1 } - _ => { fail!(); } + _ => { panic!(); } }; *self.stack.get_mut(len - 1) = InternalIndex(idx); } @@ -1814,7 +1814,7 @@ impl> Builder { match self.token { None => {} Some(Error(e)) => { return Err(e); } - ref tok => { fail!("unexpected token {}", tok.clone()); } + ref tok => { panic!("unexpected token {}", tok.clone()); } } result } @@ -1874,7 +1874,7 @@ impl> Builder { } let key = match self.parser.stack().top() { Some(Key(k)) => { k.to_string() } - _ => { fail!("invalid state"); } + _ => { panic!("invalid state"); } }; match self.build_value() { Ok(value) => { values.insert(key, value); } @@ -3015,9 +3015,9 @@ mod tests { Ok(json) => Decodable::decode(&mut Decoder::new(json)) }; match res { - Ok(_) => fail!("`{}` parsed & decoded ok, expecting error `{}`", + Ok(_) => panic!("`{}` parsed & decoded ok, expecting error `{}`", to_parse, expected), - Err(ParseError(e)) => fail!("`{}` is not valid json: {}", + Err(ParseError(e)) => panic!("`{}` is not valid json: {}", to_parse, e), Err(e) => { assert_eq!(e, expected); @@ -3226,7 +3226,7 @@ mod tests { let bytes = mem_buf.unwrap(); let json_str = from_utf8(bytes.as_slice()).unwrap(); match from_str(json_str) { - Err(_) => fail!("Unable to parse json_str: {}", json_str), + Err(_) => panic!("Unable to parse json_str: {}", json_str), _ => {} // it parsed and we are good to go } } @@ -3247,7 +3247,7 @@ mod tests { let bytes = mem_buf.unwrap(); let json_str = from_utf8(bytes.as_slice()).unwrap(); match from_str(json_str) { - Err(_) => fail!("Unable to parse json_str: {}", json_str), + Err(_) => panic!("Unable to parse json_str: {}", json_str), _ => {} // it parsed and we are good to go } } @@ -3315,7 +3315,7 @@ mod tests { use Decodable; let json_str = "{\"1\":true}"; let json_obj = match from_str(json_str) { - Err(_) => fail!("Unable to parse json_str: {}", json_str), + Err(_) => panic!("Unable to parse json_str: {}", json_str), Ok(o) => o }; let mut decoder = Decoder::new(json_obj); @@ -3328,7 +3328,7 @@ mod tests { use Decodable; let json_str = "{\"a\":true}"; let json_obj = match from_str(json_str) { - Err(_) => fail!("Unable to parse json_str: {}", json_str), + Err(_) => panic!("Unable to parse json_str: {}", json_str), Ok(o) => o }; let mut decoder = Decoder::new(json_obj); @@ -3347,7 +3347,7 @@ mod tests { }; let (ref expected_evt, ref expected_stack) = expected[i]; if !parser.stack().is_equal_to(expected_stack.as_slice()) { - fail!("Parser stack is not equal to {}", expected_stack); + panic!("Parser stack is not equal to {}", expected_stack); } assert_eq!(&evt, expected_evt); i+=1; diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 6b6b08c5e6e3a..33c8e94e32b60 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -138,7 +138,7 @@ impl<'a> fmt::Show for Ascii { /// Trait for converting into an ascii type. pub trait AsciiCast { - /// Convert to an ascii type, fail on non-ASCII input. + /// Convert to an ascii type, panic on non-ASCII input. #[inline] fn to_ascii(&self) -> T { assert!(self.is_ascii()); @@ -649,16 +649,16 @@ mod tests { } #[test] #[should_fail] - fn test_ascii_vec_fail_u8_slice() { (&[127u8, 128u8, 255u8]).to_ascii(); } + fn test_ascii_vec_panic_u8_slice() { (&[127u8, 128u8, 255u8]).to_ascii(); } #[test] #[should_fail] - fn test_ascii_vec_fail_str_slice() { "zoä华".to_ascii(); } + fn test_ascii_vec_panic_str_slice() { "zoä华".to_ascii(); } #[test] #[should_fail] - fn test_ascii_fail_u8_slice() { 255u8.to_ascii(); } + fn test_ascii_panic_u8_slice() { 255u8.to_ascii(); } #[test] #[should_fail] - fn test_ascii_fail_char_slice() { 'λ'.to_ascii(); } + fn test_ascii_panic_char_slice() { 'λ'.to_ascii(); } #[test] fn test_opt() { diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 7ec25acb17308..bb7de168898f0 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -169,7 +169,7 @@ mod tests { fn malloc(n: uint) -> CVec { unsafe { let mem = libc::malloc(n as libc::size_t); - if mem.is_null() { fail!("out of memory") } + if mem.is_null() { panic!("out of memory") } CVec::new_with_dtor(mem as *mut u8, n, proc() { libc::free(mem as *mut libc::c_void); }) @@ -189,7 +189,7 @@ mod tests { #[test] #[should_fail] - fn test_fail_at_null() { + fn test_panic_at_null() { unsafe { CVec::new(ptr::null_mut::(), 9); } @@ -213,7 +213,7 @@ mod tests { fn test_unwrap() { unsafe { let cv = CVec::new_with_dtor(1 as *mut int, 0, - proc() { fail!("Don't run this destructor!") }); + proc() { panic!("Don't run this destructor!") }); let p = cv.unwrap(); assert_eq!(p, 1 as *mut int); } diff --git a/src/libstd/collections/hashmap/map.rs b/src/libstd/collections/hashmap/map.rs index ac0d117e02a11..6562a644988e6 100644 --- a/src/libstd/collections/hashmap/map.rs +++ b/src/libstd/collections/hashmap/map.rs @@ -120,8 +120,7 @@ impl DefaultResizePolicy { // is also memory and cache pressure that this would entail that would be very // difficult to properly see in a microbenchmark. // -// Future Improvements (FIXME!) -// ============================ +// ## Future Improvements (FIXME!) // // Allow the load factor to be changed dynamically and/or at initialization. // @@ -129,8 +128,7 @@ impl DefaultResizePolicy { // underlying table? This is exactly the use case for 'realloc', and may // be worth exploring. // -// Future Optimizations (FIXME!) -// ============================= +// ## Future Optimizations (FIXME!) // // Another possible design choice that I made without any real reason is // parameterizing the raw table over keys and values. Technically, all we need @@ -473,7 +471,7 @@ impl, V, S, H: Hasher> HashMap { }; buckets.next(); } - fail!("Internal HashMap error: Out of space."); + panic!("Internal HashMap error: Out of space."); } } @@ -829,7 +827,8 @@ impl, V, S, H: Hasher> HashMap { } /// Retrieves a mutable value for the given key. - /// See [`find_mut`](../trait.MutableMap.html#tymethod.find_mut) for a non-failing alternative. + /// See [`find_mut`](../trait.MutableMap.html#tymethod.find_mut) for a non-panicking + /// alternative. /// /// # Failure /// @@ -856,7 +855,7 @@ impl, V, S, H: Hasher> HashMap { pub fn get_mut<'a>(&'a mut self, k: &K) -> &'a mut V { match self.find_mut(k) { Some(v) => v, - None => fail!("no entry found for key") + None => panic!("no entry found for key") } } @@ -1625,7 +1624,7 @@ mod test_map { assert!(m.insert(5i, 14i)); let new = 100; match m.find_mut(&5) { - None => fail!(), Some(x) => *x = new + None => panic!(), Some(x) => *x = new } assert_eq!(m.find(&5), Some(&new)); } @@ -1746,7 +1745,7 @@ mod test_map { assert!(m.find(&1i).is_none()); m.insert(1i, 2i); match m.find(&1) { - None => fail!(), + None => panic!(), Some(v) => assert_eq!(*v, 2) } } @@ -1759,12 +1758,12 @@ mod test_map { for i in range(1i, 10000) { m.insert(i, i + 7); match m.find_copy(&i) { - None => fail!(), + None => panic!(), Some(v) => assert_eq!(v, i + 7) } for j in range(1i, i/100) { match m.find_copy(&j) { - None => fail!(), + None => panic!(), Some(v) => assert_eq!(v, j + 7) } } diff --git a/src/libstd/collections/hashmap/table.rs b/src/libstd/collections/hashmap/table.rs index ee64a7931c062..ca20c3ddb74f0 100644 --- a/src/libstd/collections/hashmap/table.rs +++ b/src/libstd/collections/hashmap/table.rs @@ -470,7 +470,7 @@ impl BucketState { pub fn expect_full(self) -> FullBucket { match self { Full(full) => full, - Empty(..) => fail!("Expected full bucket") + Empty(..) => panic!("Expected full bucket") } } } diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index ed8ff821f5cad..c2f27caad1d9c 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -44,7 +44,7 @@ impl Drop for DynamicLibrary { } }) { Ok(()) => {}, - Err(str) => fail!("{}", str) + Err(str) => panic!("{}", str) } } } @@ -168,13 +168,13 @@ mod test { // statically linked in let none: Option = None; // appease the typechecker let libm = match DynamicLibrary::open(none) { - Err(error) => fail!("Could not load self as module: {}", error), + Err(error) => panic!("Could not load self as module: {}", error), Ok(libm) => libm }; let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe { match libm.symbol("cos") { - Err(error) => fail!("Could not load function cos: {}", error), + Err(error) => panic!("Could not load function cos: {}", error), Ok(cosine) => mem::transmute::<*mut u8, _>(cosine) } }; @@ -183,7 +183,7 @@ mod test { let expected_result = 1.0; let result = cosine(argument); if result != expected_result { - fail!("cos({}) != {} but equaled {} instead", argument, + panic!("cos({}) != {} but equaled {} instead", argument, expected_result, result) } } @@ -199,7 +199,7 @@ mod test { let path = Path::new("/dev/null"); match DynamicLibrary::open(Some(&path)) { Err(_) => {} - Ok(_) => fail!("Successfully opened the empty library.") + Ok(_) => panic!("Successfully opened the empty library.") } } } diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index a7de84184ff5d..0775997435641 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -51,11 +51,11 @@ pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) { // all times. This means that this `exists` will return true almost all of // the time. There are border cases, however, when the runtime has // *almost* set up the local task, but hasn't quite gotten there yet. In - // order to get some better diagnostics, we print on failure and + // order to get some better diagnostics, we print on panic and // immediately abort the whole process if there is no local task // available. if !Local::exists(None::) { - let _ = writeln!(&mut err, "failed at '{}', {}:{}", msg, file, line); + let _ = writeln!(&mut err, "panicked at '{}', {}:{}", msg, file, line); if backtrace::log_enabled() { let _ = backtrace::write(&mut err); } else { @@ -76,9 +76,9 @@ pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) { match local_stderr.replace(None) { Some(mut stderr) => { - // FIXME: what to do when the task printing fails? + // FIXME: what to do when the task printing panics? let _ = writeln!(stderr, - "task '{}' failed at '{}', {}:{}\n", + "task '{}' panicked at '{}', {}:{}\n", n, msg, file, line); if backtrace::log_enabled() { let _ = backtrace::write(&mut *stderr); @@ -86,7 +86,7 @@ pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) { local_stderr.replace(Some(stderr)); } None => { - let _ = writeln!(&mut err, "task '{}' failed at '{}', {}:{}", + let _ = writeln!(&mut err, "task '{}' panicked at '{}', {}:{}", n, msg, file, line); if backtrace::log_enabled() { let _ = backtrace::write(&mut err); @@ -94,8 +94,8 @@ pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) { } } - // If this is a double failure, make sure that we printed a backtrace - // for this failure. + // If this is a double panic, make sure that we printed a backtrace + // for this panic. if unwinding && !backtrace::log_enabled() { let _ = backtrace::write(&mut err); } diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 95c44e6a3fc89..9cd8dbcc50949 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -183,7 +183,7 @@ impl BufferedWriter { /// /// The buffer is flushed before returning the writer. pub fn unwrap(mut self) -> W { - // FIXME(#12628): is failing the right thing to do if flushing fails? + // FIXME(#12628): is panicking the right thing to do if flushing panicks? self.flush_buf().unwrap(); self.inner.take().unwrap() } @@ -214,7 +214,7 @@ impl Writer for BufferedWriter { impl Drop for BufferedWriter { fn drop(&mut self) { if self.inner.is_some() { - // dtors should not fail, so we ignore a failed flush + // dtors should not panic, so we ignore a panicked flush let _ = self.flush_buf(); } } @@ -612,7 +612,7 @@ mod test { #[test] #[should_fail] - fn dont_fail_in_drop_on_failed_flush() { + fn dont_panic_in_drop_on_panicked_flush() { struct FailFlushWriter; impl Writer for FailFlushWriter { @@ -623,9 +623,8 @@ mod test { let writer = FailFlushWriter; let _writer = BufferedWriter::new(writer); - // Trigger failure. If writer fails *again* due to the flush - // error then the process will abort. - fail!(); + // If writer panics *again* due to the flush error then the process will abort. + panic!(); } #[bench] diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index bd9577c8cfc8c..07f4ebda2d41a 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -188,14 +188,14 @@ mod test { assert_eq!(a, buf.as_slice()); match reader.read(buf.as_mut_slice()) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } assert_eq!(a, buf.as_slice()); - // Ensure it continues to fail in the same way. + // Ensure it continues to panic in the same way. match reader.read(buf.as_mut_slice()) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } assert_eq!(a, buf.as_slice()); @@ -218,7 +218,7 @@ mod test { assert_eq!(Ok("hello world\n".to_string()), reader.read_line()); assert_eq!(Ok("how are you?".to_string()), reader.read_line()); match reader.read_line() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } } @@ -232,12 +232,12 @@ mod test { let wanted = vec![0u8, 0u8, 0u8, 42u8]; let got = match task::try(proc() { rx.recv() }) { Ok(got) => got, - Err(_) => fail!(), + Err(_) => panic!(), }; assert_eq!(wanted, got); match writer.write_u8(1) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::BrokenPipe), } } diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index 57741db5ae218..a595921fcf72d 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -70,7 +70,7 @@ impl<'r, R: Reader> Iterator> for Bytes<'r, R> { /// /// * `n`: The value to convert. /// * `size`: The size of the value, in bytes. This must be 8 or less, or task -/// failure occurs. If this is less than 8, then a value of that +/// panic occurs. If this is less than 8, then a value of that /// many bytes is produced. For example, if `size` is 4, then a /// 32-bit byte representation is produced. /// * `f`: A callback that receives the value. @@ -109,7 +109,7 @@ pub fn u64_to_le_bytes(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// /// * `n`: The value to convert. /// * `size`: The size of the value, in bytes. This must be 8 or less, or task -/// failure occurs. If this is less than 8, then a value of that +/// panic occurs. If this is less than 8, then a value of that /// many bytes is produced. For example, if `size` is 4, then a /// 32-bit byte representation is produced. /// * `f`: A callback that receives the value. @@ -146,7 +146,7 @@ pub fn u64_to_be_bytes(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { /// * `data`: The buffer in which to extract the value. /// * `start`: The offset at which to extract the value. /// * `size`: The size of the value in bytes to extract. This must be 8 or -/// less, or task failure occurs. If this is less than 8, then only +/// less, or task panic occurs. If this is less than 8, then only /// that many bytes are parsed. For example, if `size` is 4, then a /// 32-bit value is parsed. pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { @@ -156,7 +156,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 { assert!(size <= 8u); if data.len() - start < size { - fail!("index out of bounds"); + panic!("index out of bounds"); } let mut buf = [0u8, ..8]; diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 8632fc63e52f8..f749d6c823ea3 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -105,7 +105,7 @@ impl File { /// /// let file = match File::open_mode(&p, Open, ReadWrite) { /// Ok(f) => f, - /// Err(e) => fail!("file error: {}", e), + /// Err(e) => panic!("file error: {}", e), /// }; /// // do some stuff with that file /// @@ -957,13 +957,13 @@ mod test { macro_rules! check( ($e:expr) => ( match $e { Ok(t) => t, - Err(e) => fail!("{} failed with: {}", stringify!($e), e), + Err(e) => panic!("{} failed with: {}", stringify!($e), e), } ) ) macro_rules! error( ($e:expr, $s:expr) => ( match $e { - Ok(val) => fail!("Unexpected success. Should've been: {}", $s), + Ok(val) => panic!("Unexpected success. Should've been: {}", $s), Err(ref err) => assert!(err.to_string().as_slice().contains($s.as_slice()), format!("`{}` did not contain `{}`", err, $s)) } @@ -1013,7 +1013,7 @@ mod test { let mut read_stream = File::open_mode(filename, Open, Read); let mut read_buf = [0, .. 1028]; let read_str = match check!(read_stream.read(read_buf)) { - -1|0 => fail!("shouldn't happen"), + -1|0 => panic!("shouldn't happen"), n => str::from_utf8(read_buf[..n]).unwrap().to_string() }; assert_eq!(read_str.as_slice(), message); @@ -1241,7 +1241,7 @@ mod test { check!(File::open(f).read(mem)); let read_str = str::from_utf8(mem).unwrap(); let expected = match n { - None|Some("") => fail!("really shouldn't happen.."), + None|Some("") => panic!("really shouldn't happen.."), Some(n) => format!("{}{}", prefix, n), }; assert_eq!(expected.as_slice(), read_str); @@ -1371,7 +1371,7 @@ mod test { from.display(), to.display())); match copy(&from, &to) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => { assert!(!from.exists()); assert!(!to.exists()); @@ -1400,7 +1400,7 @@ mod test { check!(File::create(&out)); match copy(&out, tmpdir.path()) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } } @@ -1424,7 +1424,7 @@ mod test { let out = tmpdir.join("out"); match copy(tmpdir.path(), &out) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } assert!(!out.exists()); } @@ -1475,7 +1475,7 @@ mod test { fn readlink_not_symlink() { let tmpdir = tmpdir(); match readlink(tmpdir.path()) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a failure"), Err(..) => {} } } @@ -1501,12 +1501,12 @@ mod test { // can't link to yourself match link(&input, &input) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a failure"), Err(..) => {} } // can't link to something that doesn't exist match link(&tmpdir.join("foo"), &tmpdir.join("bar")) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a failure"), Err(..) => {} } } @@ -1522,7 +1522,7 @@ mod test { assert!(!check!(stat(&file)).perm.contains(io::USER_WRITE)); match chmod(&tmpdir.join("foo"), io::USER_RWX) { - Ok(..) => fail!("wanted a failure"), + Ok(..) => panic!("wanted a panic"), Err(..) => {} } @@ -1580,7 +1580,7 @@ mod test { let tmpdir = tmpdir(); match File::open_mode(&tmpdir.join("a"), io::Open, io::Read) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } // Perform each one twice to make sure that it succeeds the second time @@ -1615,7 +1615,7 @@ mod test { let mut f = check!(File::open_mode(&tmpdir.join("h"), io::Open, io::Read)); match f.write("wut".as_bytes()) { - Ok(..) => fail!(), Err(..) => {} + Ok(..) => panic!(), Err(..) => {} } } assert!(check!(stat(&tmpdir.join("h"))).size == 3, @@ -1653,7 +1653,7 @@ mod test { let tmpdir = tmpdir(); match change_file_times(&tmpdir.join("a"), 100, 200) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => {} } } diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index dd4a3e0593594..2f6dd7e47955f 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -409,7 +409,7 @@ mod test { writer.write([0]).unwrap(); match writer.write([0, 0]) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::OtherIoError), } } @@ -510,7 +510,7 @@ mod test { let buf = [0xff]; let mut r = BufReader::new(buf); match r.read_to_string() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => {} } } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 8592d48974a25..7826a6dd9c68e 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1730,7 +1730,7 @@ pub enum FileType { /// # fn foo() { /// let info = match Path::new("foo.txt").stat() { /// Ok(stat) => stat, -/// Err(e) => fail!("couldn't read foo.txt: {}", e), +/// Err(e) => panic!("couldn't read foo.txt: {}", e), /// }; /// /// println!("byte size: {}", info.size); diff --git a/src/libstd/io/net/pipe.rs b/src/libstd/io/net/pipe.rs index e0cf761fdbd7e..112094d1d39b3 100644 --- a/src/libstd/io/net/pipe.rs +++ b/src/libstd/io/net/pipe.rs @@ -269,13 +269,13 @@ mod tests { spawn(proc() { match UnixStream::connect(&path2) { Ok(c) => client(c), - Err(e) => fail!("failed connect: {}", e), + Err(e) => panic!("failed connect: {}", e), } }); match acceptor.accept() { Ok(c) => server(c), - Err(e) => fail!("failed accept: {}", e), + Err(e) => panic!("failed accept: {}", e), } } @@ -283,7 +283,7 @@ mod tests { fn bind_error() { let path = "path/to/nowhere"; match UnixListener::bind(&path) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => { assert!(e.kind == PermissionDenied || e.kind == FileNotFound || e.kind == InvalidInput); @@ -299,7 +299,7 @@ mod tests { "path/to/nowhere" }; match UnixStream::connect(&path) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => { assert!(e.kind == FileNotFound || e.kind == OtherIoError); } @@ -358,7 +358,7 @@ mod tests { let mut acceptor = match UnixListener::bind(&path1).listen() { Ok(a) => a, - Err(e) => fail!("failed listen: {}", e), + Err(e) => panic!("failed listen: {}", e), }; spawn(proc() { @@ -366,7 +366,7 @@ mod tests { let mut stream = UnixStream::connect(&path2); match stream.write([100]) { Ok(..) => {} - Err(e) => fail!("failed write: {}", e) + Err(e) => panic!("failed write: {}", e) } } }); @@ -376,7 +376,7 @@ mod tests { let mut buf = [0]; match client.read(buf) { Ok(..) => {} - Err(e) => fail!("failed read/accept: {}", e), + Err(e) => panic!("failed read/accept: {}", e), } assert_eq!(buf[0], 100); } @@ -531,10 +531,10 @@ mod tests { match a.accept() { Ok(..) => break, Err(ref e) if e.kind == TimedOut => {} - Err(e) => fail!("error: {}", e), + Err(e) => panic!("error: {}", e), } ::task::deschedule(); - if i == 1000 { fail!("should have a pending connection") } + if i == 1000 { panic!("should have a pending connection") } } drop(l); @@ -659,9 +659,9 @@ mod tests { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } // I'm not sure as to why, but apparently the write on windows always @@ -687,7 +687,7 @@ mod tests { while amt < 100 * 128 * 1024 { match s.read([0, ..128 * 1024]) { Ok(n) => { amt += n; } - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } } let _ = rx.recv_opt(); @@ -722,9 +722,9 @@ mod tests { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } tx.send(()); diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index d6528ce977e98..09804ef570313 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -471,7 +471,7 @@ impl TcpAcceptor { /// match socket { /// Ok(s) => { /* handle s */ } /// Err(ref e) if e.kind == EndOfFile => break, // closed - /// Err(e) => fail!("unexpected error: {}", e), + /// Err(e) => panic!("unexpected error: {}", e), /// } /// } /// }); @@ -532,7 +532,7 @@ mod test { #[test] fn bind_error() { match TcpListener::bind("0.0.0.0", 1) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, PermissionDenied), } } @@ -540,7 +540,7 @@ mod test { #[test] fn connect_error() { match TcpStream::connect("0.0.0.0", 1) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, ConnectionRefused), } } @@ -708,7 +708,7 @@ mod test { assert!(nread.is_err()); match stream.read(buf) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(ref e) => { assert!(e.kind == NotConnected || e.kind == EndOfFile, "unknown kind: {}", e.kind); @@ -734,7 +734,7 @@ mod test { assert!(nread.is_err()); match stream.read(buf) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(ref e) => { assert!(e.kind == NotConnected || e.kind == EndOfFile, "unknown kind: {}", e.kind); @@ -1082,7 +1082,7 @@ mod test { let listener = TcpListener::bind(ip_str.as_slice(), port).unwrap().listen(); assert!(listener.is_ok()); match TcpListener::bind(ip_str.as_slice(), port).listen() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => { assert!(e.kind == ConnectionRefused || e.kind == OtherIoError, "unknown error: {} {}", e, e.kind); @@ -1266,10 +1266,10 @@ mod test { match a.accept() { Ok(..) => break, Err(ref e) if e.kind == TimedOut => {} - Err(e) => fail!("error: {}", e), + Err(e) => panic!("error: {}", e), } ::task::deschedule(); - if i == 1000 { fail!("should have a pending connection") } + if i == 1000 { panic!("should have a pending connection") } } } @@ -1373,9 +1373,9 @@ mod test { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } assert_eq!(s.write([0]).err().unwrap().kind, TimedOut); @@ -1398,7 +1398,7 @@ mod test { while amt < 100 * 128 * 1024 { match s.read([0, ..128 * 1024]) { Ok(n) => { amt += n; } - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } } let _ = rx.recv_opt(); @@ -1435,9 +1435,9 @@ mod test { match s.write([0, .. 128 * 1024]) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } - if i == 1000 { fail!("should have filled up?!"); } + if i == 1000 { panic!("should have filled up?!"); } } assert_eq!(s.write([0]).err().unwrap().kind, TimedOut); diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 7d9eea3a73279..ad9ed090a5ba6 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -43,7 +43,7 @@ use rt::rtio; /// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 }; /// let mut socket = match UdpSocket::bind(addr) { /// Ok(s) => s, -/// Err(e) => fail!("couldn't bind socket: {}", e), +/// Err(e) => panic!("couldn't bind socket: {}", e), /// }; /// /// let mut buf = [0, ..10]; @@ -271,7 +271,7 @@ mod test { fn bind_error() { let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 }; match UdpSocket::bind(addr) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, PermissionDenied), } } @@ -289,7 +289,7 @@ mod test { rx1.recv(); client.send_to([99], server_ip).unwrap() } - Err(..) => fail!() + Err(..) => panic!() } tx2.send(()); }); @@ -304,10 +304,10 @@ mod test { assert_eq!(buf[0], 99); assert_eq!(src, client_ip); } - Err(..) => fail!() + Err(..) => panic!() } } - Err(..) => fail!() + Err(..) => panic!() } rx2.recv(); } @@ -324,7 +324,7 @@ mod test { rx.recv(); client.send_to([99], server_ip).unwrap() } - Err(..) => fail!() + Err(..) => panic!() } }); @@ -338,10 +338,10 @@ mod test { assert_eq!(buf[0], 99); assert_eq!(src, client_ip); } - Err(..) => fail!() + Err(..) => panic!() } } - Err(..) => fail!() + Err(..) => panic!() } } @@ -362,7 +362,7 @@ mod test { let mut stream = client.connect(server_ip); stream.write(val).unwrap(); } - Err(..) => fail!() + Err(..) => panic!() } }; rx1.recv(); @@ -382,10 +382,10 @@ mod test { assert_eq!(nread, 1); assert_eq!(buf[0], 99); } - Err(..) => fail!(), + Err(..) => panic!(), } } - Err(..) => fail!() + Err(..) => panic!() } rx2.recv(); } @@ -406,7 +406,7 @@ mod test { rx1.recv(); stream.write([99]).unwrap(); } - Err(..) => fail!() + Err(..) => panic!() } tx2.send(()); }); @@ -422,10 +422,10 @@ mod test { assert_eq!(nread, 1); assert_eq!(buf[0], 99); } - Err(..) => fail!() + Err(..) => panic!() } } - Err(..) => fail!() + Err(..) => panic!() } rx2.recv(); } @@ -535,7 +535,7 @@ mod test { rx.recv(); match sock2.recv_from(buf) { Ok(..) => {} - Err(e) => fail!("failed receive: {}", e), + Err(e) => panic!("failed receive: {}", e), } serv_tx.send(()); }); @@ -612,7 +612,7 @@ mod test { match a.send_to([0, ..4*1024], addr2) { Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {}, Err(IoError { kind: TimedOut, .. }) => break, - Err(e) => fail!("other error: {}", e), + Err(e) => panic!("other error: {}", e), } } } diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 88f8434b9576e..36d235907046d 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -56,7 +56,7 @@ use std::hash::sip::SipState; /// /// let mut child = match Command::new("/bin/cat").arg("file.txt").spawn() { /// Ok(child) => child, -/// Err(e) => fail!("failed to execute child: {}", e), +/// Err(e) => panic!("failed to execute child: {}", e), /// }; /// /// let contents = child.stdout.as_mut().unwrap().read_to_end(); @@ -145,7 +145,7 @@ pub type EnvMap = HashMap; /// /// let mut process = match Command::new("sh").arg("-c").arg("echo hello").spawn() { /// Ok(p) => p, -/// Err(e) => fail!("failed to execute process: {}", e), +/// Err(e) => panic!("failed to execute process: {}", e), /// }; /// /// let output = process.stdout.as_mut().unwrap().read_to_end(); @@ -372,7 +372,7 @@ impl Command { /// /// let output = match Command::new("cat").arg("foot.txt").output() { /// Ok(output) => output, - /// Err(e) => fail!("failed to execute process: {}", e), + /// Err(e) => panic!("failed to execute process: {}", e), /// }; /// /// println!("status: {}", output.status); @@ -393,7 +393,7 @@ impl Command { /// /// let status = match Command::new("ls").status() { /// Ok(status) => status, - /// Err(e) => fail!("failed to execute process: {}", e), + /// Err(e) => panic!("failed to execute process: {}", e), /// }; /// /// println!("process exited with: {}", status); @@ -691,7 +691,7 @@ mod tests { #[test] fn smoke_failure() { match Command::new("if-this-is-a-binary-then-the-world-has-ended").spawn() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(..) => {} } } @@ -714,7 +714,7 @@ mod tests { let mut p = p.unwrap(); match p.wait().unwrap() { process::ExitSignal(1) => {}, - result => fail!("not terminated by signal 1 (instead, {})", result), + result => panic!("not terminated by signal 1 (instead, {})", result), } } @@ -815,7 +815,7 @@ mod tests { fn test_process_output_fail_to_start() { match Command::new("/no-binary-by-this-name-should-exist").output() { Err(e) => assert_eq!(e.kind, FileNotFound), - Ok(..) => fail!() + Ok(..) => panic!() } } @@ -1063,7 +1063,7 @@ mod tests { } timer::sleep(Duration::milliseconds(100)); } - fail!("never saw the child go away"); + panic!("never saw the child go away"); } #[test] @@ -1121,7 +1121,7 @@ mod tests { let mut fdes = match file::open(&path.to_c_str(), Truncate, Write) { Ok(f) => f, - Err(_) => fail!("failed to open file descriptor"), + Err(_) => panic!("failed to open file descriptor"), }; let mut cmd = pwd_cmd(); diff --git a/src/libstd/io/result.rs b/src/libstd/io/result.rs index 03637079241d6..40793d98ee3b8 100644 --- a/src/libstd/io/result.rs +++ b/src/libstd/io/result.rs @@ -96,11 +96,11 @@ mod test { Err(io::standard_error(io::EndOfFile)); match writer.write([0, 0, 0]) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } match writer.flush() { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } } @@ -122,7 +122,7 @@ mod test { let mut buf = []; match reader.read(buf) { - Ok(..) => fail!(), + Ok(..) => panic!(), Err(e) => assert_eq!(e.kind, io::EndOfFile), } } diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 93037f765d635..5fd4faff6d250 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -176,8 +176,8 @@ pub fn set_stdout(stdout: Box) -> Option> { /// Resets the task-local stderr handle to the specified writer /// /// This will replace the current task's stderr handle, returning the old -/// handle. Currently, the stderr handle is used for printing failure messages -/// during task failure. +/// handle. Currently, the stderr handle is used for printing panic messages +/// during task panic. /// /// Note that this does not need to be called for all new tasks; the default /// output handle is to the process's stderr stream. @@ -212,7 +212,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()>) { }; match result { Ok(()) => {} - Err(e) => fail!("failed printing to stdout: {}", e), + Err(e) => panic!("failed printing to stdout: {}", e), } } @@ -415,7 +415,7 @@ mod tests { let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); spawn(proc() { ::realstd::io::stdio::set_stderr(box w); - fail!("my special message"); + panic!("my special message"); }); let s = r.read_to_string().unwrap(); assert!(s.as_slice().contains("my special message")); diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index 9b4333a6d8298..6571dc41585bb 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -139,14 +139,14 @@ mod darwin_fd_limit { if sysctl(&mut mib[0], 2, &mut maxfiles as *mut libc::c_int as *mut libc::c_void, &mut size, null_mut(), 0) != 0 { let err = last_os_error(); - fail!("raise_fd_limit: error calling sysctl: {}", err); + panic!("raise_fd_limit: error calling sysctl: {}", err); } // Fetch the current resource limits let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0}; if getrlimit(RLIMIT_NOFILE, &mut rlim) != 0 { let err = last_os_error(); - fail!("raise_fd_limit: error calling getrlimit: {}", err); + panic!("raise_fd_limit: error calling getrlimit: {}", err); } // Bump the soft limit to the smaller of kern.maxfilesperproc and the hard limit @@ -155,7 +155,7 @@ mod darwin_fd_limit { // Set our newly-increased resource limit if setrlimit(RLIMIT_NOFILE, &rlim) != 0 { let err = last_os_error(); - fail!("raise_fd_limit: error calling setrlimit: {}", err); + panic!("raise_fd_limit: error calling setrlimit: {}", err); } } } diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index a657989fe1244..d16199da77fcd 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -340,7 +340,7 @@ mod test { fn oneshot_fail() { let mut timer = Timer::new().unwrap(); let _rx = timer.oneshot(Duration::milliseconds(1)); - fail!(); + panic!(); } #[test] @@ -348,14 +348,14 @@ mod test { fn period_fail() { let mut timer = Timer::new().unwrap(); let _rx = timer.periodic(Duration::milliseconds(1)); - fail!(); + panic!(); } #[test] #[should_fail] fn normal_fail() { let _timer = Timer::new().unwrap(); - fail!(); + panic!(); } #[test] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index c47cd02599485..5451d07ab4685 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -91,7 +91,7 @@ //! Finally, the [`prelude`](prelude/index.html) defines a //! common set of traits, types, and functions that are made available //! to all code by default. [`macros`](macros/index.html) contains -//! all the standard macros, such as `assert!`, `fail!`, `println!`, +//! all the standard macros, such as `assert!`, `panic!`, `println!`, //! and `format!`, also available to all Rust code. #![crate_name = "std"] @@ -261,7 +261,7 @@ mod std { pub use io; // used for println!() pub use local_data; // used for local_data_key!() pub use option; // used for bitflags!{} - pub use rt; // used for fail!() + pub use rt; // used for panic!() pub use vec; // used for vec![] // The test runner calls ::std::os::args() but really wants realstd diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 1ad3d6eed9420..9e0530a76f257 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -17,29 +17,29 @@ #![experimental] #![macro_escape] -/// The entry point for failure of rust tasks. +/// The entry point for panic of Rust tasks. /// -/// This macro is used to inject failure into a rust task, causing the task to -/// unwind and fail entirely. Each task's failure can be reaped as the -/// `Box` type, and the single-argument form of the `fail!` macro will be +/// This macro is used to inject panic into a Rust task, causing the task to +/// unwind and panic entirely. Each task's panic can be reaped as the +/// `Box` type, and the single-argument form of the `panic!` macro will be /// the value which is transmitted. /// -/// The multi-argument form of this macro fails with a string and has the +/// The multi-argument form of this macro panics with a string and has the /// `format!` syntax for building a string. /// /// # Example /// /// ```should_fail /// # #![allow(unreachable_code)] -/// fail!(); -/// fail!("this is a terrible mistake!"); -/// fail!(4i); // fail with the value of 4 to be collected elsewhere -/// fail!("this is a {} {message}", "fancy", message = "message"); +/// panic!(); +/// panic!("this is a terrible mistake!"); +/// panic!(4i); // panic with the value of 4 to be collected elsewhere +/// panic!("this is a {} {message}", "fancy", message = "message"); /// ``` #[macro_export] -macro_rules! fail( +macro_rules! panic( () => ({ - fail!("explicit failure") + panic!("explicit panic") }); ($msg:expr) => ({ // static requires less code at runtime, more constant data @@ -57,7 +57,7 @@ macro_rules! fail( // as returning !. We really do want this to be inlined, however, // because it's just a tiny wrapper. Small wins (156K to 149K in size) // were seen when forcing this to be inlined, and that number just goes - // up with the number of calls to fail!() + // up with the number of calls to panic!() // // The leading _'s are to avoid dead code warnings if this is // used inside a dead function. Just `#[allow(dead_code)]` is @@ -74,13 +74,13 @@ macro_rules! fail( /// Ensure that a boolean expression is `true` at runtime. /// -/// This will invoke the `fail!` macro if the provided expression cannot be +/// This will invoke the `panic!` macro if the provided expression cannot be /// evaluated to `true` at runtime. /// /// # Example /// /// ``` -/// // the failure message for these assertions is the stringified value of the +/// // the panic message for these assertions is the stringified value of the /// // expression given. /// assert!(true); /// # fn some_computation() -> bool { true } @@ -96,12 +96,12 @@ macro_rules! fail( macro_rules! assert( ($cond:expr) => ( if !$cond { - fail!(concat!("assertion failed: ", stringify!($cond))) + panic!(concat!("assertion failed: ", stringify!($cond))) } ); ($cond:expr, $($arg:expr),+) => ( if !$cond { - fail!($($arg),+) + panic!($($arg),+) } ); ) @@ -109,7 +109,7 @@ macro_rules! assert( /// Asserts that two expressions are equal to each other, testing equality in /// both directions. /// -/// On failure, this macro will print the values of the expressions. +/// On panic, this macro will print the values of the expressions. /// /// # Example /// @@ -126,7 +126,7 @@ macro_rules! assert_eq( // check both directions of equality.... if !((*given_val == *expected_val) && (*expected_val == *given_val)) { - fail!("assertion failed: `(left == right) && (right == left)` \ + panic!("assertion failed: `(left == right) && (right == left)` \ (left: `{}`, right: `{}`)", *given_val, *expected_val) } } @@ -136,7 +136,7 @@ macro_rules! assert_eq( /// Ensure that a boolean expression is `true` at runtime. /// -/// This will invoke the `fail!` macro if the provided expression cannot be +/// This will invoke the `panic!` macro if the provided expression cannot be /// evaluated to `true` at runtime. /// /// Unlike `assert!`, `debug_assert!` statements can be disabled by passing @@ -147,7 +147,7 @@ macro_rules! assert_eq( /// # Example /// /// ``` -/// // the failure message for these assertions is the stringified value of the +/// // the panic message for these assertions is the stringified value of the /// // expression given. /// debug_assert!(true); /// # fn some_expensive_computation() -> bool { true } @@ -167,7 +167,7 @@ macro_rules! debug_assert( /// Asserts that two expressions are equal to each other, testing equality in /// both directions. /// -/// On failure, this macro will print the values of the expressions. +/// On panic, this macro will print the values of the expressions. /// /// Unlike `assert_eq!`, `debug_assert_eq!` statements can be disabled by /// passing `--cfg ndebug` to the compiler. This makes `debug_assert_eq!` @@ -186,7 +186,7 @@ macro_rules! debug_assert_eq( ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert_eq!($($arg)*); }) ) -/// A utility macro for indicating unreachable code. It will fail if +/// A utility macro for indicating unreachable code. It will panic if /// executed. This is occasionally useful to put after loops that never /// terminate normally, but instead directly return from a function. /// @@ -211,14 +211,14 @@ macro_rules! debug_assert_eq( /// ``` #[macro_export] macro_rules! unreachable( - () => (fail!("internal error: entered unreachable code")) + () => (panic!("internal error: entered unreachable code")) ) -/// A standardised placeholder for marking unfinished code. It fails with the +/// A standardised placeholder for marking unfinished code. It panics with the /// message `"not yet implemented"` when executed. #[macro_export] macro_rules! unimplemented( - () => (fail!("not yet implemented")) + () => (panic!("not yet implemented")) ) /// Use the syntax described in `std::fmt` to create a value of type `String`. diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index af66e6ca93490..6e0d81a63c951 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -264,10 +264,10 @@ pub fn float_to_str_bytes_common= DIGIT_E_RADIX // decimal exponent 'e' - => fail!("float_to_str_bytes_common: radix {} incompatible with \ + => panic!("float_to_str_bytes_common: radix {} incompatible with \ use of 'e' as decimal exponent", radix), ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p' - => fail!("float_to_str_bytes_common: radix {} incompatible with \ + => panic!("float_to_str_bytes_common: radix {} incompatible with \ use of 'p' as binary exponent", radix), _ => () } @@ -553,19 +553,19 @@ pub fn from_str_bytes_common+ ) -> Option { match exponent { ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e' - => fail!("from_str_bytes_common: radix {} incompatible with \ + => panic!("from_str_bytes_common: radix {} incompatible with \ use of 'e' as decimal exponent", radix), ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p' - => fail!("from_str_bytes_common: radix {} incompatible with \ + => panic!("from_str_bytes_common: radix {} incompatible with \ use of 'p' as binary exponent", radix), _ if special && radix >= DIGIT_I_RADIX // first digit of 'inf' - => fail!("from_str_bytes_common: radix {} incompatible with \ + => panic!("from_str_bytes_common: radix {} incompatible with \ special values 'inf' and 'NaN'", radix), _ if (radix as int) < 2 - => fail!("from_str_bytes_common: radix {} to low, \ + => panic!("from_str_bytes_common: radix {} to low, \ must lie in the range [2, 36]", radix), _ if (radix as int) > 36 - => fail!("from_str_bytes_common: radix {} to high, \ + => panic!("from_str_bytes_common: radix {} to high, \ must lie in the range [2, 36]", radix), _ => () } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index e758dec6bff94..c7994ae84e848 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -96,7 +96,7 @@ pub fn getcwd() -> Path { let mut buf = [0 as c_char, ..BUF_BYTES]; unsafe { if libc::getcwd(buf.as_mut_ptr(), buf.len() as libc::size_t).is_null() { - fail!() + panic!() } Path::new(CString::new(buf.as_ptr(), false)) } @@ -130,7 +130,7 @@ pub fn getcwd() -> Path { let mut buf = [0 as u16, ..BUF_BYTES]; unsafe { if libc::GetCurrentDirectoryW(buf.len() as DWORD, buf.as_mut_ptr()) == 0 as DWORD { - fail!(); + panic!(); } } Path::new(String::from_utf16(::str::truncate_utf16_at_nul(buf)) @@ -238,7 +238,7 @@ pub fn env_as_bytes() -> Vec<(Vec,Vec)> { }; let ch = GetEnvironmentStringsW(); if ch as uint == 0 { - fail!("os::env() failure getting env string from OS: {}", + panic!("os::env() failure getting env string from OS: {}", os::last_os_error()); } // Here, we lossily decode the string as UTF16. @@ -280,7 +280,7 @@ pub fn env_as_bytes() -> Vec<(Vec,Vec)> { } let mut environ = rust_env_pairs(); if environ as uint == 0 { - fail!("os::env() failure getting env string from OS: {}", + panic!("os::env() failure getting env string from OS: {}", os::last_os_error()); } let mut result = Vec::new(); @@ -1009,7 +1009,7 @@ pub fn error_string(errnum: uint) -> String { let p = buf.as_mut_ptr(); unsafe { if strerror_r(errnum as c_int, p, buf.len() as libc::size_t) < 0 { - fail!("strerror_r failure"); + panic!("strerror_r failure"); } ::string::raw::from_buf(p as *const u8) @@ -1079,9 +1079,9 @@ static EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT; * Sets the process exit code * * Sets the exit code returned by the process if all supervised tasks - * terminate successfully (without failing). If the current root task fails + * terminate successfully (without panicking). If the current root task panics * and is supervised by the scheduler then any user-specified exit status is - * ignored and the process exits with the default failure status. + * ignored and the process exits with the default panic status. * * Note that this is not synchronized against modifications of other threads. */ @@ -1185,7 +1185,7 @@ fn real_args_as_bytes() -> Vec> { match rt::args::clone() { Some(args) => args, - None => fail!("process arguments not initialized") + None => panic!("process arguments not initialized") } } @@ -1511,12 +1511,12 @@ impl MemoryMap { #[cfg(unix)] impl Drop for MemoryMap { - /// Unmap the mapping. Fails the task if `munmap` fails. + /// Unmap the mapping. Panics the task if `munmap` panics. fn drop(&mut self) { if self.len == 0 { /* workaround for dummy_stack */ return; } unsafe { - // `munmap` only fails due to logic errors + // `munmap` only panics due to logic errors libc::munmap(self.data as *mut c_void, self.len as libc::size_t); } } @@ -2098,7 +2098,7 @@ mod tests { os::MapWritable ]) { Ok(chunk) => chunk, - Err(msg) => fail!("{}", msg) + Err(msg) => panic!("{}", msg) }; assert!(chunk.len >= 16); @@ -2147,7 +2147,7 @@ mod tests { MapOffset(size / 2) ]) { Ok(chunk) => chunk, - Err(msg) => fail!("{}", msg) + Err(msg) => panic!("{}", msg) }; assert!(chunk.len > 0); diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 4456cf9609428..1897c8638cc69 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -1343,7 +1343,7 @@ mod tests { #[test] #[should_fail] - fn test_not_utf8_fail() { + fn test_not_utf8_panics() { Path::new(b"hello\x80.txt"); } diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 29eae0ced5412..d1c655cb4d0bb 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -297,7 +297,7 @@ impl<'a> SeedableRng<&'a [uint]> for StdRng { pub fn weak_rng() -> XorShiftRng { match OsRng::new() { Ok(mut r) => r.gen(), - Err(e) => fail!("weak_rng: failed to create seeded RNG: {}", e) + Err(e) => panic!("weak_rng: failed to create seeded RNG: {}", e) } } @@ -308,7 +308,7 @@ impl reseeding::Reseeder for TaskRngReseeder { fn reseed(&mut self, rng: &mut StdRng) { *rng = match StdRng::new() { Ok(r) => r, - Err(e) => fail!("could not reseed task_rng: {}", e) + Err(e) => panic!("could not reseed task_rng: {}", e) } } } @@ -339,7 +339,7 @@ pub fn task_rng() -> TaskRng { None => { let r = match StdRng::new() { Ok(r) => r, - Err(e) => fail!("could not initialize task_rng: {}", e) + Err(e) => panic!("could not initialize task_rng: {}", e) }; let rng = reseeding::ReseedingRng::new(r, TASK_RNG_RESEED_THRESHOLD, @@ -445,7 +445,7 @@ mod test { // use this to get nicer error messages. for (i, &byte) in v.iter().enumerate() { if byte == 0 { - fail!("byte {} of {} is zero", i, n) + panic!("byte {} of {} is zero", i, n) } } } @@ -472,14 +472,14 @@ mod test { #[test] #[should_fail] - fn test_gen_range_fail_int() { + fn test_gen_range_panic_int() { let mut r = task_rng(); r.gen_range(5i, -2); } #[test] #[should_fail] - fn test_gen_range_fail_uint() { + fn test_gen_range_panic_uint() { let mut r = task_rng(); r.gen_range(5u, 2u); } diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 91308be21edbd..424fd039fd4c4 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -120,7 +120,7 @@ mod imp { SecRandomCopyBytes(kSecRandomDefault, v.len() as size_t, v.as_mut_ptr()) }; if ret == -1 { - fail!("couldn't generate random bytes: {}", os::last_os_error()); + panic!("couldn't generate random bytes: {}", os::last_os_error()); } } } @@ -208,7 +208,7 @@ mod imp { v.as_mut_ptr()) }; if ret == 0 { - fail!("couldn't generate random bytes: {}", os::last_os_error()); + panic!("couldn't generate random bytes: {}", os::last_os_error()); } } } @@ -219,7 +219,7 @@ mod imp { CryptReleaseContext(self.hcryptprov, 0) }; if ret == 0 { - fail!("couldn't release context: {}", os::last_os_error()); + panic!("couldn't release context: {}", os::last_os_error()); } } } diff --git a/src/libstd/rand/reader.rs b/src/libstd/rand/reader.rs index 8ca1cec3e0ae9..4f2205312373c 100644 --- a/src/libstd/rand/reader.rs +++ b/src/libstd/rand/reader.rs @@ -18,7 +18,9 @@ use result::{Ok, Err}; /// An RNG that reads random bytes straight from a `Reader`. This will /// work best with an infinite reader, but this is not required. /// -/// It will fail if it there is insufficient data to fulfill a request. +/// # Panics +/// +/// It will panic if it there is insufficient data to fulfill a request. /// /// # Example /// @@ -65,7 +67,7 @@ impl Rng for ReaderRng { if v.len() == 0 { return } match self.reader.read_at_least(v.len(), v) { Ok(_) => {} - Err(e) => fail!("ReaderRng.fill_bytes error: {}", e) + Err(e) => panic!("ReaderRng.fill_bytes error: {}", e) } } } diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index e05e533be56c5..5bd3927727574 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Simple backtrace functionality (to print on failure) +//! Simple backtrace functionality (to print on panic) #![allow(non_camel_case_types)] @@ -265,7 +265,7 @@ mod imp { // while it doesn't requires lock for work as everything is // local, it still displays much nicer backtraces when a - // couple of tasks fail simultaneously + // couple of tasks panic simultaneously static LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT; let _g = unsafe { LOCK.lock() }; @@ -327,7 +327,7 @@ mod imp { // FindEnclosingFunction on non-osx platforms. In doing so, we get a // slightly more accurate stack trace in the process. // - // This is often because failure involves the last instruction of a + // This is often because panic involves the last instruction of a // function being "call std::rt::begin_unwind", with no ret // instructions after it. This means that the return instruction // pointer points *outside* of the calling function, and by diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index a91c6c572e686..e36d4ce8d4b74 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -67,7 +67,7 @@ pub use rustrt::{task, local, mutex, exclusive, stack, args, rtio, thread}; pub use rustrt::{Stdio, Stdout, Stderr, begin_unwind, begin_unwind_fmt}; pub use rustrt::{bookkeeping, at_exit, unwind, DEFAULT_ERROR_CODE, Runtime}; -// Simple backtrace functionality (to print on failure) +// Simple backtrace functionality (to print on panic) pub mod backtrace; // Just stuff diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index ec301369804ed..56f2dbf667a7c 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -62,7 +62,7 @@ pub fn default_sched_threads() -> uint { let opt_n: Option = FromStr::from_str(nstr.as_slice()); match opt_n { Some(n) if n > 0 => n, - _ => fail!("`RUST_THREADS` is `{}`, should be a positive integer", nstr) + _ => panic!("`RUST_THREADS` is `{}`, should be a positive integer", nstr) } } None => { diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 621c08fe7bcc0..3607050943270 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -58,7 +58,7 @@ impl Future { let state = replace(&mut self.state, Evaluating); match state { Forced(v) => v, - _ => fail!( "Logic error." ), + _ => panic!( "Logic error." ), } } @@ -70,10 +70,10 @@ impl Future { */ match self.state { Forced(ref v) => return v, - Evaluating => fail!("Recursive forcing of future!"), + Evaluating => panic!("Recursive forcing of future!"), Pending(_) => { match replace(&mut self.state, Evaluating) { - Forced(_) | Evaluating => fail!("Logic error."), + Forced(_) | Evaluating => panic!("Logic error."), Pending(f) => { self.state = Forced(f()); self.get_ref() @@ -132,7 +132,7 @@ impl Future { let (tx, rx) = channel(); spawn(proc() { - // Don't fail if the other end has hung up + // Don't panic if the other end has hung up let _ = tx.send_opt(blk()); }); @@ -193,8 +193,8 @@ mod test { #[test] #[should_fail] - fn test_futurefail() { - let mut f = Future::spawn(proc() fail!()); + fn test_future_panic() { + let mut f = Future::spawn(proc() panic!()); let _x: String = f.get(); } @@ -211,7 +211,7 @@ mod test { } #[test] - fn test_dropped_future_doesnt_fail() { + fn test_dropped_future_doesnt_panic() { struct Bomb(Sender); local_data_key!(LOCAL: Bomb) @@ -224,13 +224,13 @@ mod test { } // Spawn a future, but drop it immediately. When we receive the result - // later on, we should never view the task as having failed. + // later on, we should never view the task as having panicked. let (tx, rx) = channel(); drop(Future::spawn(proc() { LOCAL.replace(Some(Bomb(tx))); })); - // Make sure the future didn't fail the task. + // Make sure the future didn't panic the task. assert!(!rx.recv()); } } diff --git a/src/libstd/sync/task_pool.rs b/src/libstd/sync/task_pool.rs index a00eeb1f93838..d4a60fb584457 100644 --- a/src/libstd/sync/task_pool.rs +++ b/src/libstd/sync/task_pool.rs @@ -42,9 +42,9 @@ impl TaskPool { /// `init_fn_factory` returns a function which, given the index of the /// task, should return local data to be kept around in that task. /// - /// # Failure + /// # Panics /// - /// This function will fail if `n_tasks` is less than 1. + /// This function will panic if `n_tasks` is less than 1. pub fn new(n_tasks: uint, init_fn_factory: || -> proc(uint):Send -> T) -> TaskPool { @@ -96,7 +96,7 @@ fn test_task_pool() { #[test] #[should_fail] -fn test_zero_tasks_failure() { +fn test_zero_tasks_panic() { let f: || -> proc(uint):Send -> uint = || { proc(i) i }; TaskPool::new(0, f); } diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 1d1e6ae4febfd..c79b8715c06c2 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -28,12 +28,12 @@ //! using the atomically-reference-counted container, //! [`Arc`](../../std/sync/struct.Arc.html). //! -//! Fatal logic errors in Rust cause *task failure*, during which +//! Fatal logic errors in Rust cause *task panic*, during which //! a task will unwind the stack, running destructors and freeing -//! owned resources. Task failure is unrecoverable from within -//! the failing task (i.e. there is no 'try/catch' in Rust), but -//! failure may optionally be detected from a different task. If -//! the main task fails the application will exit with a non-zero +//! owned resources. Task panic is unrecoverable from within +//! the panicking task (i.e. there is no 'try/catch' in Rust), but +//! panic may optionally be detected from a different task. If +//! the main task panics the application will exit with a non-zero //! exit code. //! //! # Basic task scheduling @@ -123,7 +123,7 @@ impl Spawner for SiblingSpawner { let tb: Option> = Local::try_take(); match tb { Some(t) => t.spawn_sibling(opts, f), - None => fail!("need a local task to spawn a sibling task"), + None => panic!("need a local task to spawn a sibling task"), }; } } @@ -140,7 +140,7 @@ impl Spawner for SiblingSpawner { // sidestep that whole issue by making builders uncopyable and making // the run function move them in. pub struct TaskBuilder { - // A name for the task-to-be, for identification in failure messages + // A name for the task-to-be, for identification in panic messages name: Option, // The size of the stack for the spawned task stack_size: Option, @@ -173,7 +173,7 @@ impl TaskBuilder { impl TaskBuilder { /// Name the task-to-be. Currently the name is used for identification - /// only in failure messages. + /// only in panic messages. #[unstable = "IntoMaybeOwned will probably change."] pub fn named>(mut self, name: T) -> TaskBuilder { self.name = Some(name.into_maybe_owned()); @@ -269,10 +269,10 @@ impl TaskBuilder { /// /// # Return value /// - /// If the child task executes successfully (without failing) then the + /// If the child task executes successfully (without panicking) then the /// future returns `result::Ok` containing the value returned by the - /// function. If the child task fails then the future returns `result::Err` - /// containing the argument to `fail!(...)` as an `Any` trait object. + /// function. If the child task panics then the future returns `result::Err` + /// containing the argument to `panic!(...)` as an `Any` trait object. #[experimental = "Futures are experimental."] pub fn try_future(self, f: proc():Send -> T) -> Future>> { @@ -293,7 +293,7 @@ impl TaskBuilder { } /// Execute a function in a newly-spawnedtask and block until the task - /// completes or fails. Equivalent to `.try_future(f).unwrap()`. + /// completes or panics. Equivalent to `.try_future(f).unwrap()`. #[unstable = "Error type may change."] pub fn try(self, f: proc():Send -> T) -> Result> { self.try_future(f).unwrap() @@ -313,7 +313,7 @@ pub fn spawn(f: proc(): Send) { } /// Execute a function in a newly-spawned task and return either the return -/// value of the function or an error if the task failed. +/// value of the function or an error if the task panicked. /// /// This is equivalent to `TaskBuilder::new().try`. #[unstable = "Error type may change."] @@ -355,8 +355,8 @@ pub fn deschedule() { task.yield_now(); } -/// True if the running task is currently failing (e.g. will return `true` inside a -/// destructor that is run while unwinding the stack after a call to `fail!()`). +/// True if the running task is currently panicking (e.g. will return `true` inside a +/// destructor that is run while unwinding the stack after a call to `panic!()`). #[unstable = "May move to a different module."] pub fn failing() -> bool { use rt::task::Task; @@ -420,7 +420,7 @@ mod test { assert!(result.unwrap().is_ok()); let result = TaskBuilder::new().try_future(proc() -> () { - fail!(); + panic!(); }); assert!(result.unwrap().is_err()); } @@ -431,17 +431,17 @@ mod test { "Success!".to_string() }).as_ref().map(|s| s.as_slice()) { result::Ok("Success!") => (), - _ => fail!() + _ => panic!() } } #[test] - fn test_try_fail() { + fn test_try_panic() { match try(proc() { - fail!() + panic!() }) { result::Err(_) => (), - result::Ok(()) => fail!() + result::Ok(()) => panic!() } } @@ -541,37 +541,37 @@ mod test { } #[test] - fn test_try_fail_message_static_str() { + fn test_try_panic_message_static_str() { match try(proc() { - fail!("static string"); + panic!("static string"); }) { Err(e) => { type T = &'static str; assert!(e.is::()); assert_eq!(*e.downcast::().unwrap(), "static string"); } - Ok(()) => fail!() + Ok(()) => panic!() } } #[test] - fn test_try_fail_message_owned_str() { + fn test_try_panic_message_owned_str() { match try(proc() { - fail!("owned string".to_string()); + panic!("owned string".to_string()); }) { Err(e) => { type T = String; assert!(e.is::()); assert_eq!(*e.downcast::().unwrap(), "owned string".to_string()); } - Ok(()) => fail!() + Ok(()) => panic!() } } #[test] - fn test_try_fail_message_any() { + fn test_try_panic_message_any() { match try(proc() { - fail!(box 413u16 as Box); + panic!(box 413u16 as Box); }) { Err(e) => { type T = Box; @@ -580,19 +580,19 @@ mod test { assert!(any.is::()); assert_eq!(*any.downcast::().unwrap(), 413u16); } - Ok(()) => fail!() + Ok(()) => panic!() } } #[test] - fn test_try_fail_message_unit_struct() { + fn test_try_panic_message_unit_struct() { struct Juju; match try(proc() { - fail!(Juju) + panic!(Juju) }) { Err(ref e) if e.is::() => {} - Err(_) | Ok(()) => fail!() + Err(_) | Ok(()) => panic!() } } diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 751eb00bfaecc..c8b01ce1055bd 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -107,7 +107,7 @@ impl Duration { pub fn seconds(seconds: i64) -> Duration { let d = Duration { secs: seconds, nanos: 0 }; if d < MIN || d > MAX { - fail!("Duration::seconds out of bounds"); + panic!("Duration::seconds out of bounds"); } d } diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index ddfd1088a41a8..247f50d666e14 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -46,13 +46,13 @@ //! ## Failure Propagation //! //! In addition to being a core primitive for communicating in rust, channels -//! are the points at which failure is propagated among tasks. Whenever the one +//! are the points at which panics are propagated among tasks. Whenever the one //! half of channel is closed, the other half will have its next operation -//! `fail!`. The purpose of this is to allow propagation of failure among tasks +//! `panic!`. The purpose of this is to allow propagation of panics among tasks //! that are linked to one another via channels. //! //! There are methods on both of senders and receivers to perform their -//! respective operations without failing, however. +//! respective operations without panicking, however. //! //! ## Runtime Requirements //! @@ -102,10 +102,10 @@ //! } //! ``` //! -//! Propagating failure: +//! Propagating panics: //! //! ```should_fail -//! // The call to recv() will fail!() because the channel has already hung +//! // The call to recv() will panic!() because the channel has already hung //! // up (or been deallocated) //! let (tx, rx) = channel::(); //! drop(tx); @@ -506,7 +506,7 @@ pub fn channel() -> (Sender, Receiver) { /// becomes "rendezvous channel" where each send will not return until a recv /// is paired with it. /// -/// As with asynchronous channels, all senders will fail in `send` if the +/// As with asynchronous channels, all senders will panic in `send` if the /// `Receiver` has been destroyed. /// /// # Example @@ -550,25 +550,25 @@ impl Sender { /// /// Rust channels are infinitely buffered so this method will never block. /// - /// # Failure + /// # Panics /// - /// This function will fail if the other end of the channel has hung up. + /// This function will panic if the other end of the channel has hung up. /// This means that if the corresponding receiver has fallen out of scope, - /// this function will trigger a fail message saying that a message is + /// this function will trigger a panic message saying that a message is /// being sent on a closed channel. /// - /// Note that if this function does *not* fail, it does not mean that the + /// Note that if this function does *not* panic, it does not mean that the /// data will be successfully received. All sends are placed into a queue, /// so it is possible for a send to succeed (the other end is alive), but /// then the other end could immediately disconnect. /// - /// The purpose of this functionality is to propagate failure among tasks. - /// If failure is not desired, then consider using the `send_opt` method + /// The purpose of this functionality is to propagate panicks among tasks. + /// If a panic is not desired, then consider using the `send_opt` method #[experimental = "this function is being considered candidate for removal \ to adhere to the general guidelines of rust"] pub fn send(&self, t: T) { if self.send_opt(t).is_err() { - fail!("sending on a closed channel"); + panic!("sending on a closed channel"); } } @@ -585,9 +585,9 @@ impl Sender { /// /// Like `send`, this method will never block. /// - /// # Failure + /// # Panics /// - /// This method will never fail, it will return the message back to the + /// This method will never panic, it will return the message back to the /// caller if the other end is disconnected /// /// # Example @@ -634,7 +634,7 @@ impl Sender { } oneshot::UpDisconnected => (a, Err(t)), oneshot::UpWoke(task) => { - // This send cannot fail because the task is + // This send cannot panic because the task is // asleep (we're looking at it), so the receiver // can't go away. (*a.get()).send(t).ok().unwrap(); @@ -731,20 +731,20 @@ impl SyncSender { /// time. If the buffer size is 0, however, it can be guaranteed that the /// receiver has indeed received the data if this function returns success. /// - /// # Failure + /// # Panics /// - /// Similarly to `Sender::send`, this function will fail if the + /// Similarly to `Sender::send`, this function will panic if the /// corresponding `Receiver` for this channel has disconnected. This - /// behavior is used to propagate failure among tasks. + /// behavior is used to propagate panics among tasks. /// - /// If failure is not desired, you can achieve the same semantics with the - /// `SyncSender::send_opt` method which will not fail if the receiver + /// If a panic is not desired, you can achieve the same semantics with the + /// `SyncSender::send_opt` method which will not panic if the receiver /// disconnects. #[experimental = "this function is being considered candidate for removal \ to adhere to the general guidelines of rust"] pub fn send(&self, t: T) { if self.send_opt(t).is_err() { - fail!("sending on a closed channel"); + panic!("sending on a closed channel"); } } @@ -756,9 +756,9 @@ impl SyncSender { /// is returned back to the callee. This function is similar to `try_send`, /// except that it will block if the channel is currently full. /// - /// # Failure + /// # Panics /// - /// This function cannot fail. + /// This function cannot panic. #[unstable = "this function may be renamed to send() in the future"] pub fn send_opt(&self, t: T) -> Result<(), T> { unsafe { (*self.inner.get()).send(t) } @@ -774,9 +774,9 @@ impl SyncSender { /// See `SyncSender::send` for notes about guarantees of whether the /// receiver has received the data or not if this function is successful. /// - /// # Failure + /// # Panics /// - /// This function cannot fail + /// This function cannot panic #[unstable = "the return type of this function is candidate for \ modification"] pub fn try_send(&self, t: T) -> Result<(), TrySendError> { @@ -814,13 +814,13 @@ impl Receiver { /// on the channel from its paired `Sender` structure. This receiver will /// be woken up when data is ready, and the data will be returned. /// - /// # Failure + /// # Panics /// - /// Similar to channels, this method will trigger a task failure if the + /// Similar to channels, this method will trigger a task panic if the /// other end of the channel has hung up (been deallocated). The purpose of - /// this is to propagate failure among tasks. + /// this is to propagate panicks among tasks. /// - /// If failure is not desired, then there are two options: + /// If a panic is not desired, then there are two options: /// /// * If blocking is still desired, the `recv_opt` method will return `None` /// when the other end hangs up @@ -832,7 +832,7 @@ impl Receiver { pub fn recv(&self) -> T { match self.recv_opt() { Ok(t) => t, - Err(()) => fail!("receiving on a closed channel"), + Err(()) => panic!("receiving on a closed channel"), } } @@ -845,7 +845,9 @@ impl Receiver { /// This is useful for a flavor of "optimistic check" before deciding to /// block on a receiver. /// - /// This function cannot fail. + /// # Panics + /// + /// This function cannot panic. #[unstable = "the return type of this function may be altered"] pub fn try_recv(&self) -> Result { // If a thread is spinning in try_recv, we should take the opportunity @@ -899,15 +901,15 @@ impl Receiver { } } - /// Attempt to wait for a value on this receiver, but does not fail if the + /// Attempt to wait for a value on this receiver, but does not panic if the /// corresponding channel has hung up. /// /// This implementation of iterators for ports will always block if there is - /// not data available on the receiver, but it will not fail in the case + /// not data available on the receiver, but it will not panic in the case /// that the channel has been deallocated. /// /// In other words, this function has the same semantics as the `recv` - /// method except for the failure aspect. + /// method except for the panic aspect. /// /// If the channel has hung up, then `Err` is returned. Otherwise `Ok` of /// the value found on the receiver is returned. @@ -947,7 +949,7 @@ impl Receiver { } /// Returns an iterator which will block waiting for messages, but never - /// `fail!`. It will return `None` when the channel has hung up. + /// `panic!`. It will return `None` when the channel has hung up. #[unstable] pub fn iter<'a>(&'a self) -> Messages<'a, T> { Messages { rx: self } @@ -1191,7 +1193,7 @@ mod test { assert_eq!(rx.recv(), 1); } match rx.try_recv() { - Ok(..) => fail!(), + Ok(..) => panic!(), _ => {} } dtx.send(()); @@ -1287,7 +1289,7 @@ mod test { } #[should_fail]) test!(fn oneshot_single_thread_recv_chan_close() { - // Receiving on a closed chan will fail + // Receiving on a closed chan will panic let res = task::try(proc() { let (tx, rx) = channel::(); drop(tx); @@ -1711,7 +1713,7 @@ mod sync_tests { assert_eq!(rx.recv(), 1); } match rx.try_recv() { - Ok(..) => fail!(), + Ok(..) => panic!(), _ => {} } dtx.send(()); @@ -1747,7 +1749,7 @@ mod sync_tests { } #[should_fail]) test!(fn oneshot_single_thread_recv_chan_close() { - // Receiving on a closed chan will fail + // Receiving on a closed chan will panic let res = task::try(proc() { let (tx, rx) = sync_channel::(0); drop(tx); diff --git a/src/libsync/comm/oneshot.rs b/src/libsync/comm/oneshot.rs index 053b5dc4c8a74..447585fb2e087 100644 --- a/src/libsync/comm/oneshot.rs +++ b/src/libsync/comm/oneshot.rs @@ -94,7 +94,7 @@ impl Packet { // Sanity check match self.upgrade { NothingSent => {} - _ => fail!("sending on a oneshot that's already sent on "), + _ => panic!("sending on a oneshot that's already sent on "), } assert!(self.data.is_none()); self.data = Some(t); @@ -203,7 +203,7 @@ impl Packet { let prev = match self.upgrade { NothingSent => NothingSent, SendUsed => SendUsed, - _ => fail!("upgrading again"), + _ => panic!("upgrading again"), }; self.upgrade = GoUp(up); diff --git a/src/libsync/comm/select.rs b/src/libsync/comm/select.rs index 669c1c958b884..f826664308429 100644 --- a/src/libsync/comm/select.rs +++ b/src/libsync/comm/select.rs @@ -102,7 +102,7 @@ pub trait Packet { impl Select { /// Creates a new selection structure. This set is initially empty and - /// `wait` will fail!() if called. + /// `wait` will panic!() if called. /// /// Usage of this struct directly can sometimes be burdensome, and usage is /// rather much easier through the `select!` macro. @@ -353,17 +353,17 @@ mod test { tx1.send(1); select! ( foo = rx1.recv() => { assert_eq!(foo, 1); }, - _bar = rx2.recv() => { fail!() } + _bar = rx2.recv() => { panic!() } ) tx2.send(2); select! ( - _foo = rx1.recv() => { fail!() }, + _foo = rx1.recv() => { panic!() }, bar = rx2.recv() => { assert_eq!(bar, 2) } ) drop(tx1); select! ( foo = rx1.recv_opt() => { assert_eq!(foo, Err(())); }, - _bar = rx2.recv() => { fail!() } + _bar = rx2.recv() => { panic!() } ) drop(tx2); select! ( @@ -379,10 +379,10 @@ mod test { let (tx5, rx5) = channel::(); tx5.send(4); select! ( - _foo = rx1.recv() => { fail!("1") }, - _foo = rx2.recv() => { fail!("2") }, - _foo = rx3.recv() => { fail!("3") }, - _foo = rx4.recv() => { fail!("4") }, + _foo = rx1.recv() => { panic!("1") }, + _foo = rx2.recv() => { panic!("2") }, + _foo = rx3.recv() => { panic!("3") }, + _foo = rx4.recv() => { panic!("4") }, foo = rx5.recv() => { assert_eq!(foo, 4); } ) }) @@ -393,7 +393,7 @@ mod test { drop(tx2); select! ( - _a1 = rx1.recv_opt() => { fail!() }, + _a1 = rx1.recv_opt() => { panic!() }, a2 = rx2.recv_opt() => { assert_eq!(a2, Err(())); } ) }) @@ -412,12 +412,12 @@ mod test { select! ( a = rx1.recv() => { assert_eq!(a, 1); }, - _b = rx2.recv() => { fail!() } + _b = rx2.recv() => { panic!() } ) tx3.send(1); select! ( a = rx1.recv_opt() => { assert_eq!(a, Err(())); }, - _b = rx2.recv() => { fail!() } + _b = rx2.recv() => { panic!() } ) }) @@ -488,7 +488,7 @@ mod test { tx3.send(()); select!( _i1 = rx1.recv() => {}, - _i2 = rx2.recv() => fail!() + _i2 = rx2.recv() => panic!() ) tx3.send(()); }) @@ -509,7 +509,7 @@ mod test { tx3.send(()); select!( _i1 = rx1.recv() => {}, - _i2 = rx2.recv() => fail!() + _i2 = rx2.recv() => panic!() ) tx3.send(()); }) diff --git a/src/libsync/comm/shared.rs b/src/libsync/comm/shared.rs index cfd045d08821a..a82efe76289bf 100644 --- a/src/libsync/comm/shared.rs +++ b/src/libsync/comm/shared.rs @@ -299,7 +299,7 @@ impl Packet { Thread::yield_now(); match self.queue.pop() { mpsc::Data(t) => { data = t; break } - mpsc::Empty => fail!("inconsistent => empty"), + mpsc::Empty => panic!("inconsistent => empty"), mpsc::Inconsistent => {} } } @@ -358,7 +358,7 @@ impl Packet { match self.channels.fetch_sub(1, atomic::SeqCst) { 1 => {} n if n > 1 => return, - n => fail!("bad number of channels left {}", n), + n => panic!("bad number of channels left {}", n), } match self.cnt.swap(DISCONNECTED, atomic::SeqCst) { diff --git a/src/libsync/comm/sync.rs b/src/libsync/comm/sync.rs index 528a15cf6d765..bbb4813f5f90f 100644 --- a/src/libsync/comm/sync.rs +++ b/src/libsync/comm/sync.rs @@ -19,7 +19,7 @@ /// which means that every successful send is paired with a successful recv. /// /// This flavor of channels defines a new `send_opt` method for channels which -/// is the method by which a message is sent but the task does not fail if it +/// is the method by which a message is sent but the task does not panic if it /// cannot be delivered. /// /// Another major difference is that send() will *always* return back the data @@ -193,7 +193,7 @@ impl Packet { // success, someone's about to receive our buffered data. BlockedReceiver(task) => { wakeup(task, guard); Ok(()) } - BlockedSender(..) => fail!("lolwut"), + BlockedSender(..) => panic!("lolwut"), } } diff --git a/src/libsync/deque.rs b/src/libsync/deque.rs index 09fa8920a07d7..31889a36dd7ab 100644 --- a/src/libsync/deque.rs +++ b/src/libsync/deque.rs @@ -467,7 +467,7 @@ mod tests { while left > 0 { match s.steal() { Data((1, 10)) => { left -= 1; } - Data(..) => fail!(), + Data(..) => panic!(), Abort | Empty => {} } } @@ -497,7 +497,7 @@ mod tests { Data(box 20) => { (*unsafe_remaining).fetch_sub(1, SeqCst); } - Data(..) => fail!(), + Data(..) => panic!(), Abort | Empty => {} } } @@ -508,7 +508,7 @@ mod tests { while remaining.load(SeqCst) > 0 { match w.pop() { Some(box 20) => { remaining.fetch_sub(1, SeqCst); } - Some(..) => fail!(), + Some(..) => panic!(), None => {} } } @@ -556,7 +556,7 @@ mod tests { loop { match s.steal() { Data(2) => { HITS.fetch_add(1, SeqCst); } - Data(..) => fail!(), + Data(..) => panic!(), _ if DONE.load(SeqCst) => break, _ => {} } @@ -571,7 +571,7 @@ mod tests { match w.pop() { None => {} Some(2) => { HITS.fetch_add(1, SeqCst); }, - Some(_) => fail!(), + Some(_) => panic!(), } } else { expected += 1; @@ -583,7 +583,7 @@ mod tests { match w.pop() { None => {} Some(2) => { HITS.fetch_add(1, SeqCst); }, - Some(_) => fail!(), + Some(_) => panic!(), } } DONE.store(true, SeqCst); @@ -618,7 +618,7 @@ mod tests { Data((1, 2)) => { (*thread_box).fetch_add(1, SeqCst); } - Data(..) => fail!(), + Data(..) => panic!(), _ if DONE.load(SeqCst) => break, _ => {} } @@ -635,7 +635,7 @@ mod tests { match w.pop() { None => {} Some((1, 2)) => myhit = true, - Some(_) => fail!(), + Some(_) => panic!(), } } else { w.push((1, 2)); diff --git a/src/libsync/lock.rs b/src/libsync/lock.rs index 78a7d128be5f3..a9b0b7c48034f 100644 --- a/src/libsync/lock.rs +++ b/src/libsync/lock.rs @@ -12,11 +12,11 @@ //! //! The wrappers in this module build on the primitives from `sync::raw` to //! provide safe interfaces around using the primitive locks. These primitives -//! implement a technique called "poisoning" where when a task failed with a -//! held lock, all future attempts to use the lock will fail. +//! implement a technique called "poisoning" where when a task panicked with a +//! held lock, all future attempts to use the lock will panic. //! -//! For example, if two tasks are contending on a mutex and one of them fails -//! after grabbing the lock, the second task will immediately fail because the +//! For example, if two tasks are contending on a mutex and one of them panics +//! after grabbing the lock, the second task will immediately panic because the //! lock is now poisoned. use core::prelude::*; @@ -43,7 +43,7 @@ fn failing() -> bool { impl<'a> PoisonOnFail<'a> { fn check(flag: bool, name: &str) { if flag { - fail!("Poisoned {} - another task failed inside!", name); + panic!("Poisoned {} - another task failed inside!", name); } } @@ -99,10 +99,10 @@ impl<'a> Condvar<'a> { /// /// wait() is equivalent to wait_on(0). /// - /// # Failure + /// # Panics /// /// A task which is killed while waiting on a condition variable will wake - /// up, fail, and unlock the associated lock as it unwinds. + /// up, panic, and unlock the associated lock as it unwinds. #[inline] pub fn wait(&self) { self.wait_on(0) } @@ -213,12 +213,12 @@ impl Mutex { /// when dropped. All concurrent tasks attempting to lock the mutex will /// block while the returned value is still alive. /// - /// # Failure + /// # Panics /// - /// Failing while inside the Mutex will unlock the Mutex while unwinding, so + /// Panicking while inside the Mutex will unlock the Mutex while unwinding, so /// that other tasks won't block forever. It will also poison the Mutex: /// any tasks that subsequently try to access it (including those already - /// blocked on the mutex) will also fail immediately. + /// blocked on the mutex) will also panic immediately. #[inline] pub fn lock<'a>(&'a self) -> MutexGuard<'a, T> { let guard = self.lock.lock(); @@ -317,11 +317,11 @@ impl RWLock { /// Access the underlying data mutably. Locks the rwlock in write mode; /// other readers and writers will block. /// - /// # Failure + /// # Panics /// - /// Failing while inside the lock will unlock the lock while unwinding, so + /// Panicking while inside the lock will unlock the lock while unwinding, so /// that other tasks won't block forever. As Mutex.lock, it will also poison - /// the lock, so subsequent readers and writers will both also fail. + /// the lock, so subsequent readers and writers will both also panic. #[inline] pub fn write<'a>(&'a self) -> RWLockWriteGuard<'a, T> { let guard = self.lock.write(); @@ -496,7 +496,7 @@ mod tests { let lock = arc2.lock(); lock.cond.signal(); // Parent should fail when it wakes up. - fail!(); + panic!(); }); let lock = arc.lock(); @@ -546,7 +546,7 @@ mod tests { } } let _u = Unwinder { i: arc2 }; - fail!(); + panic!(); }); let lock = arc.lock(); assert_eq!(*lock, 2); @@ -661,7 +661,7 @@ mod tests { } } let _u = Unwinder { i: arc2 }; - fail!(); + panic!(); }); let lock = arc.read(); assert_eq!(*lock, 2); diff --git a/src/libsync/mpsc_queue.rs b/src/libsync/mpsc_queue.rs index ac2acf3d7d4d2..69dc2fe8e607e 100644 --- a/src/libsync/mpsc_queue.rs +++ b/src/libsync/mpsc_queue.rs @@ -177,7 +177,7 @@ mod tests { let q = Queue::new(); match q.pop() { Empty => {} - Inconsistent | Data(..) => fail!() + Inconsistent | Data(..) => panic!() } let (tx, rx) = channel(); let q = Arc::new(q); diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index 81ae8dbb98f1a..4fd62ac3a1da0 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -216,10 +216,10 @@ pub struct Condvar<'a> { impl<'a> Condvar<'a> { /// Atomically drop the associated lock, and block until a signal is sent. /// - /// # Failure + /// # Panics /// /// A task which is killed while waiting on a condition variable will wake - /// up, fail, and unlock the associated lock as it unwinds. + /// up, panic, and unlock the associated lock as it unwinds. pub fn wait(&self) { self.wait_on(0) } /// As wait(), but can specify which of multiple condition variables to @@ -228,7 +228,7 @@ impl<'a> Condvar<'a> { /// /// The associated lock must have been initialised with an appropriate /// number of condvars. The condvar_id must be between 0 and num_condvars-1 - /// or else this call will fail. + /// or else this call will panic. /// /// wait() is equivalent to wait_on(0). pub fn wait_on(&self, condvar_id: uint) { @@ -324,7 +324,7 @@ impl<'a> Condvar<'a> { } } -// Checks whether a condvar ID was out of bounds, and fails if so, or does +// Checks whether a condvar ID was out of bounds, and panics if so, or does // something else next on success. #[inline] fn check_cvar_bounds( @@ -335,9 +335,9 @@ fn check_cvar_bounds( -> U { match out_of_bounds { Some(0) => - fail!("{} with illegal ID {} - this lock has no condvars!", act, id), + panic!("{} with illegal ID {} - this lock has no condvars!", act, id), Some(length) => - fail!("{} with illegal ID {} - ID must be less than {}", act, id, length), + panic!("{} with illegal ID {} - ID must be less than {}", act, id, length), None => blk() } } @@ -367,9 +367,9 @@ pub struct SemaphoreGuard<'a> { impl Semaphore { /// Create a new semaphore with the specified count. /// - /// # Failure + /// # Panics /// - /// This function will fail if `count` is negative. + /// This function will panic if `count` is negative. pub fn new(count: int) -> Semaphore { Semaphore { sem: Sem::new(count, ()) } } @@ -396,8 +396,9 @@ impl Semaphore { /// A blocking, bounded-waiting, mutual exclusion lock with an associated /// FIFO condition variable. /// -/// # Failure -/// A task which fails while holding a mutex will unlock the mutex as it +/// # Panics +/// +/// A task which panicks while holding a mutex will unlock the mutex as it /// unwinds. pub struct Mutex { sem: Sem>, @@ -421,7 +422,7 @@ impl Mutex { /// Create a new mutex, with a specified number of associated condvars. This /// will allow calling wait_on/signal_on/broadcast_on with condvar IDs /// between 0 and num_condvars-1. (If num_condvars is 0, lock_cond will be - /// allowed but any operations on the condvar will fail.) + /// allowed but any operations on the condvar will panic.) pub fn new_with_condvars(num_condvars: uint) -> Mutex { Mutex { sem: Sem::new_and_signal(1, num_condvars) } } @@ -443,9 +444,9 @@ impl Mutex { /// A blocking, no-starvation, reader-writer lock with an associated condvar. /// -/// # Failure +/// # Panics /// -/// A task which fails while holding an rwlock will unlock the rwlock as it +/// A task which panics while holding an rwlock will unlock the rwlock as it /// unwinds. pub struct RWLock { order_lock: Semaphore, @@ -835,13 +836,13 @@ mod tests { fn test_mutex_killed_simple() { use std::any::Any; - // Mutex must get automatically unlocked if failed/killed within. + // Mutex must get automatically unlocked if panicked/killed within. let m = Arc::new(Mutex::new()); let m2 = m.clone(); let result: result::Result<(), Box> = task::try(proc() { let _lock = m2.lock(); - fail!(); + panic!(); }); assert!(result.is_err()); // child task must have finished by the time try returns @@ -1075,13 +1076,13 @@ mod tests { fn rwlock_kill_helper(mode1: RWLockMode, mode2: RWLockMode) { use std::any::Any; - // Mutex must get automatically unlocked if failed/killed within. + // Mutex must get automatically unlocked if panicked/killed within. let x = Arc::new(RWLock::new()); let x2 = x.clone(); let result: result::Result<(), Box> = task::try(proc() { lock_rwlock_in_mode(&x2, mode1, || { - fail!(); + panic!(); }) }); assert!(result.is_err()); diff --git a/src/libsync/spsc_queue.rs b/src/libsync/spsc_queue.rs index 9cd64d46bad85..ef0ceb141458b 100644 --- a/src/libsync/spsc_queue.rs +++ b/src/libsync/spsc_queue.rs @@ -369,7 +369,7 @@ mod test { loop { match consumer.pop() { Some(1i) => break, - Some(_) => fail!(), + Some(_) => panic!(), None => {} } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a4f060cd9fc1e..3bd25d245e175 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -84,7 +84,7 @@ impl PartialEq for Ident { // one example and its non-hygienic counterpart would be: // syntax::parse::token::Token::mtwt_eq // syntax::ext::tt::macro_parser::token_name_eq - fail!("not allowed to compare these idents: {}, {}. \ + panic!("not allowed to compare these idents: {}, {}. \ Probably related to issue \\#6993", self, other); } } diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs index 8280f34615fc2..187d94d1fa780 100644 --- a/src/libsyntax/ast_map/blocks.rs +++ b/src/libsyntax/ast_map/blocks.rs @@ -198,17 +198,17 @@ impl<'a> FnLikeNode<'a> { ident: i.ident, decl: &**decl, style: style, body: &**block, generics: generics, abi: abi, id: i.id, span: i.span }), - _ => fail!("item FnLikeNode that is not fn-like"), + _ => panic!("item FnLikeNode that is not fn-like"), }, ast_map::NodeTraitItem(t) => match *t { ast::ProvidedMethod(ref m) => method(&**m), - _ => fail!("trait method FnLikeNode that is not fn-like"), + _ => panic!("trait method FnLikeNode that is not fn-like"), }, ast_map::NodeImplItem(ii) => { match *ii { ast::MethodImplItem(ref m) => method(&**m), ast::TypeImplItem(_) => { - fail!("impl method FnLikeNode that is not fn-like") + panic!("impl method FnLikeNode that is not fn-like") } } } @@ -217,9 +217,9 @@ impl<'a> FnLikeNode<'a> { closure(ClosureParts::new(&**decl, &**block, e.id, e.span)), ast::ExprProc(ref decl, ref block) => closure(ClosureParts::new(&**decl, &**block, e.id, e.span)), - _ => fail!("expr FnLikeNode that is not fn-like"), + _ => panic!("expr FnLikeNode that is not fn-like"), }, - _ => fail!("other FnLikeNode that is not fn-like"), + _ => panic!("other FnLikeNode that is not fn-like"), } } } diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index b82a4a0b99718..915c2d1b3188c 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -263,12 +263,12 @@ impl<'ast> Map<'ast> { &self.forest.krate } - /// Retrieve the Node corresponding to `id`, failing if it cannot + /// Retrieve the Node corresponding to `id`, panicking if it cannot /// be found. pub fn get(&self, id: NodeId) -> Node<'ast> { match self.find(id) { Some(node) => node, - None => fail!("couldn't find node id {} in the AST map", id) + None => panic!("couldn't find node id {} in the AST map", id) } } @@ -308,7 +308,7 @@ impl<'ast> Map<'ast> { }; match abi { Some(abi) => abi, - None => fail!("expected foreign mod or inlined parent, found {}", + None => panic!("expected foreign mod or inlined parent, found {}", self.node_to_string(parent)) } } @@ -324,7 +324,7 @@ impl<'ast> Map<'ast> { pub fn expect_item(&self, id: NodeId) -> &'ast Item { match self.find(id) { Some(NodeItem(item)) => item, - _ => fail!("expected item, found {}", self.node_to_string(id)) + _ => panic!("expected item, found {}", self.node_to_string(id)) } } @@ -333,37 +333,37 @@ impl<'ast> Map<'ast> { Some(NodeItem(i)) => { match i.node { ItemStruct(ref struct_def, _) => &**struct_def, - _ => fail!("struct ID bound to non-struct") + _ => panic!("struct ID bound to non-struct") } } Some(NodeVariant(variant)) => { match variant.node.kind { StructVariantKind(ref struct_def) => &**struct_def, - _ => fail!("struct ID bound to enum variant that isn't struct-like"), + _ => panic!("struct ID bound to enum variant that isn't struct-like"), } } - _ => fail!(format!("expected struct, found {}", self.node_to_string(id))), + _ => panic!(format!("expected struct, found {}", self.node_to_string(id))), } } pub fn expect_variant(&self, id: NodeId) -> &'ast Variant { match self.find(id) { Some(NodeVariant(variant)) => variant, - _ => fail!(format!("expected variant, found {}", self.node_to_string(id))), + _ => panic!(format!("expected variant, found {}", self.node_to_string(id))), } } pub fn expect_foreign_item(&self, id: NodeId) -> &'ast ForeignItem { match self.find(id) { Some(NodeForeignItem(item)) => item, - _ => fail!("expected foreign item, found {}", self.node_to_string(id)) + _ => panic!("expected foreign item, found {}", self.node_to_string(id)) } } pub fn expect_expr(&self, id: NodeId) -> &'ast Expr { match self.find(id) { Some(NodeExpr(expr)) => expr, - _ => fail!("expected expr, found {}", self.node_to_string(id)) + _ => panic!("expected expr, found {}", self.node_to_string(id)) } } @@ -388,7 +388,7 @@ impl<'ast> Map<'ast> { PathName(ident.name) } MethMac(_) => { - fail!("no path elem for {}", node) + panic!("no path elem for {}", node) } } } @@ -402,13 +402,13 @@ impl<'ast> Map<'ast> { MethDecl(ident, _, _, _, _, _, _, _) => { PathName(ident.name) } - MethMac(_) => fail!("no path elem for {}", node), + MethMac(_) => panic!("no path elem for {}", node), } } TypeTraitItem(ref m) => PathName(m.ident.name), }, NodeVariant(v) => PathName(v.node.name.name), - _ => fail!("no path elem for {}", node) + _ => panic!("no path elem for {}", node) } } @@ -533,7 +533,7 @@ impl<'ast> Map<'ast> { pub fn span(&self, id: NodeId) -> Span { self.opt_span(id) - .unwrap_or_else(|| fail!("AstMap.span: could not find span for id {}", id)) + .unwrap_or_else(|| panic!("AstMap.span: could not find span for id {}", id)) } pub fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span { @@ -666,7 +666,7 @@ impl Named for Method { fn name(&self) -> Name { match self.node { MethDecl(i, _, _, _, _, _, _, _) => i.name, - MethMac(_) => fail!("encountered unexpanded method macro."), + MethMac(_) => panic!("encountered unexpanded method macro."), } } } @@ -1018,9 +1018,9 @@ impl<'a> NodePrinter for pprust::State<'a> { // these cases do not carry enough information in the // ast_map to reconstruct their full structure for pretty // printing. - NodeLocal(_) => fail!("cannot print isolated Local"), - NodeArg(_) => fail!("cannot print isolated Arg"), - NodeStructCtor(_) => fail!("cannot print isolated StructCtor"), + NodeLocal(_) => panic!("cannot print isolated Local"), + NodeArg(_) => panic!("cannot print isolated Arg"), + NodeStructCtor(_) => panic!("cannot print isolated StructCtor"), } } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index d5a460dc9dba1..7e1716e6b1817 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -43,7 +43,7 @@ pub fn stmt_id(s: &Stmt) -> NodeId { StmtDecl(_, id) => id, StmtExpr(_, id) => id, StmtSemi(_, id) => id, - StmtMac(..) => fail!("attempted to analyze unexpanded stmt") + StmtMac(..) => panic!("attempted to analyze unexpanded stmt") } } @@ -233,7 +233,7 @@ pub fn trait_method_to_ty_method(method: &Method) -> TypeMethod { abi: abi, } }, - MethMac(_) => fail!("expected non-macro method declaration") + MethMac(_) => panic!("expected non-macro method declaration") } } @@ -246,7 +246,7 @@ pub fn trait_item_to_ty_method(method: &TraitItem) -> TypeMethod { RequiredMethod(ref m) => (*m).clone(), ProvidedMethod(ref m) => trait_method_to_ty_method(&**m), TypeTraitItem(_) => { - fail!("trait_method_to_ty_method(): expected method but found \ + panic!("trait_method_to_ty_method(): expected method but found \ typedef") } } @@ -615,7 +615,7 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool { slice.iter().all(|p| walk_pat(&**p, |p| it(p))) && after.iter().all(|p| walk_pat(&**p, |p| it(p))) } - PatMac(_) => fail!("attempted to analyze unexpanded pattern"), + PatMac(_) => panic!("attempted to analyze unexpanded pattern"), PatWild(_) | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) | PatEnum(_, _) => { true @@ -725,7 +725,7 @@ macro_rules! mf_method{ match self.node { $field_pat => $result, MethMac(_) => { - fail!("expected an AST without macro invocations"); + panic!("expected an AST without macro invocations"); } } } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 4df334a3f2c70..7d303644020a4 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -425,7 +425,7 @@ impl CodeMap { // FIXME #8256: this used to be an assert but whatever precondition // it's testing isn't true for all spans in the AST, so to allow the - // caller to not have to fail (and it can't catch it since the CodeMap + // caller to not have to panic (and it can't catch it since the CodeMap // isn't sendable), return None if begin.fm.start_pos != end.fm.start_pos { None @@ -441,7 +441,7 @@ impl CodeMap { return fm.clone(); } } - fail!("asking for {} which we don't know about", filename); + panic!("asking for {} which we don't know about", filename); } pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos { @@ -503,13 +503,13 @@ impl CodeMap { break; } if a == 0 { - fail!("position {} does not resolve to a source location", + panic!("position {} does not resolve to a source location", pos.to_uint()); } a -= 1; } if a >= len { - fail!("position {} does not resolve to a source location", + panic!("position {} does not resolve to a source location", pos.to_uint()) } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 3da1b1f3175f2..e24aa0f0b9587 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -63,7 +63,7 @@ pub trait Emitter { sp: RenderSpan, msg: &str, lvl: Level); } -/// This structure is used to signify that a task has failed with a fatal error +/// This structure is used to signify that a task has panicked with a fatal error /// from the diagnostics. You can use this with the `Any` trait to figure out /// how a rustc task died (if so desired). pub struct FatalError; @@ -83,7 +83,7 @@ pub struct SpanHandler { impl SpanHandler { pub fn span_fatal(&self, sp: Span, msg: &str) -> ! { self.handler.emit(Some((&self.cm, sp)), msg, Fatal); - fail!(FatalError); + panic!(FatalError); } pub fn span_err(&self, sp: Span, msg: &str) { self.handler.emit(Some((&self.cm, sp)), msg, Error); @@ -113,7 +113,7 @@ impl SpanHandler { } pub fn span_bug(&self, sp: Span, msg: &str) -> ! { self.handler.emit(Some((&self.cm, sp)), msg, Bug); - fail!(ExplicitBug); + panic!(ExplicitBug); } pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! { self.span_bug(sp, format!("unimplemented {}", msg).as_slice()); @@ -134,7 +134,7 @@ pub struct Handler { impl Handler { pub fn fatal(&self, msg: &str) -> ! { self.emit.borrow_mut().emit(None, msg, None, Fatal); - fail!(FatalError); + panic!(FatalError); } pub fn err(&self, msg: &str) { self.emit.borrow_mut().emit(None, msg, None, Error); @@ -172,7 +172,7 @@ impl Handler { } pub fn bug(&self, msg: &str) -> ! { self.emit.borrow_mut().emit(None, msg, None, Bug); - fail!(ExplicitBug); + panic!(ExplicitBug); } pub fn unimpl(&self, msg: &str) -> ! { self.bug(format!("unimplemented {}", msg).as_slice()); @@ -367,7 +367,7 @@ impl Emitter for EmitterWriter { match error { Ok(()) => {} - Err(e) => fail!("failed to print diagnostics: {}", e), + Err(e) => panic!("failed to print diagnostics: {}", e), } } @@ -375,7 +375,7 @@ impl Emitter for EmitterWriter { sp: RenderSpan, msg: &str, lvl: Level) { match emit(self, cm, sp, msg, None, lvl, true) { Ok(()) => {} - Err(e) => fail!("failed to print diagnostics: {}", e), + Err(e) => panic!("failed to print diagnostics: {}", e), } } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 39b710e0d5725..87406081aae97 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -741,7 +741,7 @@ fn expand_arm(arm: ast::Arm, fld: &mut MacroExpander) -> ast::Arm { // expand pats... they might contain macro uses: let expanded_pats = arm.pats.move_map(|pat| fld.fold_pat(pat)); if expanded_pats.len() == 0 { - fail!("encountered match arm with 0 patterns"); + panic!("encountered match arm with 0 patterns"); } // all of the pats must have the same set of bindings, so use the // first one to extract them and generate new names: @@ -1621,7 +1621,7 @@ mod test { // good lord, you can't make a path with 0 segments, can you? let final_varref_ident = match varref.segments.last() { Some(pathsegment) => pathsegment.identifier, - None => fail!("varref with 0 path segments?") + None => panic!("varref with 0 path segments?") }; let varref_name = mtwt::resolve(final_varref_ident); let varref_idents : Vec @@ -1688,7 +1688,7 @@ foo_module!() let cxbinds: &[&ast::Ident] = cxbinds.as_slice(); let cxbind = match cxbinds { [b] => b, - _ => fail!("expected just one binding for ext_cx") + _ => panic!("expected just one binding for ext_cx") }; let resolved_binding = mtwt::resolve(*cxbind); let varrefs = crate_varrefs(&cr); diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index b4f8b9f822849..840468176ab03 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -211,7 +211,7 @@ fn resolve_internal(id: Ident, resolvedthis } } - IllegalCtxt => fail!("expected resolvable context, got IllegalCtxt") + IllegalCtxt => panic!("expected resolvable context, got IllegalCtxt") } }; resolve_table.insert(key, resolved); @@ -250,7 +250,7 @@ fn marksof_internal(ctxt: SyntaxContext, loopvar = tl; } } - IllegalCtxt => fail!("expected resolvable context, got IllegalCtxt") + IllegalCtxt => panic!("expected resolvable context, got IllegalCtxt") } } } @@ -261,7 +261,7 @@ pub fn outer_mark(ctxt: SyntaxContext) -> Mrk { with_sctable(|sctable| { match (*sctable.table.borrow())[ctxt as uint] { Mark(mrk, _) => mrk, - _ => fail!("can't retrieve outer mark when outside is not a mark") + _ => panic!("can't retrieve outer mark when outside is not a mark") } }) } @@ -342,7 +342,7 @@ mod tests { sc = tail; continue; } - IllegalCtxt => fail!("expected resolvable context, got IllegalCtxt") + IllegalCtxt => panic!("expected resolvable context, got IllegalCtxt") } } } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index dc7a495523f22..a95a737720a96 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -366,7 +366,7 @@ pub mod rt { Some(ast) => ast, None => { error!("parse error"); - fail!() + panic!() } } } @@ -598,7 +598,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { vec!(mk_name(cx, sp, ident.ident()))); } - token::Interpolated(_) => fail!("quote! with interpolated token"), + token::Interpolated(_) => panic!("quote! with interpolated token"), _ => () } @@ -635,7 +635,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { token::Dollar => "Dollar", token::Underscore => "Underscore", token::Eof => "Eof", - _ => fail!(), + _ => panic!(), }; mk_token_path(cx, sp, name) } @@ -662,7 +662,7 @@ fn mk_tt(cx: &ExtCtxt, _: Span, tt: &ast::TokenTree) -> Vec> { .chain(mk_tt(cx, sp, &close.to_tt()).into_iter()) .collect() }, - ast::TtSequence(..) => fail!("TtSequence in quote!"), + ast::TtSequence(..) => panic!("TtSequence in quote!"), ast::TtNonterminal(sp, ident) => { // tt.extend($ident.to_tokens(ext_cx).into_iter()) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 073bebcb3f6ff..9260a45adb954 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -395,7 +395,7 @@ pub fn parse(sess: &ParseSess, token::get_ident(name), token::get_ident(bind))).to_string() } - _ => fail!() + _ => panic!() } }).collect::>().connect(" or "); return Error(sp, format!( "local ambiguity: multiple parsing options: \ @@ -421,7 +421,7 @@ pub fn parse(sess: &ParseSess, parse_nt(&mut rust_parser, name_string.get())))); ei.idx += 1u; } - _ => fail!() + _ => panic!() } cur_eis.push(ei); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 20428e50c7f1f..85bd5cde3044f 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -39,7 +39,7 @@ impl<'a> ParserAnyMacro<'a> { /// silently drop anything. `allow_semi` is so that "optional" /// semicolons at the end of normal expressions aren't complained /// about e.g. the semicolon in `macro_rules! kapow( () => { - /// fail!(); } )` doesn't get picked up by .parse_expr(), but it's + /// panic!(); } )` doesn't get picked up by .parse_expr(), but it's /// allowed to be there. fn ensure_complete_parse(&self, allow_semi: bool) { let mut parser = self.parser.borrow_mut(); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 967ad3a897cde..47ca66b0b4923 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -171,7 +171,7 @@ pub trait Folder { } fn fold_mac(&mut self, _macro: Mac) -> Mac { - fail!("fold_mac disabled by default"); + panic!("fold_mac disabled by default"); // NB: see note about macros above. // if you really want a folder that // works on macros, use this @@ -1404,7 +1404,7 @@ mod test { let a_val = $a; let b_val = $b; if !(pred_val(a_val.as_slice(),b_val.as_slice())) { - fail!("expected args satisfying {}, got {} and {}", + panic!("expected args satisfying {}, got {} and {}", $predname, a_val, b_val); } } diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 3814ecfbe5bc6..5a7679570bf8d 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -142,7 +142,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { return lines.connect("\n"); } - fail!("not a doc-comment: {}", comment); + panic!("not a doc-comment: {}", comment); } fn push_blank_line_comment(rdr: &StringReader, comments: &mut Vec) { @@ -322,7 +322,7 @@ fn consume_comment(rdr: &mut StringReader, read_block_comment(rdr, code_to_the_left, comments); } else if rdr.curr_is('#') && rdr.nextch_is('!') { read_shebang_comment(rdr, code_to_the_left, comments); - } else { fail!(); } + } else { panic!(); } debug!("<<< consume comment"); } diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index b439353ad9566..3a6cf610b4f8b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -555,8 +555,8 @@ impl<'a> StringReader<'a> { whence: &str) { match r.curr { Some(r_c) if r_c == c => r.bump(), - Some(r_c) => fail!("expected {}, hit {}, {}", described_c, r_c, whence), - None => fail!("expected {}, hit EOF, {}", described_c, whence), + Some(r_c) => panic!("expected {}, hit {}, {}", described_c, r_c, whence), + None => panic!("expected {}, hit EOF, {}", described_c, whence), } } @@ -577,7 +577,7 @@ impl<'a> StringReader<'a> { self.scan_digits(base); let encoded_name : u32 = self.with_str_from(start_bpos, |s| { num::from_str_radix(s, 10).unwrap_or_else(|| { - fail!("expected digits representing a name, got `{}`, {}, range [{},{}]", + panic!("expected digits representing a name, got `{}`, {}, range [{},{}]", s, whence, start_bpos, self.last_pos); }) }); @@ -595,7 +595,7 @@ impl<'a> StringReader<'a> { self.scan_digits(base); let encoded_ctxt : ast::SyntaxContext = self.with_str_from(start_bpos, |s| { num::from_str_radix(s, 10).unwrap_or_else(|| { - fail!("expected digits representing a ctxt, got `{}`, {}", s, whence); + panic!("expected digits representing a ctxt, got `{}`, {}", s, whence); }) }); @@ -1542,7 +1542,7 @@ mod test { let mut lexer = setup(&sh, "/* /* */ */'a'".to_string()); match lexer.next_token().tok { token::Comment => { }, - _ => fail!("expected a comment!") + _ => panic!("expected a comment!") } assert_eq!(lexer.next_token().tok, token::LitChar(token::intern("a"))); } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index e60da0867f755..c731f3965a0c9 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -65,7 +65,7 @@ impl ParseSess { match v.checked_add(&count) { Some(next) => { self.node_id.set(next); } - None => fail!("Input too large, ran out of node ids!") + None => panic!("Input too large, ran out of node ids!") } v @@ -381,7 +381,7 @@ pub fn char_lit(lit: &str) -> (char, int) { '0' => Some('\0'), _ => { None } }, - _ => fail!("lexer accepted invalid char escape `{}`", lit) + _ => panic!("lexer accepted invalid char escape `{}`", lit) }; match c { @@ -434,7 +434,7 @@ pub fn str_lit(lit: &str) -> String { match c { '\\' => { let ch = chars.peek().unwrap_or_else(|| { - fail!("{}", error(i).as_slice()) + panic!("{}", error(i).as_slice()) }).val1(); if ch == '\n' { @@ -442,11 +442,11 @@ pub fn str_lit(lit: &str) -> String { } else if ch == '\r' { chars.next(); let ch = chars.peek().unwrap_or_else(|| { - fail!("{}", error(i).as_slice()) + panic!("{}", error(i).as_slice()) }).val1(); if ch != '\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } eat(&mut chars); } else { @@ -460,11 +460,11 @@ pub fn str_lit(lit: &str) -> String { }, '\r' => { let ch = chars.peek().unwrap_or_else(|| { - fail!("{}", error(i).as_slice()) + panic!("{}", error(i).as_slice()) }).val1(); if ch != '\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } chars.next(); res.push('\n'); @@ -494,7 +494,7 @@ pub fn raw_str_lit(lit: &str) -> String { Some(c) => { if c == '\r' { if *chars.peek().unwrap() != '\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } chars.next(); res.push('\n'); @@ -553,11 +553,11 @@ pub fn byte_lit(lit: &str) -> (u8, uint) { match ::std::num::from_str_radix::(lit.slice(2, 4), 16) { Some(c) => if c > 0xFF { - fail!(err(2)) + panic!(err(2)) } else { return (c as u8, 4) }, - None => fail!(err(3)) + None => panic!(err(3)) } } }; @@ -594,7 +594,7 @@ pub fn binary_lit(lit: &str) -> Rc> { b'\r' => { chars.next(); if chars.peek().expect(em.as_slice()).val1() != b'\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } eat(&mut chars); } @@ -612,7 +612,7 @@ pub fn binary_lit(lit: &str) -> Rc> { Some((i, b'\r')) => { let em = error(i); if chars.peek().expect(em.as_slice()).val1() != b'\n' { - fail!("lexer accepted bare CR"); + panic!("lexer accepted bare CR"); } chars.next(); res.push(b'\n'); @@ -813,7 +813,7 @@ mod test { ast::TtToken(_, token::Ident(name, token::Plain))], &ast::Delimiter { token: token::RParen, .. }) if name.as_str() == "a" => {}, - _ => fail!("value 3: {}", **first_delimed), + _ => panic!("value 3: {}", **first_delimed), } let (ref second_open, ref second_tts, ref second_close) = **second_delimed; match (second_open, second_tts.as_slice(), second_close) { @@ -822,13 +822,13 @@ mod test { ast::TtToken(_, token::Ident(name, token::Plain))], &ast::Delimiter { token: token::RParen, .. }) if name.as_str() == "a" => {}, - _ => fail!("value 4: {}", **second_delimed), + _ => panic!("value 4: {}", **second_delimed), } }, - _ => fail!("value 2: {}", **macro_delimed), + _ => panic!("value 2: {}", **macro_delimed), } }, - _ => fail!("value: {}",tts), + _ => panic!("value: {}",tts), } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 654de709566ae..8ef3a559bf41a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5746,7 +5746,7 @@ impl<'a> Parser<'a> { break; } IoviForeignItem(_) => { - fail!(); + panic!(); } } attrs = self.parse_outer_attributes(); @@ -5769,7 +5769,7 @@ impl<'a> Parser<'a> { items.push(item) } IoviForeignItem(_) => { - fail!(); + panic!(); } } } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 65efd4f00425b..57c72ca77c616 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -600,7 +600,7 @@ impl Printer { } Eof => { // Eof should never get here. - fail!(); + panic!(); } } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a52987f5bd174..d347d0199a724 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1072,7 +1072,7 @@ impl<'a> State<'a> { Inconsistent, struct_def.fields.as_slice(), |s, field| { match field.node.kind { - ast::NamedField(..) => fail!("unexpected named field"), + ast::NamedField(..) => panic!("unexpected named field"), ast::UnnamedField(vis) => { try!(s.print_visibility(vis)); try!(s.maybe_print_comment(field.span.lo)); @@ -1093,7 +1093,7 @@ impl<'a> State<'a> { for field in struct_def.fields.iter() { match field.node.kind { - ast::UnnamedField(..) => fail!("unexpected unnamed field"), + ast::UnnamedField(..) => panic!("unexpected unnamed field"), ast::NamedField(ident, visibility) => { try!(self.hardbreak_if_not_bol()); try!(self.maybe_print_comment(field.span.lo)); @@ -1440,7 +1440,7 @@ impl<'a> State<'a> { } // BLEAH, constraints would be great here _ => { - fail!("print_if saw if with weird alternative"); + panic!("print_if saw if with weird alternative"); } } } diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index 60ba5f6615b92..422c2d5c75bd7 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -99,7 +99,7 @@ impl SmallVector { match self.repr { One(ref v) if idx == 0 => v, Many(ref vs) => &vs[idx], - _ => fail!("out of bounds access") + _ => panic!("out of bounds access") } } @@ -110,10 +110,10 @@ impl SmallVector { if v.len() == 1 { v.into_iter().next().unwrap() } else { - fail!(err) + panic!(err) } } - _ => fail!(err) + _ => panic!(err) } } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index f2d56f53d22ca..bec72e88f99b9 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -103,7 +103,7 @@ pub trait Visitor<'v> { walk_explicit_self(self, es) } fn visit_mac(&mut self, _macro: &'v Mac) { - fail!("visit_mac disabled by default"); + panic!("visit_mac disabled by default"); // NB: see note about macros above. // if you really want a visitor that // works on macros, use this diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index 586f420dc3e00..a3482dc85c63b 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -474,7 +474,7 @@ impl FormatOp { 'x' => FormatHex, 'X' => FormatHEX, 's' => FormatString, - _ => fail!("bad FormatOp char") + _ => panic!("bad FormatOp char") } } fn to_char(self) -> char { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 307c4b27886a4..81d0bb76d1497 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -130,7 +130,7 @@ pub trait TDynBenchFn { } // A function that runs a test. If the function returns successfully, -// the test succeeds; if the function fails then the test fails. We +// the test succeeds; if the function panics then the test fails. We // may need to come up with a more clever definition of test in order // to support isolation of tests into tasks. pub enum TestFn { @@ -235,18 +235,18 @@ pub fn test_main(args: &[String], tests: Vec ) { let opts = match parse_opts(args) { Some(Ok(o)) => o, - Some(Err(msg)) => fail!("{}", msg), + Some(Err(msg)) => panic!("{}", msg), None => return }; match run_tests_console(&opts, tests) { Ok(true) => {} - Ok(false) => fail!("Some tests failed"), - Err(e) => fail!("io error when running tests: {}", e), + Ok(false) => panic!("Some tests failed"), + Err(e) => panic!("io error when running tests: {}", e), } } // A variant optimized for invocation with a static test vector. -// This will fail (intentionally) when fed any dynamic tests, because +// This will panic (intentionally) when fed any dynamic tests, because // it is copying the static values out into a dynamic vector and cannot // copy dynamic values. It is doing this because from this point on // a ~[TestDescAndFn] is used in order to effect ownership-transfer @@ -257,7 +257,7 @@ pub fn test_main_static(args: &[String], tests: &[TestDescAndFn]) { match t.testfn { StaticTestFn(f) => TestDescAndFn { testfn: StaticTestFn(f), desc: t.desc.clone() }, StaticBenchFn(f) => TestDescAndFn { testfn: StaticBenchFn(f), desc: t.desc.clone() }, - _ => fail!("non-static tests passed to test::test_main_static") + _ => panic!("non-static tests passed to test::test_main_static") } }).collect(); test_main(args, owned_tests) @@ -352,7 +352,7 @@ Test Attributes: #[bench] - Indicates a function is a benchmark to be run. This function takes one argument (test::Bencher). #[should_fail] - This function (also labeled with #[test]) will only pass if - the code causes a failure (an assertion failure or fail!) + the code causes a failure (an assertion failure or panic!) #[ignore] - When applied to a function which is already attributed as a test, then the test runner will ignore these tests during normal test runs. Running with --ignored will run these @@ -445,7 +445,7 @@ pub fn opt_shard(maybestr: Option) -> Option<(uint,uint)> { it.next()) { (Some(a), Some(b), None) => { if a <= 0 || a > b { - fail!("tried to run shard {a}.{b}, but {a} is out of bounds \ + panic!("tried to run shard {a}.{b}, but {a} is out of bounds \ (should be between 1 and {b}", a=a, b=b) } Some((a, b)) @@ -964,7 +964,7 @@ fn get_concurrency() -> uint { let opt_n: Option = FromStr::from_str(s.as_slice()); match opt_n { Some(n) if n > 0 => n, - _ => fail!("RUST_TEST_TASKS is `{}`, should be a positive integer.", s) + _ => panic!("RUST_TEST_TASKS is `{}`, should be a positive integer.", s) } } None => { @@ -1120,7 +1120,7 @@ impl MetricMap { /// /// # Failure /// - /// This function will fail if the path does not exist or the path does not + /// This function will panic if the path does not exist or the path does not /// contain a valid metric map. pub fn load(p: &Path) -> MetricMap { assert!(p.exists()); @@ -1129,7 +1129,7 @@ impl MetricMap { let mut decoder = json::Decoder::new(value); MetricMap(match Decodable::decode(&mut decoder) { Ok(t) => t, - Err(e) => fail!("failure decoding JSON: {}", e) + Err(e) => panic!("failure decoding JSON: {}", e) }) } @@ -1401,7 +1401,7 @@ mod tests { #[test] pub fn do_not_run_ignored_tests() { - fn f() { fail!(); } + fn f() { panic!(); } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), @@ -1435,7 +1435,7 @@ mod tests { #[test] fn test_should_fail() { - fn f() { fail!(); } + fn f() { panic!(); } let desc = TestDescAndFn { desc: TestDesc { name: StaticTestName("whatever"), @@ -1472,7 +1472,7 @@ mod tests { let args = vec!("progname".to_string(), "some_regex_filter".to_string()); let opts = match parse_opts(args.as_slice()) { Some(Ok(o)) => o, - _ => fail!("Malformed arg in first_free_arg_should_be_a_filter") + _ => panic!("Malformed arg in first_free_arg_should_be_a_filter") }; assert!(opts.filter.expect("should've found filter").is_match("some_regex_filter")) } @@ -1484,7 +1484,7 @@ mod tests { "--ignored".to_string()); let opts = match parse_opts(args.as_slice()) { Some(Ok(o)) => o, - _ => fail!("Malformed arg in parse_ignored_flag") + _ => panic!("Malformed arg in parse_ignored_flag") }; assert!((opts.run_ignored)); } diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index ee06c3f6caa34..590d0bfdcabc4 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -1305,7 +1305,7 @@ mod tests { == Err(InvalidTime)); match strptime("Fri Feb 13 15:31:30.01234 2009", format) { - Err(e) => fail!(e), + Err(e) => panic!(e), Ok(ref tm) => { assert!(tm.tm_sec == 30_i32); assert!(tm.tm_min == 31_i32); @@ -1324,7 +1324,7 @@ mod tests { fn test(s: &str, format: &str) -> bool { match strptime(s, format) { Ok(ref tm) => tm.strftime(format).unwrap() == s.to_string(), - Err(e) => fail!(e) + Err(e) => panic!(e) } } diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index bbaf7991fd3cc..44d001d45fda2 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -38,7 +38,7 @@ pub fn alist_get ) { - xs.iter().map(|_x| { unsafe fn q() { fail!(); } }).collect::>(); + xs.iter().map(|_x| { unsafe fn q() { panic!(); } }).collect::>(); } diff --git a/src/test/auxiliary/logging_right_crate.rs b/src/test/auxiliary/logging_right_crate.rs index 6bc5b677a2730..fad70a917980d 100644 --- a/src/test/auxiliary/logging_right_crate.rs +++ b/src/test/auxiliary/logging_right_crate.rs @@ -12,6 +12,6 @@ #[phase(plugin, link)] extern crate log; pub fn foo() { - fn death() -> int { fail!() } + fn death() -> int { panic!() } debug!("{}", (||{ death() })()); } diff --git a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs index 000e42b970356..9c0716e2cc2a5 100644 --- a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs +++ b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs @@ -36,7 +36,7 @@ pub trait IntoMaybeOwned<'a> { } impl<'a> IntoMaybeOwned<'a> for Inv<'a> { - fn into_maybe_owned(self) -> MaybeOwned<'a> { fail!() } - fn into_inv(self) -> Inv<'a> { fail!() } - fn bigger_region<'b:'a>(self, b: Inv<'b>) { fail!() } + fn into_maybe_owned(self) -> MaybeOwned<'a> { panic!() } + fn into_inv(self) -> Inv<'a> { panic!() } + fn bigger_region<'b:'a>(self, b: Inv<'b>) { panic!() } } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index eef2fdbfea9d9..811d8f1169239 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -36,6 +36,6 @@ impl read for bool { pub fn read(s: String) -> T { match read::readMaybe(s) { Some(x) => x, - _ => fail!("read failed!") + _ => panic!("read panicked!") } } diff --git a/src/test/auxiliary/weak-lang-items.rs b/src/test/auxiliary/weak-lang-items.rs index c998e362d7e34..6a1f8588b60d7 100644 --- a/src/test/auxiliary/weak-lang-items.rs +++ b/src/test/auxiliary/weak-lang-items.rs @@ -28,7 +28,7 @@ impl core::ops::Drop for A { pub fn foo() { let _a = A; - fail!("wut"); + panic!("wut"); } mod std { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 404e2e31b0577..39057215b5e69 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -145,7 +145,7 @@ fn is_utf8_ascii() { for _ in range(0u, 20000) { v.push('b' as u8); if !str::is_utf8(v.as_slice()) { - fail!("is_utf8 failed"); + panic!("is_utf8 panicked"); } } } @@ -156,7 +156,7 @@ fn is_utf8_multibyte() { for _ in range(0u, 5000) { v.push_all(s.as_bytes()); if !str::is_utf8(v.as_slice()) { - fail!("is_utf8 failed"); + panic!("is_utf8 panicked"); } } } diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 4ed0de2a13883..abcd9f9033343 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -90,7 +90,7 @@ fn show_digit(nn: uint) -> &'static str { 7 => {" seven"} 8 => {" eight"} 9 => {" nine"} - _ => {fail!("expected digits from 0 to 9...")} + _ => {panic!("expected digits from 0 to 9...")} } } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 1799504eb4782..d0e6aacdbb2ad 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -225,7 +225,7 @@ fn pack_symbol(c: u8) -> u8 { 'C' => 1, 'G' => 2, 'T' => 3, - _ => fail!("{}", c as char), + _ => panic!("{}", c as char), } } diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 8e8378641853b..6e80c07a1a2aa 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -207,7 +207,7 @@ fn get_id(m: u64) -> u8 { for id in range(0u8, 10) { if m & (1 << (id + 50) as uint) != 0 {return id;} } - fail!("{:016x} does not have a valid identifier", m); + panic!("{:016x} does not have a valid identifier", m); } // Converts a list of mask to a Vec. diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 91b9e058e8fea..425b2e3e7140b 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -61,7 +61,7 @@ fn parse_opts(argv: Vec ) -> Config { Ok(ref m) => { return Config {stress: m.opt_present("stress")} } - Err(_) => { fail!(); } + Err(_) => { panic!(); } } } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 01c412c6d3195..ae7594ea8a20e 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -83,7 +83,7 @@ impl Sudoku { from_str::(comps[2]).unwrap() as u8; } else { - fail!("Invalid sudoku file"); + panic!("Invalid sudoku file"); } } return Sudoku::new(g) @@ -123,7 +123,7 @@ impl Sudoku { ptr = ptr + 1u; } else { // no: redo this field aft recoloring pred; unless there is none - if ptr == 0u { fail!("No solution found for this sudoku"); } + if ptr == 0u { panic!("No solution found for this sudoku"); } ptr = ptr - 1u; } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index bdeee5fb6e0bf..5d96c90197cce 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -39,7 +39,7 @@ fn run(repeat: int, depth: int) { for _ in range(0, repeat) { println!("starting {:.4f}", precise_time_s()); task::try(proc() { - recurse_or_fail(depth, None) + recurse_or_panic(depth, None) }); println!("stopping {:.4f}", precise_time_s()); } @@ -70,10 +70,10 @@ fn r(l: Box) -> r { } } -fn recurse_or_fail(depth: int, st: Option) { +fn recurse_or_panic(depth: int, st: Option) { if depth == 0 { println!("unwinding {:.4f}", precise_time_s()); - fail!(); + panic!(); } else { let depth = depth - 1; @@ -96,6 +96,6 @@ fn recurse_or_fail(depth: int, st: Option) { } }; - recurse_or_fail(depth, Some(st)); + recurse_or_panic(depth, Some(st)); } } diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 9ebdbf0682d79..3d2822e14597f 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -51,6 +51,6 @@ fn main() { let (tx, rx) = channel(); child_generation(from_str::(args[1].as_slice()).unwrap(), tx); if rx.recv_opt().is_err() { - fail!("it happened when we slumbered"); + panic!("it happened when we slumbered"); } } diff --git a/src/test/compile-fail/bad-bang-ann.rs b/src/test/compile-fail/bad-bang-ann.rs index 69200ffedf9bb..7e8142dbb2908 100644 --- a/src/test/compile-fail/bad-bang-ann.rs +++ b/src/test/compile-fail/bad-bang-ann.rs @@ -11,7 +11,7 @@ // Tests that a function with a ! annotation always actually fails fn bad_bang(i: uint) -> ! { //~ ERROR computation may converge in a function marked as diverging - if i < 0u { } else { fail!(); } + if i < 0u { } else { panic!(); } } fn main() { bad_bang(5u); } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs index 87904399e032f..2a5c7136dc377 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs @@ -20,6 +20,6 @@ fn main() { let x = Some((X { x: () }, X { x: () })); match x { Some((ref _y, _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => fail!() + None => panic!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs index ba011d289255f..ae568a5277ce8 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs @@ -22,6 +22,6 @@ fn main() { let x = some2(X { x: () }, X { x: () }); match x { some2(ref _y, _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - none2 => fail!() + none2 => panic!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs index 6858b7200db6c..8c7542fbe6b3d 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs @@ -20,6 +20,6 @@ fn main() { let x = Some((X { x: () }, X { x: () })); match x { Some((_y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => fail!() + None => panic!() } } diff --git a/src/test/compile-fail/bind-by-move-no-guards.rs b/src/test/compile-fail/bind-by-move-no-guards.rs index 5602aff5cadcf..18534db0dd5a0 100644 --- a/src/test/compile-fail/bind-by-move-no-guards.rs +++ b/src/test/compile-fail/bind-by-move-no-guards.rs @@ -13,8 +13,8 @@ fn main() { let x = Some(rx); tx.send(false); match x { - Some(z) if z.recv() => { fail!() }, //~ ERROR cannot bind by-move into a pattern guard + Some(z) if z.recv() => { panic!() }, //~ ERROR cannot bind by-move into a pattern guard Some(z) => { assert!(!z.recv()); }, - None => fail!() + None => panic!() } } diff --git a/src/test/compile-fail/borrowck-anon-fields-variant.rs b/src/test/compile-fail/borrowck-anon-fields-variant.rs index 12624a49f7a29..3e0cd05cba346 100644 --- a/src/test/compile-fail/borrowck-anon-fields-variant.rs +++ b/src/test/compile-fail/borrowck-anon-fields-variant.rs @@ -20,12 +20,12 @@ fn distinct_variant() { let a = match y { Y(ref mut a, _) => a, - X => fail!() + X => panic!() }; let b = match y { Y(_, ref mut b) => b, - X => fail!() + X => panic!() }; *a += 1; @@ -37,12 +37,12 @@ fn same_variant() { let a = match y { Y(ref mut a, _) => a, - X => fail!() + X => panic!() }; let b = match y { Y(ref mut b, _) => b, //~ ERROR cannot borrow - X => fail!() + X => panic!() }; *a += 1; diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index 2a2a3dee1dfa6..4c6088969f359 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -28,7 +28,7 @@ fn main() { x = X(Left((0,0))); (*f)() }, - _ => fail!() + _ => panic!() } }) } diff --git a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs index 208f58f6b54c1..c071691c94707 100644 --- a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs +++ b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs @@ -19,7 +19,7 @@ struct Bar { int2: int, } -fn make_foo() -> Box { fail!() } +fn make_foo() -> Box { panic!() } fn borrow_same_field_twice_mut_mut() { let mut foo = make_foo(); diff --git a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs index cdcf50c906e36..3a85b45ad126d 100644 --- a/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs +++ b/src/test/compile-fail/borrowck-borrow-from-stack-variable.rs @@ -18,7 +18,7 @@ struct Bar { int2: int, } -fn make_foo() -> Foo { fail!() } +fn make_foo() -> Foo { panic!() } fn borrow_same_field_twice_mut_mut() { let mut foo = make_foo(); diff --git a/src/test/compile-fail/borrowck-closures-unique.rs b/src/test/compile-fail/borrowck-closures-unique.rs index 61c77ce7bbaa9..febc84ccd4461 100644 --- a/src/test/compile-fail/borrowck-closures-unique.rs +++ b/src/test/compile-fail/borrowck-closures-unique.rs @@ -43,7 +43,7 @@ fn d(x: &mut int) { } fn e(x: &mut int) { - let c1: || = || x = fail!(); //~ ERROR closure cannot assign to immutable local variable + let c1: || = || x = panic!(); //~ ERROR closure cannot assign to immutable local variable } fn main() { diff --git a/src/test/compile-fail/borrowck-lend-flow-if.rs b/src/test/compile-fail/borrowck-lend-flow-if.rs index e556b1bc184e3..8a7ecde700ae6 100644 --- a/src/test/compile-fail/borrowck-lend-flow-if.rs +++ b/src/test/compile-fail/borrowck-lend-flow-if.rs @@ -17,9 +17,9 @@ fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} -fn cond() -> bool { fail!() } -fn for_func(_f: || -> bool) { fail!() } -fn produce() -> T { fail!(); } +fn cond() -> bool { panic!() } +fn for_func(_f: || -> bool) { panic!() } +fn produce() -> T { panic!(); } fn inc(v: &mut Box) { *v = box() (**v + 1); diff --git a/src/test/compile-fail/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck-lend-flow-loop.rs index 12e1240d10d63..6adcfad33f46c 100644 --- a/src/test/compile-fail/borrowck-lend-flow-loop.rs +++ b/src/test/compile-fail/borrowck-lend-flow-loop.rs @@ -17,8 +17,8 @@ fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} -fn cond() -> bool { fail!() } -fn produce() -> T { fail!(); } +fn cond() -> bool { panic!() } +fn produce() -> T { panic!(); } fn inc(v: &mut Box) { *v = box() (**v + 1); diff --git a/src/test/compile-fail/borrowck-lend-flow.rs b/src/test/compile-fail/borrowck-lend-flow.rs index 7ad2d9040940c..de8c7d9def4e1 100644 --- a/src/test/compile-fail/borrowck-lend-flow.rs +++ b/src/test/compile-fail/borrowck-lend-flow.rs @@ -17,9 +17,9 @@ fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} -fn cond() -> bool { fail!() } -fn for_func(_f: || -> bool) { fail!() } -fn produce() -> T { fail!(); } +fn cond() -> bool { panic!() } +fn for_func(_f: || -> bool) { panic!() } +fn produce() -> T { panic!(); } fn inc(v: &mut Box) { *v = box() (**v + 1); diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs index 30d57d4d755f0..376832ada4ef5 100644 --- a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs @@ -16,7 +16,7 @@ enum Either { Left(T), Right(U) } *x = Right(1.0); *z } - _ => fail!() + _ => panic!() } } diff --git a/src/test/compile-fail/borrowck-ref-into-rvalue.rs b/src/test/compile-fail/borrowck-ref-into-rvalue.rs index ba1d3a9ddba79..726d4bcdf1d08 100644 --- a/src/test/compile-fail/borrowck-ref-into-rvalue.rs +++ b/src/test/compile-fail/borrowck-ref-into-rvalue.rs @@ -14,7 +14,7 @@ fn main() { Some(ref m) => { //~ ERROR borrowed value does not live long enough msg = m; }, - None => { fail!() } + None => { panic!() } } println!("{}", *msg); } diff --git a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs index d256b033298ed..4a5418a4f20c2 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs @@ -15,7 +15,7 @@ fn a<'a>() -> &'a [int] { let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let tail = match vec { [_, tail..] => tail, - _ => fail!("a") + _ => panic!("a") }; tail } @@ -25,7 +25,7 @@ fn b<'a>() -> &'a [int] { let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let init = match vec { [init.., _] => init, - _ => fail!("b") + _ => panic!("b") }; init } @@ -35,7 +35,7 @@ fn c<'a>() -> &'a [int] { let vec: &[int] = vec.as_slice(); //~ ERROR does not live long enough let slice = match vec { [_, slice.., _] => slice, - _ => fail!("c") + _ => panic!("c") }; slice } diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index 2c9cf7d1b65be..852eb172c59d1 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -13,7 +13,7 @@ fn a<'a>() -> &'a int { let vec: &[int] = vec.as_slice(); //~ ERROR `vec` does not live long enough let tail = match vec { [_a, tail..] => &tail[0], - _ => fail!("foo") + _ => panic!("foo") }; tail } diff --git a/src/test/compile-fail/closure-that-fails.rs b/src/test/compile-fail/closure-that-fails.rs index 05317e9c6b029..7a1ebed0a82ac 100644 --- a/src/test/compile-fail/closure-that-fails.rs +++ b/src/test/compile-fail/closure-that-fails.rs @@ -12,8 +12,8 @@ fn foo(f: || -> !) {} fn main() { // Type inference didn't use to be able to handle this: - foo(|| fail!()); - foo(|| -> ! fail!()); + foo(|| panic!()); + foo(|| -> ! panic!()); foo(|| 22i); //~ ERROR computation may converge in a function marked as diverging foo(|| -> ! 22i); //~ ERROR computation may converge in a function marked as diverging let x = || -> ! 1i; //~ ERROR computation may converge in a function marked as diverging diff --git a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs b/src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs index 578de06b74780..da2e6200eb65f 100644 --- a/src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs +++ b/src/test/compile-fail/coherence-blanket-conflicts-with-specific-multidispatch.rs @@ -20,7 +20,7 @@ trait MyTrait { impl MyTrait for T { //~ ERROR E0119 fn get(&self) -> T { - fail!() + panic!() } } diff --git a/src/test/compile-fail/dead-code-closure-bang.rs b/src/test/compile-fail/dead-code-closure-bang.rs index 96e8378a35df8..3179b1815609f 100644 --- a/src/test/compile-fail/dead-code-closure-bang.rs +++ b/src/test/compile-fail/dead-code-closure-bang.rs @@ -11,7 +11,7 @@ #![deny(unreachable_code)] fn main() { - let x: || -> ! = || fail!(); + let x: || -> ! = || panic!(); x(); println!("Foo bar"); //~ ERROR: unreachable statement } diff --git a/src/test/compile-fail/deref-non-pointer.rs b/src/test/compile-fail/deref-non-pointer.rs index 7b1b0f6243ac4..1c711c0145d90 100644 --- a/src/test/compile-fail/deref-non-pointer.rs +++ b/src/test/compile-fail/deref-non-pointer.rs @@ -10,6 +10,6 @@ fn main() { match *1 { //~ ERROR: cannot be dereferenced - _ => { fail!(); } + _ => { panic!(); } } } diff --git a/src/test/compile-fail/fail-no-dead-code-core.rs b/src/test/compile-fail/fail-no-dead-code-core.rs index 58ecdec538e0b..49a927b9879e4 100644 --- a/src/test/compile-fail/fail-no-dead-code-core.rs +++ b/src/test/compile-fail/fail-no-dead-code-core.rs @@ -18,11 +18,11 @@ fn foo() { //~ ERROR function is never used // none of these should have any dead_code exposed to the user - fail!(); + panic!(); - fail!("foo"); + panic!("foo"); - fail!("bar {}", "baz") + panic!("bar {}", "baz") } diff --git a/src/test/compile-fail/fail-no-dead-code.rs b/src/test/compile-fail/fail-no-dead-code.rs index 897710609fd41..6e5d3a313556e 100644 --- a/src/test/compile-fail/fail-no-dead-code.rs +++ b/src/test/compile-fail/fail-no-dead-code.rs @@ -14,11 +14,11 @@ fn foo() { //~ ERROR function is never used // none of these should have any dead_code exposed to the user - fail!(); + panic!(); - fail!("foo"); + panic!("foo"); - fail!("bar {}", "baz") + panic!("bar {}", "baz") } diff --git a/src/test/compile-fail/fail-simple.rs b/src/test/compile-fail/fail-simple.rs index 19c1aa1ba204f..97b709592a9c9 100644 --- a/src/test/compile-fail/fail-simple.rs +++ b/src/test/compile-fail/fail-simple.rs @@ -11,5 +11,5 @@ // error-pattern:unexpected token fn main() { - fail!(@); + panic!(@); } diff --git a/src/test/compile-fail/generic-lifetime-trait-impl.rs b/src/test/compile-fail/generic-lifetime-trait-impl.rs index 8b52324848bf4..651072d2118e5 100644 --- a/src/test/compile-fail/generic-lifetime-trait-impl.rs +++ b/src/test/compile-fail/generic-lifetime-trait-impl.rs @@ -23,7 +23,7 @@ trait Foo<'a> { } impl<'a> Foo<'a> for &'a str { - fn bar>(self) -> &'a str { fail!() } //~ ERROR lifetime + fn bar>(self) -> &'a str { panic!() } //~ ERROR lifetime } fn main() { diff --git a/src/test/compile-fail/issue-10392-2.rs b/src/test/compile-fail/issue-10392-2.rs index 8d7125d7fdd3a..2cbb59cc15a20 100644 --- a/src/test/compile-fail/issue-10392-2.rs +++ b/src/test/compile-fail/issue-10392-2.rs @@ -10,7 +10,7 @@ struct A { foo: int } -fn a() -> A { fail!() } +fn a() -> A { panic!() } fn main() { let A { .., } = a(); //~ ERROR: expected `}` diff --git a/src/test/compile-fail/issue-10392.rs b/src/test/compile-fail/issue-10392.rs index 455704376d6f9..4d0e02c6310c2 100644 --- a/src/test/compile-fail/issue-10392.rs +++ b/src/test/compile-fail/issue-10392.rs @@ -10,7 +10,7 @@ struct A { foo: int } -fn a() -> A { fail!() } +fn a() -> A { panic!() } fn main() { let A { , } = a(); //~ ERROR: expected ident diff --git a/src/test/compile-fail/issue-11844.rs b/src/test/compile-fail/issue-11844.rs index e5400bf60c361..55c12b051b94d 100644 --- a/src/test/compile-fail/issue-11844.rs +++ b/src/test/compile-fail/issue-11844.rs @@ -13,7 +13,7 @@ fn main() { match a { Ok(a) => //~ ERROR: mismatched types println!("{}",a), - None => fail!() + None => panic!() } } diff --git a/src/test/compile-fail/issue-12116.rs b/src/test/compile-fail/issue-12116.rs index a80e405d05ca2..cc0841a6856ca 100644 --- a/src/test/compile-fail/issue-12116.rs +++ b/src/test/compile-fail/issue-12116.rs @@ -18,7 +18,7 @@ fn tail(source_list: &IntList) -> IntList { &Cons(val, box ref next_list) => tail(next_list), &Cons(val, box Nil) => Cons(val, box Nil), //~^ ERROR: unreachable pattern - _ => fail!() + _ => panic!() } } diff --git a/src/test/compile-fail/issue-12187-1.rs b/src/test/compile-fail/issue-12187-1.rs index 356d95452b3e1..74423b041dda3 100644 --- a/src/test/compile-fail/issue-12187-1.rs +++ b/src/test/compile-fail/issue-12187-1.rs @@ -9,7 +9,7 @@ // except according to those terms. fn new() -> &'static T { - fail!() + panic!() } fn main() { diff --git a/src/test/compile-fail/issue-12187-2.rs b/src/test/compile-fail/issue-12187-2.rs index a67d9dee9768f..af5c8b45a483e 100644 --- a/src/test/compile-fail/issue-12187-2.rs +++ b/src/test/compile-fail/issue-12187-2.rs @@ -9,7 +9,7 @@ // except according to those terms. fn new<'r, T>() -> &'r T { - fail!() + panic!() } fn main() { diff --git a/src/test/compile-fail/issue-13466.rs b/src/test/compile-fail/issue-13466.rs index 14cc0a82df5b2..e150c1a0f2fc8 100644 --- a/src/test/compile-fail/issue-13466.rs +++ b/src/test/compile-fail/issue-13466.rs @@ -16,6 +16,6 @@ pub fn main() { // tricked into looking up a non-existing second type parameter. let _x: uint = match Some(1u) { Ok(u) => u, //~ ERROR mismatched types: expected `core::option::Option` - Err(e) => fail!(e) //~ ERROR mismatched types: expected `core::option::Option` + Err(e) => panic!(e) //~ ERROR mismatched types: expected `core::option::Option` }; } diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index 19d210f190595..e64d674b7c862 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -15,7 +15,7 @@ trait vec_monad { impl vec_monad for Vec { fn bind(&self, f: |A| -> Vec ) { - let mut r = fail!(); + let mut r = panic!(); for elt in self.iter() { r = r + f(*elt); } //~^ ERROR the type of this value must be known //~^^ ERROR not implemented diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index 7457a1020cee1..468fed1eff5ad 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -14,7 +14,7 @@ fn fail_len(v: Vec ) -> uint { let mut i = 3; - fail!(); + panic!(); for x in v.iter() { i += 1u; } //~^ ERROR: unreachable statement return i; diff --git a/src/test/compile-fail/issue-2151.rs b/src/test/compile-fail/issue-2151.rs index 5559ba344ed17..fbd8f9163b5df 100644 --- a/src/test/compile-fail/issue-2151.rs +++ b/src/test/compile-fail/issue-2151.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - let x = fail!(); + let x = panic!(); x.clone(); //~ ERROR the type of this value must be known in this context } diff --git a/src/test/compile-fail/issue-2330.rs b/src/test/compile-fail/issue-2330.rs index e46dbaf0ae0e6..6291b0240533f 100644 --- a/src/test/compile-fail/issue-2330.rs +++ b/src/test/compile-fail/issue-2330.rs @@ -16,7 +16,7 @@ trait channel { // `chan` is not a trait, it's an enum impl chan for int { //~ ERROR `chan` is not a trait - fn send(&self, v: int) { fail!() } + fn send(&self, v: int) { panic!() } } fn main() { diff --git a/src/test/compile-fail/issue-2354.rs b/src/test/compile-fail/issue-2354.rs index a2bb56fdf5f65..93f38a50b0582 100644 --- a/src/test/compile-fail/issue-2354.rs +++ b/src/test/compile-fail/issue-2354.rs @@ -10,8 +10,8 @@ fn foo() { //~ NOTE Did you mean to close this delimiter? match Some(x) { - Some(y) { fail!(); } - None { fail!(); } + Some(y) { panic!(); } + None { panic!(); } } fn bar() { diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 42b70c28be604..70ffa86359d5a 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Sync` + fn b(_x: F) -> F { panic!() } //~ ERROR type parameter 0 requires `Sync` } fn main() {} diff --git a/src/test/compile-fail/issue-2611-5.rs b/src/test/compile-fail/issue-2611-5.rs index 9b8346da5c5d9..2eda5d67edd8e 100644 --- a/src/test/compile-fail/issue-2611-5.rs +++ b/src/test/compile-fail/issue-2611-5.rs @@ -21,7 +21,7 @@ struct E { impl A for E { // n.b. The error message is awful -- see #3404 - fn b(&self, _x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type + fn b(&self, _x: G) -> G { panic!() } //~ ERROR method `b` has an incompatible type } fn main() {} diff --git a/src/test/compile-fail/issue-3021.rs b/src/test/compile-fail/issue-3021.rs index d44d81b7fe01d..578f100eba40b 100644 --- a/src/test/compile-fail/issue-3021.rs +++ b/src/test/compile-fail/issue-3021.rs @@ -23,7 +23,7 @@ fn siphash(k0 : u64) -> SipHash { //~^ ERROR unresolved name `k0`. } } - fail!(); + panic!(); } fn main() {} diff --git a/src/test/compile-fail/issue-3601.rs b/src/test/compile-fail/issue-3601.rs index dd27314e14fa3..2716d49fe69a8 100644 --- a/src/test/compile-fail/issue-3601.rs +++ b/src/test/compile-fail/issue-3601.rs @@ -38,6 +38,6 @@ fn main() { box Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns box HTMLImageElement(ref d) if d.image.is_some() => { true } }, - _ => fail!("WAT") //~ ERROR unreachable pattern + _ => panic!("WAT") //~ ERROR unreachable pattern }; } diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index cccf730095bdf..9c31dc1e38ef8 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -17,7 +17,7 @@ impl PTrait for P { fn getChildOption(&self) -> Option> { static childVal: Box
' failed at fn main() { - fail!() + panic!() } diff --git a/src/test/run-fail/match-bot-fail.rs b/src/test/run-fail/match-bot-fail.rs index 9d80f07de0af9..8763f958a83e6 100644 --- a/src/test/run-fail/match-bot-fail.rs +++ b/src/test/run-fail/match-bot-fail.rs @@ -17,6 +17,6 @@ fn foo(s: String) { } fn main() { let i = - match Some::(3) { None:: => { fail!() } Some::(_) => { fail!() } }; + 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 index 13ccd118c6186..da08f53fcde56 100644 --- a/src/test/run-fail/match-disc-bot.rs +++ b/src/test/run-fail/match-disc-bot.rs @@ -9,6 +9,6 @@ // except according to those terms. // error-pattern:quux -fn f() -> ! { fail!("quux") } +fn f() -> ! { panic!("quux") } fn g() -> int { 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 index a4a6739bfc1d4..5c1a9e1a5e712 100644 --- a/src/test/run-fail/match-wildcards.rs +++ b/src/test/run-fail/match-wildcards.rs @@ -11,9 +11,9 @@ // error-pattern:squirrelcupcake fn cmp() -> int { match (Some('a'), None::) { - (Some(_), _) => { fail!("squirrelcupcake"); } - (_, Some(_)) => { fail!(); } - _ => { fail!("wat"); } + (Some(_), _) => { panic!("squirrelcupcake"); } + (_, Some(_)) => { panic!(); } + _ => { panic!("wat"); } } } diff --git a/src/test/run-fail/native-failure.rs b/src/test/run-fail/native-failure.rs index ae3924ba9356c..6b5e3bafe79b5 100644 --- a/src/test/run-fail/native-failure.rs +++ b/src/test/run-fail/native-failure.rs @@ -16,6 +16,6 @@ extern crate native; #[start] fn start(argc: int, argv: *const *const u8) -> int { native::start(argc, argv, proc() { - fail!(); + panic!(); }) } diff --git a/src/test/run-fail/rhs-type.rs b/src/test/run-fail/rhs-type.rs index d607ec76c351d..ec19e08c74f72 100644 --- a/src/test/run-fail/rhs-type.rs +++ b/src/test/run-fail/rhs-type.rs @@ -18,6 +18,6 @@ struct T { t: String } fn main() { - let pth = fail!("bye"); + let pth = panic!("bye"); let _rs: T = T {t: pth}; } diff --git a/src/test/run-fail/rt-set-exit-status-fail.rs b/src/test/run-fail/rt-set-exit-status-fail.rs index c960679a43f1e..e524a2432ac4e 100644 --- a/src/test/run-fail/rt-set-exit-status-fail.rs +++ b/src/test/run-fail/rt-set-exit-status-fail.rs @@ -17,8 +17,8 @@ use std::os; fn main() { error!("whatever"); // Setting the exit status only works when the scheduler terminates - // normally. In this case we're going to fail, so instead of + // normally. In this case we're going to panic, so instead of // returning 50 the process will return the typical rt failure code. os::set_exit_status(50); - fail!(); + panic!(); } diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs index 22985d57936a2..1cfc6c36a6397 100644 --- a/src/test/run-fail/rt-set-exit-status-fail2.rs +++ b/src/test/run-fail/rt-set-exit-status-fail2.rs @@ -20,7 +20,7 @@ struct r { } // Setting the exit status after the runtime has already -// failed has no effect and the process exits with the +// panicked has no effect and the process exits with the // runtime's exit code impl Drop for r { fn drop(&mut self) { @@ -39,5 +39,5 @@ fn main() { task::spawn(proc() { let _i = r(5); }); - fail!(); + panic!(); } diff --git a/src/test/run-fail/rt-set-exit-status.rs b/src/test/run-fail/rt-set-exit-status.rs index d08cb198802ad..bddf9b5a7ea59 100644 --- a/src/test/run-fail/rt-set-exit-status.rs +++ b/src/test/run-fail/rt-set-exit-status.rs @@ -16,7 +16,7 @@ use std::os; fn main() { error!("whatever"); - // 101 is the code the runtime uses on task failure and the value + // 101 is the code the runtime uses on task panic and the value // compiletest expects run-fail tests to return. os::set_exit_status(101); } diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index 70ef4a0c0c3d3..0e218740ab1cf 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -17,5 +17,5 @@ mod m { pub fn exported() { } #[test] - fn unexported() { fail!("runned an unexported test"); } + fn unexported() { panic!("runned an unexported test"); } } diff --git a/src/test/run-fail/str-overrun.rs b/src/test/run-fail/str-overrun.rs index c3ee76047d134..a9c0030fecaf7 100644 --- a/src/test/run-fail/str-overrun.rs +++ b/src/test/run-fail/str-overrun.rs @@ -13,6 +13,6 @@ fn main() { let s: String = "hello".to_string(); - // Bounds-check failure. + // 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 index e7fd97f8d31f3..dfc3238662cfe 100644 --- a/src/test/run-fail/task-spawn-barefn.rs +++ b/src/test/run-fail/task-spawn-barefn.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:Ensure that the child task runs by failing +// error-pattern:Ensure that the child task runs by panicking use std::task; @@ -17,10 +17,10 @@ fn main() { // works when provided with a bare function: let r = task::try(startfn); if r.is_err() { - fail!() + panic!() } } fn startfn() { - assert!("Ensure that the child task runs by failing".is_empty()); + assert!("Ensure that the child task runs by panicking".is_empty()); } diff --git a/src/test/run-fail/test-fail.rs b/src/test/run-fail/test-fail.rs index b628f101fd576..0c1f9424ba035 100644 --- a/src/test/run-fail/test-fail.rs +++ b/src/test/run-fail/test-fail.rs @@ -15,6 +15,6 @@ #[test] fn test_foo() { - fail!() + panic!() } diff --git a/src/test/run-fail/tls-exit-status.rs b/src/test/run-fail/tls-exit-status.rs index 1858ceb283648..5b44e3757047b 100644 --- a/src/test/run-fail/tls-exit-status.rs +++ b/src/test/run-fail/tls-exit-status.rs @@ -15,5 +15,5 @@ use std::os; fn main() { os::args(); - fail!("please have a nonzero exit status"); + panic!("please have a nonzero exit status"); } diff --git a/src/test/run-fail/too-much-recursion-unwinding.rs b/src/test/run-fail/too-much-recursion-unwinding.rs index 04733552969c5..2ec670c3306db 100644 --- a/src/test/run-fail/too-much-recursion-unwinding.rs +++ b/src/test/run-fail/too-much-recursion-unwinding.rs @@ -11,7 +11,7 @@ // ignore-test leaks // error-pattern:ran out of stack -// Test that the task fails after hitting the recursion limit +// Test that the task panicks after hitting the recursion limit // during unwinding fn recurse() { diff --git a/src/test/run-fail/unique-fail.rs b/src/test/run-fail/unique-fail.rs index f1804c1069189..931963442442c 100644 --- a/src/test/run-fail/unique-fail.rs +++ b/src/test/run-fail/unique-fail.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern: fail -fn main() { box fail!(); } +fn main() { box panic!(); } diff --git a/src/test/run-fail/unwind-interleaved.rs b/src/test/run-fail/unwind-interleaved.rs index f6a3aa48def9b..5012ded28b5c3 100644 --- a/src/test/run-fail/unwind-interleaved.rs +++ b/src/test/run-fail/unwind-interleaved.rs @@ -12,7 +12,7 @@ fn a() { } -fn b() { fail!(); } +fn b() { panic!(); } fn main() { let _x = vec!(0i); diff --git a/src/test/run-fail/unwind-rec.rs b/src/test/run-fail/unwind-rec.rs index 9c96970f0e7f1..1c72686b60287 100644 --- a/src/test/run-fail/unwind-rec.rs +++ b/src/test/run-fail/unwind-rec.rs @@ -12,7 +12,7 @@ fn build() -> Vec { - fail!(); + panic!(); } struct Blk { node: Vec } diff --git a/src/test/run-fail/unwind-rec2.rs b/src/test/run-fail/unwind-rec2.rs index 178d0a8ab327c..943b4cd76715c 100644 --- a/src/test/run-fail/unwind-rec2.rs +++ b/src/test/run-fail/unwind-rec2.rs @@ -16,7 +16,7 @@ fn build1() -> Vec { } fn build2() -> Vec { - fail!(); + panic!(); } struct Blk { node: Vec , span: Vec } diff --git a/src/test/run-fail/unwind-unique.rs b/src/test/run-fail/unwind-unique.rs index 233d367c4b1e1..6b5aefbab802b 100644 --- a/src/test/run-fail/unwind-unique.rs +++ b/src/test/run-fail/unwind-unique.rs @@ -12,7 +12,7 @@ fn failfn() { - fail!(); + panic!(); } fn main() { diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs index 281523a807ef8..c378e852f897e 100644 --- a/src/test/run-fail/vec-overrun.rs +++ b/src/test/run-fail/vec-overrun.rs @@ -15,7 +15,7 @@ fn main() { let v: Vec = vec!(10); let x: uint = 0; assert_eq!(v[x], 10); - // Bounds-check failure. + // Bounds-check panic. assert_eq!(v[x + 2], 20); } diff --git a/src/test/run-fail/while-body-fails.rs b/src/test/run-fail/while-body-fails.rs index 0a0b26083579d..6a7d0a1d73e8f 100644 --- a/src/test/run-fail/while-body-fails.rs +++ b/src/test/run-fail/while-body-fails.rs @@ -11,4 +11,4 @@ #![allow(while_true)] // error-pattern:quux -fn main() { let _x: int = { while true { fail!("quux"); } ; 8 } ; } +fn main() { let _x: int = { while true { panic!("quux"); } ; 8 } ; } diff --git a/src/test/run-fail/while-fail.rs b/src/test/run-fail/while-fail.rs index 24058c4fb936e..f6081e497bffe 100644 --- a/src/test/run-fail/while-fail.rs +++ b/src/test/run-fail/while-fail.rs @@ -12,5 +12,5 @@ // error-pattern:giraffe fn main() { - fail!({ while true { fail!("giraffe") }; "clandestine" }); + panic!({ while true { panic!("giraffe") }; "clandestine" }); } diff --git a/src/test/run-make/static-unwinding/main.rs b/src/test/run-make/static-unwinding/main.rs index 9fe78cc2553e7..9918fbb1ab701 100644 --- a/src/test/run-make/static-unwinding/main.rs +++ b/src/test/run-make/static-unwinding/main.rs @@ -24,7 +24,7 @@ impl Drop for A { fn main() { task::try(proc() { let _a = A; - lib::callback(|| fail!()); + lib::callback(|| panic!()); 1i }); diff --git a/src/test/run-pass/attr-main-2.rs b/src/test/run-pass/attr-main-2.rs index 8ae2c1600aa28..2f5e72491bef3 100644 --- a/src/test/run-pass/attr-main-2.rs +++ b/src/test/run-pass/attr-main-2.rs @@ -10,7 +10,7 @@ pub fn main() { - fail!() + panic!() } #[main] diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index f487a1c6be5ce..7e7399c403a73 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -26,16 +26,16 @@ fn start(argc: int, argv: *const *const u8) -> int { fn foo() { let _v = vec![1i, 2, 3]; if os::getenv("IS_TEST").is_some() { - fail!() + panic!() } } #[inline(never)] fn double() { (|| { - fail!("once"); + panic!("once"); }).finally(|| { - fail!("twice"); + panic!("twice"); }) } diff --git a/src/test/run-pass/binary-minus-without-space.rs b/src/test/run-pass/binary-minus-without-space.rs index 9c6e6ab60abe2..8235b91273b52 100644 --- a/src/test/run-pass/binary-minus-without-space.rs +++ b/src/test/run-pass/binary-minus-without-space.rs @@ -11,6 +11,6 @@ // Check that issue #954 stays fixed pub fn main() { - match -1i { -1 => {}, _ => fail!("wat") } + match -1i { -1 => {}, _ => panic!("wat") } assert_eq!(1i-1, 0i); } diff --git a/src/test/run-pass/bind-by-move.rs b/src/test/run-pass/bind-by-move.rs index a7d3d99e45892..a9fa8449d0f1a 100644 --- a/src/test/run-pass/bind-by-move.rs +++ b/src/test/run-pass/bind-by-move.rs @@ -16,6 +16,6 @@ pub fn main() { let x = Some(p); match x { Some(z) => { dispose(z); }, - None => fail!() + None => panic!() } } diff --git a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs index 10835730fa54e..415c660221d40 100644 --- a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs +++ b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs @@ -32,11 +32,11 @@ impl Foo { ); match s { box Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)), - _ => fail!() + _ => panic!() } } - fn check_id(&mut self, s: int) { fail!() } + fn check_id(&mut self, s: int) { panic!() } } pub fn main() { } diff --git a/src/test/run-pass/byte-literals.rs b/src/test/run-pass/byte-literals.rs index aa45bfd14541c..ee8a58a0d337f 100644 --- a/src/test/run-pass/byte-literals.rs +++ b/src/test/run-pass/byte-literals.rs @@ -29,12 +29,12 @@ pub fn main() { match 42 { b'*' => {}, - _ => fail!() + _ => panic!() } match 100 { b'a' ... b'z' => {}, - _ => fail!() + _ => panic!() } let expected: &[_] = &[97u8, 10u8, 13u8, 9u8, 92u8, 39u8, 34u8, 0u8, 240u8]; @@ -48,7 +48,7 @@ pub fn main() { let val: &[_] = &[97u8, 10u8]; match val { b"a\n" => {}, - _ => fail!(), + _ => panic!(), } let buf = vec!(97u8, 98, 99, 100); diff --git a/src/test/run-pass/cell-does-not-clone.rs b/src/test/run-pass/cell-does-not-clone.rs index 97310fd9ad2e6..c7c655b3db48c 100644 --- a/src/test/run-pass/cell-does-not-clone.rs +++ b/src/test/run-pass/cell-does-not-clone.rs @@ -20,7 +20,7 @@ impl Clone for Foo { // invoked -- after all, that would permit evil user code to // abuse `Cell` and trigger crashes. - fail!(); + panic!(); } } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index dd3a7b86bea83..aab06c0339be2 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -75,7 +75,7 @@ impl MutableMap for cat { true } - fn find_mut(&mut self, _k: &int) -> Option<&mut T> { fail!() } + fn find_mut(&mut self, _k: &int) -> Option<&mut T> { panic!() } fn remove(&mut self, k: &int) -> bool { if self.find(k).is_some() { @@ -85,16 +85,16 @@ impl MutableMap for cat { } } - fn pop(&mut self, _k: &int) -> Option { fail!() } + fn pop(&mut self, _k: &int) -> Option { panic!() } - fn swap(&mut self, _k: int, _v: T) -> Option { fail!() } + fn swap(&mut self, _k: int, _v: T) -> Option { panic!() } } impl cat { pub fn get(&self, k: &int) -> &T { match self.find(k) { Some(v) => { v } - None => { fail!("epic fail"); } + None => { panic!("epic fail"); } } } diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index fda4a31375bcd..97134a9d38937 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -14,7 +14,7 @@ // // 1. Partial cleanup of `box` is in scope, // 2. cleanup of return value from `get_bar()` is in scope, -// 3. do_it() fails. +// 3. do_it() panics. // // This led to a bug because `the top-most frame that was to be // cleaned (which happens to be the partial cleanup of `box`) required @@ -33,7 +33,7 @@ enum Conzabble { struct Foo { field: Box } fn do_it(x: &[uint]) -> Foo { - fail!() + panic!() } fn get_bar(x: uint) -> Vec { vec!(x * 2) } diff --git a/src/test/run-pass/closure-return-bang.rs b/src/test/run-pass/closure-return-bang.rs index e164aeca013b2..9b4033ae0d722 100644 --- a/src/test/run-pass/closure-return-bang.rs +++ b/src/test/run-pass/closure-return-bang.rs @@ -15,6 +15,6 @@ fn f(x: || -> !) -> ! { } fn main() { - let x: || -> ! = || fail!(); + let x: || -> ! = || panic!(); let _y: || -> ! = || x(); } diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 116aa462a0ae2..e5891b2f48dff 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -80,7 +80,7 @@ mod m { // Since the bogus configuration isn't defined main will just be // parsed, but nothing further will be done with it #[cfg(bogus)] -pub fn main() { fail!() } +pub fn main() { panic!() } pub fn main() { // Exercise some of the configured items in ways that wouldn't be possible @@ -94,7 +94,7 @@ pub fn main() { fn test_in_fn_ctxt() { #[cfg(bogus)] - fn f() { fail!() } + fn f() { panic!() } fn f() { } f(); diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass/conditional-debug-macro-off.rs index 29d329d46a05a..f87d92dc16f7f 100644 --- a/src/test/run-pass/conditional-debug-macro-off.rs +++ b/src/test/run-pass/conditional-debug-macro-off.rs @@ -16,6 +16,6 @@ extern crate log; pub fn main() { - // only fails if println! evaluates its argument. - debug!("{}", { if true { fail!() } }); + // only panics if println! evaluates its argument. + debug!("{}", { if true { panic!() } }); } diff --git a/src/test/run-pass/conditional-debug-macro-on.rs b/src/test/run-pass/conditional-debug-macro-on.rs index 9d09740f3b45e..0591828bb132b 100644 --- a/src/test/run-pass/conditional-debug-macro-on.rs +++ b/src/test/run-pass/conditional-debug-macro-on.rs @@ -12,8 +12,8 @@ pub fn main() { // exits early if println! evaluates its arguments, otherwise it - // will hit the fail. + // will hit the panic. println!("{}", { if true { return; } }); - fail!(); + panic!(); } diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs index ac2e879ceacc9..1b9bd5e5692af 100644 --- a/src/test/run-pass/const-big-enum.rs +++ b/src/test/run-pass/const-big-enum.rs @@ -19,18 +19,18 @@ static X: Foo = Baz; pub fn main() { match X { Baz => {} - _ => fail!() + _ => panic!() } match Y { Bar(s) => assert!(s == 2654435769), - _ => fail!() + _ => panic!() } match Z { Quux(d,h) => { assert_eq!(d, 0x123456789abcdef0); assert_eq!(h, 0x1234); } - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/const-enum-byref-self.rs b/src/test/run-pass/const-enum-byref-self.rs index eaca18be93a13..465830c6e1298 100644 --- a/src/test/run-pass/const-enum-byref-self.rs +++ b/src/test/run-pass/const-enum-byref-self.rs @@ -15,7 +15,7 @@ impl E { pub fn method(&self) { match *self { V => {} - VV(..) => fail!() + VV(..) => panic!() } } } diff --git a/src/test/run-pass/const-enum-byref.rs b/src/test/run-pass/const-enum-byref.rs index ee7e3c7c66300..4cad4acf147ff 100644 --- a/src/test/run-pass/const-enum-byref.rs +++ b/src/test/run-pass/const-enum-byref.rs @@ -14,7 +14,7 @@ static C: E = V; fn f(a: &E) { match *a { V => {} - VV(..) => fail!() + VV(..) => panic!() } } diff --git a/src/test/run-pass/const-enum-ptr.rs b/src/test/run-pass/const-enum-ptr.rs index c1e3889d613d9..02d8fcf201d83 100644 --- a/src/test/run-pass/const-enum-ptr.rs +++ b/src/test/run-pass/const-enum-ptr.rs @@ -14,6 +14,6 @@ static C: &'static E = &V0; pub fn main() { match *C { V0 => (), - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/const-enum-structlike.rs b/src/test/run-pass/const-enum-structlike.rs index c4e36ba7b4e39..3cd7db69f074a 100644 --- a/src/test/run-pass/const-enum-structlike.rs +++ b/src/test/run-pass/const-enum-structlike.rs @@ -19,7 +19,7 @@ static C: E = S1 { u: 23 }; pub fn main() { match C { - S0 { .. } => fail!(), + S0 { .. } => panic!(), S1 { u } => assert!(u == 23) } } diff --git a/src/test/run-pass/const-enum-vec-index.rs b/src/test/run-pass/const-enum-vec-index.rs index 2a00daa3c038c..9177cad9d6241 100644 --- a/src/test/run-pass/const-enum-vec-index.rs +++ b/src/test/run-pass/const-enum-vec-index.rs @@ -19,19 +19,19 @@ static D1: E = C[1]; pub fn main() { match C0 { V0 => (), - _ => fail!() + _ => panic!() } match C1 { V1(n) => assert!(n == 0xDEADBEE), - _ => fail!() + _ => panic!() } match D0 { V0 => (), - _ => fail!() + _ => panic!() } match D1 { V1(n) => assert!(n == 0xDEADBEE), - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs index 95c4ed836c769..8723b2815dabe 100644 --- a/src/test/run-pass/const-enum-vec-ptr.rs +++ b/src/test/run-pass/const-enum-vec-ptr.rs @@ -14,10 +14,10 @@ static C: &'static [E] = &[V0, V1(0xDEADBEE), V0]; pub fn main() { match C[1] { V1(n) => assert!(n == 0xDEADBEE), - _ => fail!() + _ => panic!() } match C[2] { V0 => (), - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/const-enum-vector.rs b/src/test/run-pass/const-enum-vector.rs index 3dc5b918f7f58..e94e1de2e2d1e 100644 --- a/src/test/run-pass/const-enum-vector.rs +++ b/src/test/run-pass/const-enum-vector.rs @@ -14,10 +14,10 @@ static C: [E, ..3] = [V0, V1(0xDEADBEE), V0]; pub fn main() { match C[1] { V1(n) => assert!(n == 0xDEADBEE), - _ => fail!() + _ => panic!() } match C[2] { V0 => (), - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/const-nullary-enum.rs b/src/test/run-pass/const-nullary-enum.rs index bc61c8e9aecf5..2d023317db623 100644 --- a/src/test/run-pass/const-nullary-enum.rs +++ b/src/test/run-pass/const-nullary-enum.rs @@ -19,11 +19,11 @@ static X: Foo = Bar; pub fn main() { match X { Bar => {} - Baz | Boo => fail!() + Baz | Boo => panic!() } match Y { Baz => {} - Bar | Boo => fail!() + Bar | Boo => panic!() } } diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index b4a54b599fe8a..d8dfb433e6d49 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -25,14 +25,14 @@ use std::time::Duration; use std::str; macro_rules! succeed( ($e:expr) => ( - match $e { Ok(..) => {}, Err(e) => fail!("failure: {}", e) } + match $e { Ok(..) => {}, Err(e) => panic!("panic: {}", e) } ) ) fn test_destroy_once() { let mut p = sleeper(); match p.signal_exit() { Ok(()) => {} - Err(e) => fail!("error: {}", e), + Err(e) => panic!("error: {}", e), } } @@ -91,7 +91,7 @@ pub fn test_destroy_actually_kills(force: bool) { } }); match p.wait().unwrap() { - ExitStatus(..) => fail!("expected a signal"), + ExitStatus(..) => panic!("expected a signal"), ExitSignal(..) => tx.send(()), } } diff --git a/src/test/run-pass/deriving-cmp-shortcircuit.rs b/src/test/run-pass/deriving-cmp-shortcircuit.rs index df5c58ff04b6d..fd59b804da376 100644 --- a/src/test/run-pass/deriving-cmp-shortcircuit.rs +++ b/src/test/run-pass/deriving-cmp-shortcircuit.rs @@ -9,22 +9,22 @@ // except according to those terms. // check that the derived impls for the comparison traits shortcircuit -// where possible, by having a type that fails when compared as the +// where possible, by having a type that panics when compared as the // second element, so this passes iff the instances shortcircuit. pub struct FailCmp; impl PartialEq for FailCmp { - fn eq(&self, _: &FailCmp) -> bool { fail!("eq") } + fn eq(&self, _: &FailCmp) -> bool { panic!("eq") } } impl PartialOrd for FailCmp { - fn partial_cmp(&self, _: &FailCmp) -> Option { fail!("partial_cmp") } + fn partial_cmp(&self, _: &FailCmp) -> Option { panic!("partial_cmp") } } impl Eq for FailCmp {} impl Ord for FailCmp { - fn cmp(&self, _: &FailCmp) -> Ordering { fail!("cmp") } + fn cmp(&self, _: &FailCmp) -> Ordering { panic!("cmp") } } #[deriving(PartialEq,PartialOrd,Eq,Ord)] diff --git a/src/test/run-pass/die-macro.rs b/src/test/run-pass/die-macro.rs index df1e4132cb737..565e33ce01e17 100644 --- a/src/test/run-pass/die-macro.rs +++ b/src/test/run-pass/die-macro.rs @@ -8,14 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Just testing that fail!() type checks in statement or expr +// Just testing that panic!() type checks in statement or expr #![allow(unreachable_code)] fn f() { - fail!(); + panic!(); - let _x: int = fail!(); + let _x: int = panic!(); } pub fn main() { diff --git a/src/test/run-pass/drop-trait-enum.rs b/src/test/run-pass/drop-trait-enum.rs index 977eaa13fc108..6f4e927abd5da 100644 --- a/src/test/run-pass/drop-trait-enum.rs +++ b/src/test/run-pass/drop-trait-enum.rs @@ -44,7 +44,7 @@ impl Drop for Foo { sender.send(DestructorRan); } &FailingVariant { .. } => { - fail!("Failed"); + panic!("Failed"); } } } diff --git a/src/test/run-pass/dst-deref-mut.rs b/src/test/run-pass/dst-deref-mut.rs index 465529ac90941..c2707a1ae6e90 100644 --- a/src/test/run-pass/dst-deref-mut.rs +++ b/src/test/run-pass/dst-deref-mut.rs @@ -16,7 +16,7 @@ pub struct Arr { impl Deref<[uint]> for Arr { fn deref(&self) -> &[uint] { - fail!(); + panic!(); } } diff --git a/src/test/run-pass/enum-alignment.rs b/src/test/run-pass/enum-alignment.rs index a1ef12a7657fe..27560986e0253 100644 --- a/src/test/run-pass/enum-alignment.rs +++ b/src/test/run-pass/enum-alignment.rs @@ -24,7 +24,7 @@ fn is_aligned(ptr: &T) -> bool { pub fn main() { let x = Some(0u64); match x { - None => fail!(), + None => panic!(), Some(ref y) => assert!(is_aligned(y)) } } diff --git a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs index 24fb503aea3a9..d6cdce7390a60 100644 --- a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs +++ b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs @@ -20,6 +20,6 @@ pub fn main() { match Cons(10i, box Nil) { Cons(10i, _) => {} Nil => {} - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/expr-if-fail-all.rs b/src/test/run-pass/expr-if-fail-all.rs index 8e56011e6dcec..0dd7ddc3f846a 100644 --- a/src/test/run-pass/expr-if-fail-all.rs +++ b/src/test/run-pass/expr-if-fail-all.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// When all branches of an if expression result in fail, the entire if -// expression results in fail. +// When all branches of an if expression result in panic, the entire if +// expression results in panic. pub fn main() { let _x = if true { 10i } else { - if true { fail!() } else { fail!() } + if true { panic!() } else { panic!() } }; } diff --git a/src/test/run-pass/expr-if-fail.rs b/src/test/run-pass/expr-if-fail.rs index e9f116fcdd425..aa4240c60f1df 100644 --- a/src/test/run-pass/expr-if-fail.rs +++ b/src/test/run-pass/expr-if-fail.rs @@ -8,19 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test_if_fail() { - let x = if false { fail!() } else { 10i }; +fn test_if_panic() { + let x = if false { panic!() } else { 10i }; assert!((x == 10)); } -fn test_else_fail() { - let x = if true { 10i } else { fail!() }; +fn test_else_panic() { + let x = if true { 10i } else { panic!() }; assert_eq!(x, 10i); } -fn test_elseif_fail() { - let x = if false { 0i } else if false { fail!() } else { 10i }; +fn test_elseif_panic() { + let x = if false { 0i } else if false { panic!() } else { 10i }; assert_eq!(x, 10i); } -pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); } +pub fn main() { test_if_panic(); test_else_panic(); test_elseif_panic(); } diff --git a/src/test/run-pass/expr-match-fail-all.rs b/src/test/run-pass/expr-match-fail-all.rs index 0d23098d8fc77..3b33c18bbbd59 100644 --- a/src/test/run-pass/expr-match-fail-all.rs +++ b/src/test/run-pass/expr-match-fail-all.rs @@ -11,12 +11,12 @@ -// When all branches of a match expression result in fail, the entire -// match expression results in fail. +// When all branches of a match expression result in panic, the entire +// match expression results in panic. pub fn main() { let _x = match true { true => { 10i } - false => { match true { true => { fail!() } false => { fail!() } } } + false => { match true { true => { panic!() } false => { panic!() } } } }; } diff --git a/src/test/run-pass/expr-match-fail.rs b/src/test/run-pass/expr-match-fail.rs index 1f246581687b1..d8ee21dfdc6b9 100644 --- a/src/test/run-pass/expr-match-fail.rs +++ b/src/test/run-pass/expr-match-fail.rs @@ -10,12 +10,12 @@ fn test_simple() { - let r = match true { true => { true } false => { fail!() } }; + let r = match true { true => { true } false => { panic!() } }; assert_eq!(r, true); } fn test_box() { - let r = match true { true => { vec!(10i) } false => { fail!() } }; + let r = match true { true => { vec!(10i) } false => { panic!() } }; assert_eq!(r[0], 10i); } diff --git a/src/test/run-pass/expr-match-generic-unique1.rs b/src/test/run-pass/expr-match-generic-unique1.rs index e2f8f7c8ebf0a..aed4024b5bc5c 100644 --- a/src/test/run-pass/expr-match-generic-unique1.rs +++ b/src/test/run-pass/expr-match-generic-unique1.rs @@ -14,7 +14,7 @@ type compare = |Box, Box|: 'static -> bool; fn test_generic(expected: Box, eq: compare) { let actual: Box = match true { true => { expected.clone() }, - _ => fail!("wat") + _ => panic!("wat") }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-match-generic-unique2.rs b/src/test/run-pass/expr-match-generic-unique2.rs index a9b02a6e79938..89adef378f1a1 100644 --- a/src/test/run-pass/expr-match-generic-unique2.rs +++ b/src/test/run-pass/expr-match-generic-unique2.rs @@ -14,7 +14,7 @@ type compare<'a, T> = |T, T|: 'a -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => expected.clone(), - _ => fail!("wat") + _ => panic!("wat") }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-match-generic.rs b/src/test/run-pass/expr-match-generic.rs index ff19862fee343..c74caf4de4bdc 100644 --- a/src/test/run-pass/expr-match-generic.rs +++ b/src/test/run-pass/expr-match-generic.rs @@ -12,7 +12,7 @@ type compare = extern "Rust" fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { - let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; + let actual: T = match true { true => { expected.clone() }, _ => panic!("wat") }; assert!((eq(expected, actual))); } diff --git a/src/test/run-pass/expr-match-struct.rs b/src/test/run-pass/expr-match-struct.rs index 3d01c6653a7a0..21b0c28495e6b 100644 --- a/src/test/run-pass/expr-match-struct.rs +++ b/src/test/run-pass/expr-match-struct.rs @@ -16,7 +16,7 @@ struct R { i: int } fn test_rec() { - let rs = match true { true => R {i: 100}, _ => fail!() }; + let rs = match true { true => R {i: 100}, _ => panic!() }; assert_eq!(rs.i, 100); } diff --git a/src/test/run-pass/expr-match-unique.rs b/src/test/run-pass/expr-match-unique.rs index 3ee0a232d19c0..83f2ada02b0ff 100644 --- a/src/test/run-pass/expr-match-unique.rs +++ b/src/test/run-pass/expr-match-unique.rs @@ -11,7 +11,7 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { box 100i }, _ => fail!() }; + let res = match true { true => { box 100i }, _ => panic!() }; assert_eq!(*res, 100i); } diff --git a/src/test/run-pass/fail-during-tld-destroy.rs b/src/test/run-pass/fail-during-tld-destroy.rs index 3faa30c4c8a20..2f0d6cf90aa5a 100644 --- a/src/test/run-pass/fail-during-tld-destroy.rs +++ b/src/test/run-pass/fail-during-tld-destroy.rs @@ -16,7 +16,7 @@ struct Foo; impl Drop for Foo { fn drop(&mut self) { unsafe { DROPS += 1; } - fail!() + panic!() } } diff --git a/src/test/run-pass/fail-in-dtor-drops-fields.rs b/src/test/run-pass/fail-in-dtor-drops-fields.rs index be4a497989ce8..46924c74a8c46 100644 --- a/src/test/run-pass/fail-in-dtor-drops-fields.rs +++ b/src/test/run-pass/fail-in-dtor-drops-fields.rs @@ -22,7 +22,7 @@ struct B { impl Drop for A { fn drop(&mut self) { - fail!() + panic!() } } diff --git a/src/test/run-pass/for-loop-fail.rs b/src/test/run-pass/for-loop-fail.rs index c0f6b14dc2748..d157da3139fdb 100644 --- a/src/test/run-pass/for-loop-fail.rs +++ b/src/test/run-pass/for-loop-fail.rs @@ -9,4 +9,4 @@ // except according to those terms. -pub fn main() { let x: Vec = Vec::new(); for _ in x.iter() { fail!("moop"); } } +pub fn main() { let x: Vec = Vec::new(); for _ in x.iter() { panic!("moop"); } } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index afa4b7a1ad0be..a3df98afcb0c5 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -19,7 +19,7 @@ pub fn main() { match getopts(args.as_slice(), opts.as_slice()) { Ok(ref m) => assert!(!m.opt_present("b")), - Err(ref f) => fail!("{}", *f) + Err(ref f) => panic!("{}", *f) }; } diff --git a/src/test/run-pass/hygienic-labels.rs b/src/test/run-pass/hygienic-labels.rs index abb0bdab71f8b..53c081ff83e0e 100644 --- a/src/test/run-pass/hygienic-labels.rs +++ b/src/test/run-pass/hygienic-labels.rs @@ -35,23 +35,23 @@ pub fn main() { 'x: for _ in range(0i, 1) { // this 'x should refer to the outer loop, lexically loop_x!(break 'x); - fail!("break doesn't act hygienically inside for loop"); + panic!("break doesn't act hygienically inside for loop"); } 'x: loop { // ditto loop_x!(break 'x); - fail!("break doesn't act hygienically inside infinite loop"); + panic!("break doesn't act hygienically inside infinite loop"); } 'x: while 1i + 1 == 2 { while_x!(break 'x); - fail!("break doesn't act hygienically inside infinite while loop"); + panic!("break doesn't act hygienically inside infinite while loop"); } 'x: for _ in range(0i, 1) { // ditto run_once!(continue 'x); - fail!("continue doesn't act hygienically inside for loop"); + panic!("continue doesn't act hygienically inside for loop"); } } diff --git a/src/test/run-pass/if-bot.rs b/src/test/run-pass/if-bot.rs index bfe3e9beddc54..44c834d233fe7 100644 --- a/src/test/run-pass/if-bot.rs +++ b/src/test/run-pass/if-bot.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - let i: int = if false { fail!() } else { 5 }; + let i: int = if false { panic!() } else { 5 }; println!("{}", i); } diff --git a/src/test/run-pass/if-check.rs b/src/test/run-pass/if-check.rs index 22b5281ef38f0..660a6147d08d4 100644 --- a/src/test/run-pass/if-check.rs +++ b/src/test/run-pass/if-check.rs @@ -18,7 +18,7 @@ fn foo(x: uint) { if even(x) { println!("{}", x); } else { - fail!(); + panic!(); } } diff --git a/src/test/run-pass/if-let.rs b/src/test/run-pass/if-let.rs index 4bf3a85677c72..a07b783278672 100644 --- a/src/test/run-pass/if-let.rs +++ b/src/test/run-pass/if-let.rs @@ -15,7 +15,7 @@ pub fn main() { if let Some(y) = x { assert_eq!(y, 3i); } else { - fail!("if-let failed"); + panic!("if-let panicked"); } let mut worked = false; if let Some(_) = x { @@ -35,9 +35,9 @@ pub fn main() { assert_eq!(clause, 4u); if 3i > 4 { - fail!("bad math"); + panic!("bad math"); } else if let 1 = 2i { - fail!("bad pattern match"); + panic!("bad pattern match"); } enum Foo { @@ -48,22 +48,22 @@ pub fn main() { let foo = Three("three".to_string(), 42i); if let One = foo { - fail!("bad pattern match"); + panic!("bad pattern match"); } else if let Two(_x) = foo { - fail!("bad pattern match"); + panic!("bad pattern match"); } else if let Three(s, _) = foo { assert_eq!(s.as_slice(), "three"); } else { - fail!("bad else"); + panic!("bad else"); } if false { - fail!("wat"); + panic!("wat"); } else if let a@Two(_) = Two(42u) { if let Two(b) = a { assert_eq!(b, 42u); } else { - fail!("fail in nested if-let"); + panic!("panic in nested if-let"); } } } diff --git a/src/test/run-pass/inherent-trait-method-order.rs b/src/test/run-pass/inherent-trait-method-order.rs index 416c070180454..6643636c5704d 100644 --- a/src/test/run-pass/inherent-trait-method-order.rs +++ b/src/test/run-pass/inherent-trait-method-order.rs @@ -13,7 +13,7 @@ struct Foo; impl Foo { #[allow(dead_code)] fn foo(self) { - fail!("wrong method!") + panic!("wrong method!") } } diff --git a/src/test/run-pass/issue-10392.rs b/src/test/run-pass/issue-10392.rs index 796fae7dc3298..1aa9c96de1a94 100644 --- a/src/test/run-pass/issue-10392.rs +++ b/src/test/run-pass/issue-10392.rs @@ -11,8 +11,8 @@ struct A { foo: int } struct B { a: int, b: int, c: int } -fn mka() -> A { fail!() } -fn mkb() -> B { fail!() } +fn mka() -> A { panic!() } +fn mkb() -> B { panic!() } fn test() { let A { foo, } = mka(); diff --git a/src/test/run-pass/issue-10734.rs b/src/test/run-pass/issue-10734.rs index a30cf71732851..1c267f4833752 100644 --- a/src/test/run-pass/issue-10734.rs +++ b/src/test/run-pass/issue-10734.rs @@ -35,7 +35,7 @@ pub fn main() { // An `if false {} else { expr }` statement should compile the same as `{ expr }`. if false { - fail!(); + panic!(); } else { let _a = Foo{ dropped: false }; } diff --git a/src/test/run-pass/issue-11552.rs b/src/test/run-pass/issue-11552.rs index 42b5bbc8623e4..106bb7f701c96 100644 --- a/src/test/run-pass/issue-11552.rs +++ b/src/test/run-pass/issue-11552.rs @@ -20,7 +20,7 @@ fn fas(n: &Noun) -> Noun { match n { &Cell(box Atom(2), box Cell(ref a, _)) => (**a).clone(), - _ => fail!("Invalid fas pattern") + _ => panic!("Invalid fas pattern") } } diff --git a/src/test/run-pass/issue-11709.rs b/src/test/run-pass/issue-11709.rs index d299b853aeeb1..0567a5836abfa 100644 --- a/src/test/run-pass/issue-11709.rs +++ b/src/test/run-pass/issue-11709.rs @@ -10,10 +10,10 @@ // ignore-pretty -// Don't fail on blocks without results +// Don't panic on blocks without results // There are several tests in this run-pass that raised // when this bug was opened. The cases where the compiler -// failed before the fix have a comment. +// panics before the fix have a comment. struct S {x:()} @@ -31,8 +31,8 @@ fn not(b: bool) -> bool { if b { !b } else { - // `fail!(...)` would break - fail!("Break the compiler"); + // `panic!(...)` would break + panic!("Break the compiler"); } } diff --git a/src/test/run-pass/issue-13259-windows-tcb-trash.rs b/src/test/run-pass/issue-13259-windows-tcb-trash.rs index 1a909db92e328..0e42bdbd6add7 100644 --- a/src/test/run-pass/issue-13259-windows-tcb-trash.rs +++ b/src/test/run-pass/issue-13259-windows-tcb-trash.rs @@ -32,7 +32,7 @@ mod imp { FormatMessageW(0x1000, 0 as *mut c_void, 1, 0x400, buf.as_mut_ptr(), buf.len() as u32, 0 as *const c_void) }; - // On some 32-bit Windowses (Win7-8 at least) this will fail with segmented + // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented // stacks taking control of pvArbitrary assert!(ret != 0); } diff --git a/src/test/run-pass/issue-14865.rs b/src/test/run-pass/issue-14865.rs index c84b1eae8e097..e3cc653909f33 100644 --- a/src/test/run-pass/issue-14865.rs +++ b/src/test/run-pass/issue-14865.rs @@ -17,14 +17,14 @@ fn main() { let x = match Foo(42) { Foo(..) => 1i, _ if true => 0, - Bar(..) => fail!("Oh dear") + Bar(..) => panic!("Oh dear") }; assert_eq!(x, 1); let x = match Foo(42) { _ if true => 0i, Foo(..) => 1, - Bar(..) => fail!("Oh dear") + Bar(..) => panic!("Oh dear") }; assert_eq!(x, 0); } diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index 3aaa480d776c2..3c5af9ca032c1 100644 --- a/src/test/run-pass/issue-1516.rs +++ b/src/test/run-pass/issue-1516.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - let early_error: |&str|: 'static -> ! = |_msg| { fail!() }; + let early_error: |&str|: 'static -> ! = |_msg| { panic!() }; } diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index b03bfb958af1b..e0b98ab19652a 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -15,7 +15,7 @@ struct foo { impl foo { pub fn bar>(&self, _c: C) -> B { - fail!(); + panic!(); } } diff --git a/src/test/run-pass/issue-2312.rs b/src/test/run-pass/issue-2312.rs index 14b5efe904db8..8c597552d75aa 100644 --- a/src/test/run-pass/issue-2312.rs +++ b/src/test/run-pass/issue-2312.rs @@ -15,7 +15,7 @@ trait clam { } struct foo(int); impl foo { - pub fn bar>(&self, _c: C) -> B { fail!(); } + pub fn bar>(&self, _c: C) -> B { panic!(); } } pub fn main() { } diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs index 8a9e2d28776a7..2608c89d15567 100644 --- a/src/test/run-pass/issue-2611-3.rs +++ b/src/test/run-pass/issue-2611-3.rs @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } + fn b(_x: F) -> F { panic!() } //~^ ERROR in method `b`, type parameter 0 has 1 bound, but } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index c52dd5ce5e4e3..cb17b7f6a6cc0 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -56,9 +56,9 @@ pub mod pipes { } mod rusti { - pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail!(); } - pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail!(); } - pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail!(); } + pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { panic!(); } + pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { panic!(); } + pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { panic!(); } } // We should consider moving this to ::std::unsafe, although I @@ -92,7 +92,7 @@ pub mod pipes { // The receiver will eventually clean this up. unsafe { forget(p); } } - full => { fail!("duplicate send") } + full => { panic!("duplicate send") } blocked => { // The receiver will eventually clean this up. @@ -134,7 +134,7 @@ pub mod pipes { } full => { // This is impossible - fail!("you dun goofed") + panic!("you dun goofed") } terminated => { // I have to clean up, use drop_glue @@ -151,7 +151,7 @@ pub mod pipes { } blocked => { // this shouldn't happen. - fail!("terminating a blocked packet") + panic!("terminating a blocked packet") } terminated | full => { // I have to clean up, use drop_glue @@ -236,7 +236,7 @@ pub mod pingpong { let _addr : *const ::pipes::send_packet = match &p { &ping(ref x) => { mem::transmute(x) } }; - fail!() + panic!() } } @@ -245,7 +245,7 @@ pub mod pingpong { let _addr : *const ::pipes::send_packet = match &p { &pong(ref x) => { mem::transmute(x) } }; - fail!() + panic!() } } @@ -269,7 +269,7 @@ pub mod pingpong { pub fn do_pong(c: pong) -> (ping, ()) { let packet = ::pipes::recv(c); if packet.is_none() { - fail!("sender closed the connection") + panic!("sender closed the connection") } (pingpong::liberate_pong(packet.unwrap()), ()) } @@ -284,7 +284,7 @@ pub mod pingpong { pub fn do_ping(c: ping) -> (pong, ()) { let packet = ::pipes::recv(c); if packet.is_none() { - fail!("sender closed the connection") + panic!("sender closed the connection") } (pingpong::liberate_ping(packet.unwrap()), ()) } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 1964001cebd8e..04866c56913b1 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -53,7 +53,7 @@ fn square_from_char(c: char) -> square { ' ' => { empty } _ => { println!("invalid square: {}", c); - fail!() + panic!() } } } diff --git a/src/test/run-pass/issue-3895.rs b/src/test/run-pass/issue-3895.rs index efe0cb8d491d9..ee075db272350 100644 --- a/src/test/run-pass/issue-3895.rs +++ b/src/test/run-pass/issue-3895.rs @@ -13,6 +13,6 @@ pub fn main() { match BadChar { _ if true => BadChar, - BadChar | BadSyntax => fail!() , + BadChar | BadSyntax => panic!() , }; } diff --git a/src/test/run-pass/issue-4016.rs b/src/test/run-pass/issue-4016.rs index 20b818f47d477..e5cc8414f064b 100644 --- a/src/test/run-pass/issue-4016.rs +++ b/src/test/run-pass/issue-4016.rs @@ -19,7 +19,7 @@ fn exec() { let doc = json::from_str("").unwrap(); let mut decoder = json::Decoder::new(doc); let _v: T = Decodable::decode(&mut decoder).unwrap(); - fail!() + panic!() } pub fn main() {} diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index d8c08f8ac3214..3130c0441a5bd 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -48,7 +48,7 @@ priv fn parse_list(len: uint, io: @io::Reader) -> Result { let v = match io.read_char() { '$' => parse_bulk(io), ':' => parse_int(io), - _ => fail!() + _ => panic!() }; list.push(v); } @@ -61,26 +61,26 @@ priv fn chop(s: String) -> String { priv fn parse_bulk(io: @io::Reader) -> Result { match from_str::(chop(io.read_line())) { - None => fail!(), + None => panic!(), Some(-1) => Nil, Some(len) if len >= 0 => parse_data(len as uint, io), - Some(_) => fail!() + Some(_) => panic!() } } priv fn parse_multi(io: @io::Reader) -> Result { match from_str::(chop(io.read_line())) { - None => fail!(), + None => panic!(), Some(-1) => Nil, Some(0) => List(~[]), Some(len) if len >= 0 => parse_list(len as uint, io), - Some(_) => fail!() + Some(_) => panic!() } } priv fn parse_int(io: @io::Reader) -> Result { match from_str::(chop(io.read_line())) { - None => fail!(), + None => panic!(), Some(i) => Int(i) } } @@ -92,7 +92,7 @@ priv fn parse_response(io: @io::Reader) -> Result { '+' => Status(chop(io.read_line())), '-' => Error(chop(io.read_line())), ':' => parse_int(io), - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/issue-5521.rs b/src/test/run-pass/issue-5521.rs index be75c7230427b..fb0e8e599eb2a 100644 --- a/src/test/run-pass/issue-5521.rs +++ b/src/test/run-pass/issue-5521.rs @@ -15,7 +15,7 @@ extern crate "issue-5521" as foo; fn bar(a: foo::map) { if false { - fail!(); + panic!(); } else { let _b = &(*a)[2]; } diff --git a/src/test/run-pass/issue-6128.rs b/src/test/run-pass/issue-6128.rs index 29775e4a69921..4b31f39330932 100644 --- a/src/test/run-pass/issue-6128.rs +++ b/src/test/run-pass/issue-6128.rs @@ -19,7 +19,7 @@ trait Graph { impl Graph for HashMap { fn f(&self, _e: E) { - fail!(); + panic!(); } } diff --git a/src/test/run-pass/issue-6449.rs b/src/test/run-pass/issue-6449.rs index 48e2890b2594f..5a6dea8d15bff 100644 --- a/src/test/run-pass/issue-6449.rs +++ b/src/test/run-pass/issue-6449.rs @@ -20,25 +20,25 @@ enum Other { fn main() { match Baz { - ::Bar(3) => fail!(), - ::Bar(_) if false => fail!(), - ::Bar(..) if false => fail!(), - ::Bar(_n) => fail!(), + ::Bar(3) => panic!(), + ::Bar(_) if false => panic!(), + ::Bar(..) if false => panic!(), + ::Bar(_n) => panic!(), ::Baz => {} } match Bar(3) { ::Bar(3) => {} - ::Bar(_) if false => fail!(), - ::Bar(..) if false => fail!(), - ::Bar(_n) => fail!(), - ::Baz => fail!(), + ::Bar(_) if false => panic!(), + ::Bar(..) if false => panic!(), + ::Bar(_n) => panic!(), + ::Baz => panic!(), } match Bar(4) { - ::Bar(3) => fail!(), - ::Bar(_) if false => fail!(), - ::Bar(..) if false => fail!(), + ::Bar(3) => panic!(), + ::Bar(_) if false => panic!(), + ::Bar(..) if false => panic!(), ::Bar(n) => assert_eq!(n, 4), - ::Baz => fail!(), + ::Baz => panic!(), } match Other1(Baz) { diff --git a/src/test/run-pass/issue-8351-1.rs b/src/test/run-pass/issue-8351-1.rs index ac389c8e4947a..c1d5bb0961bba 100644 --- a/src/test/run-pass/issue-8351-1.rs +++ b/src/test/run-pass/issue-8351-1.rs @@ -18,8 +18,8 @@ enum E { pub fn main() { let e = Foo{f: 0}; match e { - Foo{f: 1} => fail!(), + Foo{f: 1} => panic!(), Foo{..} => (), - _ => fail!(), + _ => panic!(), } } diff --git a/src/test/run-pass/issue-8351-2.rs b/src/test/run-pass/issue-8351-2.rs index 9ce24200d690b..28b37826812a3 100644 --- a/src/test/run-pass/issue-8351-2.rs +++ b/src/test/run-pass/issue-8351-2.rs @@ -18,8 +18,8 @@ enum E { pub fn main() { let e = Foo{f: 0, b: false}; match e { - Foo{f: 1, b: true} => fail!(), + Foo{f: 1, b: true} => panic!(), Foo{b: false, f: 0} => (), - _ => fail!(), + _ => panic!(), } } diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index 05bf8e01c5874..c0dcf9e609418 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -15,7 +15,7 @@ fn lp(s: String, f: |String| -> T) -> T { let r = f(s); return (r); } - fail!(); + panic!(); } fn apply(s: String, f: |String| -> T) -> T { diff --git a/src/test/run-pass/logging-enabled-debug.rs b/src/test/run-pass/logging-enabled-debug.rs index 7975af434d284..4b97d274fbae4 100644 --- a/src/test/run-pass/logging-enabled-debug.rs +++ b/src/test/run-pass/logging-enabled-debug.rs @@ -17,6 +17,6 @@ extern crate log; pub fn main() { if log_enabled!(log::DEBUG) { - fail!("what?! debugging?"); + panic!("what?! debugging?"); } } diff --git a/src/test/run-pass/logging-enabled.rs b/src/test/run-pass/logging-enabled.rs index 184ac713c899b..c4f7b1492ab57 100644 --- a/src/test/run-pass/logging-enabled.rs +++ b/src/test/run-pass/logging-enabled.rs @@ -16,9 +16,9 @@ extern crate log; pub fn main() { if log_enabled!(log::DEBUG) { - fail!("what?! debugging?"); + panic!("what?! debugging?"); } if !log_enabled!(log::INFO) { - fail!("what?! no info?"); + panic!("what?! no info?"); } } diff --git a/src/test/run-pass/logging-right-crate.rs b/src/test/run-pass/logging-right-crate.rs index 31c2ae891e068..ced1fdc445519 100644 --- a/src/test/run-pass/logging-right-crate.rs +++ b/src/test/run-pass/logging-right-crate.rs @@ -19,11 +19,11 @@ // monomorphized functions from other crates had logging turned on (their // logging module names were all incorrect). This test ensures that this no // longer happens by enabling logging for *this* crate and then invoking a -// function in an external crate which will fail when logging is enabled. +// function in an external crate which will panic when logging is enabled. extern crate logging_right_crate; pub fn main() { - // this function fails if logging is turned on + // this function panicks if logging is turned on logging_right_crate::foo::(); } diff --git a/src/test/run-pass/loop-no-reinit-needed-post-bot.rs b/src/test/run-pass/loop-no-reinit-needed-post-bot.rs index 14aee4c3be81d..0f4dd881698a4 100644 --- a/src/test/run-pass/loop-no-reinit-needed-post-bot.rs +++ b/src/test/run-pass/loop-no-reinit-needed-post-bot.rs @@ -13,7 +13,7 @@ struct S; impl Drop for S { fn drop(&mut self) { } } // user-defined function "returning" bottom (i.e. no return at all). -fn my_fail() -> ! { loop {} } +fn my_panic() -> ! { loop {} } pub fn step(f: bool) { let mut g = S; @@ -30,7 +30,7 @@ pub fn step(f: bool) { continue; } - my_fail(); + my_panic(); // we never get here, so we do not need to re-initialize g. } diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index 76fc05deb0eae..672efa68398ec 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -18,7 +18,7 @@ macro_rules! overly_complicated ( Some($pat) => { $res } - _ => { fail!(); } + _ => { panic!(); } } }) diff --git a/src/test/run-pass/match-bot-2.rs b/src/test/run-pass/match-bot-2.rs index f3c299bd1f913..5b48d0ff50809 100644 --- a/src/test/run-pass/match-bot-2.rs +++ b/src/test/run-pass/match-bot-2.rs @@ -9,5 +9,5 @@ // except according to those terms. // n.b. This was only ever failing with optimization disabled. -fn a() -> int { match return 1i { 2i => 3i, _ => fail!() } } +fn a() -> int { match return 1i { 2i => 3i, _ => panic!() } } pub fn main() { a(); } diff --git a/src/test/run-pass/match-bot.rs b/src/test/run-pass/match-bot.rs index 7e55e227cc07b..74cf3faea46ee 100644 --- a/src/test/run-pass/match-bot.rs +++ b/src/test/run-pass/match-bot.rs @@ -11,6 +11,6 @@ pub fn main() { let i: int = - match Some::(3) { None:: => { fail!() } Some::(_) => { 5 } }; + match Some::(3) { None:: => { panic!() } Some::(_) => { 5 } }; println!("{}", i); } diff --git a/src/test/run-pass/match-enum-struct-0.rs b/src/test/run-pass/match-enum-struct-0.rs index fef7555af5e42..6b18f3c19da2b 100644 --- a/src/test/run-pass/match-enum-struct-0.rs +++ b/src/test/run-pass/match-enum-struct-0.rs @@ -20,7 +20,7 @@ enum E { pub fn main() { let e = Bar; match e { - Foo{f: _f} => fail!(), + Foo{f: _f} => panic!(), _ => (), } } diff --git a/src/test/run-pass/match-enum-struct-1.rs b/src/test/run-pass/match-enum-struct-1.rs index 12902fb738e97..451b8f63e9576 100644 --- a/src/test/run-pass/match-enum-struct-1.rs +++ b/src/test/run-pass/match-enum-struct-1.rs @@ -19,10 +19,10 @@ pub fn main() { let e = Foo{f: 1}; match e { Foo{..} => (), - _ => fail!(), + _ => panic!(), } match e { Foo{f: _f} => (), - _ => fail!(), + _ => panic!(), } } diff --git a/src/test/run-pass/match-pattern-lit.rs b/src/test/run-pass/match-pattern-lit.rs index 9d59b197d3ab7..4265d0a5406aa 100644 --- a/src/test/run-pass/match-pattern-lit.rs +++ b/src/test/run-pass/match-pattern-lit.rs @@ -14,7 +14,7 @@ fn altlit(f: int) -> int { match f { 10 => { println!("case 10"); return 20; } 11 => { println!("case 11"); return 22; } - _ => fail!("the impossible happened") + _ => panic!("the impossible happened") } } diff --git a/src/test/run-pass/match-pipe-binding.rs b/src/test/run-pass/match-pipe-binding.rs index 2169e996577bf..ed2f7c5cb47c2 100644 --- a/src/test/run-pass/match-pipe-binding.rs +++ b/src/test/run-pass/match-pipe-binding.rs @@ -15,7 +15,7 @@ fn test1() { assert_eq!(a, "a".to_string()); assert_eq!(b, "b".to_string()); }, - _ => fail!(), + _ => panic!(), } } @@ -25,7 +25,7 @@ fn test2() { assert_eq!(a, 2); assert_eq!(b, 3); }, - _ => fail!(), + _ => panic!(), } } @@ -35,7 +35,7 @@ fn test3() { assert_eq!(*a, 2); assert_eq!(*b, 3); }, - _ => fail!(), + _ => panic!(), } } @@ -45,7 +45,7 @@ fn test4() { assert_eq!(a, 2); assert_eq!(b, 3); }, - _ => fail!(), + _ => panic!(), } } @@ -55,7 +55,7 @@ fn test5() { assert_eq!(*a, 2); assert_eq!(*b, 3); }, - _ => fail!(), + _ => panic!(), } } diff --git a/src/test/run-pass/match-range.rs b/src/test/run-pass/match-range.rs index 4761d2606fc2a..83066c126ce14 100644 --- a/src/test/run-pass/match-range.rs +++ b/src/test/run-pass/match-range.rs @@ -13,31 +13,31 @@ pub fn main() { match 5u { 1u...5u => {} - _ => fail!("should match range"), + _ => panic!("should match range"), } match 5u { - 6u...7u => fail!("shouldn't match range"), + 6u...7u => panic!("shouldn't match range"), _ => {} } match 5u { - 1u => fail!("should match non-first range"), + 1u => panic!("should match non-first range"), 2u...6u => {} - _ => fail!("math is broken") + _ => panic!("math is broken") } match 'c' { 'a'...'z' => {} - _ => fail!("should suppport char ranges") + _ => panic!("should suppport char ranges") } match -3i { -7...5 => {} - _ => fail!("should match signed range") + _ => panic!("should match signed range") } match 3.0f64 { 1.0...5.0 => {} - _ => fail!("should match float range") + _ => panic!("should match float range") } match -1.5f64 { -3.6...3.6 => {} - _ => fail!("should match negative float range") + _ => panic!("should match negative float range") } } diff --git a/src/test/run-pass/match-ref-binding-in-guard-3256.rs b/src/test/run-pass/match-ref-binding-in-guard-3256.rs index a07c63490e78e..243c87c0eeb00 100644 --- a/src/test/run-pass/match-ref-binding-in-guard-3256.rs +++ b/src/test/run-pass/match-ref-binding-in-guard-3256.rs @@ -15,7 +15,7 @@ pub fn main() { Some(ref z) if *z.lock() => { assert!(*z.lock()); }, - _ => fail!() + _ => panic!() } } } diff --git a/src/test/run-pass/match-str.rs b/src/test/run-pass/match-str.rs index d31f7a6071510..651f56e894ac8 100644 --- a/src/test/run-pass/match-str.rs +++ b/src/test/run-pass/match-str.rs @@ -11,21 +11,21 @@ // Issue #53 pub fn main() { - match "test" { "not-test" => fail!(), "test" => (), _ => fail!() } + match "test" { "not-test" => panic!(), "test" => (), _ => panic!() } enum t { tag1(String), tag2, } match tag1("test".to_string()) { - tag2 => fail!(), - tag1(ref s) if "test" != s.as_slice() => fail!(), + tag2 => panic!(), + tag1(ref s) if "test" != s.as_slice() => panic!(), tag1(ref s) if "test" == s.as_slice() => (), - _ => fail!() + _ => panic!() } - let x = match "a" { "a" => 1i, "b" => 2i, _ => fail!() }; + let x = match "a" { "a" => 1i, "b" => 2i, _ => panic!() }; assert_eq!(x, 1); - match "a" { "a" => { } "b" => { }, _ => fail!() } + match "a" { "a" => { } "b" => { }, _ => panic!() } } diff --git a/src/test/run-pass/match-struct-0.rs b/src/test/run-pass/match-struct-0.rs index 769a5ab5460a7..6d5658aa13cbf 100644 --- a/src/test/run-pass/match-struct-0.rs +++ b/src/test/run-pass/match-struct-0.rs @@ -15,15 +15,15 @@ struct Foo{ pub fn main() { let f = Foo{f: 1}; match f { - Foo{f: 0} => fail!(), + Foo{f: 0} => panic!(), Foo{..} => (), } match f { - Foo{f: 0} => fail!(), + Foo{f: 0} => panic!(), Foo{f: _f} => (), } match f { - Foo{f: 0} => fail!(), + Foo{f: 0} => panic!(), _ => (), } } diff --git a/src/test/run-pass/negative.rs b/src/test/run-pass/negative.rs index 148c1c9f0cfaf..4bf91bf703523 100644 --- a/src/test/run-pass/negative.rs +++ b/src/test/run-pass/negative.rs @@ -11,6 +11,6 @@ pub fn main() { match -5i { -5 => {} - _ => { fail!() } + _ => { panic!() } } } diff --git a/src/test/run-pass/nested-block-comment.rs b/src/test/run-pass/nested-block-comment.rs index 0cbe46cb4ef17..a6d932935ade6 100644 --- a/src/test/run-pass/nested-block-comment.rs +++ b/src/test/run-pass/nested-block-comment.rs @@ -11,7 +11,7 @@ /* This test checks that nested comments are supported /* - This should not fail + This should not panic */ */ diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index 927f8160f7e4a..19eba0808c882 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -23,7 +23,7 @@ pub fn main() { } } - // fn b(x:int) -> int { fail!(); } + // fn b(x:int) -> int { panic!(); } let z = b(42); assert_eq!(z.i, 42); diff --git a/src/test/run-pass/nested-matchs.rs b/src/test/run-pass/nested-matchs.rs index fa28025afa077..55c1de2700f95 100644 --- a/src/test/run-pass/nested-matchs.rs +++ b/src/test/run-pass/nested-matchs.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn baz() -> ! { fail!(); } +fn baz() -> ! { panic!(); } fn foo() { match Some::(5) { diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs index bc03b0d27ca8d..7fe50d667087c 100644 --- a/src/test/run-pass/nested-pattern.rs +++ b/src/test/run-pass/nested-pattern.rs @@ -16,7 +16,7 @@ enum t { foo(int, uint), bar(int, Option), } fn nested(o: t) { match o { - bar(_i, Some::(_)) => { println!("wrong pattern matched"); fail!(); } + bar(_i, Some::(_)) => { println!("wrong pattern matched"); panic!(); } _ => { println!("succeeded"); } } } diff --git a/src/test/run-pass/no-landing-pads.rs b/src/test/run-pass/no-landing-pads.rs index bc7987f4a27e2..eda36fad215fe 100644 --- a/src/test/run-pass/no-landing-pads.rs +++ b/src/test/run-pass/no-landing-pads.rs @@ -25,7 +25,7 @@ impl Drop for A { fn main() { task::try::<()>(proc() { let _a = A; - fail!(); + panic!(); }); assert!(unsafe { !HIT }); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 9d7130ecb8c55..450034e12403b 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -30,7 +30,7 @@ impl E { } fn get_ref(&self) -> (int, &T) { match *self { - Nothing(..) => fail!("E::get_ref(Nothing::<{}>)", stringify!(T)), + Nothing(..) => panic!("E::get_ref(Nothing::<{}>)", stringify!(T)), Thing(x, ref y) => (x, y) } } @@ -59,7 +59,7 @@ macro_rules! check_fancy { let t_ = Thing::<$T>(23, e); match t_.get_ref() { (23, $v) => { $chk } - _ => fail!("Thing::<{}>(23, {}).get_ref() != (23, _)", + _ => panic!("Thing::<{}>(23, {}).get_ref() != (23, _)", stringify!($T), stringify!($e)) } }} diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index 8bdae89e523fd..71323016e835e 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -26,7 +26,7 @@ impl<'a> Drop for dtor<'a> { fn unwrap(o: Option) -> T { match o { Some(v) => v, - None => fail!() + None => panic!() } } diff --git a/src/test/run-pass/overload-index-operator.rs b/src/test/run-pass/overload-index-operator.rs index d047f02fe2f65..7c6ad45a9efe1 100644 --- a/src/test/run-pass/overload-index-operator.rs +++ b/src/test/run-pass/overload-index-operator.rs @@ -35,7 +35,7 @@ impl Index for AssociationList return &pair.value } } - fail!("No value found for key: {}", index); + panic!("No value found for key: {}", index); } } diff --git a/src/test/run-pass/overloaded-autoderef.rs b/src/test/run-pass/overloaded-autoderef.rs index a0686e7f17f8b..2975b209d0690 100644 --- a/src/test/run-pass/overloaded-autoderef.rs +++ b/src/test/run-pass/overloaded-autoderef.rs @@ -36,7 +36,7 @@ pub fn main() { let mut_s = Rc::new(RefCell::new(String::from_str("foo"))); mut_s.borrow_mut().push_str("bar"); - // HACK assert_eq! would fail here because it stores the LHS and RHS in two locals. + // HACK assert_eq! would panic here because it stores the LHS and RHS in two locals. assert!(mut_s.borrow().as_slice() == "foobar"); assert!(mut_s.borrow_mut().as_slice() == "foobar"); diff --git a/src/test/run-pass/overloaded-deref.rs b/src/test/run-pass/overloaded-deref.rs index cdd56f64d273d..b63db29cf916e 100644 --- a/src/test/run-pass/overloaded-deref.rs +++ b/src/test/run-pass/overloaded-deref.rs @@ -34,7 +34,7 @@ pub fn main() { let mut_s = Rc::new(RefCell::new(String::from_str("foo"))); (*(*mut_s).borrow_mut()).push_str("bar"); - // assert_eq! would fail here because it stores the LHS and RHS in two locals. + // assert_eq! would panic here because it stores the LHS and RHS in two locals. assert!((*(*mut_s).borrow()).as_slice() == "foobar"); assert!((*(*mut_s).borrow_mut()).as_slice() == "foobar"); diff --git a/src/test/run-pass/parse-fail.rs b/src/test/run-pass/parse-fail.rs index 34c5bf0234f18..0dbba3654b689 100644 --- a/src/test/run-pass/parse-fail.rs +++ b/src/test/run-pass/parse-fail.rs @@ -10,6 +10,6 @@ #![allow(unreachable_code)] -fn dont_call_me() { fail!(); println!("{}", 1i); } +fn dont_call_me() { panic!(); println!("{}", 1i); } pub fn main() { } diff --git a/src/test/run-pass/process-detach.rs b/src/test/run-pass/process-detach.rs index 569d4acb4c610..4c078a66f0882 100644 --- a/src/test/run-pass/process-detach.rs +++ b/src/test/run-pass/process-detach.rs @@ -44,6 +44,6 @@ fn main() { drop(p.stdin.take()); match p.wait().unwrap() { process::ExitStatus(..) => {} - process::ExitSignal(..) => fail!() + process::ExitSignal(..) => panic!() } } diff --git a/src/test/run-pass/regions-bot.rs b/src/test/run-pass/regions-bot.rs index dbc5bf6626af1..75c52f63041a5 100644 --- a/src/test/run-pass/regions-bot.rs +++ b/src/test/run-pass/regions-bot.rs @@ -10,7 +10,7 @@ // A very limited test of the "bottom" region -fn produce_static() -> &'static T { fail!(); } +fn produce_static() -> &'static T { panic!(); } fn foo(_x: &T) -> &uint { produce_static() } diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs index 68a451b62acc4..f074ca9a88921 100644 --- a/src/test/run-pass/regions-dependent-addr-of.rs +++ b/src/test/run-pass/regions-dependent-addr-of.rs @@ -58,21 +58,21 @@ fn get_v5(a: &A, _i: uint) -> &int { fn get_v6_a(a: &A, _i: uint) -> &int { match a.value.v6 { Some(ref v) => &v.f, - None => fail!() + None => panic!() } } fn get_v6_b(a: &A, _i: uint) -> &int { match *a { A { value: B { v6: Some(ref v), .. } } => &v.f, - _ => fail!() + _ => panic!() } } fn get_v6_c(a: &A, _i: uint) -> &int { match a { &A { value: B { v6: Some(ref v), .. } } => &v.f, - _ => fail!() + _ => panic!() } } diff --git a/src/test/run-pass/regions-early-bound-trait-param.rs b/src/test/run-pass/regions-early-bound-trait-param.rs index c732d20a15605..5de5e39a4545b 100644 --- a/src/test/run-pass/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions-early-bound-trait-param.rs @@ -91,13 +91,13 @@ impl<'l> List<'l> { fn car<'m>(&'m self) -> int { match self { &Cons(car, _) => car, - &Null => fail!(), + &Null => panic!(), } } fn cdr<'n>(&'n self) -> &'l List<'l> { match self { &Cons(_, cdr) => cdr, - &Null => fail!(), + &Null => panic!(), } } } diff --git a/src/test/run-pass/regions-return-interior-of-option.rs b/src/test/run-pass/regions-return-interior-of-option.rs index f6971a8b4ad30..54458f0d0df03 100644 --- a/src/test/run-pass/regions-return-interior-of-option.rs +++ b/src/test/run-pass/regions-return-interior-of-option.rs @@ -11,7 +11,7 @@ fn get(opt: &Option) -> &T { match *opt { Some(ref v) => v, - None => fail!("none") + None => panic!("none") } } diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index 42e5c8731e269..ff4932e8453e4 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -11,7 +11,7 @@ -fn my_err(s: String) -> ! { println!("{}", s); fail!(); } +fn my_err(s: String) -> ! { println!("{}", s); panic!(); } fn okay(i: uint) -> int { if i == 3u { diff --git a/src/test/run-pass/return-from-closure.rs b/src/test/run-pass/return-from-closure.rs index 1756d74a81e17..2709904fb4cac 100644 --- a/src/test/run-pass/return-from-closure.rs +++ b/src/test/run-pass/return-from-closure.rs @@ -17,7 +17,7 @@ fn surrounding() { unsafe { calls += 1 } if n >= 0 { return; } - fail!() + panic!() }; return_works(10); @@ -28,7 +28,7 @@ fn surrounding() { unsafe { calls += 1 } if n >= 0 { return; } - fail!() + panic!() }; return_works_proc(10); diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index d0762d1f3d8f2..942542a6bcdbd 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -25,12 +25,12 @@ fn start(argc: int, argv: *const *const u8) -> int { 1 => {} 2 => println!("foo"), 3 => assert!(try(|| {}).is_ok()), - 4 => assert!(try(|| fail!()).is_err()), + 4 => assert!(try(|| panic!()).is_err()), 5 => assert!(try(|| spawn(proc() {})).is_err()), 6 => assert!(Command::new("test").spawn().is_err()), 7 => assert!(foo.get().is_none()), 8 => assert!(try(|| { foo.replace(Some(3)); }).is_err()), - _ => fail!() + _ => panic!() } } return 0 diff --git a/src/test/run-pass/sepcomp-unwind.rs b/src/test/run-pass/sepcomp-unwind.rs index 5d154e02af670..c2c7a48815cc0 100644 --- a/src/test/run-pass/sepcomp-unwind.rs +++ b/src/test/run-pass/sepcomp-unwind.rs @@ -23,7 +23,7 @@ fn pad() -> uint { 0 } mod a { pub fn f() { - fail!(); + panic!(); } } diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index 52fa8e1132e2f..dc72b6b05390b 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -25,7 +25,7 @@ pub fn main() { match status { ExitSignal(_) if cfg!(unix) => {}, ExitStatus(0xC0000028) if cfg!(windows) => {}, - _ => fail!("invalid termination (was not signalled): {}", status) + _ => panic!("invalid termination (was not signalled): {}", status) } } } diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index 65928fd7bf332..afb6c21d3f41a 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -15,7 +15,7 @@ fn uhoh(v: Vec> ) { a::(ref _t, ref u) => { println!("incorrect"); println!("{}", u); - fail!(); + panic!(); } b:: => { println!("correct"); } } diff --git a/src/test/run-pass/slice-fail-2.rs b/src/test/run-pass/slice-fail-2.rs index a2aecc1d5cd56..0ac7a2001fc67 100644 --- a/src/test/run-pass/slice-fail-2.rs +++ b/src/test/run-pass/slice-fail-2.rs @@ -23,7 +23,7 @@ impl Drop for Foo { } fn bar() -> uint { - fail!(); + panic!(); } fn foo() { diff --git a/src/test/run-pass/syntax-extension-cfg.rs b/src/test/run-pass/syntax-extension-cfg.rs index 8f67532d89d6b..8c888ff03624f 100644 --- a/src/test/run-pass/syntax-extension-cfg.rs +++ b/src/test/run-pass/syntax-extension-cfg.rs @@ -12,21 +12,21 @@ pub fn main() { // check - if ! cfg!(foo) { fail!() } - if cfg!(not(foo)) { fail!() } + if ! cfg!(foo) { panic!() } + if cfg!(not(foo)) { panic!() } - if ! cfg!(qux="foo") { fail!() } - if cfg!(not(qux="foo")) { fail!() } + if ! cfg!(qux="foo") { panic!() } + if cfg!(not(qux="foo")) { panic!() } - if ! cfg!(all(foo, qux="foo")) { fail!() } - if cfg!(not(all(foo, qux="foo"))) { fail!() } - if cfg!(all(not(all(foo, qux="foo")))) { fail!() } + if ! cfg!(all(foo, qux="foo")) { panic!() } + if cfg!(not(all(foo, qux="foo"))) { panic!() } + if cfg!(all(not(all(foo, qux="foo")))) { panic!() } - if cfg!(not_a_cfg) { fail!() } - if cfg!(all(not_a_cfg, foo, qux="foo")) { fail!() } - if cfg!(all(not_a_cfg, foo, qux="foo")) { fail!() } - if ! cfg!(any(not_a_cfg, foo)) { fail!() } + if cfg!(not_a_cfg) { panic!() } + if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } + if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } + if ! cfg!(any(not_a_cfg, foo)) { panic!() } - if ! cfg!(not(not_a_cfg)) { fail!() } - if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { fail!() } + if ! cfg!(not(not_a_cfg)) { panic!() } + if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { panic!() } } diff --git a/src/test/run-pass/task-stderr.rs b/src/test/run-pass/task-stderr.rs index ceffd1e363667..0dbe74d722bca 100644 --- a/src/test/run-pass/task-stderr.rs +++ b/src/test/run-pass/task-stderr.rs @@ -17,7 +17,7 @@ fn main() { let stderr = ChanWriter::new(tx); let res = TaskBuilder::new().stderr(box stderr as Box).try(proc() -> () { - fail!("Hello, world!") + panic!("Hello, world!") }); assert!(res.is_err()); diff --git a/src/test/run-pass/tcp-accept-stress.rs b/src/test/run-pass/tcp-accept-stress.rs index fe882937ca018..bf6fe5a9d26d9 100644 --- a/src/test/run-pass/tcp-accept-stress.rs +++ b/src/test/run-pass/tcp-accept-stress.rs @@ -45,7 +45,7 @@ fn test() { } } Err(ref e) if e.kind == EndOfFile => break, - Err(e) => fail!("{}", e), + Err(e) => panic!("{}", e), } } srv_tx.send(()); @@ -67,7 +67,7 @@ fn test() { // wait for senders if cli_rx.iter().take(N).count() != N { a.close_accept().unwrap(); - fail!("clients failed"); + panic!("clients panicked"); } // wait for one acceptor to die diff --git a/src/test/run-pass/tcp-connect-timeouts.rs b/src/test/run-pass/tcp-connect-timeouts.rs index e186f63e0a45e..07fc1212d7899 100644 --- a/src/test/run-pass/tcp-connect-timeouts.rs +++ b/src/test/run-pass/tcp-connect-timeouts.rs @@ -48,10 +48,10 @@ fn eventual_timeout() { match TcpStream::connect_timeout(addr, Duration::milliseconds(100)) { Ok(e) => v.push(e), Err(ref e) if e.kind == io::TimedOut => return, - Err(e) => fail!("other error: {}", e), + Err(e) => panic!("other error: {}", e), } } - fail!("never timed out!"); + panic!("never timed out!"); } fn timeout_success() { diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 91c07c259a2d8..8d2a8a6ccfe20 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -40,7 +40,7 @@ fn main() { let mut stream = match acceptor.accept() { Ok(stream) => stream, Err(error) => { - debug!("accept failed: {}", error); + debug!("accept panicked: {}", error); continue; } }; diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index eceafa40265f9..476278405ca8a 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -39,7 +39,7 @@ fn test_rm_tempdir() { let f: proc():Send = proc() { let tmp = TempDir::new("test_rm_tempdir").unwrap(); tx.send(tmp.path().clone()); - fail!("fail to unwind past `tmp`"); + panic!("panic to unwind past `tmp`"); }; task::try(f); let path = rx.recv(); @@ -49,7 +49,7 @@ fn test_rm_tempdir() { let path = tmp.path().clone(); let f: proc():Send = proc() { let _tmp = tmp; - fail!("fail to unwind past `tmp`"); + panic!("panic to unwind past `tmp`"); }; task::try(f); assert!(!path.exists()); @@ -81,7 +81,7 @@ fn test_rm_tempdir_close() { let tmp = TempDir::new("test_rm_tempdir").unwrap(); tx.send(tmp.path().clone()); tmp.close(); - fail!("fail to unwind past `tmp`"); + panic!("panic when unwinding past `tmp`"); }; task::try(f); let path = rx.recv(); @@ -92,7 +92,7 @@ fn test_rm_tempdir_close() { let f: proc():Send = proc() { let tmp = tmp; tmp.close(); - fail!("fail to unwind past `tmp`"); + panic!("panic when unwinding past `tmp`"); }; task::try(f); assert!(!path.exists()); @@ -175,15 +175,15 @@ pub fn test_rmdir_recursive_ok() { assert!(!root.join("bar").join("blat").exists()); } -pub fn dont_double_fail() { +pub fn dont_double_panic() { let r: Result<(), _> = task::try(proc() { let tmpdir = TempDir::new("test").unwrap(); // Remove the temporary directory so that TempDir sees // an error on drop fs::rmdir(tmpdir.path()); - // Trigger failure. If TempDir fails *again* due to the rmdir + // Panic. If TempDir panics *again* due to the rmdir // error then the process will abort. - fail!(); + panic!(); }); assert!(r.is_err()); } @@ -203,5 +203,5 @@ pub fn main() { in_tmpdir(recursive_mkdir_dot); in_tmpdir(recursive_mkdir_rel_2); in_tmpdir(test_rmdir_recursive_ok); - in_tmpdir(dont_double_fail); + in_tmpdir(dont_double_panic); } diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index 41a9e6e53f251..2a71148216d64 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -20,13 +20,13 @@ fn test_cont() { let mut i = 0i; while i < 1 { i += 1; let _x: Box = contin fn test_ret() { let _x: Box = return; } -fn test_fail() { - fn f() { let _x: Box = fail!(); } +fn test_panic() { + fn f() { let _x: Box = panic!(); } task::try(proc() f() ); } -fn test_fail_indirect() { - fn f() -> ! { fail!(); } +fn test_panic_indirect() { + fn f() -> ! { panic!(); } fn g() { let _x: Box = f(); } task::try(proc() g() ); } @@ -35,6 +35,6 @@ pub fn main() { test_break(); test_cont(); test_ret(); - test_fail(); - test_fail_indirect(); + test_panic(); + test_panic_indirect(); } diff --git a/src/test/run-pass/test-runner-hides-main.rs b/src/test/run-pass/test-runner-hides-main.rs index 9b658ee1dae53..839e91f3793d4 100644 --- a/src/test/run-pass/test-runner-hides-main.rs +++ b/src/test/run-pass/test-runner-hides-main.rs @@ -13,4 +13,4 @@ // Building as a test runner means that a synthetic main will be run, // not ours -pub fn main() { fail!(); } +pub fn main() { panic!(); } diff --git a/src/test/run-pass/trans-tag-static-padding.rs b/src/test/run-pass/trans-tag-static-padding.rs index ed4712ff3be9c..93aa367feee82 100644 --- a/src/test/run-pass/trans-tag-static-padding.rs +++ b/src/test/run-pass/trans-tag-static-padding.rs @@ -57,10 +57,10 @@ fn non_default_instance() -> &'static Request { pub fn main() { match default_instance() { &Request { foo: TestNone, bar: 17 } => {}, - _ => fail!(), + _ => panic!(), }; match non_default_instance() { &Request { foo: TestSome(0x1020304050607080), bar: 19 } => {}, - _ => fail!(), + _ => panic!(), }; } diff --git a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs index 6be79cb62dd7f..48d073e28aa75 100644 --- a/src/test/run-pass/typeck-macro-interaction-issue-8852.rs +++ b/src/test/run-pass/typeck-macro-interaction-issue-8852.rs @@ -26,7 +26,7 @@ macro_rules! test( match (a, b) { (A($id1), A($id2)) => A($e), (B($id1), B($id2)) => B($e), - _ => fail!() + _ => panic!() } } ) diff --git a/src/test/run-pass/unique-containing-tag.rs b/src/test/run-pass/unique-containing-tag.rs index 762a74b24551c..3c67eaee0a6a2 100644 --- a/src/test/run-pass/unique-containing-tag.rs +++ b/src/test/run-pass/unique-containing-tag.rs @@ -17,13 +17,13 @@ pub fn main() { t1(a) { assert_eq!(a, 10); } - _ { fail!(); } + _ { panic!(); } }*/ /*alt x { box t1(a) { assert_eq!(a, 10); } - _ { fail!(); } + _ { panic!(); } }*/ } diff --git a/src/test/run-pass/unique-decl.rs b/src/test/run-pass/unique-decl.rs index 7f894a8c324b5..a902fef288f00 100644 --- a/src/test/run-pass/unique-decl.rs +++ b/src/test/run-pass/unique-decl.rs @@ -14,5 +14,5 @@ pub fn main() { } fn f(_i: Box) -> Box { - fail!(); + panic!(); } diff --git a/src/test/run-pass/unique-pat.rs b/src/test/run-pass/unique-pat.rs index 297ded0222d1f..a0eee7e3cb6ee 100644 --- a/src/test/run-pass/unique-pat.rs +++ b/src/test/run-pass/unique-pat.rs @@ -11,7 +11,7 @@ fn simple() { match box true { box true => { } - _ => { fail!(); } + _ => { panic!(); } } } diff --git a/src/test/run-pass/unit-like-struct-drop-run.rs b/src/test/run-pass/unit-like-struct-drop-run.rs index 3a1cc0331a3e6..c12303b009f46 100644 --- a/src/test/run-pass/unit-like-struct-drop-run.rs +++ b/src/test/run-pass/unit-like-struct-drop-run.rs @@ -17,7 +17,7 @@ struct Foo; impl Drop for Foo { fn drop(&mut self) { - fail!("This failure should happen."); + panic!("This panic should happen."); } } @@ -27,5 +27,5 @@ pub fn main() { }); let s = x.unwrap_err().downcast::<&'static str>().unwrap(); - assert_eq!(s.as_slice(), "This failure should happen."); + assert_eq!(s.as_slice(), "This panic should happen."); } diff --git a/src/test/run-pass/unix-process-spawn-errno.rs b/src/test/run-pass/unix-process-spawn-errno.rs index 42b78e4ec6616..b2ef1a044db80 100644 --- a/src/test/run-pass/unix-process-spawn-errno.rs +++ b/src/test/run-pass/unix-process-spawn-errno.rs @@ -87,7 +87,7 @@ fn main() { }; match process::Process::spawn(cfg) { - Ok(_) => { fail!("spawn() should have failled"); } + Ok(_) => { panic!("spawn() should have panicked"); } Err(rtio::IoError { code: err, ..}) => { assert_eq!(err as c_int, EXPECTED_ERRNO); } diff --git a/src/test/run-pass/unreachable-code-1.rs b/src/test/run-pass/unreachable-code-1.rs index fa24cc44f9007..d8a8913e58ad9 100644 --- a/src/test/run-pass/unreachable-code-1.rs +++ b/src/test/run-pass/unreachable-code-1.rs @@ -14,7 +14,7 @@ fn id(x: bool) -> bool { x } fn call_id() { - let c = fail!(); + let c = panic!(); id(c); //~ WARNING unreachable statement } diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs index 496be7e0e6abb..a9ac78c5d76fd 100644 --- a/src/test/run-pass/unreachable-code.rs +++ b/src/test/run-pass/unreachable-code.rs @@ -15,7 +15,7 @@ fn id(x: bool) -> bool { x } fn call_id() { - let c = fail!(); + let c = panic!(); id(c); } diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index 13370ea340f65..60f07663bef0e 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -32,7 +32,7 @@ fn complainer(tx: Sender) -> complainer { fn f(tx: Sender) { let _tx = complainer(tx); - fail!(); + panic!(); } pub fn main() { diff --git a/src/test/run-pass/unwind-unique.rs b/src/test/run-pass/unwind-unique.rs index e5497427755fd..2f31ee25b5daa 100644 --- a/src/test/run-pass/unwind-unique.rs +++ b/src/test/run-pass/unwind-unique.rs @@ -12,7 +12,7 @@ use std::task; fn f() { let _a = box 0i; - fail!(); + panic!(); } pub fn main() { diff --git a/src/test/run-pass/use-uninit-match2.rs b/src/test/run-pass/use-uninit-match2.rs index b5d2b9ef84c57..9337d064d2397 100644 --- a/src/test/run-pass/use-uninit-match2.rs +++ b/src/test/run-pass/use-uninit-match2.rs @@ -13,7 +13,7 @@ fn foo(o: myoption) -> int { let mut x: int; match o { - none:: => { fail!(); } + none:: => { panic!(); } some::(_t) => { x = 5; } } return x; diff --git a/src/test/run-pass/vec-matching-autoslice.rs b/src/test/run-pass/vec-matching-autoslice.rs index 9992c059ac4e6..6476f734ae650 100644 --- a/src/test/run-pass/vec-matching-autoslice.rs +++ b/src/test/run-pass/vec-matching-autoslice.rs @@ -11,11 +11,11 @@ pub fn main() { let x = [1i, 2, 3]; match x { - [2, _, _] => fail!(), + [2, _, _] => panic!(), [1, a, b] => { assert!([a, b] == [2, 3]); } - [_, _, _] => fail!(), + [_, _, _] => panic!(), } let y = ([(1i, true), (2i, false)], 0.5f64); @@ -24,7 +24,7 @@ pub fn main() { assert_eq!(a, true); assert_eq!(b, 2); } - ([_, _], 0.5) => fail!(), - ([_, _], _) => fail!(), + ([_, _], 0.5) => panic!(), + ([_, _], _) => panic!(), } } diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs index 187d97f483dda..77226df7fa202 100644 --- a/src/test/run-pass/vec-matching.rs +++ b/src/test/run-pass/vec-matching.rs @@ -57,7 +57,7 @@ fn b() { fn c() { let x = [1i]; match x { - [2, ..] => fail!(), + [2, ..] => panic!(), [..] => () } } diff --git a/src/test/run-pass/vector-sort-failure-safe.rs b/src/test/run-pass/vector-sort-failure-safe.rs index 10c37651a8635..ce9cc68bd3654 100644 --- a/src/test/run-pass/vector-sort-failure-safe.rs +++ b/src/test/run-pass/vector-sort-failure-safe.rs @@ -68,8 +68,8 @@ pub fn main() { let mut count = 0; main.clone().as_mut_slice().sort_by(|a, b| { count += 1; a.cmp(b) }); - // ... and then fail on each and every single one. - for fail_countdown in range(0i, count) { + // ... and then panic on each and every single one. + for panic_countdown in range(0i, count) { // refresh the counters. for c in drop_counts.iter() { c.store(0, Relaxed); @@ -79,12 +79,12 @@ pub fn main() { let _ = task::try(proc() { let mut v = v; - let mut fail_countdown = fail_countdown; + let mut panic_countdown = panic_countdown; v.as_mut_slice().sort_by(|a, b| { - if fail_countdown == 0 { - fail!() + if panic_countdown == 0 { + panic!() } - fail_countdown -= 1; + panic_countdown -= 1; a.cmp(b) }) }); diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 72204c28f82ad..f73800b89db64 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -71,7 +71,7 @@ fn canttouchthis() -> uint { fn angrydome() { loop { if break { } } let mut i = 0i; - loop { i += 1; if i == 1 { match (continue) { 1i => { }, _ => fail!("wat") } } + loop { i += 1; if i == 1 { match (continue) { 1i => { }, _ => panic!("wat") } } break; } } diff --git a/src/test/run-pass/while-label.rs b/src/test/run-pass/while-label.rs index dd53ac889f505..41712f7c64d29 100644 --- a/src/test/run-pass/while-label.rs +++ b/src/test/run-pass/while-label.rs @@ -15,7 +15,7 @@ pub fn main() { i -= 1; if i == 95 { break 'w; - fail!("Should have broken out of loop"); + panic!("Should have broken out of loop"); } } assert_eq!(i, 95); diff --git a/src/test/run-pass/writealias.rs b/src/test/run-pass/writealias.rs index 6d57bff1bd673..ae49c07093b11 100644 --- a/src/test/run-pass/writealias.rs +++ b/src/test/run-pass/writealias.rs @@ -20,7 +20,7 @@ pub fn main() { Some(ref z) if *z.lock() => { assert!(*z.lock()); }, - _ => fail!() + _ => panic!() } } } From 6ac7fc73f5acfe30c698ea4f8bfc37b30473977e Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 28 Oct 2014 14:07:33 -0400 Subject: [PATCH 2/2] Update infrastructure for fail -> panic This includes updating the language items and marking what needs to change after a snapshot. If you do not use the standard library, the language items you need to implement have changed. For example: ```rust #[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } ``` is now ```rust #[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } ``` Related, lesser-implemented language items `fail` and `fail_bounds_check` have become `panic` and `panic_bounds_check`, as well. These are implemented by `libcore`, so it is unlikely (though possible!) that these two renamings will affect you. [breaking-change] Fix test suite --- src/doc/guide-unsafe.md | 18 +++---- src/libcore/panicking.rs | 47 +++++++++++++++++++ src/librustc/middle/trans/controlflow.rs | 6 +-- src/librustrt/unwind.rs | 8 ++++ src/test/auxiliary/lang-item-public.rs | 4 +- src/test/compile-fail/binop-fail-3.rs | 2 +- src/test/compile-fail/issue-5500.rs | 2 +- src/test/compile-fail/weak-lang-item.rs | 2 +- src/test/run-fail/assert-macro-explicit.rs | 2 +- src/test/run-fail/assert-macro-fmt.rs | 2 +- src/test/run-fail/assert-macro-owned.rs | 2 +- src/test/run-fail/assert-macro-static.rs | 2 +- .../run-fail/by-value-self-objects-fail.rs | 2 +- src/test/run-fail/expr-fn-fail.rs | 4 +- src/test/run-fail/expr-if-fail-fn.rs | 4 +- src/test/run-fail/expr-if-fail.rs | 4 +- src/test/run-fail/expr-match-fail-fn.rs | 4 +- src/test/run-fail/expr-match-fail.rs | 4 +- src/test/run-fail/fail-macro-any-wrapped.rs | 2 +- src/test/run-fail/fail-macro-any.rs | 3 +- src/test/run-fail/fail-macro-explicit.rs | 2 +- src/test/run-fail/fail-macro-fmt.rs | 2 +- src/test/run-fail/fail-macro-owned.rs | 2 +- src/test/run-fail/fail-macro-static.rs | 2 +- src/test/run-fail/fail-non-utf8.rs | 2 +- src/test/run-fail/fail-task-name-none.rs | 2 +- src/test/run-fail/fail-task-name-owned.rs | 2 +- src/test/run-fail/fail-task-name-send-str.rs | 2 +- src/test/run-fail/fail-task-name-static.rs | 2 +- src/test/run-fail/glob-use-std.rs | 2 +- src/test/run-fail/issue-12920.rs | 2 +- src/test/run-fail/issue-2444.rs | 2 +- src/test/run-fail/main-fail.rs | 2 +- src/test/run-fail/match-bot-fail.rs | 2 +- src/test/run-fail/native-failure.rs | 2 +- src/test/run-fail/test-fail.rs | 2 +- src/test/run-fail/unique-fail.rs | 2 +- src/test/run-make/no-duplicate-libs/bar.rs | 2 +- src/test/run-make/no-duplicate-libs/foo.rs | 2 +- src/test/run-pass/smallest-hello-world.rs | 2 +- 40 files changed, 104 insertions(+), 60 deletions(-) diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index cade043a7931f..4d6dde7f57fb9 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -462,7 +462,7 @@ fn start(_argc: int, _argv: *const *const u8) -> int { // provided by libstd. #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } +#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } # // fn main() {} tricked you, rustdoc! ``` @@ -485,7 +485,7 @@ pub extern fn main(argc: int, argv: *const *const u8) -> int { #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } +#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } # // fn main() {} tricked you, rustdoc! ``` @@ -505,7 +505,7 @@ failure mechanisms of the compiler. This is often mapped to GCC's personality function (see the [libstd implementation](std/rt/unwind/index.html) for more information), but crates which do not trigger a panic can be assured -that this function is never called. The final function, `fail_fmt`, is +that this function is never called. The final function, `panic_fmt`, is also used by the failure mechanisms of the compiler. ## Using libcore @@ -565,8 +565,8 @@ pub extern fn dot_product(a: *const u32, a_len: u32, return ret; } -#[lang = "fail_fmt"] -extern fn fail_fmt(args: &core::fmt::Arguments, +#[lang = "panic_fmt"] +extern fn panic_fmt(args: &core::fmt::Arguments, file: &str, line: uint) -> ! { loop {} @@ -579,9 +579,9 @@ extern fn fail_fmt(args: &core::fmt::Arguments, ``` Note that there is one extra lang item here which differs from the examples -above, `fail_fmt`. This must be defined by consumers of libcore because the -core library declares failure, but it does not define it. The `fail_fmt` -lang item is this crate's definition of failure, and it must be guaranteed to +above, `panic_fmt`. This must be defined by consumers of libcore because the +core library declares panics, but it does not define it. The `panic_fmt` +lang item is this crate's definition of panic, and it must be guaranteed to never return. As can be seen in this example, the core library is intended to provide the @@ -686,7 +686,7 @@ fn main(argc: int, argv: *const *const u8) -> int { #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } +#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } ``` Note the use of `abort`: the `exchange_malloc` lang item is assumed to diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index cda21b6ecfa7d..62c9d907cb227 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -33,6 +33,49 @@ use fmt; use intrinsics; +// NOTE(stage0): remove after a snapshot +#[cfg(stage0)] +#[cold] #[inline(never)] // this is the slow path, always +#[lang="fail"] +pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { + let (expr, file, line) = *expr_file_line; + let ref file_line = (file, line); + format_args!(|args| -> () { + panic_fmt(args, file_line); + }, "{}", expr); + + unsafe { intrinsics::abort() } +} + +// NOTE(stage0): remove after a snapshot +#[cfg(stage0)] +#[cold] #[inline(never)] +#[lang="fail_bounds_check"] +fn panic_bounds_check(file_line: &(&'static str, uint), + index: uint, len: uint) -> ! { + format_args!(|args| -> () { + panic_fmt(args, file_line); + }, "index out of bounds: the len is {} but the index is {}", len, index); + unsafe { intrinsics::abort() } +} + +// NOTE(stage0): remove after a snapshot +#[cfg(stage0)] +#[cold] #[inline(never)] +pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { + #[allow(ctypes)] + extern { + #[lang = "fail_fmt"] + fn panic_impl(fmt: &fmt::Arguments, file: &'static str, + line: uint) -> !; + + } + let (file, line) = *file_line; + unsafe { panic_impl(fmt, file, line) } +} + +// NOTE(stage0): remove cfg after a snapshot +#[cfg(not(stage0))] #[cold] #[inline(never)] // this is the slow path, always #[lang="panic"] pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { @@ -45,6 +88,8 @@ pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! { unsafe { intrinsics::abort() } } +// NOTE(stage0): remove cfg after a snapshot +#[cfg(not(stage0))] #[cold] #[inline(never)] #[lang="panic_bounds_check"] fn panic_bounds_check(file_line: &(&'static str, uint), @@ -55,6 +100,8 @@ fn panic_bounds_check(file_line: &(&'static str, uint), unsafe { intrinsics::abort() } } +// NOTE(stage0): remove cfg after a snapshot +#[cfg(not(stage0))] #[cold] #[inline(never)] pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! { #[allow(ctypes)] diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index f7210bb4e08bb..911ae42e142d8 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -11,7 +11,7 @@ use llvm::*; use driver::config::FullDebugInfo; use middle::def; -use middle::lang_items::{FailFnLangItem, FailBoundsCheckFnLangItem}; +use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; use middle::trans::_match; use middle::trans::adt; use middle::trans::base::*; @@ -498,7 +498,7 @@ pub fn trans_fail<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let expr_file_line_const = C_struct(ccx, &[v_str, filename, line], false); let expr_file_line = consts::const_addr_of(ccx, expr_file_line_const, ast::MutImmutable); let args = vec!(expr_file_line); - let did = langcall(bcx, Some(sp), "", FailFnLangItem); + let did = langcall(bcx, Some(sp), "", PanicFnLangItem); let bcx = callee::trans_lang_call(bcx, did, args.as_slice(), @@ -525,7 +525,7 @@ pub fn trans_fail_bounds_check<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let file_line_const = C_struct(ccx, &[filename, line], false); let file_line = consts::const_addr_of(ccx, file_line_const, ast::MutImmutable); let args = vec!(file_line, index, len); - let did = langcall(bcx, Some(sp), "", FailBoundsCheckFnLangItem); + let did = langcall(bcx, Some(sp), "", PanicBoundsCheckFnLangItem); let bcx = callee::trans_lang_call(bcx, did, args.as_slice(), diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs index 96a584492aeda..8279b7d9654e4 100644 --- a/src/librustrt/unwind.rs +++ b/src/librustrt/unwind.rs @@ -497,6 +497,14 @@ pub extern fn rust_begin_unwind(msg: &fmt::Arguments, begin_unwind_fmt(msg, &(file, line)) } +// NOTE(stage0): remove after a snapshot +#[cfg(not(test))] +#[lang = "fail_fmt"] +pub extern fn rust_fail_begin_unwind(msg: &fmt::Arguments, + file: &'static str, line: uint) -> ! { + rust_begin_unwind(msg, file, line) +} + /// The entry point for unwinding with a formatted message. /// /// This is designed to reduce the amount of code required at the call diff --git a/src/test/auxiliary/lang-item-public.rs b/src/test/auxiliary/lang-item-public.rs index 967f49924d405..ea2461ccfa8ef 100644 --- a/src/test/auxiliary/lang-item-public.rs +++ b/src/test/auxiliary/lang-item-public.rs @@ -14,8 +14,8 @@ #[lang="sized"] pub trait Sized for Sized? {} -#[lang="fail"] -fn fail(_: &(&'static str, &'static str, uint)) -> ! { loop {} } +#[lang="panic"] +fn panic(_: &(&'static str, &'static str, uint)) -> ! { loop {} } #[lang = "stack_exhausted"] extern fn stack_exhausted() {} diff --git a/src/test/compile-fail/binop-fail-3.rs b/src/test/compile-fail/binop-fail-3.rs index 2d6f8ccbfa25f..097a52b894179 100644 --- a/src/test/compile-fail/binop-fail-3.rs +++ b/src/test/compile-fail/binop-fail-3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo() -> ! { fail!("quux"); } +fn foo() -> ! { panic!("quux"); } fn main() { foo() //~ ERROR the type of this value must be known in this context == diff --git a/src/test/compile-fail/issue-5500.rs b/src/test/compile-fail/issue-5500.rs index e972379944acc..86ff29a52b034 100644 --- a/src/test/compile-fail/issue-5500.rs +++ b/src/test/compile-fail/issue-5500.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - &fail!() + &panic!() //~^ ERROR mismatched types: expected `()`, found `&` (expected (), found &-ptr) } diff --git a/src/test/compile-fail/weak-lang-item.rs b/src/test/compile-fail/weak-lang-item.rs index 74ec56f7bd90a..baac192cbf022 100644 --- a/src/test/compile-fail/weak-lang-item.rs +++ b/src/test/compile-fail/weak-lang-item.rs @@ -9,7 +9,7 @@ // except according to those terms. // aux-build:weak-lang-items.rs -// error-pattern: language item required, but not found: `fail_fmt` +// error-pattern: language item required, but not found: `panic_fmt` // error-pattern: language item required, but not found: `stack_exhausted` // error-pattern: language item required, but not found: `eh_personality` diff --git a/src/test/run-fail/assert-macro-explicit.rs b/src/test/run-fail/assert-macro-explicit.rs index 8e70c2c3561a2..197ed59c07f44 100644 --- a/src/test/run-fail/assert-macro-explicit.rs +++ b/src/test/run-fail/assert-macro-explicit.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'assertion failed: false' +// 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 index 72222ce43627e..223c60d6ae438 100644 --- a/src/test/run-fail/assert-macro-fmt.rs +++ b/src/test/run-fail/assert-macro-fmt.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'test-assert-fmt 42 rust' +// error-pattern:panicked at 'test-assert-fmt 42 rust' fn main() { assert!(false, "test-assert-fmt {} {}", 42i, "rust"); diff --git a/src/test/run-fail/assert-macro-owned.rs b/src/test/run-fail/assert-macro-owned.rs index a1a8eb6a092dc..e68aef10de891 100644 --- a/src/test/run-fail/assert-macro-owned.rs +++ b/src/test/run-fail/assert-macro-owned.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'test-assert-owned' +// 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 index a35258462deaa..59be468e0cb90 100644 --- a/src/test/run-fail/assert-macro-static.rs +++ b/src/test/run-fail/assert-macro-static.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'test-assert-static' +// error-pattern:panicked at 'test-assert-static' fn main() { assert!(false, "test-assert-static"); diff --git a/src/test/run-fail/by-value-self-objects-fail.rs b/src/test/run-fail/by-value-self-objects-fail.rs index 5747aa7a838e3..6b000866d3ab9 100644 --- a/src/test/run-fail/by-value-self-objects-fail.rs +++ b/src/test/run-fail/by-value-self-objects-fail.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:explicit failure +// error-pattern:explicit panic trait Foo { fn foo(self, x: int); diff --git a/src/test/run-fail/expr-fn-fail.rs b/src/test/run-fail/expr-fn-fail.rs index 179d52bda0318..8cf018fb7702d 100644 --- a/src/test/run-fail/expr-fn-fail.rs +++ b/src/test/run-fail/expr-fn-fail.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// error-pattern:explicit panic - - -// error-pattern:explicit failure fn f() -> ! { panic!() } fn main() { f(); } diff --git a/src/test/run-fail/expr-if-fail-fn.rs b/src/test/run-fail/expr-if-fail-fn.rs index ad2ff7a8c6bea..987bee55c606d 100644 --- a/src/test/run-fail/expr-if-fail-fn.rs +++ b/src/test/run-fail/expr-if-fail-fn.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// error-pattern:explicit panic - - -// error-pattern:explicit failure fn f() -> ! { panic!() } fn g() -> int { let x = if true { f() } else { 10 }; return x; } diff --git a/src/test/run-fail/expr-if-fail.rs b/src/test/run-fail/expr-if-fail.rs index d2214f8c39878..f04c94a3bf47f 100644 --- a/src/test/run-fail/expr-if-fail.rs +++ b/src/test/run-fail/expr-if-fail.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// error-pattern:explicit panic - - -// error-pattern:explicit failure fn main() { let _x = if false { 0i } else if true { panic!() } else { 10i }; } diff --git a/src/test/run-fail/expr-match-fail-fn.rs b/src/test/run-fail/expr-match-fail-fn.rs index 78f9ce8cc291d..069c1d5ed3557 100644 --- a/src/test/run-fail/expr-match-fail-fn.rs +++ b/src/test/run-fail/expr-match-fail-fn.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// error-pattern:explicit panic - - -// error-pattern:explicit failure fn f() -> ! { panic!() } fn g() -> int { let x = match true { true => { f() } false => { 10 } }; return x; } diff --git a/src/test/run-fail/expr-match-fail.rs b/src/test/run-fail/expr-match-fail.rs index 0354717291dd2..d5c005b7029a5 100644 --- a/src/test/run-fail/expr-match-fail.rs +++ b/src/test/run-fail/expr-match-fail.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// error-pattern:explicit panic - - -// error-pattern:explicit failure fn main() { let _x = match true { false => { 0i } true => { panic!() } }; } diff --git a/src/test/run-fail/fail-macro-any-wrapped.rs b/src/test/run-fail/fail-macro-any-wrapped.rs index 432647e0e2b2a..e25390a798628 100644 --- a/src/test/run-fail/fail-macro-any-wrapped.rs +++ b/src/test/run-fail/fail-macro-any-wrapped.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'Box' +// error-pattern:panicked at 'Box' fn main() { panic!(box 612_i64); diff --git a/src/test/run-fail/fail-macro-any.rs b/src/test/run-fail/fail-macro-any.rs index 54704c44c0116..b73c66c4f2165 100644 --- a/src/test/run-fail/fail-macro-any.rs +++ b/src/test/run-fail/fail-macro-any.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'Box' - +// error-pattern:panicked at 'Box' fn main() { panic!(box 413i as Box<::std::any::Any+Send>); diff --git a/src/test/run-fail/fail-macro-explicit.rs b/src/test/run-fail/fail-macro-explicit.rs index bc240181e4c41..a8565549a03ed 100644 --- a/src/test/run-fail/fail-macro-explicit.rs +++ b/src/test/run-fail/fail-macro-explicit.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'explicit failure' +// error-pattern:panicked at 'explicit panic' fn main() { panic!(); diff --git a/src/test/run-fail/fail-macro-fmt.rs b/src/test/run-fail/fail-macro-fmt.rs index 069ffc4434f3f..ac50f02cf33c3 100644 --- a/src/test/run-fail/fail-macro-fmt.rs +++ b/src/test/run-fail/fail-macro-fmt.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'test-fail-fmt 42 rust' +// error-pattern:panicked at 'test-fail-fmt 42 rust' fn main() { panic!("test-fail-fmt {} {}", 42i, "rust"); diff --git a/src/test/run-fail/fail-macro-owned.rs b/src/test/run-fail/fail-macro-owned.rs index 477f344280451..2f695c4e4b70c 100644 --- a/src/test/run-fail/fail-macro-owned.rs +++ b/src/test/run-fail/fail-macro-owned.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'test-fail-owned' +// error-pattern:panicked at 'test-fail-owned' fn main() { panic!("test-fail-owned"); diff --git a/src/test/run-fail/fail-macro-static.rs b/src/test/run-fail/fail-macro-static.rs index 51b70110da296..c62162da09b7c 100644 --- a/src/test/run-fail/fail-macro-static.rs +++ b/src/test/run-fail/fail-macro-static.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at 'test-fail-static' +// error-pattern:panicked at 'test-fail-static' fn main() { panic!("test-fail-static"); diff --git a/src/test/run-fail/fail-non-utf8.rs b/src/test/run-fail/fail-non-utf8.rs index ba4ff1da7e0b5..8b013199369a3 100644 --- a/src/test/run-fail/fail-non-utf8.rs +++ b/src/test/run-fail/fail-non-utf8.rs @@ -12,7 +12,7 @@ // Previously failed formating invalid utf8. // cc #16877 -// error-pattern:failed at 'hello�' +// error-pattern:panicked at 'hello�' struct Foo; impl std::fmt::Show for Foo { diff --git a/src/test/run-fail/fail-task-name-none.rs b/src/test/run-fail/fail-task-name-none.rs index a32b64f910518..3f8abc41ff74a 100644 --- a/src/test/run-fail/fail-task-name-none.rs +++ b/src/test/run-fail/fail-task-name-none.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:task '' failed at 'test' +// error-pattern:task '' panicked at 'test' use std::task; diff --git a/src/test/run-fail/fail-task-name-owned.rs b/src/test/run-fail/fail-task-name-owned.rs index 7553347e20b67..0a303475a29ff 100644 --- a/src/test/run-fail/fail-task-name-owned.rs +++ b/src/test/run-fail/fail-task-name-owned.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:task 'owned name' failed at 'test' +// error-pattern:task 'owned name' panicked at 'test' use std::task::TaskBuilder; diff --git a/src/test/run-fail/fail-task-name-send-str.rs b/src/test/run-fail/fail-task-name-send-str.rs index 2dcf947d0a9ac..73fca24659093 100644 --- a/src/test/run-fail/fail-task-name-send-str.rs +++ b/src/test/run-fail/fail-task-name-send-str.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:task 'send name' failed at 'test' +// error-pattern:task 'send name' panicked at 'test' fn main() { let r: Result = diff --git a/src/test/run-fail/fail-task-name-static.rs b/src/test/run-fail/fail-task-name-static.rs index d1861931e6062..21c019e1a7422 100644 --- a/src/test/run-fail/fail-task-name-static.rs +++ b/src/test/run-fail/fail-task-name-static.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:task 'static name' failed at 'test' +// error-pattern:task 'static name' panicked at 'test' fn main() { let r: Result = diff --git a/src/test/run-fail/glob-use-std.rs b/src/test/run-fail/glob-use-std.rs index cb66f2602d4a6..939845a7b349a 100644 --- a/src/test/run-fail/glob-use-std.rs +++ b/src/test/run-fail/glob-use-std.rs @@ -14,7 +14,7 @@ // // Expanded pretty printing causes resolve conflicts. -// error-pattern:fail works +// error-pattern:panic works #![feature(globs)] use std::*; diff --git a/src/test/run-fail/issue-12920.rs b/src/test/run-fail/issue-12920.rs index ade098d721ed7..8dbfc06152a0f 100644 --- a/src/test/run-fail/issue-12920.rs +++ b/src/test/run-fail/issue-12920.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:explicit failure +// error-pattern:explicit panic pub fn main() { panic!(); println!("{}", 1i); diff --git a/src/test/run-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs index 8aaf38e251a36..2b20540501ec0 100644 --- a/src/test/run-fail/issue-2444.rs +++ b/src/test/run-fail/issue-2444.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:explicit failure +// error-pattern:explicit panic use std::sync::Arc; diff --git a/src/test/run-fail/main-fail.rs b/src/test/run-fail/main-fail.rs index 6b1818b4fa2a7..b750501c265d5 100644 --- a/src/test/run-fail/main-fail.rs +++ b/src/test/run-fail/main-fail.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:task '
' failed at +// error-pattern:task '
' panicked at fn main() { panic!() diff --git a/src/test/run-fail/match-bot-fail.rs b/src/test/run-fail/match-bot-fail.rs index 8763f958a83e6..1b7cace14b079 100644 --- a/src/test/run-fail/match-bot-fail.rs +++ b/src/test/run-fail/match-bot-fail.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:explicit failure +// error-pattern:explicit panic #![allow(unreachable_code)] #![allow(unused_variable)] diff --git a/src/test/run-fail/native-failure.rs b/src/test/run-fail/native-failure.rs index 6b5e3bafe79b5..0b261676cb2df 100644 --- a/src/test/run-fail/native-failure.rs +++ b/src/test/run-fail/native-failure.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-android (FIXME #11419) -// error-pattern:explicit failure +// error-pattern:explicit panic extern crate native; diff --git a/src/test/run-fail/test-fail.rs b/src/test/run-fail/test-fail.rs index 0c1f9424ba035..cd2ec834d82ac 100644 --- a/src/test/run-fail/test-fail.rs +++ b/src/test/run-fail/test-fail.rs @@ -9,7 +9,7 @@ // except according to those terms. // check-stdout -// error-pattern:task 'test_foo' failed at +// error-pattern:task 'test_foo' panicked at // compile-flags: --test // ignore-pretty: does not work well with `--test` diff --git a/src/test/run-fail/unique-fail.rs b/src/test/run-fail/unique-fail.rs index 931963442442c..07c9a21c5c110 100644 --- a/src/test/run-fail/unique-fail.rs +++ b/src/test/run-fail/unique-fail.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: fail +// error-pattern: panic fn main() { box panic!(); } diff --git a/src/test/run-make/no-duplicate-libs/bar.rs b/src/test/run-make/no-duplicate-libs/bar.rs index 721d16b4810c8..1183475610584 100644 --- a/src/test/run-make/no-duplicate-libs/bar.rs +++ b/src/test/run-make/no-duplicate-libs/bar.rs @@ -19,4 +19,4 @@ pub extern fn bar() {} #[lang = "stack_exhausted"] fn stack_exhausted() {} #[lang = "eh_personality"] fn eh_personality() {} -#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } +#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } diff --git a/src/test/run-make/no-duplicate-libs/foo.rs b/src/test/run-make/no-duplicate-libs/foo.rs index 3382cc2079972..61a2a51da0864 100644 --- a/src/test/run-make/no-duplicate-libs/foo.rs +++ b/src/test/run-make/no-duplicate-libs/foo.rs @@ -19,4 +19,4 @@ pub extern fn foo() {} #[lang = "stack_exhausted"] fn stack_exhausted() {} #[lang = "eh_personality"] fn eh_personality() {} -#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } +#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } diff --git a/src/test/run-pass/smallest-hello-world.rs b/src/test/run-pass/smallest-hello-world.rs index 65307c5e7b559..2877aa6bd3be1 100644 --- a/src/test/run-pass/smallest-hello-world.rs +++ b/src/test/run-pass/smallest-hello-world.rs @@ -22,7 +22,7 @@ extern "rust-intrinsic" { fn transmute(t: T) -> U; } #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } +#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } #[start] #[no_stack_check]

= self.child.get(); //~^ ERROR attempt to use a non-constant value in a constant - fail!(); + panic!(); } } diff --git a/src/test/compile-fail/issue-5500-1.rs b/src/test/compile-fail/issue-5500-1.rs index e1779a1db8697..0edcfa8a5477d 100644 --- a/src/test/compile-fail/issue-5500-1.rs +++ b/src/test/compile-fail/issue-5500-1.rs @@ -16,5 +16,5 @@ fn main() { let a = 5; let _iter = TrieMapIterator{node: &a}; _iter.node = & //~ ERROR cannot assign to immutable field - fail!() + panic!() } diff --git a/src/test/compile-fail/issue-6458-1.rs b/src/test/compile-fail/issue-6458-1.rs index cb3ffae5dbae3..52a57fa2f4411 100644 --- a/src/test/compile-fail/issue-6458-1.rs +++ b/src/test/compile-fail/issue-6458-1.rs @@ -9,5 +9,5 @@ // except according to those terms. fn foo(t: T) {} -fn main() { foo(fail!()) } +fn main() { foo(panic!()) } //~^ ERROR type annotations required diff --git a/src/test/compile-fail/issue-897-2.rs b/src/test/compile-fail/issue-897-2.rs index e6b97b727a7e9..659b1426bd3f9 100644 --- a/src/test/compile-fail/issue-897-2.rs +++ b/src/test/compile-fail/issue-897-2.rs @@ -10,7 +10,7 @@ #![deny(unreachable_code)] -fn g() -> ! { fail!(); } +fn g() -> ! { panic!(); } fn f() -> ! { return g(); //~ ERROR `return` in a function declared as diverging g(); diff --git a/src/test/compile-fail/issue-897.rs b/src/test/compile-fail/issue-897.rs index 944546d0b4a61..b9cfbd695b047 100644 --- a/src/test/compile-fail/issue-897.rs +++ b/src/test/compile-fail/issue-897.rs @@ -11,8 +11,8 @@ #![deny(unreachable_code)] fn f() -> ! { - return fail!(); //~ ERROR `return` in a function declared as diverging - fail!(); // the unreachable statement error is in , at this line, there + return panic!(); //~ ERROR `return` in a function declared as diverging + panic!(); // the unreachable statement error is in , at this line, there // only is a note } diff --git a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs index 5fa8c5db5b01c..849f337743b77 100644 --- a/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs +++ b/src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs @@ -11,13 +11,13 @@ // Lifetime annotation needed because we have no arguments. fn f() -> &int { //~ ERROR missing lifetime specifier //~^ NOTE there is no value for it to be borrowed from - fail!() + panic!() } // Lifetime annotation needed because we have two by-reference parameters. fn g(_x: &int, _y: &int) -> &int { //~ ERROR missing lifetime specifier //~^ NOTE the signature does not say whether it is borrowed from `_x` or `_y` - fail!() + panic!() } struct Foo<'a> { @@ -28,7 +28,7 @@ struct Foo<'a> { // and one on the reference. fn h(_x: &Foo) -> &int { //~ ERROR missing lifetime specifier //~^ NOTE the signature does not say which one of `_x`'s 2 elided lifetimes it is borrowed from - fail!() + panic!() } fn main() {} diff --git a/src/test/compile-fail/lint-unused-unsafe.rs b/src/test/compile-fail/lint-unused-unsafe.rs index 8ae3f1fdd0d74..df3feefa881f3 100644 --- a/src/test/compile-fail/lint-unused-unsafe.rs +++ b/src/test/compile-fail/lint-unused-unsafe.rs @@ -20,7 +20,7 @@ mod foo { } } -fn callback(_f: || -> T) -> T { fail!() } +fn callback(_f: || -> T) -> T { panic!() } unsafe fn unsf() {} fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block @@ -50,7 +50,7 @@ fn good2() { sure that when purity is inherited that the source of the unsafe-ness is tracked correctly */ unsafe { - unsafe fn what() -> Vec { fail!() } + unsafe fn what() -> Vec { panic!() } callback(|| { what(); diff --git a/src/test/compile-fail/lint-visible-private-types.rs b/src/test/compile-fail/lint-visible-private-types.rs index 4a4032d2ab932..55ffdcd7f9fb3 100644 --- a/src/test/compile-fail/lint-visible-private-types.rs +++ b/src/test/compile-fail/lint-visible-private-types.rs @@ -17,27 +17,27 @@ struct Private; pub struct Public; impl Private> { - pub fn a(&self) -> Private { fail!() } - fn b(&self) -> Private { fail!() } + pub fn a(&self) -> Private { panic!() } + fn b(&self) -> Private { panic!() } - pub fn c() -> Private { fail!() } - fn d() -> Private { fail!() } + pub fn c() -> Private { panic!() } + fn d() -> Private { panic!() } } impl Private { - pub fn e(&self) -> Private { fail!() } - fn f(&self) -> Private { fail!() } + pub fn e(&self) -> Private { panic!() } + fn f(&self) -> Private { panic!() } } impl Public> { - pub fn a(&self) -> Private { fail!() } - fn b(&self) -> Private { fail!() } + pub fn a(&self) -> Private { panic!() } + fn b(&self) -> Private { panic!() } - pub fn c() -> Private { fail!() } //~ ERROR private type in exported type signature - fn d() -> Private { fail!() } + pub fn c() -> Private { panic!() } //~ ERROR private type in exported type signature + fn d() -> Private { panic!() } } impl Public { - pub fn e(&self) -> Private { fail!() } //~ ERROR private type in exported type signature - fn f(&self) -> Private { fail!() } + pub fn e(&self) -> Private { panic!() } //~ ERROR private type in exported type signature + fn f(&self) -> Private { panic!() } } pub fn x(_: Private) {} //~ ERROR private type in exported type signature @@ -70,39 +70,39 @@ enum Qux { } pub trait PubTrait { - fn foo(&self) -> Private { fail!( )} //~ ERROR private type in exported type signature + fn foo(&self) -> Private { panic!( )} //~ ERROR private type in exported type signature fn bar(&self) -> Private; //~ ERROR private type in exported type signature fn baz() -> Private; //~ ERROR private type in exported type signature } impl PubTrait for Public { - fn bar(&self) -> Private { fail!() } - fn baz() -> Private { fail!() } + fn bar(&self) -> Private { panic!() } + fn baz() -> Private { panic!() } } impl PubTrait for Public> { - fn bar(&self) -> Private { fail!() } - fn baz() -> Private { fail!() } + fn bar(&self) -> Private { panic!() } + fn baz() -> Private { panic!() } } impl PubTrait for Private { - fn bar(&self) -> Private { fail!() } - fn baz() -> Private { fail!() } + fn bar(&self) -> Private { panic!() } + fn baz() -> Private { panic!() } } impl PubTrait for (Private,) { - fn bar(&self) -> Private { fail!() } - fn baz() -> Private { fail!() } + fn bar(&self) -> Private { panic!() } + fn baz() -> Private { panic!() } } trait PrivTrait { - fn foo(&self) -> Private { fail!( )} + fn foo(&self) -> Private { panic!( )} fn bar(&self) -> Private; } impl PrivTrait for Private { - fn bar(&self) -> Private { fail!() } + fn bar(&self) -> Private { panic!() } } impl PrivTrait for (Private,) { - fn bar(&self) -> Private { fail!() } + fn bar(&self) -> Private { panic!() } } pub trait ParamTrait { @@ -111,14 +111,14 @@ pub trait ParamTrait { impl ParamTrait> //~ ERROR private type in exported type signature for Public { - fn foo() -> Private { fail!() } + fn foo() -> Private { panic!() } } impl ParamTrait> for Private { - fn foo() -> Private { fail!( )} + fn foo() -> Private { panic!( )} } impl>> //~ ERROR private type in exported type signature ParamTrait for Public { - fn foo() -> T { fail!() } + fn foo() -> T { panic!() } } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 54d0b2d00c776..1ad696503e7f9 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -11,7 +11,7 @@ fn send(ch: _chan, data: T) { println!("{}", ch); println!("{}", data); - fail!(); + panic!(); } #[deriving(Show)] @@ -24,4 +24,4 @@ fn test00_start(ch: _chan>, message: Box, _count: Box) { println!("{}", message); //~ ERROR use of moved value: `message` } -fn main() { fail!(); } +fn main() { panic!(); } diff --git a/src/test/compile-fail/match-join.rs b/src/test/compile-fail/match-join.rs index de44a005fc33a..8064ef0e427a3 100644 --- a/src/test/compile-fail/match-join.rs +++ b/src/test/compile-fail/match-join.rs @@ -11,10 +11,10 @@ // a good test that we merge paths correctly in the presence of a // variable that's used before it's declared -fn my_fail() -> ! { fail!(); } +fn my_panic() -> ! { panic!(); } fn main() { - match true { false => { my_fail(); } true => { } } + match true { false => { my_panic(); } true => { } } println!("{}", x); //~ ERROR unresolved name `x`. let x: int; diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index 1d6dc504ab43b..678808f166cde 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -13,7 +13,7 @@ struct Foo { f: A } -fn guard(_s: String) -> bool {fail!()} +fn guard(_s: String) -> bool {panic!()} fn touch(_a: &A) {} fn f10() { diff --git a/src/test/compile-fail/moves-based-on-type-match-bindings.rs b/src/test/compile-fail/moves-based-on-type-match-bindings.rs index 65ae25396c8d6..7d209467caf2a 100644 --- a/src/test/compile-fail/moves-based-on-type-match-bindings.rs +++ b/src/test/compile-fail/moves-based-on-type-match-bindings.rs @@ -13,7 +13,7 @@ // terms of the binding, not the discriminant. struct Foo { f: A } -fn guard(_s: String) -> bool {fail!()} +fn guard(_s: String) -> bool {panic!()} fn touch(_a: &A) {} fn f10() { diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index ff5ad2c5e1936..2a73b769895ee 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -31,7 +31,7 @@ fn innocent_looking_victim() { //~^ ERROR: cannot borrow `*f` as mutable because println!("{}", msg); }, - None => fail!("oops"), + None => panic!("oops"), } } }) diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs index 439c82a6df08b..eb946a90c376c 100644 --- a/src/test/compile-fail/non-exhaustive-match-nested.rs +++ b/src/test/compile-fail/non-exhaustive-match-nested.rs @@ -23,7 +23,7 @@ fn match_nested_vecs<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'s fn main() { let x = a(c); match x { //~ ERROR non-exhaustive patterns: `a(c)` not covered - a(d) => { fail!("hello"); } - b => { fail!("goodbye"); } + a(d) => { panic!("hello"); } + b => { panic!("goodbye"); } } } diff --git a/src/test/compile-fail/not-enough-arguments.rs b/src/test/compile-fail/not-enough-arguments.rs index 57eca3666ef14..2deb9591a834d 100644 --- a/src/test/compile-fail/not-enough-arguments.rs +++ b/src/test/compile-fail/not-enough-arguments.rs @@ -13,7 +13,7 @@ // unrelated errors. fn foo(a: int, b: int, c: int, d:int) { - fail!(); + panic!(); } fn main() { diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index 38669a99b498f..7da62ef4db7da 100644 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ b/src/test/compile-fail/pattern-tyvar-2.rs @@ -11,7 +11,7 @@ enum bar { t1((), Option>), t2, } // n.b. my change changes this error message, but I think it's right -- tjc -fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail!(); } } } +fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { panic!(); } } } //~^ ERROR binary operation `*` cannot be applied to fn main() { } diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs index efb98a74538f2..7752ea521f7e3 100644 --- a/src/test/compile-fail/pattern-tyvar.rs +++ b/src/test/compile-fail/pattern-tyvar.rs @@ -17,7 +17,7 @@ fn foo(t: bar) { t1(_, Some::(x)) => { println!("{}", x); } - _ => { fail!(); } + _ => { panic!(); } } } diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index 06d473baea878..deae9a8386603 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -64,5 +64,5 @@ fn main() { } fn check_pp(expr: T, f: |pprust::ps, T|, expect: str) { - fail!(); + panic!(); } diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index f63dd91eb2bc1..94485dddd136b 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -57,5 +57,5 @@ fn main() { } fn check_pp(expr: T, f: |pprust::ps, T|, expect: str) { - fail!(); + panic!(); } diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index b3b5993bf915b..c2b52b79f6c87 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -21,8 +21,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of() -> |T| { fail!(); } -fn subtype(x: |T|) { fail!(); } +fn of() -> |T| { panic!(); } +fn subtype(x: |T|) { panic!(); } fn test_fn<'x, 'y, 'z, T>(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters diff --git a/src/test/compile-fail/regions-fn-subtyping-return-static.rs b/src/test/compile-fail/regions-fn-subtyping-return-static.rs index 2d20634cdc41d..72004f8714c6e 100644 --- a/src/test/compile-fail/regions-fn-subtyping-return-static.rs +++ b/src/test/compile-fail/regions-fn-subtyping-return-static.rs @@ -31,17 +31,17 @@ fn want_G(f: G) { } // Should meet both. fn foo(x: &S) -> &'static S { - fail!() + panic!() } // Should meet both. fn bar<'a,'b>(x: &'a S) -> &'b S { - fail!() + panic!() } // Meets F, but not G. fn baz(x: &S) -> &S { - fail!() + panic!() } fn supply_F() { diff --git a/src/test/compile-fail/regions-fn-subtyping.rs b/src/test/compile-fail/regions-fn-subtyping.rs index 30b33e82a4b79..8e8d892a39f22 100644 --- a/src/test/compile-fail/regions-fn-subtyping.rs +++ b/src/test/compile-fail/regions-fn-subtyping.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of<'a,T>() -> |T|:'a { fail!(); } -fn subtype(x: |T|) { fail!(); } +fn of<'a,T>() -> |T|:'a { panic!(); } +fn subtype(x: |T|) { panic!(); } fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters diff --git a/src/test/compile-fail/regions-free-region-ordering-callee.rs b/src/test/compile-fail/regions-free-region-ordering-callee.rs index 26cf3be429bd6..435d10a0a29a1 100644 --- a/src/test/compile-fail/regions-free-region-ordering-callee.rs +++ b/src/test/compile-fail/regions-free-region-ordering-callee.rs @@ -27,7 +27,7 @@ fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint { // Do not infer an ordering from the return value. let z: &'b uint = &*x; //~^ ERROR cannot infer - fail!(); + panic!(); } fn ordering4<'a, 'b>(a: &'a uint, b: &'b uint, x: |&'a &'b uint|) { diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index 9615e32bb1acf..a9df449032e6f 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -15,7 +15,7 @@ use std::vec::Vec; fn last(v: Vec<&T> ) -> std::option::Option { - fail!(); + panic!(); } fn main() { diff --git a/src/test/compile-fail/tag-type-args.rs b/src/test/compile-fail/tag-type-args.rs index f2ef1d1952505..5785a13b00682 100644 --- a/src/test/compile-fail/tag-type-args.rs +++ b/src/test/compile-fail/tag-type-args.rs @@ -14,4 +14,4 @@ enum quux { bar } fn foo(c: quux) { assert!((false)); } -fn main() { fail!(); } +fn main() { panic!(); } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs index 4233fa843eb61..52035c09dd6dd 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs @@ -20,7 +20,7 @@ fn main() { x: 3i }; - let baz: Foo = fail!(); + let baz: Foo = panic!(); //~^ ERROR not implemented } diff --git a/src/test/compile-fail/unused-result.rs b/src/test/compile-fail/unused-result.rs index ecc52c0ee7d58..124bd9c4d5b4e 100644 --- a/src/test/compile-fail/unused-result.rs +++ b/src/test/compile-fail/unused-result.rs @@ -17,7 +17,7 @@ enum MustUse { Test } #[must_use = "some message"] enum MustUseMsg { Test2 } -fn foo() -> T { fail!() } +fn foo() -> T { panic!() } fn bar() -> int { return foo::(); } fn baz() -> MustUse { return foo::(); } diff --git a/src/test/debuginfo/basic-types-metadata.rs b/src/test/debuginfo/basic-types-metadata.rs index d67a6b1e20049..dae1aca4ed37c 100644 --- a/src/test/debuginfo/basic-types-metadata.rs +++ b/src/test/debuginfo/basic-types-metadata.rs @@ -72,4 +72,4 @@ fn main() { } fn _zzz() {()} -fn _yyy() -> ! {fail!()} +fn _yyy() -> ! {panic!()} diff --git a/src/test/pretty/issue-929.rs b/src/test/pretty/issue-929.rs index 85b71e4e86cc7..377f4669ffc8c 100644 --- a/src/test/pretty/issue-929.rs +++ b/src/test/pretty/issue-929.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f() { if (1i == fail!()) { } else { } } +fn f() { if (1i == panic!()) { } else { } } fn main() { } diff --git a/src/test/run-fail/args-fail.rs b/src/test/run-fail/args-fail.rs index 5e1b7bb69bb2b..4878ec59fd4bc 100644 --- a/src/test/run-fail/args-fail.rs +++ b/src/test/run-fail/args-fail.rs @@ -11,6 +11,6 @@ // error-pattern:meep -fn f(_a: int, _b: int, _c: Box) { fail!("moop"); } +fn f(_a: int, _b: int, _c: Box) { panic!("moop"); } -fn main() { f(1, fail!("meep"), box 42); } +fn main() { f(1, panic!("meep"), box 42); } diff --git a/src/test/run-fail/binop-fail.rs b/src/test/run-fail/binop-fail.rs index 1ae520bbf1a74..ac85b218ec030 100644 --- a/src/test/run-fail/binop-fail.rs +++ b/src/test/run-fail/binop-fail.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: String) -> ! { println!("{}", s); fail!("quux"); } +fn my_err(s: String) -> ! { println!("{}", s); panic!("quux"); } fn main() { 3u == my_err("bye".to_string()); } diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow-2.rs b/src/test/run-fail/bug-2470-bounds-check-overflow-2.rs index 8ca317e1dd773..06712841823e8 100644 --- a/src/test/run-fail/bug-2470-bounds-check-overflow-2.rs +++ b/src/test/run-fail/bug-2470-bounds-check-overflow-2.rs @@ -16,7 +16,7 @@ use std::uint; fn main() { let x = vec!(1u,2u,3u); - // This should cause a bounds-check failure, but may not if we do our + // This should cause a bounds-check panic, but may not if we do our // bounds checking by comparing a scaled index value to the vector's // length (in bytes), because the scaling of the index will cause it to // wrap around to a small number. @@ -24,6 +24,6 @@ fn main() { let idx = uint::MAX & !(uint::MAX >> 1u); println!("ov2 idx = 0x%x", idx); - // This should fail. + // This should panic. println!("ov2 0x%x", x[idx]); } diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs b/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs index 6106abc76c3f7..22a9fffb2fb23 100644 --- a/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs +++ b/src/test/run-fail/bug-2470-bounds-check-overflow-3.rs @@ -17,7 +17,7 @@ use std::u64; fn main() { let x = vec!(1u,2u,3u); - // This should cause a bounds-check failure, but may not if we do our + // This should cause a bounds-check panic, but may not if we do our // bounds checking by truncating the index value to the size of the // machine word, losing relevant bits of the index value. @@ -28,13 +28,13 @@ fn main() { (idx >> 32) as uint, idx as uint); - // This should fail. + // This should panic. println!("ov3 0x%x", x.as_slice()[idx]); } #[cfg(target_arch="x86_64")] fn main() { - // This version just fails anyways, for symmetry on 64-bit hosts. + // This version just panics anyways, for symmetry on 64-bit hosts. let x = vec!(1u,2u,3u); error!("ov3 0x%x", x.as_slice()[200]); } diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow.rs b/src/test/run-fail/bug-2470-bounds-check-overflow.rs index 9123342f09a5c..f8686d0dbb56f 100644 --- a/src/test/run-fail/bug-2470-bounds-check-overflow.rs +++ b/src/test/run-fail/bug-2470-bounds-check-overflow.rs @@ -14,7 +14,7 @@ use std::mem; fn main() { - // This should cause a bounds-check failure, but may not if we do our + // 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 @@ -30,6 +30,6 @@ fn main() { println!("ov1 idx * sizeof::() = 0x{:x}", idx * mem::size_of::()); - // This should fail. + // 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 index 2a256b9a4e384..e46564f80760c 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -19,6 +19,6 @@ struct chan_t { port: port_id, } -fn send(_ch: chan_t, _data: T) { fail!(); } +fn send(_ch: chan_t, _data: T) { panic!(); } -fn main() { fail!("quux"); } +fn main() { panic!("quux"); } diff --git a/src/test/run-fail/by-value-self-objects-fail.rs b/src/test/run-fail/by-value-self-objects-fail.rs index 74889263cc8a2..5747aa7a838e3 100644 --- a/src/test/run-fail/by-value-self-objects-fail.rs +++ b/src/test/run-fail/by-value-self-objects-fail.rs @@ -23,7 +23,7 @@ struct S { impl Foo for S { fn foo(self, x: int) { - fail!() + panic!() } } diff --git a/src/test/run-fail/die-macro-expr.rs b/src/test/run-fail/die-macro-expr.rs index 7f7eddd86cf67..2014a108b3dab 100644 --- a/src/test/run-fail/die-macro-expr.rs +++ b/src/test/run-fail/die-macro-expr.rs @@ -11,5 +11,5 @@ // error-pattern:test fn main() { - let _i: int = fail!("test"); + let _i: int = panic!("test"); } diff --git a/src/test/run-fail/die-macro-pure.rs b/src/test/run-fail/die-macro-pure.rs index f1d9b15c42a0b..b54bf1c0c68d6 100644 --- a/src/test/run-fail/die-macro-pure.rs +++ b/src/test/run-fail/die-macro-pure.rs @@ -11,7 +11,7 @@ // error-pattern:test fn f() { - fail!("test"); + panic!("test"); } fn main() { diff --git a/src/test/run-fail/die-macro.rs b/src/test/run-fail/die-macro.rs index 82e790c5d9fd9..811bd6e037dd4 100644 --- a/src/test/run-fail/die-macro.rs +++ b/src/test/run-fail/die-macro.rs @@ -11,5 +11,5 @@ // error-pattern:test fn main() { - fail!("test"); + panic!("test"); } diff --git a/src/test/run-fail/doublefail.rs b/src/test/run-fail/doublefail.rs index 4f3dfaa80b939..3835a16a5c263 100644 --- a/src/test/run-fail/doublefail.rs +++ b/src/test/run-fail/doublefail.rs @@ -12,6 +12,6 @@ //error-pattern:One fn main() { - fail!("One"); - fail!("Two"); + panic!("One"); + panic!("Two"); } diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index 4af9b82ec7e22..f6d27cf99592a 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -15,5 +15,5 @@ fn main() { let mut a = 1i; if 1i == 1 { a = 2; } - fail!(format!("woooo{}", "o")); + panic!(format!("woooo{}", "o")); } diff --git a/src/test/run-fail/explicit-fail.rs b/src/test/run-fail/explicit-fail.rs index 8c204b66e3657..4699897bf8abe 100644 --- a/src/test/run-fail/explicit-fail.rs +++ b/src/test/run-fail/explicit-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit -fn main() { fail!(); } +fn main() { panic!(); } diff --git a/src/test/run-fail/expr-fn-fail.rs b/src/test/run-fail/expr-fn-fail.rs index e645ea34df564..179d52bda0318 100644 --- a/src/test/run-fail/expr-fn-fail.rs +++ b/src/test/run-fail/expr-fn-fail.rs @@ -12,6 +12,6 @@ // error-pattern:explicit failure -fn f() -> ! { fail!() } +fn f() -> ! { panic!() } fn main() { f(); } diff --git a/src/test/run-fail/expr-if-fail-fn.rs b/src/test/run-fail/expr-if-fail-fn.rs index 99f798147f28f..ad2ff7a8c6bea 100644 --- a/src/test/run-fail/expr-if-fail-fn.rs +++ b/src/test/run-fail/expr-if-fail-fn.rs @@ -12,7 +12,7 @@ // error-pattern:explicit failure -fn f() -> ! { fail!() } +fn f() -> ! { panic!() } fn g() -> int { let x = if true { f() } else { 10 }; return x; } diff --git a/src/test/run-fail/expr-if-fail.rs b/src/test/run-fail/expr-if-fail.rs index 55d86bc649324..d2214f8c39878 100644 --- a/src/test/run-fail/expr-if-fail.rs +++ b/src/test/run-fail/expr-if-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit failure -fn main() { let _x = if false { 0i } else if true { fail!() } else { 10i }; } +fn main() { let _x = if false { 0i } else if true { panic!() } else { 10i }; } diff --git a/src/test/run-fail/expr-match-fail-fn.rs b/src/test/run-fail/expr-match-fail-fn.rs index 6476e57a35b84..78f9ce8cc291d 100644 --- a/src/test/run-fail/expr-match-fail-fn.rs +++ b/src/test/run-fail/expr-match-fail-fn.rs @@ -12,7 +12,7 @@ // error-pattern:explicit failure -fn f() -> ! { fail!() } +fn f() -> ! { panic!() } fn g() -> int { let x = match true { true => { f() } false => { 10 } }; return x; } diff --git a/src/test/run-fail/expr-match-fail.rs b/src/test/run-fail/expr-match-fail.rs index d15ec3f7b486a..0354717291dd2 100644 --- a/src/test/run-fail/expr-match-fail.rs +++ b/src/test/run-fail/expr-match-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit failure -fn main() { let _x = match true { false => { 0i } true => { fail!() } }; } +fn main() { let _x = match true { false => { 0i } true => { panic!() } }; } diff --git a/src/test/run-fail/extern-fail.rs b/src/test/run-fail/extern-fail.rs index c11d269a89755..21a332a46cb59 100644 --- a/src/test/run-fail/extern-fail.rs +++ b/src/test/run-fail/extern-fail.rs @@ -45,7 +45,7 @@ fn main() { task::spawn(proc() { let result = count(5u); println!("result = %?", result); - fail!(); + panic!(); }); } } diff --git a/src/test/run-fail/fail-arg.rs b/src/test/run-fail/fail-arg.rs index e23145ec25357..4d4f931751067 100644 --- a/src/test/run-fail/fail-arg.rs +++ b/src/test/run-fail/fail-arg.rs @@ -11,4 +11,4 @@ // error-pattern:woe fn f(a: int) { println!("{}", a); } -fn main() { f(fail!("woe")); } +fn main() { f(panic!("woe")); } diff --git a/src/test/run-fail/fail-macro-any-wrapped.rs b/src/test/run-fail/fail-macro-any-wrapped.rs index e1eea1d89b9db..432647e0e2b2a 100644 --- a/src/test/run-fail/fail-macro-any-wrapped.rs +++ b/src/test/run-fail/fail-macro-any-wrapped.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'Box' fn main() { - fail!(box 612_i64); + panic!(box 612_i64); } diff --git a/src/test/run-fail/fail-macro-any.rs b/src/test/run-fail/fail-macro-any.rs index 528f18dde0d3b..54704c44c0116 100644 --- a/src/test/run-fail/fail-macro-any.rs +++ b/src/test/run-fail/fail-macro-any.rs @@ -12,5 +12,5 @@ fn main() { - fail!(box 413i as Box<::std::any::Any+Send>); + panic!(box 413i as Box<::std::any::Any+Send>); } diff --git a/src/test/run-fail/fail-macro-explicit.rs b/src/test/run-fail/fail-macro-explicit.rs index 13e3a6a31a8fa..bc240181e4c41 100644 --- a/src/test/run-fail/fail-macro-explicit.rs +++ b/src/test/run-fail/fail-macro-explicit.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'explicit failure' fn main() { - fail!(); + panic!(); } diff --git a/src/test/run-fail/fail-macro-fmt.rs b/src/test/run-fail/fail-macro-fmt.rs index b3984c210b5b4..069ffc4434f3f 100644 --- a/src/test/run-fail/fail-macro-fmt.rs +++ b/src/test/run-fail/fail-macro-fmt.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-fail-fmt 42 rust' fn main() { - fail!("test-fail-fmt {} {}", 42i, "rust"); + panic!("test-fail-fmt {} {}", 42i, "rust"); } diff --git a/src/test/run-fail/fail-macro-owned.rs b/src/test/run-fail/fail-macro-owned.rs index e59f5bdcaa179..477f344280451 100644 --- a/src/test/run-fail/fail-macro-owned.rs +++ b/src/test/run-fail/fail-macro-owned.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-fail-owned' fn main() { - fail!("test-fail-owned"); + panic!("test-fail-owned"); } diff --git a/src/test/run-fail/fail-macro-static.rs b/src/test/run-fail/fail-macro-static.rs index 688ca4ce7e572..51b70110da296 100644 --- a/src/test/run-fail/fail-macro-static.rs +++ b/src/test/run-fail/fail-macro-static.rs @@ -11,5 +11,5 @@ // error-pattern:failed at 'test-fail-static' fn main() { - fail!("test-fail-static"); + panic!("test-fail-static"); } diff --git a/src/test/run-fail/fail-main.rs b/src/test/run-fail/fail-main.rs index f90530a4435b1..877ea9cd0a430 100644 --- a/src/test/run-fail/fail-main.rs +++ b/src/test/run-fail/fail-main.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern:moop -fn main() { fail!("moop"); } +fn main() { panic!("moop"); } diff --git a/src/test/run-fail/fail-non-utf8.rs b/src/test/run-fail/fail-non-utf8.rs index 88720b421e687..ba4ff1da7e0b5 100644 --- a/src/test/run-fail/fail-non-utf8.rs +++ b/src/test/run-fail/fail-non-utf8.rs @@ -22,5 +22,5 @@ impl std::fmt::Show for Foo { } } fn main() { - fail!("{}", Foo) + panic!("{}", Foo) } diff --git a/src/test/run-fail/fail-parens.rs b/src/test/run-fail/fail-parens.rs index 90a44e4275937..06655e4c68132 100644 --- a/src/test/run-fail/fail-parens.rs +++ b/src/test/run-fail/fail-parens.rs @@ -12,12 +12,12 @@ // certain positions // error-pattern:oops -fn bigfail() { - while (fail!("oops")) { if (fail!()) { - match (fail!()) { () => { +fn bigpanic() { + while (panic!("oops")) { if (panic!()) { + match (panic!()) { () => { } } }}; } -fn main() { bigfail(); } +fn main() { bigpanic(); } diff --git a/src/test/run-fail/fail-task-name-none.rs b/src/test/run-fail/fail-task-name-none.rs index 75d23d0f4fdf2..a32b64f910518 100644 --- a/src/test/run-fail/fail-task-name-none.rs +++ b/src/test/run-fail/fail-task-name-none.rs @@ -14,7 +14,7 @@ use std::task; fn main() { let r: Result = task::try(proc() { - fail!("test"); + panic!("test"); 1i }); assert!(r.is_ok()); diff --git a/src/test/run-fail/fail-task-name-owned.rs b/src/test/run-fail/fail-task-name-owned.rs index edb03b2d6b461..7553347e20b67 100644 --- a/src/test/run-fail/fail-task-name-owned.rs +++ b/src/test/run-fail/fail-task-name-owned.rs @@ -15,7 +15,7 @@ use std::task::TaskBuilder; fn main() { let r: Result = TaskBuilder::new().named("owned name".to_string()) .try(proc() { - fail!("test"); + panic!("test"); 1i }); assert!(r.is_ok()); diff --git a/src/test/run-fail/fail-task-name-send-str.rs b/src/test/run-fail/fail-task-name-send-str.rs index 0a74009977828..2dcf947d0a9ac 100644 --- a/src/test/run-fail/fail-task-name-send-str.rs +++ b/src/test/run-fail/fail-task-name-send-str.rs @@ -14,7 +14,7 @@ fn main() { let r: Result = ::std::task::TaskBuilder::new().named("send name".into_maybe_owned()) .try(proc() { - fail!("test"); + panic!("test"); 3i }); assert!(r.is_ok()); diff --git a/src/test/run-fail/fail-task-name-static.rs b/src/test/run-fail/fail-task-name-static.rs index 0b2901889cbf2..d1861931e6062 100644 --- a/src/test/run-fail/fail-task-name-static.rs +++ b/src/test/run-fail/fail-task-name-static.rs @@ -13,7 +13,7 @@ fn main() { let r: Result = ::std::task::TaskBuilder::new().named("static name").try(proc() { - fail!("test"); + panic!("test"); }); assert!(r.is_ok()); } diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index ae89f9518406a..22e81480867a9 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -12,5 +12,5 @@ fn main() { let str_var: String = "meh".to_string(); - fail!("{}", str_var); + panic!("{}", str_var); } diff --git a/src/test/run-fail/for-each-loop-fail.rs b/src/test/run-fail/for-each-loop-fail.rs index 508463599a32f..472c8ae15b992 100644 --- a/src/test/run-fail/for-each-loop-fail.rs +++ b/src/test/run-fail/for-each-loop-fail.rs @@ -10,4 +10,4 @@ // error-pattern:moop -fn main() { for _ in range(0u, 10u) { fail!("moop"); } } +fn main() { for _ in range(0u, 10u) { panic!("moop"); } } diff --git a/src/test/run-fail/glob-use-std.rs b/src/test/run-fail/glob-use-std.rs index bf04789bbc773..cb66f2602d4a6 100644 --- a/src/test/run-fail/glob-use-std.rs +++ b/src/test/run-fail/glob-use-std.rs @@ -20,5 +20,5 @@ use std::*; fn main() { - fail!("fail works") + panic!("panic works") } diff --git a/src/test/run-fail/if-check-fail.rs b/src/test/run-fail/if-check-fail.rs index b5f39e73fcb1a..1ead81b00919d 100644 --- a/src/test/run-fail/if-check-fail.rs +++ b/src/test/run-fail/if-check-fail.rs @@ -19,7 +19,7 @@ fn foo(x: uint) { if even(x) { println!("{}", x); } else { - fail!("Number is odd"); + panic!("Number is odd"); } } diff --git a/src/test/run-fail/if-cond-bot.rs b/src/test/run-fail/if-cond-bot.rs index d80ae967f0e2c..f38b00ab46d90 100644 --- a/src/test/run-fail/if-cond-bot.rs +++ b/src/test/run-fail/if-cond-bot.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: String) -> ! { println!("{}", s); fail!("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 index b5b8d4855ab8d..ade098d721ed7 100644 --- a/src/test/run-fail/issue-12920.rs +++ b/src/test/run-fail/issue-12920.rs @@ -11,5 +11,5 @@ // error-pattern:explicit failure pub fn main() { - fail!(); println!("{}", 1i); + panic!(); println!("{}", 1i); } diff --git a/src/test/run-fail/issue-13202.rs b/src/test/run-fail/issue-13202.rs index 80006936f22c0..57b7dfc1eecd6 100644 --- a/src/test/run-fail/issue-13202.rs +++ b/src/test/run-fail/issue-13202.rs @@ -11,5 +11,5 @@ // error-pattern:bad input fn main() { - Some("foo").unwrap_or(fail!("bad input")).to_string(); + Some("foo").unwrap_or(panic!("bad input")).to_string(); } diff --git a/src/test/run-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs index 9a5a8e7c38f81..8aaf38e251a36 100644 --- a/src/test/run-fail/issue-2444.rs +++ b/src/test/run-fail/issue-2444.rs @@ -14,7 +14,7 @@ use std::sync::Arc; enum e { ee(Arc) } -fn foo() -> e {fail!();} +fn foo() -> e {panic!();} fn main() { let _f = foo(); diff --git a/src/test/run-fail/issue-3029.rs b/src/test/run-fail/issue-3029.rs index 539d2adc7d45c..686277c8c09a0 100644 --- a/src/test/run-fail/issue-3029.rs +++ b/src/test/run-fail/issue-3029.rs @@ -17,6 +17,6 @@ fn main() { let mut x = Vec::new(); let y = vec!(3i); - fail!("so long"); + panic!("so long"); x.extend(y.into_iter()); } diff --git a/src/test/run-fail/issue-948.rs b/src/test/run-fail/issue-948.rs index 5669131aeee53..878a293c37316 100644 --- a/src/test/run-fail/issue-948.rs +++ b/src/test/run-fail/issue-948.rs @@ -16,5 +16,5 @@ struct Point { x: int, y: int } fn main() { let origin = Point {x: 0, y: 0}; - let f: Point = Point {x: (fail!("beep boop")),.. origin}; + let f: Point = Point {x: (panic!("beep boop")),.. origin}; } diff --git a/src/test/run-fail/main-fail.rs b/src/test/run-fail/main-fail.rs index ca219fe21837d..6b1818b4fa2a7 100644 --- a/src/test/run-fail/main-fail.rs +++ b/src/test/run-fail/main-fail.rs @@ -11,5 +11,5 @@ // error-pattern:task '