]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #21964 - semarie:openbsd-env, r=alexcrichton
authorManish Goregaokar <manishsmail@gmail.com>
Fri, 6 Feb 2015 00:06:48 +0000 (05:36 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Fri, 6 Feb 2015 10:51:05 +0000 (16:21 +0530)
 - add `_SC_GETPW_R_SIZE_MAX` constant
- declare `struct passwd`
- convert `load_self` to `current_exe`

Note: OpenBSD don't provide system function to return a valuable Path
for `env::current_exe`. The implementation is currently based on the
value of `argv[0]`, which couldn't be used when executable is called via
PATH.

502 files changed:
Makefile.in
mk/main.mk
mk/tests.mk
src/compiletest/compiletest.rs
src/compiletest/errors.rs
src/compiletest/header.rs
src/compiletest/procsrv.rs
src/compiletest/runtest.rs
src/doc/trpl/crates-and-modules.md
src/etc/errorck.py
src/etc/featureck.py
src/etc/licenseck.py
src/etc/tidy.py
src/grammar/check.sh
src/grammar/testparser.py
src/grammar/verify.rs
src/liballoc/rc.rs
src/libcollections/bench.rs
src/libcollections/bit.rs
src/libcollections/dlist.rs
src/libcollections/slice.rs
src/libcollections/str.rs
src/libcollections/string.rs
src/libcollections/vec.rs
src/libcore/finally.rs
src/libcore/fmt/float.rs
src/libcore/fmt/mod.rs
src/libcore/hash/mod.rs
src/libcore/mem.rs
src/libcore/str/mod.rs
src/libcoretest/char.rs
src/libcoretest/finally.rs
src/libcoretest/hash/sip.rs
src/libcoretest/str.rs
src/libflate/lib.rs
src/libgetopts/lib.rs
src/libgraphviz/lib.rs
src/liblog/lib.rs
src/librand/chacha.rs
src/librand/distributions/mod.rs
src/librand/isaac.rs
src/librand/lib.rs
src/librand/reseeding.rs
src/librbml/io.rs
src/librbml/lib.rs
src/librustc/lint/builtin.rs
src/librustc/lint/context.rs
src/librustc/metadata/creader.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/loader.rs
src/librustc/metadata/tydecode.rs
src/librustc/middle/astencode.rs
src/librustc/middle/check_const.rs
src/librustc/middle/check_match.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/dead.rs
src/librustc/middle/entry.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/graph.rs
src/librustc/middle/infer/combine.rs
src/librustc/middle/infer/error_reporting.rs
src/librustc/middle/infer/freshen.rs
src/librustc/middle/infer/higher_ranked/mod.rs
src/librustc/middle/infer/region_inference/graphviz.rs
src/librustc/middle/infer/region_inference/mod.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/region.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/stability.rs
src/librustc/middle/subst.rs
src/librustc/middle/traits/doc.rs
src/librustc/middle/traits/error_reporting.rs
src/librustc/middle/traits/fulfill.rs
src/librustc/middle/traits/project.rs
src/librustc/middle/traits/select.rs
src/librustc/middle/traits/util.rs
src/librustc/middle/ty.rs
src/librustc/middle/ty_walk.rs
src/librustc/middle/weak_lang_items.rs
src/librustc/plugin/build.rs
src/librustc/plugin/load.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc/util/common.rs
src/librustc/util/ppaux.rs
src/librustc_back/sha2.rs
src/librustc_back/target/mod.rs
src/librustc_borrowck/borrowck/fragments.rs
src/librustc_borrowck/borrowck/gather_loans/restrictions.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_borrowck/graphviz.rs
src/librustc_driver/driver.rs
src/librustc_driver/lib.rs
src/librustc_driver/pretty.rs
src/librustc_driver/test.rs
src/librustc_privacy/lib.rs
src/librustc_resolve/lib.rs
src/librustc_trans/back/link.rs
src/librustc_trans/back/lto.rs
src/librustc_trans/back/write.rs
src/librustc_trans/save/mod.rs
src/librustc_trans/save/recorder.rs
src/librustc_trans/save/span_utils.rs
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/adt.rs
src/librustc_trans/trans/asm.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/cabi_mips.rs
src/librustc_trans/trans/cabi_powerpc.rs
src/librustc_trans/trans/cabi_x86_64.rs
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/context.rs
src/librustc_trans/trans/debuginfo.rs
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/foreign.rs
src/librustc_trans/trans/intrinsic.rs
src/librustc_trans/trans/meth.rs
src/librustc_trans/trans/monomorphize.rs
src/librustc_trans/trans/type_of.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/callee.rs
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/vtable.rs
src/librustc_typeck/check/wf.rs
src/librustc_typeck/coherence/orphan.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/variance.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/core.rs
src/librustdoc/externalfiles.rs
src/librustdoc/html/escape.rs
src/librustdoc/html/format.rs
src/librustdoc/html/highlight.rs
src/librustdoc/html/markdown.rs
src/librustdoc/html/render.rs
src/librustdoc/html/toc.rs
src/librustdoc/lib.rs
src/librustdoc/markdown.rs
src/librustdoc/passes.rs
src/librustdoc/plugins.rs
src/librustdoc/test.rs
src/libserialize/json.rs
src/libstd/ascii.rs
src/libstd/dynamic_lib.rs
src/libstd/ffi/c_str.rs
src/libstd/num/strconv.rs
src/libstd/old_io/buffered.rs
src/libstd/old_io/comm_adapters.rs
src/libstd/old_io/extensions.rs
src/libstd/old_io/fs.rs
src/libstd/old_io/mem.rs
src/libstd/old_io/mod.rs
src/libstd/old_io/net/ip.rs
src/libstd/old_io/process.rs
src/libstd/old_io/result.rs
src/libstd/old_io/util.rs
src/libstd/old_path/posix.rs
src/libstd/old_path/windows.rs
src/libstd/os.rs
src/libstd/rand/mod.rs
src/libstd/rt/args.rs
src/libstd/sync/future.rs
src/libstd/sync/mpsc/spsc_queue.rs
src/libstd/sync/task_pool.rs
src/libstd/sys/common/helper_thread.rs
src/libstd/sys/common/net.rs
src/libstd/sys/common/thread_info.rs
src/libstd/sys/common/wtf8.rs
src/libstd/sys/unix/os_str.rs
src/libstd/sys/unix/pipe.rs
src/libstd/sys/unix/process.rs
src/libstd/sys/windows/process.rs
src/libstd/sys/windows/tty.rs
src/libstd/thread.rs
src/libstd/thunk.rs
src/libsyntax/ast_map/blocks.rs
src/libsyntax/attr.rs
src/libsyntax/codemap.rs
src/libsyntax/config.rs
src/libsyntax/diagnostics/macros.rs
src/libsyntax/ext/cfg.rs
src/libsyntax/ext/cfg_attr.rs
src/libsyntax/ext/deriving/bounds.rs
src/libsyntax/ext/deriving/clone.rs
src/libsyntax/ext/deriving/default.rs
src/libsyntax/ext/deriving/generic/mod.rs
src/libsyntax/ext/deriving/generic/ty.rs
src/libsyntax/ext/deriving/hash.rs
src/libsyntax/ext/deriving/rand.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/format.rs
src/libsyntax/ext/quote.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/feature_gate.rs
src/libsyntax/fold.rs
src/libsyntax/owned_slice.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/test.rs
src/libsyntax/util/small_vector.rs
src/libsyntax/visit.rs
src/libterm/terminfo/mod.rs
src/libterm/terminfo/parm.rs
src/libtest/lib.rs
src/libtest/stats.rs
src/libunicode/u_str.rs
src/rt/rust_builtin.c
src/snapshots.txt
src/test/auxiliary/issue-18711.rs
src/test/auxiliary/logging_right_crate.rs
src/test/auxiliary/plugin_args.rs
src/test/auxiliary/roman_numerals.rs
src/test/auxiliary/static-methods-crate.rs
src/test/auxiliary/unboxed-closures-cross-crate.rs
src/test/bench/core-map.rs
src/test/bench/core-set.rs
src/test/bench/core-std.rs
src/test/bench/msgsend-pipes-shared.rs
src/test/bench/msgsend-pipes.rs
src/test/bench/rt-messaging-ping-pong.rs
src/test/bench/rt-parfib.rs
src/test/bench/shootout-binarytrees.rs
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-fannkuch-redux.rs
src/test/bench/shootout-fasta-redux.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide.rs
src/test/bench/shootout-mandelbrot.rs
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-pfib.rs
src/test/bench/shootout-reverse-complement.rs
src/test/bench/shootout-spectralnorm.rs
src/test/bench/sudoku.rs
src/test/compile-fail/assign-to-method.rs
src/test/compile-fail/blind-item-local-shadow.rs
src/test/compile-fail/borrowck-assign-comp-idx.rs
src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs
src/test/compile-fail/borrowck-closures-mut-and-imm.rs
src/test/compile-fail/borrowck-closures-mut-of-imm.rs
src/test/compile-fail/borrowck-closures-two-mut.rs
src/test/compile-fail/borrowck-closures-unique-imm.rs
src/test/compile-fail/borrowck-closures-unique.rs
src/test/compile-fail/borrowck-closures-use-after-free.rs
src/test/compile-fail/borrowck-init-in-called-fn-expr.rs
src/test/compile-fail/borrowck-init-in-fn-expr.rs
src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
src/test/compile-fail/borrowck-mut-slice-of-imm-vec.rs
src/test/compile-fail/borrowck-overloaded-index-autoderef.rs
src/test/compile-fail/borrowck-overloaded-index.rs
src/test/compile-fail/borrowck-report-with-custom-diagnostic.rs
src/test/compile-fail/borrowck-vec-pattern-element-loan.rs
src/test/compile-fail/borrowck-vec-pattern-loan-from-mut.rs
src/test/compile-fail/borrowck-vec-pattern-nesting.rs
src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs
src/test/compile-fail/cannot-mutate-captured-non-mut-var.rs
src/test/compile-fail/closure-reform-bad.rs
src/test/compile-fail/dead-code-closure-bang.rs
src/test/compile-fail/estr-subtyping.rs
src/test/compile-fail/fn-trait-formatting.rs
src/test/compile-fail/immut-function-arguments.rs
src/test/compile-fail/integral-indexing.rs
src/test/compile-fail/issue-10398.rs
src/test/compile-fail/issue-11192.rs
src/test/compile-fail/issue-11374.rs
src/test/compile-fail/issue-11873.rs
src/test/compile-fail/issue-12369.rs
src/test/compile-fail/issue-15783.rs
src/test/compile-fail/issue-16939.rs
src/test/compile-fail/issue-17551.rs
src/test/compile-fail/issue-17651.rs
src/test/compile-fail/issue-17728.rs
src/test/compile-fail/issue-2149.rs
src/test/compile-fail/issue-3044.rs
src/test/compile-fail/issue-3563.rs
src/test/compile-fail/issue-4335.rs
src/test/compile-fail/issue-5239-1.rs
src/test/compile-fail/issue-6801.rs
src/test/compile-fail/issue-7573.rs
src/test/compile-fail/lint-unused-mut-variables.rs
src/test/compile-fail/lub-if.rs
src/test/compile-fail/lub-match.rs
src/test/compile-fail/match-vec-unreachable.rs
src/test/compile-fail/moves-based-on-type-exprs.rs
src/test/compile-fail/non-exhaustive-match.rs
src/test/compile-fail/packed-struct-generic-transmute.rs
src/test/compile-fail/refutable-pattern-in-fn-arg.rs
src/test/compile-fail/region-bound-on-closure-outlives-call.rs
src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs
src/test/compile-fail/regions-addr-of-upvar-self.rs
src/test/compile-fail/regions-escape-unboxed-closure.rs
src/test/compile-fail/regions-glb-free-free.rs
src/test/compile-fail/regions-pattern-typing-issue-19552.rs
src/test/compile-fail/regions-return-ref-to-upvar-issue-17403.rs
src/test/compile-fail/slice-1.rs
src/test/compile-fail/slice-2.rs
src/test/compile-fail/trait-coercion-generic-regions.rs
src/test/compile-fail/unboxed-closure-immutable-capture.rs
src/test/compile-fail/unboxed-closure-region.rs
src/test/compile-fail/unboxed-closures-borrow-conflict.rs
src/test/compile-fail/unboxed-closures-infer-argument-types-two-region-pointers.rs
src/test/compile-fail/unboxed-closures-type-mismatch.rs
src/test/compile-fail/unused-mut-warning-captured-var.rs
src/test/debuginfo/closure-in-generic-function.rs
src/test/debuginfo/lexical-scope-in-parameterless-closure.rs
src/test/debuginfo/lexical-scope-in-stack-closure.rs
src/test/debuginfo/lexical-scope-in-unique-closure.rs
src/test/debuginfo/multi-byte-chars.rs
src/test/debuginfo/type-names.rs
src/test/debuginfo/var-captured-in-nested-closure.rs
src/test/debuginfo/var-captured-in-sendable-closure.rs
src/test/debuginfo/var-captured-in-stack-closure.rs
src/test/run-fail/bug-2470-bounds-check-overflow-3.rs
src/test/run-make/c-dynamic-dylib/cfoo.c
src/test/run-make/c-dynamic-rlib/cfoo.c
src/test/run-make/c-link-to-rust-dylib/bar.c
src/test/run-make/c-link-to-rust-staticlib/bar.c
src/test/run-make/c-static-dylib/cfoo.c
src/test/run-make/c-static-rlib/cfoo.c
src/test/run-make/cannot-read-embedded-idents/create_and_compile.rs
src/test/run-make/extern-fn-generic/test.c
src/test/run-make/extern-fn-mangle/test.c
src/test/run-make/extern-fn-with-packed-struct/test.c
src/test/run-make/extern-fn-with-union/test.c
src/test/run-make/interdependent-c-libraries/bar.c
src/test/run-make/interdependent-c-libraries/foo.c
src/test/run-make/issue-12446/foo.c
src/test/run-make/issue-15460/foo.c
src/test/run-make/issue-19371/foo.rs
src/test/run-make/link-path-order/correct.c
src/test/run-make/link-path-order/wrong.c
src/test/run-make/linkage-attr-on-static/foo.c
src/test/run-make/lto-smoke-c/bar.c
src/test/run-make/manual-link/bar.c
src/test/run-make/manual-link/foo.c
src/test/run-make/no-duplicate-libs/bar.c
src/test/run-make/no-duplicate-libs/foo.c
src/test/run-make/save-analysis/foo.rs
src/test/run-make/unicode-input/multiple_files.rs
src/test/run-make/unicode-input/span_length.rs
src/test/run-pass/assignability-trait.rs
src/test/run-pass/associated-types-conditional-dispatch.rs
src/test/run-pass/auto-encode.rs
src/test/run-pass/backtrace.rs
src/test/run-pass/bare-fn-implements-fn-mut.rs
src/test/run-pass/block-fn-coerce.rs
src/test/run-pass/bool.rs
src/test/run-pass/borrowck-binding-mutbl.rs
src/test/run-pass/borrowck-closures-two-imm.rs
src/test/run-pass/borrowck-move-by-capture-ok.rs
src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs
src/test/run-pass/borrowed-ptr-pattern-2.rs
src/test/run-pass/capture-clauses-unboxed-closures.rs
src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs
src/test/run-pass/cleanup-shortcircuit.rs
src/test/run-pass/closure-inference2.rs
src/test/run-pass/coerce-overloaded-autoderef.rs
src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs
src/test/run-pass/coerce-reborrow-mut-vec-arg.rs
src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs
src/test/run-pass/deriving-encodable-decodable-box.rs
src/test/run-pass/deriving-encodable-decodable-cell-refcell.rs
src/test/run-pass/deriving-encodable-decodable.rs
src/test/run-pass/empty-tag.rs
src/test/run-pass/fn-pattern-expected-type.rs
src/test/run-pass/fn-type-infer.rs
src/test/run-pass/foreach-external-iterators-break.rs
src/test/run-pass/foreach-external-iterators-nested.rs
src/test/run-pass/foreach-external-iterators.rs
src/test/run-pass/getopts_ref.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/hrtb-precedence-of-plus.rs
src/test/run-pass/hrtb-unboxed-closure-trait.rs
src/test/run-pass/if-let.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/inconsistent-lifetime-mismatch.rs
src/test/run-pass/issue-10626.rs
src/test/run-pass/issue-10683.rs
src/test/run-pass/issue-10718.rs
src/test/run-pass/issue-11869.rs
src/test/run-pass/issue-13027.rs
src/test/run-pass/issue-13304.rs
src/test/run-pass/issue-13323.rs
src/test/run-pass/issue-13434.rs
src/test/run-pass/issue-14021.rs
src/test/run-pass/issue-14456.rs
src/test/run-pass/issue-1460.rs
src/test/run-pass/issue-14919.rs
src/test/run-pass/issue-14936.rs
src/test/run-pass/issue-14940.rs
src/test/run-pass/issue-15149.rs
src/test/run-pass/issue-15571.rs
src/test/run-pass/issue-16256.rs
src/test/run-pass/issue-16560.rs
src/test/run-pass/issue-16668.rs
src/test/run-pass/issue-16774.rs
src/test/run-pass/issue-16783.rs
src/test/run-pass/issue-17734.rs
src/test/run-pass/issue-17816.rs
src/test/run-pass/issue-17897.rs
src/test/run-pass/issue-18188.rs
src/test/run-pass/issue-18352.rs
src/test/run-pass/issue-18652.rs
src/test/run-pass/issue-18661.rs
src/test/run-pass/issue-18685.rs
src/test/run-pass/issue-18711.rs
src/test/run-pass/issue-19135.rs
src/test/run-pass/issue-2074.rs
src/test/run-pass/issue-21306.rs
src/test/run-pass/issue-21891.rs [new file with mode: 0644]
src/test/run-pass/issue-3052.rs
src/test/run-pass/issue-3429.rs
src/test/run-pass/issue-3559.rs
src/test/run-pass/issue-3563-3.rs
src/test/run-pass/issue-4541.rs
src/test/run-pass/issue-5239-2.rs
src/test/run-pass/issue-5550.rs
src/test/run-pass/issue-6157.rs
src/test/run-pass/issue-868.rs
src/test/run-pass/issue-8898.rs
src/test/run-pass/issue-9129.rs
src/test/run-pass/issue-9259.rs
src/test/run-pass/issue-9382.rs
src/test/run-pass/istr.rs
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/last-use-in-cap-clause.rs
src/test/run-pass/logging-separate-lines.rs
src/test/run-pass/match-str.rs
src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs
src/test/run-pass/move-out-of-field.rs
src/test/run-pass/mut-function-arguments.rs
src/test/run-pass/mut-in-ident-patterns.rs
src/test/run-pass/new-unicode-escapes.rs
src/test/run-pass/order-drop-with-match.rs
src/test/run-pass/out-of-stack-new-thread-no-split.rs
src/test/run-pass/out-of-stack-no-split.rs
src/test/run-pass/out-of-stack.rs
src/test/run-pass/overloaded-autoderef.rs
src/test/run-pass/overloaded-deref-count.rs
src/test/run-pass/overloaded-deref.rs
src/test/run-pass/pattern-in-closure.rs
src/test/run-pass/process-remove-from-env.rs
src/test/run-pass/process-spawn-with-unicode-params.rs
src/test/run-pass/range.rs
src/test/run-pass/ranges-precedence.rs
src/test/run-pass/rcvr-borrowed-to-slice.rs
src/test/run-pass/realloc-16687.rs
src/test/run-pass/regions-borrow-evec-uniq.rs
src/test/run-pass/regions-copy-closure.rs
src/test/run-pass/regions-dependent-autoslice.rs
src/test/run-pass/regions-infer-borrow-scope-view.rs
src/test/run-pass/regions-lifetime-nonfree-late-bound.rs
src/test/run-pass/regions-mock-tcx.rs
src/test/run-pass/regions-static-closure.rs
src/test/run-pass/repeated-vector-syntax.rs
src/test/run-pass/return-from-closure.rs
src/test/run-pass/running-with-no-runtime.rs
src/test/run-pass/rust-log-filter.rs
src/test/run-pass/segfault-no-out-of-stack.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/signal-exit-status.rs
src/test/run-pass/sigpipe-should-be-ignored.rs
src/test/run-pass/slice-2.rs
src/test/run-pass/slice.rs
src/test/run-pass/small-enums-with-fields.rs
src/test/run-pass/swap-2.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/trait-bounds-in-arc.rs
src/test/run-pass/type-id-higher-rank.rs
src/test/run-pass/typeck_type_placeholder_1.rs
src/test/run-pass/unboxed-closures-all-traits.rs
src/test/run-pass/unboxed-closures-boxed.rs
src/test/run-pass/unboxed-closures-by-ref.rs
src/test/run-pass/unboxed-closures-direct-sugary-call.rs
src/test/run-pass/unboxed-closures-drop.rs
src/test/run-pass/unboxed-closures-generic.rs
src/test/run-pass/unboxed-closures-infer-argument-types-from-expected-bound.rs
src/test/run-pass/unboxed-closures-infer-argument-types-from-expected-object-type.rs
src/test/run-pass/unboxed-closures-infer-argument-types-with-bound-regions-from-expected-bound.rs
src/test/run-pass/unboxed-closures-monomorphization.rs
src/test/run-pass/unboxed-closures-move-mutable.rs
src/test/run-pass/unboxed-closures-prelude.rs
src/test/run-pass/unboxed-closures-simple.rs
src/test/run-pass/unboxed-closures-single-word-env.rs
src/test/run-pass/unboxed-closures-static-call-fn-once.rs
src/test/run-pass/unboxed-closures-unique-type-id.rs
src/test/run-pass/unit-like-struct-drop-run.rs
src/test/run-pass/unused-move-capture.rs
src/test/run-pass/vec-concat.rs
src/test/run-pass/vector-sort-panic-safe.rs
src/test/run-pass/wait-forked-but-failed-child.rs
src/test/run-pass/weird-exprs.rs
src/test/run-pass/where-clauses-unboxed-closures.rs

index 63c5742a540d404c0502a38326fceb06e47da22a..a760155bbd91aeeee3a961599f7a7cf86c4b331a 100644 (file)
@@ -59,6 +59,9 @@
 #   * check-stage$(stage)-$(crate) - Test a crate in a specific stage
 #   * check-stage$(stage)-{rpass,rfail,cfail,rmake,...} - Run tests in src/test/
 #   * check-stage1-T-$(target)-H-$(host) - Run cross-compiled-tests
+#   * tidy-basic - show file / line stats
+#   * tidy-errors - show the highest rustc error code
+#   * tidy-features - show the status of language and lib features
 #
 # Then mix in some of these environment variables to harness the
 # ultimate power of The Rust Build System.
index 0e52f168f59ed2072cb87c2eddfee295cb821685..a6b201a2b7bdfc7bd1a7c259bc7068ae6053fe90 100644 (file)
@@ -72,6 +72,7 @@ endif
 # numbers and dots here
 CFG_VERSION_WIN = $(CFG_RELEASE_NUM)
 
+CFG_INFO := $(info cfg: version $(CFG_VERSION))
 
 ######################################################################
 # More configuration
@@ -179,6 +180,7 @@ endif
 
 ifndef CFG_DISABLE_VALGRIND_RPASS
   $(info cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS))
+  $(info cfg: valgrind-rpass command set to $(CFG_VALGRIND))
   CFG_VALGRIND_RPASS :=$(CFG_VALGRIND)
 else
   CFG_VALGRIND_RPASS :=
index e28f56fffe41b3d547f7c82ed3f1b86ef2b18725..8728d816034894fd92ebee4a18e5a87714248fb4 100644 (file)
@@ -162,7 +162,8 @@ $(foreach file,$(wildcard $(S)src/doc/trpl/*.md), \
 ######################################################################
 
 # The main testing target. Tests lots of stuff.
-check: cleantmptestlogs cleantestlibs check-notidy tidy
+check: cleantmptestlogs cleantestlibs all check-stage2 tidy
+       $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
 
 # As above but don't bother running tidy.
 check-notidy: cleantmptestlogs cleantestlibs all check-stage2
@@ -235,57 +236,24 @@ cleantestlibs:
 ######################################################################
 
 ifdef CFG_NOTIDY
+.PHONY: tidy
 tidy:
 else
 
-ALL_CS := $(wildcard $(S)src/rt/*.cpp \
-                     $(S)src/rt/*/*.cpp \
-                     $(S)src/rt/*/*/*.cpp \
-                     $(S)src/rustllvm/*.cpp)
-ALL_CS := $(filter-out $(S)src/rt/miniz.cpp \
-                      $(wildcard $(S)src/rt/hoedown/src/*.c) \
-                      $(wildcard $(S)src/rt/hoedown/bin/*.c) \
-       ,$(ALL_CS))
-ALL_HS := $(wildcard $(S)src/rt/*.h \
-                     $(S)src/rt/*/*.h \
-                     $(S)src/rt/*/*/*.h \
-                     $(S)src/rustllvm/*.h)
-ALL_HS := $(filter-out $(S)src/rt/valgrind/valgrind.h \
-                       $(S)src/rt/valgrind/memcheck.h \
-                       $(S)src/rt/msvc/typeof.h \
-                       $(S)src/rt/msvc/stdint.h \
-                       $(S)src/rt/msvc/inttypes.h \
-                      $(wildcard $(S)src/rt/hoedown/src/*.h) \
-                      $(wildcard $(S)src/rt/hoedown/bin/*.h) \
-       ,$(ALL_HS))
-
 # Run the tidy script in multiple parts to avoid huge 'echo' commands
-tidy:
+.PHONY: tidy
+tidy: tidy-basic tidy-binaries tidy-errors tidy-features
+
+endif
+
+.PHONY: tidy-basic
+tidy-basic:
                @$(call E, check: formatting)
-               $(Q)find $(S)src -name '*.r[sc]' \
-                   -and -not -regex '^$(S)src/jemalloc.*' \
-                   -and -not -regex '^$(S)src/libuv.*' \
-                   -and -not -regex '^$(S)src/llvm.*' \
-                   -and -not -regex '^$(S)src/gyp.*' \
-                   -and -not -regex '^$(S)src/libbacktrace.*' \
-                   -print0 \
-               | xargs -0 -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)find $(S)src/etc -name '*.py' \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)find $(S)src/doc -name '*.js' \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)find $(S)src/etc -name '*.sh' \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)find $(S)src/etc -name '*.pl' \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)find $(S)src/etc -name '*.c' \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)find $(S)src/etc -name '*.h' \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)echo $(ALL_CS) \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
-               $(Q)echo $(ALL_HS) \
-               | xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
+               $(Q) $(CFG_PYTHON) $(S)src/etc/tidy.py $(S)src/
+
+.PHONY: tidy-binaries
+tidy-binaries:
+               @$(call E, check: binaries)
                $(Q)find $(S)src -type f -perm +a+x \
                    -not -name '*.rs' -and -not -name '*.py' \
                    -and -not -name '*.sh' \
@@ -300,11 +268,16 @@ tidy:
                | grep '^$(S)src/libbacktrace' -v \
                | grep '^$(S)src/rust-installer' -v \
                | xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
-               $(Q) $(CFG_PYTHON) $(S)src/etc/errorck.py $(S)src/
-               $(Q) $(CFG_PYTHON) $(S)src/etc/featureck.py $(S)src/
 
+.PHONY: tidy-errors
+tidy-errors:
+               @$(call E, check: extended errors)
+               $(Q) $(CFG_PYTHON) $(S)src/etc/errorck.py $(S)src/
 
-endif
+.PHONY: tidy-features
+tidy-features:
+               @$(call E, check: feature sanity)
+               $(Q) $(CFG_PYTHON) $(S)src/etc/featureck.py $(S)src/
 
 
 ######################################################################
@@ -639,7 +612,6 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
 
 ifdef CFG_VALGRIND_RPASS
 ifdef GOOD_VALGRIND_$(2)
-$(info cfg: valgrind-path set to $(CFG_VALGRIND_RPASS))
 CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) += --valgrind-path "$(CFG_VALGRIND_RPASS)"
 endif
 endif
index 07e92c704d86f9fb854660d24378c27026fac86f..e6d2a691cf5630467f1edf4aef3b12b756be7eb2 100644 (file)
@@ -97,28 +97,31 @@ pub fn parse_config(args: Vec<String> ) -> Config {
     assert!(!args.is_empty());
     let argv0 = args[0].clone();
     let args_ = args.tail();
-    if args[1].as_slice() == "-h" || args[1].as_slice() == "--help" {
+    if args[1] == "-h" || args[1] == "--help" {
         let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
-        println!("{}", getopts::usage(message.as_slice(), groups.as_slice()));
+        println!("{}", getopts::usage(&message, &groups));
         println!("");
         panic!()
     }
 
     let matches =
-        &match getopts::getopts(args_.as_slice(), groups.as_slice()) {
+        &match getopts::getopts(args_, &groups) {
           Ok(m) => m,
           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!("{}", getopts::usage(&message, &groups));
         println!("");
         panic!()
     }
 
     fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
-        Path::new(m.opt_str(nm).unwrap())
+        match m.opt_str(nm) {
+            Some(s) => Path::new(s),
+            None => panic!("no option (=path) found for {}", nm),
+        }
     }
 
     let filter = if !matches.free.is_empty() {
@@ -156,9 +159,9 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
         adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
         adb_device_status:
             "arm-linux-androideabi" ==
-                opt_str2(matches.opt_str("target")).as_slice() &&
+                opt_str2(matches.opt_str("target")) &&
             "(none)" !=
-                opt_str2(matches.opt_str("adb-test-dir")).as_slice() &&
+                opt_str2(matches.opt_str("adb-test-dir")) &&
             !opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
         lldb_python_dir: matches.opt_str("lldb-python-dir"),
         verbose: matches.opt_present("verbose"),
@@ -201,7 +204,7 @@ pub fn log_config(config: &Config) {
 pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {
     match *maybestr {
         None => "(none)",
-        Some(ref s) => s.as_slice(),
+        Some(ref s) => s,
     }
 }
 
@@ -213,7 +216,7 @@ pub fn opt_str2(maybestr: Option<String>) -> String {
 }
 
 pub fn run_tests(config: &Config) {
-    if config.target.as_slice() == "arm-linux-androideabi" {
+    if config.target == "arm-linux-androideabi" {
         match config.mode {
             DebugInfoGdb => {
                 println!("arm-linux-androideabi debug-info \
@@ -306,13 +309,13 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
     let mut valid = false;
 
     for ext in &valid_extensions {
-        if name.ends_with(ext.as_slice()) {
+        if name.ends_with(ext) {
             valid = true;
         }
     }
 
     for pre in &invalid_prefixes {
-        if name.starts_with(pre.as_slice()) {
+        if name.starts_with(pre) {
             valid = false;
         }
     }
@@ -359,7 +362,7 @@ pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::Test
     let config = (*config).clone();
     // FIXME (#9639): This needs to handle non-utf8 paths
     let testfile = testfile.as_str().unwrap().to_string();
-    test::DynMetricFn(box move |mm: &mut test::MetricMap| {
+    test::DynMetricFn(box move |mm: &mut test::MetricMap| {
         runtest::run_metrics(config, testfile, mm)
     })
 }
index 40d4397916d3f2d38f53142ec778ff895ce6e704..d8faa53a2de647bc8c82262505ec266572e00daa 100644 (file)
@@ -44,7 +44,7 @@ pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
     rdr.lines().enumerate().filter_map(|(line_no, ln)| {
         parse_expected(last_nonfollow_error,
                        line_no + 1,
-                       ln.unwrap().as_slice())
+                       &ln.unwrap())
             .map(|(which, error)| {
                 match which {
                     FollowPrevious(_) => {}
index 005ec013b8e6dd5acc3c638b2478a3944305ee39..c2539679643221332b31a32c6caba396dc6f3aee 100644 (file)
@@ -145,7 +145,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
 
 pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
     fn ignore_target(config: &Config) -> String {
-        format!("ignore-{}", util::get_os(config.target.as_slice()))
+        format!("ignore-{}", util::get_os(&config.target))
     }
     fn ignore_stage(config: &Config) -> String {
         format!("ignore-{}",
@@ -169,8 +169,8 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
                                           .expect("Malformed GDB version directive");
                     // Ignore if actual version is smaller the minimum required
                     // version
-                    gdb_version_to_int(actual_version.as_slice()) <
-                        gdb_version_to_int(min_version.as_slice())
+                    gdb_version_to_int(actual_version) <
+                        gdb_version_to_int(min_version)
                 } else {
                     false
                 }
@@ -197,8 +197,8 @@ fn ignore_lldb(config: &Config, line: &str) -> bool {
                                           .expect("Malformed lldb version directive");
                     // Ignore if actual version is smaller the minimum required
                     // version
-                    lldb_version_to_int(actual_version.as_slice()) <
-                        lldb_version_to_int(min_version.as_slice())
+                    lldb_version_to_int(actual_version) <
+                        lldb_version_to_int(min_version)
                 } else {
                     false
                 }
@@ -209,8 +209,8 @@ fn ignore_lldb(config: &Config, line: &str) -> bool {
 
     let val = iter_header(testfile, |ln| {
         !parse_name_directive(ln, "ignore-test") &&
-        !parse_name_directive(ln, ignore_target(config).as_slice()) &&
-        !parse_name_directive(ln, ignore_stage(config).as_slice()) &&
+        !parse_name_directive(ln, &ignore_target(config)) &&
+        !parse_name_directive(ln, &ignore_stage(config)) &&
         !(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
         !(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
         !ignore_gdb(config, ln) &&
@@ -294,7 +294,7 @@ fn parse_pretty_compare_only(line: &str) -> bool {
 fn parse_exec_env(line: &str) -> Option<(String, String)> {
     parse_name_value_directive(line, "exec-env").map(|nv| {
         // nv is either FOO or FOO=BAR
-        let mut strs: Vec<String> = nv.as_slice()
+        let mut strs: Vec<String> = nv
                                       .splitn(1, '=')
                                       .map(|s| s.to_string())
                                       .collect();
@@ -330,7 +330,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
 pub fn parse_name_value_directive(line: &str, directive: &str)
                                   -> Option<String> {
     let keycolon = format!("{}:", directive);
-    match line.find_str(keycolon.as_slice()) {
+    match line.find_str(&keycolon) {
         Some(colon) => {
             let value = line[(colon + keycolon.len()) .. line.len()].to_string();
             debug!("{}: {}", directive, value);
@@ -344,7 +344,7 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
     let error_string = format!(
         "Encountered GDB version string with unexpected format: {}",
         version_string);
-    let error_string = error_string.as_slice();
+    let error_string = error_string;
 
     let components: Vec<&str> = version_string.trim().split('.').collect();
 
@@ -352,8 +352,8 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
         panic!("{}", error_string);
     }
 
-    let major: int = components[0].parse().ok().expect(error_string);
-    let minor: int = components[1].parse().ok().expect(error_string);
+    let major: int = components[0].parse().ok().expect(&error_string);
+    let minor: int = components[1].parse().ok().expect(&error_string);
 
     return major * 1000 + minor;
 }
@@ -362,7 +362,7 @@ pub fn lldb_version_to_int(version_string: &str) -> int {
     let error_string = format!(
         "Encountered LLDB version string with unexpected format: {}",
         version_string);
-    let error_string = error_string.as_slice();
-    let major: int = version_string.parse().ok().expect(error_string);
+    let error_string = error_string;
+    let major: int = version_string.parse().ok().expect(&error_string);
     return major;
 }
index 4b0eea33d69b7a2176cd0c0c86d1480f43409c48..148a43e6c783196555b044efb3e4ec8e1791d4d6 100644 (file)
@@ -23,7 +23,7 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
 
     // Add the new dylib search path var
     let var = DynamicLibrary::envvar();
-    let newpath = DynamicLibrary::create_path(path.as_slice());
+    let newpath = DynamicLibrary::create_path(&path);
     let newpath = String::from_utf8(newpath).unwrap();
     cmd.env(var.to_string(), newpath);
 }
index a8e644dba99d18a8552d1d359f272f5a96d54840..5a372fd7cdcb261f83898f29e0ace7a8a63738ab 100644 (file)
@@ -40,7 +40,7 @@
 use test::MetricMap;
 
 pub fn run(config: Config, testfile: String) {
-    match config.target.as_slice() {
+    match &*config.target {
 
         "arm-linux-androideabi" => {
             if !config.adb_device_status {
@@ -106,10 +106,10 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
         }
         check_expected_errors(expected_errors, testfile, &proc_res);
     } else {
-        check_error_patterns(props, testfile, output_to_check.as_slice(), &proc_res);
+        check_error_patterns(props, testfile, &output_to_check, &proc_res);
     }
     check_no_compiler_crash(&proc_res);
-    check_forbid_output(props, output_to_check.as_slice(), &proc_res);
+    check_forbid_output(props, &output_to_check, &proc_res);
 }
 
 fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
@@ -133,7 +133,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
 
     let output_to_check = get_output(props, &proc_res);
     check_correct_failure_status(&proc_res);
-    check_error_patterns(props, testfile, output_to_check.as_slice(), &proc_res);
+    check_error_patterns(props, testfile, &output_to_check, &proc_res);
 }
 
 fn check_correct_failure_status(proc_res: &ProcRes) {
@@ -141,8 +141,8 @@ fn check_correct_failure_status(proc_res: &ProcRes) {
     static RUST_ERR: int = 101;
     if !proc_res.status.matches_exit_status(RUST_ERR) {
         fatal_proc_rec(
-            format!("failure produced the wrong error: {:?}",
-                    proc_res.status).as_slice(),
+            &format!("failure produced the wrong error: {:?}",
+                     proc_res.status),
             proc_res);
     }
 }
@@ -211,11 +211,10 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
                                     props,
                                     testfile,
                                     srcs[round].to_string(),
-                                    props.pretty_mode.as_slice());
+                                    &props.pretty_mode);
 
         if !proc_res.status.success() {
-            fatal_proc_rec(format!("pretty-printing failed in round {}",
-                                   round).as_slice(),
+            fatal_proc_rec(&format!("pretty-printing failed in round {}", round),
                           &proc_res);
         }
 
@@ -237,11 +236,11 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
     if props.pp_exact.is_some() {
         // Now we have to care about line endings
         let cr = "\r".to_string();
-        actual = actual.replace(cr.as_slice(), "").to_string();
-        expected = expected.replace(cr.as_slice(), "").to_string();
+        actual = actual.replace(&cr, "").to_string();
+        expected = expected.replace(&cr, "").to_string();
     }
 
-    compare_source(expected.as_slice(), actual.as_slice());
+    compare_source(&expected, &actual);
 
     // If we're only making sure that the output matches then just stop here
     if props.pretty_compare_only { return; }
@@ -282,7 +281,7 @@ fn print_source(config: &Config,
                                      testfile,
                                      pretty_type.to_string()),
                         props.exec_env.clone(),
-                        config.compile_lib_path.as_slice(),
+                        &config.compile_lib_path,
                         Some(aux_dir.as_str().unwrap()),
                         Some(src))
     }
@@ -335,9 +334,9 @@ fn typecheck_source(config: &Config, props: &TestProps,
     fn make_typecheck_args(config: &Config, props: &TestProps, testfile: &Path) -> ProcArgs {
         let aux_dir = aux_output_dir_name(config, testfile);
         let target = if props.force_host {
-            config.host.as_slice()
+            &*config.host
         } else {
-            config.target.as_slice()
+            &*config.target
         };
         // FIXME (#9639): This needs to handle non-utf8 paths
         let mut args = vec!("-".to_string(),
@@ -382,7 +381,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
     let exe_file = make_exe_name(config, testfile);
 
     let debugger_run_result;
-    match config.target.as_slice() {
+    match &*config.target {
         "arm-linux-androideabi" => {
 
             cmds = cmds.replace("run", "continue").to_string();
@@ -397,12 +396,12 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
             debug!("script_str = {}", script_str);
             dump_output_file(config,
                              testfile,
-                             script_str.as_slice(),
+                             &script_str,
                              "debugger.script");
 
 
             procsrv::run("",
-                         config.adb_path.as_slice(),
+                         &config.adb_path,
                          None,
                          &[
                             "push".to_string(),
@@ -411,10 +410,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                          ],
                          vec!(("".to_string(), "".to_string())),
                          Some("".to_string()))
-                .expect(format!("failed to exec `{:?}`", config.adb_path).as_slice());
+                .expect(&format!("failed to exec `{:?}`", config.adb_path));
 
             procsrv::run("",
-                         config.adb_path.as_slice(),
+                         &config.adb_path,
                          None,
                          &[
                             "forward".to_string(),
@@ -423,7 +422,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                          ],
                          vec!(("".to_string(), "".to_string())),
                          Some("".to_string()))
-                .expect(format!("failed to exec `{:?}`", config.adb_path).as_slice());
+                .expect(&format!("failed to exec `{:?}`", config.adb_path));
 
             let adb_arg = format!("export LD_LIBRARY_PATH={}; \
                                    gdbserver :5039 {}/{}",
@@ -434,8 +433,8 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                                       .unwrap()).unwrap());
 
             let mut process = procsrv::run_background("",
-                                                      config.adb_path
-                                                            .as_slice(),
+                                                      &config.adb_path
+                                                            ,
                                                       None,
                                                       &[
                                                         "shell".to_string(),
@@ -444,7 +443,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                                                       vec!(("".to_string(),
                                                             "".to_string())),
                                                       Some("".to_string()))
-                .expect(format!("failed to exec `{:?}`", config.adb_path).as_slice());
+                .expect(&format!("failed to exec `{:?}`", config.adb_path));
             loop {
                 //waiting 1 second for gdbserver start
                 timer::sleep(Duration::milliseconds(1000));
@@ -477,16 +476,16 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                 err,
                 status
             } = procsrv::run("",
-                             gdb_path.as_slice(),
+                             &gdb_path,
                              None,
-                             debugger_opts.as_slice(),
+                             &debugger_opts,
                              vec!(("".to_string(), "".to_string())),
                              None)
-                .expect(format!("failed to exec `{:?}`", gdb_path).as_slice());
+                .expect(&format!("failed to exec `{:?}`", gdb_path));
             let cmdline = {
                 let cmdline = make_cmdline("",
                                            "arm-linux-androideabi-gdb",
-                                           debugger_opts.as_slice());
+                                           &debugger_opts);
                 logv(config, format!("executing {}", cmdline));
                 cmdline
             };
@@ -517,16 +516,16 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
             match config.gdb_version {
                 Some(ref version) => {
                     println!("NOTE: compiletest thinks it is using GDB version {}",
-                             version.as_slice());
+                             version);
 
-                    if header::gdb_version_to_int(version.as_slice()) >
+                    if header::gdb_version_to_int(version) >
                         header::gdb_version_to_int("7.4") {
                         // Add the directory containing the pretty printers to
                         // GDB's script auto loading safe path
                         script_str.push_str(
-                            format!("add-auto-load-safe-path {}\n",
-                                    rust_pp_module_abs_path.replace("\\", "\\\\").as_slice())
-                                .as_slice());
+                            &format!("add-auto-load-safe-path {}\n",
+                                     rust_pp_module_abs_path.replace("\\", "\\\\"))
+                                );
                     }
                 }
                 _ => {
@@ -553,13 +552,13 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                                              *line)[]);
             }
 
-            script_str.push_str(cmds.as_slice());
+            script_str.push_str(&cmds);
             script_str.push_str("quit\n");
 
             debug!("script_str = {}", script_str);
             dump_output_file(config,
                              testfile,
-                             script_str.as_slice(),
+                             &script_str,
                              "debugger.script");
 
             // run debugger script with gdb
@@ -592,7 +591,7 @@ fn debugger() -> String {
                                                   testfile,
                                                   proc_args,
                                                   environment,
-                                                  config.run_lib_path.as_slice(),
+                                                  &config.run_lib_path,
                                                   None,
                                                   None);
         }
@@ -602,7 +601,7 @@ fn debugger() -> String {
         fatal("gdb failed to execute");
     }
 
-    check_debugger_output(&debugger_run_result, check_lines.as_slice());
+    check_debugger_output(&debugger_run_result, &check_lines);
 }
 
 fn find_rust_src_root(config: &Config) -> Option<Path> {
@@ -644,7 +643,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
     match config.lldb_version {
         Some(ref version) => {
             println!("NOTE: compiletest thinks it is using LLDB version {}",
-                     version.as_slice());
+                     version);
         }
         _ => {
             println!("NOTE: compiletest does not know which version of \
@@ -684,13 +683,12 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
 
     // Set breakpoints on every line that contains the string "#break"
     for line in &breakpoint_lines {
-        script_str.push_str(format!("breakpoint set --line {}\n",
-                                    line).as_slice());
+        script_str.push_str(&format!("breakpoint set --line {}\n", line));
     }
 
     // Append the other commands
     for line in &commands {
-        script_str.push_str(line.as_slice());
+        script_str.push_str(line);
         script_str.push_str("\n");
     }
 
@@ -701,7 +699,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
     debug!("script_str = {}", script_str);
     dump_output_file(config,
                      testfile,
-                     script_str.as_slice(),
+                     &script_str,
                      "debugger.script");
     let debugger_script = make_out_name(config, testfile, "debugger.script");
 
@@ -715,7 +713,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
         fatal_proc_rec("Error while running LLDB", &debugger_run_result);
     }
 
-    check_debugger_output(&debugger_run_result, check_lines.as_slice());
+    check_debugger_output(&debugger_run_result, &check_lines);
 
     fn run_lldb(config: &Config,
                 test_executable: &Path,
@@ -729,7 +727,7 @@ fn run_lldb(config: &Config,
         cmd.arg(lldb_script_path)
            .arg(test_executable)
            .arg(debugger_script)
-           .env_set_all(&[("PYTHONPATH", config.lldb_python_dir.clone().unwrap().as_slice())]);
+           .env_set_all(&[("PYTHONPATH", config.lldb_python_dir.clone().unwrap())]);
 
         let (status, out, err) = match cmd.spawn() {
             Ok(process) => {
@@ -741,12 +739,12 @@ fn run_lldb(config: &Config,
                  String::from_utf8(error).unwrap())
             },
             Err(e) => {
-                fatal(format!("Failed to setup Python process for \
-                               LLDB script: {}", e).as_slice())
+                fatal(&format!("Failed to setup Python process for \
+                                LLDB script: {}", e))
             }
         };
 
-        dump_output(config, test_executable, out.as_slice(), err.as_slice());
+        dump_output(config, test_executable, &out, &err);
         return ProcRes {
             status: status,
             stdout: out,
@@ -782,20 +780,19 @@ fn parse_debugger_commands(file_path: &Path, debugger_prefix: &str)
                 }
 
                 header::parse_name_value_directive(
-                        line.as_slice(),
-                        command_directive.as_slice()).map(|cmd| {
+                        &line,
+                        &command_directive).map(|cmd| {
                     commands.push(cmd)
                 });
 
                 header::parse_name_value_directive(
-                        line.as_slice(),
-                        check_directive.as_slice()).map(|cmd| {
+                        &line,
+                        &check_directive).map(|cmd| {
                     check_lines.push(cmd)
                 });
             }
             Err(e) => {
-                fatal(format!("Error while parsing debugger commands: {}",
-                              e).as_slice())
+                fatal(&format!("Error while parsing debugger commands: {}", e))
             }
         }
         counter += 1;
@@ -834,7 +831,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
         // bits in the wrong case of an enum) with the notation "[...]".
         let check_fragments: Vec<Vec<String>> =
             check_lines.iter().map(|s| {
-                s.as_slice()
+                s
                  .trim()
                  .split_str("[...]")
                  .map(|x| x.to_string())
@@ -849,13 +846,13 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
             let mut failed = false;
             for frag in &check_fragments[i] {
                 let found = if first {
-                    if rest.starts_with(frag.as_slice()) {
+                    if rest.starts_with(frag) {
                         Some(0)
                     } else {
                         None
                     }
                 } else {
-                    rest.find_str(frag.as_slice())
+                    rest.find_str(frag)
                 };
                 match found {
                     None => {
@@ -877,8 +874,8 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
             }
         }
         if i != num_check_lines {
-            fatal_proc_rec(format!("line not found in debugger output: {}",
-                                  check_lines.get(i).unwrap()).as_slice(),
+            fatal_proc_rec(&format!("line not found in debugger output: {}",
+                                    check_lines.get(i).unwrap()),
                           debugger_run_result);
         }
     }
@@ -889,14 +886,13 @@ fn check_error_patterns(props: &TestProps,
                         output_to_check: &str,
                         proc_res: &ProcRes) {
     if props.error_patterns.is_empty() {
-        fatal(format!("no error pattern specified in {:?}",
-                      testfile.display()).as_slice());
+        fatal(&format!("no error pattern specified in {:?}", testfile.display()));
     }
     let mut next_err_idx = 0;
     let mut next_err_pat = &props.error_patterns[next_err_idx];
     let mut done = false;
     for line in output_to_check.lines() {
-        if line.contains(next_err_pat.as_slice()) {
+        if line.contains(next_err_pat) {
             debug!("found error pattern {}", next_err_pat);
             next_err_idx += 1;
             if next_err_idx == props.error_patterns.len() {
@@ -911,13 +907,11 @@ fn check_error_patterns(props: &TestProps,
 
     let missing_patterns = &props.error_patterns[next_err_idx..];
     if missing_patterns.len() == 1 {
-        fatal_proc_rec(format!("error pattern '{}' not found!",
-                              missing_patterns[0]).as_slice(),
+        fatal_proc_rec(&format!("error pattern '{}' not found!", missing_patterns[0]),
                       proc_res);
     } else {
         for pattern in missing_patterns {
-            error(format!("error pattern '{}' not found!",
-                          *pattern).as_slice());
+            error(&format!("error pattern '{}' not found!", *pattern));
         }
         fatal_proc_rec("multiple error patterns not found", proc_res);
     }
@@ -936,7 +930,7 @@ fn check_forbid_output(props: &TestProps,
                        output_to_check: &str,
                        proc_res: &ProcRes) {
     for pat in &props.forbid_output {
-        if output_to_check.contains(pat.as_slice()) {
+        if output_to_check.contains(pat) {
             fatal_proc_rec("forbidden pattern found in compiler output", proc_res);
         }
     }
@@ -959,7 +953,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
 
     #[cfg(windows)]
     fn prefix_matches( line : &str, prefix : &str ) -> bool {
-        line.to_ascii_lowercase().starts_with(prefix.to_ascii_lowercase().as_slice())
+        line.to_ascii_lowercase().starts_with(&prefix.to_ascii_lowercase())
     }
 
     #[cfg(unix)]
@@ -988,13 +982,13 @@ fn continuation( line: &str) -> bool {
         for (i, ee) in expected_errors.iter().enumerate() {
             if !found_flags[i] {
                 debug!("prefix={} ee.kind={} ee.msg={} line={}",
-                       prefixes[i].as_slice(),
+                       prefixes[i],
                        ee.kind,
                        ee.msg,
                        line);
-                if (prefix_matches(line, prefixes[i].as_slice()) || continuation(line)) &&
-                    line.contains(ee.kind.as_slice()) &&
-                    line.contains(ee.msg.as_slice()) {
+                if (prefix_matches(line, &prefixes[i]) || continuation(line)) &&
+                    line.contains(&ee.kind) &&
+                    line.contains(&ee.msg) {
                     found_flags[i] = true;
                     was_expected = true;
                     break;
@@ -1008,8 +1002,8 @@ fn continuation( line: &str) -> bool {
         }
 
         if !was_expected && is_compiler_error_or_warning(line) {
-            fatal_proc_rec(format!("unexpected compiler error or warning: '{}'",
-                                  line).as_slice(),
+            fatal_proc_rec(&format!("unexpected compiler error or warning: '{}'",
+                                    line),
                           proc_res);
         }
     }
@@ -1017,8 +1011,8 @@ fn continuation( line: &str) -> bool {
     for (i, &flag) in found_flags.iter().enumerate() {
         if !flag {
             let ee = &expected_errors[i];
-            fatal_proc_rec(format!("expected {} on line {} not found: {}",
-                                  ee.kind, ee.line, ee.msg).as_slice(),
+            fatal_proc_rec(&format!("expected {} on line {} not found: {}",
+                                    ee.kind, ee.line, ee.msg),
                           proc_res);
         }
     }
@@ -1139,7 +1133,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
 
     let env = props.exec_env.clone();
 
-    match config.target.as_slice() {
+    match &*config.target {
 
         "arm-linux-androideabi" => {
             _arm_exec_compiled_test(config, props, testfile, env)
@@ -1151,7 +1145,7 @@ fn exec_compiled_test(config: &Config, props: &TestProps,
                             testfile,
                             make_run_args(config, props, testfile),
                             env,
-                            config.run_lib_path.as_slice(),
+                            &config.run_lib_path,
                             Some(aux_dir.as_str().unwrap()),
                             None)
         }
@@ -1174,7 +1168,7 @@ fn compose_and_run_compiler(
     let extra_link_args = vec!("-L".to_string(), aux_dir.as_str().unwrap().to_string());
 
     for rel_ab in &props.aux_builds {
-        let abs_ab = config.aux_base.join(rel_ab.as_slice());
+        let abs_ab = config.aux_base.join(rel_ab);
         let aux_props = header::load_props(&abs_ab);
         let mut crate_type = if aux_props.no_prefer_dynamic {
             Vec::new()
@@ -1195,17 +1189,17 @@ fn compose_and_run_compiler(
                                      &abs_ab,
                                      aux_args,
                                      Vec::new(),
-                                     config.compile_lib_path.as_slice(),
+                                     &config.compile_lib_path,
                                      Some(aux_dir.as_str().unwrap()),
                                      None);
         if !auxres.status.success() {
             fatal_proc_rec(
-                format!("auxiliary build of {:?} failed to compile: ",
-                        abs_ab.display()).as_slice(),
+                &format!("auxiliary build of {:?} failed to compile: ",
+                        abs_ab.display()),
                 &auxres);
         }
 
-        match config.target.as_slice() {
+        match &*config.target {
             "arm-linux-androideabi" => {
                 _arm_push_aux_shared_library(config, testfile);
             }
@@ -1217,7 +1211,7 @@ fn compose_and_run_compiler(
                     testfile,
                     args,
                     Vec::new(),
-                    config.compile_lib_path.as_slice(),
+                    &config.compile_lib_path,
                     Some(aux_dir.as_str().unwrap()),
                     input)
 }
@@ -1252,16 +1246,16 @@ fn make_compile_args<F>(config: &Config,
 {
     let xform_file = xform(config, testfile);
     let target = if props.force_host {
-        config.host.as_slice()
+        &*config.host
     } else {
-        config.target.as_slice()
+        &*config.target
     };
     // FIXME (#9639): This needs to handle non-utf8 paths
     let mut args = vec!(testfile.as_str().unwrap().to_string(),
                         "-L".to_string(),
                         config.build_base.as_str().unwrap().to_string(),
                         format!("--target={}", target));
-    args.push_all(extras.as_slice());
+    args.push_all(&extras);
     if !props.no_prefer_dynamic {
         args.push("-C".to_string());
         args.push("prefer-dynamic".to_string());
@@ -1329,7 +1323,7 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path) ->
 fn split_maybe_args(argstr: &Option<String>) -> Vec<String> {
     match *argstr {
         Some(ref s) => {
-            s.as_slice()
+            s
              .split(' ')
              .filter_map(|s| {
                  if s.chars().all(|c| c.is_whitespace()) {
@@ -1350,8 +1344,8 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
     let cmdline =
         {
             let cmdline = make_cmdline(lib_path,
-                                       prog.as_slice(),
-                                       args.as_slice());
+                                       &prog,
+                                       &args);
             logv(config, format!("executing {}", cmdline));
             cmdline
         };
@@ -1360,12 +1354,12 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String
         err,
         status
     } = procsrv::run(lib_path,
-                     prog.as_slice(),
+                     &prog,
                      aux_path,
-                     args.as_slice(),
+                     &args,
                      env,
-                     input).expect(format!("failed to exec `{}`", prog).as_slice());
-    dump_output(config, testfile, out.as_slice(), err.as_slice());
+                     input).expect(&format!("failed to exec `{}`", prog));
+    dump_output(config, testfile, &out, &err);
     return ProcRes {
         status: status,
         stdout: out,
@@ -1422,7 +1416,7 @@ fn output_testname(testfile: &Path) -> Path {
 fn output_base_name(config: &Config, testfile: &Path) -> Path {
     config.build_base
         .join(&output_testname(testfile))
-        .with_extension(config.stage_id.as_slice())
+        .with_extension(&config.stage_id)
 }
 
 fn maybe_dump_to_stdout(config: &Config, out: &str, err: &str) {
@@ -1465,12 +1459,11 @@ fn _arm_exec_compiled_test(config: &Config,
                            -> ProcRes {
     let args = make_run_args(config, props, testfile);
     let cmdline = make_cmdline("",
-                               args.prog.as_slice(),
-                               args.args.as_slice());
+                               &args.prog,
+                               &args.args);
 
     // get bare program string
     let mut tvec: Vec<String> = args.prog
-                                    .as_slice()
                                     .split('/')
                                     .map(|ts| ts.to_string())
                                     .collect();
@@ -1478,7 +1471,7 @@ fn _arm_exec_compiled_test(config: &Config,
 
     // copy to target
     let copy_result = procsrv::run("",
-                                   config.adb_path.as_slice(),
+                                   &config.adb_path,
                                    None,
                                    &[
                                     "push".to_string(),
@@ -1487,7 +1480,7 @@ fn _arm_exec_compiled_test(config: &Config,
                                    ],
                                    vec!(("".to_string(), "".to_string())),
                                    Some("".to_string()))
-        .expect(format!("failed to exec `{}`", config.adb_path).as_slice());
+        .expect(&format!("failed to exec `{}`", config.adb_path));
 
     if config.verbose {
         println!("push ({}) {} {} {}",
@@ -1514,11 +1507,11 @@ fn _arm_exec_compiled_test(config: &Config,
         runargs.push(tv.to_string());
     }
     procsrv::run("",
-                 config.adb_path.as_slice(),
+                 &config.adb_path,
                  None,
-                 runargs.as_slice(),
+                 &runargs,
                  vec!(("".to_string(), "".to_string())), Some("".to_string()))
-        .expect(format!("failed to exec `{}`", config.adb_path).as_slice());
+        .expect(&format!("failed to exec `{}`", config.adb_path));
 
     // get exitcode of result
     runargs = Vec::new();
@@ -1528,12 +1521,12 @@ fn _arm_exec_compiled_test(config: &Config,
 
     let procsrv::Result{ out: exitcode_out, err: _, status: _ } =
         procsrv::run("",
-                     config.adb_path.as_slice(),
+                     &config.adb_path,
                      None,
-                     runargs.as_slice(),
+                     &runargs,
                      vec!(("".to_string(), "".to_string())),
                      Some("".to_string()))
-        .expect(format!("failed to exec `{}`", config.adb_path).as_slice());
+        .expect(&format!("failed to exec `{}`", config.adb_path));
 
     let mut exitcode: int = 0;
     for c in exitcode_out.chars() {
@@ -1552,12 +1545,12 @@ fn _arm_exec_compiled_test(config: &Config,
 
     let procsrv::Result{ out: stdout_out, err: _, status: _ } =
         procsrv::run("",
-                     config.adb_path.as_slice(),
+                     &config.adb_path,
                      None,
-                     runargs.as_slice(),
+                     &runargs,
                      vec!(("".to_string(), "".to_string())),
                      Some("".to_string()))
-        .expect(format!("failed to exec `{}`", config.adb_path).as_slice());
+        .expect(&format!("failed to exec `{}`", config.adb_path));
 
     // get stderr of result
     runargs = Vec::new();
@@ -1567,17 +1560,17 @@ fn _arm_exec_compiled_test(config: &Config,
 
     let procsrv::Result{ out: stderr_out, err: _, status: _ } =
         procsrv::run("",
-                     config.adb_path.as_slice(),
+                     &config.adb_path,
                      None,
-                     runargs.as_slice(),
+                     &runargs,
                      vec!(("".to_string(), "".to_string())),
                      Some("".to_string()))
-        .expect(format!("failed to exec `{}`", config.adb_path).as_slice());
+        .expect(&format!("failed to exec `{}`", config.adb_path));
 
     dump_output(config,
                 testfile,
-                stdout_out.as_slice(),
-                stderr_out.as_slice());
+                &stdout_out,
+                &stderr_out);
 
     ProcRes {
         status: process::ProcessExit::ExitStatus(exitcode),
@@ -1595,7 +1588,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
         if file.extension_str() == Some("so") {
             // FIXME (#9639): This needs to handle non-utf8 paths
             let copy_result = procsrv::run("",
-                                           config.adb_path.as_slice(),
+                                           &config.adb_path,
                                            None,
                                            &[
                                             "push".to_string(),
@@ -1607,7 +1600,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
                                            vec!(("".to_string(),
                                                  "".to_string())),
                                            Some("".to_string()))
-                .expect(format!("failed to exec `{}`", config.adb_path).as_slice());
+                .expect(&format!("failed to exec `{}`", config.adb_path));
 
             if config.verbose {
                 println!("push ({}) {:?} {} {}",
@@ -1702,7 +1695,7 @@ fn disassemble_extract(config: &Config, _props: &TestProps,
 
 fn count_extracted_lines(p: &Path) -> uint {
     let x = File::open(&p.with_extension("ll")).read_to_end().unwrap();
-    let x = str::from_utf8(x.as_slice()).unwrap();
+    let x = str::from_utf8(&x).unwrap();
     x.lines().count()
 }
 
index efeb201efe8474977dc617783a395ec41811625c..17b2cf7d0cc251ea98ff3959c1f002920da51d04 100644 (file)
@@ -551,6 +551,10 @@ module, we now have a `phrases::japanese::hello()` function and a
 `phrases::japanese::farewells::goodbye()`. Our internal organization doesn't
 define our external interface.
 
+Here we have a `pub use` for each function we want to bring into the 
+`japanese` scope. We could alternatively use the wildcard syntax to include
+everything from `greetings` into the current scope: `pub use self::greetings::*`. 
+
 Also, note that we `pub use`d before we declared our `mod`s. Rust requires that
 `use` declarations go first.
 
index c940359abc118d8e0ef570c82fec5ccbab1572f7..7b11504f3cd8023b63c4948f7bb2a97f15f54b27 100644 (file)
@@ -15,6 +15,10 @@ import sys
 import os
 import re
 
+if len(sys.argv) < 2:
+    print "usage: errorck.py <src-dir>"
+    sys.exit(1)
+
 src_dir = sys.argv[1]
 errcode_map = {}
 error_re = re.compile("(E\d\d\d\d)")
@@ -54,8 +58,10 @@ for errcode, entries in errcode_map.items():
             print("{1}: {2}\n{3}".format(*entry))
         errors = True
 
-print("{0} error codes".format(len(errcode_map)))
-print("highest error code: " + max(all_errors))
+print
+print("* {0} error codes".format(len(errcode_map)))
+print("* highest error code: " + max(all_errors))
+print
 
 if errors:
     sys.exit(1)
index 064cf1d40ab36ce881aad53dad4d0ff841323284..df4ea998fefc2b330ae2d0d0afcae0eb56275a1c 100644 (file)
 
 import sys, os, re
 
+if len(sys.argv) < 2:
+    print "usage: featurkck.py <src-dir>"
+    sys.exit(1)
+
 src_dir = sys.argv[1]
 
 # Features that are allowed to exist in both the language and the library
@@ -234,10 +238,8 @@ for s in stats:
 
 lines.sort()
 
-print
-print "Rust feature summary:"
 print
 for line in lines:
-    print line
+    print "* " + line
 print
 
index f38583ee1fb3774c8bf01c56304358b58992fe70..889b2c95a7ea88c5a740c8a4bfda2e607801d006 100644 (file)
@@ -22,11 +22,6 @@ u"""(#|//) Copyright .* The Rust Project Developers. See the COPYRIGHT
 \\1 except according to those terms.""")
 
 exceptions = [
-    "rt/rust_android_dummy.cpp", # BSD, chromium
-    "rt/rust_android_dummy.h", # BSD, chromium
-    "rt/isaac/randport.cpp", # public domain
-    "rt/isaac/rand.h", # public domain
-    "rt/isaac/standard.h", # public domain
     "libstd/sync/mpsc/mpsc_queue.rs", # BSD
     "libstd/sync/mpsc/spsc_queue.rs", # BSD
     "test/bench/shootout-binarytrees.rs", # BSD
index f5172feb5b60f1cb288973ae9459597cebaeea02..fd3309dce12cbd01e1c573e05beeddb096a7c2f1 100644 (file)
@@ -51,78 +51,155 @@ def do_license_check(name, contents):
     if not check_license(name, contents):
         report_error_name_no(name, 1, "incorrect license")
 
-
-file_names = [s for s in sys.argv[1:] if (not s.endswith("_gen.rs"))
-                                     and (not ".#" in s)]
-
 current_name = ""
 current_contents = ""
 check_tab = True
 check_cr = True
 check_linelength = True
 
+if len(sys.argv) < 2:
+    print "usage: tidy.py <src-dir>"
+    sys.exit(1)
+
+src_dir = sys.argv[1]
 
 try:
-    for line in fileinput.input(file_names,
+    count_lines = 0
+    count_non_blank_lines = 0
+
+    interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
+
+    file_counts = {ext: 0 for ext in interesting_files}
+    file_counts['other'] = 0
+
+    def update_counts(current_name):
+        global file_counts
+        _, ext = os.path.splitext(current_name)
+
+        if ext in file_counts:
+            file_counts[ext] += 1
+        else:
+            file_counts['other'] += 1
+
+    all_paths = set()
+
+    for (dirpath, dirnames, filenames) in os.walk(src_dir):
+
+        # Skip some third-party directories
+        skippable_dirs = {
+            'src/jemalloc',
+            'src/llvm',
+            'src/gyp',
+            'src/libbacktrace',
+            'src/libuv',
+            'src/compiler-rt',
+            'src/rt/hoedown',
+            'src/rustllvm',
+            'src/rt/valgrind',
+            'src/rt/msvc',
+            'src/rust-installer'
+        }
+
+        if any(d in dirpath for d in skippable_dirs):
+            continue
+
+        def interesting_file(f):
+            if "miniz.c" in f \
+            or "jquery" in f \
+            or "rust_android_dummy" in f:
+                return False
+
+            return any(os.path.splitext(f)[1] == ext for ext in interesting_files)
+
+        file_names = [os.path.join(dirpath, f) for f in filenames
+                      if interesting_file(f)
+                      and not f.endswith("_gen.rs")
+                      and not ".#" is f]
+
+        if not file_names:
+            continue
+
+        for line in fileinput.input(file_names,
                                 openhook=fileinput.hook_encoded("utf-8")):
 
-        if "tidy.py" not in fileinput.filename():
+            filename = fileinput.filename()
+
+            if "tidy.py" not in filename:
+                if "TODO" in line:
+                    report_err("TODO is deprecated; use FIXME")
+                match = re.match(r'^.*/(\*|/!?)\s*XXX', line)
+                if match:
+                    report_err("XXX is no longer necessary, use FIXME")
+                match = re.match(r'^.*//\s*(NOTE.*)$', line)
+                if match and "TRAVIS" not in os.environ:
+                    m = match.group(1)
+                    if "snap" in m.lower():
+                        report_warn(match.group(1))
+                match = re.match(r'^.*//\s*SNAP\s+(\w+)', line)
+                if match:
+                    hsh = match.group(1)
+                    date, rev = snapshot.curr_snapshot_rev()
+                    if not hsh.startswith(rev):
+                        report_err("snapshot out of date (" + date
+                            + "): " + line)
+                else:
+                    if "SNAP" in line:
+                        report_warn("unmatched SNAP line: " + line)
+
             if cr_flag in line:
                 check_cr = False
             if tab_flag in line:
                 check_tab = False
             if linelength_flag in line:
                 check_linelength = False
-            if "TODO" in line:
-                report_err("TODO is deprecated; use FIXME")
-            match = re.match(r'^.*/(\*|/!?)\s*XXX', line)
-            if match:
-                report_err("XXX is no longer necessary, use FIXME")
-            match = re.match(r'^.*//\s*(NOTE.*)$', line)
-            if match and "TRAVIS" not in os.environ:
-                m = match.group(1)
-                if "snap" in m.lower():
-                    report_warn(match.group(1))
-            match = re.match(r'^.*//\s*SNAP\s+(\w+)', line)
-            if match:
-                hsh = match.group(1)
-                date, rev = snapshot.curr_snapshot_rev()
-                if not hsh.startswith(rev):
-                    report_err("snapshot out of date (" + date
-                               + "): " + line)
-            else:
-                if "SNAP" in line:
-                    report_warn("unmatched SNAP line: " + line)
-
-        if check_tab and ('\t' in line and
-                          "Makefile" not in fileinput.filename()):
-            report_err("tab character")
-        if check_cr and not autocrlf and '\r' in line:
-            report_err("CR character")
-        if line.endswith(" \n") or line.endswith("\t\n"):
-            report_err("trailing whitespace")
-        line_len = len(line)-2 if autocrlf else len(line)-1
-
-        if check_linelength and line_len > cols:
-            report_err("line longer than %d chars" % cols)
-
-        if fileinput.isfirstline() and current_name != "":
-            do_license_check(current_name, current_contents)
-
-        if fileinput.isfirstline():
-            current_name = fileinput.filename()
-            current_contents = ""
-            check_cr = True
-            check_tab = True
-            check_linelength = True
-
-        current_contents += line
+
+            if check_tab and ('\t' in line and
+                              "Makefile" not in filename):
+                report_err("tab character")
+            if check_cr and not autocrlf and '\r' in line:
+                report_err("CR character")
+            if line.endswith(" \n") or line.endswith("\t\n"):
+                report_err("trailing whitespace")
+            line_len = len(line)-2 if autocrlf else len(line)-1
+
+            if check_linelength and line_len > cols:
+                report_err("line longer than %d chars" % cols)
+
+            if fileinput.isfirstline():
+                # This happens at the end of each file except the last.
+                if current_name != "":
+                    update_counts(current_name)
+                    assert len(current_contents) > 0
+                    do_license_check(current_name, current_contents)
+
+                current_name = filename
+                current_contents = ""
+                check_cr = True
+                check_tab = True
+                check_linelength = True
+
+            # Put a reasonable limit on the amount of header data we use for
+            # the licenseck
+            if len(current_contents) < 1000:
+                current_contents += line
+
+            count_lines += 1
+            if line.strip():
+                count_non_blank_lines += 1
 
     if current_name != "":
+        update_counts(current_name)
+        assert len(current_contents) > 0
         do_license_check(current_name, current_contents)
 
 except UnicodeDecodeError as e:
     report_err("UTF-8 decoding error " + str(e))
 
+print
+for ext in file_counts:
+    print "* linted " + str(file_counts[ext]) + " " + ext + " files"
+print "* total lines of code: " + str(count_lines)
+print "* total non-blank lines of code: " + str(count_non_blank_lines)
+print
 
 sys.exit(err)
index cb269bbdb0ade0dc343bc3513bc9ce82698a0119..b5be3daa13e1d01b4f294f61b81b94f42dc1011f 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+# ignore-license
+
 # Run the reference lexer against libsyntax and compare the tokens and spans.
 # If "// ignore-lexer-test" is present in the file, it will be ignored.
 
index 38e57be288b240f3d2b4e780ac02a6f9aa3ef803..16babd4194e4d73815dd03eb8e9e6270441fb25e 100755 (executable)
@@ -9,6 +9,9 @@
 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 # option. This file may not be copied, modified, or distributed
 # except according to those terms.
+
+# ignore-tidy-linelength
+
 import sys
 
 import os
index bb72b066e0963022a85117ba4557fdc5c491b536..75b56f54cccc79efc4a5c48f8bd246b8fc986960 100644 (file)
@@ -179,7 +179,7 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, token::Token>) -> TokenAn
     let toknum = &s[content_end + 3 .. toknum_end];
 
     let proto_tok = tokens.get(toknum).expect(format!("didn't find token {:?} in the map",
-                                                              toknum).as_slice());
+                                                              toknum));
 
     let nm = parse::token::intern(content);
 
@@ -242,8 +242,8 @@ fn next(r: &mut lexer::StringReader) -> TokenAndSpan {
 
     let args = std::os::args();
 
-    let mut token_file = File::open(&Path::new(args[2].as_slice()));
-    let token_map = parse_token_list(token_file.read_to_string().unwrap().as_slice());
+    let mut token_file = File::open(&Path::new(args[2]));
+    let token_map = parse_token_list(token_file.read_to_string().unwrap());
 
     let mut stdin = std::io::stdin();
     let mut lock = stdin.lock();
@@ -251,7 +251,7 @@ fn next(r: &mut lexer::StringReader) -> TokenAndSpan {
     let mut antlr_tokens = lines.map(|l| parse_antlr_token(l.unwrap().trim(),
                                                                    &token_map));
 
-    let code = File::open(&Path::new(args[1].as_slice())).unwrap().read_to_string().unwrap();
+    let code = File::open(&Path::new(args[1])).unwrap().read_to_string().unwrap();
     let options = config::basic_options();
     let session = session::build_session(options, None,
                                          syntax::diagnostics::registry::Registry::new(&[]));
index 464f20e9cac53f03df5344363567837614a4d0f2..80ffa4a0a191013c4024afedc04056318da64de0 100644 (file)
 use core::ptr::{self, PtrExt};
 use core::result::Result;
 use core::result::Result::{Ok, Err};
+use core::intrinsics::assume;
 
 use heap::deallocate;
 
@@ -769,12 +770,34 @@ fn weak(&self) -> uint { self.inner().weak.get() }
 
 impl<T> RcBoxPtr<T> for Rc<T> {
     #[inline(always)]
-    fn inner(&self) -> &RcBox<T> { unsafe { &(**self._ptr) } }
+    fn inner(&self) -> &RcBox<T> {
+        unsafe {
+            // Safe to assume this here, as if it weren't true, we'd be breaking
+            // the contract anyway.
+            // This allows the null check to be elided in the destructor if we
+            // manipulated the reference count in the same function.
+            if cfg!(not(stage0)) { // NOTE remove cfg after next snapshot
+                assume(!self._ptr.is_null());
+            }
+            &(**self._ptr)
+        }
+    }
 }
 
 impl<T> RcBoxPtr<T> for Weak<T> {
     #[inline(always)]
-    fn inner(&self) -> &RcBox<T> { unsafe { &(**self._ptr) } }
+    fn inner(&self) -> &RcBox<T> {
+        unsafe {
+            // Safe to assume this here, as if it weren't true, we'd be breaking
+            // the contract anyway.
+            // This allows the null check to be elided in the destructor if we
+            // manipulated the reference count in the same function.
+            if cfg!(not(stage0)) { // NOTE remove cfg after next snapshot
+                assume(!self._ptr.is_null());
+            }
+            &(**self._ptr)
+        }
+    }
 }
 
 #[cfg(test)]
index 9301bf5e4ab47c701a57ef29f3a91fbbc868c10e..c5c19ee56bf0cec2bb9b69894fffa66e1f1aa370 100644 (file)
@@ -77,7 +77,7 @@ pub fn find_rand_n<M, T, I, F>(n: uint,
         insert(map, *k);
     }
 
-    rng.shuffle(keys.as_mut_slice());
+    rng.shuffle(&mut keys);
 
     // measure
     let mut i = 0;
index 3e603f6ebaf86862703e047e0d2ccca269cdfb40..c9b3f72526f8c5c0d2c09770f7887cb8fa712d91 100644 (file)
@@ -1910,7 +1910,7 @@ fn test_to_str() {
     fn test_0_elements() {
         let act = Bitv::new();
         let exp = Vec::new();
-        assert!(act.eq_vec(exp.as_slice()));
+        assert!(act.eq_vec(&exp));
         assert!(act.none() && act.all());
     }
 
index d85e9ee32265e134fcfc9f2858b2eca5baecf26c..d93e61b91f20026a7c2a3a8fd8abf074d9bc7ba4 100644 (file)
@@ -1054,12 +1054,12 @@ fn test_append() {
         // Non-empty to non-empty
         let v = vec![1,2,3,4,5];
         let u = vec![9,8,1,2,3,4,5];
-        let mut m = list_from(v.as_slice());
-        let mut n = list_from(u.as_slice());
+        let mut m = list_from(&v);
+        let mut n = list_from(&u);
         m.append(&mut n);
         check_links(&m);
         let mut sum = v;
-        sum.push_all(u.as_slice());
+        sum.push_all(&u);
         assert_eq!(sum.len(), m.len());
         for elt in sum {
             assert_eq!(m.pop_front(), Some(elt))
@@ -1090,7 +1090,7 @@ fn test_split_off() {
         // not singleton, forwards
         {
             let u = vec![1,2,3,4,5];
-            let mut m = list_from(u.as_slice());
+            let mut m = list_from(&u);
             let mut n = m.split_off(2);
             assert_eq!(m.len(), 2);
             assert_eq!(n.len(), 3);
@@ -1104,7 +1104,7 @@ fn test_split_off() {
         // not singleton, backwards
         {
             let u = vec![1,2,3,4,5];
-            let mut m = list_from(u.as_slice());
+            let mut m = list_from(&u);
             let mut n = m.split_off(4);
             assert_eq!(m.len(), 4);
             assert_eq!(n.len(), 1);
index 4b4ea3e4c3ca539729dc22c657aabc7be7221a67..8721de1299fb2fc71e48f2bb0082ad72081e7ef6 100644 (file)
@@ -1528,7 +1528,7 @@ fn test_from_fn() {
         // Test on-stack from_fn.
         let mut v = (0u..3).map(square).collect::<Vec<_>>();
         {
-            let v = v.as_slice();
+            let v = v;
             assert_eq!(v.len(), 3u);
             assert_eq!(v[0], 0u);
             assert_eq!(v[1], 1u);
@@ -1538,7 +1538,7 @@ fn test_from_fn() {
         // Test on-heap from_fn.
         v = (0u..5).map(square).collect::<Vec<_>>();
         {
-            let v = v.as_slice();
+            let v = v;
             assert_eq!(v.len(), 5u);
             assert_eq!(v[0], 0u);
             assert_eq!(v[1], 1u);
@@ -1553,7 +1553,7 @@ fn test_from_elem() {
         // Test on-stack from_elem.
         let mut v = vec![10u, 10u];
         {
-            let v = v.as_slice();
+            let v = v;
             assert_eq!(v.len(), 2u);
             assert_eq!(v[0], 10u);
             assert_eq!(v[1], 10u);
@@ -1562,7 +1562,7 @@ fn test_from_elem() {
         // Test on-heap from_elem.
         v = vec![20u, 20u, 20u, 20u, 20u, 20u];
         {
-            let v = v.as_slice();
+            let v = v;
             assert_eq!(v[0], 20u);
             assert_eq!(v[1], 20u);
             assert_eq!(v[2], 20u);
@@ -1715,7 +1715,7 @@ fn test_slice() {
         let vec_fixed = [1, 2, 3, 4];
         let v_a = vec_fixed[1u..vec_fixed.len()].to_vec();
         assert_eq!(v_a.len(), 3u);
-        let v_a = v_a.as_slice();
+        let v_a = v_a;
         assert_eq!(v_a[0], 2);
         assert_eq!(v_a[1], 3);
         assert_eq!(v_a[2], 4);
@@ -1724,7 +1724,7 @@ fn test_slice() {
         let vec_stack: &[_] = &[1, 2, 3];
         let v_b = vec_stack[1u..3u].to_vec();
         assert_eq!(v_b.len(), 2u);
-        let v_b = v_b.as_slice();
+        let v_b = v_b;
         assert_eq!(v_b[0], 2);
         assert_eq!(v_b[1], 3);
 
@@ -1732,7 +1732,7 @@ fn test_slice() {
         let vec_unique = vec![1, 2, 3, 4, 5, 6];
         let v_d = vec_unique[1u..6u].to_vec();
         assert_eq!(v_d.len(), 5u);
-        let v_d = v_d.as_slice();
+        let v_d = v_d;
         assert_eq!(v_d[0], 2);
         assert_eq!(v_d[1], 3);
         assert_eq!(v_d[2], 4);
@@ -1813,20 +1813,20 @@ fn test_push() {
         let mut v = vec![];
         v.push(1);
         assert_eq!(v.len(), 1u);
-        assert_eq!(v.as_slice()[0], 1);
+        assert_eq!(v[0], 1);
 
         // Test on-heap push().
         v.push(2);
         assert_eq!(v.len(), 2u);
-        assert_eq!(v.as_slice()[0], 1);
-        assert_eq!(v.as_slice()[1], 2);
+        assert_eq!(v[0], 1);
+        assert_eq!(v[1], 2);
     }
 
     #[test]
     fn test_truncate() {
         let mut v = vec![box 6,box 5,box 4];
         v.truncate(1);
-        let v = v.as_slice();
+        let v = v;
         assert_eq!(v.len(), 1);
         assert_eq!(*(v[0]), 6);
         // If the unsafe block didn't drop things properly, we blow up here.
@@ -2587,7 +2587,7 @@ macro_rules! test_show_vec {
             ($x:expr, $x_str:expr) => ({
                 let (x, x_str) = ($x, $x_str);
                 assert_eq!(format!("{:?}", x), x_str);
-                assert_eq!(format!("{:?}", x.as_slice()), x_str);
+                assert_eq!(format!("{:?}", x), x_str);
             })
         }
         let empty: Vec<int> = vec![];
@@ -2910,7 +2910,7 @@ fn push(b: &mut Bencher) {
     fn starts_with_same_vector(b: &mut Bencher) {
         let vec: Vec<uint> = (0u..100).collect();
         b.iter(|| {
-            vec.starts_with(vec.as_slice())
+            vec.starts_with(&vec)
         })
     }
 
@@ -2918,7 +2918,7 @@ fn starts_with_same_vector(b: &mut Bencher) {
     fn starts_with_single_element(b: &mut Bencher) {
         let vec: Vec<uint> = vec![0];
         b.iter(|| {
-            vec.starts_with(vec.as_slice())
+            vec.starts_with(&vec)
         })
     }
 
@@ -2928,7 +2928,7 @@ fn starts_with_diff_one_element_at_end(b: &mut Bencher) {
         let mut match_vec: Vec<uint> = (0u..99).collect();
         match_vec.push(0);
         b.iter(|| {
-            vec.starts_with(match_vec.as_slice())
+            vec.starts_with(&match_vec)
         })
     }
 
@@ -2936,7 +2936,7 @@ fn starts_with_diff_one_element_at_end(b: &mut Bencher) {
     fn ends_with_same_vector(b: &mut Bencher) {
         let vec: Vec<uint> = (0u..100).collect();
         b.iter(|| {
-            vec.ends_with(vec.as_slice())
+            vec.ends_with(&vec)
         })
     }
 
@@ -2944,7 +2944,7 @@ fn ends_with_same_vector(b: &mut Bencher) {
     fn ends_with_single_element(b: &mut Bencher) {
         let vec: Vec<uint> = vec![0];
         b.iter(|| {
-            vec.ends_with(vec.as_slice())
+            vec.ends_with(&vec)
         })
     }
 
@@ -2952,9 +2952,9 @@ fn ends_with_single_element(b: &mut Bencher) {
     fn ends_with_diff_one_element_at_beginning(b: &mut Bencher) {
         let vec: Vec<uint> = (0u..100).collect();
         let mut match_vec: Vec<uint> = (0u..100).collect();
-        match_vec.as_mut_slice()[0] = 200;
+        match_vec[0] = 200;
         b.iter(|| {
-            vec.starts_with(match_vec.as_slice())
+            vec.starts_with(&match_vec)
         })
     }
 
@@ -3042,7 +3042,7 @@ fn sort_random_small(b: &mut Bencher) {
         let mut rng = weak_rng();
         b.iter(|| {
             let mut v = rng.gen_iter::<u64>().take(5).collect::<Vec<u64>>();
-            v.as_mut_slice().sort();
+            v.sort();
         });
         b.bytes = 5 * mem::size_of::<u64>() as u64;
     }
@@ -3052,7 +3052,7 @@ fn sort_random_medium(b: &mut Bencher) {
         let mut rng = weak_rng();
         b.iter(|| {
             let mut v = rng.gen_iter::<u64>().take(100).collect::<Vec<u64>>();
-            v.as_mut_slice().sort();
+            v.sort();
         });
         b.bytes = 100 * mem::size_of::<u64>() as u64;
     }
@@ -3062,7 +3062,7 @@ fn sort_random_large(b: &mut Bencher) {
         let mut rng = weak_rng();
         b.iter(|| {
             let mut v = rng.gen_iter::<u64>().take(10000).collect::<Vec<u64>>();
-            v.as_mut_slice().sort();
+            v.sort();
         });
         b.bytes = 10000 * mem::size_of::<u64>() as u64;
     }
index 75f7b812974d703daba644a855e53b9721e4b206..336d9fcf5da1eb9b0419d64e459fe8db3cfa8514 100644 (file)
@@ -199,11 +199,11 @@ fn next(&mut self) -> Option<char> {
                 let buffer = &mut self.buffer;
                 let sorted = &mut self.sorted;
                 {
-                    let callback = |&mut: d| {
+                    let callback = |d| {
                         let class =
                             unicode::char::canonical_combining_class(d);
                         if class == 0 && !*sorted {
-                            canonical_sort(buffer.as_mut_slice());
+                            canonical_sort(buffer);
                             *sorted = true;
                         }
                         buffer.push((d, class));
@@ -224,7 +224,7 @@ fn next(&mut self) -> Option<char> {
         }
 
         if !self.sorted {
-            canonical_sort(self.buffer.as_mut_slice());
+            canonical_sort(&mut self.buffer);
             self.sorted = true;
         }
 
@@ -592,7 +592,7 @@ fn char_indices(&self) -> CharIndices {
     /// let v: Vec<&str> = "Mary had a little lamb".split(' ').collect();
     /// assert_eq!(v, vec!["Mary", "had", "a", "little", "lamb"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).collect();
+    /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).collect();
     /// assert_eq!(v, vec!["abc", "def", "ghi"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
@@ -616,7 +616,7 @@ fn split<P: CharEq>(&self, pat: P) -> Split<P> {
     /// let v: Vec<&str> = "Mary had a little lambda".splitn(2, ' ').collect();
     /// assert_eq!(v, vec!["Mary", "had", "a little lambda"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".splitn(1, |&: c: char| c.is_numeric()).collect();
+    /// let v: Vec<&str> = "abc1def2ghi".splitn(1, |c: char| c.is_numeric()).collect();
     /// assert_eq!(v, vec!["abc", "def2ghi"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".splitn(2, 'X').collect();
@@ -651,7 +651,7 @@ fn splitn<P: CharEq>(&self, count: uint, pat: P) -> SplitN<P> {
     /// let v: Vec<&str> = "Mary had a little lamb".split(' ').rev().collect();
     /// assert_eq!(v, vec!["lamb", "little", "a", "had", "Mary"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).rev().collect();
+    /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).rev().collect();
     /// assert_eq!(v, vec!["ghi", "def", "abc"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".split('X').rev().collect();
@@ -672,7 +672,7 @@ fn split_terminator<P: CharEq>(&self, pat: P) -> SplitTerminator<P> {
     /// let v: Vec<&str> = "Mary had a little lamb".rsplitn(2, ' ').collect();
     /// assert_eq!(v, vec!["lamb", "little", "Mary had a"]);
     ///
-    /// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |&: c: char| c.is_numeric()).collect();
+    /// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |c: char| c.is_numeric()).collect();
     /// assert_eq!(v, vec!["ghi", "abc1def"]);
     ///
     /// let v: Vec<&str> = "lionXXtigerXleopard".rsplitn(2, 'X').collect();
@@ -853,7 +853,7 @@ fn ends_with(&self, pat: &str) -> bool {
     /// assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
     /// let x: &[_] = &['1', '2'];
     /// assert_eq!("12foo1bar12".trim_matches(x), "foo1bar");
-    /// assert_eq!("123foo1bar123".trim_matches(|&: c: char| c.is_numeric()), "foo1bar");
+    /// assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     fn trim_matches<P: CharEq>(&self, pat: P) -> &str {
@@ -873,7 +873,7 @@ fn trim_matches<P: CharEq>(&self, pat: P) -> &str {
     /// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
     /// let x: &[_] = &['1', '2'];
     /// assert_eq!("12foo1bar12".trim_left_matches(x), "foo1bar12");
-    /// assert_eq!("123foo1bar123".trim_left_matches(|&: c: char| c.is_numeric()), "foo1bar123");
+    /// assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str {
@@ -893,7 +893,7 @@ fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str {
     /// assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
     /// let x: &[_] = &['1', '2'];
     /// assert_eq!("12foo1bar12".trim_right_matches(x), "12foo1bar");
-    /// assert_eq!("123foo1bar123".trim_right_matches(|&: c: char| c.is_numeric()), "123foo1bar");
+    /// assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str {
@@ -1066,7 +1066,7 @@ fn as_bytes(&self) -> &[u8] {
     /// assert_eq!(s.find('é'), Some(14));
     ///
     /// // the first space
-    /// assert_eq!(s.find(|&: c: char| c.is_whitespace()), Some(5));
+    /// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5));
     ///
     /// // neither are found
     /// let x: &[_] = &['1', '2'];
@@ -1094,7 +1094,7 @@ fn find<P: CharEq>(&self, pat: P) -> Option<uint> {
     /// assert_eq!(s.rfind('é'), Some(14));
     ///
     /// // the second space
-    /// assert_eq!(s.rfind(|&: c: char| c.is_whitespace()), Some(12));
+    /// assert_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12));
     ///
     /// // searches for an occurrence of either `1` or `2`, but neither are found
     /// let x: &[_] = &['1', '2'];
@@ -1387,21 +1387,21 @@ fn test_len() {
     #[test]
     fn test_find() {
         assert_eq!("hello".find('l'), Some(2u));
-        assert_eq!("hello".find(|&: c:char| c == 'o'), Some(4u));
+        assert_eq!("hello".find(|c:char| c == 'o'), Some(4u));
         assert!("hello".find('x').is_none());
-        assert!("hello".find(|&: c:char| c == 'x').is_none());
+        assert!("hello".find(|c:char| c == 'x').is_none());
         assert_eq!("ประเทศไทย中华Việt Nam".find('华'), Some(30u));
-        assert_eq!("ประเทศไทย中华Việt Nam".find(|&: c: char| c == '华'), Some(30u));
+        assert_eq!("ประเทศไทย中华Việt Nam".find(|c: char| c == '华'), Some(30u));
     }
 
     #[test]
     fn test_rfind() {
         assert_eq!("hello".rfind('l'), Some(3u));
-        assert_eq!("hello".rfind(|&: c:char| c == 'o'), Some(4u));
+        assert_eq!("hello".rfind(|c:char| c == 'o'), Some(4u));
         assert!("hello".rfind('x').is_none());
-        assert!("hello".rfind(|&: c:char| c == 'x').is_none());
+        assert!("hello".rfind(|c:char| c == 'x').is_none());
         assert_eq!("ประเทศไทย中华Việt Nam".rfind('华'), Some(30u));
-        assert_eq!("ประเทศไทย中华Việt Nam".rfind(|&: c: char| c == '华'), Some(30u));
+        assert_eq!("ประเทศไทย中华Việt Nam".rfind(|c: char| c == '华'), Some(30u));
     }
 
     #[test]
@@ -1480,7 +1480,7 @@ macro_rules! test_concat {
     fn test_concat_for_different_types() {
         test_concat!("ab", vec![s("a"), s("b")]);
         test_concat!("ab", vec!["a", "b"]);
-        test_concat!("ab", vec!["a", "b"].as_slice());
+        test_concat!("ab", vec!["a", "b"]);
         test_concat!("ab", vec![s("a"), s("b")]);
     }
 
@@ -1506,9 +1506,9 @@ macro_rules! test_connect {
     fn test_connect_for_different_types() {
         test_connect!("a-b", ["a", "b"], "-");
         let hyphen = "-".to_string();
-        test_connect!("a-b", [s("a"), s("b")], hyphen.as_slice());
-        test_connect!("a-b", vec!["a", "b"], hyphen.as_slice());
-        test_connect!("a-b", vec!["a", "b"].as_slice(), "-");
+        test_connect!("a-b", [s("a"), s("b")], &*hyphen);
+        test_connect!("a-b", vec!["a", "b"], &*hyphen);
+        test_connect!("a-b", &*vec!["a", "b"], "-");
         test_connect!("a-b", vec![s("a"), s("b")], "-");
     }
 
@@ -1723,7 +1723,7 @@ fn test_trim_left_matches() {
         assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
         let chars: &[char] = &['1', '2'];
         assert_eq!("12foo1bar12".trim_left_matches(chars), "foo1bar12");
-        assert_eq!("123foo1bar123".trim_left_matches(|&: c: char| c.is_numeric()), "foo1bar123");
+        assert_eq!("123foo1bar123".trim_left_matches(|c: char| c.is_numeric()), "foo1bar123");
     }
 
     #[test]
@@ -1738,7 +1738,7 @@ fn test_trim_right_matches() {
         assert_eq!("11foo1bar11".trim_right_matches('1'), "11foo1bar");
         let chars: &[char] = &['1', '2'];
         assert_eq!("12foo1bar12".trim_right_matches(chars), "12foo1bar");
-        assert_eq!("123foo1bar123".trim_right_matches(|&: c: char| c.is_numeric()), "123foo1bar");
+        assert_eq!("123foo1bar123".trim_right_matches(|c: char| c.is_numeric()), "123foo1bar");
     }
 
     #[test]
@@ -1753,7 +1753,7 @@ fn test_trim_matches() {
         assert_eq!("11foo1bar11".trim_matches('1'), "foo1bar");
         let chars: &[char] = &['1', '2'];
         assert_eq!("12foo1bar12".trim_matches(chars), "foo1bar");
-        assert_eq!("123foo1bar123".trim_matches(|&: c: char| c.is_numeric()), "foo1bar");
+        assert_eq!("123foo1bar123".trim_matches(|c: char| c.is_numeric()), "foo1bar");
     }
 
     #[test]
@@ -1960,7 +1960,7 @@ fn vec_str_conversions() {
         let s1: String = String::from_str("All mimsy were the borogoves");
 
         let v: Vec<u8> = s1.as_bytes().to_vec();
-        let s2: String = String::from_str(from_utf8(v.as_slice()).unwrap());
+        let s2: String = String::from_str(from_utf8(&v).unwrap());
         let mut i: uint = 0u;
         let n1: uint = s1.len();
         let n2: uint = v.len();
@@ -2222,14 +2222,14 @@ fn test_splitn_char_iterator() {
         let split: Vec<&str> = data.splitn(3, ' ').collect();
         assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
 
-        let split: Vec<&str> = data.splitn(3, |&: c: char| c == ' ').collect();
+        let split: Vec<&str> = data.splitn(3, |c: char| c == ' ').collect();
         assert_eq!(split, vec!["\nMäry", "häd", "ä", "little lämb\nLittle lämb\n"]);
 
         // Unicode
         let split: Vec<&str> = data.splitn(3, 'ä').collect();
         assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
 
-        let split: Vec<&str> = data.splitn(3, |&: c: char| c == 'ä').collect();
+        let split: Vec<&str> = data.splitn(3, |c: char| c == 'ä').collect();
         assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
     }
 
@@ -2791,11 +2791,11 @@ fn sum_len(v: &[&str]) -> uint {
 
         let s = String::from_str("01234");
         assert_eq!(5, sum_len(&["012", "", "34"]));
-        assert_eq!(5, sum_len(&[String::from_str("01").as_slice(),
-                                String::from_str("2").as_slice(),
-                                String::from_str("34").as_slice(),
-                                String::from_str("").as_slice()]));
-        assert_eq!(5, sum_len(&[s.as_slice()]));
+        assert_eq!(5, sum_len(&[&String::from_str("01"),
+                                &String::from_str("2"),
+                                &String::from_str("34"),
+                                &String::from_str("")]));
+        assert_eq!(5, sum_len(&[&s]));
     }
 
     #[test]
@@ -2940,7 +2940,7 @@ fn split_closure(b: &mut Bencher) {
         let s = "Mary had a little lamb, Little lamb, little-lamb.";
         let len = s.split(' ').count();
 
-        b.iter(|| assert_eq!(s.split(|&: c: char| c == ' ').count(), len));
+        b.iter(|| assert_eq!(s.split(|c: char| c == ' ').count(), len));
     }
 
     #[bench]
index 554eee765f3eb5efc4a792ed6162b7c06cea5403..a96ab40dd708fef1dfd30ea331b5eedd7ca5cd57 100644 (file)
@@ -126,7 +126,7 @@ pub fn from_str(string: &str) -> String {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
-        match str::from_utf8(vec.as_slice()) {
+        match str::from_utf8(&vec) {
             Ok(..) => Ok(String { vec: vec }),
             Err(e) => Err(FromUtf8Error { bytes: vec, error: e })
         }
@@ -489,7 +489,7 @@ pub fn push(&mut self, ch: char) {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
-        self.vec.as_slice()
+        &self.vec
     }
 
     /// Shortens a string to the specified length.
@@ -804,7 +804,7 @@ impl Str for String {
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn as_slice<'a>(&'a self) -> &'a str {
-        unsafe { mem::transmute(self.vec.as_slice()) }
+        unsafe { mem::transmute(&*self.vec) }
     }
 }
 
@@ -882,7 +882,7 @@ impl ops::Index<ops::RangeFull> for String {
     type Output = str;
     #[inline]
     fn index(&self, _index: &ops::RangeFull) -> &str {
-        unsafe { mem::transmute(self.vec.as_slice()) }
+        unsafe { mem::transmute(&*self.vec) }
     }
 }
 
@@ -980,7 +980,7 @@ fn into_cow(self) -> CowString<'a> {
 impl<'a> Str for CowString<'a> {
     #[inline]
     fn as_slice<'b>(&'b self) -> &'b str {
-        (**self).as_slice()
+        &**self
     }
 }
 
@@ -1005,13 +1005,13 @@ mod tests {
     #[test]
     fn test_as_string() {
         let x = "foo";
-        assert_eq!(x, as_string(x).as_slice());
+        assert_eq!(x, &**as_string(x));
     }
 
     #[test]
     fn test_from_str() {
       let owned: Option<::std::string::String> = "string".parse().ok();
-      assert_eq!(owned.as_ref().map(|s| s.as_slice()), Some("string"));
+      assert_eq!(owned.as_ref().map(|s| &**s), Some("string"));
     }
 
     #[test]
@@ -1121,15 +1121,15 @@ fn test_from_utf16() {
         for p in &pairs {
             let (s, u) = (*p).clone();
             let s_as_utf16 = s.utf16_units().collect::<Vec<u16>>();
-            let u_as_string = String::from_utf16(u.as_slice()).unwrap();
+            let u_as_string = String::from_utf16(&u).unwrap();
 
-            assert!(::unicode::str::is_utf16(u.as_slice()));
+            assert!(::unicode::str::is_utf16(&u));
             assert_eq!(s_as_utf16, u);
 
             assert_eq!(u_as_string, s);
-            assert_eq!(String::from_utf16_lossy(u.as_slice()), s);
+            assert_eq!(String::from_utf16_lossy(&u), s);
 
-            assert_eq!(String::from_utf16(s_as_utf16.as_slice()).unwrap(), s);
+            assert_eq!(String::from_utf16(&s_as_utf16).unwrap(), s);
             assert_eq!(u_as_string.utf16_units().collect::<Vec<u16>>(), u);
         }
     }
@@ -1419,7 +1419,7 @@ fn from_utf8_lossy_invalid(b: &mut Bencher) {
     fn from_utf8_lossy_100_invalid(b: &mut Bencher) {
         let s = repeat(0xf5u8).take(100).collect::<Vec<_>>();
         b.iter(|| {
-            let _ = String::from_utf8_lossy(s.as_slice());
+            let _ = String::from_utf8_lossy(&s);
         });
     }
 
index e9ddfd4872f7e3671c77dd1bc1aabbb879ae4412..8218469d6afb58e637e5c0e192192a993c8fc773 100644 (file)
@@ -382,7 +382,7 @@ pub fn shrink_to_fit(&mut self) {
     pub fn into_boxed_slice(mut self) -> Box<[T]> {
         self.shrink_to_fit();
         unsafe {
-            let xs: Box<[T]> = mem::transmute(self.as_mut_slice());
+            let xs: Box<[T]> = mem::transmute(&mut *self);
             mem::forget(self);
             xs
         }
@@ -604,7 +604,7 @@ pub fn retain<F>(&mut self, mut f: F) where F: FnMut(&T) -> bool {
         let len = self.len();
         let mut del = 0u;
         {
-            let v = self.as_mut_slice();
+            let v = &mut **self;
 
             for i in 0u..len {
                 if !f(&v[i]) {
@@ -1246,7 +1246,7 @@ unsafe fn dealloc<T>(ptr: *mut T, len: uint) {
 
 #[unstable(feature = "collections")]
 impl<T:Clone> Clone for Vec<T> {
-    fn clone(&self) -> Vec<T> { ::slice::SliceExt::to_vec(self.as_slice()) }
+    fn clone(&self) -> Vec<T> { ::slice::SliceExt::to_vec(&**self) }
 
     fn clone_from(&mut self, other: &Vec<T>) {
         // drop anything in self that will not be overwritten
@@ -1269,7 +1269,7 @@ fn clone_from(&mut self, other: &Vec<T>) {
 impl<S: hash::Writer + hash::Hasher, T: Hash<S>> Hash<S> for Vec<T> {
     #[inline]
     fn hash(&self, state: &mut S) {
-        self.as_slice().hash(state);
+        Hash::hash(&**self, state)
     }
 }
 
@@ -1279,7 +1279,8 @@ impl<T> Index<uint> for Vec<T> {
 
     #[inline]
     fn index<'a>(&'a self, index: &uint) -> &'a T {
-        &self.as_slice()[*index]
+        // NB built-in indexing via `&[T]`
+        &(**self)[*index]
     }
 }
 
@@ -1289,7 +1290,8 @@ impl<T> IndexMut<uint> for Vec<T> {
 
     #[inline]
     fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
-        &mut self.as_mut_slice()[*index]
+        // NB built-in indexing via `&mut [T]`
+        &mut (**self)[*index]
     }
 }
 
@@ -1299,7 +1301,7 @@ impl<T> ops::Index<ops::Range<uint>> for Vec<T> {
     type Output = [T];
     #[inline]
     fn index(&self, index: &ops::Range<uint>) -> &[T] {
-        self.as_slice().index(index)
+        Index::index(&**self, index)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -1307,7 +1309,7 @@ impl<T> ops::Index<ops::RangeTo<uint>> for Vec<T> {
     type Output = [T];
     #[inline]
     fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
-        self.as_slice().index(index)
+        Index::index(&**self, index)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -1315,7 +1317,7 @@ impl<T> ops::Index<ops::RangeFrom<uint>> for Vec<T> {
     type Output = [T];
     #[inline]
     fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
-        self.as_slice().index(index)
+        Index::index(&**self, index)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -1332,7 +1334,7 @@ impl<T> ops::IndexMut<ops::Range<uint>> for Vec<T> {
     type Output = [T];
     #[inline]
     fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
-        self.as_mut_slice().index_mut(index)
+        IndexMut::index_mut(&mut **self, index)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -1340,7 +1342,7 @@ impl<T> ops::IndexMut<ops::RangeTo<uint>> for Vec<T> {
     type Output = [T];
     #[inline]
     fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
-        self.as_mut_slice().index_mut(index)
+        IndexMut::index_mut(&mut **self, index)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -1348,7 +1350,7 @@ impl<T> ops::IndexMut<ops::RangeFrom<uint>> for Vec<T> {
     type Output = [T];
     #[inline]
     fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
-        self.as_mut_slice().index_mut(index)
+        IndexMut::index_mut(&mut **self, index)
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -1489,7 +1491,7 @@ fn ne(&self, other: &CowVec<'a, A>) -> bool { PartialEq::ne(&**self, &**other) }
 impl<T: PartialOrd> PartialOrd for Vec<T> {
     #[inline]
     fn partial_cmp(&self, other: &Vec<T>) -> Option<Ordering> {
-        self.as_slice().partial_cmp(other.as_slice())
+        PartialOrd::partial_cmp(&**self, &**other)
     }
 }
 
@@ -1500,7 +1502,7 @@ impl<T: Eq> Eq for Vec<T> {}
 impl<T: Ord> Ord for Vec<T> {
     #[inline]
     fn cmp(&self, other: &Vec<T>) -> Ordering {
-        self.as_slice().cmp(other.as_slice())
+        Ord::cmp(&**self, &**other)
     }
 }
 
@@ -1567,7 +1569,7 @@ fn default() -> Vec<T> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: fmt::Debug> fmt::Debug for Vec<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        fmt::Debug::fmt(self.as_slice(), f)
+        fmt::Debug::fmt(&**self, f)
     }
 }
 
@@ -1931,7 +1933,7 @@ fn drop(&mut self) {
     #[test]
     fn test_as_vec() {
         let xs = [1u8, 2u8, 3u8];
-        assert_eq!(as_vec(&xs).as_slice(), xs);
+        assert_eq!(&**as_vec(&xs), xs);
     }
 
     #[test]
@@ -2396,7 +2398,7 @@ fn test_drain_items_zero_sized() {
     fn test_into_boxed_slice() {
         let xs = vec![1u, 2, 3];
         let ys = xs.into_boxed_slice();
-        assert_eq!(ys.as_slice(), [1u, 2, 3]);
+        assert_eq!(ys, [1u, 2, 3]);
     }
 
     #[test]
@@ -2636,7 +2638,7 @@ fn do_bench_push_all(b: &mut Bencher, dst_len: uint, src_len: uint) {
 
         b.iter(|| {
             let mut dst = dst.clone();
-            dst.push_all(src.as_slice());
+            dst.push_all(&src);
             assert_eq!(dst.len(), dst_len + src_len);
             assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
         });
index 0f444ef186f9abe37ec960601b91a334c3cc74d0..182851002d9426bc35d49a3dd7ae2e42231e4d59 100644 (file)
@@ -23,7 +23,7 @@
 //!
 //! use std::finally::Finally;
 //!
-//! (|&mut:| {
+//! (|| {
 //!     // ...
 //! }).finally(|| {
 //!     // this code is always run
index 0963afaf72e21009c2a372fe97de5756153b11e2..25bb959b9b3aa9db02d12d0dbc894c151077555f 100644 (file)
@@ -225,10 +225,10 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
         // cut off the one extra digit, and depending on its value
         // round the remaining ones.
         if limit_digits && dig == digit_count {
-            let ascii2value = |&: chr: u8| {
+            let ascii2value = |chr: u8| {
                 (chr as char).to_digit(radix).unwrap()
             };
-            let value2ascii = |&: val: uint| {
+            let value2ascii = |val: uint| {
                 char::from_digit(val, radix).unwrap() as u8
             };
 
index 60262857765e26854a24012b825df22eb3f06ae9..0357b723b3c7aa29af0f9ff43ae9b4cf519d309a 100644 (file)
@@ -483,7 +483,7 @@ pub fn pad_integral(&mut self,
         }
 
         // Writes the sign if it exists, and then the prefix if it was requested
-        let write_prefix = |&: f: &mut Formatter| {
+        let write_prefix = |f: &mut Formatter| {
             if let Some(c) = sign {
                 let mut b = [0; 4];
                 let n = c.encode_utf8(&mut b).unwrap_or(0);
index d73e6ed589ff3bed1455121de3cc80a76ee8062e..a5d2618eff948959e881f655beaa839d75b4536d 100644 (file)
@@ -123,7 +123,7 @@ fn hash(&self, state: &mut S) {
                 let a: [u8; ::$ty::BYTES] = unsafe {
                     mem::transmute((*self as $uty).to_le() as $ty)
                 };
-                state.write(a.as_slice())
+                state.write(&a)
             }
         }
     }
index 0d26c8e79142ae728bf071fc216143a496387841..51bf3c1648f568482abce0ad2ea1e54c6269435a 100644 (file)
@@ -331,8 +331,9 @@ pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
 #[unstable(feature = "core",
            reason = "this function may be removed in the future due to its \
                      questionable utility")]
-pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a mut S,
-                                                            ptr: &mut T)
-                                                            -> &'a mut T {
+pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
+                                                               ptr: &mut T)
+                                                              -> &'a mut T
+{
     transmute(ptr)
 }
index 8c0c16bafc4c586b860d57ebb81339ebe2c3719c..673ab1e094a8612bf9ea56908dc00e3d6aca00eb 100644 (file)
@@ -1518,11 +1518,11 @@ fn ends_with(&self, needle: &str) -> bool {
 
     #[inline]
     fn trim_matches<P: CharEq>(&self, mut pat: P) -> &str {
-        let cur = match self.find(|&mut: c: char| !pat.matches(c)) {
+        let cur = match self.find(|c: char| !pat.matches(c)) {
             None => "",
             Some(i) => unsafe { self.slice_unchecked(i, self.len()) }
         };
-        match cur.rfind(|&mut: c: char| !pat.matches(c)) {
+        match cur.rfind(|c: char| !pat.matches(c)) {
             None => "",
             Some(i) => {
                 let right = cur.char_range_at(i).next;
@@ -1533,7 +1533,7 @@ fn trim_matches<P: CharEq>(&self, mut pat: P) -> &str {
 
     #[inline]
     fn trim_left_matches<P: CharEq>(&self, mut pat: P) -> &str {
-        match self.find(|&mut: c: char| !pat.matches(c)) {
+        match self.find(|c: char| !pat.matches(c)) {
             None => "",
             Some(first) => unsafe { self.slice_unchecked(first, self.len()) }
         }
@@ -1541,7 +1541,7 @@ fn trim_left_matches<P: CharEq>(&self, mut pat: P) -> &str {
 
     #[inline]
     fn trim_right_matches<P: CharEq>(&self, mut pat: P) -> &str {
-        match self.rfind(|&mut: c: char| !pat.matches(c)) {
+        match self.rfind(|c: char| !pat.matches(c)) {
             None => "",
             Some(last) => {
                 let next = self.char_range_at(last).next;
index 2e29b1c41c418f1fb098735d3df6ee353e942d3a..9ba9c2c4a9ca57599a0d12ea8f43625294660520 100644 (file)
@@ -166,7 +166,7 @@ fn string(c: char) -> String { c.escape_unicode().collect() }
 fn test_encode_utf8() {
     fn check(input: char, expect: &[u8]) {
         let mut buf = [0u8; 4];
-        let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
+        let n = input.encode_utf8(&mut buf).unwrap_or(0);
         assert_eq!(&buf[..n], expect);
     }
 
@@ -180,7 +180,7 @@ fn check(input: char, expect: &[u8]) {
 fn test_encode_utf16() {
     fn check(input: char, expect: &[u16]) {
         let mut buf = [0u16; 2];
-        let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
+        let n = input.encode_utf16(&mut buf).unwrap_or(0);
         assert_eq!(&buf[..n], expect);
     }
 
index 22917b09ce9959856b3dcbb8c3451c380290d61f..42c2dfbda082af112e9b208bc1839428f792eee8 100644 (file)
@@ -47,8 +47,9 @@ fn test_fail() {
 
 #[test]
 fn test_retval() {
-    let mut closure = |&mut:| 10;
-    let i = closure.finally(|| { });
+    let mut closure = || 10;
+    // FIXME(#16640) `: i32` annotation shouldn't be necessary
+    let i: i32 = closure.finally(|| { });
     assert_eq!(i, 10);
 }
 
index a493f71925e0a2a15a53158be8a9bf837fcea39c..248cad32ef4d24c7af645dc16543d783bf9cf682 100644 (file)
@@ -110,7 +110,7 @@ fn test_siphash() {
     fn to_hex_str(r: &[u8; 8]) -> String {
         let mut s = String::new();
         for b in r {
-            s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
+            s.push_str(format!("{}", fmt::radix(*b, 16)));
         }
         s
     }
@@ -131,7 +131,7 @@ fn result_str(h: u64) -> String {
         let r = result_bytes(h);
         let mut s = String::new();
         for b in &r {
-            s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
+            s.push_str(format!("{}", fmt::radix(*b, 16)));
         }
         s
     }
@@ -139,12 +139,12 @@ fn result_str(h: u64) -> String {
     while t < 64 {
         debug!("siphash test {}: {}", t, buf);
         let vec = u8to64_le!(vecs[t], 0);
-        let out = hash_with_keys(k0, k1, &Bytes(buf.as_slice()));
+        let out = hash_with_keys(k0, k1, &Bytes(buf));
         debug!("got {}, expected {}", out, vec);
         assert_eq!(vec, out);
 
         state_full.reset();
-        state_full.write(buf.as_slice());
+        state_full.write(buf);
         let f = result_str(state_full.result());
         let i = result_str(state_inc.result());
         let v = to_hex_str(&vecs[t]);
index f2a1b0ac584d3d34875b5ede0d2db196fbb50c3e..375564c39bb5b1846f5a4d0f7fd27310ead2cb07 100644 (file)
@@ -54,7 +54,7 @@ fn test_rsplitn_char_iterator() {
     split.reverse();
     assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
 
-    let mut split: Vec<&str> = data.rsplitn(3, |&: c: char| c == ' ').collect();
+    let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == ' ').collect();
     split.reverse();
     assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
 
@@ -63,7 +63,7 @@ fn test_rsplitn_char_iterator() {
     split.reverse();
     assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
 
-    let mut split: Vec<&str> = data.rsplitn(3, |&: c: char| c == 'ä').collect();
+    let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == 'ä').collect();
     split.reverse();
     assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
 }
@@ -79,10 +79,10 @@ fn test_split_char_iterator() {
     rsplit.reverse();
     assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
 
-    let split: Vec<&str> = data.split(|&: c: char| c == ' ').collect();
+    let split: Vec<&str> = data.split(|c: char| c == ' ').collect();
     assert_eq!( split, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
 
-    let mut rsplit: Vec<&str> = data.split(|&: c: char| c == ' ').rev().collect();
+    let mut rsplit: Vec<&str> = data.split(|c: char| c == ' ').rev().collect();
     rsplit.reverse();
     assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
 
@@ -94,10 +94,10 @@ fn test_split_char_iterator() {
     rsplit.reverse();
     assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
 
-    let split: Vec<&str> = data.split(|&: c: char| c == 'ä').collect();
+    let split: Vec<&str> = data.split(|c: char| c == 'ä').collect();
     assert_eq!( split, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
 
-    let mut rsplit: Vec<&str> = data.split(|&: c: char| c == 'ä').rev().collect();
+    let mut rsplit: Vec<&str> = data.split(|c: char| c == 'ä').rev().collect();
     rsplit.reverse();
     assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
 }
index a3bbba6d7b432eb0f4ee48d541b50cd187cf9c45..1739475336539bb3d934b0c07907027113f7c2ec 100644 (file)
@@ -147,24 +147,24 @@ fn test_flate_round_trip() {
         for _ in 0..20 {
             let mut input = vec![];
             for _ in 0..2000 {
-                input.push_all(r.choose(words.as_slice()).unwrap().as_slice());
+                input.push_all(r.choose(&words).unwrap());
             }
             debug!("de/inflate of {} bytes of random word-sequences",
                    input.len());
-            let cmp = deflate_bytes(input.as_slice()).expect("deflation failed");
-            let out = inflate_bytes(cmp.as_slice()).expect("inflation failed");
+            let cmp = deflate_bytes(&input).expect("deflation failed");
+            let out = inflate_bytes(&cmp).expect("inflation failed");
             debug!("{} bytes deflated to {} ({:.1}% size)",
                    input.len(), cmp.len(),
                    100.0 * ((cmp.len() as f64) / (input.len() as f64)));
-            assert_eq!(input, out.as_slice());
+            assert_eq!(&*input, &*out);
         }
     }
 
     #[test]
     fn test_zlib_flate() {
         let bytes = vec!(1, 2, 3, 4, 5);
-        let deflated = deflate_bytes(bytes.as_slice()).expect("deflation failed");
-        let inflated = inflate_bytes(deflated.as_slice()).expect("inflation failed");
-        assert_eq!(inflated.as_slice(), bytes);
+        let deflated = deflate_bytes(&bytes).expect("deflation failed");
+        let inflated = inflate_bytes(&deflated).expect("inflation failed");
+        assert_eq!(&*inflated, &*bytes);
     }
 }
index 9cfd4933ac22980c9264f1f768ca7fd0ef6c61a2..1b30bdf230ec127b8af67e203f0bc4dd4f0fb468 100644 (file)
@@ -316,7 +316,7 @@ pub fn opt_count(&self, nm: &str) -> uint {
     /// Returns true if any of several options were matched.
     pub fn opts_present(&self, names: &[String]) -> bool {
         for nm in names {
-            match find_opt(self.opts.as_slice(), Name::from_str(&nm[])) {
+            match find_opt(&self.opts, Name::from_str(&**nm)) {
                 Some(id) if !self.vals[id].is_empty() => return true,
                 _ => (),
             };
@@ -627,7 +627,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
                        interpreted correctly
                     */
 
-                    let opt_id = match find_opt(opts.as_slice(), opt.clone()) {
+                    let opt_id = match find_opt(&opts, opt.clone()) {
                       Some(id) => id,
                       None => return Err(UnrecognizedOption(opt.to_string()))
                     };
@@ -650,7 +650,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
             let mut name_pos = 0;
             for nm in &names {
                 name_pos += 1;
-                let optid = match find_opt(opts.as_slice(), (*nm).clone()) {
+                let optid = match find_opt(&opts, (*nm).clone()) {
                   Some(id) => id,
                   None => return Err(UnrecognizedOption(nm.to_string()))
                 };
@@ -889,7 +889,7 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
         lim = fake_i;
     }
 
-    let mut machine = |&mut: cont: &mut bool, (i, c): (uint, char)| -> bool {
+    let mut machine = |cont: &mut bool, (i, c): (uint, char)| -> bool {
         let whitespace = if c.is_whitespace() { Ws }       else { Cr };
         let limit      = if (i - slice_start + 1) <= lim  { UnderLim } else { OverLim };
 
@@ -981,7 +981,7 @@ mod tests {
     fn test_reqopt() {
         let long_args = vec!("--test=20".to_string());
         let opts = vec!(reqopt("t", "test", "testing", "TEST"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
@@ -992,7 +992,7 @@ fn test_reqopt() {
           _ => { 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()) {
+        match getopts(&short_args, &opts) {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
             assert_eq!(m.opt_str("test").unwrap(), "20");
@@ -1007,7 +1007,7 @@ fn test_reqopt() {
     fn test_reqopt_missing() {
         let args = vec!("blah".to_string());
         let opts = vec!(reqopt("t", "test", "testing", "TEST"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Err(OptionMissing(_)) => {},
           _ => panic!()
@@ -1018,13 +1018,13 @@ fn test_reqopt_missing() {
     fn test_reqopt_no_arg() {
         let long_args = vec!("--test".to_string());
         let opts = vec!(reqopt("t", "test", "testing", "TEST"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Err(ArgumentMissing(_)) => {},
           _ => panic!()
         }
         let short_args = vec!("-t".to_string());
-        match getopts(short_args.as_slice(), opts.as_slice()) {
+        match getopts(&short_args, &opts) {
           Err(ArgumentMissing(_)) => {},
           _ => panic!()
         }
@@ -1034,7 +1034,7 @@ fn test_reqopt_no_arg() {
     fn test_reqopt_multi() {
         let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string());
         let opts = vec!(reqopt("t", "test", "testing", "TEST"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Err(OptionDuplicated(_)) => {},
           _ => panic!()
@@ -1046,7 +1046,7 @@ fn test_reqopt_multi() {
     fn test_optopt() {
         let long_args = vec!("--test=20".to_string());
         let opts = vec!(optopt("t", "test", "testing", "TEST"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
@@ -1057,7 +1057,7 @@ fn test_optopt() {
           _ => panic!()
         }
         let short_args = vec!("-t".to_string(), "20".to_string());
-        match getopts(short_args.as_slice(), opts.as_slice()) {
+        match getopts(&short_args, &opts) {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
             assert_eq!(m.opt_str("test").unwrap(), "20");
@@ -1072,7 +1072,7 @@ fn test_optopt() {
     fn test_optopt_missing() {
         let args = vec!("blah".to_string());
         let opts = vec!(optopt("t", "test", "testing", "TEST"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert!(!m.opt_present("test"));
@@ -1086,13 +1086,13 @@ fn test_optopt_missing() {
     fn test_optopt_no_arg() {
         let long_args = vec!("--test".to_string());
         let opts = vec!(optopt("t", "test", "testing", "TEST"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Err(ArgumentMissing(_)) => {},
           _ => panic!()
         }
         let short_args = vec!("-t".to_string());
-        match getopts(short_args.as_slice(), opts.as_slice()) {
+        match getopts(&short_args, &opts) {
           Err(ArgumentMissing(_)) => {},
           _ => panic!()
         }
@@ -1102,7 +1102,7 @@ fn test_optopt_no_arg() {
     fn test_optopt_multi() {
         let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string());
         let opts = vec!(optopt("t", "test", "testing", "TEST"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Err(OptionDuplicated(_)) => {},
           _ => panic!()
@@ -1114,7 +1114,7 @@ fn test_optopt_multi() {
     fn test_optflag() {
         let long_args = vec!("--test".to_string());
         let opts = vec!(optflag("t", "test", "testing"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
@@ -1123,7 +1123,7 @@ fn test_optflag() {
           _ => panic!()
         }
         let short_args = vec!("-t".to_string());
-        match getopts(short_args.as_slice(), opts.as_slice()) {
+        match getopts(&short_args, &opts) {
           Ok(ref m) => {
             assert!(m.opt_present("test"));
             assert!(m.opt_present("t"));
@@ -1136,7 +1136,7 @@ fn test_optflag() {
     fn test_optflag_missing() {
         let args = vec!("blah".to_string());
         let opts = vec!(optflag("t", "test", "testing"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert!(!m.opt_present("test"));
@@ -1150,7 +1150,7 @@ fn test_optflag_missing() {
     fn test_optflag_long_arg() {
         let args = vec!("--test=20".to_string());
         let opts = vec!(optflag("t", "test", "testing"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Err(UnexpectedArgument(_)) => {},
           _ => panic!()
@@ -1161,7 +1161,7 @@ fn test_optflag_long_arg() {
     fn test_optflag_multi() {
         let args = vec!("--test".to_string(), "-t".to_string());
         let opts = vec!(optflag("t", "test", "testing"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Err(OptionDuplicated(_)) => {},
           _ => panic!()
@@ -1172,7 +1172,7 @@ fn test_optflag_multi() {
     fn test_optflag_short_arg() {
         let args = vec!("-t".to_string(), "20".to_string());
         let opts = vec!(optflag("t", "test", "testing"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             // The next variable after the flag is just a free argument
@@ -1188,7 +1188,7 @@ fn test_optflag_short_arg() {
     fn test_optflagmulti_short1() {
         let args = vec!("-v".to_string());
         let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("v"), 1);
@@ -1201,7 +1201,7 @@ fn test_optflagmulti_short1() {
     fn test_optflagmulti_short2a() {
         let args = vec!("-v".to_string(), "-v".to_string());
         let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("v"), 2);
@@ -1214,7 +1214,7 @@ fn test_optflagmulti_short2a() {
     fn test_optflagmulti_short2b() {
         let args = vec!("-vv".to_string());
         let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("v"), 2);
@@ -1227,7 +1227,7 @@ fn test_optflagmulti_short2b() {
     fn test_optflagmulti_long1() {
         let args = vec!("--verbose".to_string());
         let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("verbose"), 1);
@@ -1240,7 +1240,7 @@ fn test_optflagmulti_long1() {
     fn test_optflagmulti_long2() {
         let args = vec!("--verbose".to_string(), "--verbose".to_string());
         let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("verbose"), 2);
@@ -1254,7 +1254,7 @@ fn test_optflagmulti_mix() {
         let args = vec!("--verbose".to_string(), "-v".to_string(),
                         "-vv".to_string(), "verbose".to_string());
         let opts = vec!(optflagmulti("v", "verbose", "verbosity"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert_eq!(m.opt_count("verbose"), 4);
@@ -1269,7 +1269,7 @@ fn test_optflagmulti_mix() {
     fn test_optmulti() {
         let long_args = vec!("--test=20".to_string());
         let opts = vec!(optmulti("t", "test", "testing", "TEST"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
@@ -1280,7 +1280,7 @@ fn test_optmulti() {
           _ => panic!()
         }
         let short_args = vec!("-t".to_string(), "20".to_string());
-        match getopts(short_args.as_slice(), opts.as_slice()) {
+        match getopts(&short_args, &opts) {
           Ok(ref m) => {
             assert!((m.opt_present("test")));
             assert_eq!(m.opt_str("test").unwrap(), "20");
@@ -1295,7 +1295,7 @@ fn test_optmulti() {
     fn test_optmulti_missing() {
         let args = vec!("blah".to_string());
         let opts = vec!(optmulti("t", "test", "testing", "TEST"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert!(!m.opt_present("test"));
@@ -1309,13 +1309,13 @@ fn test_optmulti_missing() {
     fn test_optmulti_no_arg() {
         let long_args = vec!("--test".to_string());
         let opts = vec!(optmulti("t", "test", "testing", "TEST"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Err(ArgumentMissing(_)) => {},
           _ => panic!()
         }
         let short_args = vec!("-t".to_string());
-        match getopts(short_args.as_slice(), opts.as_slice()) {
+        match getopts(&short_args, &opts) {
           Err(ArgumentMissing(_)) => {},
           _ => panic!()
         }
@@ -1325,7 +1325,7 @@ fn test_optmulti_no_arg() {
     fn test_optmulti_multi() {
         let args = vec!("--test=20".to_string(), "-t".to_string(), "30".to_string());
         let opts = vec!(optmulti("t", "test", "testing", "TEST"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
               assert!(m.opt_present("test"));
@@ -1344,13 +1344,13 @@ fn test_optmulti_multi() {
     fn test_unrecognized_option() {
         let long_args = vec!("--untest".to_string());
         let opts = vec!(optmulti("t", "test", "testing", "TEST"));
-        let rs = getopts(long_args.as_slice(), opts.as_slice());
+        let rs = getopts(&long_args, &opts);
         match rs {
           Err(UnrecognizedOption(_)) => {},
           _ => panic!()
         }
         let short_args = vec!("-u".to_string());
-        match getopts(short_args.as_slice(), opts.as_slice()) {
+        match getopts(&short_args, &opts) {
           Err(UnrecognizedOption(_)) => {},
           _ => panic!()
         }
@@ -1383,7 +1383,7 @@ fn test_combined() {
               optmulti("m", "", "mmmmmm", "YUM"),
               optmulti("n", "", "nothing", "NOTHING"),
               optopt("", "notpresent", "nothing to see here", "NOPE"));
-        let rs = getopts(args.as_slice(), opts.as_slice());
+        let rs = getopts(&args, &opts);
         match rs {
           Ok(ref m) => {
             assert!(m.free[0] == "prog");
@@ -1412,8 +1412,7 @@ fn test_multi() {
                      optopt("f", "", "flag", "FLAG"));
 
         let args_single = vec!("-e".to_string(), "foo".to_string());
-        let matches_single = &match getopts(args_single.as_slice(),
-                                            opts.as_slice()) {
+        let matches_single = &match getopts(&args_single, &opts) {
           result::Result::Ok(m) => m,
           result::Result::Err(_) => panic!()
         };
@@ -1432,8 +1431,7 @@ fn test_multi() {
 
         let args_both = vec!("-e".to_string(), "foo".to_string(), "--encrypt".to_string(),
                              "foo".to_string());
-        let matches_both = &match getopts(args_both.as_slice(),
-                                          opts.as_slice()) {
+        let matches_both = &match getopts(&args_both, &opts) {
           result::Result::Ok(m) => m,
           result::Result::Err(_) => panic!()
         };
@@ -1458,7 +1456,7 @@ fn test_nospace() {
         let args = vec!("-Lfoo".to_string(), "-M.".to_string());
         let opts = vec!(optmulti("L", "", "library directory", "LIB"),
                      optmulti("M", "", "something", "MMMM"));
-        let matches = &match getopts(args.as_slice(), opts.as_slice()) {
+        let matches = &match getopts(&args, &opts) {
           result::Result::Ok(m) => m,
           result::Result::Err(_) => panic!()
         };
@@ -1474,7 +1472,7 @@ fn test_nospace_conflict() {
         let args = vec!("-vvLverbose".to_string(), "-v".to_string() );
         let opts = vec!(optmulti("L", "", "library directory", "LIB"),
                      optflagmulti("v", "verbose", "Verbose"));
-        let matches = &match getopts(args.as_slice(), opts.as_slice()) {
+        let matches = &match getopts(&args, &opts) {
           result::Result::Ok(m) => m,
           result::Result::Err(e) => panic!( "{}", e )
         };
@@ -1508,7 +1506,7 @@ fn test_aliases_long_and_short() {
 
         let args = vec!("-a".to_string(), "--apple".to_string(), "-a".to_string());
 
-        let matches = getopts(args.as_slice(), opts.as_slice()).unwrap();
+        let matches = getopts(&args, &opts).unwrap();
         assert_eq!(3, matches.opt_count("a"));
         assert_eq!(3, matches.opt_count("apple"));
     }
@@ -1535,7 +1533,7 @@ fn test_usage() {
     -l VAL              Desc
 ";
 
-        let generated_usage = usage("Usage: fruits", optgroups.as_slice());
+        let generated_usage = usage("Usage: fruits", &optgroups);
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", generated_usage);
@@ -1562,7 +1560,7 @@ fn test_usage_description_wrapping() {
                         wrapped..+..
 ";
 
-        let usage = usage("Usage: fruits", optgroups.as_slice());
+        let usage = usage("Usage: fruits", &optgroups);
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", usage);
@@ -1588,7 +1586,7 @@ fn test_usage_description_multibyte_handling() {
                         some parts of Europe.
 ";
 
-        let usage = usage("Usage: fruits", optgroups.as_slice());
+        let usage = usage("Usage: fruits", &optgroups);
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", usage);
@@ -1606,7 +1604,7 @@ fn test_short_usage() {
             optmulti("l", "", "Desc", "VAL"));
 
         let expected = "Usage: fruits -b VAL [-a VAL] [-k] [-p [VAL]] [-l VAL]..".to_string();
-        let generated_usage = short_usage("fruits", optgroups.as_slice());
+        let generated_usage = short_usage("fruits", &optgroups);
 
         debug!("expected: <<{}>>", expected);
         debug!("generated: <<{}>>", generated_usage);
index b33ca3fd7ec01d35639341adc458458629b5351e..069e4ccf41d7db0a4961a1517fa44b71ef3cc7c0 100644 (file)
@@ -565,7 +565,7 @@ fn indent<W:Writer>(w: &mut W) -> old_io::IoResult<()> {
         } else {
             let escaped = g.node_label(n).escape();
             try!(writeln(w, &[id.as_slice(),
-                              "[label=\"", escaped.as_slice(), "\"];"]));
+                              "[label=\"", &escaped, "\"];"]));
         }
     }
 
@@ -582,7 +582,7 @@ fn indent<W:Writer>(w: &mut W) -> old_io::IoResult<()> {
         } else {
             try!(writeln(w, &[source_id.as_slice(),
                               " -> ", target_id.as_slice(),
-                              "[label=\"", escaped_label.as_slice(), "\"];"]));
+                              "[label=\"", &escaped_label, "\"];"]));
         }
     }
 
@@ -746,7 +746,7 @@ fn target(&'a self, edge: & &'a Edge) -> Node {
     fn test_input(g: LabelledGraph) -> IoResult<String> {
         let mut writer = Vec::new();
         render(&g, &mut writer).unwrap();
-        (&mut writer.as_slice()).read_to_string()
+        (&mut &*writer).read_to_string()
     }
 
     // All of the tests use raw-strings as the format for the expected outputs,
@@ -858,7 +858,7 @@ fn left_aligned_text() {
                  edge(1, 3, ";"),    edge(2, 3, ";"   )));
 
         render(&g, &mut writer).unwrap();
-        let r = (&mut writer.as_slice()).read_to_string();
+        let r = (&mut &*writer).read_to_string();
 
         assert_eq!(r.unwrap(),
 r#"digraph syntax_tree {
index 34216518c21d2073bb61909101eae42b6c089c69..15f50188919b02d8060ddd41f18e54af6b705eb7 100644 (file)
@@ -428,7 +428,7 @@ fn init() {
         DIRECTIVES = mem::transmute(box directives);
 
         // Schedule the cleanup for the globals for when the runtime exits.
-        rt::at_exit(move |:| {
+        rt::at_exit(move || {
             assert!(!DIRECTIVES.is_null());
             let _directives: Box<Vec<directive::LogDirective>> =
                 mem::transmute(DIRECTIVES);
index 9f44f9debf6e2e9fb362b88c4f6903cbbf72036c..2673649f3440cc9170cff3d79e4d0cd556d418b8 100644 (file)
@@ -213,8 +213,8 @@ mod test {
     #[test]
     fn test_rng_rand_seeded() {
         let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
-        let mut ra: ChaChaRng = SeedableRng::from_seed(s.as_slice());
-        let mut rb: ChaChaRng = SeedableRng::from_seed(s.as_slice());
+        let mut ra: ChaChaRng = SeedableRng::from_seed(&*s);
+        let mut rb: ChaChaRng = SeedableRng::from_seed(&*s);
         assert!(order::equals(ra.gen_ascii_chars().take(100),
                               rb.gen_ascii_chars().take(100)));
     }
@@ -231,10 +231,10 @@ fn test_rng_seeded() {
     #[test]
     fn test_rng_reseed() {
         let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
-        let mut r: ChaChaRng = SeedableRng::from_seed(s.as_slice());
+        let mut r: ChaChaRng = SeedableRng::from_seed(&*s);
         let string1: String = r.gen_ascii_chars().take(100).collect();
 
-        r.reseed(s.as_slice());
+        r.reseed(&s);
 
         let string2: String = r.gen_ascii_chars().take(100).collect();
         assert_eq!(string1, string2);
index 180248aa1560a5e1d20bbf63b47a7b812672d922..d1d24cea8714e7c1b4fe544c9dfaf363b9903cb7 100644 (file)
@@ -300,7 +300,7 @@ fn test_weighted_choice() {
         macro_rules! t {
             ($items:expr, $expected:expr) => {{
                 let mut items = $items;
-                let wc = WeightedChoice::new(items.as_mut_slice());
+                let wc = WeightedChoice::new(&mut items);
                 let expected = $expected;
 
                 let mut rng = CountingRng { i: 0 };
index d399c244e83b8fe4ee8367dc2f56ac2f5b6bdcb4..9361cddd2a19db065459caefdedde95d61d8a13e 100644 (file)
@@ -514,16 +514,16 @@ mod test {
     #[test]
     fn test_rng_32_rand_seeded() {
         let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
-        let mut ra: IsaacRng = SeedableRng::from_seed(s.as_slice());
-        let mut rb: IsaacRng = SeedableRng::from_seed(s.as_slice());
+        let mut ra: IsaacRng = SeedableRng::from_seed(&*s);
+        let mut rb: IsaacRng = SeedableRng::from_seed(&*s);
         assert!(order::equals(ra.gen_ascii_chars().take(100),
                               rb.gen_ascii_chars().take(100)));
     }
     #[test]
     fn test_rng_64_rand_seeded() {
         let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
-        let mut ra: Isaac64Rng = SeedableRng::from_seed(s.as_slice());
-        let mut rb: Isaac64Rng = SeedableRng::from_seed(s.as_slice());
+        let mut ra: Isaac64Rng = SeedableRng::from_seed(&*s);
+        let mut rb: Isaac64Rng = SeedableRng::from_seed(&*s);
         assert!(order::equals(ra.gen_ascii_chars().take(100),
                               rb.gen_ascii_chars().take(100)));
     }
@@ -548,10 +548,10 @@ fn test_rng_64_seeded() {
     #[test]
     fn test_rng_32_reseed() {
         let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
-        let mut r: IsaacRng = SeedableRng::from_seed(s.as_slice());
+        let mut r: IsaacRng = SeedableRng::from_seed(&*s);
         let string1: String = r.gen_ascii_chars().take(100).collect();
 
-        r.reseed(s.as_slice());
+        r.reseed(&s);
 
         let string2: String = r.gen_ascii_chars().take(100).collect();
         assert_eq!(string1, string2);
@@ -559,10 +559,10 @@ fn test_rng_32_reseed() {
     #[test]
     fn test_rng_64_reseed() {
         let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
-        let mut r: Isaac64Rng = SeedableRng::from_seed(s.as_slice());
+        let mut r: Isaac64Rng = SeedableRng::from_seed(&*s);
         let string1: String = r.gen_ascii_chars().take(100).collect();
 
-        r.reseed(s.as_slice());
+        r.reseed(&s);
 
         let string2: String = r.gen_ascii_chars().take(100).collect();
         assert_eq!(string1, string2);
index 0627b461fdb0c2bec691da0c28f460cbae6161f2..b18e36da7ea39adde21f7f13436538ff42868a6d 100644 (file)
@@ -504,6 +504,7 @@ mod std {
     pub use core::marker;
     // for-loops
     pub use core::iter;
+    pub use core::ops; // slicing syntax
 }
 
 #[cfg(test)]
index 26c7afc21eb9571dc6bf2485dedbbc1b13d66029..06828911471466d2e1e3eb58786eb04567aacf1a 100644 (file)
@@ -216,7 +216,7 @@ fn test_rng_reseed() {
     #[test]
     fn test_rng_fill_bytes() {
         let mut v = repeat(0u8).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();
-        ::test::rng().fill_bytes(v.as_mut_slice());
+        ::test::rng().fill_bytes(&mut v);
 
         // Sanity test: if we've gotten here, `fill_bytes` has not infinitely
         // recursed.
index fff28a95c4e13eb8d7e7722baeb3dcdd2fd9ebdc..230fda11ab5ac58c9744787fd73a65826485e35c 100644 (file)
@@ -71,7 +71,7 @@ pub fn with_capacity(n: uint) -> SeekableMemWriter {
     /// No method is exposed for acquiring a mutable reference to the buffer
     /// because it could corrupt the state of this `MemWriter`.
     #[inline]
-    pub fn get_ref<'a>(&'a self) -> &'a [u8] { self.buf.as_slice() }
+    pub fn get_ref<'a>(&'a self) -> &'a [u8] { &self.buf }
 
     /// Unwraps this `SeekableMemWriter`, returning the underlying buffer
     #[inline]
@@ -190,7 +190,7 @@ fn do_bench_seekable_mem_writer(b: &mut Bencher, times: uint, len: uint) {
         b.iter(|| {
             let mut wr = SeekableMemWriter::new();
             for _ in 0..times {
-                wr.write(src.as_slice()).unwrap();
+                wr.write(&src).unwrap();
             }
 
             let v = wr.unwrap();
index cf5397de149b7c4029a095160ab89b2e9cd89d93..e204a2a65958f450d6a415ddd582bb17ff700d34 100644 (file)
@@ -1194,7 +1194,7 @@ pub fn vuint_at_A_aligned(b: &mut Bencher) {
         b.iter(|| {
             let mut i = 0;
             while i < data.len() {
-                sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
+                sum += reader::vuint_at(&data, i).unwrap().val;
                 i += 4;
             }
         });
@@ -1212,7 +1212,7 @@ pub fn vuint_at_A_unaligned(b: &mut Bencher) {
         b.iter(|| {
             let mut i = 1;
             while i < data.len() {
-                sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
+                sum += reader::vuint_at(&data, i).unwrap().val;
                 i += 4;
             }
         });
@@ -1231,7 +1231,7 @@ pub fn vuint_at_D_aligned(b: &mut Bencher) {
         b.iter(|| {
             let mut i = 0;
             while i < data.len() {
-                sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
+                sum += reader::vuint_at(&data, i).unwrap().val;
                 i += 4;
             }
         });
@@ -1250,7 +1250,7 @@ pub fn vuint_at_D_unaligned(b: &mut Bencher) {
         b.iter(|| {
             let mut i = 1;
             while i < data.len() {
-                sum += reader::vuint_at(data.as_slice(), i).unwrap().val;
+                sum += reader::vuint_at(&data, i).unwrap().val;
                 i += 4;
             }
         });
index 53054f462c8b6c0cd6eccc16c813a980c97f6638..34565383c5a761bfff06adbeb3cde8b87b010574 100644 (file)
@@ -949,7 +949,7 @@ impl NonSnakeCase {
     fn to_snake_case(mut str: &str) -> String {
         let mut words = vec![];
         // Preserve leading underscores
-        str = str.trim_left_matches(|&mut: c: char| {
+        str = str.trim_left_matches(|c: char| {
             if c == '_' {
                 words.push(String::new());
                 true
@@ -1082,12 +1082,12 @@ fn check_upper_case(cx: &Context, sort: &str, ident: ast::Ident, span: Span) {
                                            .map(|c| c.to_uppercase()).collect();
             if uc != s.get() {
                 cx.span_lint(NON_UPPER_CASE_GLOBALS, span,
-                    format!("{} `{}` should have an upper case name such as `{}`",
-                            sort, s, uc).as_slice());
+                    &format!("{} `{}` should have an upper case name such as `{}`",
+                             sort, s, uc));
             } else {
                 cx.span_lint(NON_UPPER_CASE_GLOBALS, span,
-                    format!("{} `{}` should have an upper case name",
-                            sort, s).as_slice());
+                    &format!("{} `{}` should have an upper case name",
+                             sort, s));
             }
         }
     }
@@ -2084,11 +2084,11 @@ fn get_lints(&self) -> LintArray {
     fn check_item(&mut self, cx: &Context, it: &ast::Item) {
         match it.node {
             ast::ItemFn(..) => {
-                if attr::contains_name(it.attrs.as_slice(), "no_mangle") &&
+                if attr::contains_name(&it.attrs, "no_mangle") &&
                        !cx.exported_items.contains(&it.id) {
                     let msg = format!("function {} is marked #[no_mangle], but not exported",
                                       it.ident);
-                    cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, msg.as_slice());
+                    cx.span_lint(PRIVATE_NO_MANGLE_FNS, it.span, &msg);
                 }
             },
             _ => {},
index 91dba90b0d2e2508d1da2c9e571ca0c7096fd6c1..844ad2be264448120dc072b0b7fa0773e0081152 100644 (file)
@@ -509,8 +509,8 @@ fn with_lint_attrs<F>(&mut self,
                                                       .collect(),
                                 None => {
                                     self.span_lint(builtin::UNKNOWN_LINTS, span,
-                                               format!("unknown `{}` attribute: `{}`",
-                                                       level.as_str(), lint_name).as_slice());
+                                                   &format!("unknown `{}` attribute: `{}`",
+                                                            level.as_str(), lint_name));
                                     continue;
                                 }
                             }
@@ -797,8 +797,8 @@ pub fn check_crate(tcx: &ty::ctxt,
     for (id, v) in &*tcx.sess.lints.borrow() {
         for &(lint, span, ref msg) in v {
             tcx.sess.span_bug(span,
-                              format!("unprocessed lint {} at {}: {}",
-                                      lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice())
+                              &format!("unprocessed lint {} at {}: {}",
+                                       lint.as_str(), tcx.map.node_to_string(*id), *msg))
         }
     }
 
index a787369dc633c35e23b8973dfee31e08222e0838..34bd1724e521b5eed6576c57b57525090c705bfc 100644 (file)
@@ -72,7 +72,7 @@ struct CrateInfo {
 }
 
 pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
-    let err = |&: s: &str| {
+    let err = |s: &str| {
         match (sp, sess) {
             (_, None) => panic!("{}", s),
             (Some(sp), Some(sess)) => sess.span_err(sp, s),
index 619cfc1b52c09b4b96c98684f445b26089be6892..070ab248f24b2169f4f1fb5c26edbbdc7d11f28b 100644 (file)
@@ -59,7 +59,7 @@ pub fn each_child_of_item<F>(cstore: &cstore::CStore,
     F: FnMut(decoder::DefLike, ast::Name, ast::Visibility),
 {
     let crate_data = cstore.get_crate_data(def_id.krate);
-    let get_crate_data = |&mut: cnum| {
+    let get_crate_data = |cnum| {
         cstore.get_crate_data(cnum)
     };
     decoder::each_child_of_item(cstore.intr.clone(),
@@ -76,7 +76,7 @@ pub fn each_top_level_item_of_crate<F>(cstore: &cstore::CStore,
     F: FnMut(decoder::DefLike, ast::Name, ast::Visibility),
 {
     let crate_data = cstore.get_crate_data(cnum);
-    let get_crate_data = |&mut: cnum| {
+    let get_crate_data = |cnum| {
         cstore.get_crate_data(cnum)
     };
     decoder::each_top_level_item_of_crate(cstore.intr.clone(),
@@ -93,7 +93,7 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem>
     // FIXME #1920: This path is not always correct if the crate is not linked
     // into the root namespace.
     let mut r = vec![ast_map::PathMod(token::intern(&cdata.name[]))];
-    r.push_all(path.as_slice());
+    r.push_all(&path);
     r
 }
 
index ccd524a2c03955a950b3929a96dae1659de9fffc..5fb047ea93b602e14a18a5de448555122300df9c 100644 (file)
@@ -1044,7 +1044,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
         encode_name(rbml_w, item.ident.name);
         encode_path(rbml_w, path);
-        encode_attributes(rbml_w, item.attrs.as_slice());
+        encode_attributes(rbml_w, &item.attrs);
         encode_inlined_item(ecx, rbml_w, IIItemRef(item));
         encode_visibility(rbml_w, vis);
         encode_stability(rbml_w, stab);
@@ -1307,7 +1307,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         let trait_def = ty::lookup_trait_def(tcx, def_id);
         encode_unsafety(rbml_w, trait_def.unsafety);
         encode_paren_sugar(rbml_w, trait_def.paren_sugar);
-        encode_associated_type_names(rbml_w, trait_def.associated_type_names.as_slice());
+        encode_associated_type_names(rbml_w, &trait_def.associated_type_names);
         encode_generics(rbml_w, ecx, &trait_def.generics, tag_item_generics);
         encode_trait_ref(rbml_w, ecx, &*trait_def.trait_ref, tag_item_trait_ref);
         encode_name(rbml_w, item.ident.name);
@@ -1409,7 +1409,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
             encode_parent_sort(rbml_w, 't');
 
             let trait_item = &ms[i];
-            let encode_trait_item = |&: rbml_w: &mut Encoder| {
+            let encode_trait_item = |rbml_w: &mut Encoder| {
                 // If this is a static method, we've already
                 // encoded this.
                 if is_nonstatic_method {
index 2fb5a6b64a6520b244f041346fc643b860fa5636..d30df131d4d299da551e99f9545d7ab53ae8d2ed 100644 (file)
@@ -394,8 +394,8 @@ fn find_library_crate(&mut self) -> Option<Library> {
                     file.ends_with(".rlib") {
                 (&file[(rlib_prefix.len()) .. (file.len() - ".rlib".len())],
                  true)
-            } else if file.starts_with(dylib_prefix.as_slice()) &&
-                      file.ends_with(dypair.1.as_slice()) {
+            } else if file.starts_with(&dylib_prefix) &&
+                      file.ends_with(&dypair.1) {
                 (&file[(dylib_prefix.len()) .. (file.len() - dypair.1.len())],
                  false)
             } else {
index 4c0aefaf83d9721863ba1972379c3047b4b7fc18..7cc7e49b6d251a6f04d36588de4a6baef83eb426 100644 (file)
@@ -555,7 +555,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
       'P' => {
           assert_eq!(next(st), '[');
           let trait_ref = parse_trait_ref_(st, conv);
-          let name = token::intern(parse_str(st, ']').as_slice());
+          let name = token::intern(&parse_str(st, ']'));
           return ty::mk_projection(tcx, trait_ref, name);
       }
       'e' => {
@@ -781,7 +781,7 @@ fn parse_projection_predicate_<'a,'tcx, F>(
     ty::ProjectionPredicate {
         projection_ty: ty::ProjectionTy {
             trait_ref: parse_trait_ref_(st, conv),
-            item_name: token::str_to_ident(parse_str(st, '|').as_slice()).name,
+            item_name: token::str_to_ident(&parse_str(st, '|')).name,
         },
         ty: parse_ty_(st, conv),
     }
index 4130195ae40d1fc0d133587e717f8ed115a37975..b0fe743b683792dc358211967b8701db22d6ed00 100644 (file)
@@ -1185,7 +1185,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
         rbml_w.tag(c::tag_table_freevars, |rbml_w| {
             rbml_w.id(id);
             rbml_w.tag(c::tag_table_val, |rbml_w| {
-                rbml_w.emit_from_vec(fv.as_slice(), |rbml_w, fv_entry| {
+                rbml_w.emit_from_vec(fv, |rbml_w, fv_entry| {
                     Ok(encode_freevar_entry(rbml_w, fv_entry))
                 });
             })
index 925bd5b6395beea35e6a2b718cb4410563c69b61..b558f838a51cba5d86f0caed48ddafe6922459d5 100644 (file)
@@ -138,7 +138,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) {
         ast::ExprBlock(ref block) => {
             // Check all statements in the block
             for stmt in &block.stmts {
-                let block_span_err = |&: span|
+                let block_span_err = |span|
                     span_err!(v.tcx.sess, span, E0016,
                               "blocks in constants are limited to items and \
                                tail expressions");
index 38084d1c2c06fe42aa067491284e23e4a7a5707c..418cdf957183f829efdb8d43d3554fe3e8b0d191 100644 (file)
@@ -1024,7 +1024,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
         })
     }
 
-    let check_move = |&: p: &Pat, sub: Option<&Pat>| {
+    let check_move = |p: &Pat, sub: Option<&Pat>| {
         // check legality of moving out of the enum
 
         // x @ Foo(..) is legal, but x @ Foo(y) isn't.
index 8f5906db589003dd27aaa7292e796b6c258e6921..7ba83c62496f368cd8bf6dee9f9071faae273c03 100644 (file)
@@ -310,7 +310,7 @@ pub fn each_bit_for_node<F>(&self, e: EntryOrExit, cfgidx: CFGIndex, f: F) -> bo
             Entry => on_entry,
             Exit => {
                 let mut t = on_entry.to_vec();
-                self.apply_gen_kill(cfgidx, t.as_mut_slice());
+                self.apply_gen_kill(cfgidx, &mut t);
                 temp_bits = t;
                 &temp_bits[]
             }
@@ -405,7 +405,7 @@ pub fn add_kills_from_flow_exits(&mut self, cfg: &cfg::CFG) {
                     Some(cfg_idx) => {
                         let (start, end) = self.compute_id_range(cfg_idx);
                         let kills = &self.kills[start.. end];
-                        if bitwise(orig_kills.as_mut_slice(), kills, &Union) {
+                        if bitwise(&mut orig_kills, kills, &Union) {
                             changed = true;
                         }
                     }
@@ -450,8 +450,8 @@ pub fn propagate(&mut self, cfg: &cfg::CFG, blk: &ast::Block) {
             let mut temp: Vec<_> = repeat(0).take(words_per_id).collect();
             while propcx.changed {
                 propcx.changed = false;
-                propcx.reset(temp.as_mut_slice());
-                propcx.walk_cfg(cfg, temp.as_mut_slice());
+                propcx.reset(&mut temp);
+                propcx.walk_cfg(cfg, &mut temp);
             }
         }
 
index 4478e3270874dc43b8642a64b563f260d40afb68..90d26f0f6bf53e79f7be1560c7a2c7bf8962c6f9 100644 (file)
@@ -287,7 +287,7 @@ fn visit_pat(&mut self, pat: &ast::Pat) {
         let def_map = &self.tcx.def_map;
         match pat.node {
             ast::PatStruct(_, ref fields, _) => {
-                self.handle_field_pattern_match(pat, fields.as_slice());
+                self.handle_field_pattern_match(pat, fields);
             }
             _ if pat_util::pat_is_const(def_map, pat) => {
                 // it might be the only use of a const
@@ -313,7 +313,7 @@ fn visit_item(&mut self, _: &ast::Item) {
 }
 
 fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
-    if attr::contains_name(attrs.as_slice(), "lang") {
+    if attr::contains_name(attrs, "lang") {
         return true;
     }
 
@@ -347,7 +347,7 @@ struct LifeSeeder {
 
 impl<'v> Visitor<'v> for LifeSeeder {
     fn visit_item(&mut self, item: &ast::Item) {
-        let allow_dead_code = has_allow_dead_code_or_lang_attr(item.attrs.as_slice());
+        let allow_dead_code = has_allow_dead_code_or_lang_attr(&item.attrs);
         if allow_dead_code {
             self.worklist.push(item.id);
         }
@@ -376,7 +376,7 @@ fn visit_fn(&mut self, fk: visit::FnKind<'v>,
         // Check for method here because methods are not ast::Item
         match fk {
             visit::FkMethod(_, _, method) => {
-                if has_allow_dead_code_or_lang_attr(method.attrs.as_slice()) {
+                if has_allow_dead_code_or_lang_attr(&method.attrs) {
                     self.worklist.push(id);
                 }
             }
@@ -467,12 +467,12 @@ fn should_warn_about_field(&mut self, node: &ast::StructField_) -> bool {
         is_named
             && !self.symbol_is_live(node.id, None)
             && !is_marker_field
-            && !has_allow_dead_code_or_lang_attr(node.attrs.as_slice())
+            && !has_allow_dead_code_or_lang_attr(&node.attrs)
     }
 
     fn should_warn_about_variant(&mut self, variant: &ast::Variant_) -> bool {
         !self.symbol_is_live(variant.id, None)
-            && !has_allow_dead_code_or_lang_attr(variant.attrs.as_slice())
+            && !has_allow_dead_code_or_lang_attr(&variant.attrs)
     }
 
     // id := node id of an item's definition.
index 24073848edf541eb353b03563a231d3be6e613c8..0ce9db1c80f3f21c4741083a46e983a4bb37ea23 100644 (file)
@@ -56,7 +56,7 @@ pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) {
     }
 
     // If the user wants no main function at all, then stop here.
-    if attr::contains_name(ast_map.krate().attrs.as_slice(), "no_main") {
+    if attr::contains_name(&ast_map.krate().attrs, "no_main") {
         session.entry_type.set(Some(config::EntryNone));
         return
     }
@@ -96,7 +96,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
                 });
             }
 
-            if attr::contains_name(item.attrs.as_slice(), "main") {
+            if attr::contains_name(&item.attrs, "main") {
                 if ctxt.attr_main_fn.is_none() {
                     ctxt.attr_main_fn = Some((item.id, item.span));
                 } else {
@@ -105,7 +105,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext) {
                 }
             }
 
-            if attr::contains_name(item.attrs.as_slice(), "start") {
+            if attr::contains_name(&item.attrs, "start") {
                 if ctxt.start_fn.is_none() {
                     ctxt.start_fn = Some((item.id, item.span));
                 } else {
index 44a816eb2f803c330e7ce9661eae3cd6d4d52a81..5cc7502b5128d3e2674769732670dec36c0ea0c1 100644 (file)
@@ -639,8 +639,7 @@ fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) {
                         None => {
                             self.tcx().sess.span_bug(
                                 callee.span,
-                                format!("unexpected callee type {}",
-                                        callee_ty.repr(self.tcx())).as_slice())
+                                &format!("unexpected callee type {}", callee_ty.repr(self.tcx())))
                         }
                     };
                 match overloaded_call_type {
@@ -1150,7 +1149,7 @@ fn walk_pat(&mut self,
                                 let msg = format!("Pattern has unexpected type: {:?} and type {}",
                                                   def,
                                                   cmt_pat.ty.repr(tcx));
-                                tcx.sess.span_bug(pat.span, msg.as_slice())
+                                tcx.sess.span_bug(pat.span, &msg)
                             }
                         }
 
index aca4b3df453676f7794fff3222cbf8ed707f7d92..989efdd235dffe76fd4cfd545404a46c06618c3d 100644 (file)
@@ -112,14 +112,12 @@ pub fn with_capacity(num_nodes: uint,
 
     #[inline]
     pub fn all_nodes<'a>(&'a self) -> &'a [Node<N>] {
-        let nodes: &'a [Node<N>] = self.nodes.as_slice();
-        nodes
+        &self.nodes
     }
 
     #[inline]
     pub fn all_edges<'a>(&'a self) -> &'a [Edge<E>] {
-        let edges: &'a [Edge<E>] = self.edges.as_slice();
-        edges
+        &self.edges
     }
 
     ///////////////////////////////////////////////////////////////////////////
index 8cb2774f7dff8290ebba032426df06f65eda5b83..daa820f43b57ec186aa67ae79ae2d5d587a14214 100644 (file)
@@ -208,8 +208,8 @@ fn fn_sigs(&self, a: &ty::FnSig<'tcx>, b: &ty::FnSig<'tcx>) -> cres<'tcx, ty::Fn
         }
 
         let inputs = try!(argvecs(self,
-                                  a.inputs.as_slice(),
-                                  b.inputs.as_slice()));
+                                  &a.inputs,
+                                  &b.inputs));
 
         let output = try!(match (a.output, b.output) {
             (ty::FnConverging(a_ty), ty::FnConverging(b_ty)) =>
index 17b62e463dae3d17ec2d3428707e7f9bbdd8fa88..05f0c247a759283bf3d8d618378fd4dec3ec9145 100644 (file)
@@ -1707,7 +1707,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
             Some(node) => match node {
                 ast_map::NodeItem(item) => match item.node {
                     ast::ItemImpl(_, _, ref gen, _, _, _) => {
-                        taken.push_all(gen.lifetimes.as_slice());
+                        taken.push_all(&gen.lifetimes);
                     }
                     _ => ()
                 },
index 8e9911aaefa0a5d3fc673893912c2973a08317e1..1b7e6c33c0575f723d341ec8373005765a0c5147 100644 (file)
@@ -127,10 +127,10 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
             ty::ty_infer(ty::FreshIntTy(c)) => {
                 if c >= self.freshen_count {
                     self.tcx().sess.bug(
-                        format!("Encountered a freshend type with id {} \
-                                 but our counter is only at {}",
-                                c,
-                                self.freshen_count).as_slice());
+                        &format!("Encountered a freshend type with id {} \
+                                  but our counter is only at {}",
+                                 c,
+                                 self.freshen_count));
                 }
                 t
             }
index e4eecd919c82b8245d6dbf106d65316f82062729..4469e27a5b05af10e8e56825a2af5e1d02899e4c 100644 (file)
@@ -133,7 +133,7 @@ fn higher_ranked_lub<T>(&self, a: &Binder<T>, b: &Binder<T>) -> cres<'tcx, Binde
                     self.tcx(),
                     &result0,
                     |r, debruijn| generalize_region(self.infcx(), span, snapshot, debruijn,
-                                                    new_vars.as_slice(), &a_map, r));
+                                                    &new_vars, &a_map, r));
 
             debug!("lub({},{}) = {}",
                    a.repr(self.tcx()),
@@ -227,8 +227,8 @@ fn higher_ranked_glb<T>(&self, a: &Binder<T>, b: &Binder<T>) -> cres<'tcx, Binde
                     self.tcx(),
                     &result0,
                     |r, debruijn| generalize_region(self.infcx(), span, snapshot, debruijn,
-                                                    new_vars.as_slice(),
-                                                    &a_map, a_vars.as_slice(), b_vars.as_slice(),
+                                                    &new_vars,
+                                                    &a_map, &a_vars, &b_vars,
                                                     r));
 
             debug!("glb({},{}) = {}",
index 87ea5436dab6b545662d33faec5b9a0fed89ed7a..6a75b1b0d3d60cdbc988d2ec06572c4569080479 100644 (file)
@@ -71,7 +71,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
 
     let output_path = {
         let output_template = match requested_output {
-            Some(ref s) if s.as_slice() == "help" => {
+            Some(ref s) if &**s == "help" => {
                 static PRINTED_YET: AtomicBool = ATOMIC_BOOL_INIT;
                 if !PRINTED_YET.load(Ordering::SeqCst) {
                     print_help_message();
@@ -92,7 +92,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
             let mut new_str = String::new();
             for c in output_template.chars() {
                 if c == '%' {
-                    new_str.push_str(subject_node.to_string().as_slice());
+                    new_str.push_str(&subject_node.to_string());
                 } else {
                     new_str.push(c);
                 }
@@ -104,11 +104,11 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
     };
 
     let constraints = &*region_vars.constraints.borrow();
-    match dump_region_constraints_to(tcx, constraints, output_path.as_slice()) {
+    match dump_region_constraints_to(tcx, constraints, &output_path) {
         Ok(()) => {}
         Err(e) => {
             let msg = format!("io error dumping region constraints: {}", e);
-            region_vars.tcx.sess.err(msg.as_slice())
+            region_vars.tcx.sess.err(&msg)
         }
     }
 }
@@ -135,7 +135,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
         let mut i = 0;
         let mut node_ids = FnvHashMap();
         {
-            let mut add_node = |&mut : node| {
+            let mut add_node = |node| {
                 if let Vacant(e) = node_ids.entry(node) {
                     e.insert(i);
                     i += 1;
@@ -157,7 +157,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
 
 impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
     fn graph_id(&self) -> dot::Id {
-        dot::Id::new(self.graph_name.as_slice()).ok().unwrap()
+        dot::Id::new(&*self.graph_name).ok().unwrap()
     }
     fn node_id(&self, n: &Node) -> dot::Id {
         dot::Id::new(format!("node_{}", self.node_ids.get(n).unwrap())).ok().unwrap()
index 919ea0a25202c5ed5a4f1246e2d2f4e1e07f1b4c..a5c40cac9e504d9563c473e93656922277305669 100644 (file)
@@ -973,8 +973,8 @@ fn infer_variable_values(&self,
         debug!("----() End constraint listing {:?}---", self.dump_constraints());
         graphviz::maybe_print_constraints_for(self, subject);
 
-        self.expansion(var_data.as_mut_slice());
-        self.contraction(var_data.as_mut_slice());
+        self.expansion(&mut var_data);
+        self.contraction(&mut var_data);
         let values =
             self.extract_values_and_collect_conflicts(&var_data[],
                                                       errors);
@@ -1303,12 +1303,12 @@ fn extract_values_and_collect_conflicts(
                     match var_data[idx].classification {
                         Expanding => {
                             self.collect_error_for_expanding_node(
-                                graph, var_data, dup_vec.as_mut_slice(),
+                                graph, var_data, &mut dup_vec,
                                 node_vid, errors);
                         }
                         Contracting => {
                             self.collect_error_for_contracting_node(
-                                graph, var_data, dup_vec.as_mut_slice(),
+                                graph, var_data, &mut dup_vec,
                                 node_vid, errors);
                         }
                     }
index d9b90c1935a396058540d43958e475542b5300d7..8a293a67727787ff73b5439acaa83dc22285e46e 100644 (file)
@@ -147,7 +147,7 @@ struct LanguageItemCollector<'a> {
 
 impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> {
     fn visit_item(&mut self, item: &ast::Item) {
-        match extract(item.attrs.as_slice()) {
+        match extract(&item.attrs) {
             Some(value) => {
                 let item_index = self.item_refs.get(value.get()).map(|x| *x);
 
index 87d386d94c97270c3fc4a75af0a6d60f2c469a2d..e8215eb5660c0399edea4958a5f6e1482be60acd 100644 (file)
@@ -666,7 +666,7 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &ast::Expr) {
 
     {
         let region_maps = &mut visitor.region_maps;
-        let terminating = |&: id| {
+        let terminating = |id| {
             let scope = CodeExtent::from_node_id(id);
             region_maps.mark_as_terminating_scope(scope)
         };
index 365355c4a2a0b3db38fd2594d0742d208c445cac..5e27023e026fbc7152401ecec9649e3281c673e5 100644 (file)
@@ -456,13 +456,13 @@ fn check_lifetime_def_for_shadowing(&self,
                     if let Some((_, lifetime_def)) = search_lifetimes(lifetimes, lifetime) {
                         self.sess.span_warn(
                             lifetime.span,
-                            format!("lifetime name `{}` shadows another \
-                                    lifetime name that is already in scope",
-                                    token::get_name(lifetime.name)).as_slice());
+                            &format!("lifetime name `{}` shadows another \
+                                     lifetime name that is already in scope",
+                                     token::get_name(lifetime.name)));
                         self.sess.span_note(
                             lifetime_def.span,
-                            format!("shadowed lifetime `{}` declared here",
-                                    token::get_name(lifetime.name)).as_slice());
+                            &format!("shadowed lifetime `{}` declared here",
+                                     token::get_name(lifetime.name)));
                         self.sess.span_note(
                             lifetime.span,
                             "shadowed lifetimes are deprecated \
index 3304bd4ae2952226f0fd3f0769280562e7a18300..dfbd11957da4409193b61127722fccdb67410535 100644 (file)
@@ -57,7 +57,7 @@ fn annotate<F>(&mut self, id: NodeId, use_parent: bool,
                    attrs: &Vec<Attribute>, item_sp: Span, f: F, required: bool) where
         F: FnOnce(&mut Annotator),
     {
-        match attr::find_stability(self.sess.diagnostic(), attrs.as_slice(), item_sp) {
+        match attr::find_stability(self.sess.diagnostic(), attrs, item_sp) {
             Some(stab) => {
                 self.index.local.insert(id, stab.clone());
 
index eb6bc4c38353a43e05d8107cc83c4892ef524df0..8cb0447e732477343128db81a7878b185687031c 100644 (file)
@@ -406,7 +406,7 @@ pub fn iter_enumerated<'a>(&'a self) -> EnumeratedItems<'a,T> {
     }
 
     pub fn as_slice(&self) -> &[T] {
-        self.content.as_slice()
+        &self.content
     }
 
     pub fn into_vec(self) -> Vec<T> {
index 8ce4e38896ecd2502726d577516e088af7052623..d69f340ca1712bb8c8c0d7fc3c91770dccf1ca96 100644 (file)
@@ -24,7 +24,7 @@ fn clone_slice<T:Clone>(x: &[T]) -> Vec<T> { ... }
 
 and then a call to that function:
 
-    let v: Vec<int> = clone_slice([1, 2, 3].as_slice())
+    let v: Vec<int> = clone_slice([1, 2, 3])
 
 it is the job of trait resolution to figure out (in which case)
 whether there exists an impl of `int : Clone`
index b8886fa65baa8c8db2e1d45be14068d364a30d9f..a1f3737cbb20826268230767dee6ac7cc62913a5 100644 (file)
@@ -93,7 +93,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
                         Piece::String(s) => Some(s),
                         Piece::NextArgument(a) => match a.position {
                             Position::ArgumentNamed(s) => match generic_map.get(s) {
-                                Some(val) => Some(val.as_slice()),
+                                Some(val) => Some(val),
                                 None => {
                                     span_err!(infcx.tcx.sess, err_sp, E0272,
                                                    "the #[rustc_on_unimplemented] \
@@ -181,7 +181,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
                                                                           obligation.cause.span);
                                 if let Some(s) = custom_note {
                                     infcx.tcx.sess.span_note(obligation.cause.span,
-                                                             s.as_slice());
+                                                             &s);
                                 }
                             }
                         }
@@ -289,12 +289,12 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
                 // Ambiguity. Coherence should have reported an error.
                 infcx.tcx.sess.span_bug(
                     obligation.cause.span,
-                    format!(
+                    &format!(
                         "coherence failed to report ambiguity: \
                          cannot locate the impl of the trait `{}` for \
                          the type `{}`",
                         trait_ref.user_string(infcx.tcx),
-                        self_ty.user_string(infcx.tcx)).as_slice());
+                        self_ty.user_string(infcx.tcx)));
             }
         }
 
@@ -330,14 +330,14 @@ fn note_obligation_cause_code<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
             let item_name = ty::item_path_str(tcx, item_def_id);
             tcx.sess.span_note(
                 cause_span,
-                format!("required by `{}`", item_name).as_slice());
+                &format!("required by `{}`", item_name));
         }
         ObligationCauseCode::ObjectCastObligation(object_ty) => {
             tcx.sess.span_note(
                 cause_span,
-                format!(
+                &format!(
                     "required for the cast to the object type `{}`",
-                    infcx.ty_to_string(object_ty)).as_slice());
+                    infcx.ty_to_string(object_ty)));
         }
         ObligationCauseCode::RepeatVec => {
             tcx.sess.span_note(
index 8adcd256ccebcccc825e70aa72fa7dee0b608918..07c7453783d9561ccef45ca8d3f12612968b9629 100644 (file)
@@ -180,7 +180,7 @@ pub fn region_obligations(&self,
     {
         match self.region_obligations.get(&body_id) {
             None => Default::default(),
-            Some(vec) => vec.as_slice(),
+            Some(vec) => vec,
         }
     }
 
index c2a451b405bb5008018d635a94662460178a746c..9d3ad28e6138b574e69149333b64f552b7c9a81a 100644 (file)
@@ -605,8 +605,8 @@ fn assemble_candidates_from_object_type<'cx,'tcx>(
         _ => {
             selcx.tcx().sess.span_bug(
                 obligation.cause.span,
-                format!("assemble_candidates_from_object_type called with non-object: {}",
-                        object_ty.repr(selcx.tcx())).as_slice());
+                &format!("assemble_candidates_from_object_type called with non-object: {}",
+                         object_ty.repr(selcx.tcx())));
         }
     };
     let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty);
@@ -693,8 +693,8 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
             // These traits have no associated types.
             selcx.tcx().sess.span_bug(
                 obligation.cause.span,
-                format!("Cannot project an associated type from `{}`",
-                        vtable.repr(selcx.tcx())).as_slice());
+                &format!("Cannot project an associated type from `{}`",
+                         vtable.repr(selcx.tcx())));
         }
     }
 
@@ -813,10 +813,10 @@ fn confirm_param_env_candidate<'cx,'tcx>(
         Err(e) => {
             selcx.tcx().sess.span_bug(
                 obligation.cause.span,
-                format!("Failed to unify `{}` and `{}` in projection: {}",
-                        obligation.repr(selcx.tcx()),
-                        projection.repr(selcx.tcx()),
-                        ty::type_err_to_str(selcx.tcx(), &e)).as_slice());
+                &format!("Failed to unify `{}` and `{}` in projection: {}",
+                         obligation.repr(selcx.tcx()),
+                         projection.repr(selcx.tcx()),
+                         ty::type_err_to_str(selcx.tcx(), &e)));
         }
     }
 
index b8af91add9efb56d6485cfcf145d88b39e873d85..2ea16d55343350459975e1b7a0095c7f7ac8ddc2 100644 (file)
@@ -933,9 +933,9 @@ fn match_projection_obligation_against_bounds_from_trait(
             _ => {
                 self.tcx().sess.span_bug(
                     obligation.cause.span,
-                    format!("match_projection_obligation_against_bounds_from_trait() called \
-                             but self-ty not a projection: {}",
-                            skol_trait_predicate.trait_ref.self_ty().repr(self.tcx())).as_slice());
+                    &format!("match_projection_obligation_against_bounds_from_trait() called \
+                              but self-ty not a projection: {}",
+                             skol_trait_predicate.trait_ref.self_ty().repr(self.tcx())));
             }
         };
         debug!("match_projection_obligation_against_bounds_from_trait: \
@@ -1787,9 +1787,9 @@ fn confirm_param_candidate(&mut self,
             Ok(obligations) => obligations,
             Err(()) => {
                 self.tcx().sess.bug(
-                    format!("Where clause `{}` was applicable to `{}` but now is not",
-                            param.repr(self.tcx()),
-                            obligation.repr(self.tcx())).as_slice());
+                    &format!("Where clause `{}` was applicable to `{}` but now is not",
+                             param.repr(self.tcx()),
+                             obligation.repr(self.tcx())));
             }
         }
     }
@@ -1953,9 +1953,9 @@ fn confirm_object_candidate(&mut self,
             Some(r) => r,
             None => {
                 self.tcx().sess.span_bug(obligation.cause.span,
-                                         format!("unable to upcast from {} to {}",
-                                                 poly_trait_ref.repr(self.tcx()),
-                                                 obligation_def_id.repr(self.tcx())).as_slice());
+                                         &format!("unable to upcast from {} to {}",
+                                                  poly_trait_ref.repr(self.tcx()),
+                                                  obligation_def_id.repr(self.tcx())));
             }
         };
 
index 45ce692bb076354e7bbb86bc891bc36d77fb4a05..5180b8379eace8c8305070d2762698d57c595fac 100644 (file)
@@ -279,7 +279,7 @@ pub fn trait_ref_for_builtin_bound<'tcx>(
             }))
         }
         Err(e) => {
-            tcx.sess.err(e.as_slice());
+            tcx.sess.err(&e);
             Err(ErrorReported)
         }
     }
index a772555d8fcb6eabb9821a8ab9d8239254e5eec0..6964a0b9db8178af441144882a088286f6d66537 100644 (file)
@@ -2793,7 +2793,7 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
                       bounds: ExistentialBounds<'tcx>)
                       -> Ty<'tcx>
 {
-    assert!(bound_list_is_sorted(bounds.projection_bounds.as_slice()));
+    assert!(bound_list_is_sorted(&bounds.projection_bounds));
 
     let inner = box TyTrait {
         principal: principal,
@@ -3406,8 +3406,8 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
                 // FIXME(#14449): `borrowed_contents` below assumes `&mut` closure.
                 let param_env = ty::empty_parameter_environment(cx);
                 let upvars = closure_upvars(&param_env, did, substs).unwrap();
-                TypeContents::union(upvars.as_slice(),
-                                    |f| tc_ty(cx, f.ty, cache))
+                TypeContents::union(&upvars,
+                                    |f| tc_ty(cx, &f.ty, cache))
                     | borrowed_contents(*r, MutMutable)
             }
 
@@ -3672,8 +3672,7 @@ fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
             ty_closure(..) => {
                 // this check is run on type definitions, so we don't expect to see
                 // inference by-products or closure types
-                cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
-                                    ty).as_slice())
+                cx.sess.bug(&format!("requires check invoked on inapplicable type: {:?}", ty))
             }
 
             ty_tup(ref ts) => {
@@ -3766,8 +3765,7 @@ fn are_inner_types_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
             ty_closure(..) => {
                 // this check is run on type definitions, so we don't expect
                 // to see closure types
-                cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
-                                    ty).as_slice())
+                cx.sess.bug(&format!("requires check invoked on inapplicable type: {:?}", ty))
             }
             _ => Representable,
         }
@@ -6087,7 +6085,7 @@ fn helper<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh,
         macro_rules! byte { ($b:expr) => { ($b as u8).hash(state) } }
         macro_rules! hash { ($e:expr) => { $e.hash(state) }  }
 
-        let region = |&: state: &mut SipHasher, r: Region| {
+        let region = |state: &mut SipHasher, r: Region| {
             match r {
                 ReStatic => {}
                 ReLateBound(db, BrAnon(i)) => {
@@ -6104,7 +6102,7 @@ macro_rules! hash { ($e:expr) => { $e.hash(state) }  }
                 }
             }
         };
-        let did = |&: state: &mut SipHasher, did: DefId| {
+        let did = |state: &mut SipHasher, did: DefId| {
             let h = if ast_util::is_local(did) {
                 svh.clone()
             } else {
@@ -6113,10 +6111,10 @@ macro_rules! hash { ($e:expr) => { $e.hash(state) }  }
             h.as_str().hash(state);
             did.node.hash(state);
         };
-        let mt = |&: state: &mut SipHasher, mt: mt| {
+        let mt = |state: &mut SipHasher, mt: mt| {
             mt.mutbl.hash(state);
         };
-        let fn_sig = |&: state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
+        let fn_sig = |state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
             let sig = anonymize_late_bound_regions(tcx, sig).0;
             for a in &sig.inputs { helper(tcx, *a, svh, state); }
             if let ty::FnConverging(output) = sig.output {
@@ -6365,9 +6363,9 @@ fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, predicates: &[ty::Predicate<
                         _ => {
                             // All named regions are instantiated with free regions.
                             tcx.sess.bug(
-                                format!("record_region_bounds: non free region: {} / {}",
-                                        r_a.repr(tcx),
-                                        r_b.repr(tcx)).as_slice());
+                                &format!("record_region_bounds: non free region: {} / {}",
+                                         r_a.repr(tcx),
+                                         r_b.repr(tcx)));
                         }
                     }
                 }
index a9121951460f54c30ad48196e201b24d347e30e7..40dfd479364a6c18c76f960518bef48a3e87777b 100644 (file)
@@ -39,9 +39,9 @@ fn push_subtypes(&mut self, parent_ty: Ty<'tcx>) {
             }
             ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => {
                 self.push_reversed(principal.substs().types.as_slice());
-                self.push_reversed(bounds.projection_bounds.iter().map(|pred| {
+                self.push_reversed(&bounds.projection_bounds.iter().map(|pred| {
                     pred.0.ty
-                }).collect::<Vec<_>>().as_slice());
+                }).collect::<Vec<_>>());
             }
             ty::ty_enum(_, ref substs) |
             ty::ty_struct(_, ref substs) |
@@ -49,7 +49,7 @@ fn push_subtypes(&mut self, parent_ty: Ty<'tcx>) {
                 self.push_reversed(substs.types.as_slice());
             }
             ty::ty_tup(ref ts) => {
-                self.push_reversed(ts.as_slice());
+                self.push_reversed(ts);
             }
             ty::ty_bare_fn(_, ref ft) => {
                 self.push_sig_subtypes(&ft.sig);
@@ -62,7 +62,7 @@ fn push_sig_subtypes(&mut self, sig: &ty::PolyFnSig<'tcx>) {
             ty::FnConverging(output) => { self.stack.push(output); }
             ty::FnDiverging => { }
         }
-        self.push_reversed(sig.0.inputs.as_slice());
+        self.push_reversed(&sig.0.inputs);
     }
 
     fn push_reversed(&mut self, tys: &[Ty<'tcx>]) {
index 425c9a4c9f7748dd8c01406559d1727e34da3658..b23d05ca64cf94c35d9b73e1eab8d0ab3aa0b38e 100644 (file)
@@ -85,8 +85,8 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
 
     $(
         if missing.contains(&lang_items::$item) && items.$name().is_none() {
-            sess.err(format!("language item required, but not found: `{}`",
-                             stringify!($name)).as_slice());
+            sess.err(&format!("language item required, but not found: `{}`",
+                              stringify!($name)));
 
         }
     )*
@@ -108,7 +108,7 @@ fn register(&mut self, name: &str, span: Span) {
 
 impl<'a, 'v> Visitor<'v> for Context<'a> {
     fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
-        match lang_items::extract(i.attrs.as_slice()) {
+        match lang_items::extract(&i.attrs) {
             None => {}
             Some(lang_item) => self.register(lang_item.get(), i.span),
         }
index 110e672b70f87888484a02c1d07f4cc81c6e73a5..818af33c34d142a4e4650dc57ddf8c961e5d7da8 100644 (file)
@@ -24,7 +24,7 @@ struct RegistrarFinder {
 impl<'v> Visitor<'v> for RegistrarFinder {
     fn visit_item(&mut self, item: &ast::Item) {
         if let ast::ItemFn(..) = item.node {
-            if attr::contains_name(item.attrs.as_slice(),
+            if attr::contains_name(&item.attrs,
                                    "plugin_registrar") {
                 self.registrars.push((item.id, item.span));
             }
index dd0b0a63ced9de64a3b63eddf14ace3d25b26bc6..a7592226fd67b1115a1a178ab9e079f0b8d55797 100644 (file)
@@ -82,8 +82,8 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
     visit::walk_crate(&mut loader, krate);
 
     if let Some(plugins) = addl_plugins {
-        for plugin in &plugins {
-            loader.load_plugin(CrateOrString::Str(plugin.as_slice()),
+        for plugin in plugins {
+            loader.load_plugin(CrateOrString::Str(&plugin),
                                                   None, None, None)
         }
     }
index 8faf81a156445e817d7b5bb5f85e43c1741db0b3..5dfb16528e07d3b28f0a5501fc4a300cfeae1176 100644 (file)
@@ -638,7 +638,7 @@ pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
     let target = match Target::search(&opts.target_triple[]) {
         Ok(t) => t,
         Err(e) => {
-            sp.handler().fatal((format!("Error loading target specification: {}", e)).as_slice());
+            sp.handler().fatal(&format!("Error loading target specification: {}", e));
     }
     };
 
@@ -856,7 +856,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         let unparsed_output_types = matches.opt_strs("emit");
         for unparsed_output_type in &unparsed_output_types {
             for part in unparsed_output_type.split(',') {
-                let output_type = match part.as_slice() {
+                let output_type = match part {
                     "asm" => OutputTypeAssembly,
                     "llvm-ir" => OutputTypeLlvmAssembly,
                     "llvm-bc" => OutputTypeBitcode,
@@ -897,9 +897,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                 Some(2) => Default,
                 Some(3) => Aggressive,
                 Some(arg) => {
-                    early_error(format!("optimization level needs to be \
-                                         between 0-3 (instead was `{}`)",
-                                        arg).as_slice());
+                    early_error(&format!("optimization level needs to be \
+                                          between 0-3 (instead was `{}`)",
+                                         arg));
                 }
             }
         }
@@ -916,9 +916,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             Some(1) => LimitedDebugInfo,
             Some(2) => FullDebugInfo,
             Some(arg) => {
-                early_error(format!("debug info level needs to be between \
-                                     0-2 (instead was `{}`)",
-                                    arg).as_slice());
+                early_error(&format!("debug info level needs to be between \
+                                      0-2 (instead was `{}`)",
+                                     arg));
             }
         }
     };
@@ -937,9 +937,9 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                 "framework" => cstore::NativeFramework,
                 "static" => cstore::NativeStatic,
                 s => {
-                    early_error(format!("unknown library kind `{}`, expected \
-                                         one of dylib, framework, or static",
-                                        s).as_slice());
+                    early_error(&format!("unknown library kind `{}`, expected \
+                                          one of dylib, framework, or static",
+                                         s));
                 }
             };
             return (name.to_string(), kind)
@@ -968,12 +968,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
     let write_dependency_info = (output_types.contains(&OutputTypeDepInfo), None);
 
     let prints = matches.opt_strs("print").into_iter().map(|s| {
-        match s.as_slice() {
+        match &*s {
             "crate-name" => PrintRequest::CrateName,
             "file-names" => PrintRequest::FileNames,
             "sysroot" => PrintRequest::Sysroot,
             req => {
-                early_error(format!("unknown print request `{}`", req).as_slice())
+                early_error(&format!("unknown print request `{}`", req))
             }
         }
     }).collect::<Vec<_>>();
index 07fbecbdebcfc26aff93e7f6a69ab460d8d3ced6..bd44dbe78f5438d8a86cbcad98df0732895df8e1 100644 (file)
@@ -332,7 +332,7 @@ pub fn build_session_(sopts: config::Options,
         Ok(t) => t,
         Err(e) => {
             span_diagnostic.handler()
-                .fatal((format!("Error loading host specification: {}", e)).as_slice());
+                .fatal(&format!("Error loading host specification: {}", e));
     }
     };
     let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
index b77a70f1f5d5a6467378f6262760eee94573d963..d3d0f56c3ce904b7836f4f51ea80c4d4e39d2267 100644 (file)
@@ -187,8 +187,8 @@ pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
 /// ```
 /// pub fn memoized<T: Clone, U: Clone, M: MutableMap<T, U>>(
 ///    cache: &RefCell<M>,
-///    f: &|&: T| -> U
-/// ) -> impl |&: T| -> U {
+///    f: &|T| -> U
+/// ) -> impl |T| -> U {
 /// ```
 /// but currently it is not possible.
 ///
index 458701f2dd7626c2746206c5bccacfb5fa5641bd..d39e1b8977a0efbf52dd616768508d248f17cb00 100644 (file)
@@ -86,7 +86,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
     return match region {
       ReScope(scope) => {
         let new_string;
-        let on_unknown_scope = |&:| {
+        let on_unknown_scope = || {
           (format!("unknown scope: {:?}.  Please report a bug.", scope), None)
         };
         let span = match scope.span(&cx.map) {
@@ -116,7 +116,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
             region::CodeExtent::Remainder(r) => {
                 new_string = format!("block suffix following statement {}",
                                      r.first_statement_index);
-                new_string.as_slice()
+                &*new_string
             }
         };
         explain_span(cx, scope_decorated_tag, span)
@@ -263,7 +263,7 @@ fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>,
         match unsafety {
             ast::Unsafety::Normal => {}
             ast::Unsafety::Unsafe => {
-                s.push_str(unsafety.to_string().as_slice());
+                s.push_str(&unsafety.to_string());
                 s.push(' ');
             }
         };
@@ -315,7 +315,7 @@ fn push_sig_to_string<'tcx>(cx: &ctxt<'tcx>,
             .iter()
             .map(|a| ty_to_string(cx, *a))
             .collect::<Vec<_>>();
-        s.push_str(strs.connect(", ").as_slice());
+        s.push_str(&strs.connect(", "));
         if sig.0.variadic {
             s.push_str(", ...");
         }
@@ -392,7 +392,7 @@ fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
         ty_enum(did, substs) | ty_struct(did, substs) => {
             let base = ty::item_path_str(cx, did);
             let generics = ty::lookup_item_type(cx, did).generics;
-            parameterized(cx, base.as_slice(), substs, &generics, did, &[])
+            parameterized(cx, &base, substs, &generics, did, &[])
         }
         ty_trait(ref data) => {
             data.user_string(cx)
@@ -643,7 +643,7 @@ fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
         let base = ty::item_path_str(tcx, trait_ref.def_id);
         let trait_def = ty::lookup_trait_def(tcx, trait_ref.def_id);
         parameterized(tcx,
-                      base.as_slice(),
+                      &base,
                       trait_ref.substs,
                       &trait_def.generics,
                       trait_ref.def_id,
@@ -780,7 +780,7 @@ fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         let trait_def = ty::lookup_trait_def(tcx, self.def_id);
         format!("TraitRef({}, {})",
                 self.substs.self_ty().repr(tcx),
-                parameterized(tcx, base.as_slice(), self.substs,
+                parameterized(tcx, &base, self.substs,
                               &trait_def.generics, self.def_id, &[]))
     }
 }
@@ -1235,7 +1235,7 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> {
     fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
         let path_str = ty::item_path_str(tcx, self.def_id);
         let trait_def = ty::lookup_trait_def(tcx, self.def_id);
-        parameterized(tcx, path_str.as_slice(), self.substs,
+        parameterized(tcx, &path_str, self.substs,
                       &trait_def.generics, self.def_id, &[])
     }
 }
index 286a3936314a5540500550f99dd8087432f2bf8c..6654a46f7c31b51cdaee38add94af4f904eb793e 100644 (file)
@@ -259,7 +259,7 @@ fn input_str(&mut self, input: &str) {
     /// newly allocated vec of bytes.
     fn result_bytes(&mut self) -> Vec<u8> {
         let mut buf: Vec<u8> = repeat(0u8).take((self.output_bits()+7)/8).collect();
-        self.result(buf.as_mut_slice());
+        self.result(&mut buf);
         buf
     }
 
@@ -560,7 +560,7 @@ fn test_hash<D: Digest>(sh: &mut D, tests: &[Test]) {
         // Test that it works when accepting the message all at once
         for t in tests {
             sh.reset();
-            sh.input_str(t.input.as_slice());
+            sh.input_str(&t.input);
             let out_str = sh.result_str();
             assert!(out_str == t.output_str);
         }
@@ -606,7 +606,7 @@ fn test_sha256() {
 
         let mut sh = box Sha256::new();
 
-        test_hash(&mut *sh, tests.as_slice());
+        test_hash(&mut *sh, &tests);
     }
 
     /// Feed 1,000,000 'a's into the digest with varying input sizes and check that the result is
@@ -630,7 +630,7 @@ fn test_digest_1million_random<D: Digest>(digest: &mut D, blocksize: uint, expec
         let result_str = digest.result_str();
         let result_bytes = digest.result_bytes();
 
-        assert_eq!(expected, result_str.as_slice());
+        assert_eq!(expected, result_str);
 
         let expected_vec: Vec<u8> = expected.from_hex()
                                             .unwrap()
index bffee9d49334da43c3bedcb1d7743a7e66523f1b..afb5c948f188542b20cb63c72c03b15d38d9be0e 100644 (file)
@@ -227,7 +227,7 @@ pub fn from_json(obj: Json) -> Target {
 
         let handler = diagnostic::default_handler(diagnostic::Auto, None, true);
 
-        let get_req_field = |&: name: &str| {
+        let get_req_field = |name: &str| {
             match obj.find(name)
                      .map(|s| s.as_string())
                      .and_then(|os| os.map(|s| s.to_string())) {
index 6f51ba3118278836f7822b13b9c4673300975b20..ecbf3a4366d4a28af28b1dfb7c83fc42db7d94cb 100644 (file)
@@ -43,7 +43,7 @@ enum Fragment {
 
 impl Fragment {
     fn loan_path_repr<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String {
-        let repr = |&: mpi| move_data.path_loan_path(mpi).repr(tcx);
+        let repr = |mpi| move_data.path_loan_path(mpi).repr(tcx);
         match *self {
             Just(mpi) => repr(mpi),
             AllButOneFrom(mpi) => format!("$(allbutone {})", repr(mpi)),
@@ -53,7 +53,7 @@ fn loan_path_repr<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>)
     fn loan_path_user_string<'tcx>(&self,
                                    move_data: &MoveData<'tcx>,
                                    tcx: &ty::ctxt<'tcx>) -> String {
-        let user_string = |&: mpi| move_data.path_loan_path(mpi).user_string(tcx);
+        let user_string = |mpi| move_data.path_loan_path(mpi).user_string(tcx);
         match *self {
             Just(mpi) => user_string(mpi),
             AllButOneFrom(mpi) => format!("$(allbutone {})", user_string(mpi)),
@@ -139,9 +139,9 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
 
     if !span_err && !print { return; }
 
-    let instrument_all_paths = |&: kind, vec_rc: &Vec<MovePathIndex>| {
+    let instrument_all_paths = |kind, vec_rc: &Vec<MovePathIndex>| {
         for (i, mpi) in vec_rc.iter().enumerate() {
-            let render = |&:| this.path_loan_path(*mpi).user_string(tcx);
+            let render = || this.path_loan_path(*mpi).user_string(tcx);
             if span_err {
                 tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())[]);
             }
@@ -151,9 +151,9 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
         }
     };
 
-    let instrument_all_fragments = |&: kind, vec_rc: &Vec<Fragment>| {
+    let instrument_all_fragments = |kind, vec_rc: &Vec<Fragment>| {
         for (i, f) in vec_rc.iter().enumerate() {
-            let render = |&:| f.loan_path_user_string(this, tcx);
+            let render = || f.loan_path_user_string(this, tcx);
             if span_err {
                 tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())[]);
             }
@@ -186,11 +186,11 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
     let mut moved = mem::replace(&mut fragments.moved_leaf_paths, vec![]);
     let mut assigned = mem::replace(&mut fragments.assigned_leaf_paths, vec![]);
 
-    let path_lps = |&: mpis: &[MovePathIndex]| -> Vec<String> {
+    let path_lps = |mpis: &[MovePathIndex]| -> Vec<String> {
         mpis.iter().map(|mpi| this.path_loan_path(*mpi).repr(tcx)).collect()
     };
 
-    let frag_lps = |&: fs: &[Fragment]| -> Vec<String> {
+    let frag_lps = |fs: &[Fragment]| -> Vec<String> {
         fs.iter().map(|f| f.loan_path_repr(this, tcx)).collect()
     };
 
@@ -343,7 +343,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
                                                                         Rc<LoanPath<'tcx>>)>) {
     let parent_ty = parent_lp.to_type();
 
-    let mut add_fragment_sibling_local = |&mut : field_name, variant_did| {
+    let mut add_fragment_sibling_local = |field_name, variant_did| {
         add_fragment_sibling_core(
             this, tcx, gathered_fragments, parent_lp.clone(), mc, field_name, origin_lp,
             variant_did);
index 311229717da1ca23f51a281a71c1e879ec1bc459..ac1e097be6ff23fb780f8b4e946027f1feb5e28d 100644 (file)
@@ -58,7 +58,7 @@ fn restrict(&self,
                 cmt: mc::cmt<'tcx>) -> RestrictionResult<'tcx> {
         debug!("restrict(cmt={})", cmt.repr(self.bccx.tcx));
 
-        let new_lp = |&: v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
+        let new_lp = |v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
 
         match cmt.cat.clone() {
             mc::cat_rvalue(..) => {
index b9d2b9ec263ab450480bf3fa02db5c5505a6dd28..c932d521bbe1bb9dacccfa81feacdeb088fead1f 100644 (file)
@@ -422,7 +422,7 @@ pub fn opt_loan_path<'tcx>(cmt: &mc::cmt<'tcx>) -> Option<Rc<LoanPath<'tcx>>> {
     //! which allows it to share common loan path pieces as it
     //! traverses the CMT.
 
-    let new_lp = |&: v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
+    let new_lp = |v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty));
 
     match cmt.cat {
         mc::cat_rvalue(..) |
@@ -798,8 +798,8 @@ pub fn report_aliasability_violation(&self,
             }
             mc::AliasableClosure(id) => {
                 self.tcx.sess.span_err(span,
-                                       format!("{} in a captured outer \
-                                               variable in an `Fn` closure", prefix).as_slice());
+                                       &format!("{} in a captured outer \
+                                                variable in an `Fn` closure", prefix));
                 if let BorrowViolation(euv::ClosureCapture(_)) = kind {
                     // The aliasability violation with closure captures can
                     // happen for nested closures, so we know the enclosing
index 8b1b156691af7379ae852699a52e19c51eb9450b..56bf3ae7fd5a30ad536bf4d537c8465b93727a68 100644 (file)
@@ -99,7 +99,7 @@ fn build_set<O:DataFlowOperator, F>(&self,
 
     fn dataflow_loans_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
         let dfcx = &self.analysis_data.loans;
-        let loan_index_to_path = |&mut: loan_index| {
+        let loan_index_to_path = |loan_index| {
             let all_loans = &self.analysis_data.all_loans;
             let l: &borrowck::Loan = &all_loans[loan_index];
             l.loan_path()
@@ -109,7 +109,7 @@ fn dataflow_loans_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
 
     fn dataflow_moves_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
         let dfcx = &self.analysis_data.move_data.dfcx_moves;
-        let move_index_to_path = |&mut: move_index| {
+        let move_index_to_path = |move_index| {
             let move_data = &self.analysis_data.move_data.move_data;
             let moves = move_data.moves.borrow();
             let the_move: &borrowck::move_data::Move = &(*moves)[move_index];
@@ -120,7 +120,7 @@ fn dataflow_moves_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
 
     fn dataflow_assigns_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
         let dfcx = &self.analysis_data.move_data.dfcx_assign;
-        let assign_index_to_path = |&mut: assign_index| {
+        let assign_index_to_path = |assign_index| {
             let move_data = &self.analysis_data.move_data.move_data;
             let assignments = move_data.var_assignments.borrow();
             let assignment: &borrowck::move_data::Assignment = &(*assignments)[assign_index];
index 8ede037594a007557d57fae70632df52507d9313..0b0b1f9276fbb3d8539da98dabae33bf90f0f962 100644 (file)
@@ -214,7 +214,7 @@ impl<'a> PhaseController<'a> {
     pub fn basic() -> PhaseController<'a> {
         PhaseController {
             stop: false,
-            callback: box |&: _| {},
+            callback: box |_| {},
         }
     }
 }
@@ -350,7 +350,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
     }
 
     if let Some(ref s) = sess.opts.show_span {
-        syntax::show_span::run(sess.diagnostic(), s.as_slice(), &krate);
+        syntax::show_span::run(sess.diagnostic(), s, &krate);
     }
 
     krate
@@ -794,7 +794,7 @@ fn write_out_deps(sess: &Session,
         _ => return,
     };
 
-    let result = (|&:| -> old_io::IoResult<()> {
+    let result = (|| -> old_io::IoResult<()> {
         // Build a list of files used to compile the output and
         // write Makefile-compatible dependency rules
         let files: Vec<String> = sess.codemap().files.borrow()
index 4fe037d852f49c715adf497772a746db53f146dd..9193debbe4243adeabda71a77f120272d3ade3c5 100644 (file)
@@ -93,7 +93,7 @@
 pub mod pretty;
 
 pub fn run(args: Vec<String>) -> int {
-    monitor(move |:| run_compiler(args.as_slice()));
+    monitor(move || run_compiler(&args));
     0
 }
 
@@ -165,7 +165,7 @@ fn run_compiler(args: &[String]) {
     let pretty = if sess.opts.debugging_opts.unstable_options {
         matches.opt_default("pretty", "normal").map(|a| {
             // stable pretty-print variants only
-            pretty::parse_pretty(&sess, a.as_slice(), false)
+            pretty::parse_pretty(&sess, &a, false)
         })
     } else {
         None
@@ -174,7 +174,7 @@ fn run_compiler(args: &[String]) {
         sess.unstable_options() {
             matches.opt_str("xpretty").map(|a| {
                 // extended with unstable pretty-print variants
-                pretty::parse_pretty(&sess, a.as_slice(), true)
+                pretty::parse_pretty(&sess, &a, true)
             })
         } else {
             pretty
@@ -313,7 +313,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
     -C help             Print codegen options
     -W help             Print 'lint' options and default settings
     -Z help             Print internal options for debugging rustc{}\n",
-              getopts::usage(message.as_slice(), groups.as_slice()),
+              getopts::usage(&message, &groups),
               extra_help);
 }
 
@@ -362,7 +362,7 @@ fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
     let max_name_len = plugin.iter().chain(builtin.iter())
         .map(|&s| s.name.width(true))
         .max().unwrap_or(0);
-    let padded = |&: x: &str| {
+    let padded = |x: &str| {
         let mut s = repeat(" ").take(max_name_len - x.chars().count())
                                .collect::<String>();
         s.push_str(x);
@@ -373,7 +373,7 @@ fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
     println!("    {}  {:7.7}  {}", padded("name"), "default", "meaning");
     println!("    {}  {:7.7}  {}", padded("----"), "-------", "-------");
 
-    let print_lints = |&: lints: Vec<&Lint>| {
+    let print_lints = |lints: Vec<&Lint>| {
         for lint in lints {
             let name = lint.name_lower().replace("_", "-");
             println!("    {}  {:7.7}  {}",
@@ -389,7 +389,7 @@ fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
     let max_name_len = plugin_groups.iter().chain(builtin_groups.iter())
         .map(|&(s, _)| s.width(true))
         .max().unwrap_or(0);
-    let padded = |&: x: &str| {
+    let padded = |x: &str| {
         let mut s = repeat(" ").take(max_name_len - x.chars().count())
                                .collect::<String>();
         s.push_str(x);
@@ -400,7 +400,7 @@ fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
     println!("    {}  {}", padded("name"), "sub-lints");
     println!("    {}  {}", padded("----"), "---------");
 
-    let print_lint_groups = |&: lints: Vec<(&'static str, Vec<lint::LintId>)>| {
+    let print_lint_groups = |lints: Vec<(&'static str, Vec<lint::LintId>)>| {
         for (name, to) in lints {
             let name = name.chars().map(|x| x.to_lowercase())
                            .collect::<String>().replace("_", "-");
@@ -481,20 +481,20 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
                 // unstable ones.
                 let all_groups : Vec<getopts::OptGroup>
                     = config::rustc_optgroups().into_iter().map(|x|x.opt_group).collect();
-                match getopts::getopts(args.as_slice(), all_groups.as_slice()) {
+                match getopts::getopts(&args, &all_groups) {
                     Ok(m_unstable) => {
                         let r = m_unstable.opt_strs("Z");
                         let include_unstable_options = r.iter().any(|x| *x == "unstable-options");
                         if include_unstable_options {
                             m_unstable
                         } else {
-                            early_error(f_stable_attempt.to_string().as_slice());
+                            early_error(&f_stable_attempt.to_string());
                         }
                     }
                     Err(_) => {
                         // ignore the error from the unstable attempt; just
                         // pass the error we got from the first try.
-                        early_error(f_stable_attempt.to_string().as_slice());
+                        early_error(&f_stable_attempt.to_string());
                     }
                 }
             }
@@ -552,13 +552,13 @@ fn print_crate_info(sess: &Session,
                     Some(input) => input,
                     None => early_error("no input file provided"),
                 };
-                let attrs = attrs.as_ref().unwrap().as_slice();
+                let attrs = attrs.as_ref().unwrap();
                 let t_outputs = driver::build_output_filenames(input,
                                                                odir,
                                                                ofile,
                                                                attrs,
                                                                sess);
-                let id = link::find_crate_name(Some(sess), attrs.as_slice(),
+                let id = link::find_crate_name(Some(sess), attrs,
                                                input);
                 if *req == PrintRequest::CrateName {
                     println!("{}", id);
@@ -569,7 +569,7 @@ fn print_crate_info(sess: &Session,
                 *sess.crate_metadata.borrow_mut() = metadata;
                 for &style in &crate_types {
                     let fname = link::filename_for_input(sess, style,
-                                                         id.as_slice(),
+                                                         &id,
                                                          &t_outputs.with_extension(""));
                     println!("{}", fname.filename_display());
                 }
index ea7e59560cda9bb75dd22f7a2f607af10a03c6cb..5dfef6c775e1e892a9980815aa21bd888e8b28ea 100644 (file)
@@ -87,15 +87,15 @@ pub fn parse_pretty(sess: &Session,
         ("flowgraph,unlabelled", true)    => PpmFlowGraph(PpFlowGraphMode::UnlabelledEdges),
         _ => {
             if extended {
-                sess.fatal(format!(
+                sess.fatal(&format!(
                     "argument to `xpretty` must be one of `normal`, \
                      `expanded`, `flowgraph[,unlabelled]=<nodeid>`, `typed`, `identified`, \
-                     `expanded,identified`, or `everybody_loops`; got {}", name).as_slice());
+                     `expanded,identified`, or `everybody_loops`; got {}", name));
             } else {
-                sess.fatal(format!(
+                sess.fatal(&format!(
                     "argument to `pretty` must be one of `normal`, \
                      `expanded`, `typed`, `identified`, \
-                     or `expanded,identified`; got {}", name).as_slice());
+                     or `expanded,identified`; got {}", name));
             }
         }
     };
@@ -388,7 +388,7 @@ fn all_matching_node_ids<'a, 'ast>(&'a self, map: &'a ast_map::Map<'ast>)
     }
 
     fn to_one_node_id(self, user_option: &str, sess: &Session, map: &ast_map::Map) -> ast::NodeId {
-        let fail_because = |&: is_wrong_because| -> ast::NodeId {
+        let fail_because = |is_wrong_because| -> ast::NodeId {
             let message =
                 format!("{} needs NodeId (int) or unique \
                          path suffix (b::c::d); got {}, which {}",
@@ -517,7 +517,7 @@ pub fn pretty_print_input(sess: Session,
         krate
     };
 
-    let id = link::find_crate_name(Some(&sess), krate.attrs.as_slice(), input);
+    let id = link::find_crate_name(Some(&sess), &krate.attrs, input);
 
     let is_expanded = needs_expansion(&ppm);
     let compute_ast_map = needs_ast_map(&ppm, &opt_uii);
index 7dc0d9be53924f9103e1872dc4cf023bbc723dea..8761b5f72ec57cde12abea280b454c41fb07ee1f 100644 (file)
@@ -56,7 +56,7 @@ fn remove_message(e: &mut ExpectErrorEmitter, msg: &str, lvl: Level) {
     }
 
     debug!("Error: {}", msg);
-    match e.messages.iter().position(|m| msg.contains(m.as_slice())) {
+    match e.messages.iter().position(|m| msg.contains(m)) {
         Some(i) => {
             e.messages.remove(i);
         }
index c398ff72f504a351a6326e6b4372a8141993ea0c..aa9b6c479bb78f9b56e57dd5f5339a9f8c04c9f8 100644 (file)
@@ -719,8 +719,8 @@ fn check_static_method(&mut self,
     fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
         debug!("privacy - path {}", self.nodestr(path_id));
         let orig_def = self.tcx.def_map.borrow()[path_id].clone();
-        let ck = |&: tyname: &str| {
-            let ck_public = |&: def: ast::DefId| {
+        let ck = |tyname: &str| {
+            let ck_public = |def: ast::DefId| {
                 debug!("privacy - ck_public {:?}", def);
                 let name = token::get_ident(path.segments.last().unwrap().identifier);
                 let origdid = orig_def.def_id();
@@ -924,7 +924,7 @@ struct type?!"),
                 }
             }
             ast::ExprPath(_) | ast::ExprQPath(_) => {
-                let guard = |&: did: ast::DefId| {
+                let guard = |did: ast::DefId| {
                     let fields = ty::lookup_struct_fields(self.tcx, did);
                     let any_priv = fields.iter().any(|f| {
                         f.vis != ast::Public && (
@@ -1076,7 +1076,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
     /// later on down the road...
     fn check_sane_privacy(&self, item: &ast::Item) {
         let tcx = self.tcx;
-        let check_inherited = |&: sp: Span, vis: ast::Visibility, note: &str| {
+        let check_inherited = |sp: Span, vis: ast::Visibility, note: &str| {
             if vis != ast::Inherited {
                 tcx.sess.span_err(sp, "unnecessary visibility qualifier");
                 if note.len() > 0 {
@@ -1156,7 +1156,7 @@ fn check_inherited(tcx: &ty::ctxt, sp: Span, vis: ast::Visibility) {
                 tcx.sess.span_err(sp, "visibility has no effect inside functions");
             }
         }
-        let check_struct = |&: def: &ast::StructDef| {
+        let check_struct = |def: &ast::StructDef| {
             for f in &def.fields {
                match f.node.kind {
                     ast::NamedField(_, p) => check_inherited(tcx, f.span, p),
index dd739059ed0ddf13c10d19ea06ce7a9aab9a90bb..ec1d300dbec894079a3eaf52bd04bf8788a97ed0 100644 (file)
@@ -1475,7 +1475,7 @@ fn get_binding(this: &mut Resolver,
         let mut import_resolutions = module_.import_resolutions.borrow_mut();
         let import_resolution = &mut (*import_resolutions)[target];
         {
-            let mut check_and_write_import = |&mut: namespace, result: &_, used_public: &mut bool| {
+            let mut check_and_write_import = |namespace, result: &_, used_public: &mut bool| {
                 let namespace_name = match namespace {
                     TypeNS => "type",
                     ValueNS => "value",
@@ -1714,7 +1714,7 @@ fn merge_import_resolution(&mut self,
 
         // Merge the child item into the import resolution.
         {
-            let mut merge_child_item = |&mut : namespace| {
+            let mut merge_child_item = |namespace| {
                 if name_bindings.defined_in_namespace_with(namespace, IMPORTABLE | PUBLIC) {
                     let namespace_name = match namespace {
                         TypeNS => "type",
@@ -1726,7 +1726,7 @@ fn merge_import_resolution(&mut self,
                                            in this module",
                                           namespace_name,
                                           token::get_name(name).get());
-                        span_err!(self.session, import_directive.span, E0251, "{}", msg.as_slice());
+                        span_err!(self.session, import_directive.span, E0251, "{}", msg);
                     } else {
                         let target = Target::new(containing_module.clone(),
                                                  name_bindings.clone(),
@@ -3756,15 +3756,14 @@ struct or enum variant",
                         }
                         Some(_) => {
                             self.resolve_error(path.span,
-                                format!("`{}` is not an enum variant, struct or const",
+                                &format!("`{}` is not an enum variant, struct or const",
                                     token::get_ident(
-                                        path.segments.last().unwrap().identifier)).as_slice());
+                                        path.segments.last().unwrap().identifier)));
                         }
                         None => {
                             self.resolve_error(path.span,
-                                format!("unresolved enum variant, struct or const `{}`",
-                                    token::get_ident(
-                                        path.segments.last().unwrap().identifier)).as_slice());
+                                &format!("unresolved enum variant, struct or const `{}`",
+                                    token::get_ident(path.segments.last().unwrap().identifier)));
                         }
                     }
 
@@ -4061,7 +4060,7 @@ fn resolve_module_relative_path(&mut self,
                     Some((span, msg)) => (span, msg),
                     None => {
                         let msg = format!("Use of undeclared type or module `{}`",
-                                          self.names_to_string(module_path.as_slice()));
+                                          self.names_to_string(&module_path));
                         (path.span, msg)
                     }
                 };
@@ -4163,7 +4162,7 @@ fn resolve_identifier_in_local_ribs(&mut self,
         let search_result = match namespace {
             ValueNS => {
                 let renamed = mtwt::resolve(ident);
-                self.search_ribs(self.value_ribs.as_slice(), renamed, span)
+                self.search_ribs(&self.value_ribs, renamed, span)
             }
             TypeNS => {
                 let name = ident.name;
@@ -4424,15 +4423,15 @@ fn resolve_expr(&mut self, expr: &Expr) {
                     Some((DefVariant(_, _, true), _)) => {
                         let path_name = self.path_names_to_string(path);
                         self.resolve_error(expr.span,
-                                format!("`{}` is a struct variant name, but \
-                                         this expression \
-                                         uses it like a function name",
-                                        path_name).as_slice());
+                                &format!("`{}` is a struct variant name, but \
+                                          this expression \
+                                          uses it like a function name",
+                                         path_name));
 
                         self.session.span_help(expr.span,
-                            format!("Did you mean to write: \
-                                    `{} {{ /* fields */ }}`?",
-                                    path_name).as_slice());
+                            &format!("Did you mean to write: \
+                                     `{} {{ /* fields */ }}`?",
+                                     path_name));
                     }
                     Some(def) => {
                         // Write the result into the def map.
@@ -4452,15 +4451,15 @@ fn resolve_expr(&mut self, expr: &Expr) {
                             Some((DefTy(struct_id, _), _))
                               if self.structs.contains_key(&struct_id) => {
                                 self.resolve_error(expr.span,
-                                        format!("`{}` is a structure name, but \
-                                                 this expression \
-                                                 uses it like a function name",
-                                                path_name).as_slice());
+                                        &format!("`{}` is a structure name, but \
+                                                  this expression \
+                                                  uses it like a function name",
+                                                 path_name));
 
                                 self.session.span_help(expr.span,
-                                    format!("Did you mean to write: \
-                                            `{} {{ /* fields */ }}`?",
-                                            path_name).as_slice());
+                                    &format!("Did you mean to write: \
+                                             `{} {{ /* fields */ }}`?",
+                                             path_name));
 
                             }
                             _ => {
@@ -4489,7 +4488,7 @@ fn resolve_expr(&mut self, expr: &Expr) {
                                         NoSuggestion => {
                                             // limit search to 5 to reduce the number
                                             // of stupid suggestions
-                                            self.find_best_match_for_name(path_name.as_slice(), 5)
+                                            self.find_best_match_for_name(&path_name, 5)
                                                                 .map_or("".to_string(),
                                                                         |x| format!("`{}`", x))
                                         }
@@ -4509,9 +4508,9 @@ fn resolve_expr(&mut self, expr: &Expr) {
 
                                     self.resolve_error(
                                         expr.span,
-                                        format!("unresolved name `{}`{}",
-                                                path_name,
-                                                msg).as_slice());
+                                        &format!("unresolved name `{}`{}",
+                                                 path_name,
+                                                 msg));
                                 }
                             }
                         }
index 792178e970cc2c9c116533623474c0ee9b37727b..2828fafddf02a5338bfb670d1b13a3cb97454a42 100644 (file)
 pub fn find_crate_name(sess: Option<&Session>,
                        attrs: &[ast::Attribute],
                        input: &Input) -> String {
-    let validate = |&: s: String, span: Option<Span>| {
+    let validate = |s: String, span: Option<Span>| {
         creader::validate_crate_name(sess, &s[], span);
         s
     };
@@ -609,7 +609,7 @@ fn link_rlib<'a>(sess: &'a Session,
                 // extension to it. This is to work around a bug in LLDB that
                 // would cause it to crash if the name of a file in an archive
                 // was exactly 16 bytes.
-                let bc_filename = obj_filename.with_extension(format!("{}.bc", i).as_slice());
+                let bc_filename = obj_filename.with_extension(&format!("{}.bc", i));
                 let bc_deflated_filename = obj_filename.with_extension(
                     &format!("{}.bytecode.deflate", i)[]);
 
@@ -1006,7 +1006,7 @@ fn link_args(cmd: &mut Command,
     if sess.opts.cg.rpath {
         let sysroot = sess.sysroot();
         let target_triple = &sess.opts.target_triple[];
-        let get_install_prefix_lib_path = |:| {
+        let get_install_prefix_lib_path = || {
             let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
             let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);
             let mut path = Path::new(install_prefix);
@@ -1087,8 +1087,8 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
             // -force_load is the OSX equivalent of --whole-archive, but it
             // involves passing the full path to the library to link.
             let lib = archive::find_library(&l[],
-                                            sess.target.target.options.staticlib_prefix.as_slice(),
-                                            sess.target.target.options.staticlib_suffix.as_slice(),
+                                            &sess.target.target.options.staticlib_prefix,
+                                            &sess.target.target.options.staticlib_suffix,
                                             &search_path[],
                                             &sess.diagnostic().handler);
             let mut v = b"-Wl,-force_load,".to_vec();
index 38c68bc9fa426005e6add8fc17fd3a2f29ade027..c88e76f42707348001214e34eff7889dba5cc897 100644 (file)
@@ -64,7 +64,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
         debug!("reading {}", file);
         for i in iter::count(0us, 1) {
             let bc_encoded = time(sess.time_passes(),
-                                  format!("check for {}.{}.bytecode.deflate", name, i).as_slice(),
+                                  &format!("check for {}.{}.bytecode.deflate", name, i),
                                   (),
                                   |_| {
                                       archive.read(&format!("{}.{}.bytecode.deflate",
@@ -84,7 +84,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
             };
 
             let bc_decoded = if is_versioned_bytecode_format(bc_encoded) {
-                time(sess.time_passes(), format!("decode {}.{}.bc", file, i).as_slice(), (), |_| {
+                time(sess.time_passes(), &format!("decode {}.{}.bc", file, i), (), |_| {
                     // Read the version
                     let version = extract_bytecode_format_version(bc_encoded);
 
@@ -108,7 +108,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
                     }
                 })
             } else {
-                time(sess.time_passes(), format!("decode {}.{}.bc", file, i).as_slice(), (), |_| {
+                time(sess.time_passes(), &format!("decode {}.{}.bc", file, i), (), |_| {
                 // the object must be in the old, pre-versioning format, so simply
                 // inflate everything and let LLVM decide if it can make sense of it
                     match flate::inflate_bytes(bc_encoded) {
index 5312d2ca1ddeee3d40675c631a80262e4b82599e..8a30806f3b601ab62f98701f17e992df5e8199a0 100644 (file)
@@ -50,7 +50,7 @@ pub fn llvm_err(handler: &diagnostic::Handler, msg: String) -> ! {
             handler.fatal(&msg[]);
         } else {
             let err = ffi::c_str_to_bytes(&cstr);
-            let err = String::from_utf8_lossy(err.as_slice()).to_string();
+            let err = String::from_utf8_lossy(err).to_string();
             libc::free(cstr as *mut _);
             handler.fatal(&format!("{}: {}",
                                   &msg[],
@@ -223,8 +223,8 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
     let tm = unsafe {
         let triple = CString::from_slice(triple.as_bytes());
         let cpu = match sess.opts.cg.target_cpu {
-            Some(ref s) => s.as_slice(),
-            None => sess.target.target.options.cpu.as_slice()
+            Some(ref s) => &**s,
+            None => &*sess.target.target.options.cpu
         };
         let cpu = CString::from_slice(cpu.as_bytes());
         let features = CString::from_slice(target_feature(sess).as_bytes());
@@ -375,7 +375,7 @@ struct HandlerFreeVars<'a> {
     match llvm::diagnostic::Diagnostic::unpack(info) {
         llvm::diagnostic::InlineAsm(inline) => {
             report_inline_asm(cgcx,
-                              llvm::twine_to_string(inline.message).as_slice(),
+                              &*llvm::twine_to_string(inline.message),
                               inline.cookie);
         }
 
@@ -390,11 +390,11 @@ struct HandlerFreeVars<'a> {
 
             if enabled {
                 let loc = llvm::debug_loc_to_string(llcx, opt.debug_loc);
-                cgcx.handler.note(format!("optimization {} for {} at {}: {}",
-                                          opt.kind.describe(),
-                                          pass_name,
-                                          if loc.is_empty() { "[unknown]" } else { loc.as_slice() },
-                                          llvm::twine_to_string(opt.message)).as_slice());
+                cgcx.handler.note(&format!("optimization {} for {} at {}: {}",
+                                           opt.kind.describe(),
+                                           pass_name,
+                                           if loc.is_empty() { "[unknown]" } else { &*loc },
+                                           llvm::twine_to_string(opt.message)));
             }
         }
 
@@ -423,7 +423,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
 
     if config.emit_no_opt_bc {
         let ext = format!("{}.no-opt.bc", name_extra);
-        let out = output_names.with_extension(ext.as_slice());
+        let out = output_names.with_extension(&ext);
         let out = CString::from_slice(out.as_vec());
         llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
     }
@@ -439,7 +439,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
 
             // If we're verifying or linting, add them to the function pass
             // manager.
-            let addpass = |&: pass: &str| {
+            let addpass = |pass: &str| {
                 let pass = CString::from_slice(pass.as_bytes());
                 llvm::LLVMRustAddPass(fpm, pass.as_ptr())
             };
@@ -455,8 +455,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
             for pass in &config.passes {
                 let pass = CString::from_slice(pass.as_bytes());
                 if !llvm::LLVMRustAddPass(mpm, pass.as_ptr()) {
-                    cgcx.handler.warn(format!("unknown pass {:?}, ignoring",
-                                              pass).as_slice());
+                    cgcx.handler.warn(&format!("unknown pass {:?}, ignoring", pass));
                 }
             }
 
@@ -477,7 +476,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
 
                     if config.emit_lto_bc {
                         let name = format!("{}.lto.bc", name_extra);
-                        let out = output_names.with_extension(name.as_slice());
+                        let out = output_names.with_extension(&name);
                         let out = CString::from_slice(out.as_vec());
                         llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
                     }
@@ -511,7 +510,7 @@ unsafe fn with_codegen<F>(tm: TargetMachineRef,
 
     if config.emit_bc {
         let ext = format!("{}.bc", name_extra);
-        let out = output_names.with_extension(ext.as_slice());
+        let out = output_names.with_extension(&ext);
         let out = CString::from_slice(out.as_vec());
         llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
     }
@@ -519,7 +518,7 @@ unsafe fn with_codegen<F>(tm: TargetMachineRef,
     time(config.time_passes, "codegen passes", (), |()| {
         if config.emit_ir {
             let ext = format!("{}.ll", name_extra);
-            let out = output_names.with_extension(ext.as_slice());
+            let out = output_names.with_extension(&ext);
             let out = CString::from_slice(out.as_vec());
             with_codegen(tm, llmod, config.no_builtins, |cpm| {
                 llvm::LLVMRustPrintModule(cpm, llmod, out.as_ptr());
@@ -660,7 +659,7 @@ pub fn run_passes(sess: &Session,
 
     // Produce final compile outputs.
 
-    let copy_if_one_unit = |&: ext: &str, output_type: config::OutputType, keep_numbered: bool| {
+    let copy_if_one_unit = |ext: &str, output_type: config::OutputType, keep_numbered: bool| {
         // Three cases:
         if sess.opts.cg.codegen_units == 1 {
             // 1) Only one codegen unit.  In this case it's no difficulty
@@ -685,7 +684,7 @@ pub fn run_passes(sess: &Session,
         }
     };
 
-    let link_obj = |&: output_path: &Path| {
+    let link_obj = |output_path: &Path| {
         // Running `ld -r` on a single input is kind of pointless.
         if sess.opts.cg.codegen_units == 1 {
             fs::copy(&crate_output.with_extension("0.o"),
@@ -910,7 +909,7 @@ fn run_work_multithreaded(sess: &Session,
         let mut tx = Some(tx);
         futures.push(rx);
 
-        thread::Builder::new().name(format!("codegen-{}", i)).spawn(move |:| {
+        thread::Builder::new().name(format!("codegen-{}", i)).spawn(move || {
             let diag_handler = mk_handler(true, box diag_emitter);
 
             // Must construct cgcx inside the proc because it has non-Send
@@ -1001,7 +1000,7 @@ unsafe fn configure_llvm(sess: &Session) {
     let mut llvm_c_strs = Vec::new();
     let mut llvm_args = Vec::new();
     {
-        let mut add = |&mut : arg: &str| {
+        let mut add = |arg: &str| {
             let s = CString::from_slice(arg.as_bytes());
             llvm_args.push(s.as_ptr());
             llvm_c_strs.push(s);
@@ -1013,7 +1012,7 @@ unsafe fn configure_llvm(sess: &Session) {
         if sess.print_llvm_passes() { add("-debug-pass=Structure"); }
 
         // FIXME #21627 disable faulty FastISel on AArch64 (even for -O0)
-        if sess.target.target.arch.as_slice() == "aarch64" { add("-fast-isel=0"); }
+        if sess.target.target.arch == "aarch64" { add("-fast-isel=0"); }
 
         for arg in &sess.opts.cg.llvm_args {
             add(&(*arg)[]);
index b0ce9641cf440e8a658e9bcb314d129720692fbe..ab9617d6365cbf31e0c68173dfdb557cbd1e226f 100644 (file)
@@ -309,7 +309,7 @@ fn process_method(&mut self, method: &ast::Method) {
                                 Some(def_id) => {
                                     result.push_str(" as ");
                                     result.push_str(
-                                        ty::item_path_str(&self.analysis.ty_cx, def_id).as_slice());
+                                        &ty::item_path_str(&self.analysis.ty_cx, def_id));
                                 },
                                 None => {}
                             }
@@ -643,7 +643,7 @@ fn process_enum(&mut self,
                         item.id);
 
                     for field in &struct_def.fields {
-                        self.process_struct_field_def(field, qualname.as_slice(), variant.node.id);
+                        self.process_struct_field_def(field, &qualname, variant.node.id);
                         self.visit_ty(&*field.node.ty);
                     }
                 }
@@ -795,7 +795,7 @@ fn process_path(&mut self,
         let def_map = self.analysis.ty_cx.def_map.borrow();
         if !def_map.contains_key(&id) {
             self.sess.span_bug(span,
-                               format!("def_map has no key for {} in visit_expr", id).as_slice());
+                               &format!("def_map has no key for {} in visit_expr", id));
         }
         let def = &(*def_map)[id];
         let sub_span = self.span.span_for_last_ident(span);
@@ -1117,7 +1117,7 @@ fn visit_item(&mut self, item: &ast::Item) {
                         self.fmt.use_glob_str(path.span,
                                               sub_span,
                                               item.id,
-                                              name_string.as_slice(),
+                                              &name_string,
                                               self.cur_scope);
                         self.write_sub_paths(path, true);
                     }
@@ -1200,7 +1200,7 @@ fn visit_item(&mut self, item: &ast::Item) {
                                      &value[]);
 
                 self.visit_ty(&**ty);
-                self.process_generic_params(ty_params, item.span, qualname.as_slice(), item.id);
+                self.process_generic_params(ty_params, item.span, &qualname, item.id);
             },
             ast::ItemMac(_) => (),
             _ => visit::walk_item(self, item),
index f6f03887528aec8a8b8343947a192cd126291303..3bd04ed29d4a1139a2a3bc502a6241793931c616 100644 (file)
@@ -229,8 +229,8 @@ pub fn record_with_span(&mut self,
 
         if !needs_span {
             self.span.sess.span_bug(span,
-                                    format!("Called record_with_span for '{}' \
-                                             which does not require a span", label).as_slice());
+                                    &format!("Called record_with_span for '{}' \
+                                              which does not require a span", label));
         }
 
         let values_str = match self.make_values_str(label, fields, values, span) {
index beec8071a72baf4f1491864da078b072aae0ca28..a724cdc0229d2f465af8865f8cd1ae42951dda33 100644 (file)
@@ -69,8 +69,8 @@ pub fn make_sub_span(&self, span: Span, sub_span: Option<Span>) -> Option<Span>
 
     pub fn snippet(&self, span: Span) -> String {
         match self.sess.codemap().span_to_snippet(span) {
-            Some(s) => s,
-            None => String::new(),
+            Ok(s) => s,
+            Err(_) => String::new(),
         }
     }
 
index 52fe8797592b5b72c8bfedc006fdfb8a07ef21ac..1fea8f6aa3b1d8be9985b98207de536d07f27b90 100644 (file)
@@ -747,7 +747,7 @@ fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> uint {
         }
     }
 
-    let column_score = |&: m: &[Match], col: uint| -> uint {
+    let column_score = |m: &[Match], col: uint| -> uint {
         let total_score = m.iter()
             .map(|row| row.pats[col])
             .map(|pat| pat_score(def_map, pat))
@@ -761,7 +761,7 @@ fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> uint {
         }
     };
 
-    let column_contains_any_nonwild_patterns = |&: &col: &uint| -> bool {
+    let column_contains_any_nonwild_patterns = |&col: &uint| -> bool {
         m.iter().any(|row| match row.pats[col].node {
             ast::PatWild(_) => false,
             _ => true
@@ -1029,8 +1029,8 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                                         field_vals.len())
             );
             let mut vals = field_vals;
-            vals.push_all(vals_left.as_slice());
-            compile_submatch(bcx, pats.as_slice(), vals.as_slice(), chk, has_genuine_default);
+            vals.push_all(&vals_left);
+            compile_submatch(bcx, &pats, &vals, chk, has_genuine_default);
             return;
         }
         _ => ()
index b99622ce911d2f2b6ee0f393874335e78eee358d..21e52e5fffe56a509814ab7193c01515b0962754 100644 (file)
@@ -265,9 +265,9 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             // Use the minimum integer type we figured out above
             let fields : Vec<_> = cases.iter().map(|c| {
                 let mut ftys = vec!(ty_of_inttype(cx.tcx(), min_ity));
-                ftys.push_all(c.tys.as_slice());
+                ftys.push_all(&c.tys);
                 if dtor { ftys.push(cx.tcx().types.bool); }
-                mk_struct(cx, ftys.as_slice(), false, t)
+                mk_struct(cx, &ftys, false, t)
             }).collect();
 
 
@@ -283,7 +283,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             // This check is needed to avoid increasing the size of types when
             // the alignment of the first field is smaller than the overall
             // alignment of the type.
-            let (_, align) = union_size_and_align(fields.as_slice());
+            let (_, align) = union_size_and_align(&fields);
             let mut use_align = true;
             for st in &fields {
                 // Get the first non-zero-sized field
index 05abd3ff5577d7b211a0a59a2ded4b493aeccf8f..1d910c81da988318ff3cd69d06e8ff06fbc000ba 100644 (file)
@@ -125,7 +125,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
     let r = InlineAsmCall(bcx,
                           asm.as_ptr(),
                           constraints.as_ptr(),
-                          inputs.as_slice(),
+                          &inputs,
                           output_type,
                           ia.volatile,
                           ia.alignstack,
index c2af6ec8c8ad82183cea6d88dfb267ad9c6c1b4e..38051a647caf3b2f2a87fa4a2f723241243f80f6 100644 (file)
@@ -115,7 +115,7 @@ pub fn with_insn_ctxt<F>(blk: F) where
     F: FnOnce(&[&'static str]),
 {
     TASK_LOCAL_INSN_KEY.with(move |slot| {
-        slot.borrow().as_ref().map(move |s| blk(s.as_slice()));
+        slot.borrow().as_ref().map(move |s| blk(s));
     })
 }
 
@@ -540,7 +540,7 @@ pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
                                         t: Ty<'tcx>,
                                         op: ast::BinOp_)
                                         -> Result<'blk, 'tcx> {
-    let f = |&: a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
+    let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
 
     match t.sty {
         ty::ty_tup(ref tys) if tys.is_empty() => f(nil_type),
@@ -1354,8 +1354,8 @@ fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>)
         // glue, shims, etc
         None if id == ast::DUMMY_NODE_ID => return (ast::DUMMY_NODE_ID, None),
 
-        _ => tcx.sess.bug(format!("unexpected variant in has_nested_returns: {}",
-                                  tcx.map.path_to_string(id)).as_slice())
+        _ => tcx.sess.bug(&format!("unexpected variant in has_nested_returns: {}",
+                                   tcx.map.path_to_string(id)))
     };
 
     (blk.id, Some(cfg::CFG::new(tcx, &**blk)))
@@ -2247,7 +2247,7 @@ pub fn update_linkage(ccx: &CrateContext,
     if let Some(id) = id {
         let item = ccx.tcx().map.get(id);
         if let ast_map::NodeItem(i) = item {
-            if let Some(name) = attr::first_attr_value_str_by_name(i.attrs.as_slice(), "linkage") {
+            if let Some(name) = attr::first_attr_value_str_by_name(&i.attrs, "linkage") {
                 if let Some(linkage) = llvm_linkage_by_name(name.get()) {
                     llvm::SetLinkage(llval, linkage);
                 } else {
@@ -2757,7 +2757,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
     let val = match item {
         ast_map::NodeItem(i) => {
             let ty = ty::node_id_to_type(ccx.tcx(), i.id);
-            let sym = |&:| exported_name(ccx, id, ty, &i.attrs[]);
+            let sym = || exported_name(ccx, id, ty, &i.attrs[]);
 
             let v = match i.node {
                 ast::ItemStatic(_, _, ref expr) => {
@@ -2987,10 +2987,10 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec<u8> {
     let encode_parms = crate_ctxt_to_encode_parms(cx, encode_inlined_item);
     let metadata = encoder::encode_metadata(encode_parms, krate);
     let mut compressed = encoder::metadata_encoding_version.to_vec();
-    compressed.push_all(match flate::deflate_bytes(metadata.as_slice()) {
+    compressed.push_all(&match flate::deflate_bytes(&metadata) {
         Some(compressed) => compressed,
         None => cx.sess().fatal("failed to compress metadata"),
-    }.as_slice());
+    });
     let llmeta = C_bytes_in_context(cx.metadata_llcx(), &compressed[]);
     let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);
     let name = format!("rust_metadata_{}_{}",
@@ -3016,14 +3016,14 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
     unsafe {
         let mut declared = HashSet::new();
 
-        let iter_globals = |&: llmod| {
+        let iter_globals = |llmod| {
             ValueIter {
                 cur: llvm::LLVMGetFirstGlobal(llmod),
                 step: llvm::LLVMGetNextGlobal,
             }
         };
 
-        let iter_functions = |&: llmod| {
+        let iter_functions = |llmod| {
             ValueIter {
                 cur: llvm::LLVMGetFirstFunction(llmod),
                 step: llvm::LLVMGetNextFunction,
@@ -3062,7 +3062,7 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
                 let name = ffi::c_str_to_bytes(&llvm::LLVMGetValueName(val))
                                .to_vec();
                 if !declared.contains(&name) &&
-                   !reachable.contains(str::from_utf8(name.as_slice()).unwrap()) {
+                   !reachable.contains(str::from_utf8(&name).unwrap()) {
                     llvm::SetLinkage(val, llvm::InternalLinkage);
                 }
             }
index fecd1a9013bb2c5bb9f7ea8cb1b278ad951bcccb..bc171e3ae4381fbbce881c5fdc3e3627b53e1d1e 100644 (file)
@@ -159,7 +159,7 @@ fn coerce_to_int(ccx: &CrateContext, size: uint) -> Vec<Type> {
 
 fn struct_ty(ccx: &CrateContext, ty: Type) -> Type {
     let size = ty_size(ty) * 8;
-    Type::struct_(ccx, coerce_to_int(ccx, size).as_slice(), false)
+    Type::struct_(ccx, &coerce_to_int(ccx, size), false)
 }
 
 pub fn compute_abi_info(ccx: &CrateContext,
index 9583158a0e243971d028b6e0edef7b4a223a9409..4871617e89f3bfd1b0b9c5f319f984cd774ac18c 100644 (file)
@@ -154,7 +154,7 @@ fn coerce_to_int(ccx: &CrateContext, size: uint) -> Vec<Type> {
 
 fn struct_ty(ccx: &CrateContext, ty: Type) -> Type {
     let size = ty_size(ty) * 8;
-    Type::struct_(ccx, coerce_to_int(ccx, size).as_slice(), false)
+    Type::struct_(ccx, &coerce_to_int(ccx, size), false)
 }
 
 pub fn compute_abi_info(ccx: &CrateContext,
index 2484e74e19349a9f2aa30398d255ba1432a09fa3..ab41fe31a6e20b0343e7fbe409b75404119557b3 100644 (file)
@@ -237,7 +237,7 @@ fn classify(ty: Type,
                 unify(cls, ix + off / 8, SSEDs);
             }
             Struct => {
-                classify_struct(ty.field_types().as_slice(), cls, ix, off, ty.is_packed());
+                classify_struct(&ty.field_types(), cls, ix, off, ty.is_packed());
             }
             Array => {
                 let len = ty.array_length();
@@ -322,11 +322,11 @@ fn fixup(ty: Type, cls: &mut [RegClass]) {
     let words = (ty_size(ty) + 7) / 8;
     let mut cls: Vec<_> = repeat(NoClass).take(words).collect();
     if words > 4 {
-        all_mem(cls.as_mut_slice());
+        all_mem(&mut cls);
         return cls;
     }
-    classify(ty, cls.as_mut_slice(), 0, 0);
-    fixup(ty, cls.as_mut_slice());
+    classify(ty, &mut cls, 0, 0);
+    fixup(ty, &mut cls);
     return cls;
 }
 
@@ -381,7 +381,7 @@ fn llvec_len(cls: &[RegClass]) -> uint {
         // if the type contains only a vector, pass it as that vector.
         tys[0]
     } else {
-        Type::struct_(ccx, tys.as_slice(), false)
+        Type::struct_(ccx, &tys, false)
     }
 }
 
@@ -398,11 +398,11 @@ fn x86_64_ty<F>(ccx: &CrateContext,
     {
         if !ty.is_reg_ty() {
             let cls = classify_ty(ty);
-            if is_mem_cls(cls.as_slice()) {
+            if is_mem_cls(&cls) {
                 ArgType::indirect(ty, Some(ind_attr))
             } else {
                 ArgType::direct(ty,
-                                Some(llreg_ty(ccx, cls.as_slice())),
+                                Some(llreg_ty(ccx, &cls)),
                                 None,
                                 None)
             }
index 0403a2f2e3c679d9d4447c79db69b76c045a4046..7652dba4bce220f5e527c704a95de886f79ff12b 100644 (file)
@@ -241,8 +241,10 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
                                         ty::ty_vec(unit_ty, Some(len)) => {
                                             let llunitty = type_of::type_of(cx, unit_ty);
                                             let llptr = ptrcast(llconst, llunitty.ptr_to());
-                                            assert!(cx.const_globals().borrow_mut()
-                                                      .insert(llptr as int, llconst).is_none());
+                                            let prev_const = cx.const_globals().borrow_mut()
+                                                             .insert(llptr as int, llconst);
+                                            assert!(prev_const.is_none() ||
+                                                    prev_const == Some(llconst));
                                             assert_eq!(abi::FAT_PTR_ADDR, 0);
                                             assert_eq!(abi::FAT_PTR_EXTRA, 1);
                                             llconst = C_struct(cx, &[
@@ -289,7 +291,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
 // the bool returned is whether this expression can be inlined into other crates
 // if it's assigned to a static.
 fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
-    let map_list = |&: exprs: &[P<ast::Expr>]| {
+    let map_list = |exprs: &[P<ast::Expr>]| {
         exprs.iter().map(|e| const_expr(cx, &**e).0)
              .fold(Vec::new(), |mut l, val| { l.push(val); l })
     };
@@ -582,7 +584,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
               })
           }
           ast::ExprVec(ref es) => {
-            const_vec(cx, e, es.as_slice()).0
+            const_vec(cx, e, es).0
           }
           ast::ExprRepeat(ref elem, ref count) => {
             let vec_ty = ty::expr_ty(cx.tcx(), e);
index 3a2a1d158642e161ee93b2b25d1db2816b3b42fe..27dba9c4809b93b830279af8046af9c7698300f9 100644 (file)
@@ -224,11 +224,11 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
     let mod_name = CString::from_slice(mod_name.as_bytes());
     let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
 
-    let data_layout = sess.target.target.data_layout.as_slice();
+    let data_layout = &*sess.target.target.data_layout;
     let data_layout = CString::from_slice(data_layout.as_bytes());
     llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
 
-    let llvm_target = sess.target.target.llvm_target.as_slice();
+    let llvm_target = &*sess.target.target.llvm_target;
     let llvm_target = CString::from_slice(llvm_target.as_bytes());
     llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
     (llcx, llmod)
index c6b70e1a1abc354a47b187b628d4d94b93c584ce..4d4a2bf48548abf260677929750f807e28ec4881 100644 (file)
@@ -1094,7 +1094,7 @@ pub fn get_cleanup_debug_loc_for_ast_node<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         // bodies), in which case we also just want to return the span of the
         // whole expression.
         let code_snippet = cx.sess().codemap().span_to_snippet(node_span);
-        if let Some(code_snippet) = code_snippet {
+        if let Ok(code_snippet) = code_snippet {
             let bytes = code_snippet.as_bytes();
 
             if bytes.len() > 0 && &bytes[bytes.len()-1..] == b"}" {
@@ -1246,7 +1246,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
     let (ident, fn_decl, generics, top_level_block, span, has_path) = match fnitem {
         ast_map::NodeItem(ref item) => {
-            if contains_nodebug_attribute(item.attrs.as_slice()) {
+            if contains_nodebug_attribute(&item.attrs) {
                 return FunctionDebugContext::FunctionWithoutDebugInfo;
             }
 
@@ -1263,7 +1263,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ast_map::NodeImplItem(ref item) => {
             match **item {
                 ast::MethodImplItem(ref method) => {
-                    if contains_nodebug_attribute(method.attrs.as_slice()) {
+                    if contains_nodebug_attribute(&method.attrs) {
                         return FunctionDebugContext::FunctionWithoutDebugInfo;
                     }
 
@@ -1302,7 +1302,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ast_map::NodeTraitItem(ref trait_method) => {
             match **trait_method {
                 ast::ProvidedMethod(ref method) => {
-                    if contains_nodebug_attribute(method.attrs.as_slice()) {
+                    if contains_nodebug_attribute(&method.attrs) {
                         return FunctionDebugContext::FunctionWithoutDebugInfo;
                     }
 
@@ -1399,7 +1399,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     };
 
     let scope_map = create_scope_map(cx,
-                                     fn_decl.inputs.as_slice(),
+                                     &fn_decl.inputs,
                                      &*top_level_block,
                                      fn_metadata,
                                      fn_ast_id);
@@ -2453,7 +2453,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         })
         .collect();
 
-    let discriminant_type_metadata = |&: inttype| {
+    let discriminant_type_metadata = |inttype| {
         // We can reuse the type of the discriminant for all monomorphized
         // instances of an enum because it doesn't depend on any type parameters.
         // The def_id, uniquely identifying the enum's polytype acts as key in
@@ -2483,7 +2483,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                         UNKNOWN_LINE_NUMBER,
                         bytes_to_bits(discriminant_size),
                         bytes_to_bits(discriminant_align),
-                        create_DIArray(DIB(cx), enumerators_metadata.as_slice()),
+                        create_DIArray(DIB(cx), &enumerators_metadata),
                         discriminant_base_type_metadata)
                 };
 
@@ -3764,7 +3764,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
             match optional_length {
                 Some(len) => {
-                    output.push_str(format!("; {}", len).as_slice());
+                    output.push_str(&format!("; {}", len));
                 }
                 None => { /* nothing to do */ }
             };
@@ -4070,11 +4070,10 @@ fn get_or_insert_gdb_debug_scripts_section_global(ccx: &CrateContext)
 
 fn needs_gdb_debug_scripts_section(ccx: &CrateContext) -> bool {
     let omit_gdb_pretty_printer_section =
-        attr::contains_name(ccx.tcx()
-                               .map
-                               .krate()
-                               .attrs
-                               .as_slice(),
+        attr::contains_name(&ccx.tcx()
+                                .map
+                                .krate()
+                                .attrs,
                             "omit_gdb_pretty_printer_section");
 
     !omit_gdb_pretty_printer_section &&
index 44eb5b190e1a65666aafad1f46abd1cb44ac9793..dea34baad376fc8e5b40e9f7781e3a5b61b94874 100644 (file)
@@ -350,7 +350,7 @@ fn unsize_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         debug!("dest_ty={}", unsized_ty.repr(bcx.tcx()));
         // Closures for extracting and manipulating the data and payload parts of
         // the fat pointer.
-        let info = |bcx, _val| unsized_info(bcx,
+        let info = |bcx, _val| unsized_info(bcx,
                                               k,
                                               expr.id,
                                               datum_ty,
@@ -382,8 +382,8 @@ fn ref_fat_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                -> DatumBlock<'blk, 'tcx, Expr> {
         let tcx = bcx.tcx();
         let dest_ty = ty::close_type(tcx, datum.ty);
-        let base = |bcx, val| Load(bcx, get_dataptr(bcx, val));
-        let len = |bcx, val| Load(bcx, get_len(bcx, val));
+        let base = |bcx, val| Load(bcx, get_dataptr(bcx, val));
+        let len = |bcx, val| Load(bcx, get_len(bcx, val));
         into_fat_ptr(bcx, expr, datum, dest_ty, base, len)
     }
 
@@ -1056,7 +1056,7 @@ fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
             if let Some(did) = did {
                 let substs = Substs::new_type(ty_params, vec![]);
                 trans_struct(bcx,
-                             fields.as_slice(),
+                             &fields,
                              None,
                              expr.span,
                              expr.id,
@@ -1398,7 +1398,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         trans_adt(bcx,
                   ty,
                   discr,
-                  numbered_fields.as_slice(),
+                  &numbered_fields,
                   optbase,
                   dest,
                   DebugLoc::At(expr_id, expr_span))
index 00bb3036546763787988d23ea4e5559e939d4bf0..48f519398cee5fd89d6b73048912e36358acaf7b 100644 (file)
@@ -431,7 +431,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 // ABIs are handled at all correctly.
 fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
     if !tcx.sess.features.borrow().simd_ffi {
-        let check = |&: ast_ty: &ast::Ty, ty: ty::Ty| {
+        let check = |ast_ty: &ast::Ty, ty: ty::Ty| {
             if ty::type_is_simd(tcx, ty) {
                 tcx.sess.span_err(ast_ty.span,
                               &format!("use of SIMD type `{}` in FFI is highly experimental and \
@@ -649,7 +649,7 @@ unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         // Array for the arguments we will pass to the rust function.
         let mut llrust_args = Vec::new();
         let mut next_foreign_arg_counter: c_uint = 0;
-        let mut next_foreign_arg = |&mut : pad: bool| -> c_uint {
+        let mut next_foreign_arg = |pad: bool| -> c_uint {
             next_foreign_arg_counter += if pad {
                 2
             } else {
@@ -788,7 +788,7 @@ unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         debug!("calling llrustfn = {}, t = {}",
                ccx.tn().val_to_string(llrustfn), t.repr(ccx.tcx()));
         let attributes = base::get_fn_llvm_attributes(ccx, t);
-        let llrust_ret_val = builder.call(llrustfn, llrust_args.as_slice(), Some(attributes));
+        let llrust_ret_val = builder.call(llrustfn, &llrust_args, Some(attributes));
 
         // Get the return value where the foreign fn expects it.
         let llforeign_ret_ty = match tys.fn_ty.ret_ty.cast {
@@ -898,7 +898,7 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         _ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
     };
     let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
-    let llsig = foreign_signature(ccx, &fn_sig, fn_sig.inputs.as_slice());
+    let llsig = foreign_signature(ccx, &fn_sig, &fn_sig.inputs);
     let fn_ty = cabi::compute_abi_info(ccx,
                                        &llsig.llarg_tys[],
                                        llsig.llret_ty,
@@ -911,7 +911,7 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
            ty.repr(ccx.tcx()),
            ccx.tn().types_to_str(&llsig.llarg_tys[]),
            ccx.tn().type_to_string(llsig.llret_ty),
-           ccx.tn().types_to_str(fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>().as_slice()),
+           ccx.tn().types_to_str(&fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>()),
            ccx.tn().type_to_string(fn_ty.ret_ty.ty),
            llsig.ret_def);
 
@@ -959,7 +959,7 @@ fn lltype_for_fn_from_foreign_types(ccx: &CrateContext, tys: &ForeignTypes) -> T
     }
 
     if tys.fn_sig.variadic {
-        Type::variadic_func(llargument_tys.as_slice(), &llreturn_ty)
+        Type::variadic_func(&llargument_tys, &llreturn_ty)
     } else {
         Type::func(&llargument_tys[], &llreturn_ty)
     }
index 6228043eeb1a9b307bf50dfa4e57f33ed0189e28..08be8fa193dda951d65ea32421a94b549187d8be 100644 (file)
@@ -118,25 +118,25 @@ pub fn check_intrinsics(ccx: &CrateContext) {
             if transmute_restriction.original_from != transmute_restriction.substituted_from {
                 ccx.sess().span_err(
                     transmute_restriction.span,
-                    format!("transmute called on types with potentially different sizes: \
-                             {} (could be {} bit{}) to {} (could be {} bit{})",
-                            ty_to_string(ccx.tcx(), transmute_restriction.original_from),
-                            from_type_size as uint,
-                            if from_type_size == 1 {""} else {"s"},
-                            ty_to_string(ccx.tcx(), transmute_restriction.original_to),
-                            to_type_size as uint,
-                            if to_type_size == 1 {""} else {"s"}).as_slice());
+                    &format!("transmute called on types with potentially different sizes: \
+                              {} (could be {} bit{}) to {} (could be {} bit{})",
+                             ty_to_string(ccx.tcx(), transmute_restriction.original_from),
+                             from_type_size as uint,
+                             if from_type_size == 1 {""} else {"s"},
+                             ty_to_string(ccx.tcx(), transmute_restriction.original_to),
+                             to_type_size as uint,
+                             if to_type_size == 1 {""} else {"s"}));
             } else {
                 ccx.sess().span_err(
                     transmute_restriction.span,
-                    format!("transmute called on types with different sizes: \
-                             {} ({} bit{}) to {} ({} bit{})",
-                            ty_to_string(ccx.tcx(), transmute_restriction.original_from),
-                            from_type_size as uint,
-                            if from_type_size == 1 {""} else {"s"},
-                            ty_to_string(ccx.tcx(), transmute_restriction.original_to),
-                            to_type_size as uint,
-                            if to_type_size == 1 {""} else {"s"}).as_slice());
+                    &format!("transmute called on types with different sizes: \
+                              {} ({} bit{}) to {} ({} bit{})",
+                             ty_to_string(ccx.tcx(), transmute_restriction.original_from),
+                             from_type_size as uint,
+                             if from_type_size == 1 {""} else {"s"},
+                             ty_to_string(ccx.tcx(), transmute_restriction.original_to),
+                             to_type_size as uint,
+                             if to_type_size == 1 {""} else {"s"}));
             }
         }
     }
@@ -183,7 +183,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                 // This should be caught by the intrinsicck pass
                 assert_eq!(in_type_size, out_type_size);
 
-                let nonpointer_nonaggregate = |&: llkind: TypeKind| -> bool {
+                let nonpointer_nonaggregate = |llkind: TypeKind| -> bool {
                     use llvm::TypeKind::*;
                     match llkind {
                         Half | Float | Double | X86_FP80 | FP128 |
@@ -309,7 +309,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
     let simple = get_simple_intrinsic(ccx, &*foreign_item);
     let llval = match (simple, name.get()) {
         (Some(llfn), _) => {
-            Call(bcx, llfn, llargs.as_slice(), None, call_debug_location)
+            Call(bcx, llfn, &llargs, None, call_debug_location)
         }
         (_, "breakpoint") => {
             let llfn = ccx.get_intrinsic(&("llvm.debugtrap"));
index f522024c2e7e910ec782cb5ad4fbd0233fbb0adb..9c440d4509e0090c546ab848e7f3ba0201ee3c43 100644 (file)
@@ -567,8 +567,8 @@ pub fn trans_object_shim<'a, 'tcx>(
                 data.principal_trait_ref_with_self_ty(tcx, object_ty)
             }
             _ => {
-                tcx.sess.bug(format!("trans_object_shim() called on non-object: {}",
-                                     object_ty.repr(tcx)).as_slice());
+                tcx.sess.bug(&format!("trans_object_shim() called on non-object: {}",
+                                      object_ty.repr(tcx)));
             }
         };
 
@@ -595,7 +595,7 @@ pub fn trans_object_shim<'a, 'tcx>(
     let function_name =
         link::mangle_internal_name_by_type_and_seq(ccx, method_bare_fn_ty, "object_shim");
     let llfn =
-        decl_internal_rust_fn(ccx, method_bare_fn_ty, function_name.as_slice());
+        decl_internal_rust_fn(ccx, method_bare_fn_ty, &function_name);
 
     let sig = ty::erase_late_bound_regions(ccx.tcx(), &fty.sig);
 
@@ -624,11 +624,11 @@ pub fn trans_object_shim<'a, 'tcx>(
             RustCall => {
                 // unpack the tuple to extract the input type arguments:
                 match sig.inputs[1].sty {
-                    ty::ty_tup(ref tys) => tys.as_slice(),
+                    ty::ty_tup(ref tys) => &**tys,
                     _ => {
                         bcx.sess().bug(
-                            format!("rust-call expects a tuple not {}",
-                                    sig.inputs[1].repr(tcx)).as_slice());
+                            &format!("rust-call expects a tuple not {}",
+                                     sig.inputs[1].repr(tcx)));
                     }
                 }
             }
@@ -673,7 +673,7 @@ pub fn trans_object_shim<'a, 'tcx>(
                                                                   method_bare_fn_ty,
                                                                   method_offset_in_vtable,
                                                                   llobject),
-                           ArgVals(llargs.as_slice()),
+                           ArgVals(&llargs),
                            dest).bcx;
 
     finish_fn(&fcx, bcx, sig.output, DebugLoc::None);
@@ -744,8 +744,8 @@ pub fn get_vtable<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 // an object type; this cannot happen because we
                 // cannot cast an unsized type into a trait object
                 bcx.sess().bug(
-                    format!("cannot get vtable for an object type: {}",
-                            data.repr(bcx.tcx())).as_slice());
+                    &format!("cannot get vtable for an object type: {}",
+                             data.repr(bcx.tcx())));
             }
             traits::VtableParam(..) => {
                 bcx.sess().bug(
index b3d388b0f0236b3e8f257db91d197b44fceba0bd..5796e72a61018e126d43f7cc6c32a6c8ad1313c3 100644 (file)
@@ -139,7 +139,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
     // This shouldn't need to option dance.
     let mut hash_id = Some(hash_id);
-    let mut mk_lldecl = |&mut : abi: abi::Abi| {
+    let mut mk_lldecl = |abi: abi::Abi| {
         let lldecl = if abi != abi::Rust {
             foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, &s[])
         } else {
@@ -149,7 +149,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         ccx.monomorphized().borrow_mut().insert(hash_id.take().unwrap(), lldecl);
         lldecl
     };
-    let setup_lldecl = |&: lldecl, attrs: &[ast::Attribute]| {
+    let setup_lldecl = |lldecl, attrs: &[ast::Attribute]| {
         base::update_linkage(ccx, lldecl, None, base::OriginalTranslation);
         set_llvm_fn_attrs(ccx, attrs, lldecl);
 
index 2243982c20d61fcea680e035475493a91c4779a7..9d1c0fadefcd22718ca1dac09debc1fb7cb9e3fc 100644 (file)
@@ -113,7 +113,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     let mut atys: Vec<Type> = Vec::new();
 
     // First, munge the inputs, if this has the `rust-call` ABI.
-    let inputs = untuple_arguments_if_necessary(cx, sig.inputs.as_slice(), abi);
+    let inputs = untuple_arguments_if_necessary(cx, &sig.inputs, abi);
 
     // Arg 0: Output pointer.
     // (if the output type is non-immediate)
index 8809931cd80c23b23f81096be36772dd5b33d520..58f4d3f1bc0379bc6b9e8cf1c1d10abfd5ee0bd0 100644 (file)
@@ -272,7 +272,7 @@ pub fn ast_path_substs_for_ty<'tcx>(
         }
     };
 
-    prohibit_projections(this.tcx(), assoc_bindings.as_slice());
+    prohibit_projections(this.tcx(), &assoc_bindings);
 
     create_substs_for_ast_path(this,
                                rscope,
@@ -656,7 +656,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
 
     match projections {
         None => {
-            prohibit_projections(this.tcx(), assoc_bindings.as_slice());
+            prohibit_projections(this.tcx(), &assoc_bindings);
         }
         Some(ref mut v) => {
             for binding in &assoc_bindings {
@@ -960,7 +960,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
 
         // FIXME(#20300) -- search where clauses, not bounds
         suitable_bounds =
-            traits::transitive_bounds(tcx, ty_param_def.bounds.trait_bounds.as_slice())
+            traits::transitive_bounds(tcx, &ty_param_def.bounds.trait_bounds)
             .filter(|b| trait_defines_associated_type_named(this, b.def_id(), assoc_name))
             .collect();
     }
@@ -1595,11 +1595,11 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
     let region_bound = compute_region_bound(this,
                                             rscope,
                                             span,
-                                            region_bounds.as_slice(),
+                                            &region_bounds,
                                             principal_trait_ref,
                                             builtin_bounds);
 
-    ty::sort_bounds_list(projection_bounds.as_mut_slice());
+    ty::sort_bounds_list(&mut projection_bounds);
 
     ty::ExistentialBounds {
         region_bound: region_bound,
index 174a902953476da2db8519a7cca58188dbb3bb2e..1249e0d8ce1e549979cf446f3368a49d1a809e58 100644 (file)
@@ -164,7 +164,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
             check_pat_enum(pcx, pat, path, subpats, expected);
         }
         ast::PatStruct(ref path, ref fields, etc) => {
-            check_pat_struct(pcx, pat, path, fields.as_slice(), etc, expected);
+            check_pat_struct(pcx, pat, path, fields, etc, expected);
         }
         ast::PatTup(ref elements) => {
             let element_tys: Vec<_> =
@@ -480,7 +480,7 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx ast::Pat,
         .unwrap_or_else(|| Substs::empty());
 
     let struct_fields = ty::struct_fields(tcx, variant_def_id, &item_substs);
-    check_struct_pat_fields(pcx, pat.span, fields, struct_fields.as_slice(),
+    check_struct_pat_fields(pcx, pat.span, fields, &struct_fields,
                             variant_def_id, etc);
 }
 
index 93c6445606eb896ebe2bb0b7025a0bdc6ceadd19..6a9d34d7637b23d57a9be8b71387f5e991dd47b6 100644 (file)
@@ -252,10 +252,10 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
                                                       call_expr.span,
                                                       expected,
                                                       fn_sig.output,
-                                                      fn_sig.inputs.as_slice());
+                                                      &fn_sig.inputs);
     check_argument_types(fcx,
                          call_expr.span,
-                         fn_sig.inputs.as_slice(),
+                         &fn_sig.inputs,
                          &expected_arg_tys[],
                          arg_exprs,
                          AutorefArgs::No,
index 1cfb019395870fa63ec47d6b6125f52dfc270764..77701af25d39ab0f9aebde4fd8d7c19f77a41936 100644 (file)
@@ -655,9 +655,9 @@ fn upcast(&mut self,
             None => {
                 self.tcx().sess.span_bug(
                     self.span,
-                    format!("cannot upcast `{}` to `{}`",
-                            source_trait_ref.repr(self.tcx()),
-                            target_trait_def_id.repr(self.tcx())).as_slice());
+                    &format!("cannot upcast `{}` to `{}`",
+                             source_trait_ref.repr(self.tcx()),
+                             target_trait_def_id.repr(self.tcx())));
             }
         }
     }
index a988fb4cc6e19015e0b58ec43b737db33bbd6742..ba49ae637b32e6cd9c6de0f2dd3bd8eeb2cd5d1d 100644 (file)
@@ -368,7 +368,7 @@ fn assemble_inherent_candidates_from_param(&mut self,
             })
             .collect();
 
-        self.elaborate_bounds(bounds.as_slice(), |this, poly_trait_ref, m, method_num| {
+        self.elaborate_bounds(&bounds, |this, poly_trait_ref, m, method_num| {
             let trait_ref =
                 this.erase_late_bound_regions(&poly_trait_ref);
 
index c22d2a9bb416fe01a4e5537a29f22efb0dc00128..063300a1d72803778be778f1febfaf6036da028a 100644 (file)
@@ -342,7 +342,7 @@ fn handle_external_def(traits: &mut AllTraitsVec,
             }
         }
         let cstore = &ccx.tcx.sess.cstore;
-        cstore.iter_crate_data(|&mut: cnum, _| {
+        cstore.iter_crate_data(|cnum, _| {
             csearch::each_top_level_item_of_crate(cstore, cnum, |dl, _, _| {
                 handle_external_def(&mut traits, ccx, cstore, dl)
             })
index adf15fbf28a8f040708e9e9aaea3b371558fdd9a..fb05450373f7df437fcfb3a77ccae960ca627633 100644 (file)
@@ -730,7 +730,7 @@ pub fn check_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
                 check_impl_items_against_trait(ccx,
                                                it.span,
                                                &*impl_trait_ref,
-                                               impl_items.as_slice());
+                                               impl_items);
               }
               None => { }
           }
@@ -801,12 +801,12 @@ pub fn check_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
 fn check_trait_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                generics: &ast::Generics,
                                item: &ast::Item) {
-    if let Some(ref attr) = item.attrs.iter().find(|&: a| {
+    if let Some(ref attr) = item.attrs.iter().find(|a| {
         a.check_name("rustc_on_unimplemented")
     }) {
         if let Some(ref istring) = attr.value_str() {
             let parser = Parser::new(istring.get());
-            let types = generics.ty_params.as_slice();
+            let types = &*generics.ty_params;
             for token in parser {
                 match token {
                     Piece::String(_) => (), // Normal string, no need to check it
@@ -908,9 +908,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                 // caught in resolve.
                                 tcx.sess.span_bug(
                                     impl_method.span,
-                                    format!("item `{}` is of a different kind from its trait `{}`",
-                                            token::get_name(impl_item_ty.name()),
-                                            impl_trait_ref.repr(tcx)).as_slice());
+                                    &format!("item `{}` is of a different kind from its trait `{}`",
+                                             token::get_name(impl_item_ty.name()),
+                                             impl_trait_ref.repr(tcx)));
                             }
                         }
                     }
@@ -919,9 +919,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                         // caught in resolve.
                         tcx.sess.span_bug(
                             impl_method.span,
-                            format!("method `{}` is not a member of trait `{}`",
-                                    token::get_name(impl_item_ty.name()),
-                                    impl_trait_ref.repr(tcx)).as_slice());
+                            &format!("method `{}` is not a member of trait `{}`",
+                                     token::get_name(impl_item_ty.name()),
+                                     impl_trait_ref.repr(tcx)));
                     }
                 }
             }
@@ -944,9 +944,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                 // already been caught in resolve.
                                 tcx.sess.span_bug(
                                     typedef.span,
-                                    format!("item `{}` is of a different kind from its trait `{}`",
-                                            token::get_name(typedef_ty.name()),
-                                            impl_trait_ref.repr(tcx)).as_slice());
+                                    &format!("item `{}` is of a different kind from its trait `{}`",
+                                             token::get_name(typedef_ty.name()),
+                                             impl_trait_ref.repr(tcx)));
                             }
                         }
                     }
@@ -955,11 +955,11 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                         // caught in resolve.
                         tcx.sess.span_bug(
                             typedef.span,
-                            format!(
+                            &format!(
                                 "associated type `{}` is not a member of \
                                  trait `{}`",
                                 token::get_name(typedef_ty.name()),
-                                impl_trait_ref.repr(tcx)).as_slice());
+                                impl_trait_ref.repr(tcx)));
                     }
                 }
             }
@@ -1715,7 +1715,7 @@ pub fn adjust_expr_ty(&self,
     {
         let raw_ty = self.expr_ty(expr);
         let raw_ty = self.infcx().shallow_resolve(raw_ty);
-        let resolve_ty = |&: ty: Ty<'tcx>| self.infcx().resolve_type_vars_if_possible(&ty);
+        let resolve_ty = |ty: Ty<'tcx>| self.infcx().resolve_type_vars_if_possible(&ty);
         ty::adjust_ty(self.tcx(),
                       expr.span,
                       expr.id,
@@ -3123,7 +3123,7 @@ fn suggest_field_names<'tcx>(id : DefId,
         }
         if let Some(n) = best {
             tcx.sess.span_help(field.span,
-                format!("did you mean `{}`?", n).as_slice());
+                &format!("did you mean `{}`?", n));
         }
     }
 
@@ -3734,7 +3734,7 @@ fn check_struct_fields_on_error<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
         }
       }
       ast::ExprMatch(ref discrim, ref arms, match_src) => {
-        _match::check_match(fcx, expr, &**discrim, arms.as_slice(), expected, match_src);
+        _match::check_match(fcx, expr, &**discrim, arms, expected, match_src);
       }
       ast::ExprClosure(capture, ref decl, ref body) => {
           closure::check_expr_closure(fcx, expr, capture, &**decl, &**body, expected);
@@ -5217,7 +5217,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
 
 pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
     fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
-        let name = token::intern(format!("P{}", n).as_slice());
+        let name = token::intern(&format!("P{}", n));
         ty::mk_param(ccx.tcx, subst::FnSpace, n, name)
     }
 
index 6f66010925ec0b5411d059312947ce6bdb08c573..3ff36f8c44f5fbc7bf8d42654e3d43906e70ca38 100644 (file)
@@ -153,31 +153,31 @@ pub fn check_object_safety<'tcx>(tcx: &ty::ctxt<'tcx>,
             ObjectSafetyViolation::Method(method, MethodViolationCode::ByValueSelf) => {
                 tcx.sess.span_note(
                     span,
-                    format!("method `{}` has a receiver type of `Self`, \
-                             which cannot be used with a trait object",
-                            method.name.user_string(tcx)).as_slice());
+                    &format!("method `{}` has a receiver type of `Self`, \
+                              which cannot be used with a trait object",
+                             method.name.user_string(tcx)));
             }
 
             ObjectSafetyViolation::Method(method, MethodViolationCode::StaticMethod) => {
                 tcx.sess.span_note(
                     span,
-                    format!("method `{}` has no receiver",
-                            method.name.user_string(tcx)).as_slice());
+                    &format!("method `{}` has no receiver",
+                             method.name.user_string(tcx)));
             }
 
             ObjectSafetyViolation::Method(method, MethodViolationCode::ReferencesSelf) => {
                 tcx.sess.span_note(
                     span,
-                    format!("method `{}` references the `Self` type \
-                             in its arguments or return type",
-                            method.name.user_string(tcx)).as_slice());
+                    &format!("method `{}` references the `Self` type \
+                              in its arguments or return type",
+                             method.name.user_string(tcx)));
             }
 
             ObjectSafetyViolation::Method(method, MethodViolationCode::Generic) => {
                 tcx.sess.span_note(
                     span,
-                    format!("method `{}` has generic type parameters",
-                            method.name.user_string(tcx)).as_slice());
+                    &format!("method `{}` has generic type parameters",
+                             method.name.user_string(tcx)));
             }
         }
     }
index 71b495af444dd240f313e5a53f59ecedd489355c..1079e87a48bf620cac30fa691412f88e05adfe59 100644 (file)
@@ -170,7 +170,7 @@ fn check_type_defn<F>(&mut self, item: &ast::Item, mut lookup_fields: F) where
                 variants.iter().flat_map(|v| v.fields.iter().map(|f| f.ty)).collect();
 
             regionck::regionck_ensure_component_tys_wf(
-                fcx, item.span, field_tys.as_slice());
+                fcx, item.span, &field_tys);
         });
     }
 
@@ -227,7 +227,7 @@ fn check_impl(&mut self,
             // There are special rules that apply to drop.
             if
                 fcx.tcx().lang_items.drop_trait() == Some(trait_ref.def_id) &&
-                !attr::contains_name(item.attrs.as_slice(), "unsafe_destructor")
+                !attr::contains_name(&item.attrs, "unsafe_destructor")
             {
                 match self_ty.sty {
                     ty::ty_struct(def_id, _) |
index 5b97175ab22fbda3e2f675ba0f96db5b7f50ac15..a571b2793df17906a806f40a12eb4305095fe82e 100644 (file)
@@ -94,9 +94,9 @@ fn visit_item(&mut self, item: &'v ast::Item) {
                                     param_ty.user_string(self.tcx));
                             self.tcx.sess.span_note(
                                 item.span,
-                                format!("for a limited time, you can add \
-                                         `#![feature(old_orphan_check)]` to your crate \
-                                         to disable this rule").as_slice());
+                                &format!("for a limited time, you can add \
+                                          `#![feature(old_orphan_check)]` to your crate \
+                                          to disable this rule"));
                         }
                     }
                 }
index 7dfa5298fb4c78b092d2e438b8b4694193f8ba27..ce26658cf4b9392535ce65ff3ccf20d0327c6727 100644 (file)
@@ -169,9 +169,9 @@ fn get_item_type_scheme(&self, id: ast::DefId) -> ty::TypeScheme<'tcx> {
                 ty_of_foreign_item(self, &*foreign_item, abi)
             }
             x => {
-                self.tcx.sess.bug(format!("unexpected sort of node \
-                                           in get_item_type_scheme(): {:?}",
-                                          x).as_slice());
+                self.tcx.sess.bug(&format!("unexpected sort of node \
+                                            in get_item_type_scheme(): {:?}",
+                                           x));
             }
         }
     }
@@ -562,7 +562,7 @@ fn convert(ccx: &CollectCtxt, it: &ast::Item) {
             write_ty_to_tcx(tcx, it.id, scheme.ty);
             get_enum_variant_types(ccx,
                                    scheme.ty,
-                                   enum_definition.variants.as_slice(),
+                                   &enum_definition.variants,
                                    generics);
         },
         ast::ItemImpl(_, _,
@@ -846,7 +846,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
                        ref generics,
                        ref supertraits,
                        ref items) => {
-            (unsafety, generics, supertraits, items.as_slice())
+            (unsafety, generics, supertraits, items)
         }
         ref s => {
             tcx.sess.span_bug(
@@ -878,7 +878,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
 
     let bounds = compute_bounds(ccx,
                                 self_param_ty.to_ty(ccx.tcx),
-                                bounds.as_slice(),
+                                bounds,
                                 SizedByDefault::No,
                                 it.span);
 
@@ -1136,7 +1136,7 @@ fn predicates_for_associated_types<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
 
                 let bounds = compute_bounds(ccx,
                                             assoc_ty,
-                                            assoc_type_def.bounds.as_slice(),
+                                            &*assoc_type_def.bounds,
                                             SizedByDefault::Yes,
                                             assoc_type_def.span);
 
@@ -1448,7 +1448,7 @@ fn conv_param_bounds<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
     let astconv::PartitionedBounds { builtin_bounds,
                                      trait_bounds,
                                      region_bounds } =
-        astconv::partition_bounds(ccx.tcx, span, ast_bounds.as_slice());
+        astconv::partition_bounds(ccx.tcx, span, ast_bounds);
 
     let mut projection_bounds = Vec::new();
 
@@ -1701,9 +1701,9 @@ fn enforce_impl_ty_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
             if ty::has_attr(tcx, impl_def_id, "old_impl_check") {
                 tcx.sess.span_warn(
                     ty_param.span,
-                    format!("the type parameter `{}` is not constrained by the \
-                             impl trait, self type, or predicates",
-                            param_ty.user_string(tcx)).as_slice());
+                    &format!("the type parameter `{}` is not constrained by the \
+                              impl trait, self type, or predicates",
+                             param_ty.user_string(tcx)));
             } else {
                 span_err!(tcx.sess, ty_param.span, E0207,
                     "the type parameter `{}` is not constrained by the \
@@ -1711,8 +1711,8 @@ impl trait, self type, or predicates",
                             param_ty.user_string(tcx));
                 tcx.sess.span_help(
                     ty_param.span,
-                    format!("you can temporarily opt out of this rule by placing \
-                             the `#[old_impl_check]` attribute on the impl").as_slice());
+                    &format!("you can temporarily opt out of this rule by placing \
+                              the `#[old_impl_check]` attribute on the impl"));
             }
         }
     }
index 40197ee2c4988bf3eb0c717340f8a502d52a1864..567a388836f25e52c382b36616accb5d5ebf5918 100644 (file)
 use self::ParamKind::*;
 
 use arena;
-use arena::Arena;
+use arena::TypedArena;
 use middle::resolve_lifetime as rl;
 use middle::subst;
 use middle::subst::{ParamSpace, FnSpace, TypeSpace, SelfSpace, VecPerParamSpace};
 
 pub fn infer_variance(tcx: &ty::ctxt) {
     let krate = tcx.map.krate();
-    let mut arena = arena::Arena::new();
+    let mut arena = arena::TypedArena::new();
     let terms_cx = determine_parameters_to_be_inferred(tcx, &mut arena, krate);
     let constraints_cx = add_constraints_from_crate(terms_cx, krate);
     solve_constraints(constraints_cx);
@@ -254,7 +254,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 struct TermsContext<'a, 'tcx: 'a> {
     tcx: &'a ty::ctxt<'tcx>,
-    arena: &'a Arena,
+    arena: &'a TypedArena<VarianceTerm<'a>>,
 
     empty_variances: Rc<ty::ItemVariances>,
 
@@ -282,7 +282,7 @@ struct InferredInfo<'a> {
 }
 
 fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
-                                                 arena: &'a mut Arena,
+                                                 arena: &'a mut TypedArena<VarianceTerm<'a>>,
                                                  krate: &ast::Crate)
                                                  -> TermsContext<'a, 'tcx> {
     let mut terms_cx = TermsContext {
@@ -312,7 +312,7 @@ fn add_inferred(&mut self,
                     index: uint,
                     param_id: ast::NodeId) {
         let inf_index = InferredIndex(self.inferred_infos.len());
-        let term = self.arena.alloc(|| InferredTerm(inf_index));
+        let term = self.arena.alloc(InferredTerm(inf_index));
         self.inferred_infos.push(InferredInfo { item_id: item_id,
                                                 kind: kind,
                                                 space: space,
@@ -455,10 +455,10 @@ fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
 
     let unsafe_lang_item = terms_cx.tcx.lang_items.unsafe_type();
 
-    let covariant = terms_cx.arena.alloc(|| ConstantTerm(ty::Covariant));
-    let contravariant = terms_cx.arena.alloc(|| ConstantTerm(ty::Contravariant));
-    let invariant = terms_cx.arena.alloc(|| ConstantTerm(ty::Invariant));
-    let bivariant = terms_cx.arena.alloc(|| ConstantTerm(ty::Bivariant));
+    let covariant = terms_cx.arena.alloc(ConstantTerm(ty::Covariant));
+    let contravariant = terms_cx.arena.alloc(ConstantTerm(ty::Contravariant));
+    let invariant = terms_cx.arena.alloc(ConstantTerm(ty::Invariant));
+    let bivariant = terms_cx.arena.alloc(ConstantTerm(ty::Bivariant));
     let mut constraint_cx = ConstraintContext {
         terms_cx: terms_cx,
 
@@ -597,7 +597,7 @@ fn is_to_be_inferred(&self, param_id: ast::NodeId) -> bool {
         // parameter (by inspecting parent of its binding declaration
         // to see if it is introduced by a type or by a fn/impl).
 
-        let check_result = |&: this:&ConstraintContext| -> bool {
+        let check_result = |this:&ConstraintContext| -> bool {
             let tcx = this.terms_cx.tcx;
             let decl_id = this.find_binding_for_lifetime(param_id);
             // Currently only called on lifetimes; double-checking that.
@@ -719,7 +719,7 @@ fn xform(&mut self,
             }
 
             _ => {
-                &*self.terms_cx.arena.alloc(|| TransformTerm(v1, v2))
+                &*self.terms_cx.arena.alloc(TransformTerm(v1, v2))
             }
         }
     }
index 6e79bd9bebda1003233dfa0a9b8ce95d06e125f7..9cdad8fccbeb73d1bc5f2d16f67cc3375b0a2640 100644 (file)
@@ -195,7 +195,7 @@ fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Stru
     let fields = ty::lookup_struct_fields(tcx, did);
 
     clean::Struct {
-        struct_type: match fields.as_slice() {
+        struct_type: match &*fields {
             [] => doctree::Unit,
             [ref f] if f.name == unnamed_field.name => doctree::Newtype,
             [ref f, ..] if f.name == unnamed_field.name => doctree::Tuple,
@@ -340,7 +340,7 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
     let polarity = csearch::get_impl_polarity(tcx, did);
     return Some(clean::Item {
         inner: clean::ImplItem(clean::Impl {
-            derived: clean::detect_derived(attrs.as_slice()),
+            derived: clean::detect_derived(&attrs),
             trait_: associated_trait.clean(cx).map(|bound| {
                 match bound {
                     clean::TraitBound(polyt, _) => polyt.trait_,
index 57eaf042aa02edc676697cb3173d92d881dd0209..611251d4cfae114d895992a24def11931a680168 100644 (file)
@@ -48,7 +48,6 @@
 
 use std::rc::Rc;
 use std::u32;
-use std::str::Str as StrTrait; // Conflicts with Str variant
 use std::old_path::Path as FsPath; // Conflicts with Path struct
 
 use core::DocContext;
@@ -136,7 +135,7 @@ fn clean(&self, cx: &DocContext) -> Crate {
 
         // Figure out the name of this crate
         let input = &cx.input;
-        let name = link::find_crate_name(None, self.attrs.as_slice(), input);
+        let name = link::find_crate_name(None, &self.attrs, input);
 
         // Clean the crate, translating the entire libsyntax AST to one that is
         // understood by rustdoc.
@@ -171,7 +170,7 @@ fn clean(&self, cx: &DocContext) -> Crate {
                     ModuleItem(..) => {}
                     _ => continue,
                 }
-                let prim = match PrimitiveType::find(child.attrs.as_slice()) {
+                let prim = match PrimitiveType::find(&child.attrs) {
                     Some(prim) => prim,
                     None => continue,
                 };
@@ -223,7 +222,7 @@ fn clean(&self, cx: &DocContext) -> ExternalCrate {
                     _ => return
                 };
                 let attrs = inline::load_attrs(cx, tcx, did);
-                PrimitiveType::find(attrs.as_slice()).map(|prim| primitives.push(prim));
+                PrimitiveType::find(&attrs).map(|prim| primitives.push(prim));
             })
         });
         ExternalCrate {
@@ -257,7 +256,7 @@ pub fn doc_list<'a>(&'a self) -> Option<&'a [Attribute]> {
         for attr in &self.attrs {
             match *attr {
                 List(ref x, ref list) if "doc" == *x => {
-                    return Some(list.as_slice());
+                    return Some(list);
                 }
                 _ => {}
             }
@@ -271,7 +270,7 @@ pub fn doc_value<'a>(&'a self) -> Option<&'a str> {
         for attr in &self.attrs {
             match *attr {
                 NameValue(ref x, ref v) if "doc" == *x => {
-                    return Some(v.as_slice());
+                    return Some(v);
                 }
                 _ => {}
             }
@@ -433,7 +432,7 @@ impl attr::AttrMetaMethods for Attribute {
     fn name(&self) -> InternedString {
         match *self {
             Word(ref n) | List(ref n, _) | NameValue(ref n, _) => {
-                token::intern_and_get_ident(n.as_slice())
+                token::intern_and_get_ident(n)
             }
         }
     }
@@ -441,7 +440,7 @@ fn name(&self) -> InternedString {
     fn value_str(&self) -> Option<InternedString> {
         match *self {
             NameValue(_, ref v) => {
-                Some(token::intern_and_get_ident(v.as_slice()))
+                Some(token::intern_and_get_ident(v))
             }
             _ => None,
         }
@@ -626,7 +625,7 @@ fn clean(&self, cx: &DocContext) -> TyParamBound {
         let fqn = csearch::get_item_path(tcx, self.def_id);
         let fqn = fqn.into_iter().map(|i| i.to_string())
                      .collect::<Vec<String>>();
-        let path = external_path(cx, fqn.last().unwrap().as_slice(),
+        let path = external_path(cx, fqn.last().unwrap(),
                                  Some(self.def_id), vec![], self.substs);
         cx.external_paths.borrow_mut().as_mut().unwrap().insert(self.def_id,
                                                             (fqn, TypeTrait));
@@ -690,7 +689,7 @@ fn clean(&self, cx: &DocContext) -> Option<Vec<TyParamBound>> {
 impl Lifetime {
     pub fn get_ref<'a>(&'a self) -> &'a str {
         let Lifetime(ref s) = *self;
-        let s: &'a str = s.as_slice();
+        let s: &'a str = s;
         return s;
     }
 
@@ -952,7 +951,7 @@ impl Clean<Item> for ast::Method {
     fn clean(&self, cx: &DocContext) -> Item {
         let all_inputs = &self.pe_fn_decl().inputs;
         let inputs = match self.pe_explicit_self().node {
-            ast::SelfStatic => all_inputs.as_slice(),
+            ast::SelfStatic => &**all_inputs,
             _ => &all_inputs[1..]
         };
         let decl = FnDecl {
@@ -990,7 +989,7 @@ pub struct TyMethod {
 impl Clean<Item> for ast::TypeMethod {
     fn clean(&self, cx: &DocContext) -> Item {
         let inputs = match self.explicit_self.node {
-            ast::SelfStatic => self.decl.inputs.as_slice(),
+            ast::SelfStatic => &*self.decl.inputs,
             _ => &self.decl.inputs[1..]
         };
         let decl = FnDecl {
@@ -1104,7 +1103,7 @@ fn clean(&self, cx: &DocContext) -> FnDecl {
         } else {
             Vec::new().into_iter()
         }.peekable();
-        if names.peek().map(|s| s.as_slice()) == Some("self") {
+        if names.peek().map(|s| &**s) == Some("self") {
             let _ = names.next();
         }
         FnDecl {
@@ -1397,7 +1396,7 @@ pub enum TypeKind {
 
 impl PrimitiveType {
     fn from_str(s: &str) -> Option<PrimitiveType> {
-        match s.as_slice() {
+        match s {
             "isize" | "int" => Some(Isize),
             "i8" => Some(I8),
             "i16" => Some(I16),
@@ -1428,7 +1427,7 @@ fn find(attrs: &[Attribute]) -> Option<PrimitiveType> {
             for sub_attr in list {
                 let value = match *sub_attr {
                     NameValue(ref k, ref v)
-                        if *k == "primitive" => v.as_slice(),
+                        if *k == "primitive" => v,
                     _ => continue,
                 };
                 match PrimitiveType::from_str(value) {
@@ -1567,7 +1566,7 @@ fn clean(&self, cx: &DocContext) -> Type {
                     ty::ty_struct(..) => TypeStruct,
                     _ => TypeEnum,
                 };
-                let path = external_path(cx, fqn.last().unwrap().to_string().as_slice(),
+                let path = external_path(cx, &fqn.last().unwrap().to_string(),
                                          None, vec![], substs);
                 cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, kind));
                 ResolvedPath {
@@ -1581,7 +1580,7 @@ fn clean(&self, cx: &DocContext) -> Type {
                 let fqn = csearch::get_item_path(cx.tcx(), did);
                 let fqn: Vec<_> = fqn.into_iter().map(|i| i.to_string()).collect();
                 let (typarams, bindings) = bounds.clean(cx);
-                let path = external_path(cx, fqn.last().unwrap().to_string().as_slice(),
+                let path = external_path(cx, &fqn.last().unwrap().to_string(),
                                          Some(did), bindings, principal.substs());
                 cx.external_paths.borrow_mut().as_mut().unwrap().insert(did, (fqn, TypeTrait));
                 ResolvedPath {
@@ -1780,7 +1779,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 impl<'tcx> Clean<Item> for ty::VariantInfo<'tcx> {
     fn clean(&self, cx: &DocContext) -> Item {
         // use syntax::parse::token::special_idents::unnamed_field;
-        let kind = match self.arg_names.as_ref().map(|s| s.as_slice()) {
+        let kind = match self.arg_names.as_ref().map(|s| &**s) {
             None | Some([]) if self.args.len() == 0 => CLikeVariant,
             None | Some([]) => {
                 TupleVariant(self.args.clean(cx))
@@ -2132,7 +2131,7 @@ fn clean(&self, cx: &DocContext) -> Item {
                             TypeImplItem(i) => i,
                         }
                     }).collect(),
-                derived: detect_derived(self.attrs.as_slice()),
+                derived: detect_derived(&self.attrs),
                 polarity: Some(self.polarity.clean(cx)),
             }),
         }
@@ -2302,8 +2301,8 @@ impl ToSource for syntax::codemap::Span {
     fn to_src(&self, cx: &DocContext) -> String {
         debug!("converting span {:?} to snippet", self.clean(cx));
         let sn = match cx.sess().codemap().span_to_snippet(*self) {
-            Some(x) => x.to_string(),
-            None    => "".to_string()
+            Ok(x) => x.to_string(),
+            Err(_) => "".to_string()
         };
         debug!("got snippet {}", sn);
         sn
index fc3d6f5912ffb566c1a88f73001fc21551192c87..f862970446c14909dd0a2a6568b0c923a3b1fa25 100644 (file)
@@ -119,10 +119,10 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
 
     let krate = driver::phase_1_parse_input(&sess, cfg, &input);
 
-    let name = link::find_crate_name(Some(&sess), krate.attrs.as_slice(),
+    let name = link::find_crate_name(Some(&sess), &krate.attrs,
                                      &input);
 
-    let krate = driver::phase_2_configure_and_expand(&sess, krate, name.as_slice(), None)
+    let krate = driver::phase_2_configure_and_expand(&sess, krate, &name, None)
                     .expect("phase_2_configure_and_expand aborted in rustdoc!");
 
     let mut forest = ast_map::Forest::new(krate);
index 84e88158219ae584273f5e524d4c205f2d13d84d..942aec7d22f2c0bff99a4faaab2fce803e7cb477 100644 (file)
@@ -36,7 +36,7 @@ pub fn load(in_header: &[String], before_content: &[String], after_content: &[St
 pub fn load_string(input: &Path) -> old_io::IoResult<Option<String>> {
     let mut f = try!(old_io::File::open(input));
     let d = try!(f.read_to_end());
-    Ok(str::from_utf8(d.as_slice()).map(|s| s.to_string()).ok())
+    Ok(str::from_utf8(&d).map(|s| s.to_string()).ok())
 }
 
 macro_rules! load_or_return {
@@ -63,7 +63,7 @@ macro_rules! load_or_return {
 pub fn load_external_files(names: &[String]) -> Option<String> {
     let mut out = String::new();
     for name in names {
-        out.push_str(load_or_return!(name.as_slice(), None, None).as_slice());
+        out.push_str(&*load_or_return!(&name, None, None));
         out.push('\n');
     }
     Some(out)
index fe8ac3fde5fcc596e3a2f4f37dd0e09302e7859e..f04e1cc75202f348ceb13318ad89ec88dd13ff75 100644 (file)
@@ -24,7 +24,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         // Because the internet is always right, turns out there's not that many
         // characters to escape: http://stackoverflow.com/questions/7381974
         let Escape(s) = *self;
-        let pile_o_bits = s.as_slice();
+        let pile_o_bits = s;
         let mut last = 0;
         for (i, ch) in s.bytes().enumerate() {
             match ch as char {
index e86c0e39714083faacbcaf37bf61441b0562f9cb..7a6157b63b5b003f543b2df5482f08d931d692e2 100644 (file)
@@ -109,10 +109,10 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 if i > 0 {
                     try!(f.write_str(", "))
                 }
-                try!(f.write_str(tp.name.as_slice()));
+                try!(f.write_str(&tp.name));
 
                 if tp.bounds.len() > 0 {
-                    try!(write!(f, ": {}", TyParamBounds(tp.bounds.as_slice())));
+                    try!(write!(f, ": {}", TyParamBounds(&tp.bounds)));
                 }
 
                 match tp.default {
@@ -139,7 +139,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             }
             match pred {
                 &clean::WherePredicate::BoundPredicate { ref ty, ref bounds } => {
-                    let bounds = bounds.as_slice();
+                    let bounds = bounds;
                     try!(write!(f, "{}: {}", ty, TyParamBounds(bounds)));
                 }
                 &clean::WherePredicate::RegionPredicate { ref lifetime,
@@ -259,7 +259,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 impl fmt::Display for clean::PathSegment {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(f.write_str(self.name.as_slice()));
+        try!(f.write_str(&self.name));
         write!(f, "{}", self.params)
     }
 }
@@ -321,8 +321,8 @@ fn path<F, G>(w: &mut fmt::Formatter,
 
     let loc = CURRENT_LOCATION_KEY.with(|l| l.borrow().clone());
     let cache = cache();
-    let abs_root = root(&*cache, loc.as_slice());
-    let rel_root = match path.segments[0].name.as_slice() {
+    let abs_root = root(&*cache, &loc);
+    let rel_root = match &*path.segments[0].name {
         "self" => Some("./".to_string()),
         _ => None,
     };
@@ -331,17 +331,17 @@ fn path<F, G>(w: &mut fmt::Formatter,
         let amt = path.segments.len() - 1;
         match rel_root {
             Some(root) => {
-                let mut root = String::from_str(root.as_slice());
+                let mut root = String::from_str(&root);
                 for seg in &path.segments[..amt] {
                     if "super" == seg.name ||
                             "self" == seg.name {
                         try!(write!(w, "{}::", seg.name));
                     } else {
-                        root.push_str(seg.name.as_slice());
+                        root.push_str(&seg.name);
                         root.push_str("/");
                         try!(write!(w, "<a class='mod'
                                             href='{}index.html'>{}</a>::",
-                                      root.as_slice(),
+                                      root,
                                       seg.name));
                     }
                 }
@@ -357,21 +357,21 @@ fn path<F, G>(w: &mut fmt::Formatter,
     match info(&*cache) {
         // This is a documented path, link to it!
         Some((ref fqp, shortty)) if abs_root.is_some() => {
-            let mut url = String::from_str(abs_root.unwrap().as_slice());
+            let mut url = String::from_str(&abs_root.unwrap());
             let to_link = &fqp[..fqp.len() - 1];
             for component in to_link {
-                url.push_str(component.as_slice());
+                url.push_str(component);
                 url.push_str("/");
             }
             match shortty {
                 ItemType::Module => {
-                    url.push_str(fqp.last().unwrap().as_slice());
+                    url.push_str(fqp.last().unwrap());
                     url.push_str("/index.html");
                 }
                 _ => {
                     url.push_str(shortty.to_static_str());
                     url.push_str(".");
-                    url.push_str(fqp.last().unwrap().as_slice());
+                    url.push_str(fqp.last().unwrap());
                     url.push_str(".html");
                 }
             }
@@ -384,7 +384,7 @@ fn path<F, G>(w: &mut fmt::Formatter,
             try!(write!(w, "{}", last.name));
         }
     }
-    try!(write!(w, "{}", generics.as_slice()));
+    try!(write!(w, "{}", generics));
     Ok(())
 }
 
@@ -454,10 +454,10 @@ impl fmt::Display for clean::Type {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::TyParamBinder(id) => {
-                f.write_str(cache().typarams[ast_util::local_def(id)].as_slice())
+                f.write_str(&cache().typarams[ast_util::local_def(id)])
             }
             clean::Generic(ref name) => {
-                f.write_str(name.as_slice())
+                f.write_str(name)
             }
             clean::ResolvedPath{ did, ref typarams, ref path } => {
                 try!(resolved_path(f, did, path, false));
@@ -468,7 +468,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             clean::BareFunction(ref decl) => {
                 write!(f, "{}{}fn{}{}",
                        UnsafetySpace(decl.unsafety),
-                       match decl.abi.as_slice() {
+                       match &*decl.abi {
                            "" => " extern ".to_string(),
                            "\"Rust\"" => "".to_string(),
                            s => format!(" extern {} ", s)
@@ -478,18 +478,17 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             }
             clean::Tuple(ref typs) => {
                 primitive_link(f, clean::PrimitiveTuple,
-                               match typs.as_slice() {
+                               &*match &**typs {
                                     [ref one] => format!("({},)", one),
-                                    many => format!("({})",
-                                                    CommaSep(many.as_slice()))
-                               }.as_slice())
+                                    many => format!("({})", CommaSep(&many)),
+                               })
             }
             clean::Vector(ref t) => {
-                primitive_link(f, clean::Slice, format!("[{}]", **t).as_slice())
+                primitive_link(f, clean::Slice, &format!("[{}]", **t))
             }
             clean::FixedVector(ref t, ref s) => {
                 primitive_link(f, clean::Slice,
-                               format!("[{}; {}]", **t, *s).as_slice())
+                               &format!("[{}; {}]", **t, *s))
             }
             clean::Bottom => f.write_str("!"),
             clean::RawPointer(m, ref t) => {
@@ -506,10 +505,10 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                         match **bt {
                             clean::Generic(_) =>
                                 primitive_link(f, clean::Slice,
-                                    format!("&amp;{}{}[{}]", lt, m, **bt).as_slice()),
+                                    &format!("&amp;{}{}[{}]", lt, m, **bt)),
                             _ => {
                                 try!(primitive_link(f, clean::Slice,
-                                    format!("&amp;{}{}[", lt, m).as_slice()));
+                                    &format!("&amp;{}{}[", lt, m)));
                                 try!(write!(f, "{}", **bt));
                                 primitive_link(f, clean::Slice, "]")
                             }
@@ -577,23 +576,21 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             clean::SelfStatic => {},
             clean::SelfValue => args.push_str("self"),
             clean::SelfBorrowed(Some(ref lt), mtbl) => {
-                args.push_str(format!("&amp;{} {}self", *lt,
-                                      MutableSpace(mtbl)).as_slice());
+                args.push_str(&format!("&amp;{} {}self", *lt, MutableSpace(mtbl)));
             }
             clean::SelfBorrowed(None, mtbl) => {
-                args.push_str(format!("&amp;{}self",
-                                      MutableSpace(mtbl)).as_slice());
+                args.push_str(&format!("&amp;{}self", MutableSpace(mtbl)));
             }
             clean::SelfExplicit(ref typ) => {
-                args.push_str(format!("self: {}", *typ).as_slice());
+                args.push_str(&format!("self: {}", *typ));
             }
         }
         for (i, input) in d.inputs.values.iter().enumerate() {
             if i > 0 || args.len() > 0 { args.push_str(", "); }
             if input.name.len() > 0 {
-                args.push_str(format!("{}: ", input.name).as_slice());
+                args.push_str(&format!("{}: ", input.name));
             }
-            args.push_str(format!("{}", input.type_).as_slice());
+            args.push_str(&format!("{}", input.type_));
         }
         write!(f, "({args}){arrow}", args = args, arrow = d.output)
     }
@@ -748,7 +745,7 @@ fn fmt_inner<'a>(f: &mut fmt::Formatter,
             let tot = cnt.total();
             if tot == 0 { return Ok(()) }
 
-            context.push(m.name.as_slice());
+            context.push(&m.name);
             let path = context.connect("::");
 
             try!(write!(f, "<tr>"));
index 38b191846f1985229c1f494731a884738a63fd6a..143b4cdee487a207e2db01e93e17174af30d1f84 100644 (file)
@@ -61,18 +61,18 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
     loop {
         let next = lexer.next_token();
 
-        let snip = |&: sp| sess.span_diagnostic.cm.span_to_snippet(sp).unwrap();
+        let snip = |sp| sess.span_diagnostic.cm.span_to_snippet(sp).unwrap();
 
         if next.tok == token::Eof { break }
 
         let klass = match next.tok {
             token::Whitespace => {
-                try!(write!(out, "{}", Escape(snip(next.sp).as_slice())));
+                try!(write!(out, "{}", Escape(&snip(next.sp))));
                 continue
             },
             token::Comment => {
                 try!(write!(out, "<span class='comment'>{}</span>",
-                            Escape(snip(next.sp).as_slice())));
+                            Escape(&snip(next.sp))));
                 continue
             },
             token::Shebang(s) => {
@@ -179,10 +179,10 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
         // stringifying this token
         let snip = sess.span_diagnostic.cm.span_to_snippet(next.sp).unwrap();
         if klass == "" {
-            try!(write!(out, "{}", Escape(snip.as_slice())));
+            try!(write!(out, "{}", Escape(&snip)));
         } else {
             try!(write!(out, "<span class='{}'>{}</span>", klass,
-                          Escape(snip.as_slice())));
+                          Escape(&snip)));
         }
     }
 
index 7e08226019f9849ca56a1f7e7538a59201381f31..64c27b47f4281f43cdbb7cd0842561101e047c81 100644 (file)
@@ -224,15 +224,13 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
                     let test = origtext.lines().map(|l| {
                         stripped_filtered_line(l).unwrap_or(l)
                     }).collect::<Vec<&str>>().connect("\n");
-                    let krate = krate.as_ref().map(|s| s.as_slice());
-                    let test = test::maketest(test.as_slice(), krate, false, false);
-                    s.push_str(format!("<span class='rusttest'>{}</span>",
-                                         Escape(test.as_slice())).as_slice());
+                    let krate = krate.as_ref().map(|s| &**s);
+                    let test = test::maketest(&test, krate, false, false);
+                    s.push_str(&format!("<span class='rusttest'>{}</span>", Escape(&test)));
                 });
-                s.push_str(highlight::highlight(text.as_slice(),
-                                                None,
-                                                Some("rust-example-rendered"))
-                             .as_slice());
+                s.push_str(&highlight::highlight(&text,
+                                                 None,
+                                                 Some("rust-example-rendered")));
                 let output = CString::from_vec(s.into_bytes());
                 hoedown_buffer_puts(ob, output.as_ptr());
             })
@@ -420,7 +418,7 @@ fn parse(string: &str) -> LangString {
         let mut seen_other_tags = false;
         let mut data = LangString::all_false();
 
-        let tokens = string.split(|&: c: char|
+        let tokens = string.split(|c: char|
             !(c == '_' || c == '-' || c.is_alphanumeric())
         );
 
@@ -459,14 +457,14 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let Markdown(md) = *self;
         // This is actually common enough to special-case
         if md.len() == 0 { return Ok(()) }
-        render(fmt, md.as_slice(), false)
+        render(fmt, md, false)
     }
 }
 
 impl<'a> fmt::Display for MarkdownWithToc<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let MarkdownWithToc(md) = *self;
-        render(fmt, md.as_slice(), true)
+        render(fmt, md, true)
     }
 }
 
@@ -555,7 +553,7 @@ fn t(s: &str,
     #[test]
     fn issue_17736() {
         let markdown = "# title";
-        format!("{}", Markdown(markdown.as_slice()));
+        format!("{}", Markdown(markdown));
     }
 
     #[test]
index 6247c6dad1496dd23b3e2a9fce432e2427621e94..f413ef7e9261d6cc9c9684acbf6dd1215e24359c 100644 (file)
@@ -447,7 +447,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> old_io::IoResult<Stri
             path = "";
         } else {
             lastpath = item.path.to_string();
-            path = item.path.as_slice();
+            path = &item.path;
         };
 
         if i > 0 {
@@ -525,8 +525,7 @@ fn collect(path: &Path, krate: &str,
                 if !line.starts_with(key) {
                     continue
                 }
-                if line.starts_with(
-                        format!("{}['{}']", key, krate).as_slice()) {
+                if line.starts_with(&format!("{}['{}']", key, krate)) {
                     continue
                 }
                 ret.push(line.to_string());
@@ -537,8 +536,7 @@ fn collect(path: &Path, krate: &str,
 
     // Update the search index
     let dst = cx.dst.join("search-index.js");
-    let all_indexes = try!(collect(&dst, krate.name.as_slice(),
-                                   "searchIndex"));
+    let all_indexes = try!(collect(&dst, &krate.name, "searchIndex"));
     let mut w = try!(File::create(&dst));
     try!(writeln!(&mut w, "var searchIndex = {{}};"));
     try!(writeln!(&mut w, "{}", search_index));
@@ -565,13 +563,13 @@ fn collect(path: &Path, krate: &str,
 
         let mut mydst = dst.clone();
         for part in &remote_path[..remote_path.len() - 1] {
-            mydst.push(part.as_slice());
+            mydst.push(part);
             try!(mkdir(&mydst));
         }
         mydst.push(format!("{}.{}.js",
                            remote_item_type.to_static_str(),
                            remote_path[remote_path.len() - 1]));
-        let all_implementors = try!(collect(&mydst, krate.name.as_slice(),
+        let all_implementors = try!(collect(&mydst, &krate.name,
                                             "implementors"));
 
         try!(mkdir(&mydst.dir_path()));
@@ -611,7 +609,7 @@ fn render_sources(cx: &mut Context,
     info!("emitting source files");
     let dst = cx.dst.join("src");
     try!(mkdir(&dst));
-    let dst = dst.join(krate.name.as_slice());
+    let dst = dst.join(&krate.name);
     try!(mkdir(&dst));
     let mut folder = SourceCollector {
         dst: dst,
@@ -662,7 +660,7 @@ fn clean_srcpath<F>(src_root: &Path, src: &[u8], mut f: F) where
             if ".." == c {
                 f("up");
             } else {
-                f(c.as_slice())
+                f(c)
             }
         }
     }
@@ -672,7 +670,7 @@ fn clean_srcpath<F>(src_root: &Path, src: &[u8], mut f: F) where
 /// rendering in to the specified source destination.
 fn extern_location(e: &clean::ExternalCrate, dst: &Path) -> ExternalLocation {
     // See if there's documentation generated into the local directory
-    let local_location = dst.join(e.name.as_slice());
+    let local_location = dst.join(&e.name);
     if local_location.is_dir() {
         return Local;
     }
@@ -715,9 +713,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
             // entire crate. The other option is maintaining this mapping on a
             // per-file basis, but that's probably not worth it...
             self.cx
-                .include_sources = match self.emit_source(item.source
-                                                              .filename
-                                                              .as_slice()) {
+                .include_sources = match self.emit_source(&item.source .filename) {
                 Ok(()) => true,
                 Err(e) => {
                     println!("warning: source code was requested to be rendered, \
@@ -750,7 +746,7 @@ fn emit_source(&mut self, filename: &str) -> old_io::IoResult<()> {
                        filename.ends_with("macros>") => return Ok(()),
             Err(e) => return Err(e)
         };
-        let contents = str::from_utf8(contents.as_slice()).unwrap();
+        let contents = str::from_utf8(&contents).unwrap();
 
         // Remove the utf-8 BOM if any
         let contents = if contents.starts_with("\u{feff}") {
@@ -776,10 +772,10 @@ fn emit_source(&mut self, filename: &str) -> old_io::IoResult<()> {
         let title = format!("{} -- source", cur.filename_display());
         let desc = format!("Source to the Rust file `{}`.", filename);
         let page = layout::Page {
-            title: title.as_slice(),
+            title: &title,
             ty: "source",
-            root_path: root_path.as_slice(),
-            description: desc.as_slice(),
+            root_path: &root_path,
+            description: &desc,
             keywords: get_basic_keywords(),
         };
         try!(layout::render(&mut w as &mut Writer, &self.cx.layout,
@@ -865,13 +861,13 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                             Some(&(ref fqp, ItemType::Struct)) |
                             Some(&(ref fqp, ItemType::Enum)) =>
                                 Some(&fqp[..fqp.len() - 1]),
-                            Some(..) => Some(self.stack.as_slice()),
+                            Some(..) => Some(&*self.stack),
                             None => None
                         };
                         ((Some(*last), path), true)
                     }
                 }
-                _ => ((None, Some(self.stack.as_slice())), false)
+                _ => ((None, Some(&*self.stack)), false)
             };
             let hidden_field = match item.inner {
                 clean::StructFieldItem(clean::HiddenStructField) => true,
@@ -1059,7 +1055,7 @@ fn recurse<T, F>(&mut self, s: String, f: F) -> T where
             panic!("Unexpected empty destination: {:?}", self.current);
         }
         let prev = self.dst.clone();
-        self.dst.push(s.as_slice());
+        self.dst.push(&s);
         self.root_path.push_str("../");
         self.current.push(s);
 
@@ -1103,9 +1099,9 @@ fn krate(mut self, mut krate: clean::Crate,
                                this.layout.krate);
             let page = layout::Page {
                 ty: "mod",
-                root_path: this.root_path.as_slice(),
-                title: title.as_slice(),
-                description: desc.as_slice(),
+                root_path: &this.root_path,
+                title: &title,
+                description: &desc,
                 keywords: get_basic_keywords(),
             };
             let html_dst = &this.dst.join("stability.html");
@@ -1151,7 +1147,7 @@ fn render(w: old_io::File, cx: &Context, it: &clean::Item,
                 if title.len() > 0 {
                     title.push_str("::");
                 }
-                title.push_str(it.name.as_ref().unwrap().as_slice());
+                title.push_str(it.name.as_ref().unwrap());
             }
             title.push_str(" - Rust");
             let tyname = shortty(it).to_static_str();
@@ -1169,10 +1165,10 @@ fn render(w: old_io::File, cx: &Context, it: &clean::Item,
             let keywords = make_item_keywords(it);
             let page = layout::Page {
                 ty: tyname,
-                root_path: cx.root_path.as_slice(),
-                title: title.as_slice(),
-                description: desc.as_slice(),
-                keywords: keywords.as_slice(),
+                root_path: &cx.root_path,
+                title: &title,
+                description: &desc,
+                keywords: &keywords,
             };
 
             markdown::reset_headers();
@@ -1191,11 +1187,11 @@ fn render(w: old_io::File, cx: &Context, it: &clean::Item,
                 match cache().paths.get(&it.def_id) {
                     Some(&(ref names, _)) => {
                         for name in &names[..names.len() - 1] {
-                            url.push_str(name.as_slice());
+                            url.push_str(name);
                             url.push_str("/");
                         }
-                        url.push_str(item_path(it).as_slice());
-                        try!(layout::redirect(&mut writer, url.as_slice()));
+                        url.push_str(&item_path(it));
+                        try!(layout::redirect(&mut writer, &url));
                     }
                     None => {}
                 }
@@ -1378,17 +1374,17 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
             _ => false,
         };
         if !is_primitive {
-            let cur = self.cx.current.as_slice();
+            let cur = &self.cx.current;
             let amt = if self.ismodule() { cur.len() - 1 } else { cur.len() };
             for (i, component) in cur.iter().enumerate().take(amt) {
                 try!(write!(fmt, "<a href='{}index.html'>{}</a>::<wbr>",
                             repeat("../").take(cur.len() - i - 1)
                                          .collect::<String>(),
-                            component.as_slice()));
+                            component));
             }
         }
         try!(write!(fmt, "<a class='{}' href=''>{}</a>",
-                    shortty(self.item), self.item.name.as_ref().unwrap().as_slice()));
+                    shortty(self.item), self.item.name.as_ref().unwrap()));
 
         // Write stability level
         try!(write!(fmt, "<wbr>{}", Stability(&self.item.stability)));
@@ -1433,7 +1429,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 
         match self.item.inner {
             clean::ModuleItem(ref m) => {
-                item_module(fmt, self.cx, self.item, m.items.as_slice())
+                item_module(fmt, self.cx, self.item, &m.items)
             }
             clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) =>
                 item_function(fmt, self.item, f),
@@ -1467,7 +1463,7 @@ fn item_path(item: &clean::Item) -> String {
 fn full_path(cx: &Context, item: &clean::Item) -> String {
     let mut s = cx.current.connect("::");
     s.push_str("::");
-    s.push_str(item.name.as_ref().unwrap().as_slice());
+    s.push_str(item.name.as_ref().unwrap());
     return s
 }
 
@@ -1580,12 +1576,12 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering {
                     Some(ref src) => {
                         try!(write!(w, "<tr><td><code>{}extern crate \"{}\" as {};",
                                     VisSpace(myitem.visibility),
-                                    src.as_slice(),
-                                    name.as_slice()))
+                                    src,
+                                    name))
                     }
                     None => {
                         try!(write!(w, "<tr><td><code>{}extern crate {};",
-                                    VisSpace(myitem.visibility), name.as_slice()))
+                                    VisSpace(myitem.visibility), name))
                     }
                 }
                 try!(write!(w, "</code></td></tr>"));
@@ -1625,7 +1621,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Initializer(s) = *self;
         if s.len() == 0 { return Ok(()); }
         try!(write!(f, "<code> = </code>"));
-        write!(f, "<code>{}</code>", s.as_slice())
+        write!(f, "<code>{}</code>", s)
     }
 }
 
@@ -1634,9 +1630,9 @@ fn item_constant(w: &mut fmt::Formatter, it: &clean::Item,
     try!(write!(w, "<pre class='rust const'>{vis}const \
                     {name}: {typ}{init}</pre>",
            vis = VisSpace(it.visibility),
-           name = it.name.as_ref().unwrap().as_slice(),
+           name = it.name.as_ref().unwrap(),
            typ = c.type_,
-           init = Initializer(c.expr.as_slice())));
+           init = Initializer(&c.expr)));
     document(w, it)
 }
 
@@ -1646,9 +1642,9 @@ fn item_static(w: &mut fmt::Formatter, it: &clean::Item,
                     {name}: {typ}{init}</pre>",
            vis = VisSpace(it.visibility),
            mutability = MutableSpace(s.mutability),
-           name = it.name.as_ref().unwrap().as_slice(),
+           name = it.name.as_ref().unwrap(),
            typ = s.type_,
-           init = Initializer(s.expr.as_slice())));
+           init = Initializer(&s.expr)));
     document(w, it)
 }
 
@@ -1658,7 +1654,7 @@ fn item_function(w: &mut fmt::Formatter, it: &clean::Item,
                     {name}{generics}{decl}{where_clause}</pre>",
            vis = VisSpace(it.visibility),
            unsafety = UnsafetySpace(f.unsafety),
-           name = it.name.as_ref().unwrap().as_slice(),
+           name = it.name.as_ref().unwrap(),
            generics = f.generics,
            where_clause = WhereClause(&f.generics),
            decl = f.decl));
@@ -1675,7 +1671,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
         bounds.push_str(": ");
         for (i, p) in t.bounds.iter().enumerate() {
             if i > 0 { bounds.push_str(" + "); }
-            bounds.push_str(format!("{}", *p).as_slice());
+            bounds.push_str(&format!("{}", *p));
         }
     }
 
@@ -1683,7 +1679,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
     try!(write!(w, "<pre class='rust trait'>{}{}trait {}{}{}{} ",
                   VisSpace(it.visibility),
                   UnsafetySpace(t.unsafety),
-                  it.name.as_ref().unwrap().as_slice(),
+                  it.name.as_ref().unwrap(),
                   t.generics,
                   bounds,
                   WhereClause(&t.generics)));
@@ -1823,7 +1819,7 @@ fn method(w: &mut fmt::Formatter, it: &clean::Item, unsafety: ast::Unsafety,
                    _ => "",
                },
                ty = shortty(it),
-               name = it.name.as_ref().unwrap().as_slice(),
+               name = it.name.as_ref().unwrap(),
                generics = *g,
                decl = Method(selfty, d),
                where_clause = WhereClause(g))
@@ -1849,7 +1845,7 @@ fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
                        it,
                        Some(&s.generics),
                        s.struct_type,
-                       s.fields.as_slice(),
+                       &s.fields,
                        "",
                        true));
     try!(write!(w, "</pre>"));
@@ -1869,7 +1865,7 @@ fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
                 try!(write!(w, "<tr><td id='structfield.{name}'>\
                                   {stab}<code>{name}</code></td><td>",
                             stab = ConciseStability(&field.stability),
-                            name = field.name.as_ref().unwrap().as_slice()));
+                            name = field.name.as_ref().unwrap()));
                 try!(document(w, field));
                 try!(write!(w, "</td></tr>"));
             }
@@ -1883,7 +1879,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
              e: &clean::Enum) -> fmt::Result {
     try!(write!(w, "<pre class='rust enum'>{}enum {}{}{}",
                   VisSpace(it.visibility),
-                  it.name.as_ref().unwrap().as_slice(),
+                  it.name.as_ref().unwrap(),
                   e.generics,
                   WhereClause(&e.generics)));
     if e.variants.len() == 0 && !e.variants_stripped {
@@ -1892,7 +1888,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
         try!(write!(w, " {{\n"));
         for v in &e.variants {
             try!(write!(w, "    "));
-            let name = v.name.as_ref().unwrap().as_slice();
+            let name = v.name.as_ref().unwrap();
             match v.inner {
                 clean::VariantItem(ref var) => {
                     match var.kind {
@@ -1912,7 +1908,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
                                                v,
                                                None,
                                                s.struct_type,
-                                               s.fields.as_slice(),
+                                               &s.fields,
                                                "    ",
                                                false));
                         }
@@ -1936,7 +1932,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
         for variant in &e.variants {
             try!(write!(w, "<tr><td id='variant.{name}'>{stab}<code>{name}</code></td><td>",
                           stab = ConciseStability(&variant.stability),
-                          name = variant.name.as_ref().unwrap().as_slice()));
+                          name = variant.name.as_ref().unwrap()));
             try!(document(w, variant));
             match variant.inner {
                 clean::VariantItem(ref var) => {
@@ -1957,8 +1953,8 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
                                 try!(write!(w, "<tr><td \
                                                   id='variant.{v}.field.{f}'>\
                                                   <code>{f}</code></td><td>",
-                                              v = variant.name.as_ref().unwrap().as_slice(),
-                                              f = field.name.as_ref().unwrap().as_slice()));
+                                              v = variant.name.as_ref().unwrap(),
+                                              f = field.name.as_ref().unwrap()));
                                 try!(document(w, field));
                                 try!(write!(w, "</td></tr>"));
                             }
@@ -1987,7 +1983,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
     try!(write!(w, "{}{}{}",
                   VisSpace(it.visibility),
                   if structhead {"struct "} else {""},
-                  it.name.as_ref().unwrap().as_slice()));
+                  it.name.as_ref().unwrap()));
     match g {
         Some(g) => try!(write!(w, "{}{}", *g, WhereClause(g))),
         None => {}
@@ -2004,7 +2000,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
                     clean::StructFieldItem(clean::TypedStructField(ref ty)) => {
                         try!(write!(w, "    {}{}: {},\n{}",
                                       VisSpace(field.visibility),
-                                      field.name.as_ref().unwrap().as_slice(),
+                                      field.name.as_ref().unwrap(),
                                       *ty,
                                       tab));
                     }
@@ -2091,7 +2087,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
     match i.dox {
         Some(ref dox) => {
             try!(write!(w, "<div class='docblock'>{}</div>",
-                          Markdown(dox.as_slice())));
+                          Markdown(dox)));
         }
         None => {}
     }
@@ -2179,7 +2175,7 @@ fn render_default_methods(w: &mut fmt::Formatter,
 fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
                 t: &clean::Typedef) -> fmt::Result {
     try!(write!(w, "<pre class='rust typedef'>type {}{} = {};</pre>",
-                  it.name.as_ref().unwrap().as_slice(),
+                  it.name.as_ref().unwrap(),
                   t.generics,
                   t.type_));
 
@@ -2205,7 +2201,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
                  cur: &clean::Item, cx: &Context) -> fmt::Result {
             let items = match cx.sidebar.get(short) {
-                Some(items) => items.as_slice(),
+                Some(items) => items,
                 None => return Ok(())
             };
             try!(write!(w, "<div class='block {}'><h2>{}</h2>", short, longty));
@@ -2219,12 +2215,12 @@ fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
                        class = class,
                        href = if curty == "mod" {"../"} else {""},
                        path = if short == "mod" {
-                           format!("{}/index.html", name.as_slice())
+                           format!("{}/index.html", name)
                        } else {
-                           format!("{}.{}.html", short, name.as_slice())
+                           format!("{}.{}.html", short, name)
                        },
-                       title = Escape(doc.as_ref().unwrap().as_slice()),
-                       name = name.as_slice()));
+                       title = Escape(doc.as_ref().unwrap()),
+                       name = name));
             }
             try!(write!(w, "</div>"));
             Ok(())
@@ -2255,16 +2251,16 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
             try!(write!(fmt, "<span id=\"{0}\">{0:1$}</span>\n", i, cols));
         }
         try!(write!(fmt, "</pre>"));
-        try!(write!(fmt, "{}", highlight::highlight(s.as_slice(), None, None)));
+        try!(write!(fmt, "{}", highlight::highlight(s, None, None)));
         Ok(())
     }
 }
 
 fn item_macro(w: &mut fmt::Formatter, it: &clean::Item,
               t: &clean::Macro) -> fmt::Result {
-    try!(w.write_str(highlight::highlight(t.source.as_slice(),
+    try!(w.write_str(&highlight::highlight(&t.source,
                                           Some("macro"),
-                                          None).as_slice()));
+                                          None)));
     document(w, it)
 }
 
index 7790c7d6a50f7262d2990c31c0d45488ec626015..ecef4c9bf7226c182aa08dee218074609a6387d1 100644 (file)
@@ -145,8 +145,7 @@ pub fn push<'a>(&'a mut self, level: u32, name: String, id: String) -> &'a str {
                     (0, &self.top_level)
                 }
                 Some(entry) => {
-                    sec_number = String::from_str(entry.sec_number
-                                                       .as_slice());
+                    sec_number = String::from_str(&entry.sec_number);
                     sec_number.push_str(".");
                     (entry.level, &entry.children)
                 }
@@ -158,7 +157,7 @@ pub fn push<'a>(&'a mut self, level: u32, name: String, id: String) -> &'a str {
                 sec_number.push_str("0.");
             }
             let number = toc.count_entries_with_level(level);
-            sec_number.push_str(format!("{}", number + 1).as_slice())
+            sec_number.push_str(&format!("{}", number + 1))
         }
 
         self.chain.push(TocEntry {
@@ -172,7 +171,7 @@ pub fn push<'a>(&'a mut self, level: u32, name: String, id: String) -> &'a str {
         // get the thing we just pushed, so we can borrow the string
         // out of it with the right lifetime
         let just_inserted = self.chain.last_mut().unwrap();
-        just_inserted.sec_number.as_slice()
+        &just_inserted.sec_number
     }
 }
 
index f4b8bbd5f8a518772bd64d88473e428ba94b2d24..40e9703c03ffbf1a31ace44d3d685de6923730c3 100644 (file)
@@ -178,12 +178,12 @@ pub fn opts() -> Vec<getopts::OptGroup> {
 
 pub fn usage(argv0: &str) {
     println!("{}",
-             getopts::usage(format!("{} [options] <input>", argv0).as_slice(),
-                            opts().as_slice()));
+             getopts::usage(&format!("{} [options] <input>", argv0),
+                            &opts()));
 }
 
 pub fn main_args(args: &[String]) -> int {
-    let matches = match getopts::getopts(args.tail(), opts().as_slice()) {
+    let matches = match getopts::getopts(args.tail(), &opts()) {
         Ok(m) => m,
         Err(err) => {
             println!("{}", err);
@@ -191,7 +191,7 @@ pub fn main_args(args: &[String]) -> int {
         }
     };
     if matches.opt_present("h") || matches.opt_present("help") {
-        usage(args[0].as_slice());
+        usage(&args[0]);
         return 0;
     } else if matches.opt_present("version") {
         rustc_driver::version("rustdoc", &matches);
@@ -217,11 +217,11 @@ pub fn main_args(args: &[String]) -> int {
         println!("only one input file may be specified");
         return 1;
     }
-    let input = matches.free[0].as_slice();
+    let input = &matches.free[0];
 
     let mut libs = SearchPaths::new();
     for s in &matches.opt_strs("L") {
-        libs.add_path(s.as_slice());
+        libs.add_path(s);
     }
     let externs = match parse_externs(&matches) {
         Ok(ex) => ex,
@@ -244,9 +244,9 @@ pub fn main_args(args: &[String]) -> int {
     let cfgs = matches.opt_strs("cfg");
 
     let external_html = match ExternalHtml::load(
-            matches.opt_strs("html-in-header").as_slice(),
-            matches.opt_strs("html-before-content").as_slice(),
-            matches.opt_strs("html-after-content").as_slice()) {
+            &matches.opt_strs("html-in-header"),
+            &matches.opt_strs("html-before-content"),
+            &matches.opt_strs("html-after-content")) {
         Some(eh) => eh,
         None => return 3
     };
@@ -274,7 +274,7 @@ pub fn main_args(args: &[String]) -> int {
     };
     let Output { krate, json_plugins, passes, } = out;
     info!("going to format");
-    match matches.opt_str("w").as_ref().map(|s| s.as_slice()) {
+    match matches.opt_str("w").as_ref().map(|s| &**s) {
         Some("html") | None => {
             match html::render::run(krate, &external_html, output.unwrap_or(Path::new("doc")),
                                     passes.into_iter().collect()) {
@@ -303,7 +303,7 @@ pub fn main_args(args: &[String]) -> int {
 fn acquire_input(input: &str,
                  externs: core::Externs,
                  matches: &getopts::Matches) -> Result<Output, String> {
-    match matches.opt_str("r").as_ref().map(|s| s.as_slice()) {
+    match matches.opt_str("r").as_ref().map(|s| &**s) {
         Some("rust") => Ok(rust_input(input, externs, matches)),
         Some("json") => json_input(input),
         Some(s) => Err(format!("unknown input format: {}", s)),
@@ -357,7 +357,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
     // First, parse the crate and extract all relevant information.
     let mut paths = SearchPaths::new();
     for s in &matches.opt_strs("L") {
-        paths.add_path(s.as_slice());
+        paths.add_path(s);
     }
     let cfgs = matches.opt_strs("cfg");
     let triple = matches.opt_str("target");
@@ -365,7 +365,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
     let cr = Path::new(cratefile);
     info!("starting to run rustc");
 
-    let (mut krate, analysis) = std::thread::Thread::scoped(move |:| {
+    let (mut krate, analysis) = std::thread::Thread::scoped(move || {
         use rustc::session::config::Input;
 
         let cr = cr;
@@ -512,7 +512,7 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
     // FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
     // straight to the Rust JSON representation.
     let crate_json_str = format!("{}", json::as_json(&krate));
-    let crate_json = match json::from_str(crate_json_str.as_slice()) {
+    let crate_json = match json::from_str(&crate_json_str) {
         Ok(j) => j,
         Err(e) => panic!("Rust generated JSON is invalid: {:?}", e)
     };
index 365fb78cfae63cecbcf7073000fae4f7d12bce5d..d64d9becc0c7c459f2ac2ebcb9e6132bc834bcb7 100644 (file)
@@ -49,7 +49,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
     let mut css = String::new();
     for name in &matches.opt_strs("markdown-css") {
         let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">\n", name);
-        css.push_str(s.as_slice())
+        css.push_str(&s)
     }
 
     let input_str = load_or_return!(input, 1, 2);
@@ -69,13 +69,13 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
         Ok(f) => f
     };
 
-    let (metadata, text) = extract_leading_metadata(input_str.as_slice());
+    let (metadata, text) = extract_leading_metadata(&input_str);
     if metadata.len() == 0 {
         let _ = writeln!(&mut old_io::stderr(),
                          "invalid markdown file: expecting initial line with `% ...TITLE...`");
         return 5;
     }
-    let title = metadata[0].as_slice();
+    let title = metadata[0];
 
     reset_headers();
 
@@ -141,8 +141,8 @@ pub fn test(input: &str, libs: SearchPaths, externs: core::Externs,
     let input_str = load_or_return!(input, 1, 2);
 
     let mut collector = Collector::new(input.to_string(), libs, externs, true);
-    find_testable_code(input_str.as_slice(), &mut collector);
+    find_testable_code(&input_str, &mut collector);
     test_args.insert(0, "rustdoctest".to_string());
-    testing::test_main(test_args.as_slice(), collector.tests);
+    testing::test_main(&test_args, collector.tests);
     0
 }
index e1c6bf1f4cfdd341322a65e128377234f0df2f99..4e023039de7c8de81fe265b627f6f03e322f0d34 100644 (file)
@@ -260,7 +260,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
                     &clean::NameValue(ref x, ref s)
                             if "doc" == *x => {
                         avec.push(clean::NameValue("doc".to_string(),
-                                                   unindent(s.as_slice())))
+                                                   unindent(s)))
                     }
                     x => avec.push(x.clone())
                 }
@@ -284,7 +284,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
                 match *attr {
                     clean::NameValue(ref x, ref s)
                             if "doc" == *x => {
-                        docstr.push_str(s.as_slice());
+                        docstr.push_str(s);
                         docstr.push('\n');
                     },
                     _ => ()
@@ -352,14 +352,14 @@ pub fn unindent(s: &str) -> String {
 
     if lines.len() >= 1 {
         let mut unindented = vec![ lines[0].trim().to_string() ];
-        unindented.push_all(lines.tail().iter().map(|&line| {
+        unindented.push_all(&lines.tail().iter().map(|&line| {
             if line.chars().all(|c| c.is_whitespace()) {
                 line.to_string()
             } else {
                 assert!(line.len() >= min_indent);
                 line[min_indent..].to_string()
             }
-        }).collect::<Vec<_>>().as_slice());
+        }).collect::<Vec<_>>());
         unindented.connect("\n")
     } else {
         s.to_string()
@@ -373,14 +373,14 @@ mod unindent_tests {
     #[test]
     fn should_unindent() {
         let s = "    line1\n    line2".to_string();
-        let r = unindent(s.as_slice());
+        let r = unindent(&s);
         assert_eq!(r, "line1\nline2");
     }
 
     #[test]
     fn should_unindent_multiple_paragraphs() {
         let s = "    line1\n\n    line2".to_string();
-        let r = unindent(s.as_slice());
+        let r = unindent(&s);
         assert_eq!(r, "line1\n\nline2");
     }
 
@@ -389,7 +389,7 @@ fn should_leave_multiple_indent_levels() {
         // Line 2 is indented another level beyond the
         // base indentation and should be preserved
         let s = "    line1\n\n        line2".to_string();
-        let r = unindent(s.as_slice());
+        let r = unindent(&s);
         assert_eq!(r, "line1\n\n    line2");
     }
 
@@ -401,14 +401,14 @@ fn should_ignore_first_line_indent() {
         // #[doc = "Start way over here
         //          and continue here"]
         let s = "line1\n    line2".to_string();
-        let r = unindent(s.as_slice());
+        let r = unindent(&s);
         assert_eq!(r, "line1\nline2");
     }
 
     #[test]
     fn should_not_ignore_first_line_indent_in_a_single_line_para() {
         let s = "line1\n\n    line2".to_string();
-        let r = unindent(s.as_slice());
+        let r = unindent(&s);
         assert_eq!(r, "line1\n\n    line2");
     }
 }
index a2afba091f4a1f8aaf3ffc4248ac73741f14585c..b65b2841aa0e5ce0ad6c874b17288fcef9a70057 100644 (file)
@@ -88,7 +88,7 @@ fn libname(mut n: String) -> String {
 #[cfg(all(not(target_os="windows"), not(target_os="macos")))]
 fn libname(n: String) -> String {
     let mut i = String::from_str("lib");
-    i.push_str(n.as_slice());
+    i.push_str(&n);
     i.push_str(".so");
     i
 }
index 29abea009e547f2580a9b2a9e76d804ac06c9e33..494efad896c5f41ea628aefea4345d0ea69c5e69 100644 (file)
@@ -68,7 +68,7 @@ pub fn run(input: &str,
 
     let mut cfg = config::build_configuration(&sess);
     cfg.extend(cfgs.into_iter().map(|cfg_| {
-        let cfg_ = token::intern_and_get_ident(cfg_.as_slice());
+        let cfg_ = token::intern_and_get_ident(&cfg_);
         P(dummy_spanned(ast::MetaWord(cfg_)))
     }));
     let krate = driver::phase_1_parse_input(&sess, cfg, &input);
@@ -105,7 +105,7 @@ pub fn run(input: &str,
 
     test_args.insert(0, "rustdoctest".to_string());
 
-    testing::test_main(test_args.as_slice(),
+    testing::test_main(&test_args,
                        collector.tests.into_iter().collect());
     0
 }
@@ -148,7 +148,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
     let w1 = old_io::ChanWriter::new(tx);
     let w2 = w1.clone();
     let old = old_io::stdio::set_stderr(box w1);
-    Thread::spawn(move |:| {
+    Thread::spawn(move || {
         let mut p = old_io::ChanReader::new(rx);
         let mut err = match old {
             Some(old) => {
@@ -194,9 +194,9 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
     let newpath = {
         let mut path = DynamicLibrary::search_path();
         path.insert(0, libdir.clone());
-        DynamicLibrary::create_path(path.as_slice())
+        DynamicLibrary::create_path(&path)
     };
-    cmd.env(DynamicLibrary::envvar(), newpath.as_slice());
+    cmd.env(DynamicLibrary::envvar(), newpath);
 
     match cmd.output() {
         Err(e) => panic!("couldn't run the test: {}{}", e,
@@ -208,7 +208,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
                 panic!("test executable succeeded when it should have failed");
             } else if !should_fail && !out.status.success() {
                 panic!("test executable failed:\n{:?}",
-                      str::from_utf8(out.error.as_slice()));
+                      str::from_utf8(&out.error));
             }
         }
     }
@@ -228,8 +228,8 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main:
         match cratename {
             Some(cratename) => {
                 if s.contains(cratename) {
-                    prog.push_str(format!("extern crate {};\n",
-                                          cratename).as_slice());
+                    prog.push_str(&format!("extern crate {};\n",
+                                           cratename));
                 }
             }
             None => {}
@@ -239,7 +239,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main:
         prog.push_str(s);
     } else {
         prog.push_str("fn main() {\n    ");
-        prog.push_str(s.replace("\n", "\n    ").as_slice());
+        prog.push_str(&s.replace("\n", "\n    "));
         prog.push_str("\n}");
     }
 
@@ -275,7 +275,7 @@ pub fn new(cratename: String, libs: SearchPaths, externs: core::Externs,
     pub fn add_test(&mut self, test: String,
                     should_fail: bool, no_run: bool, should_ignore: bool, as_test_harness: bool) {
         let name = if self.use_headers {
-            let s = self.current_header.as_ref().map(|s| s.as_slice()).unwrap_or("");
+            let s = self.current_header.as_ref().map(|s| &**s).unwrap_or("");
             format!("{}_{}", s, self.cnt)
         } else {
             format!("{}_{}", self.names.connect("::"), self.cnt)
@@ -292,8 +292,8 @@ pub fn add_test(&mut self, test: String,
                 should_fail: testing::ShouldFail::No, // compiler failures are test failures
             },
             testfn: testing::DynTestFn(Thunk::new(move|| {
-                runtest(test.as_slice(),
-                        cratename.as_slice(),
+                runtest(&test,
+                        &cratename,
                         libs,
                         externs,
                         should_fail,
index 4f62cca3c68c285fe1c70ff190c8cfe5cba1c6a5..b8383577987539a03e281c9c21b9179472074748 100644 (file)
@@ -2061,7 +2061,7 @@ pub fn from_reader(rdr: &mut old_io::Reader) -> Result<Json, BuilderError> {
         Ok(c)  => c,
         Err(e) => return Err(io_error_to_error(e))
     };
-    let s = match str::from_utf8(contents.as_slice()).ok() {
+    let s = match str::from_utf8(&contents).ok() {
         Some(s) => s,
         _       => return Err(SyntaxError(NotUtf8, 0, 0))
     };
@@ -3550,7 +3550,7 @@ enum Enum {
         map.insert(Enum::Foo, 0);
         let result = json::encode(&map).unwrap();
         assert_eq!(&result[], r#"{"Foo":0}"#);
-        let decoded: HashMap<Enum, _> = json::decode(result.as_slice()).unwrap();
+        let decoded: HashMap<Enum, _> = json::decode(&result).unwrap();
         assert_eq!(map, decoded);
     }
 
@@ -3591,7 +3591,7 @@ fn assert_stream_equal(src: &str,
                 None => { break; }
             };
             let (ref expected_evt, ref expected_stack) = expected[i];
-            if !parser.stack().is_equal_to(expected_stack.as_slice()) {
+            if !parser.stack().is_equal_to(expected_stack) {
                 panic!("Parser stack is not equal to {:?}", expected_stack);
             }
             assert_eq!(&evt, expected_evt);
@@ -4022,6 +4022,6 @@ fn bench_streaming_large(b: &mut Bencher) {
     #[bench]
     fn bench_large(b: &mut Bencher) {
         let src = big_json();
-        b.iter( || { let _ = from_str(src.as_slice()); });
+        b.iter( || { let _ = from_str(&src); });
     }
 }
index 274c669d8dfc2ce902dafc027b35275a7006a6fd..892747e79ed45e80b7509b357920d24c688972af 100644 (file)
@@ -421,7 +421,7 @@ fn test_eq_ignore_ascii_case() {
             let lower = if 'A' as u32 <= c && c <= 'Z' as u32 { c + 'a' as u32 - 'A' as u32 }
                         else { c };
             assert!((from_u32(i).unwrap()).to_string().eq_ignore_ascii_case(
-                    (from_u32(lower).unwrap()).to_string().as_slice()));
+                    &from_u32(lower).unwrap().to_string()));
             i += 1;
         }
     }
index 68ae0f7e5b5f3ace6049fb6e7ae9f43fbf3b8aba..e1bcfe3ab7287183720959140e4dccb71b4e223b 100644 (file)
@@ -67,9 +67,9 @@ pub fn open(filename: Option<&Path>) -> Result<DynamicLibrary, String> {
     pub fn prepend_search_path(path: &Path) {
         let mut search_path = DynamicLibrary::search_path();
         search_path.insert(0, path.clone());
-        let newval = DynamicLibrary::create_path(search_path.as_slice());
+        let newval = DynamicLibrary::create_path(&search_path);
         env::set_var(DynamicLibrary::envvar(),
-                     str::from_utf8(newval.as_slice()).unwrap());
+                     str::from_utf8(&newval).unwrap());
     }
 
     /// From a slice of paths, create a new vector which is suitable to be an
index 2e55c007b551b32e55a9a3e4430a15f8b32995d9..4c8735bd4ad1055dbe674644ec65ab0d40cdb654 100644 (file)
@@ -13,7 +13,7 @@
 use libc;
 use mem;
 use ops::Deref;
-use slice::{self, SliceExt, AsSlice};
+use slice::{self, SliceExt};
 use string::String;
 use vec::Vec;
 
@@ -96,12 +96,12 @@ pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
 
     /// Create a view into this C string which includes the trailing nul
     /// terminator at the end of the string.
-    pub fn as_slice_with_nul(&self) -> &[libc::c_char] { self.inner.as_slice() }
+    pub fn as_slice_with_nul(&self) -> &[libc::c_char] { &self.inner }
 
     /// Similar to the `as_slice` method, but returns a `u8` slice instead of a
     /// `libc::c_char` slice.
     pub fn as_bytes(&self) -> &[u8] {
-        unsafe { mem::transmute(self.as_slice()) }
+        unsafe { mem::transmute(&**self) }
     }
 
     /// Equivalent to `as_slice_with_nul` except that the type returned is a
@@ -197,7 +197,7 @@ fn simple() {
         assert_eq!(s.as_bytes(), b"1234");
         assert_eq!(s.as_bytes_with_nul(), b"1234\0");
         unsafe {
-            assert_eq!(s.as_slice(),
+            assert_eq!(&*s,
                        mem::transmute::<_, &[libc::c_char]>(b"1234"));
             assert_eq!(s.as_slice_with_nul(),
                        mem::transmute::<_, &[libc::c_char]>(b"1234\0"));
index 9c4741b3ce316f0eefa0e06343eda48fe8f223d5..4ae7d3437fd93f689f8bdaeb67257f05c50641aa 100644 (file)
@@ -321,10 +321,10 @@ pub fn float_to_str_bytes_common<T: Float>(
         // cut off the one extra digit, and depending on its value
         // round the remaining ones.
         if limit_digits && dig == digit_count {
-            let ascii2value = |&: chr: u8| {
+            let ascii2value = |chr: u8| {
                 (chr as char).to_digit(radix).unwrap()
             };
-            let value2ascii = |&: val: uint| {
+            let value2ascii = |val: uint| {
                 char::from_digit(val, radix).unwrap() as u8
             };
 
index 586cc1477f8dd6ecc35cd5633330e9d4ef74c7bb..59a437ad916537e23c47992b91b0b72bab8e6464 100644 (file)
@@ -97,7 +97,7 @@ pub fn into_inner(self) -> R { self.inner }
 impl<R: Reader> Buffer for BufferedReader<R> {
     fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> {
         if self.pos == self.cap {
-            self.cap = try!(self.inner.read(self.buf.as_mut_slice()));
+            self.cap = try!(self.inner.read(&mut self.buf));
             self.pos = 0;
         }
         Ok(&self.buf[self.pos..self.cap])
index feb2ef6f4f3ca1d94bba0ad555e7d47b27032f93..d8f9b1bb3feae4cd2c52d15f67f40bfaaddde6f1 100644 (file)
@@ -191,14 +191,14 @@ fn test_rx_reader() {
         let a: &[u8] = &[7,8,6];
         assert_eq!(a, buf);
 
-        match reader.read(buf.as_mut_slice()) {
+        match reader.read(&mut buf) {
             Ok(..) => panic!(),
             Err(e) => assert_eq!(e.kind, old_io::EndOfFile),
         }
         assert_eq!(a, buf);
 
         // Ensure it continues to panic in the same way.
-        match reader.read(buf.as_mut_slice()) {
+        match reader.read(&mut buf) {
             Ok(..) => panic!(),
             Err(e) => assert_eq!(e.kind, old_io::EndOfFile),
         }
index d729c2800ce13c3c134206866b219468fe0155e6..95284f2ca40365b9f828d16ad953316c535372b3 100644 (file)
@@ -24,7 +24,7 @@
 use option::Option::{Some, None};
 use ptr::PtrExt;
 use result::Result::{Ok, Err};
-use slice::{SliceExt, AsSlice};
+use slice::SliceExt;
 
 /// An iterator that reads a single byte on each iteration,
 /// until `.read_byte()` returns `EndOfFile`.
@@ -101,7 +101,7 @@ pub fn u64_to_le_bytes<T, F>(n: u64, size: uint, f: F) -> T where
             n >>= 8;
             i -= 1u;
         }
-        f(bytes.as_slice())
+        f(&bytes)
       }
     }
 }
@@ -140,7 +140,7 @@ pub fn u64_to_be_bytes<T, F>(n: u64, size: uint, f: F) -> T where
             bytes.push((n >> shift) as u8);
             i -= 1u;
         }
-        f(bytes.as_slice())
+        f(&bytes)
       }
     }
 }
@@ -455,7 +455,7 @@ fn test_read_f32() {
         let buf = vec![0x41, 0x02, 0x00, 0x00];
 
         let mut writer = Vec::new();
-        writer.write(buf.as_slice()).unwrap();
+        writer.write(&buf).unwrap();
 
         let mut reader = MemReader::new(writer);
         let f = reader.read_be_f32().unwrap();
@@ -523,7 +523,7 @@ macro_rules! u64_from_be_bytes_bench_impl {
             $b.iter(|| {
                 let mut i = $start_index;
                 while i < data.len() {
-                    sum += u64_from_be_bytes(data.as_slice(), i, $size);
+                    sum += u64_from_be_bytes(&data, i, $size);
                     i += $stride;
                 }
             });
index 67e3fddfd05a5401d10b0ea5b9a175e6dede52a2..4e9c1b360552c4ee21d69146e72cf6261ac2bd9e 100644 (file)
@@ -840,7 +840,7 @@ macro_rules! check { ($e:expr) => (
     macro_rules! error { ($e:expr, $s:expr) => (
         match $e {
             Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
-            Err(ref err) => assert!(err.to_string().contains($s.as_slice()),
+            Err(ref err) => assert!(err.to_string().contains($s),
                                     format!("`{}` did not contain `{}`", err, $s))
         }
     ) }
@@ -892,7 +892,7 @@ fn file_test_io_smoke_test() {
                 -1|0 => panic!("shouldn't happen"),
                 n => str::from_utf8(&read_buf[..n]).unwrap().to_string()
             };
-            assert_eq!(read_str.as_slice(), message);
+            assert_eq!(read_str, message);
         }
         check!(unlink(filename));
     }
@@ -907,7 +907,7 @@ fn invalid_path_raises() {
         if cfg!(unix) {
             error!(result, "no such file or directory");
         }
-        error!(result, format!("path={}; mode=open; access=read", filename.display()));
+        error!(result, &format!("path={}; mode=open; access=read", filename.display()));
     }
 
     #[test]
@@ -921,7 +921,7 @@ fn file_test_iounlinking_invalid_path_should_raise_condition() {
         if cfg!(unix) {
             error!(result, "no such file or directory");
         }
-        error!(result, format!("path={}", filename.display()));
+        error!(result, &format!("path={}", filename.display()));
     }
 
     #[test]
@@ -1120,7 +1120,7 @@ fn file_test_directoryinfo_readdir() {
                     None|Some("") => panic!("really shouldn't happen.."),
                     Some(n) => format!("{}{}", prefix, n),
                 };
-                assert_eq!(expected.as_slice(), read_str);
+                assert_eq!(expected, read_str);
             }
             check!(unlink(f));
         }
@@ -1189,7 +1189,7 @@ fn recursive_mkdir_failure() {
         error!(result, "couldn't recursively mkdir");
         error!(result, "couldn't create directory");
         error!(result, "mode=0700");
-        error!(result, format!("path={}", file.display()));
+        error!(result, &format!("path={}", file.display()));
     }
 
     #[test]
@@ -1255,9 +1255,9 @@ fn copy_file_does_not_exist() {
         let to = Path::new("test/other-bogus-path");
 
         error!(copy(&from, &to),
-            format!("couldn't copy path (the source path is not an \
-                    existing file; from={:?}; to={:?})",
-                    from.display(), to.display()));
+            &format!("couldn't copy path (the source path is not an \
+                     existing file; from={:?}; to={:?})",
+                     from.display(), to.display()));
 
         match copy(&from, &to) {
             Ok(..) => panic!(),
@@ -1277,7 +1277,7 @@ fn copy_file_ok() {
         check!(File::create(&input).write(b"hello"));
         check!(copy(&input, &out));
         let contents = check!(File::open(&out).read_to_end());
-        assert_eq!(contents.as_slice(), b"hello");
+        assert_eq!(contents, b"hello");
 
         assert_eq!(check!(input.stat()).perm, check!(out.stat()).perm);
     }
index ddb364a703a3a23186856f323666a41f17dfa580..8f32703f200556b5c48563d9a3f28236ed808e0e 100644 (file)
@@ -17,7 +17,7 @@
 use result::Result::{Err, Ok};
 use old_io;
 use old_io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
-use slice::{self, AsSlice, SliceExt};
+use slice::{self, SliceExt};
 use vec::Vec;
 
 const BUF_CAPACITY: uint = 128;
@@ -92,7 +92,7 @@ pub fn from_vec(buf: Vec<u8>) -> MemWriter {
     /// Acquires an immutable reference to the underlying buffer of this
     /// `MemWriter`.
     #[inline]
-    pub fn get_ref<'a>(&'a self) -> &'a [u8] { self.buf.as_slice() }
+    pub fn get_ref<'a>(&'a self) -> &'a [u8] { &self.buf }
 
     /// Unwraps this `MemWriter`, returning the underlying buffer
     #[inline]
@@ -147,7 +147,7 @@ pub fn eof(&self) -> bool { self.pos >= self.buf.len() }
     /// No method is exposed for acquiring a mutable reference to the buffer
     /// because it could corrupt the state of this `MemReader`.
     #[inline]
-    pub fn get_ref<'a>(&'a self) -> &'a [u8] { self.buf.as_slice() }
+    pub fn get_ref<'a>(&'a self) -> &'a [u8] { &self.buf }
 
     /// Unwraps this `MemReader`, returning the underlying buffer
     #[inline]
@@ -407,7 +407,7 @@ fn test_vec_writer() {
         writer.write(&[1, 2, 3]).unwrap();
         writer.write(&[4, 5, 6, 7]).unwrap();
         let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
-        assert_eq!(writer.as_slice(), b);
+        assert_eq!(writer, b);
     }
 
     #[test]
@@ -511,24 +511,24 @@ fn test_mem_reader() {
     #[test]
     fn test_slice_reader() {
         let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
-        let mut reader = &mut in_buf.as_slice();
+        let mut reader = &mut &*in_buf;
         let mut buf = [];
         assert_eq!(reader.read(&mut buf), Ok(0));
         let mut buf = [0];
         assert_eq!(reader.read(&mut buf), Ok(1));
         assert_eq!(reader.len(), 7);
         let b: &[_] = &[0];
-        assert_eq!(buf.as_slice(), b);
+        assert_eq!(buf, b);
         let mut buf = [0; 4];
         assert_eq!(reader.read(&mut buf), Ok(4));
         assert_eq!(reader.len(), 3);
         let b: &[_] = &[1, 2, 3, 4];
-        assert_eq!(buf.as_slice(), b);
+        assert_eq!(buf, b);
         assert_eq!(reader.read(&mut buf), Ok(3));
         let b: &[_] = &[5, 6, 7];
         assert_eq!(&buf[..3], b);
         assert!(reader.read(&mut buf).is_err());
-        let mut reader = &mut in_buf.as_slice();
+        let mut reader = &mut &*in_buf;
         assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
         assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
         assert!(reader.read(&mut buf).is_err());
@@ -537,7 +537,7 @@ fn test_slice_reader() {
     #[test]
     fn test_buf_reader() {
         let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
-        let mut reader = BufReader::new(in_buf.as_slice());
+        let mut reader = BufReader::new(&in_buf);
         let mut buf = [];
         assert_eq!(reader.read(&mut buf), Ok(0));
         assert_eq!(reader.tell(), Ok(0));
@@ -555,7 +555,7 @@ fn test_buf_reader() {
         let b: &[_] = &[5, 6, 7];
         assert_eq!(&buf[..3], b);
         assert!(reader.read(&mut buf).is_err());
-        let mut reader = BufReader::new(in_buf.as_slice());
+        let mut reader = BufReader::new(&in_buf);
         assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
         assert_eq!(reader.read_until(3).unwrap(), vec!(4, 5, 6, 7));
         assert!(reader.read(&mut buf).is_err());
@@ -664,7 +664,7 @@ fn do_bench_mem_writer(b: &mut Bencher, times: uint, len: uint) {
         b.iter(|| {
             let mut wr = MemWriter::new();
             for _ in 0..times {
-                wr.write(src.as_slice()).unwrap();
+                wr.write(&src).unwrap();
             }
 
             let v = wr.into_inner();
@@ -722,7 +722,7 @@ fn bench_mem_reader(b: &mut Bencher) {
                 for _i in 0u..10 {
                     let mut buf = [0 as u8; 10];
                     rdr.read(&mut buf).unwrap();
-                    assert_eq!(buf.as_slice(), [5; 10].as_slice());
+                    assert_eq!(buf, [5; 10]);
                 }
             }
         });
index c9cabe648b994880dd5c6f125767fb91cea41d35..c3e4e7fc80d2e2a308c9bd9d835b00e2077c1d47 100644 (file)
@@ -1076,7 +1076,7 @@ fn write_line(&mut self, s: &str) -> IoResult<()> {
     #[inline]
     fn write_char(&mut self, c: char) -> IoResult<()> {
         let mut buf = [0u8; 4];
-        let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
+        let n = c.encode_utf8(&mut buf).unwrap_or(0);
         self.write_all(&buf[..n])
     }
 
@@ -1870,7 +1870,7 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
                     // fall back on good
                     return r.read(buf);
                 }
-                match behavior.as_mut_slice()[0] {
+                match (&mut **behavior)[0] {
                     GoodBehavior(0) => (),
                     GoodBehavior(ref mut x) => {
                         *x -= 1;
index d85251795c887d254af8c696f8e57f9a2c9e5fb4..9c89c943994630f46c1b7633ec24cabe5dc8fb6a 100644 (file)
@@ -323,25 +323,25 @@ fn read_ipv6_addr(&mut self) -> Option<IpAddr> {
     }
 
     fn read_ip_addr(&mut self) -> Option<IpAddr> {
-        let ipv4_addr = |&mut: p: &mut Parser| p.read_ipv4_addr();
-        let ipv6_addr = |&mut: p: &mut Parser| p.read_ipv6_addr();
+        let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr();
+        let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr();
         self.read_or(&mut [box ipv4_addr, box ipv6_addr])
     }
 
     fn read_socket_addr(&mut self) -> Option<SocketAddr> {
-        let ip_addr = |&: p: &mut Parser| {
-            let ipv4_p = |&mut: p: &mut Parser| p.read_ip_addr();
-            let ipv6_p = |&mut: p: &mut Parser| {
-                let open_br = |&: p: &mut Parser| p.read_given_char('[');
-                let ip_addr = |&: p: &mut Parser| p.read_ipv6_addr();
-                let clos_br = |&: p: &mut Parser| p.read_given_char(']');
+        let ip_addr = |p: &mut Parser| {
+            let ipv4_p = |p: &mut Parser| p.read_ip_addr();
+            let ipv6_p = |p: &mut Parser| {
+                let open_br = |p: &mut Parser| p.read_given_char('[');
+                let ip_addr = |p: &mut Parser| p.read_ipv6_addr();
+                let clos_br = |p: &mut Parser| p.read_given_char(']');
                 p.read_seq_3::<char, IpAddr, char, _, _, _>(open_br, ip_addr, clos_br)
                         .map(|t| match t { (_, ip, _) => ip })
             };
             p.read_or(&mut [box ipv4_p, box ipv6_p])
         };
-        let colon = |&: p: &mut Parser| p.read_given_char(':');
-        let port  = |&: p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16);
+        let colon = |p: &mut Parser| p.read_given_char(':');
+        let port  = |p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16);
 
         // host, colon, port
         self.read_seq_3::<IpAddr, char, u16, _, _, _>(ip_addr, colon, port)
index 27af957e18e18614c591e47fd2911a9672cdd8f2..195d33c41a68e98e02210ccb4ad6eba323315a2d 100644 (file)
@@ -239,8 +239,8 @@ fn get_env_map<'a>(&'a mut self) -> &'a mut EnvMap {
                 // if the env is currently just inheriting from the parent's,
                 // materialize the parent's env into a hashtable.
                 self.env = Some(os::env_as_bytes().into_iter().map(|(k, v)| {
-                    (EnvKey(CString::from_slice(k.as_slice())),
-                     CString::from_slice(v.as_slice()))
+                    (EnvKey(CString::from_slice(&k)),
+                     CString::from_slice(&v))
                 }).collect());
                 self.env.as_mut().unwrap()
             }
@@ -440,7 +440,7 @@ fn program(&self) -> &CString {
         &self.program
     }
     fn args(&self) -> &[CString] {
-        self.args.as_slice()
+        &self.args
     }
     fn env(&self) -> Option<&EnvMap> {
         self.env.as_ref()
@@ -703,7 +703,7 @@ fn read(stream: Option<old_io::PipeStream>) -> Receiver<IoResult<Vec<u8>>> {
             let (tx, rx) = channel();
             match stream {
                 Some(stream) => {
-                    Thread::spawn(move |:| {
+                    Thread::spawn(move || {
                         let mut stream = stream;
                         tx.send(stream.read_to_end()).unwrap();
                     });
@@ -915,7 +915,7 @@ fn test_process_output_fail_to_start() {
     fn test_process_output_output() {
         let ProcessOutput {status, output, error}
              = Command::new("echo").arg("hello").output().unwrap();
-        let output_str = str::from_utf8(output.as_slice()).unwrap();
+        let output_str = str::from_utf8(&output).unwrap();
 
         assert!(status.success());
         assert_eq!(output_str.trim().to_string(), "hello");
@@ -956,7 +956,7 @@ fn test_finish_twice() {
     fn test_wait_with_output_once() {
         let prog = Command::new("echo").arg("hello").spawn().unwrap();
         let ProcessOutput {status, output, error} = prog.wait_with_output().unwrap();
-        let output_str = str::from_utf8(output.as_slice()).unwrap();
+        let output_str = str::from_utf8(&output).unwrap();
 
         assert!(status.success());
         assert_eq!(output_str.trim().to_string(), "hello");
@@ -1049,7 +1049,7 @@ fn test_inherit_env() {
         for &(ref k, ref v) in &r {
             // don't check windows magical empty-named variables
             assert!(k.is_empty() ||
-                    output.contains(format!("{}={}", *k, *v).as_slice()),
+                    output.contains(&format!("{}={}", *k, *v)),
                     "output doesn't contain `{}={}`\n{}",
                     k, v, output);
         }
@@ -1067,12 +1067,12 @@ fn test_inherit_env() {
         for &(ref k, ref v) in &r {
             // don't check android RANDOM variables
             if *k != "RANDOM".to_string() {
-                assert!(output.contains(format!("{}={}",
-                                                *k,
-                                                *v).as_slice()) ||
-                        output.contains(format!("{}=\'{}\'",
-                                                *k,
-                                                *v).as_slice()));
+                assert!(output.contains(&format!("{}={}",
+                                                 *k,
+                                                 *v)) ||
+                        output.contains(&format!("{}=\'{}\'",
+                                                 *k,
+                                                 *v)));
             }
         }
     }
@@ -1091,13 +1091,13 @@ fn test_override_env() {
             None => {}
             Some(val) => {
                 path_val = val;
-                new_env.push(("PATH", path_val.as_slice()))
+                new_env.push(("PATH", &path_val))
             }
         }
 
-        let prog = env_cmd().env_set_all(new_env.as_slice()).spawn().unwrap();
+        let prog = env_cmd().env_set_all(&new_env).spawn().unwrap();
         let result = prog.wait_with_output().unwrap();
-        let output = String::from_utf8_lossy(result.output.as_slice()).to_string();
+        let output = String::from_utf8_lossy(&result.output).to_string();
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"),
                 "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
@@ -1107,7 +1107,7 @@ fn test_override_env() {
     fn test_add_to_env() {
         let prog = env_cmd().env("RUN_TEST_NEW_ENV", "123").spawn().unwrap();
         let result = prog.wait_with_output().unwrap();
-        let output = String::from_utf8_lossy(result.output.as_slice()).to_string();
+        let output = String::from_utf8_lossy(&result.output).to_string();
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"),
                 "didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
index 96b979860ae902fe571e226cb00fb3fdeb592a8e..f42cb6ce8c97bf4d9c9f93d1b5ef9a2b5273945a 100644 (file)
@@ -112,7 +112,7 @@ fn test_option_reader() {
         let mut buf = [0, 0];
         reader.read(&mut buf).unwrap();
         let b: &[_] = &[0, 1];
-        assert_eq!(buf.as_slice(), b);
+        assert_eq!(buf, b);
     }
 
     #[test]
index f78e3ac1f14dad01c1a2a4583b01026c70cf8b9d..5ae239014d188145e55a2014b36be610b3f03dba 100644 (file)
@@ -101,7 +101,7 @@ fn read(&mut self, buf: &mut [u8]) -> old_io::IoResult<uint> {
 impl Buffer for ZeroReader {
     fn fill_buf<'a>(&'a mut self) -> old_io::IoResult<&'a [u8]> {
         static DATA: [u8; 64] = [0; 64];
-        Ok(DATA.as_slice())
+        Ok(&DATA)
     }
 
     fn consume(&mut self, _amt: uint) {}
@@ -321,7 +321,7 @@ fn test_limit_reader_overlong_consume() {
     fn test_null_writer() {
         let mut s = NullWriter;
         let buf = vec![0, 0, 0];
-        s.write_all(buf.as_slice()).unwrap();
+        s.write_all(&buf).unwrap();
         s.flush().unwrap();
     }
 
@@ -329,7 +329,7 @@ fn test_null_writer() {
     fn test_zero_reader() {
         let mut s = ZeroReader;
         let mut buf = vec![1, 2, 3];
-        assert_eq!(s.read(buf.as_mut_slice()), Ok(3));
+        assert_eq!(s.read(&mut buf), Ok(3));
         assert_eq!(vec![0, 0, 0], buf);
     }
 
@@ -337,7 +337,7 @@ fn test_zero_reader() {
     fn test_null_reader() {
         let mut r = NullReader;
         let mut buf = vec![0];
-        assert!(r.read(buf.as_mut_slice()).is_err());
+        assert!(r.read(&mut buf).is_err());
     }
 
     #[test]
index 8bcdd89623d8fb91a0e8b10e2f38287f73cece51..6bf2a30b7b184e91aa85fe2b13b1b46173a19b57 100644 (file)
@@ -131,25 +131,25 @@ unsafe fn set_filename_unchecked<T: BytesContainer>(&mut self, filename: T) {
                 v.push(SEP_BYTE);
                 v.push_all(filename);
                 // FIXME: this is slow
-                self.repr = Path::normalize(v.as_slice());
+                self.repr = Path::normalize(&v);
             }
             None => {
                 self.repr = Path::normalize(filename);
             }
             Some(idx) if &self.repr[idx+1..] == b".." => {
                 let mut v = Vec::with_capacity(self.repr.len() + 1 + filename.len());
-                v.push_all(self.repr.as_slice());
+                v.push_all(&self.repr);
                 v.push(SEP_BYTE);
                 v.push_all(filename);
                 // FIXME: this is slow
-                self.repr = Path::normalize(v.as_slice());
+                self.repr = Path::normalize(&v);
             }
             Some(idx) => {
                 let mut v = Vec::with_capacity(idx + 1 + filename.len());
                 v.push_all(&self.repr[..idx+1]);
                 v.push_all(filename);
                 // FIXME: this is slow
-                self.repr = Path::normalize(v.as_slice());
+                self.repr = Path::normalize(&v);
             }
         }
         self.sepidx = self.repr.rposition_elem(&SEP_BYTE);
@@ -162,11 +162,11 @@ unsafe fn push_unchecked<T: BytesContainer>(&mut self, path: T) {
                 self.repr = Path::normalize(path);
             }  else {
                 let mut v = Vec::with_capacity(self.repr.len() + path.len() + 1);
-                v.push_all(self.repr.as_slice());
+                v.push_all(&self.repr);
                 v.push(SEP_BYTE);
                 v.push_all(path);
                 // FIXME: this is slow
-                self.repr = Path::normalize(v.as_slice());
+                self.repr = Path::normalize(&v);
             }
             self.sepidx = self.repr.rposition_elem(&SEP_BYTE);
         }
@@ -176,7 +176,7 @@ unsafe fn push_unchecked<T: BytesContainer>(&mut self, path: T) {
 impl GenericPath for Path {
     #[inline]
     fn as_vec<'a>(&'a self) -> &'a [u8] {
-        self.repr.as_slice()
+        &self.repr
     }
 
     fn into_vec(self) -> Vec<u8> {
@@ -185,10 +185,10 @@ fn into_vec(self) -> Vec<u8> {
 
     fn dirname<'a>(&'a self) -> &'a [u8] {
         match self.sepidx {
-            None if b".." == self.repr => self.repr.as_slice(),
+            None if b".." == self.repr => &self.repr,
             None => dot_static,
             Some(0) => &self.repr[..1],
-            Some(idx) if &self.repr[idx+1..] == b".." => self.repr.as_slice(),
+            Some(idx) if &self.repr[idx+1..] == b".." => &self.repr,
             Some(idx) => &self.repr[..idx]
         }
     }
@@ -197,7 +197,7 @@ fn filename<'a>(&'a self) -> Option<&'a [u8]> {
         match self.sepidx {
             None if b"." == self.repr ||
                 b".." == self.repr => None,
-            None => Some(self.repr.as_slice()),
+            None => Some(&self.repr),
             Some(idx) if &self.repr[idx+1..] == b".." => None,
             Some(0) if self.repr[1..].is_empty() => None,
             Some(idx) => Some(&self.repr[idx+1..])
@@ -382,7 +382,7 @@ fn normalize<V: ?Sized + AsSlice<u8>>(v: &V) -> Vec<u8> {
     pub fn components<'a>(&'a self) -> Components<'a> {
         let v = if self.repr[0] == SEP_BYTE {
             &self.repr[1..]
-        } else { self.repr.as_slice() };
+        } else { &*self.repr };
         let is_sep_byte: fn(&u8) -> bool = is_sep_byte; // coerce to fn ptr
         let mut ret = v.split(is_sep_byte);
         if v.is_empty() {
@@ -557,14 +557,14 @@ macro_rules! t {
                 {
                     let path = Path::new($path);
                     let mo = path.display().as_cow();
-                    assert_eq!(mo.as_slice(), $exp);
+                    assert_eq!(mo, $exp);
                 }
             );
             ($path:expr, $exp:expr, filename) => (
                 {
                     let path = Path::new($path);
                     let mo = path.filename_display().as_cow();
-                    assert_eq!(mo.as_slice(), $exp);
+                    assert_eq!(mo, $exp);
                 }
             )
         }
index 2e25403220d8264c99d15083fb5a28f86acf501d..54c070e1b7db83eb507f1da9c290f526ec5f4de9 100644 (file)
@@ -1337,10 +1337,10 @@ fn test_display_str() {
 
         let path = Path::new("foo");
         let mo = path.display().as_cow();
-        assert_eq!(mo.as_slice(), "foo");
+        assert_eq!(mo, "foo");
         let path = Path::new(b"\\");
         let mo = path.filename_display().as_cow();
-        assert_eq!(mo.as_slice(), "");
+        assert_eq!(mo, "");
     }
 
     #[test]
index 72a8ac049117b9da89eb3ab7fd36da4ccf5d6b50..bc7a0d821c566d9691bd9228d5403601d26ac2fa 100644 (file)
@@ -649,7 +649,7 @@ fn real_args_as_bytes() -> Vec<Vec<u8>> {
 fn real_args() -> Vec<String> {
     real_args_as_bytes().into_iter()
                         .map(|v| {
-                            String::from_utf8_lossy(v.as_slice()).into_owned()
+                            String::from_utf8_lossy(&v).into_owned()
                         }).collect()
 }
 
@@ -1444,7 +1444,7 @@ fn make_rand_name() -> String {
         let mut rng = rand::thread_rng();
         let n = format!("TEST{}", rng.gen_ascii_chars().take(10u)
                                      .collect::<String>());
-        assert!(getenv(n.as_slice()).is_none());
+        assert!(getenv(&n).is_none());
         n
     }
 
@@ -1456,27 +1456,27 @@ fn test_num_cpus() {
     #[test]
     fn test_setenv() {
         let n = make_rand_name();
-        setenv(n.as_slice(), "VALUE");
-        assert_eq!(getenv(n.as_slice()), Some("VALUE".to_string()));
+        setenv(&n, "VALUE");
+        assert_eq!(getenv(&n), Some("VALUE".to_string()));
     }
 
     #[test]
     fn test_unsetenv() {
         let n = make_rand_name();
-        setenv(n.as_slice(), "VALUE");
-        unsetenv(n.as_slice());
-        assert_eq!(getenv(n.as_slice()), None);
+        setenv(&n, "VALUE");
+        unsetenv(&n);
+        assert_eq!(getenv(&n), None);
     }
 
     #[test]
     #[ignore]
     fn test_setenv_overwrite() {
         let n = make_rand_name();
-        setenv(n.as_slice(), "1");
-        setenv(n.as_slice(), "2");
-        assert_eq!(getenv(n.as_slice()), Some("2".to_string()));
-        setenv(n.as_slice(), "");
-        assert_eq!(getenv(n.as_slice()), Some("".to_string()));
+        setenv(&n, "1");
+        setenv(&n, "2");
+        assert_eq!(getenv(&n), Some("2".to_string()));
+        setenv(&n, "");
+        assert_eq!(getenv(&n), Some("".to_string()));
     }
 
     // Windows GetEnvironmentVariable requires some extra work to make sure
@@ -1491,9 +1491,9 @@ fn test_getenv_big() {
             i += 1;
         }
         let n = make_rand_name();
-        setenv(n.as_slice(), s.as_slice());
+        setenv(&n, &s);
         debug!("{}", s.clone());
-        assert_eq!(getenv(n.as_slice()), Some(s));
+        assert_eq!(getenv(&n), Some(s));
     }
 
     #[test]
@@ -1526,7 +1526,7 @@ fn test_env_getenv() {
         for p in &e {
             let (n, v) = (*p).clone();
             debug!("{}", n);
-            let v2 = getenv(n.as_slice());
+            let v2 = getenv(&n);
             // MingW seems to set some funky environment variables like
             // "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned
             // from env() but not visible from getenv().
@@ -1538,10 +1538,10 @@ fn test_env_getenv() {
     fn test_env_set_get_huge() {
         let n = make_rand_name();
         let s = repeat("x").take(10000).collect::<String>();
-        setenv(n.as_slice(), s.as_slice());
-        assert_eq!(getenv(n.as_slice()), Some(s));
-        unsetenv(n.as_slice());
-        assert_eq!(getenv(n.as_slice()), None);
+        setenv(&n, &s);
+        assert_eq!(getenv(&n), Some(s));
+        unsetenv(&n);
+        assert_eq!(getenv(&n), None);
     }
 
     #[test]
@@ -1549,7 +1549,7 @@ fn test_env_setenv() {
         let n = make_rand_name();
 
         let mut e = env();
-        setenv(n.as_slice(), "VALUE");
+        setenv(&n, "VALUE");
         assert!(!e.contains(&(n.clone(), "VALUE".to_string())));
 
         e = env();
@@ -1579,7 +1579,7 @@ fn homedir() {
         assert!(os::homedir().is_none());
 
         if let Some(s) = oldhome {
-            setenv("HOME", s.as_slice());
+            setenv("HOME", s);
         }
     }
 
@@ -1608,10 +1608,10 @@ fn homedir() {
         assert!(os::homedir() == Some(Path::new("/home/MountainView")));
 
         if let Some(s) = oldhome {
-            setenv("HOME", s.as_slice());
+            setenv("HOME", &s);
         }
         if let Some(s) = olduserprofile {
-            setenv("USERPROFILE", s.as_slice());
+            setenv("USERPROFILE", &s);
         }
     }
 
index e52d5ada0ef092767896d0dbc53c6e79dd263196..8f9e966cbb2b7a9fbe29a33d8d7ff6fad8cd4b28 100644 (file)
@@ -469,7 +469,7 @@ fn test_fill_bytes_default() {
                        80, 81, 82, 83, 84, 85, 86, 87];
         for &n in &lengths {
             let mut v = repeat(0u8).take(n).collect::<Vec<_>>();
-            r.fill_bytes(v.as_mut_slice());
+            r.fill_bytes(&mut v);
 
             // use this to get nicer error messages.
             for (i, &byte) in v.iter().enumerate() {
@@ -619,8 +619,8 @@ fn test_sample() {
     #[test]
     fn test_std_rng_seeded() {
         let s = thread_rng().gen_iter::<uint>().take(256).collect::<Vec<uint>>();
-        let mut ra: StdRng = SeedableRng::from_seed(s.as_slice());
-        let mut rb: StdRng = SeedableRng::from_seed(s.as_slice());
+        let mut ra: StdRng = SeedableRng::from_seed(&*s);
+        let mut rb: StdRng = SeedableRng::from_seed(&*s);
         assert!(order::equals(ra.gen_ascii_chars().take(100),
                               rb.gen_ascii_chars().take(100)));
     }
@@ -628,10 +628,10 @@ fn test_std_rng_seeded() {
     #[test]
     fn test_std_rng_reseed() {
         let s = thread_rng().gen_iter::<uint>().take(256).collect::<Vec<uint>>();
-        let mut r: StdRng = SeedableRng::from_seed(s.as_slice());
+        let mut r: StdRng = SeedableRng::from_seed(&*s);
         let string1 = r.gen_ascii_chars().take(100).collect::<String>();
 
-        r.reseed(s.as_slice());
+        r.reseed(&s);
 
         let string2 = r.gen_ascii_chars().take(100).collect::<String>();
         assert_eq!(string1, string2);
index b3bed4af96248dd4cdf70c25cad961aa7ac8b53f..c2f5133eaf3fe5547a3fd450274d0948d127cee4 100644 (file)
@@ -125,7 +125,7 @@ fn smoke_test() {
             assert!(take() == Some(expected.clone()));
             assert!(take() == None);
 
-            (|&mut:| {
+            (|| {
             }).finally(|| {
                 // Restore the actual global state.
                 match saved_value {
index 8340652d19ae6d8f06e225c66537b5bf90e1bf55..a230e35dac8c3db163a46ba7b4e56713c3f804b0 100644 (file)
@@ -126,7 +126,7 @@ pub fn from_receiver(rx: Receiver<A>) -> Future<A> {
          * waiting for the result to be received on the port.
          */
 
-        Future::from_fn(move |:| {
+        Future::from_fn(move || {
             rx.recv().unwrap()
         })
     }
@@ -143,7 +143,7 @@ pub fn spawn<F>(blk: F) -> Future<A>
 
         let (tx, rx) = channel();
 
-        Thread::spawn(move |:| {
+        Thread::spawn(move || {
             // Don't panic if the other end has hung up
             let _ = tx.send(blk());
         });
index c80aa56717315d9f5cdb76b0d706ab6983989a72..f0558c33d1ec8d973ba11430443570a0cd176369 100644 (file)
@@ -274,7 +274,7 @@ fn peek() {
 
             // Ensure the borrowchecker works
             match queue.peek() {
-                Some(vec) => match vec.as_slice() {
+                Some(vec) => match &**vec {
                     // Note that `pop` is not allowed here due to borrow
                     [1] => {}
                     _ => return
index 1bfcbcf96f1443cbbd78a721ac6dece674c4c96b..684a46fd6ff5fa51fde077b0540c2c7a604491b5 100644 (file)
@@ -112,7 +112,7 @@ pub fn execute<F>(&self, job: F)
 }
 
 fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk>>>) {
-    Thread::spawn(move |:| {
+    Thread::spawn(move || {
         // Will spawn a new thread on panic unless it is cancelled.
         let sentinel = Sentinel::new(&jobs);
 
index 6f6179a436e914c3c77de9384be7e6b41799ea02..255f474d4f4afb42bca461c9a0fad3f5013dee20 100644 (file)
@@ -95,14 +95,14 @@ pub fn boot<T, F>(&'static self, f: F, helper: fn(helper_signal::signal, Receive
                 let receive = RaceBox(receive);
 
                 let t = f();
-                Thread::spawn(move |:| {
+                Thread::spawn(move || {
                     helper(receive.0, rx, t);
                     let _g = self.lock.lock().unwrap();
                     *self.shutdown.get() = true;
                     self.cond.notify_one()
                 });
 
-                rt::at_exit(move|:| { self.shutdown() });
+                rt::at_exit(move|| { self.shutdown() });
                 *self.initialized.get() = true;
             }
         }
index 833de8adda49dfbb41ce8fb95fa3dbf65a443279..7325e0a5ac8ddfaeb3726aeca06be0c723b5d987 100644 (file)
@@ -723,8 +723,8 @@ fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
 
     pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
         let fd = self.fd();
-        let dolock = |&:| self.lock_nonblocking();
-        let doread = |&mut: nb| unsafe {
+        let dolock = || self.lock_nonblocking();
+        let doread = |nb| unsafe {
             let flags = if nb {c::MSG_DONTWAIT} else {0};
             libc::recv(fd,
                        buf.as_mut_ptr() as *mut libc::c_void,
@@ -736,8 +736,8 @@ pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 
     pub fn write(&mut self, buf: &[u8]) -> IoResult<()> {
         let fd = self.fd();
-        let dolock = |&:| self.lock_nonblocking();
-        let dowrite = |&: nb: bool, buf: *const u8, len: uint| unsafe {
+        let dolock = || self.lock_nonblocking();
+        let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe {
             let flags = if nb {c::MSG_DONTWAIT} else {0};
             libc::send(fd,
                        buf as *const _,
@@ -871,7 +871,7 @@ pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)> {
         let mut addrlen: libc::socklen_t =
                 mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t;
 
-        let dolock = |&:| self.lock_nonblocking();
+        let dolock = || self.lock_nonblocking();
         let n = try!(read(fd, self.read_deadline, dolock, |nb| unsafe {
             let flags = if nb {c::MSG_DONTWAIT} else {0};
             libc::recvfrom(fd,
@@ -892,8 +892,8 @@ pub fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> {
         let dstp = &storage as *const _ as *const libc::sockaddr;
 
         let fd = self.fd();
-        let dolock = |&: | self.lock_nonblocking();
-        let dowrite = |&mut: nb, buf: *const u8, len: uint| unsafe {
+        let dolock = || self.lock_nonblocking();
+        let dowrite = |nb, buf: *const u8, len: uint| unsafe {
             let flags = if nb {c::MSG_DONTWAIT} else {0};
             libc::sendto(fd,
                          buf as *const libc::c_void,
index 7c9758ca9242d88cd28a2685d6a3224c270c5dfe..ce67a584a0a5e0d313588fdd3ff640f937ec8075 100644 (file)
@@ -57,7 +57,7 @@ pub fn stack_guard() -> uint {
 pub fn set(stack_bounds: (uint, uint), stack_guard: uint, thread: Thread) {
     THREAD_INFO.with(|c| assert!(c.borrow().is_none()));
     match thread.name() {
-        Some(name) => unsafe { ::sys::thread::set_name(name.as_slice()); },
+        Some(name) => unsafe { ::sys::thread::set_name(name); },
         None => {}
     }
     THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{
index b30af10986b9952235c200e4de4a81db959d64e8..04cba804e8df7ef2b9762eced47c07c44cf76820 100644 (file)
@@ -140,7 +140,7 @@ fn deref(&self) -> &Wtf8 {
 impl fmt::Debug for Wtf8Buf {
     #[inline]
     fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
-        self.as_slice().fmt(formatter)
+        fmt::Debug::fmt(&**self, formatter)
     }
 }
 
@@ -220,7 +220,7 @@ fn push_code_point_unchecked(&mut self, code_point: CodePoint) {
 
     #[inline]
     pub fn as_slice(&self) -> &Wtf8 {
-        unsafe { mem::transmute(self.bytes.as_slice()) }
+        unsafe { mem::transmute(&*self.bytes) }
     }
 
     /// Reserves capacity for at least `additional` more bytes to be inserted
@@ -309,7 +309,7 @@ pub fn push(&mut self, code_point: CodePoint) {
     /// or if `new_len` is not a code point boundary.
     #[inline]
     pub fn truncate(&mut self, new_len: uint) {
-        assert!(is_code_point_boundary(self.as_slice(), new_len));
+        assert!(is_code_point_boundary(self, new_len));
         self.bytes.truncate(new_len)
     }
 
@@ -771,7 +771,7 @@ fn next(&mut self) -> Option<u16> {
 
         let mut buf = [0u16; 2];
         self.code_points.next().map(|code_point| {
-            let n = encode_utf16_raw(code_point.value, buf.as_mut_slice())
+            let n = encode_utf16_raw(code_point.value, &mut buf)
                 .unwrap_or(0);
             if n == 2 { self.extra = buf[1]; }
             buf[0]
@@ -798,7 +798,7 @@ fn hash(&self, state: &mut S) {
 impl<S: Writer + Hasher> Hash<S> for Wtf8Buf {
     #[inline]
     fn hash(&self, state: &mut S) {
-        state.write(self.bytes.as_slice());
+        state.write(&self.bytes);
         0xfeu8.hash(state)
     }
 }
@@ -843,8 +843,8 @@ fn code_point_from_char() {
 
     #[test]
     fn code_point_to_string() {
-        assert_eq!(format!("{:?}", CodePoint::from_char('a')).as_slice(), "U+0061");
-        assert_eq!(format!("{:?}", CodePoint::from_char('💩')).as_slice(), "U+1F4A9");
+        assert_eq!(format!("{:?}", CodePoint::from_char('a')), "U+0061");
+        assert_eq!(format!("{:?}", CodePoint::from_char('💩')), "U+1F4A9");
     }
 
     #[test]
@@ -865,142 +865,142 @@ fn c(value: u32) -> CodePoint { CodePoint::from_u32(value).unwrap() }
 
     #[test]
     fn wtf8buf_new() {
-        assert_eq!(Wtf8Buf::new().bytes.as_slice(), b"");
+        assert_eq!(Wtf8Buf::new().bytes, b"");
     }
 
     #[test]
     fn wtf8buf_from_str() {
-        assert_eq!(Wtf8Buf::from_str("").bytes.as_slice(), b"");
-        assert_eq!(Wtf8Buf::from_str("aé 💩").bytes.as_slice(),
+        assert_eq!(Wtf8Buf::from_str("").bytes, b"");
+        assert_eq!(Wtf8Buf::from_str("aé 💩").bytes,
                    b"a\xC3\xA9 \xF0\x9F\x92\xA9");
     }
 
     #[test]
     fn wtf8buf_from_string() {
-        assert_eq!(Wtf8Buf::from_string(String::from_str("")).bytes.as_slice(), b"");
-        assert_eq!(Wtf8Buf::from_string(String::from_str("aé 💩")).bytes.as_slice(),
+        assert_eq!(Wtf8Buf::from_string(String::from_str("")).bytes, b"");
+        assert_eq!(Wtf8Buf::from_string(String::from_str("aé 💩")).bytes,
                    b"a\xC3\xA9 \xF0\x9F\x92\xA9");
     }
 
     #[test]
     fn wtf8buf_from_wide() {
-        assert_eq!(Wtf8Buf::from_wide(&[]).bytes.as_slice(), b"");
+        assert_eq!(Wtf8Buf::from_wide(&[]).bytes, b"");
         assert_eq!(Wtf8Buf::from_wide(
-                      &[0x61, 0xE9, 0x20, 0xD83D, 0xD83D, 0xDCA9]).bytes.as_slice(),
+                      &[0x61, 0xE9, 0x20, 0xD83D, 0xD83D, 0xDCA9]).bytes,
                    b"a\xC3\xA9 \xED\xA0\xBD\xF0\x9F\x92\xA9");
     }
 
     #[test]
     fn wtf8buf_push_str() {
         let mut string = Wtf8Buf::new();
-        assert_eq!(string.bytes.as_slice(), b"");
+        assert_eq!(string.bytes, b"");
         string.push_str("aé 💩");
-        assert_eq!(string.bytes.as_slice(), b"a\xC3\xA9 \xF0\x9F\x92\xA9");
+        assert_eq!(string.bytes, b"a\xC3\xA9 \xF0\x9F\x92\xA9");
     }
 
     #[test]
     fn wtf8buf_push_char() {
         let mut string = Wtf8Buf::from_str("aé ");
-        assert_eq!(string.bytes.as_slice(), b"a\xC3\xA9 ");
+        assert_eq!(string.bytes, b"a\xC3\xA9 ");
         string.push_char('💩');
-        assert_eq!(string.bytes.as_slice(), b"a\xC3\xA9 \xF0\x9F\x92\xA9");
+        assert_eq!(string.bytes, b"a\xC3\xA9 \xF0\x9F\x92\xA9");
     }
 
     #[test]
     fn wtf8buf_push() {
         let mut string = Wtf8Buf::from_str("aé ");
-        assert_eq!(string.bytes.as_slice(), b"a\xC3\xA9 ");
+        assert_eq!(string.bytes, b"a\xC3\xA9 ");
         string.push(CodePoint::from_char('💩'));
-        assert_eq!(string.bytes.as_slice(), b"a\xC3\xA9 \xF0\x9F\x92\xA9");
+        assert_eq!(string.bytes, b"a\xC3\xA9 \xF0\x9F\x92\xA9");
 
         fn c(value: u32) -> CodePoint { CodePoint::from_u32(value).unwrap() }
 
         let mut string = Wtf8Buf::new();
         string.push(c(0xD83D));  // lead
         string.push(c(0xDCA9));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xF0\x9F\x92\xA9");  // Magic!
+        assert_eq!(string.bytes, b"\xF0\x9F\x92\xA9");  // Magic!
 
         let mut string = Wtf8Buf::new();
         string.push(c(0xD83D));  // lead
         string.push(c(0x20));  // not surrogate
         string.push(c(0xDCA9));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xED\xA0\xBD \xED\xB2\xA9");
+        assert_eq!(string.bytes, b"\xED\xA0\xBD \xED\xB2\xA9");
 
         let mut string = Wtf8Buf::new();
         string.push(c(0xD800));  // lead
         string.push(c(0xDBFF));  // lead
-        assert_eq!(string.bytes.as_slice(), b"\xED\xA0\x80\xED\xAF\xBF");
+        assert_eq!(string.bytes, b"\xED\xA0\x80\xED\xAF\xBF");
 
         let mut string = Wtf8Buf::new();
         string.push(c(0xD800));  // lead
         string.push(c(0xE000));  // not surrogate
-        assert_eq!(string.bytes.as_slice(), b"\xED\xA0\x80\xEE\x80\x80");
+        assert_eq!(string.bytes, b"\xED\xA0\x80\xEE\x80\x80");
 
         let mut string = Wtf8Buf::new();
         string.push(c(0xD7FF));  // not surrogate
         string.push(c(0xDC00));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xED\x9F\xBF\xED\xB0\x80");
+        assert_eq!(string.bytes, b"\xED\x9F\xBF\xED\xB0\x80");
 
         let mut string = Wtf8Buf::new();
         string.push(c(0x61));  // not surrogate, < 3 bytes
         string.push(c(0xDC00));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\x61\xED\xB0\x80");
+        assert_eq!(string.bytes, b"\x61\xED\xB0\x80");
 
         let mut string = Wtf8Buf::new();
         string.push(c(0xDC00));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xED\xB0\x80");
+        assert_eq!(string.bytes, b"\xED\xB0\x80");
     }
 
     #[test]
     fn wtf8buf_push_wtf8() {
         let mut string = Wtf8Buf::from_str("aé");
-        assert_eq!(string.bytes.as_slice(), b"a\xC3\xA9");
+        assert_eq!(string.bytes, b"a\xC3\xA9");
         string.push_wtf8(Wtf8::from_str(" 💩"));
-        assert_eq!(string.bytes.as_slice(), b"a\xC3\xA9 \xF0\x9F\x92\xA9");
+        assert_eq!(string.bytes, b"a\xC3\xA9 \xF0\x9F\x92\xA9");
 
         fn w(value: &[u8]) -> &Wtf8 { unsafe { transmute(value) } }
 
         let mut string = Wtf8Buf::new();
         string.push_wtf8(w(b"\xED\xA0\xBD"));  // lead
         string.push_wtf8(w(b"\xED\xB2\xA9"));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xF0\x9F\x92\xA9");  // Magic!
+        assert_eq!(string.bytes, b"\xF0\x9F\x92\xA9");  // Magic!
 
         let mut string = Wtf8Buf::new();
         string.push_wtf8(w(b"\xED\xA0\xBD"));  // lead
         string.push_wtf8(w(b" "));  // not surrogate
         string.push_wtf8(w(b"\xED\xB2\xA9"));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xED\xA0\xBD \xED\xB2\xA9");
+        assert_eq!(string.bytes, b"\xED\xA0\xBD \xED\xB2\xA9");
 
         let mut string = Wtf8Buf::new();
         string.push_wtf8(w(b"\xED\xA0\x80"));  // lead
         string.push_wtf8(w(b"\xED\xAF\xBF"));  // lead
-        assert_eq!(string.bytes.as_slice(), b"\xED\xA0\x80\xED\xAF\xBF");
+        assert_eq!(string.bytes, b"\xED\xA0\x80\xED\xAF\xBF");
 
         let mut string = Wtf8Buf::new();
         string.push_wtf8(w(b"\xED\xA0\x80"));  // lead
         string.push_wtf8(w(b"\xEE\x80\x80"));  // not surrogate
-        assert_eq!(string.bytes.as_slice(), b"\xED\xA0\x80\xEE\x80\x80");
+        assert_eq!(string.bytes, b"\xED\xA0\x80\xEE\x80\x80");
 
         let mut string = Wtf8Buf::new();
         string.push_wtf8(w(b"\xED\x9F\xBF"));  // not surrogate
         string.push_wtf8(w(b"\xED\xB0\x80"));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xED\x9F\xBF\xED\xB0\x80");
+        assert_eq!(string.bytes, b"\xED\x9F\xBF\xED\xB0\x80");
 
         let mut string = Wtf8Buf::new();
         string.push_wtf8(w(b"a"));  // not surrogate, < 3 bytes
         string.push_wtf8(w(b"\xED\xB0\x80"));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\x61\xED\xB0\x80");
+        assert_eq!(string.bytes, b"\x61\xED\xB0\x80");
 
         let mut string = Wtf8Buf::new();
         string.push_wtf8(w(b"\xED\xB0\x80"));  // trail
-        assert_eq!(string.bytes.as_slice(), b"\xED\xB0\x80");
+        assert_eq!(string.bytes, b"\xED\xB0\x80");
     }
 
     #[test]
     fn wtf8buf_truncate() {
         let mut string = Wtf8Buf::from_str("aé");
         string.truncate(1);
-        assert_eq!(string.bytes.as_slice(), b"a");
+        assert_eq!(string.bytes, b"a");
     }
 
     #[test]
@@ -1038,15 +1038,15 @@ fn wtf8buf_from_iterator() {
         fn f(values: &[u32]) -> Wtf8Buf {
             values.iter().map(|&c| CodePoint::from_u32(c).unwrap()).collect::<Wtf8Buf>()
         };
-        assert_eq!(f(&[0x61, 0xE9, 0x20, 0x1F4A9]).bytes.as_slice(), b"a\xC3\xA9 \xF0\x9F\x92\xA9");
+        assert_eq!(f(&[0x61, 0xE9, 0x20, 0x1F4A9]).bytes, b"a\xC3\xA9 \xF0\x9F\x92\xA9");
 
-        assert_eq!(f(&[0xD83D, 0xDCA9]).bytes.as_slice(), b"\xF0\x9F\x92\xA9");  // Magic!
-        assert_eq!(f(&[0xD83D, 0x20, 0xDCA9]).bytes.as_slice(), b"\xED\xA0\xBD \xED\xB2\xA9");
-        assert_eq!(f(&[0xD800, 0xDBFF]).bytes.as_slice(), b"\xED\xA0\x80\xED\xAF\xBF");
-        assert_eq!(f(&[0xD800, 0xE000]).bytes.as_slice(), b"\xED\xA0\x80\xEE\x80\x80");
-        assert_eq!(f(&[0xD7FF, 0xDC00]).bytes.as_slice(), b"\xED\x9F\xBF\xED\xB0\x80");
-        assert_eq!(f(&[0x61, 0xDC00]).bytes.as_slice(), b"\x61\xED\xB0\x80");
-        assert_eq!(f(&[0xDC00]).bytes.as_slice(), b"\xED\xB0\x80");
+        assert_eq!(f(&[0xD83D, 0xDCA9]).bytes, b"\xF0\x9F\x92\xA9");  // Magic!
+        assert_eq!(f(&[0xD83D, 0x20, 0xDCA9]).bytes, b"\xED\xA0\xBD \xED\xB2\xA9");
+        assert_eq!(f(&[0xD800, 0xDBFF]).bytes, b"\xED\xA0\x80\xED\xAF\xBF");
+        assert_eq!(f(&[0xD800, 0xE000]).bytes, b"\xED\xA0\x80\xEE\x80\x80");
+        assert_eq!(f(&[0xD7FF, 0xDC00]).bytes, b"\xED\x9F\xBF\xED\xB0\x80");
+        assert_eq!(f(&[0x61, 0xDC00]).bytes, b"\x61\xED\xB0\x80");
+        assert_eq!(f(&[0xDC00]).bytes, b"\xED\xB0\x80");
     }
 
     #[test]
@@ -1058,23 +1058,23 @@ fn c(value: &u32) -> CodePoint { CodePoint::from_u32(*value).unwrap() }
             string
         };
 
-        assert_eq!(e(&[0x61, 0xE9], &[0x20, 0x1F4A9]).bytes.as_slice(),
+        assert_eq!(e(&[0x61, 0xE9], &[0x20, 0x1F4A9]).bytes,
                    b"a\xC3\xA9 \xF0\x9F\x92\xA9");
 
-        assert_eq!(e(&[0xD83D], &[0xDCA9]).bytes.as_slice(), b"\xF0\x9F\x92\xA9");  // Magic!
-        assert_eq!(e(&[0xD83D, 0x20], &[0xDCA9]).bytes.as_slice(), b"\xED\xA0\xBD \xED\xB2\xA9");
-        assert_eq!(e(&[0xD800], &[0xDBFF]).bytes.as_slice(), b"\xED\xA0\x80\xED\xAF\xBF");
-        assert_eq!(e(&[0xD800], &[0xE000]).bytes.as_slice(), b"\xED\xA0\x80\xEE\x80\x80");
-        assert_eq!(e(&[0xD7FF], &[0xDC00]).bytes.as_slice(), b"\xED\x9F\xBF\xED\xB0\x80");
-        assert_eq!(e(&[0x61], &[0xDC00]).bytes.as_slice(), b"\x61\xED\xB0\x80");
-        assert_eq!(e(&[], &[0xDC00]).bytes.as_slice(), b"\xED\xB0\x80");
+        assert_eq!(e(&[0xD83D], &[0xDCA9]).bytes, b"\xF0\x9F\x92\xA9");  // Magic!
+        assert_eq!(e(&[0xD83D, 0x20], &[0xDCA9]).bytes, b"\xED\xA0\xBD \xED\xB2\xA9");
+        assert_eq!(e(&[0xD800], &[0xDBFF]).bytes, b"\xED\xA0\x80\xED\xAF\xBF");
+        assert_eq!(e(&[0xD800], &[0xE000]).bytes, b"\xED\xA0\x80\xEE\x80\x80");
+        assert_eq!(e(&[0xD7FF], &[0xDC00]).bytes, b"\xED\x9F\xBF\xED\xB0\x80");
+        assert_eq!(e(&[0x61], &[0xDC00]).bytes, b"\x61\xED\xB0\x80");
+        assert_eq!(e(&[], &[0xDC00]).bytes, b"\xED\xB0\x80");
     }
 
     #[test]
     fn wtf8buf_show() {
         let mut string = Wtf8Buf::from_str("aé 💩");
         string.push(CodePoint::from_u32(0xD800).unwrap());
-        assert_eq!(format!("{:?}", string).as_slice(), r#""aé 💩\u{D800}""#);
+        assert_eq!(format!("{:?}", string), r#""aé 💩\u{D800}""#);
     }
 
     #[test]
@@ -1086,7 +1086,7 @@ fn wtf8buf_as_slice() {
     fn wtf8_show() {
         let mut string = Wtf8Buf::from_str("aé 💩");
         string.push(CodePoint::from_u32(0xD800).unwrap());
-        assert_eq!(format!("{:?}", string.as_slice()).as_slice(), r#""aé 💩\u{D800}""#);
+        assert_eq!(format!("{:?}", string), r#""aé 💩\u{D800}""#);
     }
 
     #[test]
index a2c93dea6a4f504283da80a06635a9c99e88d343..023d951dc4f8a8aad9152e24f5fc2d527b859425 100644 (file)
@@ -51,7 +51,7 @@ pub fn from_str(s: &str) -> Buf {
     }
 
     pub fn as_slice(&self) -> &Slice {
-        unsafe { mem::transmute(self.inner.as_slice()) }
+        unsafe { mem::transmute(&*self.inner) }
     }
 
     pub fn into_string(self) -> Result<String, Buf> {
index 16274a2ab0820a0112a90a3cad32288ed3f6beaa..45d5b1506c3aaf13145740f055c5f78075b2d0d3 100644 (file)
@@ -151,8 +151,8 @@ fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
 
     pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
         let fd = self.fd();
-        let dolock = |&:| self.lock_nonblocking();
-        let doread = |&mut: nb| unsafe {
+        let dolock = || self.lock_nonblocking();
+        let doread = |nb| unsafe {
             let flags = if nb {c::MSG_DONTWAIT} else {0};
             libc::recv(fd,
                        buf.as_mut_ptr() as *mut libc::c_void,
@@ -164,8 +164,8 @@ pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 
     pub fn write(&mut self, buf: &[u8]) -> IoResult<()> {
         let fd = self.fd();
-        let dolock = |&: | self.lock_nonblocking();
-        let dowrite = |&: nb: bool, buf: *const u8, len: uint| unsafe {
+        let dolock = || self.lock_nonblocking();
+        let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe {
             let flags = if nb {c::MSG_DONTWAIT} else {0};
             libc::send(fd,
                        buf as *const _,
index 20f86227e8eaf291d384ae40a0f34dbb39259e71..52a8ac9c338e0d4a58ba1a7f32a4b37af2bbea92 100644 (file)
@@ -84,8 +84,8 @@ unsafe fn set_cloexec(fd: c_int) {
             mem::transmute::<&ProcessConfig<K,V>,&'static ProcessConfig<K,V>>(cfg)
         };
 
-        with_envp(cfg.env(), move|envp: *const c_void| {
-            with_argv(cfg.program(), cfg.args(), move|argv: *const *const libc::c_char| unsafe {
+        with_envp(cfg.env(), move|envp: *const c_void| {
+            with_argv(cfg.program(), cfg.args(), move|argv: *const *const libc::c_char| unsafe {
                 let (input, mut output) = try!(sys::os::pipe());
 
                 // We may use this in the child, so perform allocations before the
@@ -185,7 +185,7 @@ fn fail(output: &mut FileDesc) -> ! {
                 // up /dev/null into that file descriptor. Otherwise, the first file
                 // descriptor opened up in the child would be numbered as one of the
                 // stdio file descriptors, which is likely to wreak havoc.
-                let setup = |&: src: Option<P>, dst: c_int| {
+                let setup = |src: Option<P>, dst: c_int| {
                     let src = match src {
                         None => {
                             let flags = if dst == libc::STDIN_FILENO {
index 315c41e779a36c7abfce420642b2cebb1c357a99..eab60047aa2bf557ea515fd53903e60d8b6d9bd1 100644 (file)
@@ -169,7 +169,7 @@ pub fn spawn<K, V, C, P>(cfg: &C, in_fd: Option<P>,
             // Similarly to unix, we don't actually leave holes for the stdio file
             // descriptors, but rather open up /dev/null equivalents. These
             // equivalents are drawn from libuv's windows process spawning.
-            let set_fd = |&: fd: &Option<P>, slot: &mut HANDLE,
+            let set_fd = |fd: &Option<P>, slot: &mut HANDLE,
                           is_stdin: bool| {
                 match *fd {
                     None => {
@@ -389,7 +389,7 @@ fn append_arg(cmd: &mut String, arg: &str) {
         }
         let argvec: Vec<char> = arg.chars().collect();
         for i in 0u..argvec.len() {
-            append_char_at(cmd, argvec.as_slice(), i);
+            append_char_at(cmd, &argvec, i);
         }
         if quote {
             cmd.push('"');
@@ -485,10 +485,9 @@ mod tests {
     fn test_make_command_line() {
         fn test_wrapper(prog: &str, args: &[&str]) -> String {
             make_command_line(&CString::from_slice(prog.as_bytes()),
-                              args.iter()
-                                  .map(|a| CString::from_slice(a.as_bytes()))
-                                  .collect::<Vec<CString>>()
-                                  .as_slice())
+                              &args.iter()
+                                   .map(|a| CString::from_slice(a.as_bytes()))
+                                   .collect::<Vec<CString>>())
         }
 
         assert_eq!(
index f02c8e49f4188d1b26c783ffcd20ace768c8e8f7..8a8b53090570cadcd188b6f840b41ffbe81771ed 100644 (file)
@@ -104,7 +104,7 @@ pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
                 _ => (),
             };
             utf16.truncate(num as uint);
-            let utf8 = match String::from_utf16(utf16.as_slice()) {
+            let utf8 = match String::from_utf16(&utf16) {
                 Ok(utf8) => utf8.into_bytes(),
                 Err(..) => return Err(invalid_encoding()),
             };
index c791ee2717b0bf00cb264969443f9419429465ce..eb967c9f4e331f31a9bb5aa88aa7ac5d2f73d179 100644 (file)
 use option::Option::{self, Some, None};
 use result::Result::{Err, Ok};
 use sync::{Mutex, Condvar, Arc};
-use str::Str;
 use string::String;
 use rt::{self, unwind};
 use old_io::{Writer, stdio};
@@ -246,7 +245,7 @@ pub fn scoped<'a, T, F>(self, f: F) -> JoinGuard<'a, T> where
     {
         let my_packet = Packet(Arc::new(UnsafeCell::new(None)));
         let their_packet = Packet(my_packet.0.clone());
-        let (native, thread) = self.spawn_inner(Thunk::new(f), Thunk::with_arg(move |ret| unsafe {
+        let (native, thread) = self.spawn_inner(Thunk::new(f), Thunk::with_arg(move |ret| unsafe {
             *their_packet.0.get() = Some(ret);
         }));
 
@@ -273,7 +272,7 @@ fn spawn_inner<T: Send>(self, f: Thunk<(), T>, finish: Thunk<Result<T>, ()>)
         // because by the time that this function is executing we've already
         // consumed at least a little bit of stack (we don't know the exact byte
         // address at which our stack started).
-        let main = move |:| {
+        let main = move || {
             let something_around_the_top_of_the_stack = 1;
             let addr = &something_around_the_top_of_the_stack as *const int;
             let my_stack_top = addr as uint;
@@ -289,7 +288,7 @@ fn spawn_inner<T: Send>(self, f: Thunk<(), T>, finish: Thunk<Result<T>, ()>)
 
             let mut output = None;
             let f: Thunk<(), T> = if stdout.is_some() || stderr.is_some() {
-                Thunk::new(move |:| {
+                Thunk::new(move || {
                     let _ = stdout.map(stdio::set_stdout);
                     let _ = stderr.map(stdio::set_stderr);
                     f.invoke(())
@@ -452,7 +451,7 @@ pub fn unpark(&self) {
     /// Get the thread's name.
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn name(&self) -> Option<&str> {
-        self.inner.name.as_ref().map(|s| s.as_slice())
+        self.inner.name.as_ref().map(|s| &**s)
     }
 }
 
@@ -574,7 +573,7 @@ fn test_run_basic() {
     fn test_join_success() {
         match Thread::scoped(move|| -> String {
             "Success!".to_string()
-        }).join().as_ref().map(|s| s.as_slice()) {
+        }).join().as_ref().map(|s| &**s) {
             result::Result::Ok("Success!") => (),
             _ => panic!()
         }
index 2e53d0ceecbdfc0b00b1602d34d9b06ca43afd37..0831242f954cf0e95b12ecae70766a3dc991554c 100644 (file)
@@ -24,7 +24,7 @@ impl<R> Thunk<(),R> {
     pub fn new<F>(func: F) -> Thunk<(),R>
         where F : FnOnce() -> R, F : Send
     {
-        Thunk::with_arg(move|()| func())
+        Thunk::with_arg(move|()| func())
     }
 }
 
index a85b87f47d6ee0d1a9338f262a8344bed2624ff9..1a537c7a5b8f89fdd7f5b3623c3750c6c714eed4 100644 (file)
@@ -179,13 +179,13 @@ pub fn id(self) -> NodeId {
     }
 
     pub fn kind(self) -> visit::FnKind<'a> {
-        let item = |p: ItemFnParts<'a>| -> visit::FnKind<'a> {
+        let item = |p: ItemFnParts<'a>| -> visit::FnKind<'a> {
             visit::FkItemFn(p.ident, p.generics, p.unsafety, p.abi)
         };
-        let closure = |_: ClosureParts| {
+        let closure = |_: ClosureParts| {
             visit::FkFnBlock
         };
-        let method = |m: &'a ast::Method| {
+        let method = |m: &'a ast::Method| {
             visit::FkMethod(m.pe_ident(), m.pe_generics(), m)
         };
         self.handle(item, method, closure)
index 301a18892d8e3684d6b6688878550771be4a3f0c..15ea68a19ce855580f47a0bc30326d2831d79e73 100644 (file)
@@ -338,7 +338,7 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me
             !cfg_matches(diagnostic, cfgs, &*mis[0])
         }
         ast::MetaList(ref pred, _) => {
-            diagnostic.span_err(cfg.span, format!("invalid predicate `{}`", pred).as_slice());
+            diagnostic.span_err(cfg.span, &format!("invalid predicate `{}`", pred));
             false
         },
         ast::MetaWord(_) | ast::MetaNameValue(..) => contains(cfgs, cfg),
index 00857d10f439e763e4cdb3af4cbf160d09f0fc39..3231342cb50c8f37524ca7d44ee66fb163d56344 100644 (file)
@@ -437,18 +437,35 @@ pub fn span_to_lines(&self, sp: Span) -> FileLines {
         FileLines {file: lo.file, lines: lines}
     }
 
-    pub fn span_to_snippet(&self, sp: Span) -> Option<String> {
+    pub fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError> {
+        if sp.lo > sp.hi {
+            return Err(SpanSnippetError::IllFormedSpan(sp));
+        }
+
         let begin = self.lookup_byte_offset(sp.lo);
         let end = self.lookup_byte_offset(sp.hi);
 
-        // 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 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
+            return Err(SpanSnippetError::DistinctSources(DistinctSources {
+                begin: (begin.fm.name.clone(),
+                        begin.fm.start_pos),
+                end: (end.fm.name.clone(),
+                      end.fm.start_pos)
+            }));
         } else {
-            Some((&begin.fm.src[begin.pos.to_usize()..end.pos.to_usize()]).to_string())
+            let start = begin.pos.to_usize();
+            let limit = end.pos.to_usize();
+            if start > limit || limit > begin.fm.src.len() {
+                return Err(SpanSnippetError::MalformedForCodemap(
+                    MalformedCodemapPositions {
+                        name: begin.fm.name.clone(),
+                        source_len: begin.fm.src.len(),
+                        begin_pos: begin.pos,
+                        end_pos: end.pos,
+                    }));
+            }
+
+            return Ok((&begin.fm.src[start..limit]).to_string())
         }
     }
 
@@ -622,6 +639,27 @@ pub fn span_is_internal(&self, span: Span) -> bool {
     }
 }
 
+#[derive(Clone, PartialEq, Eq, Debug)]
+pub enum SpanSnippetError {
+    IllFormedSpan(Span),
+    DistinctSources(DistinctSources),
+    MalformedForCodemap(MalformedCodemapPositions),
+}
+
+#[derive(Clone, PartialEq, Eq, Debug)]
+pub struct DistinctSources {
+    begin: (String, BytePos),
+    end: (String, BytePos)
+}
+
+#[derive(Clone, PartialEq, Eq, Debug)]
+pub struct MalformedCodemapPositions {
+    name: String,
+    source_len: usize,
+    begin_pos: BytePos,
+    end_pos: BytePos
+}
+
 #[cfg(test)]
 mod test {
     use super::*;
@@ -773,7 +811,7 @@ fn t8() {
         let span = Span {lo: BytePos(12), hi: BytePos(23), expn_id: NO_EXPANSION};
         let snippet = cm.span_to_snippet(span);
 
-        assert_eq!(snippet, Some("second line".to_string()));
+        assert_eq!(snippet, Ok("second line".to_string()));
     }
 
     #[test]
index 3eaac0fe333e8e3026f69abd6ca6b0f7d8f52653..eb845e463a0f1b8e1da21b4e5ebed7f6559139d7 100644 (file)
@@ -27,7 +27,7 @@ struct Context<F> where F: FnMut(&[ast::Attribute]) -> bool {
 // any items that do not belong in the current configuration
 pub fn strip_unconfigured_items(diagnostic: &SpanHandler, krate: ast::Crate) -> ast::Crate {
     let config = krate.config.clone();
-    strip_items(krate, |attrs| in_cfg(diagnostic, config.as_slice(), attrs))
+    strip_items(krate, |attrs| in_cfg(diagnostic, &config, attrs))
 }
 
 impl<F> fold::Folder for Context<F> where F: FnMut(&[ast::Attribute]) -> bool {
@@ -132,7 +132,7 @@ fn fold_item_underscore<F>(cx: &mut Context<F>, item: ast::Item_) -> ast::Item_
         }
         ast::ItemEnum(def, generics) => {
             let variants = def.variants.into_iter().filter_map(|v| {
-                if !(cx.in_cfg)(v.node.attrs.as_slice()) {
+                if !(cx.in_cfg)(&v.node.attrs) {
                     None
                 } else {
                     Some(v.map(|Spanned {node: ast::Variant_ {id, name, attrs, kind,
@@ -172,7 +172,7 @@ fn fold_struct<F>(cx: &mut Context<F>, def: P<ast::StructDef>) -> P<ast::StructD
     def.map(|ast::StructDef { fields, ctor_id }| {
         ast::StructDef {
             fields: fields.into_iter().filter(|m| {
-                (cx.in_cfg)(m.node.attrs.as_slice())
+                (cx.in_cfg)(&m.node.attrs)
             }).collect(),
             ctor_id: ctor_id,
         }
@@ -223,7 +223,7 @@ fn fold_expr<F>(cx: &mut Context<F>, expr: P<ast::Expr>) -> P<ast::Expr> where
             node: match node {
                 ast::ExprMatch(m, arms, source) => {
                     ast::ExprMatch(m, arms.into_iter()
-                                        .filter(|a| (cx.in_cfg)(a.attrs.as_slice()))
+                                        .filter(|a| (cx.in_cfg)(&a.attrs))
                                         .collect(), source)
                 }
                 _ => node
@@ -236,22 +236,22 @@ fn fold_expr<F>(cx: &mut Context<F>, expr: P<ast::Expr>) -> P<ast::Expr> where
 fn item_in_cfg<F>(cx: &mut Context<F>, item: &ast::Item) -> bool where
     F: FnMut(&[ast::Attribute]) -> bool
 {
-    return (cx.in_cfg)(item.attrs.as_slice());
+    return (cx.in_cfg)(&item.attrs);
 }
 
 fn foreign_item_in_cfg<F>(cx: &mut Context<F>, item: &ast::ForeignItem) -> bool where
     F: FnMut(&[ast::Attribute]) -> bool
 {
-    return (cx.in_cfg)(item.attrs.as_slice());
+    return (cx.in_cfg)(&item.attrs);
 }
 
 fn trait_method_in_cfg<F>(cx: &mut Context<F>, meth: &ast::TraitItem) -> bool where
     F: FnMut(&[ast::Attribute]) -> bool
 {
     match *meth {
-        ast::RequiredMethod(ref meth) => (cx.in_cfg)(meth.attrs.as_slice()),
-        ast::ProvidedMethod(ref meth) => (cx.in_cfg)(meth.attrs.as_slice()),
-        ast::TypeTraitItem(ref typ) => (cx.in_cfg)(typ.attrs.as_slice()),
+        ast::RequiredMethod(ref meth) => (cx.in_cfg)(&meth.attrs),
+        ast::ProvidedMethod(ref meth) => (cx.in_cfg)(&meth.attrs),
+        ast::TypeTraitItem(ref typ) => (cx.in_cfg)(&typ.attrs),
     }
 }
 
@@ -259,8 +259,8 @@ fn impl_item_in_cfg<F>(cx: &mut Context<F>, impl_item: &ast::ImplItem) -> bool w
     F: FnMut(&[ast::Attribute]) -> bool
 {
     match *impl_item {
-        ast::MethodImplItem(ref meth) => (cx.in_cfg)(meth.attrs.as_slice()),
-        ast::TypeImplItem(ref typ) => (cx.in_cfg)(typ.attrs.as_slice()),
+        ast::MethodImplItem(ref meth) => (cx.in_cfg)(&meth.attrs),
+        ast::TypeImplItem(ref typ) => (cx.in_cfg)(&typ.attrs),
     }
 }
 
index 9321d3ca3df1141196a45917db933c208d3fb56d..54689a1f77ad2dddcb9e6fa96bdff67b0de08e53 100644 (file)
@@ -18,7 +18,7 @@ macro_rules! register_diagnostic {
 macro_rules! span_fatal {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.span_fatal_with_code($span, format!($($message)*).as_slice(), stringify!($code))
+        $session.span_fatal_with_code($span, &format!($($message)*), stringify!($code))
     })
 }
 
@@ -26,7 +26,7 @@ macro_rules! span_fatal {
 macro_rules! span_err {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.span_err_with_code($span, format!($($message)*).as_slice(), stringify!($code))
+        $session.span_err_with_code($span, &format!($($message)*), stringify!($code))
     })
 }
 
@@ -34,21 +34,21 @@ macro_rules! span_err {
 macro_rules! span_warn {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.span_warn_with_code($span, format!($($message)*).as_slice(), stringify!($code))
+        $session.span_warn_with_code($span, &format!($($message)*), stringify!($code))
     })
 }
 
 #[macro_export]
 macro_rules! span_note {
     ($session:expr, $span:expr, $($message:tt)*) => ({
-        ($session).span_note($span, format!($($message)*).as_slice())
+        ($session).span_note($span, &format!($($message)*))
     })
 }
 
 #[macro_export]
 macro_rules! span_help {
     ($session:expr, $span:expr, $($message:tt)*) => ({
-        ($session).span_help($span, format!($($message)*).as_slice())
+        ($session).span_help($span, &format!($($message)*))
     })
 }
 
index 72da60ffe0941f827a97fb6723de25ddf27fc1b3..7216602071b5c694a65cc88ee2759d0372bc7721 100644 (file)
@@ -34,6 +34,6 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
         return DummyResult::expr(sp);
     }
 
-    let matches_cfg = attr::cfg_matches(&cx.parse_sess.span_diagnostic, cx.cfg.as_slice(), &*cfg);
+    let matches_cfg = attr::cfg_matches(&cx.parse_sess.span_diagnostic, &cx.cfg, &*cfg);
     MacExpr::new(cx.expr_bool(sp, matches_cfg))
 }
index a85f12edb228648c672be37ff972662a45d890b9..72eaa3e47bec6cda739043cacdd1c9b6e2a8c709 100644 (file)
@@ -25,7 +25,7 @@ pub fn expand(cx: &mut ExtCtxt, sp: Span, mi: &ast::MetaItem, it: P<ast::Item>)
     };
 
     let mut out = (*it).clone();
-    if attr::cfg_matches(&cx.parse_sess.span_diagnostic, cx.cfg.as_slice(), &**cfg) {
+    if attr::cfg_matches(&cx.parse_sess.span_diagnostic, &cx.cfg, &**cfg) {
         out.attrs.push(cx.attribute(attr.span, attr.clone()));
     }
 
index 9c85d3d28a7a0039d5b34ade26d4d773a2f11f67..bce48747b6069243390dcf48c40ac88ad55bff73 100644 (file)
@@ -28,14 +28,14 @@ pub fn expand_deriving_bound<F>(cx: &mut ExtCtxt,
                 "Copy" => "Copy",
                 "Send" | "Sync" => {
                     return cx.span_err(span,
-                                       format!("{} is an unsafe trait and it \
-                                                should be implemented explicitly",
-                                               *tname).as_slice())
+                                       &format!("{} is an unsafe trait and it \
+                                                 should be implemented explicitly",
+                                                *tname))
                 }
                 ref tname => {
                     cx.span_bug(span,
-                                format!("expected built-in trait name but \
-                                         found {}", *tname).as_slice())
+                                &format!("expected built-in trait name but \
+                                          found {}", *tname))
                 }
             }
         },
index e1dcc887778231d1b8f557b59caa4d424faafc9e..6eb18e290238e679df6463d847ed87fc60c36b57 100644 (file)
@@ -63,7 +63,7 @@ fn cs_clone(
         cx.ident_of("Clone"),
         cx.ident_of("clone"),
     ];
-    let subcall = |&: field: &FieldInfo| {
+    let subcall = |field: &FieldInfo| {
         let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
 
         cx.expr_call_global(field.span, fn_path.clone(), args)
index 27f3c46c48fceaf3edb4f6ccac496773ac2fc00f..df5e1863d551dd84236b2c96d975e69d8f4a0e1b 100644 (file)
@@ -57,7 +57,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur
         cx.ident_of("Default"),
         cx.ident_of("default")
     );
-    let default_call = |&: span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
+    let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
 
     return match *substr.fields {
         StaticStruct(_, ref summary) => {
index 02982039be0a3bf5a9ed8921bb1407d32d91c205..7d72a7ec358c8a03b99465960591c7ba6ba9a6ea 100644 (file)
@@ -957,7 +957,7 @@ fn build_enum_match_tuple(
         // where each tuple has length = self_args.len()
         let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate()
             .map(|(index, variant)| {
-                let mk_self_pat = |&: cx: &mut ExtCtxt, self_arg_name: &str| {
+                let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| {
                     let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident,
                                                                          &**variant,
                                                                          self_arg_name,
index 85682d41b5ff65cffcdb971ca178d9d9d10c244e..bbca5c599b1c1199d12695cf1bcea9a61954ebb7 100644 (file)
@@ -247,7 +247,7 @@ pub fn to_generics(&self,
                     mk_ty_param(cx,
                                 span,
                                 *name,
-                                bounds.as_slice(),
+                                bounds,
                                 self_ty,
                                 self_generics)
                 }
index efd9322661862b480226e6c9abb66ff95e1b2a5a..f8a7af3aa91701a1d202f157a196b489933a43e5 100644 (file)
@@ -66,7 +66,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
         [ref state_expr] => state_expr,
         _ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`")
     };
-    let call_hash = |&: span, thing_expr| {
+    let call_hash = |span, thing_expr| {
         let hash_path = {
             let strs = vec![
                 cx.ident_of("std"),
index 0b57e7e7c8e9e63a38a1855fe3fa8caaa040ab5c..c708a09b53c9bbf825a03126a55710bd499a8928 100644 (file)
@@ -70,7 +70,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
         cx.ident_of("Rand"),
         cx.ident_of("rand")
     );
-    let rand_call = |&: cx: &mut ExtCtxt, span| {
+    let rand_call = |cx: &mut ExtCtxt, span| {
         cx.expr_call_global(span,
                             rand_ident.clone(),
                             vec!(rng.clone()))
index 77440914342fb2ef4a60710bf3c16376db58934b..eaee67f9a61746a4c06a4c8ee3eff2faf4094b5d 100644 (file)
@@ -664,7 +664,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
                         id: ast::DUMMY_NODE_ID,
                         span: it.span,
                         imported_from: None,
-                        export: attr::contains_name(it.attrs.as_slice(), "macro_export"),
+                        export: attr::contains_name(&it.attrs, "macro_export"),
                         use_locally: true,
                         body: tts,
                     };
@@ -1089,7 +1089,7 @@ fn expand_annotatable(a: Annotatable,
                     // but that double-mut-borrows fld
                     let mut items: SmallVector<P<ast::Item>> = SmallVector::zero();
                     dec.expand(fld.cx, attr.span, &*attr.node.value, &**it,
-                               box |&mut: item| items.push(item));
+                               box |item| items.push(item));
                     decorator_items.extend(items.into_iter()
                         .flat_map(|item| expand_item(item, fld).into_iter()));
 
@@ -1850,7 +1850,7 @@ fn run_renaming_test(t: &RenamingTest, test_idx: usize) {
             assert!((shouldmatch.len() == 0) ||
                     (varrefs.len() > *shouldmatch.iter().max().unwrap()));
             for (idx,varref) in varrefs.iter().enumerate() {
-                let print_hygiene_debug_info = |&:| {
+                let print_hygiene_debug_info = || {
                     // 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,
index 16aaccb0207a2d4beed76bc1e2b6a0c07db2d23f..56da24de8bbe2891554c673676662592550f54bd 100644 (file)
@@ -307,7 +307,7 @@ fn rtpath(ecx: &ExtCtxt, s: &str) -> Vec<ast::Ident> {
 
     fn trans_count(&self, c: parse::Count) -> P<ast::Expr> {
         let sp = self.fmtsp;
-        let count = |c, arg| {
+        let count = |c, arg| {
             let mut path = Context::rtpath(self.ecx, "Count");
             path.push(self.ecx.ident_of(c));
             match arg {
@@ -353,7 +353,7 @@ fn trans_piece(&mut self, piece: &parse::Piece) -> Option<P<ast::Expr>> {
             parse::NextArgument(ref arg) => {
                 // Translate the position
                 let pos = {
-                    let pos = |c, arg| {
+                    let pos = |c, arg| {
                         let mut path = Context::rtpath(self.ecx, "Position");
                         path.push(self.ecx.ident_of(c));
                         match arg {
@@ -404,7 +404,7 @@ fn trans_piece(&mut self, piece: &parse::Piece) -> Option<P<ast::Expr>> {
 
                 // Translate the format
                 let fill = self.ecx.expr_lit(sp, ast::LitChar(fill));
-                let align = |:name| {
+                let align = |name| {
                     let mut p = Context::rtpath(self.ecx, "Alignment");
                     p.push(self.ecx.ident_of(name));
                     self.ecx.path_global(sp, p)
index 9092169e1820067e1f7a4833e6e3b29792639626..7376b2352388a81c5d439123512b4c6b38abd3f2 100644 (file)
@@ -791,11 +791,11 @@ fn expand_parse_call(cx: &ExtCtxt,
                      tts: &[ast::TokenTree]) -> P<ast::Expr> {
     let (cx_expr, tts_expr) = expand_tts(cx, sp, tts);
 
-    let cfg_call = |&:| cx.expr_method_call(
+    let cfg_call = || cx.expr_method_call(
         sp, cx.expr_ident(sp, id_ext("ext_cx")),
         id_ext("cfg"), Vec::new());
 
-    let parse_sess_call = |&:| cx.expr_method_call(
+    let parse_sess_call = || cx.expr_method_call(
         sp, cx.expr_ident(sp, id_ext("ext_cx")),
         id_ext("parse_sess"), Vec::new());
 
index ac9f375e0a4a90535f1aa9ac299423d9c521102d..de61bdefa5de3303f341b0ced5203380465d0ceb 100644 (file)
@@ -319,11 +319,11 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
                     Some(&&TtToken(_, ref tok)) => tok.clone(),
                     Some(&&TtSequence(sp, _)) => {
                         cx.span_err(sp,
-                                    format!("`${0}:{1}` is followed by a \
-                                             sequence repetition, which is not \
-                                             allowed for `{1}` fragments",
-                                            name.as_str(), frag_spec.as_str())
-                                        .as_slice());
+                                    &format!("`${0}:{1}` is followed by a \
+                                              sequence repetition, which is not \
+                                              allowed for `{1}` fragments",
+                                             name.as_str(), frag_spec.as_str())
+                                        );
                         Eof
                     },
                     // die next iteration
@@ -338,14 +338,14 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
                     (&Eof, _) => return Some((sp, tok.clone())),
                     (_, Ok(true)) => continue,
                     (next, Ok(false)) => {
-                        cx.span_err(sp, format!("`${0}:{1}` is followed by `{2}`, which \
-                                                 is not allowed for `{1}` fragments",
+                        cx.span_err(sp, &format!("`${0}:{1}` is followed by `{2}`, which \
+                                                  is not allowed for `{1}` fragments",
                                                  name.as_str(), frag_spec.as_str(),
-                                                 token_to_string(next)).as_slice());
+                                                 token_to_string(next)));
                         continue
                     },
                     (_, Err(msg)) => {
-                        cx.span_err(sp, msg.as_slice());
+                        cx.span_err(sp, &msg);
                         continue
                     }
                 }
index d7a51e1149f30b0931636d3e551a0d9e4410d976..36701e7e25c3f0e31fa50b74fe69f75644dcac2c 100644 (file)
@@ -338,7 +338,7 @@ fn visit_item(&mut self, i: &ast::Item) {
                     _ => {}
                 }
 
-                if attr::contains_name(i.attrs.as_slice(),
+                if attr::contains_name(&i.attrs,
                                        "unsafe_destructor") {
                     self.gate_feature("unsafe_destructor",
                                       i.span,
@@ -376,7 +376,7 @@ fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
                                and not portable across platforms")
         }
 
-        let links_to_llvm = match attr::first_attr_value_str_by_name(i.attrs.as_slice(),
+        let links_to_llvm = match attr::first_attr_value_str_by_name(&i.attrs,
                                                                      "link_name") {
             Some(val) => val.get().starts_with("llvm."),
             _ => false
index 07b6af651f610eec1e10c9744fcd64d725657dfd..b0ddb655882a86a9e6cb2f586db56439df971044 100644 (file)
@@ -592,7 +592,7 @@ pub fn noop_fold_mac<T: Folder>(Spanned {node, span}: Mac, fld: &mut T) -> Mac {
     Spanned {
         node: match node {
             MacInvocTT(p, tts, ctxt) => {
-                MacInvocTT(fld.fold_path(p), fld.fold_tts(tts.as_slice()), ctxt)
+                MacInvocTT(fld.fold_path(p), fld.fold_tts(&tts), ctxt)
             }
         },
         span: fld.new_span(span)
@@ -629,7 +629,7 @@ pub fn noop_fold_tt<T: Folder>(tt: &TokenTree, fld: &mut T) -> TokenTree {
                             Delimited {
                                 delim: delimed.delim,
                                 open_span: delimed.open_span,
-                                tts: fld.fold_tts(delimed.tts.as_slice()),
+                                tts: fld.fold_tts(&delimed.tts),
                                 close_span: delimed.close_span,
                             }
                         ))
@@ -637,7 +637,7 @@ pub fn noop_fold_tt<T: Folder>(tt: &TokenTree, fld: &mut T) -> TokenTree {
         TtSequence(span, ref seq) =>
             TtSequence(span,
                        Rc::new(SequenceRepetition {
-                           tts: fld.fold_tts(seq.tts.as_slice()),
+                           tts: fld.fold_tts(&seq.tts),
                            separator: seq.separator.clone().map(|tok| fld.fold_token(tok)),
                            ..**seq
                        })),
@@ -1441,7 +1441,7 @@ mod test {
     // this version doesn't care about getting comments or docstrings in.
     fn fake_print_crate(s: &mut pprust::State,
                         krate: &ast::Crate) -> old_io::IoResult<()> {
-        s.print_mod(&krate.module, krate.attrs.as_slice())
+        s.print_mod(&krate.module, &krate.attrs)
     }
 
     // change every identifier to "zz"
@@ -1463,7 +1463,7 @@ macro_rules! assert_pred {
                 let pred_val = $pred;
                 let a_val = $a;
                 let b_val = $b;
-                if !(pred_val(a_val.as_slice(),b_val.as_slice())) {
+                if !(pred_val(&a_val, &b_val)) {
                     panic!("expected args satisfying {}, got {} and {}",
                           $predname, a_val, b_val);
                 }
index 872354024e93c319bec2e6da8b7444f9e9a6d99e..0f9a56baa170bc43b4d646f92241d35720cd067c 100644 (file)
@@ -72,7 +72,7 @@ fn default() -> OwnedSlice<T> {
 
 impl<T: Clone> Clone for OwnedSlice<T> {
     fn clone(&self) -> OwnedSlice<T> {
-        OwnedSlice::from_vec(self.as_slice().to_vec())
+        OwnedSlice::from_vec(self.to_vec())
     }
 }
 
@@ -84,7 +84,7 @@ fn from_iter<I: Iterator<Item=T>>(iter: I) -> OwnedSlice<T> {
 
 impl<T: Encodable> Encodable for OwnedSlice<T> {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
-       self.as_slice().encode(s)
+        Encodable::encode(&**self, s)
     }
 }
 
index e6da47304cee39cebf6ce3b96c34b4007d2ed9b9..ecc39925a40c55b495c459b032279c178a05d3a6 100644 (file)
@@ -360,7 +360,7 @@ pub fn nextch_is(&self, c: char) -> bool {
 
     pub fn nextnextch(&self) -> Option<char> {
         let offset = self.byte_offset(self.pos).to_usize();
-        let s = self.filemap.src.as_slice();
+        let s = &*self.filemap.src;
         if offset >= s.len() { return None }
         let str::CharRange { next, .. } = s.char_range_at(offset);
         if next < s.len() {
index eecd7d87185434c88501ed2fdcd4365eec2dd30f..9e9ec08da038e68855df48ebc1332b010184513d 100644 (file)
@@ -244,7 +244,7 @@ pub fn new_parser_from_tts<'a>(sess: &'a ParseSess,
 /// add the path to the session's codemap and return the new filemap.
 pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
     -> Rc<FileMap> {
-    let err = |&: msg: &str| {
+    let err = |msg: &str| {
         match spanopt {
             Some(sp) => sess.span_diagnostic.span_fatal(sp, msg),
             None => sess.span_diagnostic.handler().fatal(msg),
@@ -406,7 +406,7 @@ fn esc(len: usize, lit: &str) -> Option<(char, isize)> {
         .map(|x| (x, len as isize))
     }
 
-    let unicode_escape = |&: | -> Option<(char, isize)>
+    let unicode_escape = || -> Option<(char, isize)>
         if lit.as_bytes()[2] == b'{' {
             let idx = lit.find('}').expect(msg2);
             let subslice = &lit[3..idx];
@@ -433,7 +433,7 @@ pub fn str_lit(lit: &str) -> String {
     let mut res = String::with_capacity(lit.len());
 
     // FIXME #8372: This could be a for-loop if it didn't borrow the iterator
-    let error = |&: i| format!("lexer should have rejected {} at {}", lit, i);
+    let error = |i| format!("lexer should have rejected {} at {}", lit, i);
 
     /// Eat everything up to a non-whitespace
     fn eat<'a>(it: &mut iter::Peekable<str::CharIndices<'a>>) {
@@ -454,7 +454,7 @@ fn eat<'a>(it: &mut iter::Peekable<str::CharIndices<'a>>) {
                 match c {
                     '\\' => {
                         let ch = chars.peek().unwrap_or_else(|| {
-                            panic!("{}", error(i).as_slice())
+                            panic!("{}", error(i))
                         }).1;
 
                         if ch == '\n' {
@@ -462,7 +462,7 @@ fn eat<'a>(it: &mut iter::Peekable<str::CharIndices<'a>>) {
                         } else if ch == '\r' {
                             chars.next();
                             let ch = chars.peek().unwrap_or_else(|| {
-                                panic!("{}", error(i).as_slice())
+                                panic!("{}", error(i))
                             }).1;
 
                             if ch != '\n' {
@@ -480,7 +480,7 @@ fn eat<'a>(it: &mut iter::Peekable<str::CharIndices<'a>>) {
                     },
                     '\r' => {
                         let ch = chars.peek().unwrap_or_else(|| {
-                            panic!("{}", error(i).as_slice())
+                            panic!("{}", error(i))
                         }).1;
 
                         if ch != '\n' {
@@ -568,7 +568,7 @@ pub fn float_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> a
 
 /// Parse a string representing a byte literal into its final form. Similar to `char_lit`
 pub fn byte_lit(lit: &str) -> (u8, usize) {
-    let err = |&: i| format!("lexer accepted invalid byte literal {} step {}", lit, i);
+    let err = |i| format!("lexer accepted invalid byte literal {} step {}", lit, i);
 
     if lit.len() == 1 {
         (lit.as_bytes()[0], 1)
@@ -602,7 +602,7 @@ pub fn binary_lit(lit: &str) -> Rc<Vec<u8>> {
     let mut res = Vec::with_capacity(lit.len());
 
     // FIXME #8372: This could be a for-loop if it didn't borrow the iterator
-    let error = |&: i| format!("lexer should have rejected {} at {}", lit, i);
+    let error = |i| format!("lexer should have rejected {} at {}", lit, i);
 
     /// Eat everything up to a non-whitespace
     fn eat<'a, I: Iterator<Item=(usize, u8)>>(it: &mut iter::Peekable<I>) {
@@ -622,11 +622,11 @@ fn eat<'a, I: Iterator<Item=(usize, u8)>>(it: &mut iter::Peekable<I>) {
         match chars.next() {
             Some((i, b'\\')) => {
                 let em = error(i);
-                match chars.peek().expect(em.as_slice()).1 {
+                match chars.peek().expect(&em).1 {
                     b'\n' => eat(&mut chars),
                     b'\r' => {
                         chars.next();
-                        if chars.peek().expect(em.as_slice()).1 != b'\n' {
+                        if chars.peek().expect(&em).1 != b'\n' {
                             panic!("lexer accepted bare CR");
                         }
                         eat(&mut chars);
@@ -644,7 +644,7 @@ fn eat<'a, I: Iterator<Item=(usize, u8)>>(it: &mut iter::Peekable<I>) {
             },
             Some((i, b'\r')) => {
                 let em = error(i);
-                if chars.peek().expect(em.as_slice()).1 != b'\n' {
+                if chars.peek().expect(&em).1 != b'\n' {
                     panic!("lexer accepted bare CR");
                 }
                 chars.next();
@@ -1200,7 +1200,7 @@ fn wb() -> c_int { O_WRONLY as c_int }
         let name = "<source>".to_string();
         let source = "/// doc comment\r\nfn foo() {}".to_string();
         let item = parse_item_from_source_str(name.clone(), source, Vec::new(), &sess).unwrap();
-        let doc = first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap();
+        let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap();
         assert_eq!(doc.get(), "/// doc comment");
 
         let source = "/// doc comment\r\n/// line 2\r\nfn foo() {}".to_string();
@@ -1212,7 +1212,7 @@ fn wb() -> c_int { O_WRONLY as c_int }
 
         let source = "/** doc comment\r\n *  with CRLF */\r\nfn foo() {}".to_string();
         let item = parse_item_from_source_str(name, source, Vec::new(), &sess).unwrap();
-        let doc = first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap();
+        let doc = first_attr_value_str_by_name(&item.attrs, "doc").unwrap();
         assert_eq!(doc.get(), "/** doc comment\n *  with CRLF */");
     }
 
@@ -1233,8 +1233,8 @@ fn ttdelim_span() {
         let span = tts.iter().rev().next().unwrap().get_span();
 
         match sess.span_diagnostic.cm.span_to_snippet(span) {
-            Some(s) => assert_eq!(&s[], "{ body }"),
-            None => panic!("could not get snippet"),
+            Ok(s) => assert_eq!(&s[], "{ body }"),
+            Err(_) => panic!("could not get snippet"),
         }
     }
 }
index 2cb265033c399842c6783b9af1e97c7f29f5dc7b..cae23c5a2ccc59033d1723d340150ebe95102570 100644 (file)
@@ -1139,7 +1139,7 @@ pub fn parse_proc_type(&mut self, lifetime_defs: Vec<ast::LifetimeDef>) -> Ty_ {
 
     /// Parses an obsolete closure kind (`&:`, `&mut:`, or `:`).
     pub fn parse_obsolete_closure_kind(&mut self) {
-        // let lo = self.span.lo;
+         let lo = self.span.lo;
         if
             self.check(&token::BinOp(token::And)) &&
             self.look_ahead(1, |t| t.is_keyword(keywords::Mut)) &&
@@ -1163,10 +1163,8 @@ pub fn parse_obsolete_closure_kind(&mut self) {
             return;
         }
 
-        // SNAP 474b324
-        // Enable these obsolete errors after snapshot:
-        // let span = mk_sp(lo, self.span.hi);
-        // self.obsolete(span, ObsoleteSyntax::ClosureKind);
+         let span = mk_sp(lo, self.span.hi);
+         self.obsolete(span, ObsoleteSyntax::ClosureKind);
     }
 
     pub fn parse_ty_bare_fn_or_ty_closure(&mut self, lifetime_defs: Vec<LifetimeDef>) -> Ty_ {
@@ -1683,7 +1681,7 @@ pub fn lit_from_token(&self, tok: &token::Token) -> Lit_ {
 
                     token::Str_(s) => {
                         (true,
-                         LitStr(token::intern_and_get_ident(parse::str_lit(s.as_str()).as_slice()),
+                         LitStr(token::intern_and_get_ident(&parse::str_lit(s.as_str())),
                                 ast::CookedStr))
                     }
                     token::StrRaw(s, n) => {
@@ -2529,16 +2527,7 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
                 let bracket_pos = self.span.lo;
                 self.bump();
 
-                let mut found_dotdot = false;
-                if self.token == token::DotDot &&
-                   self.look_ahead(1, |t| t == &token::CloseDelim(token::Bracket)) {
-                    // Using expr[..], which is a mistake, should be expr[]
-                    self.bump();
-                    self.bump();
-                    found_dotdot = true;
-                }
-
-                if found_dotdot || self.eat(&token::CloseDelim(token::Bracket)) {
+                if self.eat(&token::CloseDelim(token::Bracket)) {
                     // No expression, expand to a RangeFull
                     // FIXME(#20516) It would be better to use a lang item or
                     // something for RangeFull.
@@ -2562,7 +2551,11 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
                     let range = ExprStruct(path, vec![], None);
                     let ix = self.mk_expr(bracket_pos, hi, range);
                     let index = self.mk_index(e, ix);
-                    e = self.mk_expr(lo, hi, index)
+                    e = self.mk_expr(lo, hi, index);
+                    // Enable after snapshot.
+                    // self.span_warn(e.span, "deprecated slicing syntax: `[]`");
+                    // self.span_note(e.span,
+                    //               "use `&expr[..]` to construct a slice of the whole of expr");
                 } else {
                     let ix = self.parse_expr();
                     hi = self.span.hi;
@@ -2571,11 +2564,6 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
                     e = self.mk_expr(lo, hi, index)
                 }
 
-                if found_dotdot {
-                    self.span_err(e.span, "incorrect slicing expression: `[..]`");
-                    self.span_note(e.span,
-                                   "use `&expr[]` to construct a slice of the whole of expr");
-                }
               }
               _ => return e
             }
@@ -2598,7 +2586,7 @@ fn parse_unquoted(&mut self) -> TokenTree {
                         |p| p.parse_token_tree()
                     );
                     let (sep, repeat) = self.parse_sep_and_kleene_op();
-                    let name_num = macro_parser::count_names(seq.as_slice());
+                    let name_num = macro_parser::count_names(&seq);
                     return TtSequence(mk_sp(sp.lo, seq_span.hi),
                                       Rc::new(SequenceRepetition {
                                           tts: seq,
@@ -2936,9 +2924,14 @@ pub fn parse_assign_expr(&mut self) -> P<Expr> {
             // with the postfix-form 'expr..'
             let lo = self.span.lo;
             self.bump();
-            let rhs = self.parse_binops();
-            let hi = rhs.span.hi;
-            let ex = self.mk_range(None, Some(rhs));
+            let opt_end = if self.is_at_start_of_range_notation_rhs() {
+                let end = self.parse_binops();
+                Some(end)
+            } else {
+                None
+            };
+            let hi = self.span.hi;
+            let ex = self.mk_range(None, opt_end);
             self.mk_expr(lo, hi, ex)
           }
           _ => {
index ee8e207fa6c059b909914232d1d501cda015a9f0..542cc41c950f6b3667a9193364e45a187ef5426f 100644 (file)
@@ -1485,7 +1485,7 @@ pub fn print_mac(&mut self, m: &ast::Mac, delim: token::DelimToken)
                     token::Bracket => try!(word(&mut self.s, "[")),
                     token::Brace => try!(self.bopen()),
                 }
-                try!(self.print_tts(tts.as_slice()));
+                try!(self.print_tts(tts));
                 match delim {
                     token::Paren => self.pclose(),
                     token::Bracket => word(&mut self.s, "]"),
@@ -1811,9 +1811,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 if let &Some(ref e) = start {
                     try!(self.print_expr(&**e));
                 }
-                if start.is_some() || end.is_some() {
-                    try!(word(&mut self.s, ".."));
-                }
+                try!(word(&mut self.s, ".."));
                 if let &Some(ref e) = end {
                     try!(self.print_expr(&**e));
                 }
@@ -2502,7 +2500,7 @@ pub fn print_where_clause(&mut self, generics: &ast::Generics)
                                                                               ref bounds,
                                                                               ..}) => {
                     try!(self.print_type(&**bounded_ty));
-                    try!(self.print_bounds(":", bounds.as_slice()));
+                    try!(self.print_bounds(":", bounds));
                 }
                 &ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
                                                                                 ref bounds,
@@ -2760,7 +2758,7 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
                              &format!("-{}", istr)[])
                     }
                     ast::UnsignedIntLit(ut) => {
-                        word(&mut self.s, ast_util::uint_ty_to_string(ut, Some(i)).as_slice())
+                        word(&mut self.s, &ast_util::uint_ty_to_string(ut, Some(i)))
                     }
                     ast::UnsuffixedIntLit(ast::Plus) => {
                         word(&mut self.s, &format!("{}", i)[])
@@ -2937,7 +2935,7 @@ pub fn print_fn_header_info(&mut self,
                                 opt_unsafety: Option<ast::Unsafety>,
                                 abi: abi::Abi,
                                 vis: ast::Visibility) -> IoResult<()> {
-        try!(word(&mut self.s, visibility_qualified(vis, "").as_slice()));
+        try!(word(&mut self.s, &visibility_qualified(vis, "")));
         try!(self.print_opt_unsafety(opt_unsafety));
 
         if abi != abi::Rust {
index 61ce664d2c79036a45dfd433a7c93ab411dc8ae8..d9d5688951288d6ba15de734d44c413387d4e6f2 100644 (file)
@@ -609,11 +609,11 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
     let test_id = ecx.ident_of("test");
 
     // creates self::test::$name
-    let test_path = |&: name| {
+    let test_path = |name| {
         ecx.path(span, vec![self_id, test_id, ecx.ident_of(name)])
     };
     // creates $name: $expr
-    let field = |&: name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
+    let field = |name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
 
     debug!("encoding {}", ast_util::path_name_i(&path[]));
 
@@ -627,7 +627,7 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
                                   vec![name_expr]);
 
     let ignore_expr = ecx.expr_bool(span, test.ignore);
-    let should_fail_path = |&: name| {
+    let should_fail_path = |name| {
         ecx.path(span, vec![self_id, test_id, ecx.ident_of("ShouldFail"), ecx.ident_of(name)])
     };
     let fail_expr = match test.should_fail {
index a6c92c037439658217f50e341b0a7f8ed9c9b893..b2009a7e8485480c00f418968c9f54c730a26f73 100644 (file)
@@ -65,7 +65,7 @@ pub fn as_slice<'a>(&'a self) -> &'a [T] {
                 result
             }
             One(ref v) => slice::ref_slice(v),
-            Many(ref vs) => vs.as_slice()
+            Many(ref vs) => vs
         }
     }
 
index fbcfcaadf12b71c29782e0ae4d5944b92043232a..21cb62b0a0c112818f30308c2ec7f3888906950d 100644 (file)
@@ -762,7 +762,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
             visitor.visit_expr(&**subexpression)
         }
         ExprVec(ref subexpressions) => {
-            walk_exprs(visitor, subexpressions.as_slice())
+            walk_exprs(visitor, subexpressions)
         }
         ExprRepeat(ref element, ref count) => {
             visitor.visit_expr(&**element);
@@ -787,7 +787,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
             visitor.visit_expr(&**callee_expression)
         }
         ExprMethodCall(_, ref types, ref arguments) => {
-            walk_exprs(visitor, arguments.as_slice());
+            walk_exprs(visitor, arguments);
             for typ in types {
                 visitor.visit_ty(&**typ)
             }
index 17c1e8cdb8c6d119b9a06a2f28836638993f35e6..0a1439ebee0f1e8c1edcc89cbdb97d43c7dbe775 100644 (file)
@@ -80,10 +80,10 @@ fn fg(&mut self, color: color::Color) -> IoResult<bool> {
                                .strings
                                .get("setaf")
                                .unwrap()
-                               .as_slice(),
+                               ,
                            &[Number(color as int)], &mut Variables::new());
             if s.is_ok() {
-                try!(self.out.write_all(s.unwrap().as_slice()));
+                try!(self.out.write_all(&s.unwrap()));
                 return Ok(true)
             }
         }
@@ -97,10 +97,10 @@ fn bg(&mut self, color: color::Color) -> IoResult<bool> {
                                .strings
                                .get("setab")
                                .unwrap()
-                               .as_slice(),
+                               ,
                            &[Number(color as int)], &mut Variables::new());
             if s.is_ok() {
-                try!(self.out.write_all(s.unwrap().as_slice()));
+                try!(self.out.write_all(&s.unwrap()));
                 return Ok(true)
             }
         }
@@ -115,11 +115,11 @@ fn attr(&mut self, attr: attr::Attr) -> IoResult<bool> {
                 let cap = cap_for_attr(attr);
                 let parm = self.ti.strings.get(cap);
                 if parm.is_some() {
-                    let s = expand(parm.unwrap().as_slice(),
+                    let s = expand(parm.unwrap(),
                                    &[],
                                    &mut Variables::new());
                     if s.is_ok() {
-                        try!(self.out.write_all(s.unwrap().as_slice()));
+                        try!(self.out.write_all(&s.unwrap()));
                         return Ok(true)
                     }
                 }
@@ -151,10 +151,10 @@ fn reset(&mut self) -> IoResult<()> {
             }
         }
         let s = cap.map_or(Err("can't find terminfo capability `sgr0`".to_string()), |op| {
-            expand(op.as_slice(), &[], &mut Variables::new())
+            expand(op, &[], &mut Variables::new())
         });
         if s.is_ok() {
-            return self.out.write_all(s.unwrap().as_slice())
+            return self.out.write_all(&s.unwrap())
         }
         Ok(())
     }
index 4173744ab4b1877b11e53223b384c995a25f9474..016dc84b23b9e22ae910d7970c7dda0e04c703eb 100644 (file)
@@ -257,7 +257,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                         let flags = Flags::new();
                         let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), flags);
                         if res.is_err() { return res }
-                        output.push_all(res.unwrap().as_slice())
+                        output.push_all(&res.unwrap())
                     } else { return Err("stack is empty".to_string()) },
                     ':'|'#'|' '|'.'|'0'...'9' => {
                         let mut flags = Flags::new();
@@ -355,7 +355,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     (_,'d')|(_,'o')|(_,'x')|(_,'X')|(_,'s') => if stack.len() > 0 {
                         let res = format(stack.pop().unwrap(), FormatOp::from_char(cur), *flags);
                         if res.is_err() { return res }
-                        output.push_all(res.unwrap().as_slice());
+                        output.push_all(&res.unwrap());
                         // will cause state to go to Nothing
                         old_state = FormatPattern(*flags, *fstate);
                     } else { return Err("stack is empty".to_string()) },
@@ -609,7 +609,7 @@ fn get_res(fmt: &str, cap: &str, params: &[Param], vars: &mut Variables) ->
         {
             let mut u8v: Vec<_> = fmt.bytes().collect();
             u8v.extend(cap.as_bytes().iter().map(|&b| b));
-            expand(u8v.as_slice(), params, vars)
+            expand(&u8v, params, vars)
         }
 
         let caps = ["%d", "%c", "%s", "%Pa", "%l", "%!", "%~"];
index c369e354875b5be7367c14d9817fc4ebbca53f73..f3edd90b4fa5b3c15ee1c35a06c4a6bc802969db 100644 (file)
@@ -105,7 +105,7 @@ impl TestName {
     fn as_slice<'a>(&'a self) -> &'a str {
         match *self {
             StaticTestName(s) => s,
-            DynTestName(ref s) => s.as_slice()
+            DynTestName(ref s) => s
         }
     }
 }
@@ -130,11 +130,11 @@ fn padded_name(&self, column_count: uint, align: NamePadding) -> String {
         match align {
             PadNone => name,
             PadOnLeft => {
-                pad.push_str(name.as_slice());
+                pad.push_str(&name);
                 pad
             }
             PadOnRight => {
-                name.push_str(pad.as_slice());
+                name.push_str(&pad);
                 name
             }
         }
@@ -354,20 +354,19 @@ fn usage(binary: &str) {
                      test, then the test runner will ignore these tests during
                      normal test runs. Running with --ignored will run these
                      tests."#,
-             usage = getopts::usage(message.as_slice(),
-                                    optgroups().as_slice()));
+             usage = getopts::usage(&message, &optgroups()));
 }
 
 // Parses command line arguments into test options
 pub fn parse_opts(args: &[String]) -> Option<OptRes> {
     let args_ = args.tail();
     let matches =
-        match getopts::getopts(args_.as_slice(), optgroups().as_slice()) {
+        match getopts::getopts(args_, &optgroups()) {
           Ok(m) => m,
           Err(f) => return Some(Err(f.to_string()))
         };
 
-    if matches.opt_present("h") { usage(args[0].as_slice()); return None; }
+    if matches.opt_present("h") { usage(&args[0]); return None; }
 
     let filter = if matches.free.len() > 0 {
         Some(matches.free[0].clone())
@@ -389,7 +388,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
         nocapture = env::var("RUST_TEST_NOCAPTURE").is_some();
     }
 
-    let color = match matches.opt_str("color").as_ref().map(|s| s.as_slice()) {
+    let color = match matches.opt_str("color").as_ref().map(|s| &**s) {
         Some("auto") | None => AutoColor,
         Some("always") => AlwaysColor,
         Some("never") => NeverColor,
@@ -523,13 +522,13 @@ pub fn write_plain(&mut self, s: &str) -> old_io::IoResult<()> {
     pub fn write_run_start(&mut self, len: uint) -> old_io::IoResult<()> {
         self.total = len;
         let noun = if len != 1 { "tests" } else { "test" };
-        self.write_plain(format!("\nrunning {} {}\n", len, noun).as_slice())
+        self.write_plain(&format!("\nrunning {} {}\n", len, noun))
     }
 
     pub fn write_test_start(&mut self, test: &TestDesc,
                             align: NamePadding) -> old_io::IoResult<()> {
         let name = test.padded_name(self.max_name_len, align);
-        self.write_plain(format!("test {} ... ", name).as_slice())
+        self.write_plain(&format!("test {} ... ", name))
     }
 
     pub fn write_result(&mut self, result: &TestResult) -> old_io::IoResult<()> {
@@ -539,13 +538,12 @@ pub fn write_result(&mut self, result: &TestResult) -> old_io::IoResult<()> {
             TrIgnored => self.write_ignored(),
             TrMetrics(ref mm) => {
                 try!(self.write_metric());
-                self.write_plain(format!(": {}", mm.fmt_metrics()).as_slice())
+                self.write_plain(&format!(": {}", mm.fmt_metrics()))
             }
             TrBench(ref bs) => {
                 try!(self.write_bench());
 
-                try!(self.write_plain(format!(": {}",
-                                              fmt_bench_samples(bs)).as_slice()));
+                try!(self.write_plain(&format!(": {}", fmt_bench_samples(bs))));
 
                 Ok(())
             }
@@ -564,7 +562,7 @@ pub fn write_log(&mut self, test: &TestDesc,
                         TrIgnored => "ignored".to_string(),
                         TrMetrics(ref mm) => mm.fmt_metrics(),
                         TrBench(ref bs) => fmt_bench_samples(bs)
-                    }, test.name.as_slice());
+                    }, test.name);
                 o.write_all(s.as_bytes())
             }
         }
@@ -577,23 +575,21 @@ pub fn write_failures(&mut self) -> old_io::IoResult<()> {
         for &(ref f, ref stdout) in &self.failures {
             failures.push(f.name.to_string());
             if stdout.len() > 0 {
-                fail_out.push_str(format!("---- {} stdout ----\n\t",
-                                          f.name.as_slice()).as_slice());
-                let output = String::from_utf8_lossy(stdout.as_slice());
-                fail_out.push_str(output.as_slice());
+                fail_out.push_str(&format!("---- {} stdout ----\n\t", f.name));
+                let output = String::from_utf8_lossy(stdout);
+                fail_out.push_str(&output);
                 fail_out.push_str("\n");
             }
         }
         if fail_out.len() > 0 {
             try!(self.write_plain("\n"));
-            try!(self.write_plain(fail_out.as_slice()));
+            try!(self.write_plain(&fail_out));
         }
 
         try!(self.write_plain("\nfailures:\n"));
         failures.sort();
         for name in &failures {
-            try!(self.write_plain(format!("    {}\n",
-                                          name.as_slice()).as_slice()));
+            try!(self.write_plain(&format!("    {}\n", name)));
         }
         Ok(())
     }
@@ -615,7 +611,7 @@ pub fn write_run_finish(&mut self) -> old_io::IoResult<bool> {
         }
         let s = format!(". {} passed; {} failed; {} ignored; {} measured\n\n",
                         self.passed, self.failed, self.ignored, self.measured);
-        try!(self.write_plain(s.as_slice()));
+        try!(self.write_plain(&s));
         return Ok(success);
     }
 }
@@ -648,13 +644,13 @@ fn callback<T: Writer>(event: &TestEvent,
                     TrOk => st.passed += 1,
                     TrIgnored => st.ignored += 1,
                     TrMetrics(mm) => {
-                        let tname = test.name.as_slice();
+                        let tname = test.name;
                         let MetricMap(mm) = mm;
                         for (k,v) in &mm {
                             st.metrics
-                              .insert_metric(format!("{}.{}",
-                                                     tname,
-                                                     k).as_slice(),
+                              .insert_metric(&format!("{}.{}",
+                                                      tname,
+                                                      k),
                                              v.value,
                                              v.noise);
                         }
@@ -686,7 +682,7 @@ fn len_if_padded(t: &TestDescAndFn) -> uint {
     match tests.iter().max_by(|t|len_if_padded(*t)) {
         Some(t) => {
             let n = t.desc.name.as_slice();
-            st.max_name_len = n.len();
+            st.max_name_len = n.as_slice().len();
         },
         None => {}
     }
@@ -1237,7 +1233,7 @@ fn parse_ignored_flag() {
         let args = vec!("progname".to_string(),
                         "filter".to_string(),
                         "--ignored".to_string());
-        let opts = match parse_opts(args.as_slice()) {
+        let opts = match parse_opts(&args) {
             Some(Ok(o)) => o,
             _ => panic!("Malformed arg in parse_ignored_flag")
         };
index ebd86dbf61cbff9e8d19e5f5e3b2167afaa6048e..04617757465ec97a58bb913e23e409e22b299f6b 100644 (file)
@@ -260,19 +260,19 @@ fn median_abs_dev_pct(&self) -> T {
 
     fn percentile(&self, pct: T) -> T {
         let mut tmp = self.to_vec();
-        local_sort(tmp.as_mut_slice());
-        percentile_of_sorted(tmp.as_slice(), pct)
+        local_sort(&mut tmp);
+        percentile_of_sorted(&tmp, pct)
     }
 
     fn quartiles(&self) -> (T,T,T) {
         let mut tmp = self.to_vec();
-        local_sort(tmp.as_mut_slice());
+        local_sort(&mut tmp);
         let first = FromPrimitive::from_uint(25).unwrap();
-        let a = percentile_of_sorted(tmp.as_slice(), first);
+        let a = percentile_of_sorted(&tmp, first);
         let secound = FromPrimitive::from_uint(50).unwrap();
-        let b = percentile_of_sorted(tmp.as_slice(), secound);
+        let b = percentile_of_sorted(&tmp, secound);
         let third = FromPrimitive::from_uint(75).unwrap();
-        let c = percentile_of_sorted(tmp.as_slice(), third);
+        let c = percentile_of_sorted(&tmp, third);
         (a,b,c)
     }
 
@@ -317,10 +317,10 @@ fn percentile_of_sorted<T: Float + FromPrimitive>(sorted_samples: &[T],
 /// See: http://en.wikipedia.org/wiki/Winsorising
 pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
     let mut tmp = samples.to_vec();
-    local_sort(tmp.as_mut_slice());
-    let lo = percentile_of_sorted(tmp.as_slice(), pct);
+    local_sort(&mut tmp);
+    let lo = percentile_of_sorted(&tmp, pct);
     let hundred: T = FromPrimitive::from_uint(100).unwrap();
-    let hi = percentile_of_sorted(tmp.as_slice(), hundred-pct);
+    let hi = percentile_of_sorted(&tmp, hundred-pct);
     for samp in samples {
         if *samp > hi {
             *samp = hi
index ff8246a0e3f875023ab849f72790febd4a6bfd62..15cf3986e6e80c61eeb74124afb041980fb63c96 100644 (file)
@@ -89,12 +89,12 @@ fn trim(&self) -> &str {
 
     #[inline]
     fn trim_left(&self) -> &str {
-        self.trim_left_matches(|&: c: char| c.is_whitespace())
+        self.trim_left_matches(|c: char| c.is_whitespace())
     }
 
     #[inline]
     fn trim_right(&self) -> &str {
-        self.trim_right_matches(|&: c: char| c.is_whitespace())
+        self.trim_right_matches(|c: char| c.is_whitespace())
     }
 }
 
@@ -527,7 +527,7 @@ fn next(&mut self) -> Option<u16> {
 
         let mut buf = [0u16; 2];
         self.chars.next().map(|ch| {
-            let n = CharExt::encode_utf16(ch, buf.as_mut_slice()).unwrap_or(0);
+            let n = CharExt::encode_utf16(ch, &mut buf).unwrap_or(0);
             if n == 2 { self.extra = buf[1]; }
             buf[0]
         })
index 255fbdcbfcf5e78e1d771221f26e2bd8bd668a0c..b756602ead4f43286408ad769742f79e4fc32934 100644 (file)
@@ -47,7 +47,8 @@ extern char **environ;
 #endif
 #endif
 
-#if defined(__FreeBSD__) || defined(__linux__) || defined(__ANDROID__) || defined(__DragonFly__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__linux__) || defined(__ANDROID__) \
+  || defined(__DragonFly__) || defined(__OpenBSD__)
 extern char **environ;
 #endif
 
@@ -235,7 +236,7 @@ const char * rust_current_exe() {
 
         /* get realpath if possible */
         if ((argv[0] != NULL) && ((*argv[0] == '.') || (*argv[0] == '/')
-                               || (strstr(argv[0], "/") != NULL)))
+                                || (strstr(argv[0], "/") != NULL)))
 
             self = realpath(argv[0], NULL);
         else
index 058e2e6bf7f28680c60817ed391389e5590bb4a5..56948ea1219ea437dff3933d31db71dcc80ccfec 100644 (file)
@@ -1,3 +1,12 @@
+S 2015-02-04 ac134f7
+  freebsd-x86_64 483e37a02a7ebc12a872e3146145e342ba4a5c04
+  linux-i386 8af64e5df839cc945399484380a8b2ebe05a6751
+  linux-x86_64 9f485d79c1f0d273ed864eddadb1707f3e2df489
+  macos-i386 800f86abd589a1d46c37a8700211c7ba6b05decb
+  macos-x86_64 b9961faccf79dcfdc0b7a6909bef8b6769798d08
+  winnt-i386 2c56a7573f8d0f78271dab1c8e29d3ced7a44ed8
+  winnt-x86_64 f1736f47de2a6fad1ff881e51c176f71db5dc2a5
+
 S 2015-01-31 474b324
   freebsd-x86_64 c5b55eb488790ff8425d74afa3b37c49517bc55f
   linux-i386 319f2f3573c058cb2c4dfc75faaf8ea3ae86ef11
index 54f1595780db715f0dc3b23705d47512364e3073..a29dcc00cddf8ed0272758a9ea2bd8a45910ccdb 100644 (file)
@@ -12,5 +12,5 @@
 #![crate_type = "rlib"]
 
 pub fn inner<F>(f: F) -> F {
-    (move |:| f)()
+    (move || f)()
 }
index 67037a3ac9e08cde559758543ff5280e342b3849..bf4ab975cedd8c97a66dfd89a45a30488e732cdf 100644 (file)
@@ -12,5 +12,5 @@
 
 pub fn foo<T>() {
     fn death() -> int { panic!() }
-    debug!("{}", (|&:|{ death() })());
+    debug!("{}", (||{ death() })());
 }
index e01a95d461b21347e29a576213c2c52b2cad3727..6779cf997c1162236bbab3dac122b55cf5226de5 100644 (file)
@@ -38,7 +38,7 @@ fn expand<'cx>(&self,
 
         let attr = ecx.attribute(sp, self.args.clone());
         let src = pprust::attribute_to_string(&attr);
-        let interned = token::intern_and_get_ident(src.as_slice());
+        let interned = token::intern_and_get_ident(&src);
         MacExpr::new(ecx.expr_str(sp, interned))
     }
 }
index 3096adaaf11f38de7201099c70a09f120a528399..3fe7a29256d8e1d9246c03d5b4e9ccc088ae4f1c 100644 (file)
@@ -46,7 +46,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
         }
     };
 
-    let mut text = text.as_slice();
+    let mut text = &*text;
     let mut total = 0u;
     while !text.is_empty() {
         match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) {
index 6cb16f04ce115713ab4bd4f2b52f2cf162f6e85b..d84ded25702f4b38de4abf61bb5721b6e526068a 100644 (file)
@@ -25,7 +25,7 @@ fn readMaybe(s: String) -> Option<int> {
 
 impl read for bool {
     fn readMaybe(s: String) -> Option<bool> {
-        match s.as_slice() {
+        match &*s {
           "true" => Some(true),
           "false" => Some(false),
           _ => None
index 4bc45caa170e4eee4e1c46d19db61bd01ffa7c7a..f03bcb41fafe8bd1f31ef25735699dcd0eb6ca81 100644 (file)
 #[inline]
 pub fn has_closures() -> uint {
     let x = 1u;
-    let mut f = move |&mut:| x;
+    let mut f = move || x;
     let y = 1u;
-    let g = |:| y;
+    let g = || y;
     f() + g()
 }
 
 pub fn has_generic_closures<T: Add<Output=T> + Copy>(x: T, y: T) -> T {
-    let mut f = move |&mut:| x;
-    let g = |:| y;
+    let mut f = move || x;
+    let g = || y;
     f() + g()
 }
index 8330c159769fd06dd5a2610ddebef910c46bdd55..12c95e4c60c64beff6a75fcae565e2a0a769ef55 100644 (file)
@@ -102,7 +102,7 @@ fn vector<M: MutableMap>(map: &mut M, n_keys: uint, dist: &[uint]) {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
+    let args = args;
     let n_keys = {
         if args.len() == 2 {
             args[1].parse::<uint>().unwrap()
@@ -143,7 +143,7 @@ fn main() {
     {
         println!(" Random integers:");
         let mut map: BTreeMap<uint,uint> = BTreeMap::new();
-        vector(&mut map, n_keys, rand.as_slice());
+        vector(&mut map, n_keys, &rand);
     }
 
     // FIXME: #9970
@@ -162,6 +162,6 @@ fn main() {
     {
         println!(" Random integers:");
         let mut map: HashMap<uint,uint> = HashMap::new();
-        vector(&mut map, n_keys, rand.as_slice());
+        vector(&mut map, n_keys, &rand);
     }
 }
index b78b147348a8cf0bfceb1d4b04da8e3bee63612b..33ac8a43b437bf24dcdc17bb0641bf93b4b0f75a 100644 (file)
@@ -180,7 +180,7 @@ fn empty_results() -> Results {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
+    let args = args;
     let num_keys = {
         if args.len() == 2 {
             args[1].parse::<uint>().unwrap()
index 388868eee708efd86c6bbbbf2c6a8238244d7d83..991c08f60be7af05df2cff6181cb27b47f2d1d16 100644 (file)
@@ -29,7 +29,7 @@ fn main() {
 
     macro_rules! bench {
         ($id:ident) =>
-            (maybe_run_test(argv.as_slice(),
+            (maybe_run_test(&argv,
                             stringify!($id).to_string(),
                             $id))
     }
@@ -94,7 +94,7 @@ fn vec_plus() {
             v.extend(rv.into_iter());
         } else {
             let mut rv = rv.clone();
-            rv.push_all(v.as_slice());
+            rv.push_all(&v);
             v = rv;
         }
         i += 1;
@@ -110,12 +110,12 @@ fn vec_append() {
         let rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
         if r.gen() {
             let mut t = v.clone();
-            t.push_all(rv.as_slice());
+            t.push_all(&rv);
             v = t;
         }
         else {
             let mut t = rv.clone();
-            t.push_all(v.as_slice());
+            t.push_all(&v);
             v = t;
         }
         i += 1;
@@ -129,11 +129,11 @@ fn vec_push_all() {
     for i in 0u..1500 {
         let mut rv = repeat(i).take(r.gen_range(0u, i + 1)).collect::<Vec<_>>();
         if r.gen() {
-            v.push_all(rv.as_slice());
+            v.push_all(&rv);
         }
         else {
             swap(&mut v, &mut rv);
-            v.push_all(rv.as_slice());
+            v.push_all(&rv);
         }
     }
 }
@@ -142,7 +142,7 @@ fn is_utf8_ascii() {
     let mut v : Vec<u8> = Vec::new();
     for _ in 0u..20000 {
         v.push('b' as u8);
-        if str::from_utf8(v.as_slice()).is_err() {
+        if str::from_utf8(&v).is_err() {
             panic!("from_utf8 panicked");
         }
     }
@@ -153,7 +153,7 @@ fn is_utf8_multibyte() {
     let mut v : Vec<u8> = Vec::new();
     for _ in 0u..5000 {
         v.push_all(s.as_bytes());
-        if str::from_utf8(v.as_slice()).is_err() {
+        if str::from_utf8(&v).is_err() {
             panic!("from_utf8 panicked");
         }
     }
index 259b4d9418dcf428b5bf8312db7fa43e09cf1571..be42cb277f7a0c38fcbb8bfc05bf844acee5db24 100644 (file)
@@ -103,5 +103,5 @@ fn main() {
     };
 
     println!("{:?}", args);
-    run(args.as_slice());
+    run(&args);
 }
index 1341c03e5055b05e7645f55f2d0ab011786dbf46..d9eea02a1769be036290df74c4e52f1c3c36b535 100644 (file)
@@ -110,5 +110,5 @@ fn main() {
     };
 
     println!("{:?}", args);
-    run(args.as_slice());
+    run(&args);
 }
index a67deac67db6cf3c348944f1e739f223c45da828..e4e8b4a6e6e1e2a954aadf48ba360d5a27e33c5c 100644 (file)
@@ -65,7 +65,7 @@ fn run_pair(n: uint) {
 fn main() {
 
     let args = os::args();
-    let args = args.as_slice();
+    let args = args;
     let n = if args.len() == 3 {
         args[1].parse::<uint>().unwrap()
     } else {
index 7dc94efcf916a8f0eaf0cbef4905f18e468c093e..13b8a5ca763ad1e5a8814c08ebdcba27d4470fa8 100644 (file)
@@ -32,7 +32,7 @@ fn parfib(n: uint) -> uint {
 fn main() {
 
     let args = os::args();
-    let args = args.as_slice();
+    let args = args;
     let n = if args.len() == 2 {
         args[1].parse::<uint>().unwrap()
     } else {
index dc65a63c5cb400c2f3d5271d6aa44093a9c3366a..38648b426f6cdd6fd7b6fd5e3bfd2d9543cb5164 100644 (file)
@@ -85,7 +85,7 @@ fn inner(depth: i32, iterations: i32) -> String {
 
 fn main() {
     let args = std::os::args();
-    let args = args.as_slice();
+    let args = args;
     let n = if std::os::getenv("RUST_BENCH").is_some() {
         17
     } else if args.len() <= 1u {
index 0835dd9a08e964103e2237bd0c39ec75fa5ca522..30bbb3bc924db6a12c12c75a82fd62f834e678a4 100644 (file)
@@ -82,7 +82,7 @@ fn show_color_list(set: Vec<Color>) -> String {
     let mut out = String::new();
     for col in &set {
         out.push(' ');
-        out.push_str(format!("{:?}", col).as_slice());
+        out.push_str(&format!("{:?}", col));
     }
     out
 }
@@ -230,7 +230,7 @@ fn main() {
     let nn = if std::os::getenv("RUST_BENCH").is_some() {
         200000
     } else {
-        std::os::args().as_slice()
+        std::os::args()
                        .get(1)
                        .and_then(|arg| arg.parse().ok())
                        .unwrap_or(600u)
index 47613e2d69c73c7d5a95637b167daf8e97ce483d..92e1bc1a922c281043e468edaa880e0791572a67 100644 (file)
@@ -180,7 +180,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
 }
 
 fn main() {
-    let n = std::os::args().as_slice()
+    let n = std::os::args()
         .get(1)
         .and_then(|arg| arg.parse().ok())
         .unwrap_or(2i32);
index 5386fc0419dc3c405b09283c2f4f70d229fa1486..d91031b8401f3fddd06235922018c9278a42a63e 100644 (file)
@@ -124,7 +124,7 @@ fn make(&mut self, n: uint) -> IoResult<()> {
         let mut buf = repeat(0u8).take(alu_len + LINE_LEN).collect::<Vec<_>>();
         let alu: &[u8] = self.alu.as_bytes();
 
-        copy_memory(buf.as_mut_slice(), alu);
+        copy_memory(&mut buf, alu);
         let buf_len = buf.len();
         copy_memory(&mut buf[alu_len..buf_len],
                     &alu[..LINE_LEN]);
@@ -180,7 +180,7 @@ fn rng(&mut self, max: f32) -> f32 {
 
     fn nextc(&mut self) -> u8 {
         let r = self.rng(1.0);
-        for a in &self.lookup[] {
+        for a in &self.lookup[..] {
             if a.p >= r {
                 return a.c;
             }
@@ -209,7 +209,7 @@ fn make(&mut self, n: uint) -> IoResult<()> {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
+    let args = args;
     let n = if args.len() > 1 {
         args[1].parse::<uint>().unwrap()
     } else {
@@ -226,12 +226,12 @@ fn main() {
 
     out.write_line(">TWO IUB ambiguity codes").unwrap();
     let iub = sum_and_scale(&IUB);
-    let mut random = RandomFasta::new(&mut out, iub.as_slice());
+    let mut random = RandomFasta::new(&mut out, &iub);
     random.make(n * 3).unwrap();
 
     random.out.write_line(">THREE Homo sapiens frequency").unwrap();
     let homo_sapiens = sum_and_scale(&HOMO_SAPIENS);
-    random.lookup = make_lookup(homo_sapiens.as_slice());
+    random.lookup = make_lookup(&homo_sapiens);
     random.make(n * 5).unwrap();
 
     random.out.write_str("\n").unwrap();
index 8a2a8453a9ef533c8a81fb6d38c88ed30b18e1b1..141e098745e7bdf790e639ddc1989bc00c433568 100644 (file)
@@ -104,7 +104,7 @@ fn make_fasta<W: Writer, I: Iterator<Item=u8>>(
 
 fn run<W: Writer>(writer: &mut W) -> std::old_io::IoResult<()> {
     let args = os::args();
-    let args = args.as_slice();
+    let args = args;
     let n = if os::getenv("RUST_BENCH").is_some() {
         25000000
     } else if args.len() <= 1u {
index ad8e6551a031b1a44c2ac5cba27ac8071b214c27..ed93594534cb4f04d999e7c5c1cba3d8697417d7 100644 (file)
@@ -64,9 +64,9 @@ fn sortKV(mut orig: Vec<(Vec<u8> ,f64)> ) -> Vec<(Vec<u8> ,f64)> {
 
    let mut buffer = String::new();
    for &(ref k, v) in &pairs_sorted {
-       buffer.push_str(format!("{:?} {:0.3}\n",
-                               k.to_ascii_uppercase(),
-                               v).as_slice());
+       buffer.push_str(&format!("{:?} {:0.3}\n",
+                                k.to_ascii_uppercase(),
+                                v));
    }
 
    return buffer
@@ -122,8 +122,8 @@ fn make_sequence_processor(sz: uint,
        line = from_parent.recv().unwrap();
        if line == Vec::new() { break; }
 
-       carry.push_all(line.as_slice());
-       carry = windows_with_carry(carry.as_slice(), sz, |window| {
+       carry.push_all(&line);
+       carry = windows_with_carry(&carry, sz, |window| {
            update_freq(&mut freqs, window);
            total += 1u;
        });
index e3f8e60df93db2fcc7a0901e331abeefa1a7b346..474e5464293976f3bc758165ea15e9afb8bbe121 100644 (file)
@@ -261,7 +261,7 @@ fn print_frequencies(frequencies: &Table, frame: uint) {
     for entry in frequencies.iter() {
         vector.push((entry.count, entry.code));
     }
-    vector.as_mut_slice().sort();
+    vector.sort();
 
     let mut total_count = 0;
     for &(count, _) in &vector {
@@ -270,7 +270,7 @@ fn print_frequencies(frequencies: &Table, frame: uint) {
 
     for &(count, key) in vector.iter().rev() {
         println!("{} {:.3}",
-                 key.unpack(frame).as_slice(),
+                 key.unpack(frame),
                  (count as f32 * 100.0) / (total_count as f32));
     }
     println!("");
@@ -301,11 +301,11 @@ fn main() {
 
     let nb_freqs: Vec<_> = (1u..3).map(|i| {
         let input = input.clone();
-        (i, Thread::scoped(move|| generate_frequencies(input.as_slice(), i)))
+        (i, Thread::scoped(move|| generate_frequencies(&input, i)))
     }).collect();
     let occ_freqs: Vec<_> = OCCURRENCES.iter().map(|&occ| {
         let input = input.clone();
-        Thread::scoped(move|| generate_frequencies(input.as_slice(), occ.len()))
+        Thread::scoped(move|| generate_frequencies(&input, occ.len()))
     }).collect();
 
     for (i, freq) in nb_freqs {
index a5729c5b5bd4c1c02596d6a661418c8e8ec2379a..e2d51fbf4111d43f63371143e6ea59eafb5b903f 100644 (file)
@@ -124,7 +124,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
 
         Thread::scoped(move|| {
             let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
-            let init_r_slice = vec_init_r.as_slice();
+            let init_r_slice = vec_init_r;
 
             let start = i * chunk_size;
             let end = if i == (WORKERS - 1) {
@@ -134,7 +134,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
             };
 
             for &init_i in &vec_init_i[start..end] {
-                write_line(init_i, init_r_slice, &mut res);
+                write_line(init_i, &init_r_slice, &mut res);
             }
 
             res
@@ -143,7 +143,7 @@ fn mandelbrot<W: old_io::Writer>(w: usize, mut out: W) -> old_io::IoResult<()> {
 
     try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
     for res in data {
-        try!(out.write(res.join().ok().unwrap().as_slice()));
+        try!(out.write(&res.join().ok().unwrap()));
     }
     out.flush()
 }
index a8de1469456cb18d1fb89d3b2557e0c19d20d968..71fe1c6affce3283d946fe95f6173c020d0f7a75 100644 (file)
@@ -103,7 +103,7 @@ struct Planet {
 
 fn advance(bodies: &mut [Planet;N_BODIES], dt: f64, steps: int) {
     for _ in 0..steps {
-        let mut b_slice = bodies.as_mut_slice();
+        let mut b_slice: &mut [_] = bodies;
         loop {
             let bi = match shift_mut_ref(&mut b_slice) {
                 Some(bi) => bi,
index ea1d913b3e2ee9cd5f576908c7d507e40ef989e2..a1a9fbb471a475df28f0f35eb003b611775f0ac1 100644 (file)
@@ -57,7 +57,7 @@ fn parse_opts(argv: Vec<String> ) -> Config {
     let argv = argv.iter().map(|x| x.to_string()).collect::<Vec<_>>();
     let opt_args = &argv[1..argv.len()];
 
-    match getopts::getopts(opt_args, opts.as_slice()) {
+    match getopts::getopts(opt_args, &opts) {
       Ok(ref m) => {
           return Config {stress: m.opt_present("stress")}
       }
index 3a35bea0d5997fc3ebf23a7de6437a36424dd0fa..82887386814025d9720a24ded2898d2e000d9d36 100644 (file)
@@ -251,6 +251,6 @@ fn parallel<'a, I, T, F>(iter: I, f: F)
 fn main() {
     let mut data = read_to_end(&mut stdin_raw()).unwrap();
     let tables = &Tables::new();
-    parallel(mut_dna_seqs(data.as_mut_slice()), |&: seq| reverse_complement(seq, tables));
-    stdout_raw().write(data.as_mut_slice()).unwrap();
+    parallel(mut_dna_seqs(&mut data), |seq| reverse_complement(seq, tables));
+    stdout_raw().write(&data).unwrap();
 }
index ec85ba18f900a1fd136f0e169162a212846b8685..24e11887065c280f3fc834bd96b0decee58231da 100644 (file)
@@ -69,10 +69,10 @@ fn spectralnorm(n: uint) -> f64 {
     let mut v = u.clone();
     let mut tmp = v.clone();
     for _ in 0u..10 {
-        mult_AtAv(u.as_slice(), v.as_mut_slice(), tmp.as_mut_slice());
-        mult_AtAv(v.as_slice(), u.as_mut_slice(), tmp.as_mut_slice());
+        mult_AtAv(&u, &mut v, &mut tmp);
+        mult_AtAv(&v, &mut u, &mut tmp);
     }
-    (dot(u.as_slice(), v.as_slice()) / dot(v.as_slice(), v.as_slice())).sqrt()
+    (dot(&u, &v) / dot(&v, &v)).sqrt()
 }
 
 fn mult_AtAv(v: &[f64], out: &mut [f64], tmp: &mut [f64]) {
index 75126973cd9f4b579bcd2700e6e4efddfa4ae163..4a248384e1054848cb8ae6b1ebef0a6cda912e8e 100644 (file)
@@ -63,7 +63,7 @@ pub fn read(mut reader: &mut BufferedReader<StdReader>) -> Sudoku {
                           .take(10).collect::<Vec<_>>();
         for line in reader.lines() {
             let line = line.unwrap();
-            let comps: Vec<&str> = line.as_slice()
+            let comps: Vec<&str> = line
                                        .trim()
                                        .split(',')
                                        .collect();
index 0694420e7666fed35f4935e80f659ba03b7b5cb5..b8aba7c483db943ea34227d32b4d1f6154d1de37 100644 (file)
@@ -27,5 +27,5 @@ fn cat(in_x : usize, in_y : isize) -> cat {
 
 fn main() {
   let nyan : cat = cat(52us, 99);
-  nyan.speak = |&:| println!("meow"); //~ ERROR attempted to take value of method
+  nyan.speak = || println!("meow"); //~ ERROR attempted to take value of method
 }
index a28f5f6e557150b53d02d50c032fd00d4fe24ebc..5cc087cb66e3c5d9f66316df9559d7f25390efbe 100644 (file)
@@ -13,7 +13,7 @@ pub fn foo() -> bool { true }
 }
 
 fn main() {
-    let foo = |&:| false;
+    let foo = || false;
     use bar::foo;
     //~^ ERROR imports are not allowed after non-item statements
     assert_eq!(foo(), false);
index 3a2c6f038510721794edb2b4a60884df0767cdd5..b18df7f3db608b4f3bee2355d9907c16eeafa101 100644 (file)
@@ -33,7 +33,7 @@ fn b() {
     let mut p = vec!(1);
 
     borrow(
-        p.as_slice(),
+        &p,
         || p[0] = 5); //~ ERROR cannot borrow `p` as mutable
 }
 
@@ -41,7 +41,7 @@ fn c() {
     // Legal because the scope of the borrow does not include the
     // modification:
     let mut p = vec!(1);
-    borrow(p.as_slice(), ||{});
+    borrow(&p, ||{});
     p[0] = 5;
 }
 
index d983c5d5087897a9b676aee43fa7350ebdfa8f82..99ac86722693ab90716e32784ca9dbfb8007c7f4 100644 (file)
@@ -30,7 +30,7 @@ fn defer<'r>(x: &'r [&'r str]) -> defer<'r> {
 }
 
 fn main() {
-    let x = defer(vec!("Goodbye", "world!").as_slice());
+    let x = defer(&vec!("Goodbye", "world!"));
     //~^ ERROR borrowed value does not live long enough
     x.x[0];
 }
index 9b9edce243bb77ce9a9c5e94b4ff5356cbe4b752..9ea5fbbdb1af08e72e83750025961b6652fbfe72 100644 (file)
@@ -49,15 +49,15 @@ fn test5(f: &mut Test) {
 }
 
 fn test6() {
-    let mut f = |&mut:| {};
-    (|&mut:| {
+    let mut f = || {};
+    (|| {
         f();
     })();
 }
 
 fn test7() {
     fn foo<F>(_: F) where F: FnMut(Box<FnMut(isize)>, isize) {}
-    let mut f = |&mut: g: Box<FnMut(isize)>, b: isize| {};
+    let mut f = |g: Box<FnMut(isize)>, b: isize| {};
     f(box |a| {
         foo(f);
         //~^ ERROR cannot move `f` into closure because it is borrowed
index 9d73ad319a61c864b45b7ccd2a19c78090849045..851b11fac2b9d1949f9eb09f3e5a15a82c5afe33 100644 (file)
@@ -23,37 +23,37 @@ fn set(x: &mut isize) {
 
 fn a() {
     let mut x = 3;
-    let c1 = |&mut:| x = 4;
-    let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
+    let c1 = || x = 4;
+    let c2 = || x * 5; //~ ERROR cannot borrow `x`
 }
 
 fn b() {
     let mut x = 3;
-    let c1 = |&mut:| set(&mut x);
-    let c2 = |&mut:| get(&x); //~ ERROR cannot borrow `x`
+    let c1 = || set(&mut x);
+    let c2 = || get(&x); //~ ERROR cannot borrow `x`
 }
 
 fn c() {
     let mut x = 3;
-    let c1 = |&mut:| set(&mut x);
-    let c2 = |&mut:| x * 5; //~ ERROR cannot borrow `x`
+    let c1 = || set(&mut x);
+    let c2 = || x * 5; //~ ERROR cannot borrow `x`
 }
 
 fn d() {
     let mut x = 3;
-    let c2 = |&mut:| x * 5;
+    let c2 = || x * 5;
     x = 5; //~ ERROR cannot assign
 }
 
 fn e() {
     let mut x = 3;
-    let c1 = |&mut:| get(&x);
+    let c1 = || get(&x);
     x = 5; //~ ERROR cannot assign
 }
 
 fn f() {
     let mut x = box 3;
-    let c1 = |&mut:| get(&*x);
+    let c1 = || get(&*x);
     *x = 5; //~ ERROR cannot assign
 }
 
@@ -63,7 +63,7 @@ struct Foo {
     }
 
     let mut x = box Foo { f: box 3 };
-    let c1 = |&mut:| get(&*x.f);
+    let c1 = || get(&*x.f);
     *x.f = 5; //~ ERROR cannot assign to `*x.f`
 }
 
@@ -73,8 +73,8 @@ struct Foo {
     }
 
     let mut x = box Foo { f: box 3 };
-    let c1 = |&mut:| get(&*x.f);
-    let c2 = |&mut:| *x.f = 5; //~ ERROR cannot borrow `x` as mutable
+    let c1 = || get(&*x.f);
+    let c2 = || *x.f = 5; //~ ERROR cannot borrow `x` as mutable
 }
 
 fn main() {
index 8260774190967b417962d319ce0ce46cc0bfd1a4..40f9be2dd8230fcb82f80831b698013c703c4db5 100644 (file)
@@ -20,9 +20,9 @@ fn set(x: &mut isize) {
 }
 
 fn a(x: &isize) {
-    let c1 = |&mut:| set(&mut *x);
+    let c1 = || set(&mut *x);
     //~^ ERROR cannot borrow
-    let c2 = |&mut:| set(&mut *x);
+    let c2 = || set(&mut *x);
     //~^ ERROR cannot borrow
     //~| ERROR closure requires unique access
 }
index 48a9dccfef0baaf39c11130e168a8a77bb941cc5..8ab4e257b0626d35a76eca6239519d5e2072e8f4 100644 (file)
 
 #![feature(box_syntax)]
 
+fn to_fn_mut<F: FnMut()>(f: F) -> F { f }
+
 fn a() {
     let mut x = 3;
-    let c1 = |&mut:| x = 4;
-    let c2 = |&mut:| x = 5; //~ ERROR cannot borrow `x` as mutable more than once
+    let c1 = to_fn_mut(|| x = 4);
+    let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
 }
 
 fn set(x: &mut isize) {
@@ -26,20 +28,20 @@ fn set(x: &mut isize) {
 
 fn b() {
     let mut x = 3;
-    let c1 = |&mut:| set(&mut x);
-    let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
+    let c1 = to_fn_mut(|| set(&mut x));
+    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
 }
 
 fn c() {
     let mut x = 3;
-    let c1 = |&mut:| x = 5;
-    let c2 = |&mut:| set(&mut x); //~ ERROR cannot borrow `x` as mutable more than once
+    let c1 = to_fn_mut(|| x = 5);
+    let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
 }
 
 fn d() {
     let mut x = 3;
-    let c1 = |&mut:| x = 5;
-    let c2 = |&mut:| { let _y = |&mut:| set(&mut x); }; // (nested closure)
+    let c1 = to_fn_mut(|| x = 5);
+    let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
     //~^ ERROR cannot borrow `x` as mutable more than once
 }
 
@@ -49,8 +51,8 @@ struct Foo {
     }
 
     let mut x = box Foo { f: box 3 };
-    let c1 = |&mut:| set(&mut *x.f);
-    let c2 = |&mut:| set(&mut *x.f);
+    let c1 = to_fn_mut(|| set(&mut *x.f));
+    let c2 = to_fn_mut(|| set(&mut *x.f));
     //~^ ERROR cannot borrow `x` as mutable more than once
 }
 
index cf86602af0be22106ddb8ff056b512b37c81098d..dcf43c01e1775635612f4b2e7f8d46c90ef69ac8 100644 (file)
@@ -16,7 +16,7 @@ pub fn main() {
     let mut this = &mut Foo {
         x: 1,
     };
-    let mut r = |&mut:| {
+    let mut r = || {
         let p = &this.x;
         &mut this.x; //~ ERROR cannot borrow
     };
index f9a6d5ac84575617db471360a6fead5f28f34f4f..9410181659c1a229a73adf620d88c2863091d913 100644 (file)
@@ -23,27 +23,27 @@ fn set(x: &mut isize) -> isize {
 }
 
 fn a(x: &mut isize) {
-    let c1 = |&mut:| get(x);
-    let c2 = |&mut:| get(x);
+    let c1 = || get(x);
+    let c2 = || get(x);
 }
 
 fn b(x: &mut isize) {
-    let c1 = |&mut:| get(x);
-    let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
+    let c1 = || get(x);
+    let c2 = || set(x); //~ ERROR closure requires unique access to `x`
 }
 
 fn c(x: &mut isize) {
-    let c1 = |&mut:| get(x);
-    let c2 = |&mut:| { get(x); set(x); }; //~ ERROR closure requires unique access to `x`
+    let c1 = || get(x);
+    let c2 = || { get(x); set(x); }; //~ ERROR closure requires unique access to `x`
 }
 
 fn d(x: &mut isize) {
-    let c1 = |&mut:| set(x);
-    let c2 = |&mut:| set(x); //~ ERROR closure requires unique access to `x`
+    let c1 = || set(x);
+    let c2 = || set(x); //~ ERROR closure requires unique access to `x`
 }
 
 fn e(x: &mut isize) {
-    let c1 = |&mut:| x = panic!(); //~ ERROR closure cannot assign to immutable local variable
+    let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable local variable
 }
 
 fn main() {
index b6529da18838b96c5f38694f699885b195eb1f11..32cd364d1f2d644ad18917d46514eeaa30e795b1 100644 (file)
@@ -26,7 +26,7 @@ fn drop(&mut self) {
 
 fn main() {
   let mut ptr = box Foo { x: 0 };
-  let mut test = |&mut: foo: &Foo| {
+  let mut test = |foo: &Foo| {
     ptr = box Foo { x: ptr.x + 1 };
   };
   test(&*ptr); //~ ERROR cannot borrow `*ptr`
index 3c20abab8bdeffac38047bab550ff1647a130cc5..5b32fd2d1987245ed1e7f76f58f142873fb801a7 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let j = |&:| -> isize {
+    let j = || -> isize {
         let i: isize;
         i //~ ERROR use of possibly uninitialized variable: `i`
     };
index 31ca39c3f9b36772a15acd3d81c7908625c55c66..65f1a1fa098aeee2fbf521b420c4e5d18ba9fcca 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let f  = |&:| -> isize {
+    let f  = || -> isize {
         let i: isize;
         i //~ ERROR use of possibly uninitialized variable: `i`
     };
index 4e7d81a1cb0cc5f4f526149f8813c1bad72e2bb3..f9d24130e47afdbe5f9c95588ac9a5bb62d054cf 100644 (file)
@@ -21,7 +21,7 @@ pub fn main() {
         Foo { string: "bar".to_string() },
         Foo { string: "baz".to_string() }
     );
-    let x: &[Foo] = x.as_slice();
+    let x: &[Foo] = &x;
     match x {
         [_, tail..] => {
             match tail {
index b8a92db4e422334eca533c5c27702df16e9bf831..9341758afd82e279c7b125fe6912e16a63116623 100644 (file)
@@ -14,5 +14,5 @@ fn write(v: &mut [isize]) {
 
 fn main() {
     let v = vec!(1, 2, 3);
-    write(v.as_mut_slice()); //~ ERROR cannot borrow
+    write(&mut v); //~ ERROR cannot borrow
 }
index 9193a28511e70e069a540969b9048b168d7d9875..977c67b1c7dbd073b03c2f53b238010433c982b9 100644 (file)
@@ -22,7 +22,7 @@ impl Index<String> for Foo {
     type Output = isize;
 
     fn index<'a>(&'a self, z: &String) -> &'a isize {
-        if z.as_slice() == "x" {
+        if *z == "x" {
             &self.x
         } else {
             &self.y
@@ -34,7 +34,7 @@ impl IndexMut<String> for Foo {
     type Output = isize;
 
     fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut isize {
-        if z.as_slice() == "x" {
+        if *z == "x" {
             &mut self.x
         } else {
             &mut self.y
index 7259ca8971d2b6ca363c47349679cfb9d355110d..9e79154eb0c5cde893bf917e93551baef80b11c4 100644 (file)
@@ -19,7 +19,7 @@ impl Index<String> for Foo {
     type Output = isize;
 
     fn index<'a>(&'a self, z: &String) -> &'a isize {
-        if z.as_slice() == "x" {
+        if *z == "x" {
             &self.x
         } else {
             &self.y
@@ -31,7 +31,7 @@ impl IndexMut<String> for Foo {
     type Output = isize;
 
     fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut isize {
-        if z.as_slice() == "x" {
+        if *z == "x" {
             &mut self.x
         } else {
             &mut self.y
index c3a1e808e37f8aa5381ea83c85e9129e849655fd..7093da6803ca5754d69aa7a93749d6a4ac9c42fa 100644 (file)
@@ -32,7 +32,7 @@ fn foo() {
 
 fn bar() {
     // Original borrow ends at end of closure
-    |&:| {
+    || {
         let mut x = 1us;
         let y = &mut x;
         let z = &mut x; //~ ERROR cannot borrow
index 577334cce95042c53ef2c267e37c6720ed9f1683..2d6a4b7d2c9df023f55075450f18727d43bf27b3 100644 (file)
@@ -12,7 +12,7 @@
 
 fn a<'a>() -> &'a [isize] {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[isize] = vec.as_slice(); //~ ERROR does not live long enough
+    let vec: &[isize] = &vec; //~ ERROR does not live long enough
     let tail = match vec {
         [_, tail..] => tail,
         _ => panic!("a")
@@ -22,7 +22,7 @@ fn a<'a>() -> &'a [isize] {
 
 fn b<'a>() -> &'a [isize] {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[isize] = vec.as_slice(); //~ ERROR does not live long enough
+    let vec: &[isize] = &vec; //~ ERROR does not live long enough
     let init = match vec {
         [init.., _] => init,
         _ => panic!("b")
@@ -32,7 +32,7 @@ fn b<'a>() -> &'a [isize] {
 
 fn c<'a>() -> &'a [isize] {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[isize] = vec.as_slice(); //~ ERROR does not live long enough
+    let vec: &[isize] = &vec; //~ ERROR does not live long enough
     let slice = match vec {
         [_, slice.., _] => slice,
         _ => panic!("c")
index 565b8ca2f6856d7000acb007581ea1acf4ebb231..c1906758a5ae89586c8531770d9bbbc56abc856a 100644 (file)
@@ -10,7 +10,7 @@
 
 fn a() {
     let mut v = vec!(1, 2, 3);
-    let vb: &mut [isize] = v.as_mut_slice();
+    let vb: &mut [isize] = &mut v;
     match vb {
         [_a, tail..] => {
             v.push(tail[0] + tail[1]); //~ ERROR cannot borrow
index e125d777371c8dbaad20946459507c716984352d..b574507081713a04e5148e5a46e89ad08659f98f 100644 (file)
@@ -22,7 +22,7 @@ fn a() {
 
 fn b() {
     let mut vec = vec!(box 1, box 2, box 3);
-    let vec: &mut [Box<isize>] = vec.as_mut_slice();
+    let vec: &mut [Box<isize>] = &mut vec;
     match vec {
         [_b..] => {
             vec[0] = box 4; //~ ERROR cannot assign
@@ -32,7 +32,7 @@ fn b() {
 
 fn c() {
     let mut vec = vec!(box 1, box 2, box 3);
-    let vec: &mut [Box<isize>] = vec.as_mut_slice();
+    let vec: &mut [Box<isize>] = &mut vec;
     match vec {
         [_a,         //~ ERROR cannot move out
          _b..] => {  //~^ NOTE attempting to move value to here
@@ -50,7 +50,7 @@ fn c() {
 
 fn d() {
     let mut vec = vec!(box 1, box 2, box 3);
-    let vec: &mut [Box<isize>] = vec.as_mut_slice();
+    let vec: &mut [Box<isize>] = &mut vec;
     match vec {
         [_a..,     //~ ERROR cannot move out
          _b] => {} //~ NOTE attempting to move value to here
@@ -61,7 +61,7 @@ fn d() {
 
 fn e() {
     let mut vec = vec!(box 1, box 2, box 3);
-    let vec: &mut [Box<isize>] = vec.as_mut_slice();
+    let vec: &mut [Box<isize>] = &mut vec;
     match vec {
         [_a, _b, _c] => {}  //~ ERROR cannot move out
         //~^ NOTE attempting to move value to here
index bcd1aa81d4c2ec68c96c78a549c9085ba3ff2568..df0fee437b94ab93ef87107bd71f5eca0fd06c19 100644 (file)
@@ -10,7 +10,7 @@
 
 fn a<'a>() -> &'a isize {
     let vec = vec!(1, 2, 3, 4);
-    let vec: &[isize] = vec.as_slice(); //~ ERROR `vec` does not live long enough
+    let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough
     let tail = match vec {
         [_a, tail..] => &tail[0],
         _ => panic!("foo")
index 738755855c0703211532b79c82ce43e92581bebc..e59bd62d178549133ae66fe02cd04cc1cb21bbba 100644 (file)
@@ -14,10 +14,10 @@ fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
 
 fn main() {
     let x = 1;
-    to_fn_once(move|:| { x = 2; });
+    to_fn_once(move|| { x = 2; });
     //~^ ERROR: cannot assign to immutable captured outer variable
 
     let s = std::old_io::stdin();
-    to_fn_once(move|:| { s.read_to_end(); });
+    to_fn_once(move|| { s.read_to_end(); });
     //~^ ERROR: cannot borrow immutable captured outer variable
 }
index ef01c96addeb8f555f4ba26919e7f3b65b73c961..d2295eba6d7a41f99fc288e116dcbf2ab72d669d 100644 (file)
@@ -17,7 +17,7 @@ fn call_bare(f: fn(&str)) {
 
 fn main() {
     let string = "world!";
-    let f = |&: s: &str| println!("{}{}", s, string);
+    let f = |s: &str| println!("{}{}", s, string);
     call_bare(f)    //~ ERROR mismatched types
 }
 
index 46f5f41d7282f89254c2c022629204c0aefe2f39..280e2ed095266f54f943de374503a38a86bc62f7 100644 (file)
@@ -13,7 +13,7 @@
 #![deny(unreachable_code)]
 
 fn main() {
-    let x = |:| panic!();
+    let x = || panic!();
     x();
     std::io::println("Foo bar"); //~ ERROR: unreachable statement
 }
index 5335fa1206dbbf4685c2712b95508cc9c1317405..6e64e01d7410d2858315a2e6e3f4d462f8abe5f3 100644 (file)
@@ -13,12 +13,12 @@ fn wants_slice(x: &str) { }
 
 fn has_uniq(x: String) {
    wants_uniq(x);
-   wants_slice(x.as_slice());
+   wants_slice(&*x);
 }
 
 fn has_slice(x: &str) {
    wants_uniq(x); //~ ERROR mismatched types
-   wants_slice(x);
+   wants_slice(x.as_slice());
 }
 
 fn main() {
index f8e7dc11828ff4f304a0bcef0ccbdacb728e6b7f..71e1f7091b2c99094e9459e64ba25fe261906ecc 100644 (file)
 fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}
 
 fn main() {
-    let _: () = (box |:_: isize| {}) as Box<FnOnce(isize)>;
+    let _: () = (box |_: isize| {}) as Box<FnOnce(isize)>;
     //~^ ERROR object-safe
     //~| ERROR mismatched types
     //~| expected `()`
     //~| found `Box<core::ops::FnOnce(isize)>`
     //~| expected ()
     //~| found box
-    let _: () = (box |&:_: isize, isize| {}) as Box<Fn(isize, isize)>;
+    let _: () = (box |_: isize, isize| {}) as Box<Fn(isize, isize)>;
     //~^ ERROR mismatched types
     //~| expected `()`
     //~| found `Box<core::ops::Fn(isize, isize)>`
     //~| expected ()
     //~| found box
-    let _: () = (box |&mut:| -> isize unimplemented!()) as Box<FnMut() -> isize>;
+    let _: () = (box || -> isize unimplemented!()) as Box<FnMut() -> isize>;
     //~^ ERROR mismatched types
     //~| expected `()`
     //~| found `Box<core::ops::FnMut() -> isize>`
index 99927d8b9bf5518d5bfee7903441443f6996de5b..949c1c0d9c436759fdbf78576794d92e4422ff7a 100644 (file)
@@ -14,7 +14,7 @@ fn f(y: Box<isize>) {
 }
 
 fn g() {
-    let _frob = |&: q: Box<isize>| { *q = 2; }; //~ ERROR cannot assign
+    let _frob = |q: Box<isize>| { *q = 2; }; //~ ERROR cannot assign
 
 }
 
index ef651dd9ce7293d24df0f468a9a62ba8cbb39f9b..88dd63384b7100dffa3364f49c6a763688d57358 100644 (file)
 pub fn main() {
     let v: Vec<isize> = vec!(0, 1, 2, 3, 4, 5);
     let s: String = "abcdef".to_string();
-    v.as_slice()[3us];
-    v.as_slice()[3];
-    v.as_slice()[3u8];  //~ERROR the trait `core::ops::Index<u8>` is not implemented
+    v[3us];
+    v[3];
+    v[3u8];  //~ERROR the trait `core::ops::Index<u8>` is not implemented
     //~^ ERROR the trait `core::ops::Index<u8>` is not implemented
-    v.as_slice()[3i8];  //~ERROR the trait `core::ops::Index<i8>` is not implemented
+    v[3i8];  //~ERROR the trait `core::ops::Index<i8>` is not implemented
     //~^ ERROR the trait `core::ops::Index<i8>` is not implemented
-    v.as_slice()[3u32]; //~ERROR the trait `core::ops::Index<u32>` is not implemented
+    v[3u32]; //~ERROR the trait `core::ops::Index<u32>` is not implemented
     //~^ ERROR the trait `core::ops::Index<u32>` is not implemented
-    v.as_slice()[3i32]; //~ERROR the trait `core::ops::Index<i32>` is not implemented
+    v[3i32]; //~ERROR the trait `core::ops::Index<i32>` is not implemented
     //~^ ERROR the trait `core::ops::Index<i32>` is not implemented
     s.as_bytes()[3us];
     s.as_bytes()[3];
index 5ee693d97a878febbd8d97a53ba579ec0eb64526..736f9630127121e23bd24340114c5700f4102656 100644 (file)
@@ -12,7 +12,7 @@
 
 fn main() {
     let x = box 1;
-    let f = move|:| {
+    let f = move|| {
         let _a = x;
         drop(x);
         //~^ ERROR: use of moved value: `x`
index 0d7a846bff633d8c7969ae93240e5837092889ca..a95bcc73a9c473adf98a2ac38839dfdeaf42ee73 100644 (file)
@@ -22,7 +22,7 @@ fn drop(&mut self) {
 
 fn main() {
     let mut ptr = box Foo { x: 0 };
-    let mut test = |&mut: foo: &Foo| {
+    let mut test = |foo: &Foo| {
         println!("access {}", foo.x);
         ptr = box Foo { x: ptr.x + 1 };
         println!("access {}", foo.x);
index aa2a71ca2dbbf51bebdf9dec83476e707f16fc3e..6dbea33d7d5d0aa59cce195851f6b1166764c740 100644 (file)
@@ -33,5 +33,5 @@ pub fn for_stdin<'a>() -> Container<'a> {
 fn main() {
     let mut c = for_stdin();
     let mut v = Vec::new();
-    c.read_to(v.as_mut_slice());
+    c.read_to(v);
 }
index f9a523641e41e1dbef4377388c1fa82fc5aab0cd..38956944f63e637a06eb70a445125ccd10b40084 100644 (file)
@@ -10,7 +10,7 @@
 
 fn main() {
     let mut v = vec!(1);
-    let mut f = |&mut:| v.push(2);
+    let mut f = || v.push(2);
     let _w = v; //~ ERROR: cannot move out of `v`
 
     f();
index 0587bdf6136b8ffe4e4b0af7c7eb0e59bbc566d7..9a471a4341f5f1706bfc9a9458c264b1e9fbef44 100644 (file)
@@ -10,7 +10,7 @@
 
 fn main() {
     let sl = vec![1,2,3];
-    let v: isize = match sl.as_slice() {
+    let v: isize = match &*sl {
         [] => 0,
         [a,b,c] => 3,
         [a, rest..] => a,
index 7080db23d42e521c8b42ddb609579128603a24d8..13a5fa4b8af5af16ad60efb1adc04de9e764e358 100644 (file)
@@ -14,7 +14,7 @@ pub fn foo(params: Option<&[&str]>) -> usize {
 
 fn main() {
     let name = "Foo";
-    let x = Some(&[name.as_slice()]);
+    let x = Some(&[name]);
     let msg = foo(x);
 //~^ ERROR mismatched types
 //~| expected `core::option::Option<&[&str]>`
index 9d2212b69cee116de1d270b87f1010416b4ab45a..7ec3fef5c878eb05a060356e60fa5b169b03392c 100644 (file)
@@ -14,7 +14,7 @@
 // wrong arity.
 
 fn _foo<F: Fn()> (f: F) {
-    |&: t| f(t); //~ ERROR E0057
+    |t| f(t); //~ ERROR E0057
 }
 
 fn main() {}
index 3889b6f4f7dceca1d9d261603bdddfe69d598a30..b19a7703b85605e49bbc807bec3c1edd0159ff02 100644 (file)
@@ -14,5 +14,5 @@
 
 fn main() {
     let foo = B;
-    let closure = |:| foo; //~ ERROR unable to infer enough type information
+    let closure = || foo; //~ ERROR unable to infer enough type information
 }
index fbecd0487bf6f5d7811752cfd71c9a24a3d12e80..1cdf48e291c755e6efb727f780d31a727e26a315 100644 (file)
@@ -14,7 +14,7 @@
 #![feature(box_syntax)]
 
 fn main() {
-    (|&:| box *[0us].as_slice())();
+    (|| box *[0us].as_slice())();
     //~^ ERROR cannot move out of borrowed content
     //~^^ ERROR cannot move a value of type [usize]
 }
index 9c708bdeaa8093fe68ac0c30ef32f5c7616e6ea7..83e52216be29baa371506ac14f26f106294db121 100644 (file)
@@ -100,7 +100,7 @@ impl TraversesWorld for Player {
 impl Debug for Player {
     fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> {
         formatter.write_str("Player{ name:");
-        formatter.write_str(self.name.as_slice());
+        formatter.write_str(&self.name);
         formatter.write_str(" }");
         Ok(())
     }
index 45b7bebfc281e904465d3d7174b09d98cfcb4731..37dbcaf39bd10ba17c99dfdc6c30f9a243a3a851 100644 (file)
@@ -20,6 +20,6 @@ fn bind<B, F>(&self, mut f: F) where F: FnMut(A) -> Vec<B> {
    }
 }
 fn main() {
-    ["hi"].bind(|&mut: x| [x] );
+    ["hi"].bind(|x| [x] );
     //~^ ERROR type `[&str; 1]` does not implement any method in scope named `bind`
 }
index c67d6b1ce8f7ce17e063dcc42ab31835527ca254..0f7cc2cb72b8e2b05b73dcb6456119e3ade48d33 100644 (file)
@@ -11,7 +11,7 @@
 
 fn main() {
     let needlesArr: Vec<char> = vec!('a', 'f');
-    needlesArr.iter().fold(|&: x, y| {
+    needlesArr.iter().fold(|x, y| {
     });
     //~^^ ERROR this function takes 2 parameters but 1 parameter was supplied
     //
index 7ebc5b7a5b96bf3757311379e0ac7aa5ee2ce235..0e1cc18dba910f373767b697787be67bfe32a3e2 100644 (file)
@@ -10,7 +10,7 @@
 
 trait A {
     fn a(&self) {
-        |&:| self.b()
+        || self.b()
         //~^ ERROR type `&Self` does not implement any method in scope named `b`
         //~| ERROR mismatched types
         //~| expected `()`
index 3d44c1a52d49253fceb0a9476dad591cd465c7d0..d0da51373d926fe599ee84da402673be3913f5d9 100644 (file)
@@ -14,7 +14,7 @@
 fn id<T>(t: T) -> T { t }
 
 fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {
-    id(box |&mut:| *v) //~ ERROR cannot infer
+    id(box || *v) //~ ERROR cannot infer
 }
 
 fn main() {
index 0eaa40efca22bda731c6b7ae5a66ba0d19fac370..49a43ee37adca88d9ec5224a79b161945a0354f0 100644 (file)
@@ -11,6 +11,6 @@
 // Regression test for issue #5239
 
 fn main() {
-    let x = |&: ref x: isize| -> isize { x += 1; };
+    let x = |ref x: isize| -> isize { x += 1; };
     //~^ ERROR binary assignment operation `+=` cannot be applied to type `&isize`
 }
index 9424ff22dc75ce971e9e68fdf571a7f12441ad0e..9e797019392450e201d0958e24809a6e031e03a8 100644 (file)
@@ -24,7 +24,7 @@ fn invoke<F>(f: F) where F: FnOnce() -> usize {
 
 fn main() {
       let x  : Box<usize>  = box 9;
-      let sq =  |:| { *x * *x };
+      let sq =  || { *x * *x };
 
       twice(x); //~ ERROR: cannot move out of
       invoke(sq);
index c15c556f5d68f2bc7eb0b07e4386a2c4c3da1794..2d1cea1d44b746698ff438f6db9d2edc3d69161d 100644 (file)
@@ -25,7 +25,7 @@ fn new(s: &str) -> CrateId {
 
 pub fn remove_package_from_database() {
     let mut lines_to_use: Vec<&CrateId> = Vec::new();
-    let push_id = |&mut: installed_id: &CrateId| {
+    let push_id = |installed_id: &CrateId| {
         lines_to_use.push(installed_id);
         //~^ ERROR cannot infer an appropriate lifetime for automatic coercion due to
         // conflicting requirements
index ddba7b58afaab6e5ad68c5acc3a34cb95570c747..dcc82b8920ff5b51245b6fb52880011da181e6fb 100644 (file)
@@ -35,7 +35,7 @@ fn main() {
       _ => {}
     }
 
-    let x = |&: mut y: isize| 10; //~ ERROR: variable does not need to be mutable
+    let x = |mut y: isize| 10; //~ ERROR: variable does not need to be mutable
     fn what(mut foo: isize) {} //~ ERROR: variable does not need to be mutable
 
     // positive cases
@@ -65,7 +65,7 @@ fn what(mut foo: isize) {} //~ ERROR: variable does not need to be mutable
       _ => {}
     }
 
-    let x = |&mut: mut y: isize| y = 32;
+    let x = |mut y: isize| y = 32;
     fn nothing(mut foo: isize) { foo = 37; }
 
     // leading underscore should avoid the warning, just like the
index 6dcf1fdee83028c5a4ceec06c42b6b51ec1b2622..06af8ac8719e57b539496912b1a825860f4947f6 100644 (file)
@@ -16,14 +16,14 @@ pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
     if maybestr.is_none() {
         "(none)"
     } else {
-        let s: &'a str = maybestr.as_ref().unwrap().as_slice();
+        let s: &'a str = maybestr.as_ref().unwrap();
         s
     }
 }
 
 pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
     if maybestr.is_some() {
-        let s: &'a str = maybestr.as_ref().unwrap().as_slice();
+        let s: &'a str = maybestr.as_ref().unwrap();
         s
     } else {
         "(none)"
@@ -34,14 +34,14 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
     if maybestr.is_none() {
         "(none)"
     } else {
-        let s: &'a str = maybestr.as_ref().unwrap().as_slice();
+        let s: &'a str = maybestr.as_ref().unwrap();
         s  //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to conflicting
     }
 }
 
 pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
     if maybestr.is_some() {
-        let s: &'a str = maybestr.as_ref().unwrap().as_slice();
+        let s: &'a str = maybestr.as_ref().unwrap();
         s  //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to conflicting
     } else {
         "(none)"
index 1939df2877b82da4e20b754d739a593d3a6d42bc..1b5824964a8eb53b44a45bd5a82fb43af5e0bdc4 100644 (file)
@@ -15,7 +15,7 @@
 pub fn opt_str0<'a>(maybestr: &'a Option<String>) -> &'a str {
     match *maybestr {
         Some(ref s) => {
-            let s: &'a str = s.as_slice();
+            let s: &'a str = s;
             s
         }
         None => "(none)",
@@ -26,7 +26,7 @@ pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
     match *maybestr {
         None => "(none)",
         Some(ref s) => {
-            let s: &'a str = s.as_slice();
+            let s: &'a str = s;
             s
         }
     }
@@ -36,7 +36,7 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
     match *maybestr {
         None => "(none)",
         Some(ref s) => {
-            let s: &'a str = s.as_slice();
+            let s: &'a str = s;
             s
             //~^ ERROR cannot infer an appropriate lifetime
         }
@@ -46,7 +46,7 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
 pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
     match *maybestr {
         Some(ref s) => {
-            let s: &'a str = s.as_slice();
+            let s: &'a str = s;
             s
             //~^ ERROR cannot infer an appropriate lifetime
         }
index e2671552b43497b289ba9e4a5530ab250e54df5d..2c63438cbf3af4ef6dceb833fc4f9105251441d5 100644 (file)
@@ -11,7 +11,7 @@
 
 fn main() {
     let x: Vec<(isize, isize)> = Vec::new();
-    let x: &[(isize, isize)] = x.as_slice();
+    let x: &[(isize, isize)] = &x;
     match x {
         [a, (2, 3), _] => (),
         [(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
@@ -21,7 +21,7 @@ fn main() {
     let x: Vec<String> = vec!["foo".to_string(),
                               "bar".to_string(),
                               "baz".to_string()];
-    let x: &[String] = x.as_slice();
+    let x: &[String] = &x;
     match x {
         [a, _, _, ..] => { println!("{}", a); }
         [_, _, _, _, _] => { } //~ ERROR unreachable pattern
@@ -29,7 +29,7 @@ fn main() {
     }
 
     let x: Vec<char> = vec!('a', 'b', 'c');
-    let x: &[char] = x.as_slice();
+    let x: &[char] = &x;
     match x {
         ['a', 'b', 'c', _tail..] => {}
         ['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
index c9f73e86a2c4609bbdef09487aa198f1f650030c..9ad44567a41f2371ba4510731b5137b843c419a1 100644 (file)
@@ -95,7 +95,7 @@ fn f110() {
 
 fn f120() {
     let mut x = vec!("hi".to_string(), "ho".to_string());
-    x.as_mut_slice().swap(0, 1);
+    x.swap(0, 1);
     touch(&x[0]);
     touch(&x[1]);
 }
index fce72f507b6fc56ba3057978808134358709e7de..1dec049aed5e66ce262aa78ecf0917492e08db42 100644 (file)
@@ -36,20 +36,20 @@ fn main() {
       (t::b, t::b) => {}
     }
     let vec = vec!(Some(42), None, Some(21));
-    let vec: &[Option<isize>] = vec.as_slice();
+    let vec: &[Option<isize>] = &vec;
     match vec { //~ ERROR non-exhaustive patterns: `[]` not covered
         [Some(..), None, tail..] => {}
         [Some(..), Some(..), tail..] => {}
         [None] => {}
     }
     let vec = vec!(1);
-    let vec: &[isize] = vec.as_slice();
+    let vec: &[isize] = &vec;
     match vec {
         [_, tail..] => (),
         [] => ()
     }
     let vec = vec!(0.5f32);
-    let vec: &[f32] = vec.as_slice();
+    let vec: &[f32] = &vec;
     match vec { //~ ERROR non-exhaustive patterns: `[_, _, _, _]` not covered
         [0.1, 0.2, 0.3] => (),
         [0.1, 0.2] => (),
@@ -57,7 +57,7 @@ fn main() {
         [] => ()
     }
     let vec = vec!(Some(42), None, Some(21));
-    let vec: &[Option<isize>] = vec.as_slice();
+    let vec: &[Option<isize>] = &vec;
     match vec {
         [Some(..), None, tail..] => {}
         [Some(..), Some(..), tail..] => {}
index 6b6ab3f29701953fc326385f8be4464df2092077..82425d2c22708760bc5d67ecc4683615de8b1836 100644 (file)
@@ -32,6 +32,6 @@ fn main() {
     let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
     unsafe {
         let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
-        println!("{:?} {:?}", &oof.rab[], oof.zab);
+        println!("{:?} {:?}", &oof.rab[..], oof.zab);
     }
 }
index 53f923e5061967a2c809eb103fa3d70d614fe29f..be42f0f0ed8837dd5f4c7d6c7b57d34098658554 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let f = |&: 3: isize| println!("hello");
+    let f = |3: isize| println!("hello");
     //~^ ERROR refutable pattern in function argument: `_` not covered
     f(4);
 }
index 5b04fa3d87ca5e97c2492e2733a7e32e165d3471..9f35c636b4526e18a95dd3b3c22ffd1e52dd9cf1 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn call_rec<F>(mut f: F) -> usize where F: FnMut(usize) -> usize {
-    (|&mut: x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f`
+    (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f`
 }
 
 fn main() {}
index cdaa3468a463cd7792ae765e1fae1988292feba8..9418156ffcd086ee6560431c84ac400f9b42de33 100644 (file)
@@ -17,7 +17,7 @@ fn main() {
     {
         let c = 1;
         let c_ref = &c; //~ ERROR `c` does not live long enough
-        f = move |&mut: a: isize, b: isize| { a + b + *c_ref };
+        f = move |a: isize, b: isize| { a + b + *c_ref };
     }
 }
 
index fa76ab758ab568a96ab55e9adc7487a69c8c45ba..70d5fe83055d35bf9ad03437bbdc4aa0044de9ae 100644 (file)
@@ -16,7 +16,7 @@ struct dog {
 
 impl dog {
     pub fn chase_cat(&mut self) {
-        let _f = |&:| {
+        let _f = || {
             let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer
             *p = 3us;
         };
index 06768fa68804c8506d2260fa849cbd0453179703..abbefd254888b3b8d8264cf36955bb89a7b643da 100644 (file)
@@ -15,5 +15,5 @@ fn with_int(f: &mut FnMut(&isize)) {
 
 fn main() {
     let mut x: Option<&isize> = None;
-    with_int(&mut |&mut: y| x = Some(y));   //~ ERROR cannot infer
+    with_int(&mut |y| x = Some(y));   //~ ERROR cannot infer
 }
index f43d35c579e25721c22016b3d9ec878384a1a73f..323d5360029c581b44ddb3734bb98f2ce022df82 100644 (file)
@@ -35,5 +35,5 @@ pub fn set_desc(self, s: &str) -> Flag<'a> {
 fn main () {
     let f : argparse::Flag = argparse::flag("flag", "My flag");
     let updated_flag = f.set_desc("My new flag");
-    assert_eq!(updated_flag.desc.as_slice(), "My new flag");
+    assert_eq!(updated_flag.desc, "My new flag");
 }
index 3f722c9433bb263a0ec5ef38312a08d132ecfaaf..57ea607cbf623f0cdd5c0bc9b4475a4ab8afb7eb 100644 (file)
@@ -12,7 +12,7 @@ fn assert_send<T: Send>(_t: T) {}
 
 fn main() {
     let line = String::new();
-    match [line.as_slice()] { //~ ERROR `line` does not live long enough
+    match [&*line] { //~ ERROR `line` does not live long enough
         [ word ] => { assert_send(word); }
     }
 }
index 21586f78db3424afca54de42a9fb54149de8624f..2e3531a2e8f2637ab661aa159731172ea4263bca 100644 (file)
@@ -16,7 +16,7 @@ fn main() {
     // Unboxed closure case
     {
         let mut x = 0us;
-        let mut f = |&mut:| &mut x; //~ ERROR cannot infer
+        let mut f = || &mut x; //~ ERROR cannot infer
         let x = f();
         let y = f();
     }
index 903760caf1a1eb64bf73184e490c8ed8e24e1d72..23ad5b09950effba47277fc56bf1533bb6b3f49e 100644 (file)
@@ -8,12 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Test slicing expr[..] is an error and gives a helpful error message.
+// Test slicing &expr[] is deprecated and gives a helpful error message.
+//
+// ignore-test
 
 struct Foo;
 
 fn main() {
     let x = Foo;
-    &x[..]; //~ ERROR incorrect slicing expression: `[..]`
-    //~^ NOTE use `&expr[]` to construct a slice of the whole of expr
+    &x[]; //~ WARNING deprecated slicing syntax: `[]`
+          //~^ NOTE use `&expr[..]` to construct a slice of the whole of expr
+          //~^^ ERROR cannot index a value of type `Foo`
 }
index 07162293565ed2c9e3f93e4d89521212497bda44..99dc3e68c8f796d47f78ea644932096619e7dfab 100644 (file)
@@ -14,7 +14,7 @@
 
 fn main() {
     let x = Foo;
-    &x[]; //~ ERROR cannot index a value of type `Foo`
+    &x[..]; //~ ERROR cannot index a value of type `Foo`
     &x[Foo..]; //~ ERROR cannot index a value of type `Foo`
     &x[..Foo]; //~ ERROR cannot index a value of type `Foo`
     &x[Foo..Foo]; //~ ERROR cannot index a value of type `Foo`
index 9c78d7ea2439aa782d689793c93dde9dd52c643b..7b426a4c0331545da4961f70a408d13627fdb7cd 100644 (file)
@@ -26,7 +26,7 @@ fn f(&self, x: &'static str) {
 
 fn main() {
     let person = "Fred".to_string();
-    let person: &str = person.as_slice();  //~ ERROR `person` does not live long enough
+    let person: &str = &person;  //~ ERROR `person` does not live long enough
     let s: Box<Trait<&'static str>> = box Struct { person: person };
 }
 
index ebdd3c3107f3f58f871b01adf5a6744e2e40fd4e..145b2bfaeddfd70185844d794d5b5dd50245eaa8 100644 (file)
 
 fn main() {
     let x = 0us;
-    move |&mut:| x = 1; //~ ERROR cannot assign
-    move |&mut:| set(&mut x); //~ ERROR cannot borrow
-    move |:| x = 1; //~ ERROR cannot assign
-    move |:| set(&mut x); //~ ERROR cannot borrow
-    |&mut:| x = 1; //~ ERROR cannot assign
+    move || x = 1; //~ ERROR cannot assign
+    move || set(&mut x); //~ ERROR cannot borrow
+    move || x = 1; //~ ERROR cannot assign
+    move || set(&mut x); //~ ERROR cannot borrow
+    || x = 1; //~ ERROR cannot assign
     // FIXME: this should be `cannot borrow` (issue #18330)
-    |&mut:| set(&mut x); //~ ERROR cannot assign
-    |:| x = 1; //~ ERROR cannot assign
+    || set(&mut x); //~ ERROR cannot assign
+    || x = 1; //~ ERROR cannot assign
     // FIXME: this should be `cannot borrow` (issue #18330)
-    |:| set(&mut x); //~ ERROR cannot assign
+    || set(&mut x); //~ ERROR cannot assign
 }
index 9d9667986949ead5c27afaf8560ed5cad542f254..98ac54de8ad78e6ec5279198210f5196745ebfda 100644 (file)
@@ -15,6 +15,6 @@
 fn main() {
     let _f = {
         let x = 0us;
-        |:| x //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
+        || x //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
     };
 }
index bb92e57d70c0e7d3bacbe73d91cf0d390cf3bbfe..0bdc261e8c88d35b08b1423a81326e63083dddfc 100644 (file)
@@ -15,6 +15,6 @@
 
 fn main() {
     let mut x = 0us;
-    let f = |:| x += 1;
+    let f = || x += 1;
     let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
 }
index ef6c439aeb89d97e0f0f522b165df59fc8f8a349..3dd5779914d06b63d26432eb66a69ab045c2ebd5 100644 (file)
@@ -23,7 +23,7 @@ fn doit<T,F>(val: T, f: &F)
 }
 
 pub fn main() {
-    doit(0, &|&: x, y| {
+    doit(0, &|x, y| {
         x.set(y); //~ ERROR cannot infer
     });
 }
index f7ac2274ffb3a60ce97863951a0911a9ea708e82..e1192b22485c6450dfc4f4d3e3ba03723408d3d6 100644 (file)
@@ -13,7 +13,7 @@
 use std::ops::FnMut;
 
 pub fn main() {
-    let mut f = |&mut: x: isize, y: isize| -> isize { x + y };
+    let mut f = |x: isize, y: isize| -> isize { x + y };
     let z = f(1us, 2);    //~ ERROR mismatched types
     println!("{}", z);
 }
index 87ea56c055350da70ec7481e6a826ebf8df43252..d4dc58864ad827d9e5ea28e426c7319d8beadc6b 100644 (file)
@@ -13,5 +13,5 @@
 fn main() {
     let mut x = 1;
     //~^ ERROR: variable does not need to be mutable
-    move|:| { println!("{}", x); };
+    move|| { println!("{}", x); };
 }
index 59428a2c06f5218e819b255cd04e57e59485d3ab..ea684b1d69c523b97f48d68a6c57c10d620d5e83 100644 (file)
@@ -51,7 +51,7 @@
 
 fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) {
 
-    let closure = |&: x, y| {
+    let closure = |x, y| {
         zzz(); // #break
         (y, x)
     };
index 5e04c81cefd7657000eb81bbd0625f5e11d2659b..fb4378d5e8beca68a11c3a6ec569ccb2c7dec547 100644 (file)
@@ -18,7 +18,7 @@
 
 // Nothing to do here really, just make sure it compiles. See issue #8513.
 fn main() {
-    let _ = |&:|();
+    let _ = ||();
     let _ = (1u..3).map(|_| 5);
 }
 
index f2d092216697ff25c543c4f380daff04703f4a23..6cb1218c1233a718f372ddcce6a4d93b7c7f111d 100644 (file)
@@ -79,7 +79,7 @@ fn main() {
     zzz(); // #break
     sentinel();
 
-    let closure = |&: x: int| {
+    let closure = |x: int| {
         zzz(); // #break
         sentinel();
 
index be4085b63abe51dcacd0261647af347d9aa1632b..ba660deeca01a25738224e848a5c2a05bd74d2e8 100644 (file)
@@ -80,7 +80,7 @@ fn main() {
     zzz(); // #break
     sentinel();
 
-    let unique_closure = |x:int| {
+    let unique_closure = |x:int| {
         zzz(); // #break
         sentinel();
 
index cb7e26327c3def2f52406095226ad97a03475a21..dd0d86bf742e6415adadd180bc6e836bfee08d05 100644 (file)
@@ -24,5 +24,5 @@ struct C { θ: u8 }
 
 fn main() {
     let x =  C { θ: 0 };
-    (|&: c: C| c.θ )(x);
+    (|c: C| c.θ )(x);
 }
index 24b6df4e8f1425abbdad1f1ab17ff20e9838b0b1..adc4711b49aa2367b040988f03b371e15bbd632f 100644 (file)
@@ -283,9 +283,9 @@ fn main() {
     let fixed_size_vec2 = ([0u, 1u, 2u], 0i16);
 
     let vec1 = vec![0u, 2u, 3u];
-    let slice1 = vec1.as_slice();
+    let slice1 = &*vec1;
     let vec2 = vec![Mod1::Variant2_2(Struct1)];
-    let slice2 = vec2.as_slice();
+    let slice2 = &*vec2;
 
     // Trait Objects
     let box_trait = (box 0) as Box<Trait1>;
@@ -322,8 +322,8 @@ fn main() {
     // how that maps to rustc's internal representation of these forms.
     // Once closures have reached their 1.0 form, the tests below should
     // probably be expanded.
-    let closure1 = (|&: x:isize| {}, 0u);
-    let closure2 = (|&: x:i8, y: f32| { (x as f32) + y }, 0u);
+    let closure1 = (|x:isize| {}, 0u);
+    let closure2 = (|x:i8, y: f32| { (x as f32) + y }, 0u);
 
     zzz(); // #break
 }
index d7831c983c05014781a8603c68ad91cab3e60d69..512df3605bfcdf2ef353c49a839d5555606a6d41 100644 (file)
@@ -101,10 +101,10 @@ fn main() {
     let struct_ref = &a_struct;
     let owned = box 6;
 
-    let mut closure = |&mut:| {
+    let mut closure = || {
         let closure_local = 8;
 
-        let mut nested_closure = |&mut:| {
+        let mut nested_closure = || {
             zzz(); // #break
             variable = constant + a_struct.a + struct_ref.a + *owned + closure_local;
         };
index 30a07ea46ddd3bcca1a7a46e478d54c34a9c28e5..b07c8ffde7f8ff1310340b9ed97459c6da046dd5 100644 (file)
@@ -61,7 +61,7 @@ fn main() {
 
     let owned = box 5;
 
-    let closure = move |:| {
+    let closure = move || {
         zzz(); // #break
         do_something(&constant, &a_struct.a, &*owned);
     };
@@ -73,7 +73,7 @@ fn main() {
     // The `self` argument of the following closure should be passed by value
     // to FnOnce::call_once(self, args), which gets translated a bit differently
     // than the regular case. Let's make sure this is supported too.
-    let immedate_env = move |:| {
+    let immedate_env = move || {
         zzz(); // #break
         return constant2;
     };
index 9daf6abba11436da90195a4c37f834dd5f548672..ee706c13634f0113aec3ea6ba1fa10d208807459 100644 (file)
@@ -94,7 +94,7 @@ fn main() {
     let owned = box 6;
 
     {
-        let mut first_closure = |&mut:| {
+        let mut first_closure = || {
             zzz(); // #break
             variable = constant + a_struct.a + struct_ref.a + *owned;
         };
@@ -103,7 +103,7 @@ fn main() {
     }
 
     {
-        let mut second_closure = |&mut:| {
+        let mut second_closure = || {
             zzz(); // #break
             variable = constant + a_struct.a + struct_ref.a + *owned;
         };
index 0cb73bc98a45aec9b71a07250abe3bad25a32f75..72e9c4849c62922f2c688956447807c30e06e0a7 100644 (file)
@@ -29,12 +29,12 @@ fn main() {
            idx as uint);
 
     // This should panic.
-    println!("ov3 0x%x",  x.as_slice()[idx]);
+    println!("ov3 0x%x",  x[idx]);
 }
 
 #[cfg(any(target_arch="x86_64", target_arch = "aarch64"))]
 fn main() {
     // 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]);
+    error!("ov3 0x%x",  x[200]);
 }
index 9fe07f82f9ed1495b13e4e4dcd2e092115b01b25..113717a776a99f8f533c6d77622170a747568e35 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 int foo() { return 0; }
index 9fe07f82f9ed1495b13e4e4dcd2e092115b01b25..113717a776a99f8f533c6d77622170a747568e35 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 int foo() { return 0; }
index bb4036b06e13b79a32ec78ae04db97590f54b2cc..5729d411c5bcd9a974e321a4a535e0b08c7dfc0b 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 void foo();
 
 int main() {
index bb4036b06e13b79a32ec78ae04db97590f54b2cc..5729d411c5bcd9a974e321a4a535e0b08c7dfc0b 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 void foo();
 
 int main() {
index 9fe07f82f9ed1495b13e4e4dcd2e092115b01b25..113717a776a99f8f533c6d77622170a747568e35 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 int foo() { return 0; }
index 9fe07f82f9ed1495b13e4e4dcd2e092115b01b25..113717a776a99f8f533c6d77622170a747568e35 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 int foo() { return 0; }
index f7c581172e2fe7069c3a32083ea771703bb97870..c8156b95dcfcb4d696db4a2f108a530b31a28f36 100644 (file)
@@ -17,8 +17,8 @@
 
 fn main() {
     let args = os::args();
-    let rustc = args[1].as_slice();
-    let tmpdir = Path::new(args[2].as_slice());
+    let rustc = &args[1];
+    let tmpdir = Path::new(&args[2]);
 
     let main_file = tmpdir.join("broken.rs");
     let _ = File::create(&main_file).unwrap()
@@ -31,12 +31,12 @@ fn main() {
     // can't exec it directly
     let result = Command::new("sh")
         .arg("-c")
-        .arg(format!("{} {}",
-                     rustc,
-                     main_file.as_str()
-                     .unwrap()).as_slice())
+        .arg(&format!("{} {}",
+                      rustc,
+                      main_file.as_str()
+                      .unwrap()))
         .output().unwrap();
-    let err = String::from_utf8_lossy(result.error.as_slice());
+    let err = String::from_utf8_lossy(&result.error);
 
     // positive test so that this test will be updated when the
     // compiler changes.
index f23dd1eb1462cffe054ec7165139c4bf4c71fd7d..f9faef64afc41a519832a2372d48e7cea401fad4 100644 (file)
@@ -1,16 +1,17 @@
+// ignore-license
 #include <stdint.h>
 
 typedef struct TestStruct {
-       uint8_t x;
-       int32_t y;
+        uint8_t x;
+        int32_t y;
 } TestStruct;
 
 typedef int callback(TestStruct s);
 
 uint32_t call(callback *c) {
-       TestStruct s;
-       s.x = 'a';
-       s.y = 3;
+        TestStruct s;
+        s.x = 'a';
+        s.y = 3;
 
-       return c(s);
+        return c(s);
 }
index 8d93917ade03ea4f8d1c67e8b54a80b725341abb..1a9855dedec490f85bcec3c5efc8212d19f44fb6 100644 (file)
@@ -1,8 +1,9 @@
+// ignore-license
 #include <stdint.h>
 
 uint32_t foo();
 uint32_t bar();
 
 uint32_t add() {
-       return foo() + bar();
+        return foo() + bar();
 }
index c3456a64b9bc40bdcbc7af04ba00be8f5e6e30e6..121e48e84e46fd8ba2fbbbbf1eb32c99f4859a37 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 // Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
 #pragma pack(1)
 struct __attribute__((packed)) Foo {
index 86cb64537236e1611f877a64a32a1b52d06c5904..8c87c230693d1d0d490d2028ac9b302f2c0d12f3 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 #include <stdio.h>
 #include <stdint.h>
 
index 812c97535287233599c6f936f6cd97be7f3ea5e6..c761f029effbec56ea1bf0e5a7690eb3f3baa57c 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 void foo();
 
 void bar() { foo(); }
index 85e6cd8c3909a7e67c41750f5210b1463dd7a90c..2895ad473bf966158015a0295e161767b673f29a 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 void foo() {}
index a58cd8bb7c98f32cba0afd0b60a4082884f01203..186a0046e80ac2dc6a9c56a245a247f80946083e 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 void some_c_symbol() {}
index 85e6cd8c3909a7e67c41750f5210b1463dd7a90c..2895ad473bf966158015a0295e161767b673f29a 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 void foo() {}
index 867008cd25917f75195f72b833ad69eaf2ed80e8..808417d6521eabb341ce6a27087cf76955f8c7ea 100644 (file)
@@ -28,9 +28,9 @@ fn main() {}
         panic!("expected rustc path");
     }
 
-    let tmpdir = Path::new(args[1].as_slice());
+    let tmpdir = Path::new(&args[1]);
 
-    let mut sysroot = Path::new(args[3].as_slice());
+    let mut sysroot = Path::new(&args[3]);
     sysroot.pop();
     sysroot.pop();
 
index 3064af952f898dd0af82955b866136b66867c114..a595939f92e8ceaed80490e0752c7472df873c63 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 int should_return_one() { return 1; }
index 64275b3ad6bb0f78f4edd2abee386e200c445bff..c53e7e3c48c058cdf12cf54043aa94e4882d71ec 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 int should_return_one() { return 0; }
index 78a6934f57f76766182836819f92e94c3d513a4c..d7d33ea12e8061544e43400232159f3fe500ecf8 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 #include <stdint.h>
 
 extern int32_t BAZ;
index bb4036b06e13b79a32ec78ae04db97590f54b2cc..5729d411c5bcd9a974e321a4a535e0b08c7dfc0b 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 void foo();
 
 int main() {
index e42599986781fe984a2c1427a3373cf439a34f60..3c167b45af98d47cac41dffb772ea7a054f83c94 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 void bar() {}
index e42599986781fe984a2c1427a3373cf439a34f60..3c167b45af98d47cac41dffb772ea7a054f83c94 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 void bar() {}
index 330d914a011e2955a3e663229950be2988bc0832..a7b02a2f10b635341d9dc9f3239a4f39fa3b6c60 100644 (file)
@@ -1,3 +1,4 @@
+// ignore-license
 extern void foo();
 
 void bar() { foo(); }
index 85e6cd8c3909a7e67c41750f5210b1463dd7a90c..2895ad473bf966158015a0295e161767b673f29a 100644 (file)
@@ -1 +1,2 @@
+// ignore-license
 void foo() {}
index cb3b3d9af38b2064500c0726aebfab1dd59b3239..3ede775b1197c53e12605e75b6ff39c7c1bf1d8e 100644 (file)
@@ -106,7 +106,7 @@ trait SomeTrait: SuperTrait {
     fn Method(&self, x: u32) -> u32;
 
     fn prov(&self, x: u32) -> u32 {
-        println(x.to_string().as_slice());
+        println(&x.to_string());
         42
     }
     fn provided_method(&self) -> u32 {
@@ -122,7 +122,7 @@ fn stat2(x: &Self) -> u32 {
 
 impl SomeTrait for some_fields {
     fn Method(&self, x: u32) -> u32 {
-        println(x.to_string().as_slice());
+        println(&x.to_string());
         self.field1
     }
 }
@@ -134,7 +134,7 @@ impl SubTrait for some_fields {}
 
 impl some_fields {
     fn stat(x: u32) -> u32 {
-        println(x.to_string().as_slice());
+        println(&x.to_string());
         42
     }
     fn stat2(x: &some_fields) -> u32 {
@@ -194,20 +194,20 @@ enum SomeStructEnum {
 
 fn matchSomeEnum(val: SomeEnum) {
     match val {
-        SomeEnum::Ints(int1, int2) => { println((int1+int2).to_string().as_slice()); }
-        SomeEnum::Floats(float1, float2) => { println((float2*float1).to_string().as_slice()); }
+        SomeEnum::Ints(int1, int2) => { println(&(int1+int2).to_string()); }
+        SomeEnum::Floats(float1, float2) => { println(&(float2*float1).to_string()); }
         SomeEnum::Strings(_, _, s3) => { println(s3); }
         SomeEnum::MyTypes(mt1, mt2) => {
-            println((mt1.field1 - mt2.field1).to_string().as_slice());
+            println(&(mt1.field1 - mt2.field1).to_string());
         }
     }
 }
 
 fn matchSomeStructEnum(se: SomeStructEnum) {
     match se {
-        SomeStructEnum::EnumStruct{a:a, ..} => println(a.to_string().as_slice()),
-        SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(f_2.field1.to_string().as_slice()),
-        SomeStructEnum::EnumStruct3{f1, ..} => println(f1.field1.to_string().as_slice()),
+        SomeStructEnum::EnumStruct{a:a, ..} => println(&a.to_string()),
+        SomeStructEnum::EnumStruct2{f1:f1, f2:f_2} => println(&f_2.field1.to_string()),
+        SomeStructEnum::EnumStruct3{f1, ..} => println(&f1.field1.to_string()),
     }
 }
 
@@ -215,9 +215,9 @@ fn matchSomeStructEnum(se: SomeStructEnum) {
 fn matchSomeStructEnum2(se: SomeStructEnum) {
     use SomeStructEnum::*;
     match se {
-        EnumStruct{a: ref aaa, ..} => println(aaa.to_string().as_slice()),
-        EnumStruct2{f1, f2: f2} => println(f1.field1.to_string().as_slice()),
-        EnumStruct3{f1, f3: SomeEnum::Ints(_, _), f2} => println(f1.field1.to_string().as_slice()),
+        EnumStruct{a: ref aaa, ..} => println(&aaa.to_string()),
+        EnumStruct2{f1, f2: f2} => println(&f1.field1.to_string()),
+        EnumStruct3{f1, f3: SomeEnum::Ints(_, _), f2} => println(&f1.field1.to_string()),
         _ => {},
     }
 }
@@ -233,12 +233,12 @@ fn matchSomeOtherEnum(val: SomeOtherEnum) {
 fn hello<X: SomeTrait>((z, a) : (u32, String), ex: X) {
     SameDir2::hello(43);
 
-    println(yy.to_string().as_slice());
+    println(&yy.to_string());
     let (x, y): (u32, u32) = (5, 3);
-    println(x.to_string().as_slice());
-    println(z.to_string().as_slice());
+    println(&x.to_string());
+    println(&z.to_string());
     let x: u32 = x;
-    println(x.to_string().as_slice());
+    println(&x.to_string());
     let x = "hello";
     println(x);
 
@@ -269,7 +269,7 @@ fn hello<X: SomeTrait>((z, a) : (u32, String), ex: X) {
     s4.provided_method();
     s2.prov(45);
 
-    let closure = |&: x: u32, s: &SomeTrait| {
+    let closure = |x: u32, s: &SomeTrait| {
         s.Method(23);
         return x + y;
     };
@@ -311,7 +311,7 @@ macro_rules! variable_str(($name:expr) => (
     let s3: some_fields = some_fields{ field1: 55};
     let s4: msalias::nested_struct = sub::sub2::nested_struct{ field2: 55};
     let s4: msalias::nested_struct = sub2::nested_struct{ field2: 55};
-    println(s2.field1.to_string().as_slice());
+    println(&s2.field1.to_string());
     let s5: MyType = box some_fields{ field1: 55};
     let s = SameDir::SameStruct{name: "Bob".to_string()};
     let s = SubDir::SubStruct{name:"Bob".to_string()};
index f9ffdffb4647ae98daace7106d7d5800d4633b73..be67e5a066acb90596256545070040c90e7b9d76 100644 (file)
@@ -34,8 +34,8 @@ fn random_char() -> char {
 
 fn main() {
     let args = os::args();
-    let rustc = args[1].as_slice();
-    let tmpdir = Path::new(args[2].as_slice());
+    let rustc = &args[1];
+    let tmpdir = Path::new(&args[2]);
 
     let main_file = tmpdir.join("unicode_input_multiple_files_main.rs");
     {
@@ -56,12 +56,12 @@ fn main() {
         // can't exec it directly
         let result = Command::new("sh")
                              .arg("-c")
-                             .arg(format!("{} {}",
-                                          rustc,
-                                          main_file.as_str()
-                                                   .unwrap()).as_slice())
+                             .arg(&format!("{} {}",
+                                           rustc,
+                                           main_file.as_str()
+                                                    .unwrap()))
                              .output().unwrap();
-        let err = String::from_utf8_lossy(result.error.as_slice());
+        let err = String::from_utf8_lossy(&result.error);
 
         // positive test so that this test will be updated when the
         // compiler changes.
index 9ee7516c7baeb91eadcf31be2f3e4ba5d4ee3186..95ce57da4e110c60c977e11a2857abf305340c80 100644 (file)
@@ -34,8 +34,8 @@ fn random_char() -> char {
 
 fn main() {
     let args = os::args();
-    let rustc = args[1].as_slice();
-    let tmpdir = Path::new(args[2].as_slice());
+    let rustc = &args[1];
+    let tmpdir = Path::new(&args[2]);
     let main_file = tmpdir.join("span_main.rs");
 
     for _ in 0u..100 {
@@ -52,18 +52,18 @@ fn main() {
         // can't exec it directly
         let result = Command::new("sh")
                              .arg("-c")
-                             .arg(format!("{} {}",
-                                          rustc,
-                                          main_file.as_str()
-                                                   .unwrap()).as_slice())
+                             .arg(&format!("{} {}",
+                                           rustc,
+                                           main_file.as_str()
+                                                    .unwrap()))
                              .output().unwrap();
 
-        let err = String::from_utf8_lossy(result.error.as_slice());
+        let err = String::from_utf8_lossy(&result.error);
 
         // the span should end the line (e.g no extra ~'s)
         let expected_span = format!("^{}\n", repeat("~").take(n - 1)
                                                         .collect::<String>());
-        assert!(err.contains(expected_span.as_slice()));
+        assert!(err.contains(&expected_span));
     }
 
     // Test multi-column characters and tabs
index b7e3480c076262aeeac3ef82e38d4dfc49f7ff68..57c50511604ca3f095418cac0f56ca53e264191a 100644 (file)
@@ -47,7 +47,7 @@ pub fn main() {
     assert_eq!(length(x.clone()), x.len());
     // Call a parameterized function, with type arguments that require
     // a borrow
-    assert_eq!(length::<int, &[int]>(x.as_slice()), x.len());
+    assert_eq!(length::<int, &[int]>(&*x), x.len());
 
     // Now try it with a type that *needs* to be borrowed
     let z = [0,1,2,3];
index 6d59161ff93456fdaf1163bc02cc17033d8b30e2..f21b7183d70c46c5445081f762ed18c55af6f41f 100644 (file)
@@ -36,7 +36,7 @@ fn eq(&self, other: &[B]) -> bool {
     where A: MyEq<B>, Lhs: Deref<Target=[A]>
 {
     fn eq(&self, other: &[B; 0]) -> bool {
-        MyEq::eq(&**self, other.as_slice())
+        MyEq::eq(&**self, other)
     }
 }
 
index 9b030de998373be9b62b6b9542d8de7fbb5c4a11..1fcbae833dc7f00342660e55494a2c375917d521 100644 (file)
@@ -35,7 +35,7 @@ fn test_rbml<'a, 'b, A:
     let mut rbml_w = EBwriter::Encoder::new(&mut wr);
     a1.encode(&mut rbml_w);
 
-    let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr[]);
+    let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr);
     let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
     let a2: A = Decodable::decode(&mut decoder);
     assert!(*a1 == a2);
index e9a3ab6be35c385ef3889493ea80450c512aa42d..2cb6cf99d662e48194a48c4439bebddc44c39461 100644 (file)
@@ -48,7 +48,7 @@ fn runtest(me: &str) {
     let p = template.clone().arg("fail").env("RUST_BACKTRACE", "1").spawn().unwrap();
     let out = p.wait_with_output().unwrap();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error.as_slice()).unwrap();
+    let s = str::from_utf8(&out.error).unwrap();
     assert!(s.contains("stack backtrace") && s.contains("foo::h"),
             "bad output: {}", s);
 
@@ -56,7 +56,7 @@ fn runtest(me: &str) {
     let p = template.clone().arg("fail").spawn().unwrap();
     let out = p.wait_with_output().unwrap();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error.as_slice()).unwrap();
+    let s = str::from_utf8(&out.error).unwrap();
     assert!(!s.contains("stack backtrace") && !s.contains("foo::h"),
             "bad output2: {}", s);
 
@@ -64,7 +64,7 @@ fn runtest(me: &str) {
     let p = template.clone().arg("double-fail").spawn().unwrap();
     let out = p.wait_with_output().unwrap();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error.as_slice()).unwrap();
+    let s = str::from_utf8(&out.error).unwrap();
     // loosened the following from double::h to double:: due to
     // spurious failures on mac, 32bit, optimized
     assert!(s.contains("stack backtrace") && s.contains("double::"),
@@ -75,7 +75,7 @@ fn runtest(me: &str) {
                                 .env("RUST_BACKTRACE", "1").spawn().unwrap();
     let out = p.wait_with_output().unwrap();
     assert!(!out.status.success());
-    let s = str::from_utf8(out.error.as_slice()).unwrap();
+    let s = str::from_utf8(&out.error).unwrap();
     let mut i = 0;
     for _ in 0..2 {
         i += s[i + 10..].find_str("stack backtrace").unwrap() + 10;
@@ -86,12 +86,12 @@ fn runtest(me: &str) {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() >= 2 && args[1].as_slice() == "fail" {
+    let args = args;
+    if args.len() >= 2 && args[1] == "fail" {
         foo();
-    } else if args.len() >= 2 && args[1].as_slice() == "double-fail" {
+    } else if args.len() >= 2 && args[1] == "double-fail" {
         double();
     } else {
-        runtest(args[0].as_slice());
+        runtest(&args[0]);
     }
 }
index fae83d4aa6563632eca12028ad420553141ded4e..758776298e1463cc94699fc4f563dd4ecb94da23 100644 (file)
@@ -26,13 +26,13 @@ fn call_g<G:FnMut(String,String) -> String>(mut g: G, x: String, y: String)
 }
 
 fn g(mut x: String, y: String) -> String {
-    x.push_str(y.as_slice());
+    x.push_str(&y);
     x
 }
 
 fn main() {
     call_f(f);
-    assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()).as_slice(),
+    assert_eq!(call_g(g, "foo".to_string(), "bar".to_string()),
                "foobar");
 }
 
index fe52b1a693cdcb9f76f71ac95c94fcb7450f5f05..f3c874a5afcec13b801d006a754704754ea55b32 100644 (file)
@@ -13,6 +13,6 @@
 pub fn main() {
     fn f() -> int { return 7; }
     assert_eq!(force(f), 7);
-    let g = {|&:|force(f)};
+    let g = {||force(f)};
     assert_eq!(g(), 7);
 }
index b3c4802530ed3c9f7aa38a0ea43af498648f91d1..edf6b397ff8c8c7703a3a1bb1ade80ba8b41a9f8 100644 (file)
@@ -53,9 +53,9 @@ fn main() {
     assert_eq!(!false, true);
 
     let s = false.to_string();
-    assert_eq!(s.as_slice(), "false");
+    assert_eq!(s, "false");
     let s = true.to_string();
-    assert_eq!(s.as_slice(), "true");
+    assert_eq!(s, "true");
 
     assert!(true > false);
     assert!(!(false > true));
index 6624136544dded6d8b59154babf86989a4a056b1..34ad2b2def03f82a5d4de6a5838ff9064ce50931 100644 (file)
@@ -19,7 +19,7 @@ pub fn main() {
 
     match x {
       F {f: ref mut v} => {
-        impure(v.as_slice());
+        impure(v);
       }
     }
 }
index df8dbdd03c740c1fd96e6be488111f9ef84c57af..c907778339ec50b64e72f42343c9b25321975bd1 100644 (file)
@@ -17,8 +17,8 @@
 fn a() -> i32 {
     let mut x = 3i32;
     x += 1;
-    let c1 = |&:| x * 4;
-    let c2 = |&:| x * 5;
+    let c1 = || x * 4;
+    let c2 = || x * 5;
     c1() * c2() * x
 }
 
@@ -29,16 +29,16 @@ fn get(x: &i32) -> i32 {
 fn b() -> i32 {
     let mut x = 3i32;
     x += 1;
-    let c1 = |&:| get(&x);
-    let c2 = |&:| get(&x);
+    let c1 = || get(&x);
+    let c2 = || get(&x);
     c1() * c2() * x
 }
 
 fn c() -> i32 {
     let mut x = 3i32;
     x += 1;
-    let c1 = |&:| x * 5;
-    let c2 = |&:| get(&x);
+    let c1 = || x * 5;
+    let c2 = || get(&x);
     c1() * c2() * x
 }
 
index 773780ffb0953f8e95f51387cba0a3483cd925d3..1be57674fa1ff4ad9c981e3bd59c924029011e39 100644 (file)
@@ -14,7 +14,7 @@
 
 pub fn main() {
     let bar = box 3;
-    let h = |:| -> int *bar;
+    let h = || -> int *bar;
     assert_eq!(h(), 3);
 }
 
index 94c7c2b13cec4cfc146c8990151d45255407516d..092d7c1317029be72ec0abe99ec82fcae68a08e0 100644 (file)
@@ -16,7 +16,7 @@ fn want_slice(v: &[int]) -> int {
 }
 
 fn has_mut_vec(v: Vec<int> ) -> int {
-    want_slice(v.as_slice())
+    want_slice(&v)
 }
 
 pub fn main() {
index 75b54b1af86bd4e45eb8a4b5becbe7254e17adc2..efd932933db333504992493df3a2457ff88f6f7d 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn foo(s: &String) -> bool {
-    match s.as_slice() {
+    match &**s {
         "kitty" => true,
         _ => false
     }
index de1196e10d88c0f7a7b4861870359decb5a3b4c3..ca315b7a9f1dbb05f6436899606e9a27a26e5934 100644 (file)
@@ -19,6 +19,6 @@ fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) {
 fn main() {
     let mut sum = 0u;
     let elems = [ 1u, 2, 3, 4, 5 ];
-    each(&elems, |&mut: val: &uint| sum += *val);
+    each(&elems, |val: &uint| sum += *val);
     assert_eq!(sum, 15);
 }
index 04ab0d881a84d66cf912231abc7cd9ab15e32ed1..edb3d72483b471663e7892107ba2e0e8ead5d853 100644 (file)
@@ -44,7 +44,7 @@ fn get_bar(x: uint) -> Vec<uint> { vec!(x * 2) }
 pub fn fails() {
     let x = 2;
     let mut y = Vec::new();
-    y.push(box Conzabble::Bickwick(do_it(get_bar(x).as_slice())));
+    y.push(box Conzabble::Bickwick(do_it(&get_bar(x))));
 }
 
 pub fn main() {
index 7dd46e7b01702b8ff41c08a7eebfdc34a784fd37..b776f098b1db2f550b7850149b1ae97cba083818 100644 (file)
@@ -24,7 +24,7 @@
 
 pub fn main() {
     let args = os::args();
-    let args = args.as_slice();
+    let args = args;
 
     // Here, the rvalue `"signal".to_string()` requires cleanup. Older versions
     // of the code had a problem that the cleanup scope for this
@@ -32,7 +32,7 @@ pub fn main() {
     // expression was never evaluated, we wound up trying to clean
     // uninitialized memory.
 
-    if args.len() >= 2 && args[1].as_slice() == "signal" {
+    if args.len() >= 2 && args[1] == "signal" {
         // Raise a segfault.
         unsafe { *(0 as *mut int) = 0; }
     }
index c0877568b72aaca50a4a08d6e4e44bb972cae1c5..fa16ea001452c79a52e825264ed202193dd55ace 100644 (file)
@@ -11,7 +11,7 @@
 // Test a rather underspecified example:
 
 pub fn main() {
-    let f = {|&: i| i};
+    let f = {|i| i};
     assert_eq!(f(2), 2);
     assert_eq!(f(5), 5);
 }
index ae4db40411553d4efb4f165f9e97218c76d25b5c..ec8d58616dc0fc66c902c48226b32a1d0fdaeb59 100644 (file)
@@ -47,11 +47,11 @@ fn use_slice(_: &[u8]) {}
 fn use_slice_mut(_: &mut [u8]) {}
 
 fn use_vec(mut v: Vec<u8>) {
-    use_slice_mut(&mut v[]); // what you have to write today
-    use_slice_mut(&mut v);   // what you'd be able to write
+    use_slice_mut(&mut v[..]); // what you have to write today
+    use_slice_mut(&mut v);     // what you'd be able to write
     use_slice_mut(&mut &mut &mut v);
 
-    use_slice(&v[]);    // what you have to write today
+    use_slice(&v[..]);  // what you have to write today
     use_slice(&v);      // what you'd be able to write
     use_slice(&&&&&&v);
     use_slice(&mut &&&&&v);
@@ -59,7 +59,7 @@ fn use_vec(mut v: Vec<u8>) {
 }
 
 fn use_vec_ref(v: &Vec<u8>) {
-    use_slice(&v[]);    // what you have to write today
+    use_slice(&v[..]);  // what you have to write today
     use_slice(v);       // what you'd be able to write
     use_slice(&&&&&&v);
     use_slice(&mut &&&&&v);
index 646eed5de7537b43dd6ec37bb9521ea2d95a5369..69bb3579720b1ccd37bb149fb5ec4f8f3a916996 100644 (file)
@@ -19,6 +19,6 @@ fn bip(v: &[uint]) -> Vec<uint> {
 
 pub fn main() {
     let mut the_vec = vec!(1u, 2, 3, 100);
-    assert_eq!(the_vec.clone(), bar(the_vec.as_mut_slice()));
-    assert_eq!(the_vec.clone(), bip(the_vec.as_slice()));
+    assert_eq!(the_vec.clone(), bar(&mut the_vec));
+    assert_eq!(the_vec.clone(), bip(&the_vec));
 }
index 10d747bf41408c3c3deaf742be0a93b7354a8573..f87f2e07c9de0f0ee2507023a37286cb905f3bee 100644 (file)
@@ -21,6 +21,6 @@ fn bar(v: &mut [uint]) {
 
 pub fn main() {
     let mut the_vec = vec!(1, 2, 3, 100);
-    bar(the_vec.as_mut_slice());
+    bar(&mut the_vec);
     assert_eq!(the_vec, vec!(100, 3, 2, 1));
 }
index 6820aa4d186efd8ea89103d1cdffc72917faa7cd..4f97e6a20815d0014f06a8581abac69b50d8f69e 100644 (file)
@@ -17,6 +17,6 @@ fn bar(v: &mut [uint]) {
 
 pub fn main() {
     let mut the_vec = vec!(1, 2, 3, 100);
-    bar(the_vec.as_mut_slice());
+    bar(&mut the_vec);
     assert_eq!(the_vec, vec!(100, 3, 2, 1));
 }
index a0888850aaf1408104bd6442fb2dc362300b5011..838d05cf0d53084873383d4c3cabd51529818619 100644 (file)
@@ -25,6 +25,6 @@ struct A {
 fn main() {
     let obj = A { foo: box [true, false] };
     let s = json::encode(&obj).unwrap();
-    let obj2: A = json::decode(s.as_slice()).unwrap();
+    let obj2: A = json::decode(&s).unwrap();
     assert!(obj.foo == obj2.foo);
 }
index a5453d26170ad62833dfa45d88d3d6583bc3ea78..7d581927c30b460a1aafd7dac9182fb90a294a11 100644 (file)
@@ -36,7 +36,7 @@ fn main() {
         bar: RefCell::new( A { baz: 2 } )
     };
     let s = json::encode(&obj).unwrap();
-    let obj2: B = json::decode(s.as_slice()).unwrap();
+    let obj2: B = json::decode(&s).unwrap();
     assert!(obj.foo.get() == obj2.foo.get());
     assert!(obj.bar.borrow().baz == obj2.bar.borrow().baz);
 }
index 8c93f1ec78dc1f0849834b265db35c362dd6aedc..ea43163775ce908172c827ff386abd5dc89a9847 100644 (file)
@@ -59,7 +59,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable<Encoder<'a>> +
     let mut w = Vec::new();
     let mut e = Encoder::new(&mut w);
     obj.encode(&mut e);
-    let doc = rbml::Doc::new(&w[]);
+    let doc = rbml::Doc::new(&w);
     let mut dec = Decoder::new(doc);
     let obj2 = Decodable::decode(&mut dec);
     assert!(obj == obj2);
index 6557594594565f33639b764f41644346338e8a69..95af729e5e16545d88022e321a1b84e4d4bdde11 100644 (file)
@@ -23,6 +23,6 @@ fn wrapper3(i: chan) {
 }
 
 pub fn main() {
-    let wrapped = {|&:|wrapper3(chan::chan_t)};
+    let wrapped = {||wrapper3(chan::chan_t)};
     wrapped();
 }
index 24bf1f94d887b49fe156fe0bbb8e0e85d2ab97c8..3e81ca5125ba4b84fa16383770577d52027dd7ce 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 pub fn main() {
-    let f = |&: (x, y): (int, int)| {
+    let f = |(x, y): (int, int)| {
         assert_eq!(x, 1);
         assert_eq!(y, 2);
     };
index 785abbe449bb47057f61869bfe71151bcc42c734..34417891197a422dd6db05cf34c80eabec933198 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     // We should be able to type infer inside of ||s.
-    let _f = |&:| {
+    let _f = || {
         let i = 10;
     };
 }
index e9e8c3f09290d784e1999f3d802a330747248423..25d625e27f6ddd40578fad4ef9424085a830778b 100644 (file)
@@ -11,7 +11,7 @@
 pub fn main() {
     let x = [1; 100];
     let mut y = 0;
-    for i in &x[] {
+    for i in &x[..] {
         if y > 10 {
             break;
         }
index 6acfbc95317627bc9213fa92eb18032f6e7aed15..3817e1b0edace950ce3f320474ef3881e92cf4d5 100644 (file)
@@ -13,8 +13,8 @@ pub fn main() {
     let y = [2; 100];
     let mut p = 0;
     let mut q = 0;
-    for i in &x[] {
-        for j in &y[] {
+    for i in &x[..] {
+        for j in &y[..] {
             p += *j;
         }
         q += *i + p;
index 2f154be659d888538de644a2f2cc1da4405bfb55..8403a1669ffcf5fecd6e2fe8f688fab6f1ec4fe0 100644 (file)
@@ -11,7 +11,7 @@
 pub fn main() {
     let x = [1; 100];
     let mut y = 0;
-    for i in &x[] {
+    for i in &x[..] {
         y += *i
     }
     assert!(y == 100);
index a3df98afcb0c52e39c06908bdc7f315065f87b49..3c89900fe493bad40d3d106d3948b9cfebe9c862 100644 (file)
@@ -16,7 +16,7 @@ pub fn main() {
     let args = Vec::new();
     let opts = vec!(optopt("b", "", "something", "SMTHNG"));
 
-    match getopts(args.as_slice(), opts.as_slice()) {
+    match getopts(&args, &opts) {
         Ok(ref m)  =>
             assert!(!m.opt_present("b")),
         Err(ref f) => panic!("{}", *f)
index 651ac632439fa5f0c49598b1cbe1cede2f263216..677038af9a9c4e0de4609f0622e812f17f377486 100644 (file)
@@ -84,8 +84,7 @@ pub fn map_reduce(inputs: Vec<String>) {
               ctrl_proto::mapper_done => { num_mappers -= 1; }
               ctrl_proto::find_reducer(k, cc) => {
                 let mut c;
-                match reducers.get(&str::from_utf8(
-                        k.as_slice()).unwrap().to_string()) {
+                match reducers.get(&str::from_utf8(&k).unwrap().to_string()) {
                   Some(&_c) => { c = _c; }
                   None => { c = 0; }
                 }
index 1d1e744ef0802d8ff47fd3c2033c4e398e2f2b42..b59e7b67d4eddb4ad11b80ede4fe0193feb0ad4e 100644 (file)
@@ -17,7 +17,7 @@
 // cause a compilation error. Issue #18772.
 
 fn adder(y: int) -> Box<Fn(int) -> int + 'static> {
-    box move |&: x| y + x
+    box move |x| y + x
 }
 
 fn main() {}
index fea628177da41c4933caf9650e3e847dd9f755f5..c34e1a4862f828502032508d0af68fe704b1f1a2 100644 (file)
@@ -18,5 +18,5 @@ fn foo<F:Fn(&int)>(f: F) {
 }
 
 fn main() {
-    foo(|&: x: &int| println!("{}", *x));
+    foo(|x: &int| println!("{}", *x));
 }
index 5d97b886e8e5e4988546424ced05bb8569086d15..06294696bc937dc11ad5110487671b2d8f17ad84 100644 (file)
@@ -50,7 +50,7 @@ enum Foo {
     } else if let Foo::Two(_x) = foo {
         panic!("bad pattern match");
     } else if let Foo::Three(s, _) = foo {
-        assert_eq!(s.as_slice(), "three");
+        assert_eq!(s, "three");
     } else {
         panic!("bad else");
     }
index ce628668996b7566ab68a40174fc1fc4e045b9ba..5d157d875fa4dbec76c3d25e5853c5c21da5e5f3 100644 (file)
@@ -39,7 +39,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 macro_rules! t {
-    ($a:expr, $b:expr) => { assert_eq!($a.as_slice(), $b) }
+    ($a:expr, $b:expr) => { assert_eq!($a, $b) }
 }
 
 pub fn main() {
index b30583c666888bc7358074541915c49548e5c8cb..d87b59537df8f120968480a5940df427dfc4dd62 100644 (file)
@@ -15,7 +15,7 @@ fn bad(a: &str, b: &str) {
 }
 
 fn good(a: &str, b: &str) {
-    foo(&[a.as_slice(), b.as_slice()]);
+    foo(&[a, b]);
 }
 
 fn main() {}
index 79a0a54f834ad32de4400931221e008182608140..9150920cf2cc7e5feb79b97ea1649a3c01d50ab1 100644 (file)
@@ -17,8 +17,8 @@
 
 pub fn main () {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "child" {
+    let args = args;
+    if args.len() > 1 && args[1] == "child" {
         for _ in 0..1000 {
             println!("hello?");
         }
@@ -28,7 +28,7 @@ pub fn main () {
         return;
     }
 
-    let mut p = process::Command::new(args[0].as_slice());
+    let mut p = process::Command::new(&args[0]);
     p.arg("child").stdout(process::Ignored).stderr(process::Ignored);
     println!("{:?}", p.spawn().unwrap().wait());
 }
index 26ee65fa565e2bb3588ed261fcec0e35177e8026..a01d2e6f1a9ed90873de03e2efd58fa2e64f1c41 100644 (file)
@@ -13,7 +13,7 @@
 static NAME: &'static str = "hello world";
 
 fn main() {
-    match NAME.to_ascii_lowercase().as_slice() {
+    match &*NAME.to_ascii_lowercase() {
         "foo" => {}
         _ => {}
     }
index 71b4cbe933427fc9175e6c395d85585bf2da4a08..c3ec3fc40e30a77559d095e4d16ddef29ff17fbe 100644 (file)
@@ -15,6 +15,6 @@ fn f<F:FnOnce()>(p: F) {
 }
 
 pub fn main() {
-    let p = |:| ();
+    let p = || ();
     f(p);
 }
index c75d02c632863413966e3cb493e4e2695a98b13a..12a6d9a82c7b014d2b019eeaa9df4ede82d44ddb 100644 (file)
@@ -13,7 +13,7 @@ struct A {
 }
 
 fn borrow<'a>(binding: &'a A) -> &'a str {
-    match binding.a.as_slice() {
+    match &*binding.a {
         "in" => "in_",
         "ref" => "ref_",
         ident => ident
index 649cf63e84a08a4c3739e3e999c4382bae45cf69..056c86b01f7346c92ab6c179f0a7bbfebd567dc1 100644 (file)
@@ -179,7 +179,7 @@ enum Foo {
     // This test basically mimics how trace_macros! macro is implemented,
     // which is a rare combination of vector patterns, multiple wild-card
     // patterns and guard functions.
-    let r = match [Foo::Bar(0, false)].as_slice() {
+    let r = match [Foo::Bar(0, false)] {
         [Foo::Bar(_, pred)] if pred => 1,
         [Foo::Bar(_, pred)] if !pred => 2,
         _ => 0,
index f2a8bc47db86ed27d47a9c9d53a521ccea6a9bb0..f979235da7197bee2a207c4aa4f3dea501ff2b02 100644 (file)
@@ -16,8 +16,8 @@
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "child" {
+    let args = args;
+    if args.len() > 1 && args[1] == "child" {
         child();
     } else {
         parent();
@@ -26,13 +26,13 @@ fn main() {
 
 fn parent() {
     let args = os::args();
-    let args = args.as_slice();
-    let mut p = old_io::process::Command::new(args[0].as_slice())
+    let args = args;
+    let mut p = old_io::process::Command::new(&args[0])
                                      .arg("child").spawn().unwrap();
     p.stdin.as_mut().unwrap().write_str("test1\ntest2\ntest3").unwrap();
     let out = p.wait_with_output().unwrap();
     assert!(out.status.success());
-    let s = str::from_utf8(out.output.as_slice()).unwrap();
+    let s = str::from_utf8(&out.output).unwrap();
     assert_eq!(s, "test1\n\ntest2\n\ntest3\n");
 }
 
index 75d3c6f334d071774799677ae2c157b0ab0ccd42..44167ad2096decc595eb7e352de1ebeb11bc8740 100644 (file)
@@ -21,7 +21,7 @@ fn new(s: &str) -> StrWrap {
     }
 
     fn get_s<'a>(&'a self) -> &'a str {
-        self.s.as_slice()
+        &self.s
     }
 }
 
index 953701441256abde027776311a340dad9d102d16..5d7a84d80d4c33910210469ef503108cb677bd0a 100644 (file)
@@ -26,5 +26,5 @@ fn do_stuff<R: Repro>(r: R) -> String {
 }
 
 pub fn main() {
-  assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s)));
+  assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s)));
 }
index ab085be9bc358b32609475ae77e772c653462a80..e850ecbba6e560d6d2ad12b0ac9c0153a44f47b1 100644 (file)
@@ -22,7 +22,7 @@ pub fn main() {
     let obj = UnitLikeStruct;
     let json_str: String = json::encode(&obj).unwrap();
 
-    let json_object = json::from_str(json_str.as_slice());
+    let json_object = json::from_str(&json_str);
     let mut decoder = json::Decoder::new(json_object.unwrap());
     let mut decoded_obj: UnitLikeStruct = Decodable::decode(&mut decoder).unwrap();
 
index a41e57f10025d2e32dfa1429a03db8261783b397..5f44eb7dcd23e2ed6a987e2b9b1e9a7efffbfac8 100644 (file)
@@ -16,7 +16,7 @@
 
 fn main() {
     let args = os::args();
-    if args.len() > 1 && args[1].as_slice() == "child" {
+    if args.len() > 1 && args[1] == "child" {
         return child()
     }
 
@@ -32,7 +32,7 @@ fn child() {
 
 fn test() {
     let args = os::args();
-    let mut p = Command::new(args[0].as_slice()).arg("child")
+    let mut p = Command::new(&args[0]).arg("child")
                                      .stdin(process::Ignored)
                                      .stdout(process::Ignored)
                                      .stderr(process::Ignored)
index e7516639db0c39dd5dd1b3c3aabb22ccad59ec8d..44465fe5f80ee493fdacb95d5c2245638483c9f6 100644 (file)
@@ -10,5 +10,5 @@
 
 
 pub fn main() {
-    {|&: i| if 1 == i { }};
+    {|i| if 1 == i { }};
 }
index 4d05b98147bd6237ec9ba8b5c065a8d0c02f5cb6..933e7e40f06d34ce23ae96de299da6a594acb62b 100644 (file)
@@ -58,6 +58,6 @@ fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndi
 
 fn main() {
     let s = "abcbdef";
-    match_indices(s, |&mut: c: char| c == 'b')
+    match_indices(s, |c: char| c == 'b')
         .collect::<Vec<(uint, uint)>>();
 }
index a441729e2d0ba015287dad9217a5a823f59a9a4a..ace1f00b023b58a8847ab40dae2cf496d1c98cd7 100644 (file)
@@ -31,7 +31,7 @@ macro_rules! demo {
             }
             assert_eq!((x,y), (1,1));
             let b: &[_] = &["out", "in"];
-            assert_eq!(history.as_slice(), b);
+            assert_eq!(history, b);
         }
     }
 }
index 5ae0ad6c3e97453231f00f4783e8d9cc9a901226..e5fead72bebeb44b5aa4acd15f83c2ad31bc6ce8 100644 (file)
@@ -17,7 +17,7 @@ fn main() {
         let mut out = stdio::stdout();
         out.write(&['a' as u8; 128 * 1024]).unwrap();
     } else {
-        let out = Command::new(args[0].as_slice()).arg("child").output();
+        let out = Command::new(&args[0]).arg("child").output();
         let out = out.unwrap();
         assert!(out.status.success());
     }
index b37c71bc326270ba0d745fe883275e2fd44d9f4c..24f7a6af78239a259c98d240c33464afd00e4ddb 100644 (file)
@@ -17,7 +17,7 @@
 fn main() {
     // If we're the child, make sure we were invoked correctly
     let args = os::args();
-    if args.len() > 1 && args[1].as_slice() == "child" {
+    if args.len() > 1 && args[1] == "child" {
         // FIXME: This should check the whole `args[0]` instead of just
         // checking that it ends_with the executable name. This
         // is needed because of Windows, which has a different behavior.
@@ -45,9 +45,9 @@ fn test() {
     // Append the new directory to our own PATH.
     let mut path = os::split_paths(os::getenv("PATH").unwrap_or(String::new()));
     path.push(child_dir.clone());
-    let path = os::join_paths(path.as_slice()).unwrap();
+    let path = os::join_paths(&path).unwrap();
 
-    let child_output = Command::new("mytest").env("PATH", path.as_slice())
+    let child_output = Command::new("mytest").env("PATH", path)
                                              .arg("child")
                                              .output().unwrap();
 
index 7d53b6729516da2dbbcb08dfde8b9024b058cc76..ab9554f65d4c89d93aa6c813b883551d737809ea 100644 (file)
@@ -48,7 +48,7 @@ fn match_on_binding() {
 
 fn match_on_upvar() {
     let mut foo = Some(box 8i32);
-    let f = move|:| {
+    let f = move|| {
         match foo {
             None => {},
             Some(x) => {
index e7422e233a62903385b1a0b8823eb7c6de44b47d..48ea3a93296e3194420f2e9c79c05e23c907cade 100644 (file)
@@ -10,5 +10,5 @@
 
 fn main() {
     let mut buf = Vec::new();
-    |&mut: c: u8| buf.push(c);
+    |c: u8| buf.push(c);
 }
index 6b03a499f15773728e54d603a344f929bfa4d8d5..ca40b2fe4c7d06fce8db083777c5aa4c88454ab5 100644 (file)
@@ -15,7 +15,7 @@
 
 fn main() {
     let y = 0u8;
-    let closure = move |&: x| y + x;
+    let closure = move |x| y + x;
 
     // Check that both closures are capturing by value
     assert_eq!(1, mem::size_of_val(&closure));
index 95b7728b47f993766bf149c6401987feb5cf2c20..daf09047bef723649a519d9d5a952376ce28b4ec 100644 (file)
@@ -21,7 +21,7 @@ struct Parser<'a, I, O> {
 impl<'a, I: 'a, O: 'a> Parser<'a, I, O> {
     fn compose<K: 'a>(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> {
         Parser {
-            parse: box move |&mut: x: I| {
+            parse: box move |x: I| {
                 match (self.parse)(x) {
                     Ok(r) => (rhs.parse)(r),
                     Err(e) => Err(e)
index d426f82f89fc96fdce9c20f6888520c23e251291..cc427dd941b73d7b67d90f986d7e216efb3e37e5 100644 (file)
@@ -47,7 +47,7 @@ fn main() {
     {
         let mut test = X(box 5);
         {
-            let mut change = |&mut:| { *test = 10 };
+            let mut change = || { *test = 10 };
             change();
         }
         assert_eq!(*test, 10);
index cb12d138a5f29ce4b2a880968a0f311c0852f0ab..c2bcbe045c0cc07ac5c51e59a4cbfffd1e46893b 100644 (file)
@@ -10,5 +10,5 @@
 
 pub fn main() {
     let x = [1, 2, 3];
-    let y = x.as_slice();
+    let y = x;
 }
index e58fbe0b4c2830d0756e1f7cb81bb84a8fff5c98..3cff16409cb9b811c2b6fdf782bb18fdb7824578 100644 (file)
@@ -21,6 +21,6 @@ fn main() {
     // There is currently no safe way to construct a `Box<str>`, so improvise
     let box_arr: Box<[u8]> = box ['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8];
     let box_str: Box<str> = unsafe { std::mem::transmute(box_arr) };
-    assert_eq!(box_str.as_slice(), "hello");
+    assert_eq!(&*box_str, "hello");
     f(box_str);
 }
index d9d2c771390fdfacccef56382ca63d93f0d5b698..f8fbd680dcb9ecfddc59a9668fb9a5be4a065d8d 100644 (file)
@@ -12,7 +12,7 @@
 
 fn main() {
     struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F }
-    let f = |&: x: Vec<&str>| -> &str "foobar";
+    let f = |x: Vec<&str>| -> &str "foobar";
     let sym = Symbol { function: f };
     (sym.function)(vec![]);
 }
index da6c83142eab62c3a20244c07b8b4354adc93bbe..3774aaa190333b97e687a0e4d76842c3e5781cfb 100644 (file)
@@ -17,5 +17,5 @@ fn action(cb: Thunk<uint, uint>) -> uint {
 }
 
 pub fn main() {
-    println!("num: {}", action(Thunk::with_arg(move |:u| u)));
+    println!("num: {}", action(Thunk::with_arg(move |u| u)));
 }
index a2152db6884ac9fd269c26296cf286d438e85f22..7a5a86822afda0233e98aa0e2222b44804994ae8 100644 (file)
@@ -20,7 +20,7 @@ pub fn propagate<T, E, F, G>(action: F) -> Thunk<Result<T, E>, Result<T, E>>
         E: Promisable + Clone,
         F: FnOnce(&T) -> Result<T, E> + Send,
         G: FnOnce(Result<T, E>) -> Result<T, E> {
-    Thunk::with_arg(move |result: Result<T, E>| {
+    Thunk::with_arg(move |result: Result<T, E>| {
         match result {
             Ok(ref t) => action(t),
             Err(ref e) => Err(e.clone()),
index 7878d698e52ae148190fd3ce9b69aaec3e2cc279..e5532b4550baab32c48a59b2191a8ee617f53141 100644 (file)
@@ -11,7 +11,7 @@
 const X: &'static str = "12345";
 
 fn test(s: String) -> bool {
-    match s.as_slice() {
+    match &*s {
         X => true,
         _ => false
     }
index ef2c15c748ca36a317efa02f7993daf4215a9d20..8f560258d9f4795fe0aae54431c215b2df1d184b 100644 (file)
@@ -17,5 +17,5 @@
 fn main() {
     let x = 2u8;
     let y = 3u8;
-    assert_eq!((move |:| x + y)(), 5);
+    assert_eq!((move || x + y)(), 5);
 }
index 6a2f73a787a4835c1d54df7682cf467965d6a69e..bb2907241c2c6bfc06c5754f46f79e04c2f7bc09 100644 (file)
@@ -20,7 +20,7 @@ pub fn inside<F: Fn()>(c: F) {
 // Use different number of type parameters and closure type to trigger
 // an obvious ICE when param environments are mixed up
 pub fn outside<A,B>() {
-    inside(|&:| {});
+    inside(|| {});
 }
 
 fn main() {
index be6dd583132ecf742f94741a236a5dd8505d3e4e..698b61e5759ad98268aece46d4ccec0bbf109963 100644 (file)
@@ -17,7 +17,7 @@ trait Tr {
     fn foo(&self);
 
     fn bar(&self) {
-        (|:| { self.foo() })()
+        (|| { self.foo() })()
     }
 }
 
index 6a04e68af0cb3c028abcd5119523dba397f7599e..0338a4eff22389e2ac1dc9a88dc51459437dcddd 100644 (file)
@@ -17,5 +17,5 @@
 extern crate "issue-18711" as issue;
 
 fn main() {
-    (|:| issue::inner(()))();
+    (|| issue::inner(()))();
 }
index 9557d7e4fa816d5f8afa37fd16551f05f447d8e1..031a63ba474c181ae7b2a81438decc4a1c6a2627 100644 (file)
@@ -14,7 +14,7 @@
 struct LifetimeStruct<'a>;
 
 fn main() {
-    takes_hrtb_closure(|&mut: lts| println!("{:?}", lts));
+    takes_hrtb_closure(|lts| println!("{:?}", lts));
 }
 
 fn takes_hrtb_closure<F: for<'a>FnMut(LifetimeStruct<'a>)>(mut f: F) {
index 120ada96c15b731c932c0f5e74f680ddb94556c2..5f2805ed354553f58dfd5d28847b20adea5cc15d 100644 (file)
 #![allow(non_camel_case_types)]
 
 pub fn main() {
-    let one = |&:| {
+    let one = || {
         enum r { a };
         r::a as uint
     };
-    let two = |&:| {
+    let two = || {
         enum r { a };
         r::a as uint
     };
index c75abd88963433dbb92f6901e3d8a738f43cad96..ca2a4e546b7c8abd8aa9ada2868c2c34dccc3a41 100644 (file)
@@ -12,6 +12,6 @@
 
 fn main() {
     let x = 5us;
-    let command = Arc::new(Box::new(|&:| { x*2 }));
+    let command = Arc::new(Box::new(|| { x*2 }));
     assert_eq!(command(), 10);
 }
diff --git a/src/test/run-pass/issue-21891.rs b/src/test/run-pass/issue-21891.rs
new file mode 100644 (file)
index 0000000..d6e6f23
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+static foo: [uint; 3] = [1, 2, 3];
+
+static slice_1: &'static [uint] = &foo;
+static slice_2: &'static [uint] = &foo;
+
+fn main() {}
index c08bdf54408122447313c8e026d7b6fa6e532964..3e7deee6ec10720b4690df4336df72e1beae4bca 100644 (file)
@@ -14,7 +14,7 @@
 type Connection = Box<FnMut(Vec<u8>) + 'static>;
 
 fn f() -> Option<Connection> {
-    let mock_connection: Connection = box |&mut: _| {};
+    let mock_connection: Connection = box |_| {};
     Some(mock_connection)
 }
 
index 60c53450004363917843728b96dda31d397ed800..6fc8c9c6843ee2cb3eeea4536f508e31221e4282 100644 (file)
@@ -10,6 +10,6 @@
 
 pub fn main() {
   let x = 1u;
-  let y = |&:| x;
+  let y = || x;
   let _z = y();
 }
index 69a148d4108ea1c5c7e1adee6247ee6f83916627..754412ea949381c7059b1a6d6472d9f7a76d2489 100644 (file)
@@ -24,6 +24,6 @@ pub fn main() {
     let mut table = HashMap::new();
     table.insert("one".to_string(), 1);
     table.insert("two".to_string(), 2);
-    assert!(check_strs(format!("{:?}", table).as_slice(), "HashMap {\"one\": 1, \"two\": 2}") ||
-            check_strs(format!("{:?}", table).as_slice(), "HashMap {\"two\": 2, \"one\": 1}"));
+    assert!(check_strs(&format!("{:?}", table), "HashMap {\"one\": 1, \"two\": 2}") ||
+            check_strs(&format!("{:?}", table), "HashMap {\"two\": 2, \"one\": 1}"));
 }
index 5d02a1b2bd2982a52d1c6958c23e1527e8de9385..f4b85e03eaeac031dfb37f2e8de0f9cb7effcdbe 100644 (file)
@@ -162,7 +162,7 @@ pub fn check_strs(actual: &str, expected: &str) -> bool {
 
 fn test_ascii_art_ctor() {
     let art = AsciiArt(3, 3, '*');
-    assert!(check_strs(art.to_string().as_slice(), "...\n...\n..."));
+    assert!(check_strs(&art.to_string(), "...\n...\n..."));
 }
 
 
@@ -171,7 +171,7 @@ fn test_add_pt() {
     art.add_pt(0, 0);
     art.add_pt(0, -10);
     art.add_pt(1, 2);
-    assert!(check_strs(art.to_string().as_slice(), "*..\n...\n.*."));
+    assert!(check_strs(&art.to_string(), "*..\n...\n.*."));
 }
 
 
@@ -179,7 +179,7 @@ fn test_shapes() {
     let mut art = AsciiArt(4, 4, '*');
     art.add_rect(Rect {top_left: Point {x: 0, y: 0}, size: Size {width: 4, height: 4}});
     art.add_point(Point {x: 2, y: 2});
-    assert!(check_strs(art.to_string().as_slice(), "****\n*..*\n*.**\n****"));
+    assert!(check_strs(&art.to_string(), "****\n*..*\n*.**\n****"));
 }
 
 pub fn main() {
index c9baab3cfa49e054c5638a7d3513501e9caf4b84..f10303e8d8479a1eb433c4dbe1122628e3a84de5 100644 (file)
 
 fn parse_args() -> String {
     let args = ::std::os::args();
-    let args = args.as_slice();
+    let args = args;
     let mut n = 0;
 
     while n < args.len() {
-        match args[n].as_slice() {
+        match &*args[n] {
             "-v" => (),
             s => {
                 return s.to_string();
index 69255c576811fd075b8c5b039e276f92a75e950f..dd9a6fb35439e99929ab417e0e8a3ce46e6cd1c8 100644 (file)
@@ -11,7 +11,7 @@
 // Regression test for issue #5239
 
 pub fn main() {
-    let _f = |&: ref x: int| { *x };
+    let _f = |ref x: int| { *x };
     let foo = 10;
     assert!(_f(foo) == 10);
 }
index 7f56e42a4830863d6ccaa82df9c88ab53f59e123..f87f1d8af7649fb723fdd9c707311c72059207dd 100644 (file)
@@ -12,6 +12,6 @@
 
 pub fn main() {
     let s: String = "foobar".to_string();
-    let mut t: &str = s.as_slice();
+    let mut t: &str = &s;
     t = &t[0..3]; // for master: str::view(t, 0, 3) maybe
 }
index 07c7c6888e1ebdb4780246c8c35c016d86179722..39f387afaba048905de543623e8600b6f4c7b14b 100644 (file)
@@ -21,7 +21,7 @@ fn squarei<'a>(x: int, op: &'a mut OpInt) -> int { op.call(x, x) }
 fn muli(x:int, y:int) -> int { x * y }
 
 pub fn main() {
-    let mut f = |&mut: x, y| muli(x, y);
+    let mut f = |x, y| muli(x, y);
     {
         let g = &mut f;
         let h = g as &mut OpInt;
index b2ccc092358e2ed96d270fffb2d89bfeedf334a3..e47999fc468607c2dc3a13ff6df57c67c76554a2 100644 (file)
@@ -20,5 +20,5 @@ pub fn main() {
     let _: () = f(| | { });
     // empty block with no type info should compile too
     let _ = f(||{});
-    let _ = (|&:|{});
+    let _ = (||{});
 }
index 379b8f7700e594fb66d8b043a8ab6ceda260f74b..b1c443dd0c51b5713a2721c538bf0d84b18bbc5d 100644 (file)
@@ -18,9 +18,9 @@ pub fn main() {
     let x  = [(), ()];
     let slice = &x[..1];
 
-    assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
-    assert_repr_eq(&tf[], "[true, false]".to_string());
-    assert_repr_eq(&x[], "[(), ()]".to_string());
+    assert_repr_eq(&abc[..], "[1, 2, 3]".to_string());
+    assert_repr_eq(&tf[..], "[true, false]".to_string());
+    assert_repr_eq(&x[..], "[(), ()]".to_string());
     assert_repr_eq(slice, "[()]".to_string());
-    assert_repr_eq(&x[], "[(), ()]".to_string());
+    assert_repr_eq(&x[..], "[(), ()]".to_string());
 }
index 2ef1c1d264a409b396eb60008e7f3fde064c19da..6c843993040f38d65dcf0a77c0bb90801c982265 100644 (file)
@@ -29,7 +29,7 @@ fn Ident_new() -> Ident {
 
 pub fn light_fuse(fld: Box<bomb>) {
     int3!();
-    let f = |&:| {
+    let f = || {
         int3!();
         fld.boom(Ident_new()); // *** 1
     };
index 0fe520e59d622050bec7e282a3248b9d4f6795e7..da5338b8c3c61438bdfdf74362909e788cb94fda 100644 (file)
@@ -19,5 +19,5 @@ pub fn main() {
         a: &["test".to_string()],
         b: Some(b),
     };
-    assert_eq!(a.b.as_ref().unwrap()[0].as_slice(), "foo");
+    assert_eq!(a.b.as_ref().unwrap()[0], "foo");
 }
index 07212237305efa7903f92bb06ad29d93e81347c6..c501420fa617a00c212fc6f5c2a609512da99d3e 100644 (file)
@@ -34,7 +34,7 @@ pub fn main() {
         bar: box 32,
     };
     Thing1 {
-        baz: Vec::new().as_slice(),
+        baz: &Vec::new(),
         bar: box 32,
     };
     let _t2_fixed = Thing2 {
@@ -42,7 +42,7 @@ pub fn main() {
         bar: 32,
     };
     Thing2 {
-        baz: Vec::new().as_slice(),
+        baz: &Vec::new(),
         bar: 32,
     };
 }
index af60f18e542283168fc8d63baedc618ce5c1a5fb..15195482ed693921f39beac19f320a62450fb2a0 100644 (file)
@@ -37,19 +37,19 @@ fn test_heap_log() {
 fn test_append() {
     let mut s = String::new();
     s.push_str("a");
-    assert_eq!(s.as_slice(), "a");
+    assert_eq!(s, "a");
 
     let mut s = String::from_str("a");
     s.push_str("b");
     println!("{}", s.clone());
-    assert_eq!(s.as_slice(), "ab");
+    assert_eq!(s, "ab");
 
     let mut s = String::from_str("c");
     s.push_str("offee");
-    assert!(s.as_slice() == "coffee");
+    assert!(s == "coffee");
 
     s.push_str("&tea");
-    assert!(s.as_slice() == "coffee&tea");
+    assert!(s == "coffee&tea");
 }
 
 pub fn main() {
index b33e6512b18bdafab6c280bc5755150237ab6ec9..3c2a3f355b412e15ecf549bba8e8318d559fc438 100644 (file)
@@ -16,7 +16,7 @@ struct Refs { refs: Vec<int> , n: int }
 
 pub fn main() {
     let mut e = Refs{refs: vec!(), n: 0};
-    let _f = |&:| println!("{}", e.n);
-    let x: &[int] = e.refs.as_slice();
+    let _f = || println!("{}", e.n);
+    let x: &[int] = &e.refs;
     assert_eq!(x.len(), 0);
 }
index 0cd8c13a4e10a60644ec0c80d887de9f236d1919..4231e5dba9f0f416b86b2f61b7713551a7a68a3b 100644 (file)
@@ -19,7 +19,8 @@ struct A { a: Box<isize> }
 fn foo() -> Box<FnMut() -> isize + 'static> {
     let k = box 22;
     let _u = A {a: k.clone()};
-    let result  = |&mut:| 22;
+    // FIXME(#16640) suffix in `22i` suffix shouldn't be necessary
+    let result  = || 22i;
     box result
 }
 
index 44daa52886cf85872156234107c813c6439bd79b..1be0ee4a285514c4ab5c23db4f92f866a521c083 100644 (file)
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "child" {
+    let args = args;
+    if args.len() > 1 && args[1] == "child" {
         debug!("foo");
         debug!("bar");
         return
     }
 
-    let p = Command::new(args[0].as_slice())
+    let p = Command::new(&args[0])
                     .arg("child")
                     .spawn().unwrap().wait_with_output().unwrap();
     assert!(p.status.success());
-    let mut lines = str::from_utf8(p.error.as_slice()).unwrap().lines();
+    let mut lines = str::from_utf8(&p.error).unwrap().lines();
     assert!(lines.next().unwrap().contains("foo"));
     assert!(lines.next().unwrap().contains("bar"));
 }
index 60a5904cff31147391192a8a1ad03b045b7e2fcf..301d99a7e20b32b807b9dcce761162c782b01d47 100644 (file)
@@ -18,8 +18,8 @@ enum t { tag1(String), tag2, }
 
     match t::tag1("test".to_string()) {
       t::tag2 => panic!(),
-      t::tag1(ref s) if "test" != s.as_slice() => panic!(),
-      t::tag1(ref s) if "test" == s.as_slice() => (),
+      t::tag1(ref s) if "test" != &**s => panic!(),
+      t::tag1(ref s) if "test" == &**s => (),
       _ => panic!()
     }
 
index 76895af099d6d0109f9216c3ad9cd3bb975e0fbc..0ad600dd85d9338a1ed33c230053c369fa0098c7 100644 (file)
@@ -41,7 +41,7 @@ fn main() {
     let mut buf = [0_u8; 6];
 
     {
-        let mut writer = buf.as_mut_slice();
+        let mut writer: &mut [_] = &mut buf;
         writer.my_write(&[0, 1, 2]).unwrap();
         writer.my_write(&[3, 4, 5]).unwrap();
     }
index 92c5e025b9b2149692aa23bb41c73406015de143..cb487a34f338876dc9e60557be588322c8577b2c 100644 (file)
@@ -31,5 +31,5 @@ pub fn main() {
     sb.append("Hello, ");
     sb.append("World!");
     let str = to_string(sb);
-    assert_eq!(str.as_slice(), "Hello, World!");
+    assert_eq!(str, "Hello, World!");
 }
index 388b814b2af1068e18d75d78e801169f03bb2180..b1f7da17c8f80767bee34c713ab15627319fe355 100644 (file)
@@ -17,7 +17,7 @@ fn f(mut y: Box<int>) {
 }
 
 fn g() {
-    let frob = |&: mut q: Box<int>| { *q = 2; assert!(*q == 2); };
+    let frob = |mut q: Box<int>| { *q = 2; assert!(*q == 2); };
     let w = box 37;
     frob(w);
 
index 8be200d3bf32c852ae091d26ba04ad57540a1df2..d3ae80861f231c5f29aaa57ed211104b7c59c5b8 100644 (file)
@@ -75,6 +75,6 @@ struct A {
     x = 30;
     assert_eq!(x, 30);
 
-    (|&: A { x: mut t }: A| { t = t+1; t })(A { x: 34 });
+    (|A { x: mut t }: A| { t = t+1; t })(A { x: 34 });
 
 }
index 2888389bcceabfb4cce2b5f03b500e0f6baecf95..7430f730f3b17d0799c24873434ea9e184128053 100644 (file)
@@ -18,5 +18,5 @@ pub fn main() {
     let s = "\\{20}";
     let mut correct_s = String::from_str("\\");
     correct_s.push_str("{20}");
-    assert_eq!(s, correct_s.as_slice());
+    assert_eq!(s, correct_s);
 }
index a866be43a051473b5b8fcc9fe0921a10b8307414..3710f1b9d3052e2a27c08e3376a44f00f8649d80 100644 (file)
@@ -60,6 +60,6 @@ fn main() {
     }
     unsafe {
         let expected: &[_] = &[1, 2, 3];
-        assert_eq!(expected, ORDER.as_slice());
+        assert_eq!(expected, ORDER);
     }
 }
index c9e2f893c0f34e121775895423a45491802e3062..ca9ee469e38976ec8e49f729de97a428fb17db33 100644 (file)
@@ -35,13 +35,13 @@ fn recurse() {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "recurse" {
+    let args = args;
+    if args.len() > 1 && args[1] == "recurse" {
         let _t = Thread::scoped(recurse);
     } else {
-        let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap();
+        let recurse = Command::new(&args[0]).arg("recurse").output().unwrap();
         assert!(!recurse.status.success());
-        let error = String::from_utf8_lossy(recurse.error.as_slice());
+        let error = String::from_utf8_lossy(&recurse.error);
         println!("wut");
         println!("`{}`", error);
         assert!(error.contains("has overflowed its stack"));
index 846fbd477e04edecbe2039b4b9e0075ce8360881..fba86d74816790438fe07d986d7ccf82c49f5ee4 100644 (file)
@@ -35,13 +35,12 @@ fn recurse() {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "recurse" {
+    if args.len() > 1 && args[1] == "recurse" {
         recurse();
     } else {
-        let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap();
+        let recurse = Command::new(&args[0]).arg("recurse").output().unwrap();
         assert!(!recurse.status.success());
-        let error = String::from_utf8_lossy(recurse.error.as_slice());
+        let error = String::from_utf8_lossy(&recurse.error);
         assert!(error.contains("has overflowed its stack"));
     }
 }
index 97539a076ff1502c1da7169e49a0108c72f20362..7dfd46fb995a207706de5f9326a7c820b1e06275 100644 (file)
@@ -35,20 +35,20 @@ fn loud_recurse() {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "silent" {
+    let args = args;
+    if args.len() > 1 && args[1] == "silent" {
         silent_recurse();
-    } else if args.len() > 1 && args[1].as_slice() == "loud" {
+    } else if args.len() > 1 && args[1] == "loud" {
         loud_recurse();
     } else {
-        let silent = Command::new(args[0].as_slice()).arg("silent").output().unwrap();
+        let silent = Command::new(&args[0]).arg("silent").output().unwrap();
         assert!(!silent.status.success());
-        let error = String::from_utf8_lossy(silent.error.as_slice());
+        let error = String::from_utf8_lossy(&silent.error);
         assert!(error.contains("has overflowed its stack"));
 
-        let loud = Command::new(args[0].as_slice()).arg("loud").output().unwrap();
+        let loud = Command::new(&args[0]).arg("loud").output().unwrap();
         assert!(!loud.status.success());
-        let error = String::from_utf8_lossy(silent.error.as_slice());
+        let error = String::from_utf8_lossy(&silent.error);
         assert!(error.contains("has overflowed its stack"));
     }
 }
index baa9709eb76427aafe406256b427f9491bc652ab..fcf0feb6e30d00652cfc4ca877bd6bd51fd51e7d 100644 (file)
@@ -34,13 +34,13 @@ pub fn main() {
     assert_eq!((i_value, *i.borrow()), (2, 5));
 
     let s = Rc::new("foo".to_string());
-    assert_eq!(s.as_slice(), "foo");
+    assert_eq!(&**s, "foo");
 
     let mut_s = Rc::new(RefCell::new(String::from_str("foo")));
     mut_s.borrow_mut().push_str("bar");
     // 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");
+    assert!(&**mut_s.borrow() == "foobar");
+    assert!(&**mut_s.borrow_mut() == "foobar");
 
     let p = Rc::new(RefCell::new(Point {x: 1, y: 2}));
     p.borrow_mut().x = 3;
index 03fa64fb87fbd31dee4e30462d68ae20ed590bb7..f3091b53e8badc02e5223d2b4a30feb595f0889e 100644 (file)
@@ -82,5 +82,5 @@ pub fn main() {
     // Check the final states.
     assert_eq!(*n, 2);
     let expected: &[_] = &[1, 2];
-    assert_eq!((*v).as_slice(), expected);
+    assert_eq!((*v), expected);
 }
index fdaddca091f8f4995ebb90d6e32dd7c40ca63bb0..f56e7d56fe16aec00df2034f97375ea37f461eb2 100644 (file)
@@ -33,13 +33,13 @@ pub fn main() {
 
     let s = Rc::new("foo".to_string());
     assert_eq!(*s, "foo".to_string());
-    assert_eq!((*s).as_slice(), "foo");
+    assert_eq!((*s), "foo");
 
     let mut_s = Rc::new(RefCell::new(String::from_str("foo")));
     (*(*mut_s).borrow_mut()).push_str("bar");
     // 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");
+    assert!((*(*mut_s).borrow()) == "foobar");
+    assert!((*(*mut_s).borrow_mut()) == "foobar");
 
     let p = Rc::new(RefCell::new(Point {x: 1, y: 2}));
     (*(*p).borrow_mut()).x = 3;
index c718b948f8dc07723f4dfe49a69f351af11775dd..e4f1df2d6376df916c553f21a2e8ec7abbaf7d17 100644 (file)
@@ -14,8 +14,8 @@ struct Foo {
 }
 
 pub fn main() {
-    let f = |&: (x, _): (int, int)| println!("{}", x + 1);
-    let g = |&: Foo { x: x, y: _y }: Foo| println!("{}", x + 1);
+    let f = |(x, _): (int, int)| println!("{}", x + 1);
+    let g = |Foo { x: x, y: _y }: Foo| println!("{}", x + 1);
     f((2, 3));
     g(Foo { x: 1, y: 2 });
 }
index dcaca667fbb4f315331eb54b6c73f7a6b3173704..8b99e8a947cf5877de567e44a0acad1870606c85 100644 (file)
@@ -41,12 +41,12 @@ fn main() {
     // restore original environment
     match old_env {
         None => os::unsetenv("RUN_TEST_NEW_ENV"),
-        Some(val) => os::setenv("RUN_TEST_NEW_ENV", val.as_slice())
+        Some(val) => os::setenv("RUN_TEST_NEW_ENV", val)
     }
 
     let prog = cmd.spawn().unwrap();
     let result = prog.wait_with_output().unwrap();
-    let output = String::from_utf8_lossy(result.output.as_slice());
+    let output = String::from_utf8_lossy(&result.output);
 
     assert!(!output.contains("RUN_TEST_NEW_ENV"),
             "found RUN_TEST_NEW_ENV inside of:\n\n{}", output);
index c6fd55272610957b83f1f05a1c11beb360f4f7f4..15cc128d380db4db7cb62aed971fe25ce7bfb5ce 100644 (file)
@@ -58,12 +58,12 @@ fn main() {
         let p = Command::new(&child_path)
                         .arg(arg)
                         .cwd(&cwd)
-                        .env_set_all(my_env.as_slice())
+                        .env_set_all(&my_env)
                         .spawn().unwrap().wait_with_output().unwrap();
 
         // display the output
-        assert!(old_io::stdout().write(p.output.as_slice()).is_ok());
-        assert!(old_io::stderr().write(p.error.as_slice()).is_ok());
+        assert!(old_io::stdout().write(&p.output).is_ok());
+        assert!(old_io::stderr().write(&p.error).is_ok());
 
         // make sure the child succeeded
         assert!(p.status.success());
@@ -74,7 +74,7 @@ fn main() {
         assert!(my_cwd.ends_with_path(&Path::new(child_dir)));
 
         // check arguments
-        assert_eq!(my_args[1].as_slice(), arg);
+        assert_eq!(&*my_args[1], arg);
 
         // check environment variable
         assert!(my_env.contains(&env));
index 11e8bfa48f694fd11f373dbdfd4fe4b9f8935a83..5d2337e3819aa925daa363d285530ec6c8df1947 100644 (file)
@@ -14,6 +14,7 @@ fn foo() -> int { 42 }
 
 // Test that range syntax works in return statements
 fn return_range_to() -> ::std::ops::RangeTo<i32> { return ..1; }
+fn return_full_range() -> ::std::ops::RangeFull { return ..; }
 
 pub fn main() {
     let mut count = 0;
index c947220f1f858886c19e93a6706db88dc1582c69..cd49094851695df64a5454475015023341ff0dd2 100644 (file)
@@ -55,5 +55,8 @@ fn main() {
 
     let x = [1]..[2];
     assert!(x == (([1])..([2])));
+
+    let y = ..;
+    assert!(y == (..));
 }
 
index 8682d18185fe41b0dbb4b62fec664e1b8e1243fe..6a5da0149947abd8225cc0b4bd02cdf745a4e480 100644 (file)
@@ -24,7 +24,7 @@ fn call_sum(x: &[int]) -> int { x.sum_() }
 
 pub fn main() {
     let x = vec!(1, 2, 3);
-    let y = call_sum(x.as_slice());
+    let y = call_sum(&x);
     println!("y=={}", y);
     assert_eq!(y, 6);
 
index c932116243bffc15bce07f8e5cd22b5094a35db7..441c9d79e79f3832c15a53942db8282068dc4fa1 100644 (file)
@@ -28,7 +28,7 @@ fn main() {
 unsafe fn test_triangle() -> bool {
     static COUNT : uint = 16;
     let mut ascend = repeat(ptr::null_mut()).take(COUNT).collect::<Vec<_>>();
-    let ascend = ascend.as_mut_slice();
+    let ascend = &mut *ascend;
     static ALIGN : uint = 1;
 
     // Checks that `ascend` forms triangle of ascending size formed
@@ -103,7 +103,7 @@ fn idx_to_size(i: uint) -> uint { (i+1) * 10 }
         }
     }
 
-    sanity_check(ascend.as_slice());
+    sanity_check(&*ascend);
     test_1(ascend); // triangle -> square
     test_2(ascend); // square -> triangle
     test_3(ascend); // triangle -> square
@@ -128,10 +128,10 @@ unsafe fn test_1(ascend: &mut [*mut u8]) {
             assert!(old_size < new_size);
 
             ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
 
             ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
         }
     }
 
@@ -143,10 +143,10 @@ unsafe fn test_2(ascend: &mut [*mut u8]) {
             assert!(new_size < old_size);
 
             ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
 
             ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
         }
     }
 
@@ -158,10 +158,10 @@ unsafe fn test_3(ascend: &mut [*mut u8]) {
             assert!(old_size < new_size);
 
             ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
 
             ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
         }
     }
 
@@ -173,10 +173,10 @@ unsafe fn test_4(ascend: &mut [*mut u8]) {
             assert!(new_size < old_size);
 
             ascend[2*i+1] = reallocate(p1, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
 
             ascend[2*i] = reallocate(p0, old_size, new_size, ALIGN);
-            sanity_check(ascend.as_slice());
+            sanity_check(&*ascend);
         }
     }
 }
index f5d46d4ce7c2b221a5c8b9315eb3c68713461a96..16eeb99982e91411c9504b861be391263683c8cd 100644 (file)
@@ -15,10 +15,10 @@ fn foo(x: &[int]) -> int {
 
 pub fn main() {
     let p = vec!(1,2,3,4,5);
-    let r = foo(p.as_slice());
+    let r = foo(&p);
     assert_eq!(r, 1);
 
     let p = vec!(5,4,3,2,1);
-    let r = foo(p.as_slice());
+    let r = foo(&p);
     assert_eq!(r, 5);
 }
index dc6f377e9b279ff6a535dcc1ec7e475ae66ca872..6ebef9f34ad6619d54bd1798288acd183bf532d1 100644 (file)
@@ -24,7 +24,7 @@ pub fn main() {
     let mut i = 3i32;
     assert_eq!(i, 3);
     {
-        let cl = |&mut:| i += 1;
+        let cl = || i += 1;
         let mut cl_box = box_it(box cl);
         cl_box.cl.call_mut(());
     }
index 2cee2ac58b39c4d22fb62d6c1172ae45fcc394e1..bcf74729fdbfba1acf7a3b7c2f5b7c6ea0c08b82 100644 (file)
@@ -20,5 +20,5 @@ fn both<'r>(v: &'r [uint]) -> &'r [uint] {
 
 pub fn main() {
     let v = vec!(1,2,3);
-    both(v.as_slice());
+    both(&v);
 }
index d247f864571067bee3803c527cf00701c9a24a90..1fdf3a92a3fdbdea5fbb4bd419e122374cd0ee9c 100644 (file)
@@ -13,7 +13,7 @@ fn view<T>(x: &[T]) -> &[T] {x}
 
 pub fn main() {
     let v = vec!(1, 2, 3);
-    let x = view(v.as_slice());
-    let y = view(x.as_slice());
+    let x = view(&v);
+    let y = view(x);
     assert!((v[0] == x[0]) && (v[0] == y[0]));
 }
index c4852c9162cab4cfa31ab039f3813d75800d6254..a2b6d569ac9a72f0937219612d86e43c47a0a1be 100644 (file)
 pub fn main() {
     fn explicit() {
         fn test<F>(_x: Option<Box<F>>) where F: FnMut(Box<for<'a> FnMut(&'a int)>) {}
-        test(Some(box |&mut: _f: Box<for<'a> FnMut(&'a int)>| {}));
+        test(Some(box |_f: Box<for<'a> FnMut(&'a int)>| {}));
     }
 
     // The code below is shorthand for the code above (and more likely
     // to represent what one encounters in practice).
     fn implicit() {
         fn test<F>(_x: Option<Box<F>>) where F: FnMut(Box<        FnMut(&   int)>) {}
-        test(Some(box |&mut: _f: Box<        FnMut(&   int)>| {}));
+        test(Some(box |_f: Box<        FnMut(&   int)>| {}));
     }
 
     explicit();
index be7db25201afd0c625394388d3bfca6021d39550..bf789d5364500df680752103028111dccdb92c33 100644 (file)
@@ -21,7 +21,7 @@
 
 use TypeStructure::{TypeInt, TypeFunction};
 use AstKind::{ExprInt, ExprVar, ExprLambda};
-use arena::Arena;
+use arena::TypedArena;
 use std::collections::HashMap;
 use std::mem;
 
@@ -45,17 +45,20 @@ fn eq(&self, other: &TypeStructure<'tcx>) -> bool {
 
 impl<'tcx> Eq for TypeStructure<'tcx> {}
 
+type TyArena<'tcx> = TypedArena<TypeStructure<'tcx>>;
+type AstArena<'ast> = TypedArena<AstStructure<'ast>>;
+
 struct TypeContext<'tcx, 'ast> {
-    ty_arena: &'tcx Arena,
+    ty_arena: &'tcx TyArena<'tcx>,
     types: Vec<Type<'tcx>> ,
     type_table: HashMap<NodeId, Type<'tcx>>,
 
-    ast_arena: &'ast Arena,
+    ast_arena: &'ast AstArena<'ast>,
     ast_counter: uint,
 }
 
 impl<'tcx,'ast> TypeContext<'tcx, 'ast> {
-    fn new(ty_arena: &'tcx Arena, ast_arena: &'ast Arena)
+    fn new(ty_arena: &'tcx TyArena<'tcx>, ast_arena: &'ast AstArena<'ast>)
            -> TypeContext<'tcx, 'ast> {
         TypeContext { ty_arena: ty_arena,
                       types: Vec::new(),
@@ -72,7 +75,7 @@ fn add_type(&mut self, s: TypeStructure<'tcx>) -> Type<'tcx> {
             }
         }
 
-        let ty = self.ty_arena.alloc(|| s);
+        let ty = self.ty_arena.alloc(s);
         self.types.push(ty);
         ty
     }
@@ -85,7 +88,7 @@ fn set_type(&mut self, id: NodeId, ty: Type<'tcx>) -> Type<'tcx> {
     fn ast(&mut self, a: AstKind<'ast>) -> Ast<'ast> {
         let id = self.ast_counter;
         self.ast_counter += 1;
-        self.ast_arena.alloc(|| AstStructure { id: NodeId {id:id}, kind: a })
+        self.ast_arena.alloc(AstStructure { id: NodeId {id:id}, kind: a })
     }
 }
 
@@ -127,8 +130,8 @@ fn compute_types<'tcx,'ast>(tcx: &mut TypeContext<'tcx,'ast>,
 }
 
 pub fn main() {
-    let ty_arena = arena::Arena::new();
-    let ast_arena = arena::Arena::new();
+    let ty_arena = TypedArena::new();
+    let ast_arena = TypedArena::new();
     let mut tcx = TypeContext::new(&ty_arena, &ast_arena);
     let ast = tcx.ast(ExprInt);
     let ty = compute_types(&mut tcx, ast);
index abd5789bb1f7639af518899318c6ddda0e39b152..7198c35944f9a0f5b0e764cb55108a5346375ca0 100644 (file)
@@ -25,6 +25,6 @@ fn call_static_closure(mut cl: closure_box<'static>) {
 }
 
 pub fn main() {
-    let cl_box = box_it(box |&mut:| println!("Hello, world!"));
+    let cl_box = box_it(box || println!("Hello, world!"));
     call_static_closure(cl_box);
 }
index 6a1384ff9339614ed4913f0bf329449eb8f88961..6d72e9774dca839b0982cb7d751f9c4a80ba36af 100644 (file)
@@ -13,9 +13,9 @@ pub fn main() {
     let y = [ 0; 1 ];
 
     print!("[");
-    for xi in &x[] {
-        print!("{:?}, ", &xi[]);
+    for xi in &x[..] {
+        print!("{:?}, ", &xi[..]);
     }
     println!("]");
-    println!("{:?}", &y[]);
+    println!("{:?}", &y[..]);
 }
index 899dc8ddbe90ddd597879cfe756f7d599f406c88..60856ee60425b310f1441f41b5960099f596b7ee 100644 (file)
@@ -13,7 +13,7 @@
 static mut calls: uint = 0;
 
 fn surrounding() {
-    let return_works = |&: n: int| {
+    let return_works = |n: int| {
         unsafe { calls += 1 }
 
         if n >= 0 { return; }
@@ -23,7 +23,7 @@ fn surrounding() {
     return_works(10);
     return_works(20);
 
-    let return_works_proc = |n: int| {
+    let return_works_proc = |n: int| {
         unsafe { calls += 1 }
 
         if n >= 0 { return; }
index efc1913a2055d160749bb40f41e6a6f8fa1dd7bf..ec033b74dd1cde1714b84dbf7b37636ed9aef1a7 100644 (file)
@@ -41,7 +41,7 @@ fn start(argc: int, argv: *const *const u8) -> int {
             ffi::c_str_to_bytes(&ptr).to_vec()
         }).collect::<Vec<_>>()
     };
-    let me = args[0].as_slice();
+    let me = &*args[0];
 
     let x: &[u8] = &[1u8];
     pass(Command::new(me).arg(x).output().unwrap());
@@ -59,7 +59,7 @@ fn start(argc: int, argv: *const *const u8) -> int {
 
 fn pass(output: ProcessOutput) {
     if !output.status.success() {
-        println!("{:?}", str::from_utf8(output.output.as_slice()));
-        println!("{:?}", str::from_utf8(output.error.as_slice()));
+        println!("{:?}", str::from_utf8(&output.output));
+        println!("{:?}", str::from_utf8(&output.error));
     }
 }
index f7fa204d4539cb47fa950e1913ff0d9255fa3f5c..5d6657c7e12e653e9a4bd837dfb4c47b23fb345a 100644 (file)
@@ -48,8 +48,8 @@ pub fn main() {
         info!("bar foo");
     });
 
-    assert_eq!(rx.recv().unwrap().as_slice(), "foo");
-    assert_eq!(rx.recv().unwrap().as_slice(), "foo bar");
-    assert_eq!(rx.recv().unwrap().as_slice(), "bar foo");
+    assert_eq!(rx.recv().unwrap(), "foo");
+    assert_eq!(rx.recv().unwrap(), "foo bar");
+    assert_eq!(rx.recv().unwrap(), "bar foo");
     assert!(rx.recv().is_err());
 }
index 2b2539fac0e2d59ccb13003ffea2e01ac1eb3665..a2706dca7d3ea3d0edb036e724e9f51479cb1c84 100644 (file)
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "segfault" {
+    if args.len() > 1 && args[1] == "segfault" {
         unsafe { *(0 as *mut int) = 1 }; // trigger a segfault
     } else {
-        let segfault = Command::new(args[0].as_slice()).arg("segfault").output().unwrap();
+        let segfault = Command::new(&args[0]).arg("segfault").output().unwrap();
         assert!(!segfault.status.success());
-        let error = String::from_utf8_lossy(segfault.error.as_slice());
+        let error = String::from_utf8_lossy(&segfault.error);
         assert!(!error.contains("has overflowed its stack"));
     }
 }
index 89624c3ac16a339fbb306c297740bd48dd6a36c5..6c9707103b9bb91d8026e11eeb7b73e3b807a44d 100644 (file)
@@ -21,7 +21,7 @@ fn test05_start<F:FnOnce(int)>(f: F) {
 
 fn test05() {
     let three = box 3;
-    let fn_to_send = move|n:int| {
+    let fn_to_send = move|n:int| {
         println!("{}", *three + n); // will copy x into the closure
         assert_eq!(*three, 3);
     };
index bf500bf041723068f43743630b574d942cecaeed..856eb241addc3279eb8131ffb554084ebec1c781 100644 (file)
 
 pub fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() >= 2 && args[1].as_slice() == "signal" {
+    let args = args;
+    if args.len() >= 2 && args[1] == "signal" {
         // Raise a segfault.
         unsafe { *(0 as *mut int) = 0; }
     } else {
-        let status = Command::new(args[0].as_slice()).arg("signal").status().unwrap();
+        let status = Command::new(&args[0]).arg("signal").status().unwrap();
         // Windows does not have signal, so we get exit status 0xC0000028 (STATUS_BAD_STACK).
         match status {
             ExitSignal(_) if cfg!(unix) => {},
index 23a928571766181cb31478bc9a6fcbbecc107ce3..de8f76518fc00c0cbdbe91f0230b2ccd8214dd91 100644 (file)
@@ -26,12 +26,12 @@ fn test() {
 
 fn main() {
     let args = os::args();
-    let args = args.as_slice();
-    if args.len() > 1 && args[1].as_slice() == "test" {
+    let args = args;
+    if args.len() > 1 && args[1] == "test" {
         return test();
     }
 
-    let mut p = Command::new(args[0].as_slice())
+    let mut p = Command::new(&args[0])
                         .arg("test").spawn().unwrap();
     assert!(p.wait().unwrap().success());
 }
index 43e517404cb09b3adc9414f17584d9da7cfae8b2..6e256be69dac74c1d463ebe30f493c2518e0c306 100644 (file)
@@ -13,7 +13,7 @@
 fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     let cmp: &[int] = &[1, 2, 3, 4, 5];
-    assert!(&x[] == cmp);
+    assert!(&x[..] == cmp);
     let cmp: &[int] = &[3, 4, 5];
     assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
@@ -23,7 +23,7 @@ fn main() {
 
     let x: Vec<int> = vec![1, 2, 3, 4, 5];
     let cmp: &[int] = &[1, 2, 3, 4, 5];
-    assert!(&x[] == cmp);
+    assert!(&x[..] == cmp);
     let cmp: &[int] = &[3, 4, 5];
     assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
@@ -34,7 +34,7 @@ fn main() {
     let x: &mut [int] = &mut [1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(&mut x[] == cmp);
+        assert!(&mut x[..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
@@ -52,7 +52,7 @@ fn main() {
     let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(&mut x[] == cmp);
+        assert!(&mut x[..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
index 81db525db28a2a3d40c7053d4fe69785f0a3c31a..59fb24ffc02cd405ded5acb56abf80f63c1348ae 100644 (file)
@@ -80,11 +80,11 @@ fn index_mut(&mut self, _index: &RangeFull) -> &mut Foo {
 
 fn main() {
     let mut x = Foo;
-    &x[];
+    &x[..];
     &x[Foo..];
     &x[..Foo];
     &x[Foo..Foo];
-    &mut x[];
+    &mut x[..];
     &mut x[Foo..];
     &mut x[..Foo];
     &mut x[Foo..Foo];
index fc45e107bb0eb79d38643ee15c1e0bc104eee56e..475af8f2b8ef05fa70cc1f46c6013705024ac8c6 100644 (file)
@@ -20,8 +20,8 @@ macro_rules! check {
             static S: $t = $e;
             let v: $t = $e;
             assert_eq!(S, v);
-            assert_eq!(format!("{:?}", v).as_slice(), $s);
-            assert_eq!(format!("{:?}", S).as_slice(), $s);
+            assert_eq!(format!("{:?}", v), $s);
+            assert_eq!(format!("{:?}", S), $s);
         });*
     }}
 }
index 3c0f9505736a962a0bda461dec549b2b121d65f1..1dbd29a781effb127c488a3769c1a88a39dfbc5b 100644 (file)
@@ -12,7 +12,7 @@
 
 pub fn main() {
     let mut a: Vec<int> = vec!(0, 1, 2, 3, 4, 5, 6);
-    a.as_mut_slice().swap(2, 4);
+    a.swap(2, 4);
     assert_eq!(a[2], 4);
     assert_eq!(a[4], 2);
     let mut n = 42;
index 6695920723aefeb6692346f0e83ce22afc10c29a..4df1ff1481042a91b78430029642ee11b0505e09 100644 (file)
@@ -37,7 +37,7 @@ fn test_tempdir() {
 
 fn test_rm_tempdir() {
     let (tx, rx) = channel();
-    let f = move|:| -> () {
+    let f = move|| -> () {
         let tmp = TempDir::new("test_rm_tempdir").unwrap();
         tx.send(tmp.path().clone()).unwrap();
         panic!("panic to unwind past `tmp`");
@@ -48,7 +48,7 @@ fn test_rm_tempdir() {
 
     let tmp = TempDir::new("test_rm_tempdir").unwrap();
     let path = tmp.path().clone();
-    let f = move|:| -> () {
+    let f = move|| -> () {
         let _tmp = tmp;
         panic!("panic to unwind past `tmp`");
     };
@@ -57,10 +57,11 @@ fn test_rm_tempdir() {
 
     let path;
     {
-        let f = move|:| {
+        let f = move || {
             TempDir::new("test_rm_tempdir").unwrap()
         };
-        let tmp = Thread::scoped(f).join().ok().expect("test_rm_tmdir");
+        // FIXME(#16640) `: TempDir` annotation shouldn't be necessary
+        let tmp: TempDir = Thread::scoped(f).join().ok().expect("test_rm_tmdir");
         path = tmp.path().clone();
         assert!(path.exists());
     }
@@ -78,7 +79,7 @@ fn test_rm_tempdir() {
 
 fn test_rm_tempdir_close() {
     let (tx, rx) = channel();
-    let f = move|:| -> () {
+    let f = move|| -> () {
         let tmp = TempDir::new("test_rm_tempdir").unwrap();
         tx.send(tmp.path().clone()).unwrap();
         tmp.close();
@@ -90,7 +91,7 @@ fn test_rm_tempdir_close() {
 
     let tmp = TempDir::new("test_rm_tempdir").unwrap();
     let path = tmp.path().clone();
-    let f = move|:| -> () {
+    let f = move|| -> () {
         let tmp = tmp;
         tmp.close();
         panic!("panic when unwinding past `tmp`");
@@ -100,10 +101,11 @@ fn test_rm_tempdir_close() {
 
     let path;
     {
-        let f = move|:| {
+        let f = move || {
             TempDir::new("test_rm_tempdir").unwrap()
         };
-        let tmp = Thread::scoped(f).join().ok().expect("test_rm_tmdir");
+        // FIXME(#16640) `: TempDir` annotation shouldn't be necessary
+        let tmp: TempDir = Thread::scoped(f).join().ok().expect("test_rm_tmdir");
         path = tmp.path().clone();
         assert!(path.exists());
         tmp.close();
index 0b650d97e4f55677406984f138c9978e8f903277..26772a5b22c076c140adb0244b7ff98a1e7e28d2 100644 (file)
@@ -44,19 +44,19 @@ struct Goldfyshe {
 }
 
 impl Pet for Catte {
-    fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) }
+    fn name(&self, mut blk: Box<FnMut(&str)>) { blk(&self.name) }
     fn num_legs(&self) -> uint { 4 }
     fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 }
 }
 impl Pet for Dogge {
-    fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) }
+    fn name(&self, mut blk: Box<FnMut(&str)>) { blk(&self.name) }
     fn num_legs(&self) -> uint { 4 }
     fn of_good_pedigree(&self) -> bool {
         self.bark_decibels < 70 || self.tricks_known > 20
     }
 }
 impl Pet for Goldfyshe {
-    fn name(&self, mut blk: Box<FnMut(&str)>) { blk(self.name.as_slice()) }
+    fn name(&self, mut blk: Box<FnMut(&str)>) { blk(&self.name) }
     fn num_legs(&self) -> uint { 0 }
     fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
 }
index b114391a36db0220d7074dbf64683765e21973c7..d33ebeadba86e7008e586df25ab1a99c366b3c96 100644 (file)
@@ -56,8 +56,8 @@ fn main() {
     // Note that every unboxed closure has its own anonymous type,
     // so no two IDs should equal each other, even when compatible
     {
-        let a = id(|&: _: &int, _: &int| {});
-        let b = id(|&: _: &int, _: &int| {});
+        let a = id(|_: &int, _: &int| {});
+        let b = id(|_: &int, _: &int| {});
         assert!(a != b);
     }
 
index b2f6dad998881b344501cbc7d6f30e2356865e75..d7748f247740c2457fd6febe3ef7634d42faaf1d 100644 (file)
@@ -23,10 +23,10 @@ unsafe impl Sync for TestStruct {}
 pub fn main() {
     let x: Vec<_> = (0u..5).collect();
     let expected: &[uint] = &[0,1,2,3,4];
-    assert_eq!(x.as_slice(), expected);
+    assert_eq!(x, expected);
 
     let x = (0u..5).collect::<Vec<_>>();
-    assert_eq!(x.as_slice(), expected);
+    assert_eq!(x, expected);
 
     let y: _ = "hello";
     assert_eq!(y.len(), 5);
index 635e1670aada1bd2be866634b7e3a41df878659d..7e71e1da462fd1efc71fc771507939ec6b21723d 100644 (file)
@@ -24,8 +24,8 @@ fn c<F:FnOnce(int, int) -> int>(f: F) -> int {
 
 fn main() {
     let z: int = 7;
-    assert_eq!(a(move |&: x: int, y| x + y + z), 10);
-    assert_eq!(b(move |&mut: x: int, y| x + y + z), 14);
-    assert_eq!(c(move |x: int, y| x + y + z), 18);
+    assert_eq!(a(move |x: int, y| x + y + z), 10);
+    assert_eq!(b(move |x: int, y| x + y + z), 14);
+    assert_eq!(c(move |x: int, y| x + y + z), 18);
 }
 
index 27528ca5d5663671c3a2fdfd4114385d6479b752..d515ccf2ec0a50ca8e4367210004e298b2850a05 100644 (file)
@@ -15,7 +15,7 @@
 use std::ops::FnMut;
 
  fn make_adder(x: i32) -> Box<FnMut(i32)->i32+'static> {
-    (box move |&mut: y: i32| -> i32 { x + y }) as
+    (box move |y: i32| -> i32 { x + y }) as
         Box<FnMut(i32)->i32+'static>
 }
 
index be955486dac33d75ce2a8f2939c844d2adc095c7..f1435b43f80179d6c0f2f4af7ae25b3ea781e624 100644 (file)
@@ -28,8 +28,8 @@ fn main() {
     let mut x = 0u;
     let y = 2u;
 
-    call_fn(|&:| assert_eq!(x, 0));
-    call_fn_mut(|&mut:| x += y);
-    call_fn_once(|:| x += y);
+    call_fn(|| assert_eq!(x, 0));
+    call_fn_mut(|| x += y);
+    call_fn_once(|| x += y);
     assert_eq!(x, y * 2);
 }
index 2854d64f6637b8dec6e8fd78b70637b7ea6efb06..0c49c8151708625ac095a0a639a9410240a6ffe4 100644 (file)
@@ -11,7 +11,7 @@
 #![feature(unboxed_closures)]
 
 fn main() {
-    let mut unboxed = |&mut:| {};
+    let mut unboxed = || {};
     unboxed();
 }
 
index 8d4d7b4ecb5033ad8873d1b51e93163b3e1cf209..f4a24c17e6e99834736346f868bb66bd8a46df9b 100644 (file)
@@ -55,13 +55,13 @@ fn c<F:FnOnce(int, int) -> int>(f: F) -> int {
 
 fn test_fn() {
     {
-        a(move |&: a: int, b| { a + b });
+        a(move |a: int, b| { a + b });
     }
     assert_eq!(drop_count(), 0);
 
     {
         let z = &Droppable::new();
-        a(move |&: a: int, b| { z; a + b });
+        a(move |a: int, b| { z; a + b });
         assert_eq!(drop_count(), 0);
     }
     assert_eq!(drop_count(), 1);
@@ -69,7 +69,7 @@ fn test_fn() {
     {
         let z = &Droppable::new();
         let zz = &Droppable::new();
-        a(move |&: a: int, b| { z; zz; a + b });
+        a(move |a: int, b| { z; zz; a + b });
         assert_eq!(drop_count(), 1);
     }
     assert_eq!(drop_count(), 3);
@@ -77,13 +77,13 @@ fn test_fn() {
 
 fn test_fn_mut() {
     {
-        b(move |&mut: a: int, b| { a + b });
+        b(move |a: int, b| { a + b });
     }
     assert_eq!(drop_count(), 3);
 
     {
         let z = &Droppable::new();
-        b(move |&mut: a: int, b| { z; a + b });
+        b(move |a: int, b| { z; a + b });
         assert_eq!(drop_count(), 3);
     }
     assert_eq!(drop_count(), 4);
@@ -91,7 +91,7 @@ fn test_fn_mut() {
     {
         let z = &Droppable::new();
         let zz = &Droppable::new();
-        b(move |&mut: a: int, b| { z; zz; a + b });
+        b(move |a: int, b| { z; zz; a + b });
         assert_eq!(drop_count(), 4);
     }
     assert_eq!(drop_count(), 6);
@@ -99,13 +99,13 @@ fn test_fn_mut() {
 
 fn test_fn_once() {
     {
-        c(move |a: int, b| { a + b });
+        c(move |a: int, b| { a + b });
     }
     assert_eq!(drop_count(), 6);
 
     {
         let z = Droppable::new();
-        c(move |a: int, b| { z; a + b });
+        c(move |a: int, b| { z; a + b });
         assert_eq!(drop_count(), 7);
     }
     assert_eq!(drop_count(), 7);
@@ -113,7 +113,7 @@ fn test_fn_once() {
     {
         let z = Droppable::new();
         let zz = Droppable::new();
-        c(move |a: int, b| { z; zz; a + b });
+        c(move |a: int, b| { z; zz; a + b });
         assert_eq!(drop_count(), 9);
     }
     assert_eq!(drop_count(), 9);
index 04c124946c9a1edb28697a81b62d3205e871ba22..f4af42a866b6d6a83c478c60311f7b46165f3c2e 100644 (file)
@@ -17,7 +17,7 @@ fn call_it<F:FnMut(i32,i32)->i32>(y: i32, mut f: F) -> i32 {
 }
 
 pub fn main() {
-    let f = |&mut: x: i32, y: i32| -> i32 { x + y };
+    let f = |x: i32, y: i32| -> i32 { x + y };
     let z = call_it(3, f);
     println!("{}", z);
     assert_eq!(z, 5);
index 5bebc70ca542227ce259ff85792fbe94f81108e8..56de15961101f063f9da4785c6e6eb1c0086a919 100644 (file)
@@ -22,5 +22,5 @@ fn doit<T,F>(val: T, f: &F)
 }
 
 pub fn main() {
-    doit(0, &|&: x /*: int*/ | { x.to_int(); });
+    doit(0, &|x /*: int*/ | { x.to_int(); });
 }
index a678c7a852ff59263a9f6d182fd4ea73bf708409..c74ed665e7a071d9d70f6c98c306a5e44538245b 100644 (file)
@@ -18,5 +18,5 @@
 fn doit<T>(val: T, f: &Fn(T)) { f.call((val,)) }
 
 pub fn main() {
-    doit(0, &|&: x /*: int*/ | { x.to_int(); });
+    doit(0, &|x /*: int*/ | { x.to_int(); });
 }
index 6e0b3625a2ee5750b29bd3dab123f8347663523d..a61dd095a0d4da2e6792afcc1bfeef3bb8637e8a 100644 (file)
@@ -22,5 +22,5 @@ fn doit<T,F>(val: T, f: &F)
 }
 
 pub fn main() {
-    doit(0, &|&: x /*: int*/ | { x.to_int(); });
+    doit(0, &|x /*: int*/ | { x.to_int(); });
 }
index 29064f4805339aaa17b7575c75a1840364a68cec..535c4562362c0d3ba9620e768aa66a9855ba4ad3 100644 (file)
@@ -17,7 +17,7 @@
 
 fn main(){
     fn bar<'a, T:Clone+'a> (t: T) -> Box<FnMut()->T + 'a> {
-        box move |&mut:| t.clone()
+        box move || t.clone()
     }
 
     let mut f = bar(42_u32);
index 43a44eca2d05ef0682993107c53fdc8d90a656ae..0d04aee2a1519dc3e885b794416c7f4e3df4abce 100644 (file)
 fn main() {
     {
         let mut x = 0u;
-        move |&mut:| x += 1;
+        move || x += 1;
     }
     {
         let mut x = 0u;
-        move |:| x += 1;
+        move || x += 1;
     }
     {
         let mut x = 0u;
-        move |&mut:| set(&mut x);
+        move || set(&mut x);
     }
     {
         let mut x = 0u;
-        move |:| set(&mut x);
+        move || set(&mut x);
     }
 }
index f9fc5770a381426061eb0b903c928ff69010d8d8..c8f0d5fde45efea490bee262988152a5cd764987 100644 (file)
 #![feature(unboxed_closures)]
 
 fn main() {
-    let task: Box<Fn(int) -> int> = box |&: x| x;
+    let task: Box<Fn(int) -> int> = box |x| x;
     task.call((0, ));
 
-    let mut task: Box<FnMut(int) -> int> = box |&mut: x| x;
+    let mut task: Box<FnMut(int) -> int> = box |x| x;
     task(0);
 
-    call(|:x| x, 22);
+    call(|x| x, 22);
 }
 
 fn call<F:FnOnce(int) -> int>(f: F, x: int) -> int {
index c473db4586ff74283027b4873708ec42d9c0b244..9f29e75be7ccaec301935a0a4b14b38188291fec 100644 (file)
@@ -13,7 +13,7 @@
 use std::ops::FnMut;
 
 pub fn main() {
-    let mut f = |&mut: x: int, y: int| -> int { x + y };
+    let mut f = |x: int, y: int| -> int { x + y };
     let z = f(1, 2);
     assert_eq!(z, 3);
 }
index 61ceb5e140e32bcb102adc9f8ad46fba0a2e63ee..9e543f925f82e2acdc60e1f1f5e0eb6b9a8be197 100644 (file)
@@ -27,8 +27,8 @@ fn c<F:FnOnce(int, int) -> int>(f: F) -> int {
 
 fn main() {
     let z = 10;
-    assert_eq!(a(move |&: x: int, y| x + y + z), 13);
-    assert_eq!(b(move |&mut: x: int, y| x + y + z), 17);
-    assert_eq!(c(move |x: int, y| x + y + z), 21);
+    assert_eq!(a(move |x: int, y| x + y + z), 13);
+    assert_eq!(b(move |x: int, y| x + y + z), 17);
+    assert_eq!(c(move |x: int, y| x + y + z), 21);
 }
 
index e4b35aada9f6b8e7acfee656a2040c4f2096b2fd..7a6b68a5e09ec27113ad716f830cf6e5d120f68a 100644 (file)
@@ -11,7 +11,7 @@
 #![feature(unboxed_closures)]
 
 fn main() {
-    let onetime = |x| x;
+    let onetime = |x| x;
     onetime(0);
 }
 
index a04301931da6a941e03048046e977c3a0500565d..2871b5c68620396c9e1815e832084724bb30f9a2 100644 (file)
@@ -30,6 +30,6 @@ pub fn replace_map<'a, T, F>(src: &mut T, prod: F) where F: FnOnce(T) -> T {
 pub fn main() {
     let mut a = 7u;
     let b = &mut a;
-    replace_map(b, |x: uint| x * 2);
+    replace_map(b, |x: uint| x * 2);
     assert_eq!(*b, 14u);
 }
index 3c50712b4647f1d6c7c115468861cac7d0a40a72..0acf736e2ab5c5e8403c0bfd2269a57e8dfa5733 100644 (file)
@@ -27,5 +27,5 @@ pub fn main() {
     }).join();
 
     let s = x.err().unwrap().downcast::<&'static str>().ok().unwrap();
-    assert_eq!(s.as_slice(), "This panic should happen.");
+    assert_eq!(&**s, "This panic should happen.");
 }
index a2d1b8780aafffc856eb441707d4b24113530e58..4e8fdda95631185c9fc4541c41e4af2b947c3491 100644 (file)
@@ -13,6 +13,6 @@
 
 pub fn main() {
     let _x = box 1;
-    let lam_move = |&:| {};
+    let lam_move = || {};
     lam_move();
 }
index 02a791e7975193c959852ede408dab245b8f8c59..64c4c17386b3253341153b4fff7a0312105d8435 100644 (file)
@@ -14,7 +14,7 @@ pub fn main() {
     let a: Vec<int> = vec!(1, 2, 3, 4, 5);
     let b: Vec<int> = vec!(6, 7, 8, 9, 0);
     let mut v: Vec<int> = a;
-    v.push_all(b.as_slice());
+    v.push_all(&b);
     println!("{}", v[9]);
     assert_eq!(v[0], 1);
     assert_eq!(v[7], 8);
index 9d83c0b007996cec77674df1b8d25e2d1547220a..d13369b1f5258f9d29dd0a08aa6bd8daa20c5575 100644 (file)
@@ -68,7 +68,7 @@ pub fn main() {
             // work out the total number of comparisons required to sort
             // this array...
             let mut count = 0us;
-            main.clone().as_mut_slice().sort_by(|a, b| { count += 1; a.cmp(b) });
+            main.clone().sort_by(|a, b| { count += 1; a.cmp(b) });
 
             // ... and then panic on each and every single one.
             for panic_countdown in 0..count {
@@ -82,7 +82,7 @@ pub fn main() {
                 let _ = Thread::scoped(move|| {
                     let mut v = v;
                     let mut panic_countdown = panic_countdown;
-                    v.as_mut_slice().sort_by(|a, b| {
+                    v.sort_by(|a, b| {
                         if panic_countdown == 0 {
                             panic!()
                         }
index 12de40129fd2ff28e0c5e10597d9af177320a92c..dcbecb859e53720eaee053499769b03c0fa66447 100644 (file)
@@ -35,7 +35,7 @@ fn find_zombies() {
 
     // http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html
     let ps_cmd_output = Command::new("ps").args(&["-A", "-o", "pid,ppid,args"]).output().unwrap();
-    let ps_output = String::from_utf8_lossy(ps_cmd_output.output.as_slice());
+    let ps_output = String::from_utf8_lossy(&ps_cmd_output.output);
 
     for (line_no, line) in ps_output.split('\n').enumerate() {
         if 0 < line_no && 0 < line.len() &&
@@ -56,7 +56,7 @@ fn main() {
     let too_long = format!("/NoSuchCommand{:0300}", 0u8);
 
     let _failures = (0..100).map(|_| {
-        let cmd = Command::new(too_long.as_slice());
+        let cmd = Command::new(&too_long);
         let failed = cmd.spawn();
         assert!(failed.is_err(), "Make sure the command fails to spawn(): {:?}", cmd);
         failed
index 4080796b7a74114326772abee303409f8f8f8a8d..c9f070a279c76f30becf5bfe8aab65c151282de3 100644 (file)
@@ -26,7 +26,7 @@ fn the(x: &Cell<bool>) {
         return while !x.get() { x.set(true); };
     }
     let i = &Cell::new(false);
-    let dont = {|&:|the(i)};
+    let dont = {||the(i)};
     dont();
     assert!((i.get()));
 }
index 808e937bc72e3d1c0ad46a6b3a773d4ac50535fe..7edcdf6429223d960d5c09df113f4e1b259e8c74 100644 (file)
@@ -18,9 +18,9 @@ fn warm_up<'a, F>(f: F) where F: Fn(&'a mut Bencher) {
 
 fn main() {
     // ICE trigger
-    warm_up(|&: b: &mut Bencher| () );
+    warm_up(|b: &mut Bencher| () );
 
     // OK
-    warm_up(|&: b| () );
+    warm_up(|b| () );
 }